@frontic/nuxt 1.3.1 → 1.3.2
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
package/dist/module.mjs
CHANGED
|
@@ -168,6 +168,13 @@ frontic: { composables: false }
|
|
|
168
168
|
nitroConfig.alias ||= {};
|
|
169
169
|
nitroConfig.alias["@frontic/stack"] = clientDirPath;
|
|
170
170
|
});
|
|
171
|
+
nuxt.hook("nitro:prepare:types", ({ references }) => {
|
|
172
|
+
if (!hasFronticClient) return;
|
|
173
|
+
for (const file of ["generated-types.d.ts", "fetch-api.d.ts"]) {
|
|
174
|
+
const path = join(clientDirPath, file);
|
|
175
|
+
if (existsSync(path)) references.push({ path });
|
|
176
|
+
}
|
|
177
|
+
});
|
|
171
178
|
nuxt.hook("prepare:types", ({ tsConfig }) => {
|
|
172
179
|
tsConfig.compilerOptions ||= {};
|
|
173
180
|
tsConfig.compilerOptions.paths ||= {};
|
|
@@ -313,6 +320,22 @@ declare module 'nitropack/types' {
|
|
|
313
320
|
export {}
|
|
314
321
|
`
|
|
315
322
|
});
|
|
323
|
+
addTypeTemplate(
|
|
324
|
+
{
|
|
325
|
+
filename: "types/frontic-fetch-error.nitro.d.ts",
|
|
326
|
+
getContents: () => `import type { FronticFetchErrorPayload } from '${errorsModule}'
|
|
327
|
+
|
|
328
|
+
declare module 'nitropack/types' {
|
|
329
|
+
interface NitroRuntimeHooks {
|
|
330
|
+
'frontic:fetch:error': (payload: FronticFetchErrorPayload) => void | Promise<void>
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
export {}
|
|
335
|
+
`
|
|
336
|
+
},
|
|
337
|
+
{ nitro: true }
|
|
338
|
+
);
|
|
316
339
|
}
|
|
317
340
|
nuxt.options.runtimeConfig.public.frontic = {
|
|
318
341
|
hasFronticClient,
|
|
@@ -143,6 +143,7 @@ export function useFronticSearch(name, ...args) {
|
|
|
143
143
|
initialDataUpdatedAt: options?.initialDataUpdatedAt,
|
|
144
144
|
_client
|
|
145
145
|
};
|
|
146
|
+
const isEnabled = () => toValue(options?.enabled) !== false;
|
|
146
147
|
let data;
|
|
147
148
|
let status;
|
|
148
149
|
let asyncStatus;
|
|
@@ -225,18 +226,21 @@ export function useFronticSearch(name, ...args) {
|
|
|
225
226
|
if (loaded) emitListingResolved(loaded, "loadMore");
|
|
226
227
|
};
|
|
227
228
|
loadNextFn = async () => {
|
|
229
|
+
if (!isEnabled()) return flattenedData.value;
|
|
228
230
|
const pageParamBefore = edgePageParam("last");
|
|
229
231
|
await infiniteResult.loadNextPage();
|
|
230
232
|
emitLoadedPage("last", pageParamBefore);
|
|
231
233
|
return flattenedData.value;
|
|
232
234
|
};
|
|
233
235
|
loadPrevFn = async () => {
|
|
236
|
+
if (!isEnabled()) return flattenedData.value;
|
|
234
237
|
const pageParamBefore = edgePageParam("first");
|
|
235
238
|
await infiniteResult.loadPreviousPage();
|
|
236
239
|
emitLoadedPage("first", pageParamBefore);
|
|
237
240
|
return flattenedData.value;
|
|
238
241
|
};
|
|
239
242
|
loadPageFn = async (page) => {
|
|
243
|
+
if (!isEnabled()) return flattenedData.value;
|
|
240
244
|
const pagedQueryFactory = fetchListingQuery({
|
|
241
245
|
...queryConfig,
|
|
242
246
|
page: ref(page)
|
|
@@ -382,8 +386,9 @@ export function useFronticSearch(name, ...args) {
|
|
|
382
386
|
function resetPage() {
|
|
383
387
|
_page.value = void 0;
|
|
384
388
|
}
|
|
385
|
-
function withIntent(trigger, changedFilter) {
|
|
386
|
-
|
|
389
|
+
async function withIntent(trigger, changedFilter) {
|
|
390
|
+
if (!isEnabled()) return;
|
|
391
|
+
await runRefresh({ trigger, changedFilter });
|
|
387
392
|
}
|
|
388
393
|
const triggerSearchFromInput = useDebounceFn(() => {
|
|
389
394
|
const committed = searchTerm.value.trim().length > searchTermThreshold ? searchTerm.value : void 0;
|
|
@@ -36,9 +36,9 @@ export interface FronticQueryOptions {
|
|
|
36
36
|
*/
|
|
37
37
|
gcTime?: number;
|
|
38
38
|
/**
|
|
39
|
-
* Whether the query fetches. While `false`, no request is made
|
|
40
|
-
*
|
|
41
|
-
* not known yet.
|
|
39
|
+
* Whether the query fetches. While `false`, no request is made except by an
|
|
40
|
+
* explicit `refresh()` or `refetch()` call; flipping it back to `true`
|
|
41
|
+
* refreshes. Useful when an input (e.g. a reactive key) is not known yet.
|
|
42
42
|
* @default true
|
|
43
43
|
*/
|
|
44
44
|
enabled?: MaybeRefOrGetter<boolean>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@frontic/nuxt",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.2",
|
|
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",
|
|
@@ -56,7 +56,8 @@
|
|
|
56
56
|
"test": "vitest run",
|
|
57
57
|
"test:watch": "vitest watch",
|
|
58
58
|
"test:coverage": "vitest run --coverage",
|
|
59
|
-
"clean": "rm -rf dist .nuxt"
|
|
59
|
+
"clean": "rm -rf dist .nuxt",
|
|
60
|
+
"emit:docs-manifest": "node scripts/emit-docs-manifest.js"
|
|
60
61
|
},
|
|
61
62
|
"dependencies": {
|
|
62
63
|
"@nuxt/kit": "^4.5.2",
|