@frontic/nuxt 1.1.0 → 1.1.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/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "frontic",
3
3
  "configKey": "frontic",
4
- "version": "1.1.0",
4
+ "version": "1.1.1",
5
5
  "compatibility": {
6
6
  "nuxt": ">=4.0.0"
7
7
  },
@@ -4,6 +4,7 @@
4
4
  * Provides query key management and query factory functions for Frontic listings.
5
5
  * Compatible with both @pinia/colada and useAsyncData patterns.
6
6
  */
7
+ import type { MaybeRefOrGetter } from 'vue';
7
8
  import type { FronticClient } from '../types/client.js';
8
9
  import type { ListingName, ResponseOf } from '../types/registry.js';
9
10
  import type { FetchListingConfig } from '../types/listing.js';
@@ -53,15 +54,35 @@ export declare const LISTING_QUERY_KEYS: {
53
54
  export declare function fetchListingQuery<TListing extends ListingName>(config: FetchListingConfig<TListing> & {
54
55
  _client?: FronticClient;
55
56
  }): {
57
+ staleTime: number;
58
+ gcTime?: number;
59
+ enabled?: MaybeRefOrGetter<boolean>;
56
60
  placeholderData?: ((previousData: ResponseOf<TListing> | undefined) => ResponseOf<TListing> | undefined) | undefined;
57
- enabled?: import("vue").MaybeRefOrGetter<boolean> | undefined;
58
- gcTime?: number | undefined;
59
61
  key: () => readonly ["listings", string, Record<string, unknown>, Record<string, unknown>, {
60
62
  readonly context: string | null;
61
63
  readonly domain: string | null;
62
64
  }];
63
65
  query: () => Promise<ResponseOf<TListing>>;
66
+ };
67
+ /**
68
+ * Cache options shared by both query modes.
69
+ *
70
+ * Standard mode reaches these through `fetchListingQuery`; infinite mode builds
71
+ * its own options object and spreads this in. Kept in one place because the two
72
+ * silently diverged once already — `enabled`, `gcTime` and `keepPreviousData`
73
+ * were accepted by the composable and dropped on the infinite path, so a query
74
+ * meant to be held back fired anyway.
75
+ */
76
+ export declare function listingQueryOptions<TData>(config: {
77
+ staleTime?: number;
78
+ gcTime?: number;
79
+ enabled?: MaybeRefOrGetter<boolean>;
80
+ keepPreviousData?: boolean;
81
+ }): {
64
82
  staleTime: number;
83
+ gcTime?: number;
84
+ enabled?: MaybeRefOrGetter<boolean>;
85
+ placeholderData?: (previousData: TData | undefined) => TData | undefined;
65
86
  };
66
87
  /**
67
88
  * Creates a cache key string from query key array
@@ -40,6 +40,11 @@ export function fetchListingQuery(config) {
40
40
  throw error;
41
41
  }
42
42
  },
43
+ ...listingQueryOptions(config)
44
+ };
45
+ }
46
+ export function listingQueryOptions(config) {
47
+ return {
43
48
  staleTime: config.staleTime ?? DEFAULT_STALE_TIME,
44
49
  ...config.gcTime !== void 0 && { gcTime: config.gcTime },
45
50
  ...config.enabled !== void 0 && { enabled: config.enabled },
@@ -13,7 +13,7 @@ import {
13
13
  seedFilterLists
14
14
  } from "../utils/filter-helpers.js";
15
15
  import { makeFilterState, processAvailableFilters, processAvailableSorts, applyFilterConfig, countActiveFilters, parseSortString, isSortAllowed } from "../utils/state-helpers.js";
16
- import { fetchListingQuery, LISTING_QUERY_KEYS } from "./listings.js";
16
+ import { fetchListingQuery, listingQueryOptions, LISTING_QUERY_KEYS } from "./listings.js";
17
17
  import { useFronticClient } from "./useFronticClient.js";
18
18
  import { emit, emitOnce, bindRouteReset, toAnalyticsItems, FRONTIC_ANALYTICS_VERSION } from "./analytics.js";
19
19
  export function useFronticSearch(name, ...args) {
@@ -146,7 +146,13 @@ export function useFronticSearch(name, ...args) {
146
146
  if (!page || typeof page !== "object") return void 0;
147
147
  return page.prev ?? void 0;
148
148
  },
149
- staleTime
149
+ // Shared with the standard branch rather than restated: this object is
150
+ // hand-built, so anything the composable accepts is dropped unless it is
151
+ // forwarded here.
152
+ // Typed against the accumulated page set, not a single response: in
153
+ // infinite mode `placeholderData` receives what the cache holds, which is
154
+ // every page fetched so far.
155
+ ...listingQueryOptions(queryConfig)
150
156
  });
151
157
  const flattenedData = computed(() => {
152
158
  const pages = infiniteResult.data.value?.pages;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@frontic/nuxt",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "description": "Nuxt module for Frontic - data fetching composables with smart caching, page routing, and context management",
5
5
  "license": "MIT",
6
6
  "author": "Frontic",