nuxt-nightly 4.1.3-29323687.53d177a2 → 4.1.3-29323971.d6df732e
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/app/composables/asyncData.js +23 -15
- package/dist/index.mjs +3 -3
- package/package.json +4 -4
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { computed, getCurrentInstance, getCurrentScope, inject, isShallow, nextTick, onBeforeMount, onScopeDispose, onServerPrefetch, onUnmounted, ref, shallowRef, toRef, toValue, unref, watch } from "vue";
|
|
1
|
+
import { computed, getCurrentInstance, getCurrentScope, inject, isShallow, nextTick, onBeforeMount, onScopeDispose, onServerPrefetch, onUnmounted, queuePostFlushCb, ref, shallowRef, toRef, toValue, unref, watch } from "vue";
|
|
2
2
|
import { debounce } from "perfect-debounce";
|
|
3
3
|
import { hash } from "ohash";
|
|
4
4
|
import { useNuxtApp } from "../nuxt.js";
|
|
@@ -13,6 +13,7 @@ export function useAsyncData(...args) {
|
|
|
13
13
|
args.unshift(autoKey);
|
|
14
14
|
}
|
|
15
15
|
let [_key, _handler, options = {}] = args;
|
|
16
|
+
let keyChanging = false;
|
|
16
17
|
const key = computed(() => toValue(_key));
|
|
17
18
|
if (typeof key.value !== "string") {
|
|
18
19
|
throw new TypeError("[nuxt] [useAsyncData] key must be a string.");
|
|
@@ -116,36 +117,43 @@ You can use a different key or move the call to a composable to ensure the optio
|
|
|
116
117
|
const hasScope = getCurrentScope();
|
|
117
118
|
const unsubKeyWatcher = watch(key, (newKey, oldKey) => {
|
|
118
119
|
if ((newKey || oldKey) && newKey !== oldKey) {
|
|
119
|
-
|
|
120
|
-
const
|
|
121
|
-
|
|
122
|
-
unregister(oldKey);
|
|
123
|
-
}
|
|
120
|
+
keyChanging = true;
|
|
121
|
+
const hadData = nuxtApp._asyncData[oldKey]?.data.value !== void 0;
|
|
122
|
+
const wasRunning = nuxtApp._asyncDataPromises[oldKey] !== void 0;
|
|
124
123
|
const initialFetchOptions2 = { cause: "initial", dedupe: options.dedupe };
|
|
125
124
|
if (!nuxtApp._asyncData[newKey]?._init) {
|
|
126
|
-
let
|
|
127
|
-
if (oldKey &&
|
|
128
|
-
|
|
125
|
+
let initialValue;
|
|
126
|
+
if (oldKey && hadData) {
|
|
127
|
+
initialValue = nuxtApp._asyncData[oldKey].data.value;
|
|
129
128
|
} else {
|
|
130
|
-
|
|
131
|
-
initialFetchOptions2.cachedData =
|
|
129
|
+
initialValue = options.getCachedData(newKey, nuxtApp, { cause: "initial" });
|
|
130
|
+
initialFetchOptions2.cachedData = initialValue;
|
|
132
131
|
}
|
|
133
|
-
nuxtApp._asyncData[newKey] = createAsyncData(nuxtApp, newKey, _handler, options,
|
|
132
|
+
nuxtApp._asyncData[newKey] = createAsyncData(nuxtApp, newKey, _handler, options, initialValue);
|
|
134
133
|
}
|
|
135
134
|
nuxtApp._asyncData[newKey]._deps++;
|
|
136
|
-
if (
|
|
135
|
+
if (oldKey) {
|
|
136
|
+
unregister(oldKey);
|
|
137
|
+
}
|
|
138
|
+
if (options.immediate || hadData || wasRunning) {
|
|
137
139
|
nuxtApp._asyncData[newKey].execute(initialFetchOptions2);
|
|
138
140
|
}
|
|
141
|
+
queuePostFlushCb(() => {
|
|
142
|
+
keyChanging = false;
|
|
143
|
+
});
|
|
139
144
|
}
|
|
140
145
|
}, { flush: "sync" });
|
|
141
|
-
const
|
|
146
|
+
const unsubParamsWatcher = options.watch ? watch(options.watch, () => {
|
|
147
|
+
if (keyChanging) {
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
142
150
|
asyncData._execute({ cause: "watch", dedupe: options.dedupe });
|
|
143
151
|
}) : () => {
|
|
144
152
|
};
|
|
145
153
|
if (hasScope) {
|
|
146
154
|
onScopeDispose(() => {
|
|
147
155
|
unsubKeyWatcher();
|
|
148
|
-
|
|
156
|
+
unsubParamsWatcher();
|
|
149
157
|
unregister(key.value);
|
|
150
158
|
});
|
|
151
159
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -3830,7 +3830,7 @@ function addDeclarationTemplates(ctx, options) {
|
|
|
3830
3830
|
});
|
|
3831
3831
|
}
|
|
3832
3832
|
|
|
3833
|
-
const version = "4.1.3-
|
|
3833
|
+
const version = "4.1.3-29323971.d6df732e";
|
|
3834
3834
|
|
|
3835
3835
|
const createImportProtectionPatterns = (nuxt, options) => {
|
|
3836
3836
|
const patterns = [];
|
|
@@ -6485,7 +6485,7 @@ const middlewareTemplate = {
|
|
|
6485
6485
|
] : [
|
|
6486
6486
|
`const _globalMiddleware = ${genObjectFromRawEntries(globalMiddleware.map((mw) => [reverseResolveAlias(mw.path, alias).pop() || mw.path, genSafeVariableName(mw.name)]))}`,
|
|
6487
6487
|
`for (const path in _globalMiddleware) {`,
|
|
6488
|
-
` Object.defineProperty(_globalMiddleware[path], '_path', { value: path })`,
|
|
6488
|
+
` Object.defineProperty(_globalMiddleware[path], '_path', { value: path, configurable: true })`,
|
|
6489
6489
|
`}`,
|
|
6490
6490
|
`export const globalMiddleware = Object.values(_globalMiddleware)`,
|
|
6491
6491
|
`const _namedMiddleware = ${genArrayFromRaw(namedMiddleware.map((mw) => ({
|
|
@@ -6496,7 +6496,7 @@ const middlewareTemplate = {
|
|
|
6496
6496
|
`for (const mw of _namedMiddleware) {`,
|
|
6497
6497
|
` const i = mw.import`,
|
|
6498
6498
|
` mw.import = () => i().then(r => {`,
|
|
6499
|
-
` Object.defineProperty(r.default || r, '_path', { value: mw.path })`,
|
|
6499
|
+
` Object.defineProperty(r.default || r, '_path', { value: mw.path, configurable: true })`,
|
|
6500
6500
|
` return r`,
|
|
6501
6501
|
` })`,
|
|
6502
6502
|
`}`,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-nightly",
|
|
3
|
-
"version": "4.1.3-
|
|
3
|
+
"version": "4.1.3-29323971.d6df732e",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/nuxt/nuxt.git",
|
|
@@ -67,10 +67,10 @@
|
|
|
67
67
|
"@nuxt/cli": "npm:@nuxt/cli-nightly@latest",
|
|
68
68
|
"@nuxt/devalue": "^2.0.2",
|
|
69
69
|
"@nuxt/devtools": "^2.6.3",
|
|
70
|
-
"@nuxt/kit": "npm:@nuxt/kit-nightly@4.1.3-
|
|
71
|
-
"@nuxt/schema": "npm:@nuxt/schema-nightly@4.1.3-
|
|
70
|
+
"@nuxt/kit": "npm:@nuxt/kit-nightly@4.1.3-29323971.d6df732e",
|
|
71
|
+
"@nuxt/schema": "npm:@nuxt/schema-nightly@4.1.3-29323971.d6df732e",
|
|
72
72
|
"@nuxt/telemetry": "^2.6.6",
|
|
73
|
-
"@nuxt/vite-builder": "npm:@nuxt/vite-builder-nightly@4.1.3-
|
|
73
|
+
"@nuxt/vite-builder": "npm:@nuxt/vite-builder-nightly@4.1.3-29323971.d6df732e",
|
|
74
74
|
"@unhead/vue": "^2.0.14",
|
|
75
75
|
"@vue/shared": "^3.5.21",
|
|
76
76
|
"c12": "^3.3.0",
|