@scayle/storefront-product-detail 1.5.0 → 1.5.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/CHANGELOG.md CHANGED
@@ -1,5 +1,26 @@
1
1
  # @scayle/storefront-product-detail
2
2
 
3
+ ## 1.5.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Added a runtime configuration option to control how many recently viewed products are kept.
8
+
9
+ To configure the maximum number of recently viewed products, add the following to the `public` section of your `runtimeConfig` in `nuxt.config.ts`:
10
+
11
+ ```ts
12
+ export default defineNuxtConfig({
13
+ modules: ['@scayle/storefront-product-detail'],
14
+ runtimeConfig: {
15
+ public: {
16
+ 'product-detail': {
17
+ maxRecentlyViewedProducts: 15,
18
+ },
19
+ },
20
+ },
21
+ })
22
+ ```
23
+
3
24
  ## 1.5.0
4
25
 
5
26
  ### Minor Changes
@@ -9,15 +30,15 @@
9
30
  Example usage:
10
31
 
11
32
  ```ts
12
- import { useRecentlyViewedProducts } from "#storefront-product-detail/composables";
33
+ import { useRecentlyViewedProducts } from '#storefront-product-detail/composables'
13
34
 
14
35
  const { products, addProduct, loadMissingProducts } =
15
- useRecentlyViewedProducts();
36
+ useRecentlyViewedProducts()
16
37
 
17
38
  onBeforeMount(async () => {
18
- addProductId(1234);
19
- await loadMissingProducts();
20
- });
39
+ addProductId(1234)
40
+ await loadMissingProducts()
41
+ })
21
42
  ```
22
43
 
23
44
  ## 1.4.2
@@ -49,44 +70,46 @@
49
70
 
50
71
  ```ts
51
72
  useProductSeoData({
52
- name: "Name",
53
- brand: "Brand",
54
- productDescription: "Description",
73
+ name: 'Name',
74
+ brand: 'Brand',
75
+ productDescription: 'Description',
55
76
  variants: variants.value.map((variant) => {
56
77
  return generateProductSchema({
57
- productName: "Name",
78
+ productName: 'Name',
58
79
  variant,
59
80
  url: `${$config.public.baseUrl}${route.fullPath}`,
60
81
  size,
61
- });
82
+ })
62
83
  }),
63
84
  images: images.value,
64
85
  productId: product.value?.id || 0,
65
86
  color: formatColors(colors.value),
66
- variesBy:
67
- variants.value.length > 1 ? ["https://schema.org/size"] : undefined,
68
- });
87
+ variesBy: variants.value.length > 1
88
+ ? ['https://schema.org/size']
89
+ : undefined,
90
+ })
69
91
 
70
92
  // Will become
71
93
 
72
94
  useProductSeoData({
73
- name: "Name",
74
- brand: "Brand",
75
- productDescription: "Description",
95
+ name: 'Name',
96
+ brand: 'Brand',
97
+ productDescription: 'Description',
76
98
  variants: variants.value.map((variant) => {
77
99
  return generateProductSchema({
78
- productName: "Name",
100
+ productName: 'Name',
79
101
  variant,
80
102
  url: `${$config.public.baseUrl}${route.fullPath}`,
81
103
  size,
82
104
  images: images.value[0],
83
- });
105
+ })
84
106
  }),
85
107
  productId: product.value?.id || 0,
86
108
  color: formatColors(colors.value),
87
- variesBy:
88
- variants.value.length > 1 ? ["https://schema.org/size"] : undefined,
89
- });
109
+ variesBy: variants.value.length > 1
110
+ ? ['https://schema.org/size']
111
+ : undefined,
112
+ })
90
113
  ```
91
114
 
92
115
  ## 1.2.0
@@ -99,7 +122,7 @@
99
122
 
100
123
  ### Patch Changes
101
124
 
102
- - Use absolute URL's inproduct breadcrumbs JSONLD returned by `useProductSeoData`
125
+ - Use absolute URL's in product breadcrumbs JSONLD returned by `useProductSeoData`
103
126
 
104
127
  ## 1.1.3
105
128
 
package/dist/module.d.mts CHANGED
@@ -3,6 +3,13 @@ import * as _nuxt_schema from '@nuxt/schema';
3
3
  interface ModuleOptions {
4
4
  autoImports?: boolean;
5
5
  }
6
+ declare module '@nuxt/schema' {
7
+ interface PublicRuntimeConfig {
8
+ 'product-detail': {
9
+ maxRecentlyViewedProducts?: number;
10
+ };
11
+ }
12
+ }
6
13
  declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
7
14
 
8
15
  export { _default as default };
package/dist/module.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@scayle/storefront-product-detail",
3
3
  "configKey": "product-detail",
4
- "version": "1.5.0",
4
+ "version": "1.5.1",
5
5
  "compatibility": {
6
6
  "bridge": false,
7
7
  "nuxt": ">=3.13"
8
8
  },
9
9
  "builder": {
10
- "@nuxt/module-builder": "1.0.1",
11
- "unbuild": "3.5.0"
10
+ "@nuxt/module-builder": "1.0.2",
11
+ "unbuild": "3.6.0"
12
12
  }
13
13
  }
package/dist/module.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import { defineNuxtModule, createResolver, addImportsDir } from '@nuxt/kit';
2
2
 
3
3
  const PACKAGE_NAME = "@scayle/storefront-product-detail";
4
- const PACKAGE_VERSION = "1.5.0";
4
+ const PACKAGE_VERSION = "1.5.1";
5
5
  const module = defineNuxtModule({
6
6
  meta: {
7
7
  name: PACKAGE_NAME,
@@ -17,6 +17,8 @@ const module = defineNuxtModule({
17
17
  const { resolve, resolvePath } = createResolver(import.meta.url);
18
18
  nuxt.options.alias["#storefront-product-detail"] = resolve("./runtime");
19
19
  nuxt.options.build.transpile.push("#storefront-product-detail/runtime");
20
+ nuxt.options.runtimeConfig.public["product-detail"] ??= {};
21
+ nuxt.options.runtimeConfig.public["product-detail"].maxRecentlyViewedProducts ??= 10;
20
22
  nuxt.hook("storefront:custom-rpc:extend", async (customRpcs) => {
21
23
  customRpcs.push({
22
24
  source: await resolvePath("./runtime/rpc/methods/products"),
@@ -1,8 +1,9 @@
1
1
  import { useCurrentShop, useRpcCall } from "@scayle/storefront-nuxt/composables";
2
2
  import { useLocalStorage } from "@vueuse/core";
3
- import { useState } from "nuxt/app";
3
+ import { useState, useRuntimeConfig } from "nuxt/app";
4
4
  export function useRecentlyViewedProducts(options) {
5
5
  const shop = useCurrentShop();
6
+ const maxRecentlyViewedProducts = useRuntimeConfig().public["product-detail"].maxRecentlyViewedProducts ?? 10;
6
7
  const recentlyViewedProductsIds = useLocalStorage(
7
8
  `${shop.value.shopId}-recently-viewed-products`,
8
9
  []
@@ -26,7 +27,7 @@ export function useRecentlyViewedProducts(options) {
26
27
  productIds.splice(productIds.indexOf(productId), 1);
27
28
  }
28
29
  productIds.unshift(productId);
29
- if (productIds.length > 10) {
30
+ if (productIds.length > maxRecentlyViewedProducts) {
30
31
  productIds.pop();
31
32
  }
32
33
  recentlyViewedProductsIds.value = productIds;
@@ -69,7 +70,7 @@ export function useRecentlyViewedProducts(options) {
69
70
  return -1;
70
71
  }
71
72
  return aIndex - bIndex;
72
- }).slice(0, 10);
73
+ }).slice(0, maxRecentlyViewedProducts);
73
74
  status.value = "success";
74
75
  } catch (e) {
75
76
  error.value = e;
@@ -1,4 +1,5 @@
1
- export const getAllShopProductsForId = async function getAllShopProductsForId2(options, context) {
1
+ import { defineRpcHandler } from "@scayle/storefront-nuxt";
2
+ export const getAllShopProductsForId = defineRpcHandler(async (options, context) => {
2
3
  const { runtimeConfiguration, sapiClient, log, cached } = context;
3
4
  const fetchAllProducts = async () => {
4
5
  const products = [];
@@ -29,4 +30,4 @@ export const getAllShopProductsForId = async function getAllShopProductsForId2(o
29
30
  // 12 hours
30
31
  })();
31
32
  return result;
32
- };
33
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scayle/storefront-product-detail",
3
- "version": "1.5.0",
3
+ "version": "1.5.1",
4
4
  "description": "Collection of essential composables and utilities to work with product detail",
5
5
  "author": "SCAYLE Commerce Engine",
6
6
  "license": "MIT",
@@ -30,7 +30,6 @@
30
30
  "peerDependencies": {
31
31
  "@nuxt/kit": ">=3.13.0",
32
32
  "@scayle/storefront-nuxt": "^8.0.0",
33
- "@vue/test-utils": "^2.4.6",
34
33
  "@vueuse/core": "^12.8.2 || ^13.0.0",
35
34
  "schema-dts": "^1.1.5",
36
35
  "vue-router": "^4.5.0",
@@ -38,29 +37,28 @@
38
37
  },
39
38
  "devDependencies": {
40
39
  "@arethetypeswrong/cli": "0.18.2",
41
- "@nuxt/kit": "3.16.2",
42
- "@nuxt/module-builder": "1.0.1",
43
- "@nuxt/schema": "3.16.2",
40
+ "@nuxt/kit": "3.17.7",
41
+ "@nuxt/module-builder": "1.0.2",
42
+ "@nuxt/schema": "3.17.7",
44
43
  "@nuxt/test-utils": "3.19.2",
45
- "@scayle/eslint-config-storefront": "4.5.12",
46
- "@scayle/storefront-nuxt": "8.32.0",
47
- "@types/node": "22.15.34",
44
+ "@types/node": "22.16.5",
48
45
  "@vitest/coverage-v8": "3.2.4",
49
- "@vue/test-utils": "2.4.6",
50
- "@vueuse/core": "13.4.0",
46
+ "@vueuse/core": "13.6.0",
51
47
  "dprint": "0.50.1",
52
48
  "eslint-formatter-gitlab": "6.0.1",
53
- "eslint": "9.30.0",
49
+ "eslint": "9.32.0",
54
50
  "happy-dom": "18.0.1",
55
- "nuxt": "3.16.2",
51
+ "nuxt": "3.17.7",
56
52
  "publint": "0.3.12",
57
53
  "schema-dts": "1.1.5",
58
54
  "typescript": "5.8.3",
59
- "unbuild": "3.5.0",
55
+ "unbuild": "3.6.0",
60
56
  "vitest": "3.2.4",
61
57
  "vue-router": "4.5.1",
62
- "vue-tsc": "2.2.10",
63
- "vue": "3.5.17"
58
+ "vue-tsc": "3.0.4",
59
+ "vue": "3.5.18",
60
+ "@scayle/eslint-config-storefront": "4.7.2",
61
+ "@scayle/storefront-nuxt": "8.38.4"
64
62
  },
65
63
  "scripts": {
66
64
  "build": "nuxt-module-build build",