nuxt-custom-fetch 2.2.0 → 2.3.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/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "nuxt-custom-fetch",
3
3
  "configKey": "customFetch",
4
- "version": "2.2.0",
4
+ "version": "2.3.0",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "0.8.4",
7
7
  "unbuild": "unknown"
@@ -1,4 +1,4 @@
1
- import { createError, reactive, ref, toValue, unref, useAsyncData, useNuxtApp } from "#imports";
1
+ import { createError, getCurrentScope, onScopeDispose, reactive, ref, toValue, unref, useAsyncData, useNuxtApp, useRequestFetch, watch } from "#imports";
2
2
  import { hash, serialize } from "ohash";
3
3
  function Noop() {
4
4
  }
@@ -139,7 +139,7 @@ export class CustomFetch {
139
139
  if (_cachedController.get(key)) {
140
140
  _cachedController.get(key)?.abort?.();
141
141
  }
142
- return $fetch(url, {
142
+ return useRequestFetch()(url, {
143
143
  signal: _cachedController.get(key)?.signal,
144
144
  ...defaultOptions,
145
145
  ..._config
@@ -184,6 +184,16 @@ export class CustomFetch {
184
184
  asyncData.pending.value = false;
185
185
  _cachedController.delete(key);
186
186
  });
187
+ asyncData.refresh = asyncData.execute = () => _handler().then((result) => asyncData.data.value = result);
188
+ const hasScope = getCurrentScope();
189
+ if (options.watch) {
190
+ const unsub = watch(options.watch, async () => {
191
+ asyncData.refresh();
192
+ });
193
+ if (hasScope) {
194
+ onScopeDispose(unsub);
195
+ }
196
+ }
187
197
  return promise;
188
198
  }
189
199
  return useAsyncData(config.key || key, _handler, options);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "nuxt-custom-fetch",
3
3
  "type": "module",
4
- "version": "2.2.0",
4
+ "version": "2.3.0",
5
5
  "license": "MIT",
6
6
  "repository": {
7
7
  "type": "git",
@@ -36,25 +36,25 @@
36
36
  }
37
37
  },
38
38
  "dependencies": {
39
- "@nuxt/kit": "^3.15.4",
39
+ "@nuxt/kit": "^3.16.1",
40
40
  "ohash": "^2.0.11"
41
41
  },
42
42
  "devDependencies": {
43
- "@antfu/eslint-config": "^4.4.0",
44
- "@commitlint/cli": "^19.7.1",
45
- "@commitlint/config-conventional": "^19.7.1",
43
+ "@antfu/eslint-config": "^4.10.1",
44
+ "@commitlint/cli": "^19.8.0",
45
+ "@commitlint/config-conventional": "^19.8.0",
46
46
  "@nuxt/module-builder": "^0.8.4",
47
- "@nuxt/schema": "^3.15.4",
48
- "@types/node": "^22.13.9",
47
+ "@nuxt/schema": "^3.16.1",
48
+ "@types/node": "^22.13.10",
49
49
  "changelogen": "^0.6.1",
50
50
  "commitizen": "^4.3.1",
51
51
  "cz-git": "^1.11.1",
52
- "eslint": "^9.21.0",
52
+ "eslint": "^9.22.0",
53
53
  "husky": "^9.1.7",
54
- "lint-staged": "^15.4.3",
54
+ "lint-staged": "^15.5.0",
55
55
  "nitro": "npm:nitropack",
56
- "nuxt": "^3.15.4",
57
- "typescript": "5.7.3"
56
+ "nuxt": "^3.16.1",
57
+ "typescript": "5.8.2"
58
58
  },
59
59
  "husky": {
60
60
  "hooks": {