nuxt-nightly 4.2.0-29331232.6f9cb0d2 → 4.2.0-29331656.27fe4652

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.
@@ -96,6 +96,6 @@ type NuxtLinkDefaultSlotProps<CustomProp extends boolean = false> = CustomProp e
96
96
  type NuxtLinkSlots<CustomProp extends boolean = false> = {
97
97
  default?: (props: NuxtLinkDefaultSlotProps<CustomProp>) => VNode[];
98
98
  };
99
- export declare function defineNuxtLink(options: NuxtLinkOptions): (new <CustomProp extends boolean = false>(props: NuxtLinkProps<CustomProp> & VNodeProps & AllowedComponentProps & AnchorHTMLAttributes) => InstanceType<DefineSetupFnComponent<NuxtLinkProps<CustomProp> & VNodeProps & AllowedComponentProps & Omit<AnchorHTMLAttributes, "href">, [], SlotsType<NuxtLinkSlots<CustomProp>>>>) & Record<string, any>;
100
- declare const _default: (new <CustomProp extends boolean = false>(props: NuxtLinkProps<CustomProp> & VNodeProps & AllowedComponentProps & AnchorHTMLAttributes) => InstanceType<DefineSetupFnComponent<NuxtLinkProps<CustomProp> & VNodeProps & AllowedComponentProps & Omit<AnchorHTMLAttributes, "href">, [], SlotsType<NuxtLinkSlots<CustomProp>>>>) & Record<string, any>;
99
+ export declare function defineNuxtLink(options: NuxtLinkOptions): (new <CustomProp extends boolean = false>(props: NuxtLinkProps<CustomProp> & VNodeProps & AllowedComponentProps & AnchorHTMLAttributes) => InstanceType<DefineSetupFnComponent<NuxtLinkProps<CustomProp> & VNodeProps & AllowedComponentProps & AnchorHTMLAttributes, [], SlotsType<NuxtLinkSlots<CustomProp>>>>) & Record<string, any>;
100
+ declare const _default: (new <CustomProp extends boolean = false>(props: NuxtLinkProps<CustomProp> & VNodeProps & AllowedComponentProps & AnchorHTMLAttributes) => InstanceType<DefineSetupFnComponent<NuxtLinkProps<CustomProp> & VNodeProps & AllowedComponentProps & AnchorHTMLAttributes, [], SlotsType<NuxtLinkSlots<CustomProp>>>>) & Record<string, any>;
101
101
  export default _default;
@@ -3,9 +3,6 @@ import type { NuxtApp } from '../nuxt.js';
3
3
  import type { NuxtError } from './error.js';
4
4
  export type AsyncDataRequestStatus = 'idle' | 'pending' | 'success' | 'error';
5
5
  export type _Transform<Input = any, Output = any> = (input: Input) => Output | Promise<Output>;
6
- export type AsyncDataHandler<ResT> = (nuxtApp: NuxtApp, options: {
7
- signal: AbortSignal;
8
- }) => Promise<ResT>;
9
6
  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;
10
7
  export type KeysOf<T> = Array<T extends T ? keyof T extends string ? keyof T : never : never>;
11
8
  export type KeyOfRes<Transform extends _Transform> = KeysOf<ReturnType<Transform>>;
@@ -63,10 +60,6 @@ export interface AsyncDataOptions<ResT, DataT = ResT, PickKeys extends KeysOf<Da
63
60
  * @default 'cancel'
64
61
  */
65
62
  dedupe?: 'cancel' | 'defer';
66
- /**
67
- * A timeout in milliseconds after which the request will be aborted if it has not resolved yet.
68
- */
69
- timeout?: number;
70
63
  }
71
64
  export interface AsyncDataExecuteOptions {
72
65
  /**
@@ -78,8 +71,6 @@ export interface AsyncDataExecuteOptions {
78
71
  cause?: AsyncDataRefreshCause;
79
72
  /** @internal */
80
73
  cachedData?: any;
81
- signal?: AbortSignal;
82
- timeout?: number;
83
74
  }
84
75
  export interface _AsyncData<DataT, ErrorT> {
85
76
  data: Ref<DataT>;
@@ -98,8 +89,8 @@ export type AsyncData<Data, Error> = _AsyncData<Data, Error> & Promise<_AsyncDat
98
89
  * @param handler An asynchronous function that must return a truthy value (for example, it should not be `undefined` or `null`) or the request may be duplicated on the client side.
99
90
  * @param options customize the behavior of useAsyncData
100
91
  */
101
- export declare function useAsyncData<ResT, NuxtErrorDataT = unknown, DataT = ResT, PickKeys extends KeysOf<DataT> = KeysOf<DataT>, DefaultT = undefined>(handler: AsyncDataHandler<ResT>, options?: AsyncDataOptions<ResT, DataT, PickKeys, DefaultT>): AsyncData<PickFrom<DataT, PickKeys> | DefaultT, (NuxtErrorDataT extends Error | NuxtError ? NuxtErrorDataT : NuxtError<NuxtErrorDataT>) | undefined>;
102
- export declare function useAsyncData<ResT, NuxtErrorDataT = unknown, DataT = ResT, PickKeys extends KeysOf<DataT> = KeysOf<DataT>, DefaultT = DataT>(handler: AsyncDataHandler<ResT>, options?: AsyncDataOptions<ResT, DataT, PickKeys, DefaultT>): AsyncData<PickFrom<DataT, PickKeys> | DefaultT, (NuxtErrorDataT extends Error | NuxtError ? NuxtErrorDataT : NuxtError<NuxtErrorDataT>) | undefined>;
92
+ export declare function useAsyncData<ResT, NuxtErrorDataT = unknown, DataT = ResT, PickKeys extends KeysOf<DataT> = KeysOf<DataT>, DefaultT = undefined>(handler: (ctx?: NuxtApp) => Promise<ResT>, options?: AsyncDataOptions<ResT, DataT, PickKeys, DefaultT>): AsyncData<PickFrom<DataT, PickKeys> | DefaultT, (NuxtErrorDataT extends Error | NuxtError ? NuxtErrorDataT : NuxtError<NuxtErrorDataT>) | undefined>;
93
+ export declare function useAsyncData<ResT, NuxtErrorDataT = unknown, DataT = ResT, PickKeys extends KeysOf<DataT> = KeysOf<DataT>, DefaultT = DataT>(handler: (ctx?: NuxtApp) => Promise<ResT>, options?: AsyncDataOptions<ResT, DataT, PickKeys, DefaultT>): AsyncData<PickFrom<DataT, PickKeys> | DefaultT, (NuxtErrorDataT extends Error | NuxtError ? NuxtErrorDataT : NuxtError<NuxtErrorDataT>) | undefined>;
103
94
  /**
104
95
  * Provides access to data that resolves asynchronously in an SSR-friendly composable.
105
96
  * See {@link https://nuxt.com/docs/4.x/api/composables/use-async-data}
@@ -107,8 +98,8 @@ export declare function useAsyncData<ResT, NuxtErrorDataT = unknown, DataT = Res
107
98
  * @param handler An asynchronous function that must return a truthy value (for example, it should not be `undefined` or `null`) or the request may be duplicated on the client side.
108
99
  * @param options customize the behavior of useAsyncData
109
100
  */
110
- export declare function useAsyncData<ResT, NuxtErrorDataT = unknown, DataT = ResT, PickKeys extends KeysOf<DataT> = KeysOf<DataT>, DefaultT = undefined>(key: MaybeRefOrGetter<string>, handler: AsyncDataHandler<ResT>, options?: AsyncDataOptions<ResT, DataT, PickKeys, DefaultT>): AsyncData<PickFrom<DataT, PickKeys> | DefaultT, (NuxtErrorDataT extends Error | NuxtError ? NuxtErrorDataT : NuxtError<NuxtErrorDataT>) | undefined>;
111
- export declare function useAsyncData<ResT, NuxtErrorDataT = unknown, DataT = ResT, PickKeys extends KeysOf<DataT> = KeysOf<DataT>, DefaultT = DataT>(key: MaybeRefOrGetter<string>, handler: AsyncDataHandler<ResT>, options?: AsyncDataOptions<ResT, DataT, PickKeys, DefaultT>): AsyncData<PickFrom<DataT, PickKeys> | DefaultT, (NuxtErrorDataT extends Error | NuxtError ? NuxtErrorDataT : NuxtError<NuxtErrorDataT>) | undefined>;
101
+ export declare function useAsyncData<ResT, NuxtErrorDataT = unknown, DataT = ResT, PickKeys extends KeysOf<DataT> = KeysOf<DataT>, DefaultT = undefined>(key: MaybeRefOrGetter<string>, handler: (ctx?: NuxtApp) => Promise<ResT>, options?: AsyncDataOptions<ResT, DataT, PickKeys, DefaultT>): AsyncData<PickFrom<DataT, PickKeys> | DefaultT, (NuxtErrorDataT extends Error | NuxtError ? NuxtErrorDataT : NuxtError<NuxtErrorDataT>) | undefined>;
102
+ export declare function useAsyncData<ResT, NuxtErrorDataT = unknown, DataT = ResT, PickKeys extends KeysOf<DataT> = KeysOf<DataT>, DefaultT = DataT>(key: MaybeRefOrGetter<string>, handler: (ctx?: NuxtApp) => Promise<ResT>, options?: AsyncDataOptions<ResT, DataT, PickKeys, DefaultT>): AsyncData<PickFrom<DataT, PickKeys> | DefaultT, (NuxtErrorDataT extends Error | NuxtError ? NuxtErrorDataT : NuxtError<NuxtErrorDataT>) | undefined>;
112
103
  /**
113
104
  * Provides access to data that resolves asynchronously in an SSR-friendly composable.
114
105
  * See {@link https://nuxt.com/docs/4.x/api/composables/use-lazy-async-data}
@@ -116,8 +107,8 @@ export declare function useAsyncData<ResT, NuxtErrorDataT = unknown, DataT = Res
116
107
  * @param handler An asynchronous function that must return a truthy value (for example, it should not be `undefined` or `null`) or the request may be duplicated on the client side.
117
108
  * @param options customize the behavior of useLazyAsyncData
118
109
  */
119
- export declare function useLazyAsyncData<ResT, NuxtErrorDataT = unknown, DataT = ResT, PickKeys extends KeysOf<DataT> = KeysOf<DataT>, DefaultT = undefined>(handler: AsyncDataHandler<ResT>, options?: Omit<AsyncDataOptions<ResT, DataT, PickKeys, DefaultT>, 'lazy'>): AsyncData<PickFrom<DataT, PickKeys> | DefaultT, (NuxtErrorDataT extends Error | NuxtError ? NuxtErrorDataT : NuxtError<NuxtErrorDataT>) | undefined>;
120
- export declare function useLazyAsyncData<ResT, NuxtErrorDataT = unknown, DataT = ResT, PickKeys extends KeysOf<DataT> = KeysOf<DataT>, DefaultT = DataT>(handler: AsyncDataHandler<ResT>, options?: Omit<AsyncDataOptions<ResT, DataT, PickKeys, DefaultT>, 'lazy'>): AsyncData<PickFrom<DataT, PickKeys> | DefaultT, (NuxtErrorDataT extends Error | NuxtError ? NuxtErrorDataT : NuxtError<NuxtErrorDataT>) | undefined>;
110
+ export declare function useLazyAsyncData<ResT, NuxtErrorDataT = unknown, DataT = ResT, PickKeys extends KeysOf<DataT> = KeysOf<DataT>, DefaultT = undefined>(handler: (ctx?: NuxtApp) => Promise<ResT>, options?: Omit<AsyncDataOptions<ResT, DataT, PickKeys, DefaultT>, 'lazy'>): AsyncData<PickFrom<DataT, PickKeys> | DefaultT, (NuxtErrorDataT extends Error | NuxtError ? NuxtErrorDataT : NuxtError<NuxtErrorDataT>) | undefined>;
111
+ export declare function useLazyAsyncData<ResT, NuxtErrorDataT = unknown, DataT = ResT, PickKeys extends KeysOf<DataT> = KeysOf<DataT>, DefaultT = DataT>(handler: (ctx?: NuxtApp) => Promise<ResT>, options?: Omit<AsyncDataOptions<ResT, DataT, PickKeys, DefaultT>, 'lazy'>): AsyncData<PickFrom<DataT, PickKeys> | DefaultT, (NuxtErrorDataT extends Error | NuxtError ? NuxtErrorDataT : NuxtError<NuxtErrorDataT>) | undefined>;
121
112
  /**
122
113
  * Provides access to data that resolves asynchronously in an SSR-friendly composable.
123
114
  * See {@link https://nuxt.com/docs/4.x/api/composables/use-lazy-async-data}
@@ -125,8 +116,8 @@ export declare function useLazyAsyncData<ResT, NuxtErrorDataT = unknown, DataT =
125
116
  * @param handler An asynchronous function that must return a truthy value (for example, it should not be `undefined` or `null`) or the request may be duplicated on the client side.
126
117
  * @param options customize the behavior of useLazyAsyncData
127
118
  */
128
- export declare function useLazyAsyncData<ResT, NuxtErrorDataT = unknown, DataT = ResT, PickKeys extends KeysOf<DataT> = KeysOf<DataT>, DefaultT = undefined>(key: MaybeRefOrGetter<string>, handler: AsyncDataHandler<ResT>, options?: Omit<AsyncDataOptions<ResT, DataT, PickKeys, DefaultT>, 'lazy'>): AsyncData<PickFrom<DataT, PickKeys> | DefaultT, (NuxtErrorDataT extends Error | NuxtError ? NuxtErrorDataT : NuxtError<NuxtErrorDataT>) | undefined>;
129
- export declare function useLazyAsyncData<ResT, NuxtErrorDataT = unknown, DataT = ResT, PickKeys extends KeysOf<DataT> = KeysOf<DataT>, DefaultT = DataT>(key: MaybeRefOrGetter<string>, handler: AsyncDataHandler<ResT>, options?: Omit<AsyncDataOptions<ResT, DataT, PickKeys, DefaultT>, 'lazy'>): AsyncData<PickFrom<DataT, PickKeys> | DefaultT, (NuxtErrorDataT extends Error | NuxtError ? NuxtErrorDataT : NuxtError<NuxtErrorDataT>) | undefined>;
119
+ export declare function useLazyAsyncData<ResT, NuxtErrorDataT = unknown, DataT = ResT, PickKeys extends KeysOf<DataT> = KeysOf<DataT>, DefaultT = undefined>(key: MaybeRefOrGetter<string>, handler: (ctx?: NuxtApp) => Promise<ResT>, options?: Omit<AsyncDataOptions<ResT, DataT, PickKeys, DefaultT>, 'lazy'>): AsyncData<PickFrom<DataT, PickKeys> | DefaultT, (NuxtErrorDataT extends Error | NuxtError ? NuxtErrorDataT : NuxtError<NuxtErrorDataT>) | undefined>;
120
+ export declare function useLazyAsyncData<ResT, NuxtErrorDataT = unknown, DataT = ResT, PickKeys extends KeysOf<DataT> = KeysOf<DataT>, DefaultT = DataT>(key: MaybeRefOrGetter<string>, handler: (ctx?: NuxtApp) => Promise<ResT>, options?: Omit<AsyncDataOptions<ResT, DataT, PickKeys, DefaultT>, 'lazy'>): AsyncData<PickFrom<DataT, PickKeys> | DefaultT, (NuxtErrorDataT extends Error | NuxtError ? NuxtErrorDataT : NuxtError<NuxtErrorDataT>) | undefined>;
130
121
  /** @since 3.1.0 */
131
122
  export declare function useNuxtData<DataT = any>(key: string): {
132
123
  data: Ref<DataT | undefined>;
@@ -142,5 +133,4 @@ export type CreatedAsyncData<ResT, NuxtErrorDataT = unknown, DataT = ResT, Defau
142
133
  _init: boolean;
143
134
  _deps: number;
144
135
  _execute: (opts?: AsyncDataExecuteOptions) => Promise<void>;
145
- _abortController?: AbortController;
146
136
  };
@@ -174,17 +174,7 @@ You can use a different key or move the call to a composable to ensure the optio
174
174
  return nuxtApp._asyncData[key.value].execute(...args2);
175
175
  },
176
176
  execute: (...args2) => asyncReturn.refresh(...args2),
177
- clear: () => {
178
- const entry = nuxtApp._asyncData[key.value];
179
- if (entry?._abortController) {
180
- try {
181
- entry._abortController.abort(new DOMException("AsyncData aborted by user.", "AbortError"));
182
- } finally {
183
- entry._abortController = void 0;
184
- }
185
- }
186
- clearNuxtDataByKey(nuxtApp, key.value);
187
- }
177
+ clear: () => clearNuxtDataByKey(nuxtApp, key.value)
188
178
  };
189
179
  const asyncDataPromise = Promise.resolve(nuxtApp._asyncDataPromises[key.value]).then(() => asyncReturn);
190
180
  Object.assign(asyncDataPromise, asyncReturn);
@@ -290,6 +280,9 @@ function clearNuxtDataByKey(nuxtApp, key) {
290
280
  nuxtApp._asyncData[key].status.value = "idle";
291
281
  }
292
282
  if (key in nuxtApp._asyncDataPromises) {
283
+ if (nuxtApp._asyncDataPromises[key]) {
284
+ nuxtApp._asyncDataPromises[key].cancelled = true;
285
+ }
293
286
  nuxtApp._asyncDataPromises[key] = void 0;
294
287
  }
295
288
  }
@@ -303,13 +296,13 @@ function pick(obj, keys) {
303
296
  function createAsyncData(nuxtApp, key, _handler, options, initialCachedData) {
304
297
  nuxtApp.payload._errors[key] ??= void 0;
305
298
  const hasCustomGetCachedData = options.getCachedData !== getDefaultCachedData;
306
- const handler = import.meta.client || !import.meta.prerender || !nuxtApp.ssrContext?._sharedPrerenderCache ? _handler : (nuxtApp2, options2) => {
307
- const value = nuxtApp2.ssrContext._sharedPrerenderCache.get(key);
299
+ const handler = import.meta.client || !import.meta.prerender || !nuxtApp.ssrContext?._sharedPrerenderCache ? _handler : () => {
300
+ const value = nuxtApp.ssrContext._sharedPrerenderCache.get(key);
308
301
  if (value) {
309
302
  return value;
310
303
  }
311
- const promise = Promise.resolve().then(() => nuxtApp2.runWithContext(() => _handler(nuxtApp2, options2)));
312
- nuxtApp2.ssrContext._sharedPrerenderCache.set(key, promise);
304
+ const promise = Promise.resolve().then(() => nuxtApp.runWithContext(() => _handler(nuxtApp)));
305
+ nuxtApp.ssrContext._sharedPrerenderCache.set(key, promise);
313
306
  return promise;
314
307
  };
315
308
  const _ref = options.deep ? ref : shallowRef;
@@ -334,6 +327,7 @@ function createAsyncData(nuxtApp, key, _handler, options, initialCachedData) {
334
327
  if ((opts.dedupe ?? options.dedupe) === "defer") {
335
328
  return nuxtApp._asyncDataPromises[key];
336
329
  }
330
+ nuxtApp._asyncDataPromises[key].cancelled = true;
337
331
  }
338
332
  if (granularCachedData || opts.cause === "initial" || nuxtApp.isHydrating) {
339
333
  const cachedData = "cachedData" in opts ? opts.cachedData : options.getCachedData(key, nuxtApp, { cause: opts.cause ?? "refresh:manual" });
@@ -347,31 +341,19 @@ function createAsyncData(nuxtApp, key, _handler, options, initialCachedData) {
347
341
  if (pendingWhenIdle) {
348
342
  asyncData.pending.value = true;
349
343
  }
350
- if (asyncData._abortController) {
351
- asyncData._abortController.abort(new DOMException("AsyncData request cancelled by deduplication", "AbortError"));
352
- }
353
- asyncData._abortController = new AbortController();
354
344
  asyncData.status.value = "pending";
355
345
  const promise = new Promise(
356
346
  (resolve, reject) => {
357
347
  try {
358
- const timeout = opts.timeout ?? options.timeout;
359
- const mergedSignal = mergeAbortSignals([asyncData._abortController?.signal, opts?.signal], timeout);
360
- if (mergedSignal.aborted) {
361
- const reason = mergedSignal.reason;
362
- reject(reason instanceof Error ? reason : new DOMException(String(reason ?? "Aborted"), "AbortError"));
363
- return;
364
- }
365
- mergedSignal.addEventListener("abort", () => {
366
- const reason = mergedSignal.reason;
367
- reject(reason instanceof Error ? reason : new DOMException(String(reason ?? "Aborted"), "AbortError"));
368
- }, { once: true });
369
- return Promise.resolve(handler(nuxtApp, { signal: mergedSignal })).then(resolve, reject);
348
+ resolve(handler(nuxtApp));
370
349
  } catch (err) {
371
350
  reject(err);
372
351
  }
373
352
  }
374
353
  ).then(async (_result) => {
354
+ if (promise.cancelled) {
355
+ return nuxtApp._asyncDataPromises[key];
356
+ }
375
357
  let result = _result;
376
358
  if (options.transform) {
377
359
  result = await options.transform(_result);
@@ -389,20 +371,16 @@ function createAsyncData(nuxtApp, key, _handler, options, initialCachedData) {
389
371
  asyncData.error.value = void 0;
390
372
  asyncData.status.value = "success";
391
373
  }).catch((error) => {
392
- if (nuxtApp._asyncDataPromises[key] && nuxtApp._asyncDataPromises[key] !== promise) {
393
- return;
394
- }
395
- if (asyncData._abortController?.signal.aborted) {
396
- return;
397
- }
398
- if (typeof DOMException !== "undefined" && error instanceof DOMException && error.name === "AbortError") {
399
- asyncData.status.value = "idle";
400
- return;
374
+ if (promise.cancelled) {
375
+ return nuxtApp._asyncDataPromises[key];
401
376
  }
402
377
  asyncData.error.value = createError(error);
403
378
  asyncData.data.value = unref(options.default());
404
379
  asyncData.status.value = "error";
405
380
  }).finally(() => {
381
+ if (promise.cancelled) {
382
+ return;
383
+ }
406
384
  if (pendingWhenIdle) {
407
385
  asyncData.pending.value = false;
408
386
  }
@@ -450,40 +428,3 @@ function createHash(_handler, options) {
450
428
  getCachedData: options.getCachedData ? hash(options.getCachedData) : void 0
451
429
  };
452
430
  }
453
- function mergeAbortSignals(signals, timeout) {
454
- const list = signals.filter((s) => !!s);
455
- if (typeof timeout === "number" && timeout >= 0) {
456
- const timeoutSignal = AbortSignal.timeout?.(timeout);
457
- if (timeoutSignal) {
458
- list.push(timeoutSignal);
459
- }
460
- }
461
- if (AbortSignal.any) {
462
- return AbortSignal.any(list);
463
- }
464
- const controller = new AbortController();
465
- for (const sig of list) {
466
- if (sig.aborted) {
467
- const reason = sig.reason ?? new DOMException("Aborted", "AbortError");
468
- try {
469
- controller.abort(reason);
470
- } catch {
471
- controller.abort();
472
- }
473
- return controller.signal;
474
- }
475
- }
476
- const onAbort = () => {
477
- const abortedSignal = list.find((s) => s.aborted);
478
- const reason = abortedSignal?.reason ?? new DOMException("Aborted", "AbortError");
479
- try {
480
- controller.abort(reason);
481
- } catch {
482
- controller.abort();
483
- }
484
- };
485
- for (const sig of list) {
486
- sig.addEventListener?.("abort", onAbort, { once: true });
487
- }
488
- return controller.signal;
489
- }
@@ -11,7 +11,7 @@ interface NitroFetchOptions<R extends NitroFetchRequest, M extends AvailableRout
11
11
  method?: M;
12
12
  }
13
13
  type ComputedFetchOptions<R extends NitroFetchRequest, M extends AvailableRouterMethod<R>, DataT = any> = ComputedOptions<NitroFetchOptions<R, M, DataT>>;
14
- export interface UseFetchOptions<ResT, DataT = ResT, PickKeys extends KeysOf<DataT> = KeysOf<DataT>, DefaultT = undefined, R extends NitroFetchRequest = string & {}, M extends AvailableRouterMethod<R> = AvailableRouterMethod<R>> extends Omit<AsyncDataOptions<ResT, DataT, PickKeys, DefaultT>, 'watch'>, Omit<ComputedFetchOptions<R, M, DataT>, 'timeout'> {
14
+ export interface UseFetchOptions<ResT, DataT = ResT, PickKeys extends KeysOf<DataT> = KeysOf<DataT>, DefaultT = undefined, R extends NitroFetchRequest = string & {}, M extends AvailableRouterMethod<R> = AvailableRouterMethod<R>> extends Omit<AsyncDataOptions<ResT, DataT, PickKeys, DefaultT>, 'watch'>, ComputedFetchOptions<R, M, DataT> {
15
15
  key?: MaybeRefOrGetter<string>;
16
16
  $fetch?: typeof globalThis.$fetch;
17
17
  watch?: MultiWatchSources | false;
@@ -22,7 +22,6 @@ export function useFetch(request, arg1, arg2) {
22
22
  getCachedData,
23
23
  deep,
24
24
  dedupe,
25
- timeout,
26
25
  ...fetchOptions
27
26
  } = opts;
28
27
  const _fetchOptions = reactive({
@@ -40,7 +39,6 @@ export function useFetch(request, arg1, arg2) {
40
39
  getCachedData,
41
40
  deep,
42
41
  dedupe,
43
- timeout,
44
42
  watch: watchSources === false ? [] : [...watchSources || [], _fetchOptions]
45
43
  };
46
44
  if (import.meta.dev) {
@@ -53,7 +51,16 @@ export function useFetch(request, arg1, arg2) {
53
51
  watch(key, setImmediate, { flush: "sync", once: true });
54
52
  watch([...watchSources || [], _fetchOptions], setImmediate, { flush: "sync", once: true });
55
53
  }
56
- const asyncData = useAsyncData(watchSources === false ? key.value : key, (_, { signal }) => {
54
+ let controller;
55
+ const asyncData = useAsyncData(watchSources === false ? key.value : key, () => {
56
+ controller?.abort?.(new DOMException("Request aborted as another request to the same endpoint was initiated.", "AbortError"));
57
+ controller = typeof AbortController !== "undefined" ? new AbortController() : {};
58
+ const timeoutLength = toValue(opts.timeout);
59
+ let timeoutId;
60
+ if (timeoutLength) {
61
+ timeoutId = setTimeout(() => controller.abort(new DOMException("Request aborted due to timeout.", "AbortError")), timeoutLength);
62
+ controller.signal.onabort = () => clearTimeout(timeoutId);
63
+ }
57
64
  let _$fetch = opts.$fetch || globalThis.$fetch;
58
65
  if (import.meta.server && !opts.$fetch) {
59
66
  const isLocalFetch = typeof _request.value === "string" && _request.value[0] === "/" && (!toValue(opts.baseURL) || toValue(opts.baseURL)[0] === "/");
@@ -61,7 +68,9 @@ export function useFetch(request, arg1, arg2) {
61
68
  _$fetch = useRequestFetch();
62
69
  }
63
70
  }
64
- return _$fetch(_request.value, { signal, ..._fetchOptions });
71
+ return _$fetch(_request.value, { signal: controller.signal, ..._fetchOptions }).finally(() => {
72
+ clearTimeout(timeoutId);
73
+ });
65
74
  }, _asyncDataOptions);
66
75
  return asyncData;
67
76
  }
@@ -123,8 +123,6 @@ interface _NuxtApp {
123
123
  _execute: (opts?: AsyncDataExecuteOptions) => Promise<void>;
124
124
  /** @internal */
125
125
  _hash?: Record<string, string | undefined>;
126
- /** @internal */
127
- _abortController?: AbortController;
128
126
  } | undefined>;
129
127
  /** @internal */
130
128
  _loadingIndicator?: LoadingIndicator;
@@ -10,7 +10,7 @@ import { getQuery as getURLQuery, joinURL } from "ufo";
10
10
  import { propsToString, renderSSRHead } from "@unhead/vue/server";
11
11
  import destr from "destr";
12
12
  import { defineRenderHandler, getRouteRules, useNitroApp } from "nitropack/runtime";
13
- import { getRenderer } from "../utils/renderer/build-files.js";
13
+ import { getEntryIds, getRenderer } from "../utils/renderer/build-files.js";
14
14
  import { payloadCache } from "../utils/cache.js";
15
15
  import { renderPayloadJsonScript, renderPayloadResponse, renderPayloadScript, splitPayload } from "../utils/renderer/payload.js";
16
16
  import { createSSRContext, setSSRError } from "../utils/renderer/app.js";
@@ -18,7 +18,6 @@ import { renderInlineStyles } from "../utils/renderer/inline-styles.js";
18
18
  import { replaceIslandTeleports } from "../utils/renderer/islands.js";
19
19
  import { renderSSRHeadOptions } from "#internal/unhead.config.mjs";
20
20
  import { appHead, appTeleportAttrs, appTeleportTag, componentIslands, appManifest as isAppManifestEnabled } from "#internal/nuxt.config.mjs";
21
- import entryIds from "#internal/nuxt/entry-ids.mjs";
22
21
  import { entryFileName } from "#internal/entry-chunk.mjs";
23
22
  import { buildAssetsURL, publicAssetsURL } from "#internal/nuxt/paths";
24
23
  import { relative } from "pathe";
@@ -78,7 +77,7 @@ export default defineRenderHandler(async (event) => {
78
77
  }
79
78
  }
80
79
  if (process.env.NUXT_INLINE_STYLES) {
81
- for (const id of entryIds) {
80
+ for (const id of await getEntryIds()) {
82
81
  ssrContext.modules.add(id);
83
82
  }
84
83
  }
@@ -20,3 +20,4 @@ export declare function getRenderer(ssrContext: NuxtSSRContext): Promise<{
20
20
  }>;
21
21
  }>;
22
22
  export declare const getSSRStyles: () => Promise<Record<string, () => Promise<string[]>>>;
23
+ export declare const getEntryIds: () => Promise<string[]>;
@@ -10,19 +10,21 @@ const APP_ROOT_OPEN_TAG = `<${appRootTag}${propsToString(appRootAttrs)}>`;
10
10
  const APP_ROOT_CLOSE_TAG = `</${appRootTag}>`;
11
11
  const getServerEntry = () => import("#build/dist/server/server.mjs").then((r) => r.default || r);
12
12
  const getClientManifest = () => import("#build/dist/server/client.manifest.mjs").then((r) => r.default || r).then((r) => typeof r === "function" ? r() : r);
13
- const getPrecomputedDependencies = () => import("#build/dist/server/client.precomputed.mjs").then((r) => r.default || r).then((r) => typeof r === "function" ? r() : r);
14
13
  export const getSSRRenderer = lazyCachedFunction(async () => {
14
+ const manifest = await getClientManifest();
15
+ if (!manifest) {
16
+ throw new Error("client.manifest is not available");
17
+ }
15
18
  const createSSRApp = await getServerEntry();
16
19
  if (!createSSRApp) {
17
20
  throw new Error("Server bundle is not available");
18
21
  }
19
- const precomputed = import.meta.dev ? void 0 : await getPrecomputedDependencies();
20
- const renderer = createRenderer(createSSRApp, {
21
- precomputed,
22
- manifest: import.meta.dev ? await getClientManifest() : void 0,
22
+ const options = {
23
+ manifest,
23
24
  renderToString,
24
25
  buildAssetsURL
25
- });
26
+ };
27
+ const renderer = createRenderer(createSSRApp, options);
26
28
  async function renderToString(input, context) {
27
29
  const html = await _renderToString(input, context);
28
30
  if (import.meta.dev && process.env.NUXT_VITE_NODE_OPTIONS) {
@@ -33,7 +35,7 @@ export const getSSRRenderer = lazyCachedFunction(async () => {
33
35
  return renderer;
34
36
  });
35
37
  const getSPARenderer = lazyCachedFunction(async () => {
36
- const precomputed = import.meta.dev ? void 0 : await getPrecomputedDependencies();
38
+ const manifest = await getClientManifest();
37
39
  const spaTemplate = await import("#spa-template").then((r) => r.template).catch(() => "").then((r) => {
38
40
  if (spaLoadingTemplateOutside) {
39
41
  const APP_SPA_LOADER_OPEN_TAG = `<${appSpaLoaderTag}${propsToString(appSpaLoaderAttrs)}>`;
@@ -45,13 +47,13 @@ const getSPARenderer = lazyCachedFunction(async () => {
45
47
  return APP_ROOT_OPEN_TAG + r + APP_ROOT_CLOSE_TAG;
46
48
  }
47
49
  });
48
- const renderer = createRenderer(() => () => {
49
- }, {
50
- precomputed,
51
- manifest: import.meta.dev ? await getClientManifest() : void 0,
50
+ const options = {
51
+ manifest,
52
52
  renderToString: () => spaTemplate,
53
53
  buildAssetsURL
54
- });
54
+ };
55
+ const renderer = createRenderer(() => () => {
56
+ }, options);
55
57
  const result = await renderer.renderToString({});
56
58
  const renderToString = (ssrContext) => {
57
59
  const config = useRuntimeConfig(ssrContext.event);
@@ -84,3 +86,12 @@ export function getRenderer(ssrContext) {
84
86
  return process.env.NUXT_NO_SSR || ssrContext.noSSR ? getSPARenderer() : getSSRRenderer();
85
87
  }
86
88
  export const getSSRStyles = lazyCachedFunction(() => import("#build/dist/server/styles.mjs").then((r) => r.default || r));
89
+ export const getEntryIds = () => getClientManifest().then((r) => {
90
+ const entryIds = [];
91
+ for (const entry of Object.values(r)) {
92
+ if (entry._globalCSS) {
93
+ entryIds.push(entry.src);
94
+ }
95
+ }
96
+ return entryIds;
97
+ });
package/dist/index.mjs CHANGED
@@ -2049,6 +2049,7 @@ const vuePreset = defineUnimportPreset({
2049
2049
  "hasInjectionContext",
2050
2050
  "nextTick",
2051
2051
  "provide",
2052
+ "mergeModels",
2052
2053
  "toValue",
2053
2054
  "useModel",
2054
2055
  "useAttrs",
@@ -2281,7 +2282,7 @@ const ISLAND_RE = /\.island(?:\.global)?$/;
2281
2282
  const GLOBAL_RE = /\.global(?:\.island)?$/;
2282
2283
  const COMPONENT_MODE_RE = /(?<=\.)(client|server)(?:\.global|\.island)*$/;
2283
2284
  const MODE_REPLACEMENT_RE = /(?:\.(?:client|server))?(?:\.global|\.island)*$/;
2284
- async function scanComponents(dirs) {
2285
+ async function scanComponents(dirs, srcDir) {
2285
2286
  const components = [];
2286
2287
  const filePaths = /* @__PURE__ */ new Set();
2287
2288
  const scannedPaths = [];
@@ -2337,6 +2338,7 @@ async function scanComponents(dirs) {
2337
2338
  }
2338
2339
  resolvedNames.set(pascalName + suffix, filePath);
2339
2340
  const kebabName = kebabCase(componentNameSegments);
2341
+ const shortPath = relative(srcDir, filePath);
2340
2342
  const chunkName = "components/" + kebabName + suffix;
2341
2343
  let component = {
2342
2344
  // inheritable from directory configuration
@@ -2352,6 +2354,7 @@ async function scanComponents(dirs) {
2352
2354
  pascalName,
2353
2355
  kebabName,
2354
2356
  chunkName,
2357
+ shortPath,
2355
2358
  export: "default",
2356
2359
  // by default, give priority to scanned components
2357
2360
  priority: dir.priority ?? 1,
@@ -3483,7 +3486,7 @@ const componentsModule = defineNuxtModule({
3483
3486
  });
3484
3487
  const serverPlaceholderPath = await findPath(join(distDir, "app/components/server-placeholder")) ?? join(distDir, "app/components/server-placeholder");
3485
3488
  nuxt.hook("app:templates", async (app) => {
3486
- const newComponents = await scanComponents(componentDirs);
3489
+ const newComponents = await scanComponents(componentDirs, nuxt.options.srcDir);
3487
3490
  await nuxt.callHook("components:extend", newComponents);
3488
3491
  for (const component of newComponents) {
3489
3492
  if (!component._scanned && !(component.filePath in nuxt.vfs) && isAbsolute(component.filePath) && !existsSync(component.filePath)) {
@@ -3830,7 +3833,7 @@ function addDeclarationTemplates(ctx, options) {
3830
3833
  });
3831
3834
  }
3832
3835
 
3833
- const version = "4.2.0-29331232.6f9cb0d2";
3836
+ const version = "4.2.0-29331656.27fe4652";
3834
3837
 
3835
3838
  const createImportProtectionPatterns = (nuxt, options) => {
3836
3839
  const patterns = [];
@@ -4206,8 +4209,7 @@ async function initNitro(nuxt) {
4206
4209
  "#internal/nuxt/app-config": () => nuxt.vfs["#build/app.config.mjs"]?.replace(/\/\*\* client \*\*\/[\s\S]*\/\*\* client-end \*\*\//, "") || "",
4207
4210
  "#spa-template": async () => `export const template = ${JSON.stringify(await spaLoadingTemplate(nuxt))}`,
4208
4211
  // this will be overridden in vite plugin
4209
- "#internal/entry-chunk.mjs": () => `export const entryFileName = undefined`,
4210
- "#internal/nuxt/entry-ids.mjs": () => `export default []`
4212
+ "#internal/entry-chunk.mjs": () => `export const entryFileName = undefined`
4211
4213
  },
4212
4214
  routeRules: {
4213
4215
  "/__nuxt_error": { cache: false }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nuxt-nightly",
3
- "version": "4.2.0-29331232.6f9cb0d2",
3
+ "version": "4.2.0-29331656.27fe4652",
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.5",
70
- "@nuxt/kit": "npm:@nuxt/kit-nightly@4.2.0-29331232.6f9cb0d2",
71
- "@nuxt/schema": "npm:@nuxt/schema-nightly@4.2.0-29331232.6f9cb0d2",
70
+ "@nuxt/kit": "npm:@nuxt/kit-nightly@4.2.0-29331656.27fe4652",
71
+ "@nuxt/schema": "npm:@nuxt/schema-nightly@4.2.0-29331656.27fe4652",
72
72
  "@nuxt/telemetry": "^2.6.6",
73
- "@nuxt/vite-builder": "npm:@nuxt/vite-builder-nightly@4.2.0-29331232.6f9cb0d2",
73
+ "@nuxt/vite-builder": "npm:@nuxt/vite-builder-nightly@4.2.0-29331656.27fe4652",
74
74
  "@unhead/vue": "^2.0.14",
75
75
  "@vue/shared": "^3.5.22",
76
76
  "c12": "^3.3.0",
@@ -112,7 +112,6 @@
112
112
  "radix3": "^1.1.2",
113
113
  "scule": "^1.3.0",
114
114
  "semver": "^7.7.2",
115
- "seroval": "^1.3.2",
116
115
  "std-env": "^3.9.0",
117
116
  "tinyglobby": "^0.2.15",
118
117
  "ufo": "^1.6.1",