@frontic/nuxt 0.1.9 → 0.1.11
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.mjs +4 -2
- package/dist/runtime/composables/blocks.js +5 -2
- package/dist/runtime/composables/listings.js +5 -2
- package/dist/runtime/composables/pages.js +5 -2
- package/dist/runtime/composables/useFronticBlock.js +4 -1
- package/dist/runtime/composables/useFronticClient.js +1 -0
- package/dist/runtime/composables/useFronticContext.js +1 -0
- package/dist/runtime/composables/useFronticListing.js +4 -1
- package/dist/runtime/composables/useFronticPage.js +5 -1
- package/dist/runtime/composables/useFronticSearch.js +9 -3
- package/package.json +1 -1
package/dist/module.mjs
CHANGED
|
@@ -102,10 +102,12 @@ frontic: { composables: false }
|
|
|
102
102
|
});
|
|
103
103
|
if (anyComposableEnabled) {
|
|
104
104
|
if (!hasNuxtModule("@pinia/nuxt", nuxt)) {
|
|
105
|
-
await
|
|
105
|
+
const piniaModule = await import('@pinia/nuxt').then((m) => m.default);
|
|
106
|
+
await installModule(piniaModule, {}, nuxt);
|
|
106
107
|
}
|
|
107
108
|
if (!hasNuxtModule("@pinia/colada-nuxt", nuxt)) {
|
|
108
|
-
await
|
|
109
|
+
const coladaModule = await import('@pinia/colada-nuxt').then((m) => m.default);
|
|
110
|
+
await installModule(coladaModule, {}, nuxt);
|
|
109
111
|
}
|
|
110
112
|
}
|
|
111
113
|
if (anyComposableEnabled) {
|
|
@@ -14,8 +14,11 @@ export function fetchBlockQuery(config) {
|
|
|
14
14
|
return BLOCK_QUERY_KEYS.detail(config.name, key, contextKey);
|
|
15
15
|
},
|
|
16
16
|
query: async () => {
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
let client = config._client;
|
|
18
|
+
if (!client) {
|
|
19
|
+
const { useFronticClient } = await import("./useFronticClient.js");
|
|
20
|
+
client = useFronticClient();
|
|
21
|
+
}
|
|
19
22
|
const key = unwrapRef(config.key);
|
|
20
23
|
const contextKey = unwrapRef(config.contextKey);
|
|
21
24
|
const contextDomain = unwrapRef(config.contextDomain);
|
|
@@ -28,8 +28,11 @@ export function fetchListingQuery(config) {
|
|
|
28
28
|
const page = unwrapRef(config.page);
|
|
29
29
|
const queryWithPage = page ? { ...query, page } : query;
|
|
30
30
|
try {
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
let client = config._client;
|
|
32
|
+
if (!client) {
|
|
33
|
+
const { useFronticClient } = await import("./useFronticClient.js");
|
|
34
|
+
client = useFronticClient();
|
|
35
|
+
}
|
|
33
36
|
const result = await client.listing(config.name, params, {
|
|
34
37
|
query: queryWithPage,
|
|
35
38
|
contextKey,
|
|
@@ -14,8 +14,11 @@ export function fetchPageQuery(config) {
|
|
|
14
14
|
return PAGE_QUERY_KEYS.detail(slug, contextKey);
|
|
15
15
|
},
|
|
16
16
|
query: async () => {
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
let client = config._client;
|
|
18
|
+
if (!client) {
|
|
19
|
+
const { useFronticClient } = await import("./useFronticClient.js");
|
|
20
|
+
client = useFronticClient();
|
|
21
|
+
}
|
|
19
22
|
const slug = unwrapRef(config.slug);
|
|
20
23
|
const contextKey = unwrapRef(config.contextKey);
|
|
21
24
|
const contextDomain = unwrapRef(config.contextDomain);
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { useQuery } from "@pinia/colada";
|
|
2
2
|
import { fetchBlockQuery } from "./blocks.js";
|
|
3
|
+
import { useFronticClient } from "./useFronticClient.js";
|
|
3
4
|
export function useFronticBlock(name, key, options) {
|
|
5
|
+
const _client = useFronticClient();
|
|
4
6
|
const blockQuery = fetchBlockQuery({
|
|
5
7
|
name,
|
|
6
8
|
key,
|
|
7
9
|
contextKey: options?.contextKey,
|
|
8
10
|
contextDomain: options?.contextDomain,
|
|
9
11
|
requestUrl: options?.requestUrl,
|
|
10
|
-
staleTime: options?.staleTime
|
|
12
|
+
staleTime: options?.staleTime,
|
|
13
|
+
_client
|
|
11
14
|
});
|
|
12
15
|
const { data, status, refresh, refetch } = useQuery(blockQuery);
|
|
13
16
|
return {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { useQuery } from "@pinia/colada";
|
|
2
2
|
import { fetchListingQuery } from "./listings.js";
|
|
3
|
+
import { useFronticClient } from "./useFronticClient.js";
|
|
3
4
|
export function useFronticListing(name, params, options) {
|
|
5
|
+
const _client = useFronticClient();
|
|
4
6
|
const listingQuery = fetchListingQuery({
|
|
5
7
|
name,
|
|
6
8
|
params,
|
|
@@ -9,7 +11,8 @@ export function useFronticListing(name, params, options) {
|
|
|
9
11
|
contextKey: options?.contextKey,
|
|
10
12
|
contextDomain: options?.contextDomain,
|
|
11
13
|
requestUrl: options?.requestUrl,
|
|
12
|
-
staleTime: options?.staleTime
|
|
14
|
+
staleTime: options?.staleTime,
|
|
15
|
+
_client
|
|
13
16
|
});
|
|
14
17
|
const { data, status, refresh, refetch } = useQuery(listingQuery);
|
|
15
18
|
return {
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { useRequestURL, useRuntimeConfig, computed, toValue, watch, navigateTo, createError } from "#imports";
|
|
1
2
|
import { useQuery } from "@pinia/colada";
|
|
2
3
|
import { fetchPageQuery } from "./pages.js";
|
|
4
|
+
import { useFronticClient } from "./useFronticClient.js";
|
|
3
5
|
export function useFronticPage(slug, options) {
|
|
4
6
|
const requestURL = useRequestURL();
|
|
5
7
|
const config = useRuntimeConfig();
|
|
@@ -7,12 +9,14 @@ export function useFronticPage(slug, options) {
|
|
|
7
9
|
if (slug) return toValue(slug);
|
|
8
10
|
return `${requestURL.host}${requestURL.pathname}`;
|
|
9
11
|
});
|
|
12
|
+
const _client = useFronticClient();
|
|
10
13
|
const pageQuery = fetchPageQuery({
|
|
11
14
|
slug: pageSlug,
|
|
12
15
|
contextKey: options?.contextKey,
|
|
13
16
|
contextDomain: options?.contextDomain,
|
|
14
17
|
requestUrl: options?.requestUrl,
|
|
15
|
-
staleTime: options?.staleTime
|
|
18
|
+
staleTime: options?.staleTime,
|
|
19
|
+
_client
|
|
16
20
|
});
|
|
17
21
|
const { data, status, refresh, refetch } = useQuery(pageQuery);
|
|
18
22
|
const redirectOn301 = options?.redirectOn301 ?? config.public.frontic?.redirectOn301 ?? true;
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
+
import { useState, computed, watch, ref } from "#imports";
|
|
1
2
|
import { useQuery, useMutation, useQueryCache } from "@pinia/colada";
|
|
2
3
|
import { useDebounceFn } from "@vueuse/core";
|
|
3
4
|
import { makeLogicalFilter, manageFilter, removeFilter } from "../utils/filter-helpers.js";
|
|
4
5
|
import { makeFilterState, processAvailableFilters, processAvailableSorts, applyFilterConfig, countActiveFilters, parseSortString, isSortAllowed } from "../utils/state-helpers.js";
|
|
5
6
|
import { fetchListingQuery } from "./listings.js";
|
|
7
|
+
import { useFronticClient } from "./useFronticClient.js";
|
|
6
8
|
export function useFronticSearch(name, params, options) {
|
|
7
9
|
const queryCache = useQueryCache();
|
|
10
|
+
const _client = useFronticClient();
|
|
8
11
|
const listingName = name;
|
|
9
12
|
const cacheKey = options?.cacheKey ?? String(name);
|
|
10
13
|
const contextKey = options?.contextKey;
|
|
@@ -62,7 +65,8 @@ export function useFronticSearch(name, params, options) {
|
|
|
62
65
|
contextKey,
|
|
63
66
|
contextDomain,
|
|
64
67
|
requestUrl,
|
|
65
|
-
staleTime
|
|
68
|
+
staleTime,
|
|
69
|
+
_client
|
|
66
70
|
})
|
|
67
71
|
);
|
|
68
72
|
const { mutateAsync: loadNext } = useMutation({
|
|
@@ -77,7 +81,8 @@ export function useFronticSearch(name, params, options) {
|
|
|
77
81
|
contextDomain,
|
|
78
82
|
requestUrl,
|
|
79
83
|
page: ref(nextPage.next),
|
|
80
|
-
staleTime
|
|
84
|
+
staleTime,
|
|
85
|
+
_client
|
|
81
86
|
});
|
|
82
87
|
return await nextPageQuery.query();
|
|
83
88
|
},
|
|
@@ -162,7 +167,8 @@ export function useFronticSearch(name, params, options) {
|
|
|
162
167
|
contextDomain,
|
|
163
168
|
requestUrl,
|
|
164
169
|
page: ref(pageNumber),
|
|
165
|
-
staleTime
|
|
170
|
+
staleTime,
|
|
171
|
+
_client
|
|
166
172
|
});
|
|
167
173
|
const response = await pageQuery.query();
|
|
168
174
|
if (response) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@frontic/nuxt",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.11",
|
|
4
4
|
"description": "Nuxt module for Frontstack headless commerce - zero config data fetching composables with smart caching, page routing, and context management",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Frontic",
|