nuxt-custom-fetch 4.0.0-alpha.7 → 4.0.0-alpha.9
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/dist/runtime/utils.d.ts +1 -1
- package/dist/runtime/utils.js +27 -3
- package/package.json +11 -10
package/dist/runtime/utils.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { CustomFetchOptions, FetchMethod } from './type.js';
|
|
2
2
|
export declare function Noop(): void;
|
|
3
|
-
export declare function generateOptionSegments(opts: CustomFetchOptions & {
|
|
3
|
+
export declare function generateOptionSegments<_ResT>(opts: CustomFetchOptions & {
|
|
4
4
|
method: FetchMethod;
|
|
5
5
|
}): (string | Record<string, string> | undefined)[];
|
|
6
6
|
export declare function pick(obj: Record<string, any>, keys: string[]): any;
|
package/dist/runtime/utils.js
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
import { toValue } from "#imports";
|
|
1
|
+
import { reactive, toValue } from "#imports";
|
|
2
|
+
import { isPlainObject } from "@vue/shared";
|
|
2
3
|
import { hash } from "ohash";
|
|
3
4
|
export function Noop() {
|
|
4
5
|
}
|
|
5
6
|
export function generateOptionSegments(opts) {
|
|
6
|
-
const segments = [
|
|
7
|
+
const segments = [
|
|
8
|
+
toValue(opts.method)?.toUpperCase() || "GET",
|
|
9
|
+
toValue(opts.baseURL)
|
|
10
|
+
];
|
|
7
11
|
for (const _obj of [opts.params || opts.query]) {
|
|
8
12
|
const obj = toValue(_obj);
|
|
9
13
|
if (!obj) {
|
|
@@ -16,7 +20,27 @@ export function generateOptionSegments(opts) {
|
|
|
16
20
|
segments.push(unwrapped);
|
|
17
21
|
}
|
|
18
22
|
if (opts.body) {
|
|
19
|
-
|
|
23
|
+
const value = toValue(opts.body);
|
|
24
|
+
if (!value) {
|
|
25
|
+
segments.push(hash(value));
|
|
26
|
+
} else if (value instanceof ArrayBuffer) {
|
|
27
|
+
segments.push(hash(Object.fromEntries([...new Uint8Array(value).entries()].map(([k, v]) => [k, v.toString()]))));
|
|
28
|
+
} else if (value instanceof FormData) {
|
|
29
|
+
const obj = {};
|
|
30
|
+
for (const entry of value.entries()) {
|
|
31
|
+
const [key, val] = entry;
|
|
32
|
+
obj[key] = val instanceof File ? val.name : val;
|
|
33
|
+
}
|
|
34
|
+
segments.push(hash(obj));
|
|
35
|
+
} else if (isPlainObject(value)) {
|
|
36
|
+
segments.push(hash(reactive(value)));
|
|
37
|
+
} else {
|
|
38
|
+
try {
|
|
39
|
+
segments.push(hash(value));
|
|
40
|
+
} catch {
|
|
41
|
+
console.warn("[useFetch] Failed to hash body", value);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
20
44
|
}
|
|
21
45
|
return segments;
|
|
22
46
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-custom-fetch",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "4.0.0-alpha.
|
|
4
|
+
"version": "4.0.0-alpha.9",
|
|
5
5
|
"packageManager": "pnpm@8.15.3+sha1.64838798f519c18029c1e8a1310e16101fc2eda0",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
@@ -37,25 +37,26 @@
|
|
|
37
37
|
}
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
+
"@vue/shared": "^3.5.13",
|
|
40
41
|
"ohash": "^2.0.11",
|
|
41
42
|
"vue": "^3.5.13"
|
|
42
43
|
},
|
|
43
44
|
"devDependencies": {
|
|
44
|
-
"@antfu/eslint-config": "^4.
|
|
45
|
-
"@commitlint/cli": "^19.8.
|
|
46
|
-
"@commitlint/config-conventional": "^19.8.
|
|
47
|
-
"@nuxt/kit": "3.17.
|
|
45
|
+
"@antfu/eslint-config": "^4.13.0",
|
|
46
|
+
"@commitlint/cli": "^19.8.1",
|
|
47
|
+
"@commitlint/config-conventional": "^19.8.1",
|
|
48
|
+
"@nuxt/kit": "3.17.3",
|
|
48
49
|
"@nuxt/module-builder": "^1.0.1",
|
|
49
|
-
"@nuxt/schema": "3.17.
|
|
50
|
-
"@types/node": "^22.15.
|
|
50
|
+
"@nuxt/schema": "3.17.3",
|
|
51
|
+
"@types/node": "^22.15.17",
|
|
51
52
|
"changelogen": "^0.6.1",
|
|
52
53
|
"commitizen": "^4.3.1",
|
|
53
54
|
"cz-git": "^1.11.1",
|
|
54
|
-
"eslint": "^9.
|
|
55
|
+
"eslint": "^9.26.0",
|
|
55
56
|
"husky": "^9.1.7",
|
|
56
|
-
"lint-staged": "^
|
|
57
|
+
"lint-staged": "^16.0.0",
|
|
57
58
|
"nitro": "npm:nitropack@^2.11.11",
|
|
58
|
-
"nuxt": "3.17.
|
|
59
|
+
"nuxt": "3.17.3",
|
|
59
60
|
"typescript": "5.8.3"
|
|
60
61
|
},
|
|
61
62
|
"husky": {
|