@alessiofrittoli/fetcher 1.0.0 → 2.0.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 +83 -48
- package/dist/error/index.cjs +1 -0
- package/dist/error/index.d.cts +2 -0
- package/dist/error/index.d.mts +2 -0
- package/dist/error/index.mjs +1 -0
- package/dist/getErrorFromResponse-CIppVMTN.mjs +1 -0
- package/dist/getErrorFromResponse-D3OARgUA.cjs +1 -0
- package/dist/globals/index.d.cts +15 -0
- package/dist/globals/index.d.mts +15 -0
- package/dist/globals/index.mjs +1 -0
- package/dist/index-B8rmZCit.d.mts +398 -0
- package/dist/index-CQSGH5s-.d.cts +25 -0
- package/dist/index-CQSGH5s-.d.mts +25 -0
- package/dist/index-D-vZzzH1.d.cts +398 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.cts +17 -0
- package/dist/index.d.mts +16 -11
- package/dist/index.mjs +1 -0
- package/dist/ping/index.cjs +1 -0
- package/dist/ping/index.d.cts +9 -0
- package/dist/ping/index.d.mts +9 -0
- package/dist/ping/index.mjs +1 -0
- package/dist/types/index.cjs +0 -0
- package/dist/types/index.d.cts +2 -0
- package/dist/types/index.d.mts +2 -0
- package/dist/types/index.mjs +1 -0
- package/dist/xhr/index.cjs +1 -0
- package/dist/xhr/index.d.cts +2 -0
- package/dist/xhr/index.d.mts +2 -8
- package/dist/xhr/index.mjs +1 -1
- package/package.json +127 -155
- package/dist/chunk-HNNMLJIA.js +0 -1
- package/dist/chunk-LOWOZ6LK.mjs +0 -1
- package/dist/error.d.mts +0 -13
- package/dist/error.d.ts +0 -13
- package/dist/error.js +0 -1
- package/dist/error.mjs +0 -1
- package/dist/fetch.d.mts +0 -23
- package/dist/fetch.d.ts +0 -23
- package/dist/fetch.js +0 -1
- package/dist/fetch.mjs +0 -1
- package/dist/getErrorFromResponse-7V2YFS4F.js +0 -1
- package/dist/getErrorFromResponse-IJTUOFPH.mjs +0 -1
- package/dist/index.d.ts +0 -12
- package/dist/index.js +0 -1
- package/dist/logReadyStateChange-2QWX5XIU.mjs +0 -1
- package/dist/logReadyStateChange-MSYI3OBQ.js +0 -1
- package/dist/ping.d.mts +0 -8
- package/dist/ping.d.ts +0 -8
- package/dist/ping.js +0 -1
- package/dist/ping.mjs +0 -1
- package/dist/types-CVc-rxXe.d.ts +0 -227
- package/dist/types-DuGUXaTD.d.mts +0 -227
- package/dist/types.d.mts +0 -8
- package/dist/types.d.ts +0 -8
- package/dist/types.js +0 -1
- package/dist/xhr/index.d.ts +0 -8
- package/dist/xhr/index.js +0 -1
- package/scripts/postinstall/index.js +0 -16
- package/scripts/postinstall/ts-setup.js +0 -15
- /package/dist/{types.mjs → globals/index.cjs} +0 -0
package/package.json
CHANGED
|
@@ -1,156 +1,128 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
"@jest/globals": "^30.2.0",
|
|
130
|
-
"@types/jest": "^30.0.0",
|
|
131
|
-
"@types/node": "^24.10.1",
|
|
132
|
-
"concurrently": "^9.2.1",
|
|
133
|
-
"cross-env": "^10.1.0",
|
|
134
|
-
"dotenv": "^17.2.3",
|
|
135
|
-
"eslint": "^9.39.1",
|
|
136
|
-
"globals": "^16.5.0",
|
|
137
|
-
"http-server": "^14.1.1",
|
|
138
|
-
"jest": "^30.2.0",
|
|
139
|
-
"jest-environment-jsdom": "^30.2.0",
|
|
140
|
-
"ts-jest": "^29.4.6",
|
|
141
|
-
"ts-node": "^10.9.2",
|
|
142
|
-
"tsup": "^8.5.1",
|
|
143
|
-
"typescript": "^5.9.3",
|
|
144
|
-
"typescript-eslint": "^8.48.1"
|
|
145
|
-
},
|
|
146
|
-
"dependencies": {
|
|
147
|
-
"@alessiofrittoli/abort-controller": "^0.1.0",
|
|
148
|
-
"@alessiofrittoli/chain-functions": "^2.5.0",
|
|
149
|
-
"@alessiofrittoli/event-emitter": "^1.6.0",
|
|
150
|
-
"@alessiofrittoli/exception": "^3.3.1",
|
|
151
|
-
"@alessiofrittoli/node-scripts": "^3.2.0",
|
|
152
|
-
"@alessiofrittoli/type-utils": "^1.9.0",
|
|
153
|
-
"@alessiofrittoli/url-utils": "^3.7.1",
|
|
154
|
-
"@alessiofrittoli/web-utils": "^1.18.0"
|
|
155
|
-
}
|
|
156
|
-
}
|
|
2
|
+
"name": "@alessiofrittoli/fetcher",
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"description": "Typescript fetch/xhr utilities",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"author": {
|
|
7
|
+
"name": "Alessio Frittoli",
|
|
8
|
+
"email": "info@alessiofrittoli.it",
|
|
9
|
+
"url": "https://alessiofrittoli.it"
|
|
10
|
+
},
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"funding": [
|
|
13
|
+
{
|
|
14
|
+
"type": "github",
|
|
15
|
+
"url": "https://github.com/sponsors/alessiofrittoli"
|
|
16
|
+
}
|
|
17
|
+
],
|
|
18
|
+
"keywords": [
|
|
19
|
+
"fetch",
|
|
20
|
+
"xhr",
|
|
21
|
+
"XMLHttpRequest",
|
|
22
|
+
"ping"
|
|
23
|
+
],
|
|
24
|
+
"homepage": "https://github.com/alessiofrittoli/fetcher#readme",
|
|
25
|
+
"bugs": {
|
|
26
|
+
"url": "https://github.com/alessiofrittoli/fetcher/issues",
|
|
27
|
+
"email": "info@alessiofrittoli.it"
|
|
28
|
+
},
|
|
29
|
+
"repository": {
|
|
30
|
+
"type": "git",
|
|
31
|
+
"url": "git+https://github.com/alessiofrittoli/fetcher.git"
|
|
32
|
+
},
|
|
33
|
+
"engines": {
|
|
34
|
+
"node": ">=24.15.0",
|
|
35
|
+
"pnpm": ">=11.27.1"
|
|
36
|
+
},
|
|
37
|
+
"main": "./dist/index.cjs",
|
|
38
|
+
"module": "./dist/index.mjs",
|
|
39
|
+
"types": "./dist/index.d.mts",
|
|
40
|
+
"files": [
|
|
41
|
+
"dist"
|
|
42
|
+
],
|
|
43
|
+
"exports": {
|
|
44
|
+
".": {
|
|
45
|
+
"import": {
|
|
46
|
+
"types": "./dist/index.d.mts",
|
|
47
|
+
"default": "./dist/index.mjs"
|
|
48
|
+
},
|
|
49
|
+
"require": {
|
|
50
|
+
"types": "./dist/index.d.cts",
|
|
51
|
+
"default": "./dist/index.cjs"
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
"./*": {
|
|
55
|
+
"import": {
|
|
56
|
+
"types": "./dist/*/index.d.mts",
|
|
57
|
+
"default": "./dist/*/index.mjs"
|
|
58
|
+
},
|
|
59
|
+
"require": {
|
|
60
|
+
"types": "./dist/*/index.d.cts",
|
|
61
|
+
"default": "./dist/*/index.cjs"
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
"sideEffects": false,
|
|
66
|
+
"peerDependencies": {
|
|
67
|
+
"@alessiofrittoli/abort-controller": "^1.0.0",
|
|
68
|
+
"@alessiofrittoli/chain-functions": "^2.7.0",
|
|
69
|
+
"@alessiofrittoli/crypto-buffer": "^3.11.0",
|
|
70
|
+
"@alessiofrittoli/event-emitter": "^1.7.0",
|
|
71
|
+
"@alessiofrittoli/exception": "^4.1.1",
|
|
72
|
+
"@alessiofrittoli/math-utils": "^2.1.0",
|
|
73
|
+
"@alessiofrittoli/node-scripts": "^3.3.0",
|
|
74
|
+
"@alessiofrittoli/type-utils": "^2.0.0",
|
|
75
|
+
"@alessiofrittoli/url-utils": "^4.1.0",
|
|
76
|
+
"@alessiofrittoli/web-utils": "^2.4.0"
|
|
77
|
+
},
|
|
78
|
+
"devDependencies": {
|
|
79
|
+
"@alessiofrittoli/abort-controller": "^1.0.0",
|
|
80
|
+
"@alessiofrittoli/chain-functions": "^2.7.0",
|
|
81
|
+
"@alessiofrittoli/crypto-buffer": "^3.11.0",
|
|
82
|
+
"@alessiofrittoli/event-emitter": "^1.7.0",
|
|
83
|
+
"@alessiofrittoli/exception": "^4.1.1",
|
|
84
|
+
"@alessiofrittoli/math-utils": "^2.1.0",
|
|
85
|
+
"@alessiofrittoli/node-scripts": "^4.1.0",
|
|
86
|
+
"@alessiofrittoli/package-configs": "^1.6.0",
|
|
87
|
+
"@alessiofrittoli/type-utils": "^2.0.0",
|
|
88
|
+
"@alessiofrittoli/url-utils": "^4.1.0",
|
|
89
|
+
"@alessiofrittoli/web-utils": "^2.4.0",
|
|
90
|
+
"@types/node": "^24.19.1",
|
|
91
|
+
"@vitest/coverage-v8": "^5.0.5",
|
|
92
|
+
"concurrently": "^10.0.6",
|
|
93
|
+
"http-server": "^14.1.1",
|
|
94
|
+
"oxlint": "^1.89.0",
|
|
95
|
+
"prettier": "^3.9.10",
|
|
96
|
+
"prettier-plugin-sort-imports": "^1.8.11",
|
|
97
|
+
"tsdown": "^0.23.1",
|
|
98
|
+
"typescript": "^6.0.3",
|
|
99
|
+
"vite": "^8.3.5",
|
|
100
|
+
"vitest": "^5.0.5"
|
|
101
|
+
},
|
|
102
|
+
"scripts": {
|
|
103
|
+
"//1a": "*********************************************************************",
|
|
104
|
+
"//1b": "******************** DEV - BUILD - LINT - RELEASE *******************",
|
|
105
|
+
"//1c": "*********************************************************************",
|
|
106
|
+
"dev": "tsdown --watch",
|
|
107
|
+
"build": "pnpm lint && pnpm tsc && pnpm tsdown",
|
|
108
|
+
"lint": "oxlint --report-unused-disable-directives --max-warnings 0",
|
|
109
|
+
"release": "node scripts/release.ts --verbose --npm",
|
|
110
|
+
"//2a": "*********************************************************************",
|
|
111
|
+
"//2b": "***************************** UNIT TESTS ****************************",
|
|
112
|
+
"//2c": "*********************************************************************",
|
|
113
|
+
"test": "vitest --reporter=tree",
|
|
114
|
+
"test:watch": "pnpm test watch",
|
|
115
|
+
"test:ci": "pnpm test run",
|
|
116
|
+
"//3a": "*********************************************************************",
|
|
117
|
+
"//3b": "************************ UNIT TESTS COVERAGE ************************",
|
|
118
|
+
"//3c": "*********************************************************************",
|
|
119
|
+
"test:coverage": "pnpm test:watch --coverage",
|
|
120
|
+
"test:coverage:ci": "pnpm test:ci --coverage",
|
|
121
|
+
"test:serve-coverage": "http-server ./coverage --gzip true -p 0 -o /index.html --silent",
|
|
122
|
+
"test:coverage:serve": "concurrently --prefix none --kill-others \"pnpm test:coverage\" \"pnpm test:serve-coverage\"",
|
|
123
|
+
"//4a": "*********************************************************************",
|
|
124
|
+
"//4b": "******************************* OTHER *******************************",
|
|
125
|
+
"//4c": "*********************************************************************",
|
|
126
|
+
"postinstall": "node scripts/postinstall/index.cjs"
|
|
127
|
+
}
|
|
128
|
+
}
|
package/dist/chunk-HNNMLJIA.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _code = require('@alessiofrittoli/exception/code');var o=(r=>(r.XHR_NOT_AVAILABLE="ERR:XHRNOTAVAILABLE",r.XHR_INVALID_STATE="ERR:XHRINVALIDSTATE",r))(o||{}),p= exports.b ={Exception:_code.ErrorCode,Request:o};exports.a = o; exports.b = p;
|
package/dist/chunk-LOWOZ6LK.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{ErrorCode as E}from"@alessiofrittoli/exception/code";var o=(r=>(r.XHR_NOT_AVAILABLE="ERR:XHRNOTAVAILABLE",r.XHR_INVALID_STATE="ERR:XHRINVALIDSTATE",r))(o||{}),t={Exception:E,Request:o};export{o as a,t as b};
|
package/dist/error.d.mts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { ErrorCode as ErrorCode$1 } from '@alessiofrittoli/exception/code';
|
|
2
|
-
|
|
3
|
-
declare enum Request {
|
|
4
|
-
XHR_NOT_AVAILABLE = "ERR:XHRNOTAVAILABLE",
|
|
5
|
-
XHR_INVALID_STATE = "ERR:XHRINVALIDSTATE"
|
|
6
|
-
}
|
|
7
|
-
declare const ErrorCode: {
|
|
8
|
-
Exception: typeof ErrorCode$1;
|
|
9
|
-
Request: typeof Request;
|
|
10
|
-
};
|
|
11
|
-
type ErrorCode = MergedEnumValue<typeof ErrorCode>;
|
|
12
|
-
|
|
13
|
-
export { ErrorCode, Request };
|
package/dist/error.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { ErrorCode as ErrorCode$1 } from '@alessiofrittoli/exception/code';
|
|
2
|
-
|
|
3
|
-
declare enum Request {
|
|
4
|
-
XHR_NOT_AVAILABLE = "ERR:XHRNOTAVAILABLE",
|
|
5
|
-
XHR_INVALID_STATE = "ERR:XHRINVALIDSTATE"
|
|
6
|
-
}
|
|
7
|
-
declare const ErrorCode: {
|
|
8
|
-
Exception: typeof ErrorCode$1;
|
|
9
|
-
Request: typeof Request;
|
|
10
|
-
};
|
|
11
|
-
type ErrorCode = MergedEnumValue<typeof ErrorCode>;
|
|
12
|
-
|
|
13
|
-
export { ErrorCode, Request };
|
package/dist/error.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkHNNMLJIAjs = require('./chunk-HNNMLJIA.js');exports.ErrorCode = _chunkHNNMLJIAjs.b; exports.Request = _chunkHNNMLJIAjs.a;
|
package/dist/error.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a,b}from"./chunk-LOWOZ6LK.mjs";export{b as ErrorCode,a as Request};
|
package/dist/fetch.d.mts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { AbortSignal } from '@alessiofrittoli/abort-controller';
|
|
2
|
-
import { F as Fetch } from './types-DuGUXaTD.mjs';
|
|
3
|
-
import '@alessiofrittoli/event-emitter';
|
|
4
|
-
import '@alessiofrittoli/exception';
|
|
5
|
-
import '@alessiofrittoli/exception/abort';
|
|
6
|
-
import '@alessiofrittoli/url-utils';
|
|
7
|
-
import './error.mjs';
|
|
8
|
-
import '@alessiofrittoli/exception/code';
|
|
9
|
-
|
|
10
|
-
interface RequestInit extends globalThis.RequestInit {
|
|
11
|
-
signal?: AbortSignal;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* An extended version of the global fetch API.
|
|
15
|
-
*
|
|
16
|
-
* @param input The RequestInfo | URL.
|
|
17
|
-
* @param init The RequestInit.
|
|
18
|
-
* @param onfulfilled (Optional) A callback to run on Request fulfill. This could be used to alter the returned result.
|
|
19
|
-
* @returns An object with the parsed Request data, Request error, Request Response instance and Request Headers.
|
|
20
|
-
*/
|
|
21
|
-
declare const fetch: <T, U extends RequestInit = RequestInit, V = Fetch.ReturnDataType<T, U>>(input: RequestInfo | URL, init?: U, onfulfilled?: Fetch.OnFulfilledCallback<V>) => Promise<Fetch.Result<V>>;
|
|
22
|
-
|
|
23
|
-
export { fetch };
|
package/dist/fetch.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { AbortSignal } from '@alessiofrittoli/abort-controller';
|
|
2
|
-
import { F as Fetch } from './types-CVc-rxXe.js';
|
|
3
|
-
import '@alessiofrittoli/event-emitter';
|
|
4
|
-
import '@alessiofrittoli/exception';
|
|
5
|
-
import '@alessiofrittoli/exception/abort';
|
|
6
|
-
import '@alessiofrittoli/url-utils';
|
|
7
|
-
import './error.js';
|
|
8
|
-
import '@alessiofrittoli/exception/code';
|
|
9
|
-
|
|
10
|
-
interface RequestInit extends globalThis.RequestInit {
|
|
11
|
-
signal?: AbortSignal;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* An extended version of the global fetch API.
|
|
15
|
-
*
|
|
16
|
-
* @param input The RequestInfo | URL.
|
|
17
|
-
* @param init The RequestInit.
|
|
18
|
-
* @param onfulfilled (Optional) A callback to run on Request fulfill. This could be used to alter the returned result.
|
|
19
|
-
* @returns An object with the parsed Request data, Request error, Request Response instance and Request Headers.
|
|
20
|
-
*/
|
|
21
|
-
declare const fetch: <T, U extends RequestInit = RequestInit, V = Fetch.ReturnDataType<T, U>>(input: RequestInfo | URL, init?: U, onfulfilled?: Fetch.OnFulfilledCallback<V>) => Promise<Fetch.Result<V>>;
|
|
22
|
-
|
|
23
|
-
export { fetch };
|
package/dist/fetch.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunkHNNMLJIAjs = require('./chunk-HNNMLJIA.js');var _exception = require('@alessiofrittoli/exception');var h=(l,a,s)=>globalThis.fetch(l,a).then(async t=>{let o=t.headers,c=o.get("Content-Type"),i=_optionalChain([c, 'optionalAccess', _ => _.includes, 'call', _2 => _2("application/json")])||_optionalChain([a, 'optionalAccess', _3 => _3.responseType])==="json",u=_optionalChain([c, 'optionalAccess', _4 => _4.includes, 'call', _5 => _5("form-data")])||_optionalChain([a, 'optionalAccess', _6 => _6.responseType])==="formdata",e={response:t,headers:o,data:null,error:null};if(t.ok)return s?s(t):i?(e.data=await t.json(),e):u?(e.data=await t.formData(),e):_optionalChain([a, 'optionalAccess', _7 => _7.responseType])==="arraybuffer"?(e.data=await t.arrayBuffer(),e):_optionalChain([a, 'optionalAccess', _8 => _8.responseType])==="blob"?(e.data=await t.blob(),e):(e.data=await t.text(),e);if(i)throw await t.json();return e.error=new (0, _exception.Exception)(await t.text()||t.statusText,{code:_chunkHNNMLJIAjs.b.Exception.UNKNOWN}),e}).catch(t=>({data:null,headers:null,response:null,error:_exception.Exception.isException(t)?new (0, _exception.Exception)(t.message,{...t}):new (0, _exception.Exception)(t.message,{code:_chunkHNNMLJIAjs.b.Exception.UNKNOWN,name:t.name,cause:t})}));exports.fetch = h;
|
package/dist/fetch.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{b as n}from"./chunk-LOWOZ6LK.mjs";import{Exception as r}from"@alessiofrittoli/exception";var m=(l,a,s)=>globalThis.fetch(l,a).then(async t=>{let o=t.headers,c=o.get("Content-Type"),i=c?.includes("application/json")||a?.responseType==="json",u=c?.includes("form-data")||a?.responseType==="formdata",e={response:t,headers:o,data:null,error:null};if(t.ok)return s?s(t):i?(e.data=await t.json(),e):u?(e.data=await t.formData(),e):a?.responseType==="arraybuffer"?(e.data=await t.arrayBuffer(),e):a?.responseType==="blob"?(e.data=await t.blob(),e):(e.data=await t.text(),e);if(i)throw await t.json();return e.error=new r(await t.text()||t.statusText,{code:n.Exception.UNKNOWN}),e}).catch(t=>({data:null,headers:null,response:null,error:r.isException(t)?new r(t.message,{...t}):new r(t.message,{code:n.Exception.UNKNOWN,name:t.name,cause:t})}));export{m as fetch};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _webutils = require('@alessiofrittoli/web-utils');var _cryptobuffer = require('@alessiofrittoli/crypto-buffer');var _exception = require('@alessiofrittoli/exception');var m=async n=>{let{response:s}=n,{responseType:o}=n;switch(o){case"document":break;case"json":{let e=s;if(e&&_exception.Exception.isException(e))return new (0, _exception.Exception)(e.message,{...e});break}case"":case"text":case"arraybuffer":case"blob":default:{let e=o==="arraybuffer"?_cryptobuffer.binaryToString.call(void 0, s):o==="blob"?await s.text():s;if(_webutils.isJson.call(void 0, e)){let t=JSON.parse(e);if(_exception.Exception.isException(t))return new (0, _exception.Exception)(t.message,{...t})}break}}return null};exports.getErrorFromResponse = m;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{isJson as a}from"@alessiofrittoli/web-utils";import{binaryToString as p}from"@alessiofrittoli/crypto-buffer";import{Exception as r}from"@alessiofrittoli/exception";var u=async n=>{let{response:s}=n,{responseType:o}=n;switch(o){case"document":break;case"json":{let e=s;if(e&&r.isException(e))return new r(e.message,{...e});break}case"":case"text":case"arraybuffer":case"blob":default:{let e=o==="arraybuffer"?p(s):o==="blob"?await s.text():s;if(a(e)){let t=JSON.parse(e);if(r.isException(t))return new r(t.message,{...t})}break}}return null};export{u as getErrorFromResponse};
|
package/dist/index.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
declare global {
|
|
2
|
-
interface RequestInit {
|
|
3
|
-
/** The expected ResponseType. */
|
|
4
|
-
responseType?: XMLHttpRequestResponseType | 'formdata';
|
|
5
|
-
}
|
|
6
|
-
interface ProgressEvent {
|
|
7
|
-
readonly type: keyof XMLHttpRequestEventTargetEventMap;
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
type DoNotUse = never;
|
|
11
|
-
|
|
12
|
-
export type { DoNotUse };
|
package/dist/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var r=t=>{let e={event:"readystatechange",readyState:t.request.readyState,status:t.request.status,message:""};switch(t.request.readyState){case XMLHttpRequest.UNSENT:e.message="Request unsent";break;case XMLHttpRequest.OPENED:e.message="Request opened";break;case XMLHttpRequest.HEADERS_RECEIVED:e.message="Request headers received";break;case XMLHttpRequest.LOADING:e.message="Request loading";break;case XMLHttpRequest.DONE:e.message="Request done";break}t.log(e)};export{r as logReadyStateChange};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var a=t=>{let e={event:"readystatechange",readyState:t.request.readyState,status:t.request.status,message:""};switch(t.request.readyState){case XMLHttpRequest.UNSENT:e.message="Request unsent";break;case XMLHttpRequest.OPENED:e.message="Request opened";break;case XMLHttpRequest.HEADERS_RECEIVED:e.message="Request headers received";break;case XMLHttpRequest.LOADING:e.message="Request loading";break;case XMLHttpRequest.DONE:e.message="Request done";break}t.log(e)};exports.logReadyStateChange = a;
|
package/dist/ping.d.mts
DELETED
package/dist/ping.d.ts
DELETED
package/dist/ping.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _urlutils = require('@alessiofrittoli/url-utils');var l=(n,t)=>{navigator.sendBeacon(_urlutils.Url.format(n),t)};exports.ping = l;
|
package/dist/ping.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Url as o}from"@alessiofrittoli/url-utils";var a=(n,t)=>{navigator.sendBeacon(o.format(n),t)};export{a as ping};
|