@vpmedia/simplify 1.13.0 → 1.15.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/README.md +1 -1
- package/eslint.config.js +0 -1
- package/package.json +2 -2
- package/src/index.js +0 -1
- package/src/pagelifecycle/util.js +3 -3
- package/src/util/fetchRetry.js +13 -5
- package/types/pagelifecycle/util.d.ts +3 -3
- package/types/pagelifecycle/util.d.ts.map +1 -1
- package/types/util/fetchRetry.d.ts +6 -4
- package/types/util/fetchRetry.d.ts.map +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @vpmedia/simplify
|
|
2
2
|
|
|
3
|
-
[](https://badge.fury.io/js/@vpmedia%2Fsimplify)
|
|
4
4
|
[](https://github.com/vpmedia/simplify/actions/workflows/ci.yml)
|
|
5
5
|
|
|
6
6
|
@vpmedia/simplify TBD
|
package/eslint.config.js
CHANGED
|
@@ -51,7 +51,6 @@ export default [
|
|
|
51
51
|
...js.configs.recommended.rules,
|
|
52
52
|
...jsdocPlugin.configs['flat/recommended'].rules,
|
|
53
53
|
...unicornPlugin.configs['flat/recommended'].rules,
|
|
54
|
-
'unicorn/expiring-todo-comments': 'off',
|
|
55
54
|
'unicorn/filename-case': 'off',
|
|
56
55
|
'unicorn/no-null': 'off',
|
|
57
56
|
'unicorn/prevent-abbreviations': 'off',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vpmedia/simplify",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.15.0",
|
|
4
4
|
"description": "@vpmedia/simplify",
|
|
5
5
|
"author": "Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)",
|
|
6
6
|
"license": "MIT",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"@types/jest": "^29.5.14",
|
|
26
26
|
"eslint": "^9.15.0",
|
|
27
27
|
"eslint-plugin-jsdoc": "^50.5.0",
|
|
28
|
-
"eslint-plugin-unicorn": "^56.0.
|
|
28
|
+
"eslint-plugin-unicorn": "^56.0.1",
|
|
29
29
|
"globals": "^15.12.0",
|
|
30
30
|
"jest": "^29.7.0",
|
|
31
31
|
"jest-environment-jsdom": "^29.7.0",
|
package/src/index.js
CHANGED
|
@@ -36,7 +36,7 @@ let callbacks = {};
|
|
|
36
36
|
* @param {import('./typedef.js').DocumentState | import('./typedef.js').PageLifecycleState} state - Callback state condition.
|
|
37
37
|
* @param {() => void} callback - Callback function.
|
|
38
38
|
*/
|
|
39
|
-
export const
|
|
39
|
+
export const addPageLifecycleCallback = (state, callback) => {
|
|
40
40
|
const stateCallbacks = callbacks[state] ?? [];
|
|
41
41
|
stateCallbacks.push(callback);
|
|
42
42
|
callbacks[state] = stateCallbacks;
|
|
@@ -148,7 +148,7 @@ export const getDocumentState = () => {
|
|
|
148
148
|
* Returns the event emitter instance.
|
|
149
149
|
* @returns {EventEmitter} Event emitter instance.
|
|
150
150
|
*/
|
|
151
|
-
export const
|
|
151
|
+
export const getPageLifecycleEventEmitter = () => {
|
|
152
152
|
if (!isInitialized) {
|
|
153
153
|
initPageLifecycle();
|
|
154
154
|
}
|
|
@@ -159,6 +159,6 @@ export const getEventEmitter = () => {
|
|
|
159
159
|
* Returns the page lifecycle observer initialized state.
|
|
160
160
|
* @returns {boolean} Page lifecycle observer initialized flag.
|
|
161
161
|
*/
|
|
162
|
-
export const
|
|
162
|
+
export const isPageLifecycleInitialized = () => {
|
|
163
163
|
return isInitialized;
|
|
164
164
|
};
|
package/src/util/fetchRetry.js
CHANGED
|
@@ -10,12 +10,15 @@ export class FetchError extends Error {
|
|
|
10
10
|
/**
|
|
11
11
|
* Creates a new FetchError instance.
|
|
12
12
|
* @param {string} message - Error message.
|
|
13
|
-
* @param {
|
|
14
|
-
* @param {
|
|
13
|
+
* @param {string | URL | Request} resource - Fetch URL.
|
|
14
|
+
* @param {RequestInit} fetchOptions - Fetch options.
|
|
15
|
+
* @param {Response} response - Fetch response.
|
|
15
16
|
*/
|
|
16
|
-
constructor(message,
|
|
17
|
+
constructor(message, resource, fetchOptions, response) {
|
|
17
18
|
super(message);
|
|
18
|
-
this.
|
|
19
|
+
this.name = 'FetchError';
|
|
20
|
+
this.resource = resource;
|
|
21
|
+
this.fetchOptions = fetchOptions;
|
|
19
22
|
this.response = response;
|
|
20
23
|
}
|
|
21
24
|
}
|
|
@@ -42,7 +45,12 @@ export const fetchRetry = async (resource, fetchOptions, retryOptions) => {
|
|
|
42
45
|
const response = await fetch(resource, fetchOptions);
|
|
43
46
|
if (!response.ok) {
|
|
44
47
|
logger.warn('failure', response);
|
|
45
|
-
throw new FetchError(
|
|
48
|
+
throw new FetchError(
|
|
49
|
+
`fetch ${response.url} returned status ${response.status}`,
|
|
50
|
+
resource,
|
|
51
|
+
fetchOptions,
|
|
52
|
+
response
|
|
53
|
+
);
|
|
46
54
|
}
|
|
47
55
|
logger.info('success', response);
|
|
48
56
|
return response;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export function
|
|
1
|
+
export function addPageLifecycleCallback(state: import("./typedef.js").DocumentState | import("./typedef.js").PageLifecycleState, callback: () => void): void;
|
|
2
2
|
export function initPageLifecycle(): void;
|
|
3
3
|
export function getPageLifecycleState(): string;
|
|
4
4
|
export function getDocumentState(): import("./typedef.js").DocumentState;
|
|
5
|
-
export function
|
|
6
|
-
export function
|
|
5
|
+
export function getPageLifecycleEventEmitter(): EventEmitter;
|
|
6
|
+
export function isPageLifecycleInitialized(): boolean;
|
|
7
7
|
import { EventEmitter } from 'eventemitter3';
|
|
8
8
|
//# sourceMappingURL=util.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../src/pagelifecycle/util.js"],"names":[],"mappings":"AAsCO,
|
|
1
|
+
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../src/pagelifecycle/util.js"],"names":[],"mappings":"AAsCO,gDAHI,OAAO,cAAc,EAAE,aAAa,GAAG,OAAO,cAAc,EAAE,kBAAkB,YAChF,MAAM,IAAI,QAMpB;AAgEM,0CAsBN;AAMM,yCAFM,MAAM,CAIlB;AAMM,oCAFM,OAAO,cAAc,EAAE,aAAa,CAIhD;AAMM,gDAFM,YAAY,CAOxB;AAMM,8CAFM,OAAO,CAInB;6BA9J4B,eAAe"}
|
|
@@ -3,11 +3,13 @@ export class FetchError extends Error {
|
|
|
3
3
|
/**
|
|
4
4
|
* Creates a new FetchError instance.
|
|
5
5
|
* @param {string} message - Error message.
|
|
6
|
-
* @param {
|
|
7
|
-
* @param {
|
|
6
|
+
* @param {string | URL | Request} resource - Fetch URL.
|
|
7
|
+
* @param {RequestInit} fetchOptions - Fetch options.
|
|
8
|
+
* @param {Response} response - Fetch response.
|
|
8
9
|
*/
|
|
9
|
-
constructor(message: string,
|
|
10
|
-
|
|
10
|
+
constructor(message: string, resource: string | URL | Request, fetchOptions: RequestInit, response: Response);
|
|
11
|
+
resource: string | URL | Request;
|
|
12
|
+
fetchOptions: RequestInit;
|
|
11
13
|
response: Response;
|
|
12
14
|
}
|
|
13
15
|
export function fetchRetry(resource: string | URL | Request, fetchOptions?: RequestInit, retryOptions?: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetchRetry.d.ts","sourceRoot":"","sources":["../../src/util/fetchRetry.js"],"names":[],"mappings":"AAMA,2BAA4B;AAE5B;IACE
|
|
1
|
+
{"version":3,"file":"fetchRetry.d.ts","sourceRoot":"","sources":["../../src/util/fetchRetry.js"],"names":[],"mappings":"AAMA,2BAA4B;AAE5B;IACE;;;;;;OAMG;IACH,qBALW,MAAM,YACN,MAAM,GAAG,GAAG,GAAG,OAAO,gBACtB,WAAW,YACX,QAAQ,EAQlB;IAHC,iCAAwB;IACxB,0BAAgC;IAChC,mBAAwB;CAE3B;AASM,qCALI,MAAM,GAAG,GAAG,GAAG,OAAO,iBACtB,WAAW,iBACX;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,cAAc,CAAC,EAAE,MAAM,EAAE,CAAA;CAAC,GAC5D,OAAO,CAAC,QAAQ,CAAC,CA0C7B"}
|