cloudcommerce 2.5.0 → 2.6.0

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.
Files changed (59) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/ecomplus-stores/barradoce/functions/many/package.json +3 -3
  3. package/ecomplus-stores/barradoce/functions/ssr/package.json +6 -6
  4. package/ecomplus-stores/barradoce/functions/ssr/src/components/CartSidebar.vue +20 -0
  5. package/ecomplus-stores/barradoce/functions/ssr/src/components/HeroSlider.vue +1 -3
  6. package/ecomplus-stores/barradoce/functions/ssr/src/components/ProductDetails.vue +12 -4
  7. package/ecomplus-stores/barradoce/functions/ssr/src/components/ShippingCalculator.vue +100 -0
  8. package/ecomplus-stores/barradoce/functions/with-apps/package.json +3 -3
  9. package/ecomplus-stores/barradoce/package.json +2 -2
  10. package/package.json +2 -2
  11. package/packages/api/package.json +1 -1
  12. package/packages/apps/affiliate-program/package.json +1 -1
  13. package/packages/apps/correios/package.json +1 -1
  14. package/packages/apps/custom-payment/package.json +1 -1
  15. package/packages/apps/custom-shipping/package.json +1 -1
  16. package/packages/apps/datafrete/package.json +1 -1
  17. package/packages/apps/discounts/package.json +1 -1
  18. package/packages/apps/emails/package.json +1 -1
  19. package/packages/apps/fb-conversions/package.json +1 -1
  20. package/packages/apps/flash-courier/package.json +1 -1
  21. package/packages/apps/frenet/package.json +1 -1
  22. package/packages/apps/galaxpay/package.json +1 -1
  23. package/packages/apps/google-analytics/package.json +1 -1
  24. package/packages/apps/jadlog/package.json +1 -1
  25. package/packages/apps/loyalty-points/package.json +1 -1
  26. package/packages/apps/mandae/package.json +1 -1
  27. package/packages/apps/melhor-envio/package.json +1 -1
  28. package/packages/apps/mercadopago/package.json +1 -1
  29. package/packages/apps/pagarme/package.json +1 -1
  30. package/packages/apps/pagarme-v5/package.json +1 -1
  31. package/packages/apps/paghiper/package.json +1 -1
  32. package/packages/apps/pix/package.json +1 -1
  33. package/packages/apps/tiny-erp/package.json +1 -1
  34. package/packages/apps/webhooks/package.json +1 -1
  35. package/packages/cli/ci/bunny-prepare-ab.sh +4 -4
  36. package/packages/cli/package.json +1 -1
  37. package/packages/config/package.json +1 -1
  38. package/packages/emails/package.json +1 -1
  39. package/packages/eslint/package.json +1 -1
  40. package/packages/eslint/storefront.eslintrc.cjs +1 -0
  41. package/packages/events/package.json +1 -1
  42. package/packages/feeds/package.json +1 -1
  43. package/packages/firebase/package.json +1 -1
  44. package/packages/i18n/package.json +1 -1
  45. package/packages/modules/package.json +1 -1
  46. package/packages/passport/package.json +1 -1
  47. package/packages/ssr/package.json +3 -3
  48. package/packages/storefront/package.json +4 -3
  49. package/packages/storefront/src/__fixtures__/calculate_shipping.json +161 -0
  50. package/packages/storefront/src/helpers/afetch.ts +1 -0
  51. package/packages/storefront/src/lib/components/Spinner.vue +16 -0
  52. package/packages/storefront/src/lib/components/globals/Skeleton.vue +25 -7
  53. package/packages/storefront/src/lib/composables/use-shipping-calculator.ts +90 -31
  54. package/packages/storefront/src/lib/layouts/BaseBody.astro +0 -13
  55. package/packages/storefront/src/lib/scripts/experimental-web-ide.ts +29 -0
  56. package/packages/storefront/src/lib/ssr-context.ts +9 -0
  57. package/packages/storefront/src/web-ide/webcontainer.ts +104 -0
  58. package/packages/test-base/package.json +1 -1
  59. package/packages/types/package.json +1 -1
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/feeds",
3
3
  "type": "module",
4
- "version": "2.5.0",
4
+ "version": "2.6.0",
5
5
  "description": "E-Com Plus Cloud Commerce catalog feeds",
6
6
  "main": "lib/index.js",
7
7
  "exports": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/firebase",
3
3
  "type": "module",
4
- "version": "2.5.0",
4
+ "version": "2.6.0",
5
5
  "description": "E-Com Plus Cloud Commerce on Firebase",
6
6
  "main": "lib/index.js",
7
7
  "types": "lib/index.d.ts",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/i18n",
3
3
  "type": "module",
4
- "version": "2.5.0",
4
+ "version": "2.6.0",
5
5
  "description": "E-Com Plus Cloud Commerce i18n",
6
6
  "main": "lib/all.js",
7
7
  "exports": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/modules",
3
3
  "type": "module",
4
- "version": "2.5.0",
4
+ "version": "2.6.0",
5
5
  "description": "E-Com Plus Cloud Commerce modules API",
6
6
  "main": "lib/index.cjs",
7
7
  "exports": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/passport",
3
3
  "type": "module",
4
- "version": "2.5.0",
4
+ "version": "2.6.0",
5
5
  "description": "E-Com Plus Cloud Commerce customers authentication (passport) API",
6
6
  "main": "lib/index.js",
7
7
  "exports": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/ssr",
3
3
  "type": "module",
4
- "version": "2.5.0",
4
+ "version": "2.6.0",
5
5
  "description": "E-Com Plus Cloud Commerce storefront SSR",
6
6
  "main": "lib/index.js",
7
7
  "exports": {
@@ -31,8 +31,8 @@
31
31
  "@cloudcommerce/firebase": "workspace:*",
32
32
  "@cloudcommerce/i18n": "workspace:*",
33
33
  "@ecomplus/utils": "1.5.0-rc.6",
34
- "@vueuse/core": "10.7.2",
35
- "astro": "4.4.0",
34
+ "@vueuse/core": "10.8.0",
35
+ "astro": "4.4.1",
36
36
  "astro-capo": "^0.0.1",
37
37
  "axios": "^1.6.7",
38
38
  "firebase-admin": "^12.0.0",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/storefront",
3
3
  "type": "module",
4
- "version": "2.5.0",
4
+ "version": "2.6.0",
5
5
  "description": "E-Com Plus Cloud Commerce storefront with Astro",
6
6
  "bin": {
7
7
  "storefront": "./scripts/build-prod.sh"
@@ -42,8 +42,9 @@
42
42
  "@iconify-json/logos": "^1.1.42",
43
43
  "@types/gtag.js": "^0.0.19",
44
44
  "@vite-pwa/astro": "^0.3.0",
45
- "@vueuse/core": "10.7.2",
46
- "astro": "4.4.0",
45
+ "@vueuse/core": "10.8.0",
46
+ "@webcontainer/api": "^1.1.9",
47
+ "astro": "4.4.1",
47
48
  "astro-capo": "^0.0.1",
48
49
  "chroma-js": "^2.4.2",
49
50
  "dotenv": "^16.4.4",
@@ -0,0 +1,161 @@
1
+ {
2
+ "meta": {
3
+ "to": {
4
+ "zip": "30333111"
5
+ },
6
+ "items": [
7
+ {
8
+ "product_id": "5c701c8ac626be23430d4fe5",
9
+ "sku": "hd-csr-303",
10
+ "name": "Headset Gamer Corsair HS40 Raptor CA-9011122-NA(AP)",
11
+ "quantity": 1,
12
+ "currency_id": "BRL",
13
+ "currency_symbol": "R$",
14
+ "price": 285,
15
+ "dimensions": {
16
+ "width": {
17
+ "value": 10,
18
+ "unit": "cm"
19
+ },
20
+ "height": {
21
+ "value": 10,
22
+ "unit": "cm"
23
+ },
24
+ "length": {
25
+ "value": 10,
26
+ "unit": "cm"
27
+ }
28
+ },
29
+ "weight": {
30
+ "value": 500,
31
+ "unit": "g"
32
+ }
33
+ }
34
+ ],
35
+ "subtotal": 285,
36
+ "own_hand": false,
37
+ "receipt": false,
38
+ "is_checkout_confirmation": false
39
+ },
40
+ "result": [
41
+ {
42
+ "_id": "645e84cf0332fe172e2d7c75",
43
+ "app_id": 1253,
44
+ "queue_took": 45,
45
+ "took": 69,
46
+ "version": "1.3.0",
47
+ "validated": false,
48
+ "response_errors": null,
49
+ "error": true,
50
+ "error_message": "Request failed with status code 400",
51
+ "response": {
52
+ "error": "CALCULATE_ERR",
53
+ "message": "Zip code is unset on app hidden data (merchant must configure the app)"
54
+ }
55
+ },
56
+ {
57
+ "_id": "5fc529c069274c73fcdebb61",
58
+ "app_id": 1248,
59
+ "queue_took": 25,
60
+ "took": 423,
61
+ "version": "1.0.5",
62
+ "validated": false,
63
+ "response_errors": null,
64
+ "error": true,
65
+ "error_message": "Request failed with status code 400",
66
+ "response": {
67
+ "error": "CALCULATE_FAILED",
68
+ "message": "undefined- connect ECONNREFUSED 201.48.198.97:80- Results from offline data invalidated"
69
+ }
70
+ },
71
+ {
72
+ "_id": "5f15da8614ff772fde810435",
73
+ "app_id": 119348,
74
+ "queue_took": 5,
75
+ "took": 526,
76
+ "version": "1.1.2",
77
+ "validated": true,
78
+ "response_errors": null,
79
+ "error": false,
80
+ "error_message": null,
81
+ "response": {
82
+ "shipping_services": [
83
+ {
84
+ "label": "SEDEX",
85
+ "carrier": "Correios (Manda Bem)",
86
+ "service_name": "SEDEX",
87
+ "shipping_line": {
88
+ "from": {
89
+ "zip": "35701399"
90
+ },
91
+ "to": {
92
+ "zip": "30333111"
93
+ },
94
+ "price": 11.73,
95
+ "total_price": 11.73,
96
+ "declared_value": 285,
97
+ "discount": 0,
98
+ "delivery_time": {
99
+ "days": 1,
100
+ "working_days": true
101
+ },
102
+ "posting_deadline": {
103
+ "days": 3,
104
+ "working_days": true,
105
+ "after_approval": true
106
+ },
107
+ "package": {
108
+ "weight": {
109
+ "value": 0.5,
110
+ "unit": "kg"
111
+ }
112
+ },
113
+ "flags": [
114
+ "mandabem-ws"
115
+ ],
116
+ "own_hand": false,
117
+ "receipt": false
118
+ }
119
+ },
120
+ {
121
+ "label": "PAC",
122
+ "carrier": "Correios (Manda Bem)",
123
+ "service_name": "PAC",
124
+ "shipping_line": {
125
+ "from": {
126
+ "zip": "35701399"
127
+ },
128
+ "to": {
129
+ "zip": "30333111"
130
+ },
131
+ "price": 0,
132
+ "total_price": 0,
133
+ "declared_value": 285,
134
+ "discount": 0,
135
+ "delivery_time": {
136
+ "days": 5,
137
+ "working_days": true
138
+ },
139
+ "posting_deadline": {
140
+ "days": 3,
141
+ "working_days": true,
142
+ "after_approval": true
143
+ },
144
+ "package": {
145
+ "weight": {
146
+ "value": 0.5,
147
+ "unit": "kg"
148
+ }
149
+ },
150
+ "flags": [
151
+ "mandabem-ws"
152
+ ],
153
+ "own_hand": false,
154
+ "receipt": false
155
+ }
156
+ }
157
+ ]
158
+ }
159
+ }
160
+ ]
161
+ }
@@ -32,6 +32,7 @@ const afetch = (url: FetchParams[0], init?: AFetchInit, timeout = 10000) => {
32
32
  let query = '';
33
33
  Object.keys(init.params).forEach((key) => {
34
34
  const value: string | number | (string | number)[] = init.params![key];
35
+ if (value === undefined) return;
35
36
  if (Array.isArray(value)) {
36
37
  value.forEach((val) => {
37
38
  query += `&${key}=${val}`;
@@ -0,0 +1,16 @@
1
+ <template>
2
+ <div role="status">
3
+ <svg
4
+ aria-hidden="true"
5
+ class="size-8 max-h-full max-w-full animate-spin fill-secondary text-base-300"
6
+ viewBox="0 0 100 101"
7
+ fill="none"
8
+ xmlns="http://www.w3.org/2000/svg"
9
+ >
10
+ <!-- eslint-disable max-len -->
11
+ <path d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z" fill="currentColor"/>
12
+ <path d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z" fill="currentFill"/>
13
+ </svg>
14
+ <span class="sr-only">Loading...</span>
15
+ </div>
16
+ </template>
@@ -4,10 +4,13 @@ import { computed } from 'vue';
4
4
  export interface Props {
5
5
  isBold?: boolean;
6
6
  isLarge?: boolean;
7
+ numRows?: number;
7
8
  }
8
9
 
9
- const props = defineProps<Props>();
10
- const rowClassName = 'bg-gray-200 rounded-md dark:bg-gray-700';
10
+ const props = withDefaults(defineProps<Props>(), {
11
+ numRows: 6,
12
+ });
13
+ const rowClassName = 'bg-base-200 rounded-md';
11
14
  const firstRowClassName = computed(() => {
12
15
  return `${rowClassName} ${(props.isBold ? 'h-8 mb-6' : 'h-2.5 mb-4')}`;
13
16
  });
@@ -19,11 +22,26 @@ const nextRowsClassName = computed(() => {
19
22
  <template>
20
23
  <div role="status" class="animate-pulse" :class="isLarge ? 'max-w-4xl' : 'max-w-sm'">
21
24
  <div :class="[firstRowClassName, isLarge ? 'w-96' : 'w-48']"></div>
22
- <div :class="[nextRowsClassName, isLarge ? 'max-w-[680px]' : 'max-w-[340px]']"></div>
23
- <div :class="nextRowsClassName"></div>
24
- <div :class="[nextRowsClassName, isLarge ? 'max-w-[660px]' : 'max-w-[330px]']"></div>
25
- <div :class="[nextRowsClassName, isLarge ? 'max-w-[600px]' : 'max-w-[300px]']"></div>
26
- <div :class="[nextRowsClassName, isLarge ? 'max-w-[720px]' : 'max-w-[360px]']"></div>
25
+ <div
26
+ v-if="numRows > 1"
27
+ :class="[nextRowsClassName, isLarge ? 'max-w-[680px]' : 'max-w-[340px]']"
28
+ ></div>
29
+ <div
30
+ v-if="numRows > 2"
31
+ :class="nextRowsClassName"
32
+ ></div>
33
+ <div
34
+ v-if="numRows > 3"
35
+ :class="[nextRowsClassName, isLarge ? 'max-w-[660px]' : 'max-w-[330px]']"
36
+ ></div>
37
+ <div
38
+ v-if="numRows > 4"
39
+ :class="[nextRowsClassName, isLarge ? 'max-w-[600px]' : 'max-w-[300px]']"
40
+ ></div>
41
+ <div
42
+ v-for="n in (numRows - 5)" :key="n"
43
+ :class="[nextRowsClassName, isLarge ? 'max-w-[720px]' : 'max-w-[360px]']"
44
+ ></div>
27
45
  <span class="sr-only">Loading...</span>
28
46
  </div>
29
47
  </template>
@@ -14,24 +14,34 @@ import {
14
14
  toRef,
15
15
  } from 'vue';
16
16
  import { useDebounceFn, watchOnce } from '@vueuse/core';
17
- import { price as getPrice } from '@ecomplus/utils';
17
+ import { price as getPrice, formatMoney } from '@ecomplus/utils';
18
18
  import config from '@cloudcommerce/config';
19
+ import {
20
+ i19days,
21
+ i19free,
22
+ i19freeShipping,
23
+ i19pickUpToday,
24
+ i19receiveToday,
25
+ i19untilTomorrow,
26
+ i19upTo,
27
+ i19workingDays,
28
+ } from '@@i18n';
19
29
  import { fetchModule } from '@@sf/state/modules-info';
20
30
 
21
31
  export type ShippedItem = Exclude<CalculateShippingParams['items'], undefined>[0];
22
32
 
23
33
  export type ShippingService = CalculateShippingResponse['shipping_services'][0];
24
34
 
25
- type CartOrProductItem = Carts['items'][0] | (Partial<Products> & {
26
- product_id: string & { length: 24 },
27
- price: number,
28
- quantity: number,
29
- });
35
+ type CartOrProductItem = Carts['items'][0]
36
+ | (Partial<Products>
37
+ & { price: number, quantity: number }
38
+ & ({ product_id: string & { length: 24 } } | { _id: string & { length: 24 } })
39
+ );
30
40
 
31
41
  export interface Props {
32
- zipInput?: Ref<HTMLInputElement | null>;
33
- zipCode?: string;
34
- canSelectService?: boolean;
42
+ zipCode?: Ref<string>;
43
+ canAutoSubmit?: boolean;
44
+ // canSelectService?: boolean;
35
45
  countryCode?: string;
36
46
  shippedItems?: (ShippedItem | CartOrProductItem)[];
37
47
  shippingResult?: ModuleApiResult<'calculate_shipping'>['result'];
@@ -62,6 +72,9 @@ const sortApps = (results: any, order: number[]) => {
62
72
  });
63
73
  };
64
74
  const reduceItemBody = (itemOrProduct: Record<string, any>) => {
75
+ if (!itemOrProduct.product_id) {
76
+ itemOrProduct.product_id = itemOrProduct._id;
77
+ }
65
78
  const shippedItem = {};
66
79
  const fields: (keyof ShippedItem)[] = [
67
80
  'product_id',
@@ -86,12 +99,11 @@ const reduceItemBody = (itemOrProduct: Record<string, any>) => {
86
99
  };
87
100
 
88
101
  export const useShippingCalculator = (props: Props) => {
89
- const localZipCode = ref(props.zipCode);
90
- const zipCode = ref<string | null>(null);
91
- if (!localZipCode.value && localStorage) {
102
+ const zipCode = props.zipCode || ref('');
103
+ if (!zipCode.value && localStorage) {
92
104
  const storedZip = localStorage.getItem(ZIP_STORAGE_KEY);
93
105
  if (storedZip) {
94
- localZipCode.value = storedZip;
106
+ zipCode.value = storedZip;
95
107
  }
96
108
  }
97
109
  const countryCode = props.countryCode || config.get().countryCode;
@@ -117,7 +129,7 @@ export const useShippingCalculator = (props: Props) => {
117
129
  ...props.baseParams,
118
130
  to: {
119
131
  ...props.baseParams?.to,
120
- zip: localZipCode.value!,
132
+ zip: zipCode.value,
121
133
  },
122
134
  };
123
135
  if (shippedItems.value.length) {
@@ -125,6 +137,17 @@ export const useShippingCalculator = (props: Props) => {
125
137
  body.subtotal = amountSubtotal.value;
126
138
  }
127
139
  isFetching.value = true;
140
+ if (import.meta.env.DEV) {
141
+ // eslint-disable-next-line
142
+ return import('../../__fixtures__/calculate_shipping.json')
143
+ .then(({ default: data }) => {
144
+ setTimeout(() => {
145
+ isFetching.value = false;
146
+ // eslint-disable-next-line no-use-before-define
147
+ parseShippingResult(data.result as any, isRetry);
148
+ }, 1500);
149
+ });
150
+ }
128
151
  fetchModule('calculate_shipping', {
129
152
  method: 'POST',
130
153
  params: {
@@ -133,6 +156,7 @@ export const useShippingCalculator = (props: Props) => {
133
156
  body,
134
157
  })
135
158
  .then(async (response) => {
159
+ if (response.status === 501) return;
136
160
  const data = await response.json();
137
161
  // eslint-disable-next-line no-use-before-define
138
162
  parseShippingResult(data.result, isRetry);
@@ -220,43 +244,74 @@ export const useShippingCalculator = (props: Props) => {
220
244
  };
221
245
 
222
246
  const submitZipCode = () => {
223
- const _zipCode = localZipCode.value;
247
+ const _zipCode = zipCode.value;
224
248
  if (countryCode === 'BR') {
225
249
  if (_zipCode?.replace(/\D/g, '').length !== 8) return;
226
250
  } else if (!_zipCode) {
227
251
  return;
228
252
  }
229
- zipCode.value = _zipCode;
230
253
  if (localStorage) {
231
- localStorage.setItem(ZIP_STORAGE_KEY, zipCode.value);
254
+ localStorage.setItem(ZIP_STORAGE_KEY, _zipCode);
232
255
  }
233
256
  fetchShippingServices();
234
257
  };
235
- watch(localZipCode, submitZipCode, {
258
+ watch(zipCode, (value) => {
259
+ if (value.length) {
260
+ if (countryCode === 'BR') {
261
+ const fmt = value.replace(/\D/g, '');
262
+ if (fmt.length > 5) {
263
+ zipCode.value = fmt.substring(0, 5) + '-' + fmt.substring(5, 8);
264
+ if (props.canAutoSubmit) submitZipCode();
265
+ }
266
+ } else {
267
+ zipCode.value = value.substring(0, 30);
268
+ }
269
+ }
270
+ }, {
236
271
  immediate: !props.shippingResult,
237
272
  });
238
273
  watch(toRef(props, 'shippingResult'), (shippingResult) => {
239
274
  if (!shippingResult?.length) return;
240
- if (localZipCode.value) zipCode.value = localZipCode.value;
241
275
  parseShippingResult(shippingResult);
242
276
  }, {
243
277
  immediate: true,
244
278
  });
245
- const zipInput = props.zipInput?.value;
246
- if (zipInput) {
247
- zipInput.addEventListener('input', (ev) => {
248
- const value = (ev.target as HTMLInputElement).value;
249
- if (value.length) {
250
- if (countryCode === 'BR') {
251
- const fmt = value.replace(/\D/g, '').padEnd(8, '_');
252
- zipInput.innerHTML = fmt.substring(0, 5) + '-' + fmt.substring(5, 8);
253
- } else {
254
- zipInput.innerHTML = value.substring(0, 30);
279
+
280
+ const productionDeadline = computed(() => {
281
+ let maxDeadline = 0;
282
+ _shippedItems.value?.forEach((item: Partial<Products>) => {
283
+ if (item.quantity && item.production_time) {
284
+ const { days, cumulative } = item.production_time;
285
+ const itemDeadline = cumulative ? days * item.quantity : days;
286
+ if (itemDeadline > maxDeadline) {
287
+ maxDeadline = itemDeadline;
255
288
  }
256
289
  }
257
- localZipCode.value = value;
258
290
  });
259
- }
291
+ return maxDeadline;
292
+ });
293
+ const getShippingDeadline = (shipping: ShippingService['shipping_line']) => {
294
+ const isWorkingDays = Boolean(shipping.posting_deadline?.working_days
295
+ || shipping.delivery_time?.working_days);
296
+ let days = shipping.posting_deadline?.days || 0;
297
+ if (shipping.delivery_time) {
298
+ days += shipping.delivery_time.days;
299
+ }
300
+ days += productionDeadline.value;
301
+ if (days > 1) {
302
+ return `${i19upTo} ${days} `
303
+ + (isWorkingDays ? i19workingDays : i19days).toLowerCase();
304
+ }
305
+ if (days === 1) return i19untilTomorrow;
306
+ return shipping.pick_up ? i19pickUpToday : i19receiveToday;
307
+ };
308
+ const getShippingPrice = (shipping: ShippingService['shipping_line']) => {
309
+ const freight = typeof shipping.total_price === 'number'
310
+ ? shipping.total_price
311
+ : shipping.price;
312
+ if (freight) return formatMoney(freight);
313
+ return shipping.pick_up ? i19free : i19freeShipping;
314
+ };
260
315
 
261
316
  return {
262
317
  zipCode,
@@ -264,9 +319,13 @@ export const useShippingCalculator = (props: Props) => {
264
319
  amountSubtotal,
265
320
  submitZipCode,
266
321
  fetchShippingServices,
322
+ isFetching,
267
323
  freeFromValue,
268
324
  shippingServices,
269
325
  parseShippingResult,
326
+ productionDeadline,
327
+ getShippingDeadline,
328
+ getShippingPrice,
270
329
  };
271
330
  };
272
331
 
@@ -1,7 +1,4 @@
1
1
  ---
2
- import * as url from 'node:url';
3
- import { join as joinPath } from 'node:path';
4
- import { readFileSync } from 'node:fs';
5
2
  import '@@sf/assets/reset.css';
6
3
  import '@@sf/assets/base.css';
7
4
  import '@@sf/assets/forms.css';
@@ -10,15 +7,6 @@ import '@@sf/assets/tooltip.css';
10
7
  // import 'uno.css';
11
8
  import Picture from '@@sf/components/Picture.astro';
12
9
 
13
- const __dirname = url.fileURLToPath(new URL('.', import.meta.url));
14
- const pkgJson = readFileSync(joinPath(__dirname, '../../../package.json'), 'utf-8');
15
- const {
16
- name: pkgName,
17
- version: pkgVersion,
18
- } = JSON.parse(pkgJson);
19
- const getInlineVersionLog = () => {
20
- return `console.log('%c${pkgName} v${pkgVersion}', 'font-weight:bold')`;
21
- };
22
10
  const { settings } = Astro.locals.routeContext;
23
11
  ---
24
12
 
@@ -40,5 +28,4 @@ const { settings } = Astro.locals.routeContext;
40
28
  hasImg={false}
41
29
  />
42
30
  }
43
- <script is:inline set:html={getInlineVersionLog()} />
44
31
  </body>
@@ -0,0 +1,29 @@
1
+ import { initVM } from '../../web-ide/webcontainer';
2
+
3
+ const cliTextareaId = 'IDEcli';
4
+ const serverIframeId = 'IDEserver';
5
+
6
+ if (!import.meta.env.SSR) {
7
+ const cliTextarea = document.createElement('textarea');
8
+ cliTextarea.id = cliTextareaId;
9
+ document.body.appendChild(cliTextarea);
10
+ const serverIframe = document.createElement('iframe');
11
+ serverIframe.id = serverIframeId;
12
+ serverIframe.width = '100%';
13
+ serverIframe.height = '100%';
14
+ serverIframe.style.cssText = 'border: 1px solid #EEE; height: calc(100vh - 30px)';
15
+ document.body.appendChild(serverIframe);
16
+
17
+ const initIDE = async () => {
18
+ const repo = 'ecomplus/store';
19
+ const { vm, startDevServer } = await initVM({ repo, cliTextarea });
20
+ vm.on('server-ready', (port, href) => {
21
+ console.log({ port, href });
22
+ const url = new URL(href);
23
+ url.searchParams.set('webcontainer', 'dev');
24
+ serverIframe.src = `${url}`;
25
+ });
26
+ startDevServer();
27
+ };
28
+ initIDE();
29
+ }
@@ -296,6 +296,15 @@ const loadRouteContext = async (
296
296
  } else {
297
297
  setResponseCache(Astro, 120, 180);
298
298
  }
299
+ if (
300
+ Astro.url.searchParams.get('webcontainer') !== null
301
+ || urlPath.startsWith('/admin/ide')
302
+ ) {
303
+ // https://webcontainers.io/guides/quickstart#cross-origin-isolation
304
+ Astro.response.headers.set('Cross-Origin-Embedder-Policy', 'require-corp');
305
+ Astro.response.headers.set('Cross-Origin-Opener-Policy', 'same-origin');
306
+ Astro.response.headers.set('Cross-Origin-Resource-Policy', 'cross-origin');
307
+ }
299
308
  const routeContext = {
300
309
  ...config,
301
310
  isHomepage,