nuxt-custom-fetch 2.3.1 → 4.0.0-alpha.1
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 +29 -28
- package/dist/module.d.mts +4 -3
- package/dist/module.json +2 -2
- package/dist/module.mjs +2 -1
- package/dist/runtime/ajax.d.ts +13 -13
- package/dist/runtime/ajax.js +47 -61
- package/dist/runtime/type.d.ts +9 -3
- package/dist/runtime/utils.d.ts +6 -0
- package/dist/runtime/utils.js +29 -0
- package/dist/types.d.mts +3 -1
- package/package.json +11 -9
package/README.md
CHANGED
|
@@ -1,22 +1,20 @@
|
|
|
1
1
|
# Nuxt Module
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
simple wrapper useAsyncData
|
|
4
4
|
|
|
5
|
-
`version
|
|
5
|
+
`version >= 3.17.0`
|
|
6
6
|
|
|
7
|
-
##
|
|
7
|
+
## Attention
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
1. Invalid request in onMounted
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
- Execute in `nextTick`, or set `{server: false}` to watch `status` changes
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
2. When using `refresh` and `execute`, it should also be noted that the parameters are not responsive, so they will always be the parameters requested for the first time
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
3. If a reactive object is passed and using `watch`, it will automatically re request
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
## 安装
|
|
17
|
+
## Install
|
|
20
18
|
|
|
21
19
|
```bash
|
|
22
20
|
pnpm add nuxt-custom-fetch
|
|
@@ -29,9 +27,9 @@ export default defineNuxtConfig({
|
|
|
29
27
|
})
|
|
30
28
|
```
|
|
31
29
|
|
|
32
|
-
##
|
|
30
|
+
## Usage
|
|
33
31
|
|
|
34
|
-
|
|
32
|
+
global CustomFetch
|
|
35
33
|
|
|
36
34
|
```ts
|
|
37
35
|
const ajax = new CustomFetch({
|
|
@@ -48,7 +46,7 @@ ajax.http({
|
|
|
48
46
|
})
|
|
49
47
|
```
|
|
50
48
|
|
|
51
|
-
##
|
|
49
|
+
## Types
|
|
52
50
|
|
|
53
51
|
### useAsyncDataType
|
|
54
52
|
|
|
@@ -56,29 +54,32 @@ ajax.http({
|
|
|
56
54
|
|
|
57
55
|
```ts
|
|
58
56
|
export declare class CustomFetch {
|
|
59
|
-
baseURL:
|
|
57
|
+
baseURL: string
|
|
60
58
|
immutableKey: boolean
|
|
61
|
-
showLogs: boolean
|
|
62
|
-
params: HTTPConfig
|
|
63
|
-
baseHandler: HTTPConfig['handler']
|
|
64
|
-
interceptors: Interceptors
|
|
65
59
|
offline: typeof Noop
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
http<DataT,
|
|
60
|
+
showLogs: boolean
|
|
61
|
+
constructor (config: CustomFetchOptions)
|
|
62
|
+
http<DataT, NuxtErrorDataT = Error | null>(url: NitroFetchRequest, config: CustomFetchOptions & {
|
|
69
63
|
method: FetchMethod
|
|
70
|
-
}, options?: AsyncDataOptions<DataT>): CustomFetchReturnValue<DataT,
|
|
71
|
-
get<DataT,
|
|
72
|
-
post<DataT,
|
|
64
|
+
}, options?: AsyncDataOptions<DataT>): CustomFetchReturnValue<DataT, NuxtErrorDataT>
|
|
65
|
+
get<DataT, NuxtErrorDataT = Error | null>(url: NitroFetchRequest, config?: CustomFetchOptions, options?: AsyncDataOptions<DataT>): CustomFetchReturnValue<DataT, NuxtErrorDataT>
|
|
66
|
+
post<DataT, NuxtErrorDataT = Error | null>(url: NitroFetchRequest, config?: CustomFetchOptions, options?: AsyncDataOptions<DataT>): CustomFetchReturnValue<DataT, NuxtErrorDataT>
|
|
73
67
|
}
|
|
74
68
|
|
|
75
69
|
export type FetchMethod = 'options' | 'GET' | 'POST' | 'get' | 'HEAD' | 'PATCH' | 'PUT' | 'DELETE' | 'CONNECT' | 'OPTIONS' | 'TRACE' | 'post' | 'head' | 'patch' | 'put' | 'delete' | 'connect' | 'trace' | undefined
|
|
76
|
-
export interface
|
|
70
|
+
export interface CustomFetchOptions extends Omit<FetchOptions, 'method'> {
|
|
71
|
+
/** unique key for fetch */
|
|
77
72
|
key?: string
|
|
73
|
+
/** hash key for fetch, with [customFetch: + url] without query */
|
|
78
74
|
immutableKey?: boolean
|
|
75
|
+
/** show logs */
|
|
76
|
+
showLogs?: boolean
|
|
79
77
|
baseURL?: string
|
|
78
|
+
/** is use handler to deal with query or pramas */
|
|
80
79
|
useHandler?: boolean
|
|
81
|
-
handler
|
|
80
|
+
/** handler to deal with query or pramas */
|
|
81
|
+
handler?: (mergedObject: FetchOptions['params'] & FetchOptions['query']) => Record<string, any>
|
|
82
|
+
/** offline handler */
|
|
82
83
|
offline?: () => void
|
|
83
84
|
}
|
|
84
85
|
export interface Interceptors {
|
|
@@ -89,7 +90,7 @@ export interface Interceptors {
|
|
|
89
90
|
}
|
|
90
91
|
```
|
|
91
92
|
|
|
92
|
-
##
|
|
93
|
+
## Example
|
|
93
94
|
|
|
94
95
|
```ts
|
|
95
96
|
// api.ts
|
|
@@ -100,7 +101,7 @@ export const getInfo = (params: Record<string, any>) =>
|
|
|
100
101
|
```ts
|
|
101
102
|
// index.vue
|
|
102
103
|
import { getInfo } from './ajax'
|
|
103
|
-
const { data, error
|
|
104
|
+
const { data, error } = await getInfo({
|
|
104
105
|
sign: 123
|
|
105
106
|
})
|
|
106
107
|
console.log(data.value)
|
package/dist/module.d.mts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as nuxt_schema from 'nuxt/schema';
|
|
2
2
|
|
|
3
3
|
interface ModuleOptions {
|
|
4
4
|
}
|
|
5
|
-
declare const _default:
|
|
5
|
+
declare const _default: nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
|
|
6
6
|
|
|
7
|
-
export {
|
|
7
|
+
export { _default as default };
|
|
8
|
+
export type { ModuleOptions };
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -4,7 +4,8 @@ import { defineNuxtModule, createResolver, addImports } from '@nuxt/kit';
|
|
|
4
4
|
const module = defineNuxtModule({
|
|
5
5
|
meta: {
|
|
6
6
|
name: "nuxt-custom-fetch",
|
|
7
|
-
configKey: "customFetch"
|
|
7
|
+
configKey: "customFetch",
|
|
8
|
+
version: ">=3.17.0"
|
|
8
9
|
},
|
|
9
10
|
defaults: {},
|
|
10
11
|
setup(options, nuxt) {
|
package/dist/runtime/ajax.d.ts
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import type { NitroFetchRequest } from 'nitro';
|
|
1
|
+
import type { NitroFetchRequest } from 'nitro/types';
|
|
2
2
|
import type { AsyncData, AsyncDataOptions, NuxtError } from 'nuxt/app';
|
|
3
|
-
import type {
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
import type { CustomFetchOptions, FetchMethod, Interceptors, KeysOf, PickFrom } from './type.js';
|
|
4
|
+
import { Noop } from './utils.js';
|
|
5
|
+
type CustomFetchReturnValue<DataT, NuxtErrorDataT> = AsyncData<PickFrom<DataT, KeysOf<DataT>> | undefined, (NuxtErrorDataT extends Error | NuxtError<unknown> ? NuxtErrorDataT : NuxtError<NuxtErrorDataT>) | undefined>;
|
|
6
6
|
export declare class CustomFetch {
|
|
7
|
-
baseURL: string
|
|
7
|
+
baseURL: string;
|
|
8
8
|
immutableKey: boolean;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
_config: CustomFetchOptions;
|
|
10
|
+
_baseHandler: CustomFetchOptions['handler'];
|
|
11
|
+
_interceptors: Interceptors;
|
|
12
12
|
offline: typeof Noop;
|
|
13
13
|
showLogs: boolean;
|
|
14
|
-
constructor(config
|
|
14
|
+
constructor(config: CustomFetchOptions);
|
|
15
15
|
private baseConfig;
|
|
16
|
-
http<DataT,
|
|
16
|
+
http<DataT, NuxtErrorDataT = Error | null>(url: NitroFetchRequest, config: CustomFetchOptions & {
|
|
17
17
|
method: FetchMethod;
|
|
18
|
-
}, options?: AsyncDataOptions<DataT>): CustomFetchReturnValue<DataT,
|
|
19
|
-
get<DataT,
|
|
20
|
-
post<DataT,
|
|
18
|
+
}, options?: AsyncDataOptions<DataT>): CustomFetchReturnValue<DataT, NuxtErrorDataT>;
|
|
19
|
+
get<DataT, NuxtErrorDataT = Error | null>(url: NitroFetchRequest, config?: CustomFetchOptions, options?: AsyncDataOptions<DataT>): CustomFetchReturnValue<DataT, NuxtErrorDataT>;
|
|
20
|
+
post<DataT, NuxtErrorDataT = Error | null>(url: NitroFetchRequest, config?: CustomFetchOptions, options?: AsyncDataOptions<DataT>): CustomFetchReturnValue<DataT, NuxtErrorDataT>;
|
|
21
21
|
}
|
|
22
22
|
export {};
|
package/dist/runtime/ajax.js
CHANGED
|
@@ -1,50 +1,29 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { asyncDataDefaults, pendingWhenIdle } from "#build/nuxt.config.mjs";
|
|
2
|
+
import { clearNuxtData, createError, getCurrentScope, onScopeDispose, reactive, ref, shallowRef, unref, useAsyncData, useRequestFetch, useRuntimeConfig, watch } from "#imports";
|
|
2
3
|
import { hash, serialize } from "ohash";
|
|
3
|
-
|
|
4
|
-
}
|
|
5
|
-
function generateOptionSegments(opts) {
|
|
6
|
-
const segments = [toValue(opts.method)?.toUpperCase() || "GET", toValue(opts.baseURL)];
|
|
7
|
-
for (const _obj of [opts.params || opts.query]) {
|
|
8
|
-
const obj = toValue(_obj);
|
|
9
|
-
if (!obj) {
|
|
10
|
-
continue;
|
|
11
|
-
}
|
|
12
|
-
const unwrapped = {};
|
|
13
|
-
for (const [key, value] of Object.entries(obj)) {
|
|
14
|
-
unwrapped[toValue(key)] = toValue(value);
|
|
15
|
-
}
|
|
16
|
-
segments.push(unwrapped);
|
|
17
|
-
}
|
|
18
|
-
return segments;
|
|
19
|
-
}
|
|
20
|
-
function pick(obj, keys) {
|
|
21
|
-
const newObj = {};
|
|
22
|
-
for (const key of keys) {
|
|
23
|
-
newObj[key] = obj[key];
|
|
24
|
-
}
|
|
25
|
-
return newObj;
|
|
26
|
-
}
|
|
4
|
+
import { generateOptionSegments, Noop, pick } from "./utils.js";
|
|
27
5
|
const _cachedController = /* @__PURE__ */ new Map();
|
|
28
6
|
export class CustomFetch {
|
|
29
7
|
baseURL;
|
|
30
8
|
immutableKey = false;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
9
|
+
_config = {};
|
|
10
|
+
_baseHandler;
|
|
11
|
+
_interceptors = {};
|
|
34
12
|
offline = Noop;
|
|
35
13
|
showLogs = false;
|
|
36
|
-
constructor(config
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
this.
|
|
40
|
-
this.baseURL = config.baseURL;
|
|
14
|
+
constructor(config) {
|
|
15
|
+
const { handler, offline, ...restConfig } = config;
|
|
16
|
+
this._config = restConfig;
|
|
17
|
+
this.baseURL = config.baseURL || "";
|
|
41
18
|
this.immutableKey = config.immutableKey ?? false;
|
|
42
|
-
this.showLogs = config.showLogs ?? import.meta.dev;
|
|
43
|
-
if (
|
|
44
|
-
this.
|
|
19
|
+
this.showLogs = config.showLogs ?? import.meta.dev ?? false;
|
|
20
|
+
if (handler) {
|
|
21
|
+
this._baseHandler = handler || Noop;
|
|
45
22
|
}
|
|
46
|
-
|
|
47
|
-
|
|
23
|
+
if (offline) {
|
|
24
|
+
this.offline = offline;
|
|
25
|
+
}
|
|
26
|
+
this._interceptors = {
|
|
48
27
|
onRequest: config.onRequest || Noop,
|
|
49
28
|
onRequestError: config.onRequestError || Noop,
|
|
50
29
|
onResponse: config.onResponse || Noop,
|
|
@@ -53,11 +32,11 @@ export class CustomFetch {
|
|
|
53
32
|
}
|
|
54
33
|
baseConfig(config) {
|
|
55
34
|
const { useHandler = true, handler, query = {}, params = {} } = config;
|
|
56
|
-
const baseHandler = handler || this.
|
|
35
|
+
const baseHandler = handler || this._baseHandler;
|
|
57
36
|
const _name = Object.keys(query).length ? "query" : "params";
|
|
58
37
|
const mergeObj = {
|
|
59
|
-
...
|
|
60
|
-
...
|
|
38
|
+
...params,
|
|
39
|
+
...query
|
|
61
40
|
};
|
|
62
41
|
if (useHandler && baseHandler && typeof baseHandler === "function") {
|
|
63
42
|
return { [_name]: baseHandler(mergeObj) };
|
|
@@ -65,7 +44,8 @@ export class CustomFetch {
|
|
|
65
44
|
return { [_name]: { ...mergeObj } };
|
|
66
45
|
}
|
|
67
46
|
http(url, config, options = {}) {
|
|
68
|
-
|
|
47
|
+
const app = useRuntimeConfig().app;
|
|
48
|
+
config.baseURL ??= this.baseURL || app.baseURL;
|
|
69
49
|
Object.assign(config, this.baseConfig(config));
|
|
70
50
|
const generateOptionSegmentsWithConfig = generateOptionSegments(config);
|
|
71
51
|
if (this.showLogs && import.meta.client) {
|
|
@@ -77,14 +57,12 @@ export class CustomFetch {
|
|
|
77
57
|
}
|
|
78
58
|
console.warn("[Custom Fetch] `Request:`", url, " `Query:`", serialize(generateOptionSegmentsWithConfig), " `Body:`", bodyLogs);
|
|
79
59
|
}
|
|
80
|
-
const { onRequest, onRequestError, onResponse, onResponseError, offline, handler, useHandler, showLogs, immutableKey, ...
|
|
60
|
+
const { onRequest, onRequestError, onResponse, onResponseError, offline, handler, useHandler, showLogs, immutableKey, ...asyncDataOptions } = config;
|
|
81
61
|
if (import.meta.client && navigator && !navigator.onLine) {
|
|
82
|
-
|
|
83
|
-
offline();
|
|
84
|
-
}
|
|
62
|
+
this.offline();
|
|
85
63
|
}
|
|
86
|
-
const interceptors = this.
|
|
87
|
-
const _config = reactive({ ...
|
|
64
|
+
const interceptors = this._interceptors;
|
|
65
|
+
const _config = reactive({ ...asyncDataOptions });
|
|
88
66
|
const defaultOptions = {
|
|
89
67
|
onRequest(ctx) {
|
|
90
68
|
[interceptors.onRequest, onRequest].forEach((fns) => {
|
|
@@ -135,12 +113,15 @@ export class CustomFetch {
|
|
|
135
113
|
});
|
|
136
114
|
}
|
|
137
115
|
};
|
|
116
|
+
let key = config.key;
|
|
138
117
|
const hashValue = ["custom_fetch:", url];
|
|
118
|
+
if (import.meta.dev && !config.key && (this.immutableKey || immutableKey)) {
|
|
119
|
+
console.warn("[Custom Fetch] immutableKey is enabled, the key will be generated by hash([custom_fetch:, url])");
|
|
120
|
+
}
|
|
139
121
|
if (!this.immutableKey && !immutableKey) {
|
|
140
122
|
hashValue.push(...generateOptionSegmentsWithConfig);
|
|
141
123
|
}
|
|
142
|
-
|
|
143
|
-
options.default = options.default ?? (() => null);
|
|
124
|
+
key ??= hash(hashValue).replace(/[-_]/g, "").slice(0, 10);
|
|
144
125
|
const _handler = () => {
|
|
145
126
|
if (_cachedController.get(key)) {
|
|
146
127
|
_cachedController.get(key)?.abort?.();
|
|
@@ -152,15 +133,18 @@ export class CustomFetch {
|
|
|
152
133
|
});
|
|
153
134
|
};
|
|
154
135
|
const controller = typeof AbortController !== "undefined" ? new AbortController() : {};
|
|
155
|
-
|
|
156
|
-
|
|
136
|
+
if (import.meta.client) {
|
|
137
|
+
const _ref = options.deep ? ref : shallowRef;
|
|
157
138
|
const asyncData = {
|
|
158
|
-
data:
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
139
|
+
data: _ref(null),
|
|
140
|
+
error: _ref(null),
|
|
141
|
+
status: _ref("idle"),
|
|
142
|
+
pending: _ref(false),
|
|
143
|
+
clear: () => clearNuxtData(key)
|
|
162
144
|
};
|
|
163
|
-
|
|
145
|
+
if (pendingWhenIdle) {
|
|
146
|
+
asyncData.pending.value = true;
|
|
147
|
+
}
|
|
164
148
|
asyncData.status.value = "pending";
|
|
165
149
|
const promise = new Promise((resolve, reject) => {
|
|
166
150
|
try {
|
|
@@ -178,7 +162,7 @@ export class CustomFetch {
|
|
|
178
162
|
result = pick(result, options.pick);
|
|
179
163
|
}
|
|
180
164
|
asyncData.data.value = result;
|
|
181
|
-
asyncData.error.value =
|
|
165
|
+
asyncData.error.value = asyncDataDefaults.errorValue;
|
|
182
166
|
asyncData.status.value = "success";
|
|
183
167
|
return asyncData;
|
|
184
168
|
}).catch((error) => {
|
|
@@ -187,7 +171,9 @@ export class CustomFetch {
|
|
|
187
171
|
asyncData.status.value = "error";
|
|
188
172
|
return asyncData;
|
|
189
173
|
}).finally(() => {
|
|
190
|
-
|
|
174
|
+
if (pendingWhenIdle) {
|
|
175
|
+
asyncData.pending.value = false;
|
|
176
|
+
}
|
|
191
177
|
_cachedController.delete(key);
|
|
192
178
|
});
|
|
193
179
|
asyncData.refresh = asyncData.execute = () => _handler().then((result) => asyncData.data.value = result);
|
|
@@ -195,14 +181,14 @@ export class CustomFetch {
|
|
|
195
181
|
if (options.watch) {
|
|
196
182
|
const unsub = watch(options.watch, async () => {
|
|
197
183
|
asyncData.refresh();
|
|
198
|
-
});
|
|
184
|
+
}, { flush: "post" });
|
|
199
185
|
if (hasScope) {
|
|
200
186
|
onScopeDispose(unsub);
|
|
201
187
|
}
|
|
202
188
|
}
|
|
203
189
|
return promise;
|
|
204
190
|
}
|
|
205
|
-
return useAsyncData(
|
|
191
|
+
return useAsyncData(key, _handler, options);
|
|
206
192
|
}
|
|
207
193
|
get(url, config = {}, options) {
|
|
208
194
|
return this.http(url, {
|
package/dist/runtime/type.d.ts
CHANGED
|
@@ -1,16 +1,22 @@
|
|
|
1
1
|
import type { FetchOptions } from 'ofetch';
|
|
2
2
|
export type { FetchContext, FetchResponse } from 'ofetch';
|
|
3
|
+
/** https://github.com/nuxt/nuxt/blob/edeb0759a455dbafd030f0b5ae1d5a39ad0dfc2a/packages/nuxt/src/app/composables/asyncData.ts#L20 */
|
|
3
4
|
export type PickFrom<T, K extends Array<string>> = T extends Array<any> ? T : T extends Record<string, any> ? (keyof T extends K[number] ? T : K[number] extends never ? T : Pick<T, K[number]>) : T;
|
|
4
5
|
export type KeysOf<T> = Array<T extends T ? (keyof T extends string ? keyof T : never) : never>;
|
|
5
6
|
export type FetchMethod = 'options' | 'GET' | 'POST' | 'get' | 'HEAD' | 'PATCH' | 'PUT' | 'DELETE' | 'CONNECT' | 'OPTIONS' | 'TRACE' | 'post' | 'head' | 'patch' | 'put' | 'delete' | 'connect' | 'trace' | undefined;
|
|
6
|
-
export interface
|
|
7
|
+
export interface CustomFetchOptions extends Omit<FetchOptions, 'method'> {
|
|
8
|
+
/** unique key for fetch */
|
|
7
9
|
key?: string;
|
|
10
|
+
/** hash key for fetch, with [customFetch: + url] without query */
|
|
8
11
|
immutableKey?: boolean;
|
|
12
|
+
/** show logs */
|
|
9
13
|
showLogs?: boolean;
|
|
10
|
-
interceptors?: Interceptors;
|
|
11
14
|
baseURL?: string;
|
|
15
|
+
/** is use handler to deal with query or pramas */
|
|
12
16
|
useHandler?: boolean;
|
|
13
|
-
handler
|
|
17
|
+
/** handler to deal with query or pramas */
|
|
18
|
+
handler?: (mergedObject: FetchOptions['params'] & FetchOptions['query']) => Record<string, any>;
|
|
19
|
+
/** offline handler */
|
|
14
20
|
offline?: () => void;
|
|
15
21
|
}
|
|
16
22
|
export interface Interceptors {
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { CustomFetchOptions, FetchMethod } from './type.js';
|
|
2
|
+
export declare function Noop(): void;
|
|
3
|
+
export declare function generateOptionSegments(opts: CustomFetchOptions & {
|
|
4
|
+
method: FetchMethod;
|
|
5
|
+
}): (string | Record<string, string> | undefined)[];
|
|
6
|
+
export declare function pick(obj: Record<string, any>, keys: string[]): any;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { toValue } from "#imports";
|
|
2
|
+
import { hash } from "ohash";
|
|
3
|
+
export function Noop() {
|
|
4
|
+
}
|
|
5
|
+
export function generateOptionSegments(opts) {
|
|
6
|
+
const segments = [toValue(opts.method)?.toUpperCase() || "GET", toValue(opts.baseURL)];
|
|
7
|
+
for (const _obj of [opts.params || opts.query]) {
|
|
8
|
+
const obj = toValue(_obj);
|
|
9
|
+
if (!obj) {
|
|
10
|
+
continue;
|
|
11
|
+
}
|
|
12
|
+
const unwrapped = {};
|
|
13
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
14
|
+
unwrapped[toValue(key)] = toValue(value);
|
|
15
|
+
}
|
|
16
|
+
segments.push(unwrapped);
|
|
17
|
+
}
|
|
18
|
+
if (opts.body) {
|
|
19
|
+
segments.push(hash(toValue(opts.body)));
|
|
20
|
+
}
|
|
21
|
+
return segments;
|
|
22
|
+
}
|
|
23
|
+
export function pick(obj, keys) {
|
|
24
|
+
const newObj = {};
|
|
25
|
+
for (const key of keys) {
|
|
26
|
+
newObj[key] = obj[key];
|
|
27
|
+
}
|
|
28
|
+
return newObj;
|
|
29
|
+
}
|
package/dist/types.d.mts
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-custom-fetch",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "4.0.0-alpha.1",
|
|
5
|
+
"packageManager": "pnpm@8.15.3+sha1.64838798f519c18029c1e8a1310e16101fc2eda0",
|
|
5
6
|
"license": "MIT",
|
|
6
7
|
"repository": {
|
|
7
8
|
"type": "git",
|
|
@@ -27,6 +28,7 @@
|
|
|
27
28
|
"lint:fix": "eslint . --fix",
|
|
28
29
|
"prepare": "husky",
|
|
29
30
|
"commit": "git-cz",
|
|
31
|
+
"prerelease": "changelogen --prerelease && pnpm prepack && npm publish --tag alpha",
|
|
30
32
|
"release": "changelogen --release && pnpm prepack && npm publish && git push --follow-tags"
|
|
31
33
|
},
|
|
32
34
|
"config": {
|
|
@@ -35,24 +37,24 @@
|
|
|
35
37
|
}
|
|
36
38
|
},
|
|
37
39
|
"dependencies": {
|
|
38
|
-
"@nuxt/kit": "^3.16.2",
|
|
39
40
|
"ohash": "^2.0.11"
|
|
40
41
|
},
|
|
41
42
|
"devDependencies": {
|
|
42
|
-
"@antfu/eslint-config": "^4.
|
|
43
|
+
"@antfu/eslint-config": "^4.12.0",
|
|
43
44
|
"@commitlint/cli": "^19.8.0",
|
|
44
45
|
"@commitlint/config-conventional": "^19.8.0",
|
|
45
|
-
"@nuxt/
|
|
46
|
-
"@nuxt/
|
|
47
|
-
"@
|
|
46
|
+
"@nuxt/kit": "npm:@nuxt/kit-nightly@4.0.0-29086370.088bcd45",
|
|
47
|
+
"@nuxt/module-builder": "^1.0.1",
|
|
48
|
+
"@nuxt/schema": "npm:@nuxt/schema-nightly@4.0.0-29086370.088bcd45",
|
|
49
|
+
"@types/node": "^22.14.1",
|
|
48
50
|
"changelogen": "^0.6.1",
|
|
49
51
|
"commitizen": "^4.3.1",
|
|
50
52
|
"cz-git": "^1.11.1",
|
|
51
53
|
"eslint": "^9.24.0",
|
|
52
54
|
"husky": "^9.1.7",
|
|
53
|
-
"lint-staged": "^15.5.
|
|
54
|
-
"nitro": "npm:
|
|
55
|
-
"nuxt": "
|
|
55
|
+
"lint-staged": "^15.5.1",
|
|
56
|
+
"nitro": "npm:nitro-nightly@latest",
|
|
57
|
+
"nuxt": "npm:nuxt-nightly@4.0.0-29086370.088bcd45",
|
|
56
58
|
"typescript": "5.8.3"
|
|
57
59
|
},
|
|
58
60
|
"husky": {
|