@nuxt/bridge-edge 3.0.0-27474429.5625215 → 3.0.0-27477145.7e6c4e2

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.
@@ -741,6 +741,7 @@ const appPreset = defineUnimportPreset({
741
741
  imports: [
742
742
  "useAsyncData",
743
743
  "useLazyAsyncData",
744
+ "refreshNuxtData",
744
745
  "defineNuxtComponent",
745
746
  "useNuxtApp",
746
747
  "defineNuxtPlugin",
@@ -3,7 +3,7 @@ import hash from 'hash-sum';
3
3
  import { resolve } from 'pathe';
4
4
  import { genImport, genObjectFromRawEntries } from 'knitwork';
5
5
 
6
- const version = "3.0.0-27474429.5625215";
6
+ const version = "3.0.0-27477145.7e6c4e2";
7
7
 
8
8
  const middlewareTemplate = {
9
9
  filename: "middleware.js",
@@ -22,4 +22,5 @@ export interface _AsyncData<DataT> {
22
22
  export declare type AsyncData<Data> = _AsyncData<Data> & Promise<_AsyncData<Data>>;
23
23
  export declare function useAsyncData<DataT, Transform extends _Transform<DataT> = _Transform<DataT, DataT>, PickKeys extends KeyOfRes<Transform> = KeyOfRes<Transform>>(key: string, handler: (ctx?: NuxtApp) => Promise<DataT>, options?: AsyncDataOptions<DataT, Transform, PickKeys>): AsyncData<PickFrom<ReturnType<Transform>, PickKeys>>;
24
24
  export declare function useLazyAsyncData<DataT, Transform extends _Transform<DataT> = _Transform<DataT, DataT>, PickKeys extends KeyOfRes<Transform> = KeyOfRes<Transform>>(key: string, handler: (ctx?: NuxtApp) => Promise<DataT>, options?: Omit<AsyncDataOptions<DataT, Transform, PickKeys>, 'lazy'>): AsyncData<PickFrom<ReturnType<Transform>, PickKeys>>;
25
+ export declare function refreshNuxtData(keys?: string | string[]): Promise<void>;
25
26
  export {};
@@ -73,12 +73,15 @@ export function useAsyncData(key, handler, options = {}) {
73
73
  asyncData.refresh();
74
74
  }
75
75
  if (options.watch) {
76
- const unwatch = watch(options.watch, () => {
77
- asyncData.refresh();
78
- });
79
- if (instance) {
80
- onUnmounted(() => unwatch());
76
+ watch(options.watch, () => asyncData.refresh());
77
+ }
78
+ const off = nuxt.hook("app:data:refresh", (keys) => {
79
+ if (!keys || keys.includes(key)) {
80
+ return asyncData.refresh();
81
81
  }
82
+ });
83
+ if (instance) {
84
+ onUnmounted(off);
82
85
  }
83
86
  }
84
87
  const asyncDataPromise = Promise.resolve(nuxt._asyncDataPromises[key]).then(() => asyncData);
@@ -88,6 +91,13 @@ export function useAsyncData(key, handler, options = {}) {
88
91
  export function useLazyAsyncData(key, handler, options = {}) {
89
92
  return useAsyncData(key, handler, { ...options, lazy: true });
90
93
  }
94
+ export function refreshNuxtData(keys) {
95
+ if (process.server) {
96
+ return Promise.resolve();
97
+ }
98
+ const _keys = keys ? Array.isArray(keys) ? keys : [keys] : void 0;
99
+ return useNuxtApp().callHook("app:data:refresh", _keys);
100
+ }
91
101
  function pick(obj, keys) {
92
102
  const newObj = {};
93
103
  for (const key of keys) {
@@ -3,7 +3,7 @@ import type { MetaInfo } from 'vue-meta';
3
3
  import type VueRouter from 'vue-router';
4
4
  import type { Location, Route } from 'vue-router';
5
5
  import type { RuntimeConfig } from '@nuxt/schema';
6
- export { useLazyAsyncData } from './asyncData';
6
+ export { useLazyAsyncData, refreshNuxtData } from './asyncData';
7
7
  export { useLazyFetch } from './fetch';
8
8
  export { useCookie } from './cookie';
9
9
  export { useRequestHeaders } from './ssr';
@@ -2,7 +2,7 @@ import { getCurrentInstance, onBeforeUnmount, isRef, watch, reactive, toRef, isR
2
2
  import { sendRedirect } from "h3";
3
3
  import defu from "defu";
4
4
  import { useNuxtApp } from "./app.mjs";
5
- export { useLazyAsyncData } from "./asyncData.mjs";
5
+ export { useLazyAsyncData, refreshNuxtData } from "./asyncData.mjs";
6
6
  export { useLazyFetch } from "./fetch.mjs";
7
7
  export { useCookie } from "./cookie.mjs";
8
8
  export { useRequestHeaders } from "./ssr.mjs";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuxt/bridge-edge",
3
- "version": "3.0.0-27474429.5625215",
3
+ "version": "3.0.0-27477145.7e6c4e2",
4
4
  "repository": "nuxt/framework",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -21,10 +21,10 @@
21
21
  "@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.7",
22
22
  "@babel/plugin-proposal-optional-chaining": "^7.16.7",
23
23
  "@babel/plugin-transform-typescript": "^7.16.8",
24
- "@nuxt/kit": "npm:@nuxt/kit-edge@3.0.0-27474429.5625215",
25
- "@nuxt/nitro": "npm:@nuxt/nitro-edge@3.0.0-27474429.5625215",
24
+ "@nuxt/kit": "npm:@nuxt/kit-edge@3.0.0-27477145.7e6c4e2",
25
+ "@nuxt/nitro": "npm:@nuxt/nitro-edge@3.0.0-27477145.7e6c4e2",
26
26
  "@nuxt/postcss8": "^1.1.3",
27
- "@nuxt/schema": "npm:@nuxt/schema-edge@3.0.0-27474429.5625215",
27
+ "@nuxt/schema": "npm:@nuxt/schema-edge@3.0.0-27477145.7e6c4e2",
28
28
  "@vitejs/plugin-legacy": "^1.7.1",
29
29
  "@vue/composition-api": "^1.4.9",
30
30
  "@vueuse/head": "^0.7.5",
@@ -45,7 +45,7 @@
45
45
  "mlly": "^0.5.1",
46
46
  "murmurhash-es": "^0.1.1",
47
47
  "node-fetch": "^3.2.3",
48
- "nuxi": "npm:nuxi-edge@3.0.0-27474429.5625215",
48
+ "nuxi": "npm:nuxi-edge@3.0.0-27477145.7e6c4e2",
49
49
  "ohash": "^0.1.0",
50
50
  "pathe": "^0.2.0",
51
51
  "perfect-debounce": "^0.1.3",
@@ -59,7 +59,7 @@
59
59
  "ufo": "^0.8.1",
60
60
  "unimport": "^0.1.3",
61
61
  "unplugin": "^0.6.0",
62
- "unplugin-vue2-script-setup": "^0.10.0",
62
+ "unplugin-vue2-script-setup": "^0.10.1",
63
63
  "untyped": "^0.4.3",
64
64
  "vite": "^2.8.6",
65
65
  "vite-plugin-vue2": "^1.9.3",