cloudcommerce 0.2.1 → 0.2.3
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/.eslintrc.cjs +1 -93
- package/CHANGELOG.md +37 -0
- package/ecomplus-stores/monocard/functions/ssr/package.json +2 -1
- package/ecomplus-stores/tia-sonia/functions/ssr/package.json +2 -1
- package/package.json +7 -7
- package/packages/api/package.json +1 -1
- package/packages/apps/correios/package.json +2 -2
- package/packages/apps/custom-payment/package.json +1 -1
- package/packages/apps/custom-shipping/package.json +1 -1
- package/packages/apps/datafrete/package.json +4 -4
- package/packages/apps/discounts/package.json +1 -1
- package/packages/apps/emails/package.json +2 -2
- package/packages/apps/fb-conversions/lib/fb-conversions-events.js +131 -111
- package/packages/apps/fb-conversions/lib/fb-conversions-events.js.map +1 -1
- package/packages/apps/fb-conversions/lib/functions-lib/create-fb-objects.js +69 -0
- package/packages/apps/fb-conversions/lib/functions-lib/create-fb-objects.js.map +1 -0
- package/packages/apps/fb-conversions/package.json +4 -4
- package/packages/apps/fb-conversions/src/fb-conversions-events.ts +173 -125
- package/packages/apps/fb-conversions/src/functions-lib/create-fb-objects.ts +104 -0
- package/packages/apps/frenet/package.json +4 -4
- package/packages/apps/galaxpay/lib/galaxpay-list-payments.d.ts +2 -2
- package/packages/apps/galaxpay/lib/galaxpay.d.ts +2 -2
- package/packages/apps/galaxpay/package.json +4 -4
- package/packages/apps/google-analytics/package.json +4 -4
- package/packages/apps/infinitepay/package.json +4 -4
- package/packages/apps/jadlog/package.json +2 -2
- package/packages/apps/loyalty-points/package.json +1 -1
- package/packages/apps/mercadopago/package.json +4 -4
- package/packages/apps/pagarme/package.json +4 -4
- package/packages/apps/paghiper/CHANGELOG.md +1 -0
- package/packages/apps/paghiper/README.md +1 -0
- package/packages/apps/paghiper/lib/functions-lib/create-axios.d.ts +2 -0
- package/packages/apps/paghiper/lib/functions-lib/create-axios.js +22 -0
- package/packages/apps/paghiper/lib/functions-lib/create-axios.js.map +1 -0
- package/packages/apps/paghiper/lib/functions-lib/handle-webhook.d.ts +3 -0
- package/packages/apps/paghiper/lib/functions-lib/handle-webhook.js +154 -0
- package/packages/apps/paghiper/lib/functions-lib/handle-webhook.js.map +1 -0
- package/packages/apps/paghiper/lib/index.d.ts +1 -0
- package/packages/apps/paghiper/lib/index.js +2 -0
- package/packages/apps/paghiper/lib/index.js.map +1 -0
- package/packages/apps/paghiper/lib/paghiper-create-transaction.d.ts +71 -0
- package/packages/apps/paghiper/lib/paghiper-create-transaction.js +199 -0
- package/packages/apps/paghiper/lib/paghiper-create-transaction.js.map +1 -0
- package/packages/apps/paghiper/lib/paghiper-list-payments.d.ts +7 -0
- package/packages/apps/paghiper/lib/paghiper-list-payments.js +97 -0
- package/packages/apps/paghiper/lib/paghiper-list-payments.js.map +1 -0
- package/packages/apps/paghiper/lib/paghiper-webhook.d.ts +5 -0
- package/packages/apps/paghiper/lib/paghiper-webhook.js +18 -0
- package/packages/apps/paghiper/lib/paghiper-webhook.js.map +1 -0
- package/packages/apps/paghiper/lib/paghiper.d.ts +76 -0
- package/packages/apps/paghiper/lib/paghiper.js +12 -0
- package/packages/apps/paghiper/lib/paghiper.js.map +1 -0
- package/packages/apps/paghiper/package.json +36 -0
- package/packages/apps/paghiper/src/functions-lib/create-axios.ts +21 -0
- package/packages/apps/paghiper/src/functions-lib/handle-webhook.ts +176 -0
- package/packages/apps/paghiper/src/index.ts +1 -0
- package/packages/apps/paghiper/src/paghiper-create-transaction.ts +242 -0
- package/packages/apps/paghiper/src/paghiper-list-payments.ts +127 -0
- package/packages/apps/paghiper/src/paghiper-webhook.ts +17 -0
- package/packages/apps/paghiper/src/paghiper.ts +12 -0
- package/packages/apps/paghiper/tsconfig.json +6 -0
- package/packages/apps/paghiper/types/config-app.d.ts +34 -0
- package/packages/apps/paghiper/webhook.js +1 -0
- package/packages/apps/pix/package.json +4 -4
- package/packages/apps/tiny-erp/lib/integration/post-tiny-erp.js.map +1 -1
- package/packages/apps/tiny-erp/package.json +4 -4
- package/packages/apps/tiny-erp/src/integration/post-tiny-erp.ts +1 -1
- package/packages/cli/package.json +1 -1
- package/packages/config/package.json +1 -1
- package/packages/emails/package.json +2 -2
- package/packages/events/lib/firebase.js +2 -0
- package/packages/events/lib/firebase.js.map +1 -1
- package/packages/events/package.json +4 -3
- package/packages/events/src/firebase.ts +2 -0
- package/packages/firebase/lib/config.d.ts +3 -0
- package/packages/firebase/lib/config.js +4 -0
- package/packages/firebase/lib/config.js.map +1 -1
- package/packages/firebase/package.json +3 -3
- package/packages/firebase/src/config.ts +4 -0
- package/packages/i18n/package.json +1 -1
- package/packages/modules/lib/firebase/call-app-module.js +12 -0
- package/packages/modules/lib/firebase/call-app-module.js.map +1 -1
- package/packages/modules/package.json +6 -5
- package/packages/modules/src/firebase/call-app-module.ts +12 -0
- package/packages/passport/package.json +3 -3
- package/packages/ssr/package.json +7 -7
- package/packages/storefront/.base.eslintrc.cjs +93 -0
- package/packages/storefront/.eslintrc.cjs +1 -1
- package/packages/storefront/astro.config.mjs +2 -0
- package/packages/storefront/client.d.ts +1 -1
- package/packages/storefront/config/storefront.cms.mjs +2 -2
- package/packages/storefront/dist/client/_astro/PitchBar.f3579a5b.js +1 -0
- package/packages/storefront/dist/client/_astro/Prices.8e5cead5.js +1 -0
- package/packages/storefront/dist/client/_astro/Prices.vue_vue_type_script_setup_true_lang.b8cbeb54.js +1 -0
- package/packages/storefront/dist/client/_astro/ProductCard.6d8b6d86.js +1 -0
- package/packages/storefront/dist/client/_astro/StickyHeader.7b0f3963.js +1 -0
- package/packages/storefront/dist/client/{assets/_...slug_.fea84512.css → _astro/_...slug_.97285eba.css} +1 -1
- package/packages/storefront/dist/client/_astro/client.3e777d4c.js +1 -0
- package/packages/storefront/dist/client/_astro/ecom-utils.92f137f6.js +1 -0
- package/packages/storefront/dist/client/_astro/hoisted.6edd7364.js +1 -0
- package/packages/storefront/dist/client/{assets → _astro}/index.90df622b.css +0 -0
- package/packages/storefront/dist/client/_astro/modules-info.dde776b4.js +1 -0
- package/packages/storefront/dist/client/_astro/runtime-core.esm-bundler.7cf33881.js +1 -0
- package/packages/storefront/dist/client/_astro/runtime-dom.esm-bundler.1a4c7407.js +1 -0
- package/packages/storefront/dist/client/{assets → _astro}/server.4d9646d8.css +0 -0
- package/packages/storefront/dist/client/_astro/session-utm.72684b84.js +1 -0
- package/packages/storefront/dist/client/{chunks/workbox-window.prod.es5.10f2e5ac.js → _astro/workbox-window.prod.es5.295a6886.js} +0 -0
- package/packages/storefront/dist/client/fallback/index.html +73 -0
- package/packages/storefront/dist/client/sw.js +1 -1
- package/packages/storefront/dist/server/chunks/astro.89bd9221.mjs +3378 -0
- package/packages/storefront/dist/server/chunks/pages/all.c27193d6.mjs +2195 -0
- package/packages/storefront/dist/server/chunks/prerender.89f63027.mjs +2 -0
- package/packages/storefront/dist/server/entry.mjs +516 -5742
- package/packages/storefront/package.json +9 -9
- package/packages/storefront/src/lib/components/Carousel.vue +1 -0
- package/packages/storefront/src/lib/components/CarouselControl.vue +1 -1
- package/packages/storefront/src/lib/components/PitchBar.vue +27 -10
- package/packages/storefront/src/lib/components/Prices.vue +24 -24
- package/packages/storefront/src/lib/components/StickyHeader.vue +56 -0
- package/packages/storefront/src/lib/layouts/Base.astro +6 -0
- package/packages/storefront/src/lib/layouts/BaseBody.astro +0 -1
- package/packages/storefront/src/lib/layouts/PagesHeader.astro +24 -3
- package/packages/storefront/src/lib/scripts/modules-info-preset.ts +60 -0
- package/packages/storefront/src/lib/ssr/Picture.astro +18 -0
- package/packages/storefront/src/lib/ssr/image.ts +12 -2
- package/packages/storefront/src/lib/ssr-context.ts +18 -4
- package/packages/storefront/src/lib/state/modules-info.ts +44 -14
- package/packages/storefront/src/lib/types/cms-settings.d.ts +2 -1
- package/packages/storefront/storefront.config.mjs +20 -8
- package/packages/storefront/tailwind.config.cjs +1 -1
- package/packages/types/index.ts +17 -0
- package/packages/types/package.json +1 -1
- package/packages/storefront/dist/client/PitchBar.afe7ff5c.js +0 -1
- package/packages/storefront/dist/client/Prices.eaf8a32c.js +0 -1
- package/packages/storefront/dist/client/ProductCard.1106b153.js +0 -1
- package/packages/storefront/dist/client/chunks/Prices.vue_vue_type_script_setup_true_lang.781b6501.js +0 -1
- package/packages/storefront/dist/client/chunks/ecom-utils.63984324.js +0 -1
- package/packages/storefront/dist/client/chunks/runtime-core.esm-bundler.fa6cdb60.js +0 -1
- package/packages/storefront/dist/client/chunks/session-utm.2de8b604.js +0 -1
- package/packages/storefront/dist/client/client.367a6497.js +0 -1
- package/packages/storefront/dist/client/hoisted.4671ed15.js +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudcommerce/storefront",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.3",
|
|
5
5
|
"description": "E-Com Plus Cloud Commerce storefront with Astro",
|
|
6
6
|
"main": "src/index.js",
|
|
7
7
|
"repository": {
|
|
@@ -25,11 +25,11 @@
|
|
|
25
25
|
"prepare-monorepo": "sh scripts/prepare-monorepo.sh"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@astrojs/image": "^0.
|
|
29
|
-
"@astrojs/node": "^
|
|
30
|
-
"@astrojs/partytown": "^1.0.
|
|
28
|
+
"@astrojs/image": "^0.13.0",
|
|
29
|
+
"@astrojs/node": "^5.0.1",
|
|
30
|
+
"@astrojs/partytown": "^1.0.3",
|
|
31
31
|
"@astrojs/prefetch": "^0.1.1",
|
|
32
|
-
"@astrojs/vue": "^
|
|
32
|
+
"@astrojs/vue": "^2.0.0",
|
|
33
33
|
"@cloudcommerce/api": "workspace:*",
|
|
34
34
|
"@cloudcommerce/config": "workspace:*",
|
|
35
35
|
"@cloudcommerce/i18n": "workspace:*",
|
|
@@ -40,18 +40,18 @@
|
|
|
40
40
|
"@iconify-json/heroicons": "^1.1.8",
|
|
41
41
|
"@iconify-json/logos": "^1.1.22",
|
|
42
42
|
"@vite-pwa/astro": "^0.0.1",
|
|
43
|
-
"@vueuse/core": "^9.
|
|
44
|
-
"astro": "^
|
|
43
|
+
"@vueuse/core": "^9.11.1",
|
|
44
|
+
"astro": "^2.0.2",
|
|
45
45
|
"chroma-js": "^2.4.2",
|
|
46
46
|
"dotenv": "^16.0.3",
|
|
47
|
-
"firebase": "^9.
|
|
47
|
+
"firebase": "^9.16.0",
|
|
48
48
|
"image-size": "^1.0.2",
|
|
49
49
|
"lodash": "^4.17.21",
|
|
50
50
|
"semver": "^7.3.8",
|
|
51
51
|
"sharp": "^0.31.3",
|
|
52
52
|
"tailwindcss": "^3.2.4",
|
|
53
53
|
"unocss": "^0.48.4",
|
|
54
|
-
"vite": "^
|
|
54
|
+
"vite": "^4.0.4",
|
|
55
55
|
"vite-plugin-pwa": "^0.14.1",
|
|
56
56
|
"vue": "^3.2.45"
|
|
57
57
|
},
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
+
import { computed } from 'vue';
|
|
3
|
+
import { parseShippingPhrase } from '@@sf/state/modules-info';
|
|
2
4
|
import Carousel from '@@sf/components/Carousel.vue';
|
|
3
5
|
import CarouselControl from '@@sf/components/CarouselControl.vue';
|
|
4
6
|
|
|
@@ -10,27 +12,42 @@ export interface Props {
|
|
|
10
12
|
}>;
|
|
11
13
|
}
|
|
12
14
|
|
|
13
|
-
defineProps<Props>();
|
|
15
|
+
const props = defineProps<Props>();
|
|
16
|
+
const parsedContents = computed(() => {
|
|
17
|
+
return props.slides.map(({ html }) => {
|
|
18
|
+
return parseShippingPhrase(html).value;
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
const countValidSlides = computed(() => {
|
|
22
|
+
return parsedContents.value.filter((html) => html).length;
|
|
23
|
+
});
|
|
14
24
|
</script>
|
|
15
25
|
|
|
16
26
|
<template>
|
|
17
27
|
<div data-pitch-bar class="bg-base-100">
|
|
18
28
|
<div class="container md:w-2/3 mx-auto px-3 py-1">
|
|
19
|
-
<Carousel :autoplay="7000">
|
|
20
|
-
<li v-for="(
|
|
29
|
+
<Carousel :autoplay="countValidSlides > 1 ? 7000 : null">
|
|
30
|
+
<li v-for="(slide, i) in slides" :key="i">
|
|
21
31
|
<component
|
|
22
|
-
:is="href ? 'ALink' : 'span'"
|
|
23
|
-
:href="href"
|
|
24
|
-
:target="target"
|
|
25
|
-
:class="href ? 'hover:underline' : null"
|
|
32
|
+
:is="slide.href ? 'ALink' : 'span'"
|
|
33
|
+
:href="slide.href"
|
|
34
|
+
:target="slide.target"
|
|
35
|
+
:class="slide.href ? 'hover:underline' : null"
|
|
26
36
|
>
|
|
27
|
-
<slot name="slide">
|
|
28
|
-
<span
|
|
37
|
+
<slot name="slide" v-bind="{ slide, i, parsedContents }">
|
|
38
|
+
<span
|
|
39
|
+
v-if="parsedContents[i]"
|
|
40
|
+
v-html="parsedContents[i]"
|
|
41
|
+
class="prose text-sm text-base-800"
|
|
42
|
+
></span>
|
|
29
43
|
</slot>
|
|
30
44
|
</component>
|
|
31
45
|
</li>
|
|
32
46
|
<template #controls>
|
|
33
|
-
<div
|
|
47
|
+
<div
|
|
48
|
+
v-show="countValidSlides > 1"
|
|
49
|
+
class="text-xl leading-none text-base-400"
|
|
50
|
+
>
|
|
34
51
|
<CarouselControl
|
|
35
52
|
:direction="-1"
|
|
36
53
|
class="pr-2 bg-base-100 hover:text-base-700"
|
|
@@ -68,12 +68,12 @@ const componentVariant = useComponentVariant(props);
|
|
|
68
68
|
<slot name="sale-post" />
|
|
69
69
|
</strong>
|
|
70
70
|
</slot>
|
|
71
|
-
<
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
71
|
+
<Fade slide="down">
|
|
72
|
+
<slot
|
|
73
|
+
v-if="cashbackValue"
|
|
74
|
+
name="cashback"
|
|
75
|
+
v-bind="{ salePrice, cashbackValue, cashbackPercentage }"
|
|
76
|
+
>
|
|
77
77
|
<div v-if="hasCashback" data-prices-cashback class="relative z-10">
|
|
78
78
|
<span :data-tooltip="$t.i19get$1back
|
|
79
79
|
.replace('$1', $percentage(cashbackPercentage))">
|
|
@@ -93,14 +93,14 @@ const componentVariant = useComponentVariant(props);
|
|
|
93
93
|
</slot>
|
|
94
94
|
</span>
|
|
95
95
|
</div>
|
|
96
|
-
</
|
|
97
|
-
</
|
|
98
|
-
<
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
96
|
+
</slot>
|
|
97
|
+
</Fade>
|
|
98
|
+
<Fade slide="down">
|
|
99
|
+
<slot
|
|
100
|
+
v-if="installmentValue"
|
|
101
|
+
name="installment"
|
|
102
|
+
v-bind="{ salePrice, installmentValue, installmentsNumber, monthlyInterest }"
|
|
103
|
+
>
|
|
104
104
|
<div v-if="hasPriceOptions" data-prices-installment>
|
|
105
105
|
<slot name="installment-pre">
|
|
106
106
|
<small v-if="isLiteral">
|
|
@@ -123,14 +123,14 @@ const componentVariant = useComponentVariant(props);
|
|
|
123
123
|
</small>
|
|
124
124
|
</slot>
|
|
125
125
|
</div>
|
|
126
|
-
</
|
|
127
|
-
</
|
|
128
|
-
<
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
126
|
+
</slot>
|
|
127
|
+
</Fade>
|
|
128
|
+
<Fade slide="down">
|
|
129
|
+
<slot
|
|
130
|
+
v-if="priceWithDiscount < salePrice"
|
|
131
|
+
name="discount"
|
|
132
|
+
v-bind="{ salePrice, priceWithDiscount, discountLabel }"
|
|
133
|
+
>
|
|
134
134
|
<div v-if="hasPriceOptions" data-prices-discount>
|
|
135
135
|
<slot name="discount-pre">
|
|
136
136
|
<small v-if="!discountLabel">
|
|
@@ -149,8 +149,8 @@ const componentVariant = useComponentVariant(props);
|
|
|
149
149
|
</small>
|
|
150
150
|
</slot>
|
|
151
151
|
</div>
|
|
152
|
-
</
|
|
153
|
-
</
|
|
152
|
+
</slot>
|
|
153
|
+
</Fade>
|
|
154
154
|
</div>
|
|
155
155
|
</template>
|
|
156
156
|
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { ImgHTMLAttributes } from 'vue';
|
|
3
|
+
import { ref, toRefs } from 'vue';
|
|
4
|
+
|
|
5
|
+
export interface Props {
|
|
6
|
+
logo?: ImgHTMLAttributes;
|
|
7
|
+
logoAltHeading?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | null;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
11
|
+
logoAltHeading: 'h2',
|
|
12
|
+
});
|
|
13
|
+
const { logo } = toRefs(props);
|
|
14
|
+
const fade = ref(false);
|
|
15
|
+
setTimeout(() => {
|
|
16
|
+
fade.value = true;
|
|
17
|
+
}, 2000);
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
<template>
|
|
21
|
+
<header
|
|
22
|
+
class="header bg-opacity-90 backdrop-blur-md
|
|
23
|
+
sticky top-0 z-50 py-1 sm:py-2"
|
|
24
|
+
data-sticky-header
|
|
25
|
+
>
|
|
26
|
+
<div class="container">
|
|
27
|
+
<div class="grid grid-flow-col auto-cols-max justify-between items-center">
|
|
28
|
+
<slot name="aside">
|
|
29
|
+
<div class="header__aside md:hidden">
|
|
30
|
+
<div class="i-bars-3-bottom-left"></div>
|
|
31
|
+
</div>
|
|
32
|
+
</slot>
|
|
33
|
+
<slot name="logo" v-bind="{ logo }">
|
|
34
|
+
<a v-if="logo" href="/">
|
|
35
|
+
<component :is="(logo.alt && logoAltHeading) || 'span'" class="m-0">
|
|
36
|
+
<img v-bind="logo" />
|
|
37
|
+
</component>
|
|
38
|
+
</a>
|
|
39
|
+
</slot>
|
|
40
|
+
<div class="flex items-center">
|
|
41
|
+
<slot name="actions">
|
|
42
|
+
<slot name="nav">
|
|
43
|
+
<Fade speed="slow" slide="down">
|
|
44
|
+
<div v-if="fade" class="h-20 bg-primary w-20">
|
|
45
|
+
Fadiiing
|
|
46
|
+
</div>
|
|
47
|
+
</Fade>
|
|
48
|
+
</slot>
|
|
49
|
+
<slot name="search" />
|
|
50
|
+
<slot name="buttons" />
|
|
51
|
+
</slot>
|
|
52
|
+
</div>
|
|
53
|
+
</div>
|
|
54
|
+
</div>
|
|
55
|
+
</header>
|
|
56
|
+
</template>
|
|
@@ -20,10 +20,16 @@ const cmsCustomCode = cms('code') as CmsCode;
|
|
|
20
20
|
<BaseStateJson pageContext={pageContext} />
|
|
21
21
|
{cmsCustomCode.css && <style>{cmsCustomCode.css}</style>}
|
|
22
22
|
{cmsCustomCode.html_head && <Fragment set:html={cmsCustomCode.html_head} />}
|
|
23
|
+
<slot name="base-head-scripts">
|
|
24
|
+
<script src="../scripts/modules-info-preset"></script>
|
|
25
|
+
</slot>
|
|
23
26
|
<slot name="before-head-end" />
|
|
24
27
|
</head>
|
|
25
28
|
<BaseBody pageContext={pageContext}>
|
|
26
29
|
<slot />
|
|
27
30
|
{cmsCustomCode.html_body && <Fragment set:html={cmsCustomCode.html_body} />}
|
|
31
|
+
<slot name="base-body-scripts">
|
|
32
|
+
<script src="../scripts/session-utm"></script>
|
|
33
|
+
</slot>
|
|
28
34
|
<slot name="before-body-end" />
|
|
29
35
|
</BaseBody>
|
|
@@ -3,23 +3,25 @@ import type { Categories } from '@cloudcommerce/api/types';
|
|
|
3
3
|
import type CmsHeader from '@@sf/types/cms-header';
|
|
4
4
|
import type CmsContacts from '@@sf/types/cms-contacts';
|
|
5
5
|
import type { PageContext } from '@@sf/ssr-context';
|
|
6
|
-
import
|
|
7
|
-
import { getImage } from '@@sf/ssr/image';
|
|
6
|
+
import Picture from '@@sf/ssr/Picture.astro';
|
|
8
7
|
import PitchBar, { Props as PitchBarProps } from '@@sf/components/PitchBar.vue';
|
|
8
|
+
import StickyHeader from '@@sf/components/StickyHeader.vue';
|
|
9
9
|
|
|
10
10
|
export interface Props {
|
|
11
11
|
pageContext: PageContext;
|
|
12
|
+
logoHeading?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | null;
|
|
12
13
|
}
|
|
13
14
|
|
|
14
15
|
const {
|
|
15
16
|
pageContext: {
|
|
17
|
+
isHomepage,
|
|
16
18
|
apiState,
|
|
17
19
|
settings,
|
|
18
20
|
cms,
|
|
19
21
|
},
|
|
20
22
|
} = Astro.props as Props;
|
|
21
23
|
const header = cms('header') as CmsHeader &
|
|
22
|
-
{ marketing_stripe?: { text: string, link: string } };
|
|
24
|
+
{ marketing_stripe?: { text: string, link: string }, logo?: string };
|
|
23
25
|
const pitchBar: PitchBarProps = { slides: [] };
|
|
24
26
|
if (header.pitch_bar) {
|
|
25
27
|
pitchBar.slides = header.pitch_bar;
|
|
@@ -29,10 +31,29 @@ if (header.pitch_bar) {
|
|
|
29
31
|
html: header.marketing_stripe.text,
|
|
30
32
|
}];
|
|
31
33
|
}
|
|
34
|
+
const logoSrc = header.logo || settings.logo;
|
|
35
|
+
const LogoHeading = Astro.props.logoHeading || (isHomepage ? 'h1' : 'h2');
|
|
32
36
|
---
|
|
33
37
|
|
|
34
38
|
<Fragment>
|
|
35
39
|
<slot name="pitch-bar">
|
|
36
40
|
{pitchBar.slides.length && <PitchBar {...pitchBar} client:idle />}
|
|
37
41
|
</slot>
|
|
42
|
+
<slot name="sticky-header">
|
|
43
|
+
<StickyHeader client:load>
|
|
44
|
+
<Fragment slot="logo">
|
|
45
|
+
<slot name="logo">
|
|
46
|
+
<LogoHeading>
|
|
47
|
+
<Picture
|
|
48
|
+
src={logoSrc}
|
|
49
|
+
alt={settings.name}
|
|
50
|
+
widths={[300]}
|
|
51
|
+
sizes="150px"
|
|
52
|
+
fetchpriority="high"
|
|
53
|
+
/>
|
|
54
|
+
</LogoHeading>
|
|
55
|
+
</slot>
|
|
56
|
+
</Fragment>
|
|
57
|
+
</StickyHeader>
|
|
58
|
+
</slot>
|
|
38
59
|
</Fragment>
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
type ModulesInfoPreset = typeof window.storefront.modulesInfoPreset;
|
|
2
|
+
|
|
3
|
+
const checkObjNotNull = (obj: { [k: string]: any }) => {
|
|
4
|
+
return Object.values(obj).filter((val) => val).length;
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
const getModulesInfoPreset = (settingsModules = globalThis.storefront.settings.modules) => {
|
|
8
|
+
const modulesInfoPreset: ModulesInfoPreset = {};
|
|
9
|
+
if (settingsModules) {
|
|
10
|
+
const settingsPayments = settingsModules.list_payments;
|
|
11
|
+
if (settingsPayments) {
|
|
12
|
+
const settingsDiscount = settingsPayments.discount_option;
|
|
13
|
+
if (settingsDiscount && checkObjNotNull(settingsDiscount)) {
|
|
14
|
+
modulesInfoPreset.list_payments = { discount_option: settingsDiscount };
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const settingsInstallments = settingsPayments.installments_option;
|
|
18
|
+
if (settingsInstallments?.max_number) {
|
|
19
|
+
if (!modulesInfoPreset.list_payments) modulesInfoPreset.list_payments = {};
|
|
20
|
+
modulesInfoPreset.list_payments.installments_option = settingsInstallments as
|
|
21
|
+
{ max_number: number };
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const settingsPointsPrograms = settingsPayments.loyalty_points_programs || {};
|
|
25
|
+
if (!Object.keys(settingsPointsPrograms).length) {
|
|
26
|
+
const pointsProgram = { ...settingsPayments.loyalty_points_program };
|
|
27
|
+
if (pointsProgram?.id && pointsProgram.ratio) {
|
|
28
|
+
const { id } = pointsProgram;
|
|
29
|
+
delete pointsProgram.id;
|
|
30
|
+
settingsPointsPrograms[id] = pointsProgram as { ratio: number };
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
if (Object.keys(settingsPointsPrograms).length) {
|
|
34
|
+
if (!modulesInfoPreset.list_payments) modulesInfoPreset.list_payments = {};
|
|
35
|
+
modulesInfoPreset.list_payments.loyalty_points_programs = settingsPointsPrograms;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const settingsShipping = settingsModules.calculate_shipping;
|
|
40
|
+
if (settingsShipping && settingsShipping.free_shipping_from_value) {
|
|
41
|
+
modulesInfoPreset.calculate_shipping = settingsShipping;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return modulesInfoPreset;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const loadingGlobalInfoPreset: Promise<ModulesInfoPreset> = new Promise((resolve) => {
|
|
48
|
+
if (import.meta.env.SSR) {
|
|
49
|
+
global.storefront.onLoad(() => {
|
|
50
|
+
resolve(getModulesInfoPreset());
|
|
51
|
+
});
|
|
52
|
+
} else {
|
|
53
|
+
window.storefront.modulesInfoPreset = getModulesInfoPreset();
|
|
54
|
+
resolve(window.storefront.modulesInfoPreset);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
export default loadingGlobalInfoPreset;
|
|
59
|
+
|
|
60
|
+
export { getModulesInfoPreset, loadingGlobalInfoPreset };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { Picture } from '@astrojs/image/components';
|
|
3
|
+
import { getAspectRatio } from '@@sf/ssr/image';
|
|
4
|
+
|
|
5
|
+
type PictureProps = Parameters<typeof Picture>[0];
|
|
6
|
+
|
|
7
|
+
export type Props = Omit<PictureProps, 'aspectRatio'> & {
|
|
8
|
+
aspectRatio?: PictureProps['aspectRatio'],
|
|
9
|
+
fetchpriority: 'high' | 'low' | 'auto',
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const props = Astro.props as PictureProps;
|
|
13
|
+
if (!props.aspectRatio && typeof props.src === 'string') {
|
|
14
|
+
props.aspectRatio = getAspectRatio(props.src);
|
|
15
|
+
}
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
<Picture {...props} />
|
|
@@ -15,6 +15,16 @@ const tryImageSize = (src: string) => {
|
|
|
15
15
|
return dimensions;
|
|
16
16
|
};
|
|
17
17
|
|
|
18
|
+
const getAspectRatio = (src: string | { width?: number, height?: number }) => {
|
|
19
|
+
if (typeof src === 'string') {
|
|
20
|
+
src = tryImageSize(src);
|
|
21
|
+
}
|
|
22
|
+
if (src.width) {
|
|
23
|
+
return src.height ? src.width / src.height : 1;
|
|
24
|
+
}
|
|
25
|
+
return 0;
|
|
26
|
+
};
|
|
27
|
+
|
|
18
28
|
type TransformOptions = Omit<Parameters<typeof _getImage>[0], 'alt'> & {
|
|
19
29
|
isLowResolution?: boolean,
|
|
20
30
|
alt?: string,
|
|
@@ -38,7 +48,7 @@ const getImage = async (options: TransformOptions) => {
|
|
|
38
48
|
if (!options.width) {
|
|
39
49
|
options.width = width;
|
|
40
50
|
}
|
|
41
|
-
options.aspectRatio =
|
|
51
|
+
options.aspectRatio = getAspectRatio({ width, height });
|
|
42
52
|
}
|
|
43
53
|
}
|
|
44
54
|
const imgAttrs = await _getImage({ alt: '', ...options });
|
|
@@ -55,4 +65,4 @@ const getImage = async (options: TransformOptions) => {
|
|
|
55
65
|
|
|
56
66
|
export default getImage;
|
|
57
67
|
|
|
58
|
-
export { tryImageSize, getImage };
|
|
68
|
+
export { tryImageSize, getAspectRatio, getImage };
|
|
@@ -2,6 +2,7 @@ import type { AstroGlobal } from 'astro';
|
|
|
2
2
|
import type { BaseConfig } from '@cloudcommerce/config';
|
|
3
3
|
import type { CategoriesList, BrandsList } from '@cloudcommerce/api/types';
|
|
4
4
|
import type CmsSettings from './types/cms-settings';
|
|
5
|
+
import { EventEmitter } from 'node:events';
|
|
5
6
|
import api, { ApiError, ApiEndpoint } from '@cloudcommerce/api';
|
|
6
7
|
import _getConfig from '../../storefront.config.mjs';
|
|
7
8
|
|
|
@@ -21,19 +22,28 @@ type StorefrontConfig = {
|
|
|
21
22
|
? Array<string> : Record<string, any>,
|
|
22
23
|
};
|
|
23
24
|
|
|
25
|
+
const emitter = new EventEmitter();
|
|
24
26
|
const getConfig: () => StorefrontConfig = _getConfig;
|
|
25
27
|
|
|
26
28
|
declare global {
|
|
27
29
|
// eslint-disable-next-line
|
|
28
30
|
var api_prefetch_endpoints: ApiEndpoint[];
|
|
29
31
|
// eslint-disable-next-line
|
|
30
|
-
var storefront: {
|
|
32
|
+
var storefront: {
|
|
33
|
+
settings: Partial<CmsSettings>,
|
|
34
|
+
onLoad: (callback: (...args: any[]) => void) => void,
|
|
35
|
+
};
|
|
31
36
|
}
|
|
32
37
|
if (!globalThis.api_prefetch_endpoints) {
|
|
33
38
|
globalThis.api_prefetch_endpoints = ['categories'];
|
|
34
39
|
}
|
|
35
40
|
if (!globalThis.storefront) {
|
|
36
|
-
globalThis.storefront = {
|
|
41
|
+
globalThis.storefront = {
|
|
42
|
+
settings: {},
|
|
43
|
+
onLoad(callback: (...args: any[]) => void) {
|
|
44
|
+
emitter.on('load', callback);
|
|
45
|
+
},
|
|
46
|
+
};
|
|
37
47
|
}
|
|
38
48
|
|
|
39
49
|
type ApiPrefetchEndpoints = Array<ApiEndpoint>;
|
|
@@ -56,6 +66,7 @@ const loadPageContext = async (Astro: AstroGlobal, {
|
|
|
56
66
|
} = {}) => {
|
|
57
67
|
const startedAt = Date.now();
|
|
58
68
|
const urlPath = Astro.url.pathname;
|
|
69
|
+
const isHomepage = urlPath === '/';
|
|
59
70
|
const { slug } = Astro.params;
|
|
60
71
|
const config = getConfig();
|
|
61
72
|
globalThis.storefront.settings = config.settings;
|
|
@@ -118,18 +129,21 @@ const loadPageContext = async (Astro: AstroGlobal, {
|
|
|
118
129
|
Astro.response.headers.set('X-Load-Took', String(Date.now() - startedAt));
|
|
119
130
|
if (urlPath === '/fallback') {
|
|
120
131
|
setResponseCache(Astro, 3600, 86400);
|
|
121
|
-
} else if (
|
|
132
|
+
} else if (isHomepage) {
|
|
122
133
|
setResponseCache(Astro, 180, 300);
|
|
123
134
|
} else {
|
|
124
135
|
setResponseCache(Astro, 120, 300);
|
|
125
136
|
}
|
|
126
|
-
|
|
137
|
+
const pageContext = {
|
|
127
138
|
...config,
|
|
139
|
+
isHomepage,
|
|
128
140
|
cmsContent,
|
|
129
141
|
apiResource,
|
|
130
142
|
apiDoc,
|
|
131
143
|
apiState,
|
|
132
144
|
};
|
|
145
|
+
emitter.emit('load', pageContext);
|
|
146
|
+
return pageContext;
|
|
133
147
|
};
|
|
134
148
|
|
|
135
149
|
export default loadPageContext;
|
|
@@ -3,9 +3,11 @@ import type {
|
|
|
3
3
|
CalculateShippingResponse,
|
|
4
4
|
ApplyDiscountResponse,
|
|
5
5
|
} from '@cloudcommerce/types';
|
|
6
|
-
import { reactive } from 'vue';
|
|
6
|
+
import { reactive, computed } from 'vue';
|
|
7
|
+
import { formatMoney } from '@ecomplus/utils';
|
|
8
|
+
import loadingGlobalInfoPreset from '@@sf/scripts/modules-info-preset';
|
|
9
|
+
import utm from '@@sf/scripts/session-utm';
|
|
7
10
|
import afetch from '../../helpers/afetch';
|
|
8
|
-
import utm from '../scripts/session-utm';
|
|
9
11
|
|
|
10
12
|
const emptyInfo = {
|
|
11
13
|
list_payments: {},
|
|
@@ -25,31 +27,28 @@ const modulesInfo = reactive<{
|
|
|
25
27
|
available_extra_discount?: ApplyDiscountResponse['available_extra_discount'],
|
|
26
28
|
},
|
|
27
29
|
}>(emptyInfo);
|
|
30
|
+
loadingGlobalInfoPreset.then((modulesInfoPreset) => {
|
|
31
|
+
Object.assign(modulesInfo, modulesInfoPreset);
|
|
32
|
+
});
|
|
28
33
|
|
|
29
34
|
if (!import.meta.env.SSR) {
|
|
30
35
|
const storageKey = 'MODULES_INFO';
|
|
31
36
|
const sessionJson = sessionStorage.getItem(storageKey);
|
|
32
|
-
let persistedValue;
|
|
33
37
|
if (sessionJson) {
|
|
34
38
|
try {
|
|
35
|
-
persistedValue = JSON.parse(sessionJson);
|
|
36
|
-
if (persistedValue.__timestamp
|
|
37
|
-
persistedValue
|
|
39
|
+
const persistedValue = JSON.parse(sessionJson);
|
|
40
|
+
if (persistedValue.__timestamp >= Date.now() - 1000 * 60 * 5) {
|
|
41
|
+
delete persistedValue.__timestamp;
|
|
42
|
+
Object.assign(modulesInfo, persistedValue);
|
|
43
|
+
} else {
|
|
38
44
|
sessionStorage.removeItem(storageKey);
|
|
39
45
|
}
|
|
40
|
-
delete persistedValue.__timestamp;
|
|
41
46
|
} catch (e) {
|
|
42
47
|
sessionStorage.removeItem(storageKey);
|
|
43
48
|
}
|
|
44
49
|
}
|
|
45
50
|
|
|
46
|
-
|
|
47
|
-
Object.assign(modulesInfo, persistedValue);
|
|
48
|
-
} else {
|
|
49
|
-
const modulesInfoPreset = window.storefront?.modulesInfoPreset;
|
|
50
|
-
if (modulesInfoPreset) {
|
|
51
|
-
Object.assign(modulesInfo, modulesInfoPreset);
|
|
52
|
-
}
|
|
51
|
+
const fetchInfo = () => {
|
|
53
52
|
const modulesToFetch: { modName: string, reqOptions?: Record<string, any> }[] = [];
|
|
54
53
|
['list_payments', 'calculate_shipping'].forEach((modName) => {
|
|
55
54
|
if (!Object.keys(modulesInfo[modName]).length) {
|
|
@@ -140,7 +139,38 @@ if (!import.meta.env.SSR) {
|
|
|
140
139
|
})
|
|
141
140
|
.catch(console.error);
|
|
142
141
|
});
|
|
142
|
+
};
|
|
143
|
+
if (typeof window.requestIdleCallback === 'function') {
|
|
144
|
+
window.requestIdleCallback(fetchInfo);
|
|
145
|
+
} else {
|
|
146
|
+
setTimeout(fetchInfo, 300);
|
|
143
147
|
}
|
|
144
148
|
}
|
|
145
149
|
|
|
146
150
|
export default modulesInfo;
|
|
151
|
+
|
|
152
|
+
const parsePhrase = <T extends keyof typeof modulesInfo>(
|
|
153
|
+
phrase: string,
|
|
154
|
+
modName: T,
|
|
155
|
+
varName: string & keyof typeof modulesInfo[T],
|
|
156
|
+
formatValue: (x: any) => string = formatMoney,
|
|
157
|
+
) => {
|
|
158
|
+
return computed(() => {
|
|
159
|
+
const searchString = `{{${varName}}}`;
|
|
160
|
+
const index = phrase.indexOf(searchString);
|
|
161
|
+
if (index > -1) {
|
|
162
|
+
const fieldValue = modulesInfo[modName][varName];
|
|
163
|
+
if (fieldValue) {
|
|
164
|
+
const replacement = formatValue(fieldValue);
|
|
165
|
+
return phrase.substring(0, index) + replacement
|
|
166
|
+
+ phrase.substring(index + searchString.length);
|
|
167
|
+
}
|
|
168
|
+
return '';
|
|
169
|
+
}
|
|
170
|
+
return phrase;
|
|
171
|
+
});
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
export const parseShippingPhrase = (phrase: string) => {
|
|
175
|
+
return parsePhrase(phrase, 'calculate_shipping', 'free_shipping_from_value');
|
|
176
|
+
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { CmsSettings as _CmsSettings } from '@cloudcommerce/types';
|
|
2
2
|
|
|
3
|
-
type CmsSettings = _CmsSettings &
|
|
3
|
+
type CmsSettings = _CmsSettings &
|
|
4
|
+
Omit<typeof import('content/settings.json'), keyof _CmsSettings>;
|
|
4
5
|
|
|
5
6
|
export default CmsSettings;
|
|
6
7
|
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { join as joinPath } from 'node:path';
|
|
1
3
|
import config from '@cloudcommerce/config';
|
|
2
4
|
import getCMS from './config/storefront.cms.mjs';
|
|
3
5
|
|
|
@@ -7,14 +9,6 @@ export default () => {
|
|
|
7
9
|
config.set({ storeId: Number(VITE_ECOM_STORE_ID) });
|
|
8
10
|
}
|
|
9
11
|
|
|
10
|
-
const {
|
|
11
|
-
storeId,
|
|
12
|
-
lang,
|
|
13
|
-
countryCode,
|
|
14
|
-
currency,
|
|
15
|
-
currencySymbol,
|
|
16
|
-
} = config.get();
|
|
17
|
-
|
|
18
12
|
const {
|
|
19
13
|
domain,
|
|
20
14
|
primaryColor,
|
|
@@ -24,6 +18,24 @@ export default () => {
|
|
|
24
18
|
} = getCMS();
|
|
25
19
|
config.set({ cmsSettings: settings });
|
|
26
20
|
|
|
21
|
+
let { storeId } = config.get();
|
|
22
|
+
if (!storeId) {
|
|
23
|
+
const configFilepath = joinPath(process.cwd(), 'config.json');
|
|
24
|
+
try {
|
|
25
|
+
const mergeConfig = JSON.parse(readFileSync(configFilepath), 'utf8');
|
|
26
|
+
if (mergeConfig.storeId) {
|
|
27
|
+
storeId = mergeConfig.storeId;
|
|
28
|
+
config.set({ storeId });
|
|
29
|
+
}
|
|
30
|
+
} catch { /* */ }
|
|
31
|
+
}
|
|
32
|
+
const {
|
|
33
|
+
lang,
|
|
34
|
+
countryCode,
|
|
35
|
+
currency,
|
|
36
|
+
currencySymbol,
|
|
37
|
+
} = config.get();
|
|
38
|
+
|
|
27
39
|
return {
|
|
28
40
|
storeId,
|
|
29
41
|
lang,
|