@scayle/storefront-product-detail 1.5.0 → 1.5.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/CHANGELOG.md CHANGED
@@ -1,5 +1,32 @@
1
1
  # @scayle/storefront-product-detail
2
2
 
3
+ ## 1.5.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Use latest `nuxt@3.19.2` for build. Compatibility with previous version has not changed and is specified via package `peerDependencies` and Nuxt `compatibility` flag.
8
+
9
+ ## 1.5.1
10
+
11
+ ### Patch Changes
12
+
13
+ - Added a runtime configuration option to control how many recently viewed products are kept.
14
+
15
+ To configure the maximum number of recently viewed products, add the following to the `public` section of your `runtimeConfig` in `nuxt.config.ts`:
16
+
17
+ ```ts
18
+ export default defineNuxtConfig({
19
+ modules: ['@scayle/storefront-product-detail'],
20
+ runtimeConfig: {
21
+ public: {
22
+ 'product-detail': {
23
+ maxRecentlyViewedProducts: 15,
24
+ },
25
+ },
26
+ },
27
+ })
28
+ ```
29
+
3
30
  ## 1.5.0
4
31
 
5
32
  ### Minor Changes
@@ -9,15 +36,15 @@
9
36
  Example usage:
10
37
 
11
38
  ```ts
12
- import { useRecentlyViewedProducts } from "#storefront-product-detail/composables";
39
+ import { useRecentlyViewedProducts } from '#storefront-product-detail/composables'
13
40
 
14
41
  const { products, addProduct, loadMissingProducts } =
15
- useRecentlyViewedProducts();
42
+ useRecentlyViewedProducts()
16
43
 
17
44
  onBeforeMount(async () => {
18
- addProductId(1234);
19
- await loadMissingProducts();
20
- });
45
+ addProductId(1234)
46
+ await loadMissingProducts()
47
+ })
21
48
  ```
22
49
 
23
50
  ## 1.4.2
@@ -49,44 +76,46 @@
49
76
 
50
77
  ```ts
51
78
  useProductSeoData({
52
- name: "Name",
53
- brand: "Brand",
54
- productDescription: "Description",
79
+ name: 'Name',
80
+ brand: 'Brand',
81
+ productDescription: 'Description',
55
82
  variants: variants.value.map((variant) => {
56
83
  return generateProductSchema({
57
- productName: "Name",
84
+ productName: 'Name',
58
85
  variant,
59
86
  url: `${$config.public.baseUrl}${route.fullPath}`,
60
87
  size,
61
- });
88
+ })
62
89
  }),
63
90
  images: images.value,
64
91
  productId: product.value?.id || 0,
65
92
  color: formatColors(colors.value),
66
- variesBy:
67
- variants.value.length > 1 ? ["https://schema.org/size"] : undefined,
68
- });
93
+ variesBy: variants.value.length > 1
94
+ ? ['https://schema.org/size']
95
+ : undefined,
96
+ })
69
97
 
70
98
  // Will become
71
99
 
72
100
  useProductSeoData({
73
- name: "Name",
74
- brand: "Brand",
75
- productDescription: "Description",
101
+ name: 'Name',
102
+ brand: 'Brand',
103
+ productDescription: 'Description',
76
104
  variants: variants.value.map((variant) => {
77
105
  return generateProductSchema({
78
- productName: "Name",
106
+ productName: 'Name',
79
107
  variant,
80
108
  url: `${$config.public.baseUrl}${route.fullPath}`,
81
109
  size,
82
110
  images: images.value[0],
83
- });
111
+ })
84
112
  }),
85
113
  productId: product.value?.id || 0,
86
114
  color: formatColors(colors.value),
87
- variesBy:
88
- variants.value.length > 1 ? ["https://schema.org/size"] : undefined,
89
- });
115
+ variesBy: variants.value.length > 1
116
+ ? ['https://schema.org/size']
117
+ : undefined,
118
+ })
90
119
  ```
91
120
 
92
121
  ## 1.2.0
@@ -99,7 +128,7 @@
99
128
 
100
129
  ### Patch Changes
101
130
 
102
- - Use absolute URL's inproduct breadcrumbs JSONLD returned by `useProductSeoData`
131
+ - Use absolute URL's in product breadcrumbs JSONLD returned by `useProductSeoData`
103
132
 
104
133
  ## 1.1.3
105
134
 
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.2",
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.1"
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.2";
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.2",
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,29 @@
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.19.2",
41
+ "@nuxt/module-builder": "1.0.2",
42
+ "@nuxt/schema": "3.19.2",
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.18.3",
48
45
  "@vitest/coverage-v8": "3.2.4",
49
- "@vue/test-utils": "2.4.6",
50
- "@vueuse/core": "13.4.0",
51
- "dprint": "0.50.1",
46
+ "@vueuse/core": "13.9.0",
47
+ "dprint": "0.50.2",
52
48
  "eslint-formatter-gitlab": "6.0.1",
53
- "eslint": "9.30.0",
49
+ "eslint": "9.35.0",
54
50
  "happy-dom": "18.0.1",
55
- "nuxt": "3.16.2",
51
+ "nuxt": "3.19.2",
56
52
  "publint": "0.3.12",
57
53
  "schema-dts": "1.1.5",
58
- "typescript": "5.8.3",
59
- "unbuild": "3.5.0",
54
+ "typescript": "5.9.2",
55
+ "unbuild": "3.6.1",
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.7",
59
+ "vue": "3.5.21",
60
+ "@scayle/eslint-config-storefront": "4.7.8",
61
+ "@scayle/storefront-nuxt": "8.44.1",
62
+ "@scayle/vitest-config-storefront": "1.0.0"
64
63
  },
65
64
  "scripts": {
66
65
  "build": "nuxt-module-build build",