cloudcommerce 2.3.0 → 2.3.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.
Files changed (215) hide show
  1. package/.github/workflows/test-apps.yml +3 -3
  2. package/CHANGELOG.md +24 -0
  3. package/action.yml +6 -6
  4. package/ecomplus-stores/barra-doce/functions/many/package.json +3 -3
  5. package/ecomplus-stores/barra-doce/functions/ssr/package.json +6 -6
  6. package/ecomplus-stores/barra-doce/functions/with-apps/package.json +3 -3
  7. package/ecomplus-stores/barra-doce/package.json +2 -2
  8. package/package.json +6 -6
  9. package/packages/api/package.json +1 -1
  10. package/packages/apps/affiliate-program/package.json +1 -1
  11. package/packages/apps/correios/package.json +2 -2
  12. package/packages/apps/custom-payment/package.json +1 -1
  13. package/packages/apps/custom-shipping/package.json +1 -1
  14. package/packages/apps/datafrete/package.json +1 -1
  15. package/packages/apps/discounts/package.json +1 -1
  16. package/packages/apps/emails/package.json +1 -1
  17. package/packages/apps/fb-conversions/package.json +2 -2
  18. package/packages/apps/flash-courier/package.json +1 -1
  19. package/packages/apps/frenet/package.json +1 -1
  20. package/packages/apps/galaxpay/package.json +1 -1
  21. package/packages/apps/google-analytics/package.json +1 -1
  22. package/packages/apps/jadlog/package.json +1 -1
  23. package/packages/apps/loyalty-points/package.json +1 -1
  24. package/packages/apps/mandae/package.json +1 -1
  25. package/packages/apps/melhor-envio/package.json +1 -1
  26. package/packages/apps/mercadopago/package.json +1 -1
  27. package/packages/apps/pagarme/package.json +1 -1
  28. package/packages/apps/pagarme-v5/package.json +1 -1
  29. package/packages/apps/paghiper/package.json +1 -1
  30. package/packages/apps/pix/package.json +1 -1
  31. package/packages/apps/tiny-erp/package.json +1 -1
  32. package/packages/apps/webhooks/package.json +1 -1
  33. package/packages/cli/ci/bunny-config-base.sh +4 -2
  34. package/packages/cli/config/firestore.rules +3 -0
  35. package/packages/cli/package.json +1 -1
  36. package/packages/config/package.json +1 -1
  37. package/packages/emails/package.json +1 -1
  38. package/packages/eslint/package.json +5 -5
  39. package/packages/events/package.json +1 -1
  40. package/packages/feeds/package.json +1 -1
  41. package/packages/firebase/package.json +2 -2
  42. package/packages/i18n/package.json +1 -1
  43. package/packages/modules/package.json +1 -1
  44. package/packages/passport/package.json +1 -1
  45. package/packages/ssr/lib/lib/analytics/send-to-ga4.js +2 -1
  46. package/packages/ssr/lib/lib/analytics/send-to-ga4.js.map +1 -1
  47. package/packages/ssr/lib/lib/analytics-events.js +11 -1
  48. package/packages/ssr/lib/lib/analytics-events.js.map +1 -1
  49. package/packages/ssr/lib/lib/cron-ssr-save-views.js +11 -5
  50. package/packages/ssr/lib/lib/cron-ssr-save-views.js.map +1 -1
  51. package/packages/ssr/lib/lib/serve-storefront.js +35 -21
  52. package/packages/ssr/lib/lib/serve-storefront.js.map +1 -1
  53. package/packages/ssr/package.json +4 -4
  54. package/packages/ssr/src/lib/analytics/send-to-ga4.ts +2 -0
  55. package/packages/ssr/src/lib/analytics-events.ts +11 -1
  56. package/packages/ssr/src/lib/cron-ssr-save-views.ts +11 -8
  57. package/packages/ssr/src/lib/serve-storefront.ts +36 -22
  58. package/packages/storefront/astro.config.mjs +4 -1
  59. package/packages/storefront/config/astro/vue-server.mjs +64 -0
  60. package/packages/storefront/dist/client/_astro/AccountPage.0M6_FdU6.js +1 -0
  61. package/packages/storefront/dist/client/_astro/CartSidebar.L0Vbhsdt.js +1 -0
  62. package/packages/storefront/dist/client/_astro/HeroSlider.ju9TsLrJ.js +1 -0
  63. package/packages/storefront/dist/client/_astro/PitchBar.yqD9ycx5.js +1 -0
  64. package/packages/storefront/dist/client/_astro/Prices.xI1rdM1e.js +1 -0
  65. package/packages/storefront/dist/client/_astro/ProductDetails.FQtM5kpd.js +7 -0
  66. package/packages/storefront/dist/client/_astro/ProductShelf.-4fsYkPB.js +1 -0
  67. package/packages/storefront/dist/client/_astro/ProductShelf.GAAhKdTN.js +1 -0
  68. package/packages/storefront/dist/client/_astro/QuantitySelector.v7L8EYOR.js +1 -0
  69. package/packages/storefront/dist/client/_astro/SearchModal.rasg5jV6.js +1 -0
  70. package/packages/storefront/dist/client/_astro/SearchShowcase.kA6jICYo.js +1 -0
  71. package/packages/storefront/dist/client/_astro/ShopHeader.v_L96Y90.js +7 -0
  72. package/packages/storefront/dist/client/_astro/{_plugin-vue_export-helper.SO-0jCqa.js → _plugin-vue_export-helper.xATGHWd9.js} +2 -2
  73. package/packages/storefront/dist/client/_astro/afetch.OifQZgwR.js +1 -0
  74. package/packages/storefront/dist/client/_astro/client.YJ00ta5M.js +1 -0
  75. package/packages/storefront/dist/client/_astro/customer-session.ZD6tLDQJ.js +7 -0
  76. package/packages/storefront/dist/client/_astro/{firebase-app.VduCDgof.js → firebase-app.iLdzDVjL.js} +1 -1
  77. package/packages/storefront/dist/client/_astro/format-money.1_HtF5S2.js +1 -0
  78. package/packages/storefront/dist/client/_astro/grid-title.pK2Nn3i-.js +1 -0
  79. package/packages/storefront/dist/client/_astro/hoisted.GaT7bmE3.js +1 -0
  80. package/packages/storefront/dist/client/_astro/hoisted.ICXGWNEA.js +1 -0
  81. package/packages/storefront/dist/client/_astro/hoisted.XOXTrHqn.js +1 -0
  82. package/packages/storefront/dist/client/_astro/i18n.zhlBzJt8.js +1 -0
  83. package/packages/storefront/dist/client/_astro/img.AnjeGdy_.js +1 -0
  84. package/packages/storefront/dist/client/_astro/{index-dd468b12.fl8bpn8l.js → index-bea2a320.eWykogwr.js} +93 -93
  85. package/packages/storefront/dist/client/_astro/index.KfrHdfOH.js +1 -0
  86. package/packages/storefront/dist/client/_astro/index.ShNlAyu1.js +1 -0
  87. package/packages/storefront/dist/client/_astro/modules-info.HP6478mG.js +1 -0
  88. package/packages/storefront/dist/client/_astro/name.VA3MEpe0.js +1 -0
  89. package/packages/storefront/dist/client/_astro/server-data.4C60Esyt.js +1 -0
  90. package/packages/storefront/dist/client/_astro/sf-utils.c42cbZ9W.js +13 -0
  91. package/packages/storefront/dist/client/_astro/shopping-cart.nSNNOrp9.js +1 -0
  92. package/packages/storefront/dist/client/_astro/use-analytics.wTmoP8B1.js +1 -0
  93. package/packages/storefront/dist/client/_astro/use-product-card.UFr8SCuD.js +1 -0
  94. package/packages/storefront/dist/client/_astro/use-text-value.lKqoIagH.js +4 -0
  95. package/packages/storefront/dist/server/_noop-middleware.mjs +3 -0
  96. package/packages/storefront/dist/server/chunks/{CartSidebar_yYIzwp_R.mjs → CartSidebar_3_1aFp67.mjs} +1 -1
  97. package/packages/storefront/dist/server/chunks/{SearchModal_GvRUZ6ce.mjs → SearchModal_2azP1u7P.mjs} +1 -1
  98. package/packages/storefront/dist/server/chunks/_.._19fCuQdO.mjs +5 -0
  99. package/packages/storefront/dist/server/chunks/_page__qqIVxbal.mjs +5 -0
  100. package/packages/storefront/dist/server/chunks/account_vK6pmJlz.mjs +5 -0
  101. package/packages/storefront/dist/server/chunks/astro/{assets-service_yXRChsFH.mjs → assets-service_631fRtTy.mjs} +66 -11
  102. package/packages/storefront/dist/server/chunks/{astro_F4pl3toV.mjs → astro_u-oSb215.mjs} +24 -14
  103. package/packages/storefront/dist/server/chunks/index__05fnqFh.mjs +5 -0
  104. package/packages/storefront/dist/server/chunks/node_zqXXqc-u.mjs +5 -0
  105. package/packages/storefront/dist/server/chunks/pages/{__z8Igc_-f.mjs → __ZucPYaOo.mjs} +1313 -979
  106. package/packages/storefront/dist/server/chunks/pages/{_page__-V1Q-Ymk.mjs → _page__0sN9U0SD.mjs} +30 -12
  107. package/packages/storefront/dist/server/chunks/pages/account_OQr_6KN1.mjs +33 -0
  108. package/packages/storefront/dist/server/chunks/pages/{index_QqJiJpFy.mjs → index_3IjgOEIq.mjs} +16 -4
  109. package/packages/storefront/dist/server/chunks/pages/node_OmjWRf8D.mjs +112 -0
  110. package/packages/storefront/dist/server/chunks/pages/~fallback_133FK-CP.mjs +59 -0
  111. package/packages/storefront/dist/server/chunks/~fallback_Wahcp9Wk.mjs +5 -0
  112. package/packages/storefront/dist/server/entry.mjs +289 -166
  113. package/packages/storefront/dist/server/manifest_9FASPYUE.mjs +202 -0
  114. package/packages/storefront/dist/server/renderers.mjs +45 -34
  115. package/packages/storefront/package.json +5 -5
  116. package/packages/storefront/server.d.ts +0 -1
  117. package/packages/storefront/src/lib/$storefront.d.ts +23 -16
  118. package/packages/storefront/src/lib/composables/use-pagination.ts +1 -3
  119. package/packages/storefront/src/lib/layouts/BaseHead.astro +5 -0
  120. package/packages/storefront/src/lib/scripts/git-cms-auth.ts +3 -0
  121. package/packages/storefront/src/lib/scripts/push-analytics-events.ts +14 -7
  122. package/packages/storefront/src/lib/scripts/sso-ecom.ts +0 -0
  123. package/packages/storefront/src/lib/ssr-context.ts +49 -7
  124. package/packages/storefront/src/lib/state/use-analytics.ts +12 -11
  125. package/packages/storefront/src/lib/state/use-storage.ts +23 -9
  126. package/packages/test-base/package.json +1 -1
  127. package/packages/types/package.json +1 -1
  128. package/packages/storefront/dist/client/_astro/AccountPage.HcKW6HTE.js +0 -1
  129. package/packages/storefront/dist/client/_astro/CartSidebar.osvr0MUo.js +0 -1
  130. package/packages/storefront/dist/client/_astro/HeroSlider.I5mC8JdX.js +0 -1
  131. package/packages/storefront/dist/client/_astro/PitchBar.xC4J7MDy.js +0 -1
  132. package/packages/storefront/dist/client/_astro/Prices.Jt09rVKv.js +0 -1
  133. package/packages/storefront/dist/client/_astro/ProductDetails.oouZY3cL.js +0 -7
  134. package/packages/storefront/dist/client/_astro/ProductShelf.dYlXuNId.js +0 -1
  135. package/packages/storefront/dist/client/_astro/ProductShelf.vGE0E3Qf.js +0 -1
  136. package/packages/storefront/dist/client/_astro/QuantitySelector.OL4MN-C_.js +0 -1
  137. package/packages/storefront/dist/client/_astro/SearchModal.d8lbvLay.js +0 -1
  138. package/packages/storefront/dist/client/_astro/SearchShowcase.ynowXX4j.js +0 -1
  139. package/packages/storefront/dist/client/_astro/ShopHeader.l4KJGvUd.js +0 -7
  140. package/packages/storefront/dist/client/_astro/afetch.5c8VmT0-.js +0 -1
  141. package/packages/storefront/dist/client/_astro/client.ZhEmw4hZ.js +0 -1
  142. package/packages/storefront/dist/client/_astro/customer-session.TRPGDX3c.js +0 -7
  143. package/packages/storefront/dist/client/_astro/ecom-icon_12falx.png +0 -0
  144. package/packages/storefront/dist/client/_astro/ecom-icon_15pqnO.png +0 -0
  145. package/packages/storefront/dist/client/_astro/ecom-icon_t3guw.png +0 -0
  146. package/packages/storefront/dist/client/_astro/format-money.iK5LGydz.js +0 -1
  147. package/packages/storefront/dist/client/_astro/grid-title.vGKBy72g.js +0 -1
  148. package/packages/storefront/dist/client/_astro/headphone_T2Jjc.avif +0 -0
  149. package/packages/storefront/dist/client/_astro/headphone_Z1CG18r.webp +0 -0
  150. package/packages/storefront/dist/client/_astro/hoisted.8pwSenCN.js +0 -1
  151. package/packages/storefront/dist/client/_astro/hoisted.SLwcAI01.js +0 -1
  152. package/packages/storefront/dist/client/_astro/hoisted.gqV7f6f3.js +0 -1
  153. package/packages/storefront/dist/client/_astro/i18n.Lxnz1oF-.js +0 -1
  154. package/packages/storefront/dist/client/_astro/img.WnsidxCx.js +0 -1
  155. package/packages/storefront/dist/client/_astro/index.R7A-Pg5V.js +0 -1
  156. package/packages/storefront/dist/client/_astro/index.q6KIyKlJ.js +0 -1
  157. package/packages/storefront/dist/client/_astro/logo_1UBsBq.webp +0 -0
  158. package/packages/storefront/dist/client/_astro/logo_Z1K5PE9.png +0 -0
  159. package/packages/storefront/dist/client/_astro/logo_Z1KIIl1.avif +0 -0
  160. package/packages/storefront/dist/client/_astro/modules-info.WWsUqEPZ.js +0 -1
  161. package/packages/storefront/dist/client/_astro/name.urFqJ5yn.js +0 -1
  162. package/packages/storefront/dist/client/_astro/passion_LHbe9.webp +0 -0
  163. package/packages/storefront/dist/client/_astro/passion_Z23MeUb.avif +0 -0
  164. package/packages/storefront/dist/client/_astro/rect8589_1TtOHY.png +0 -0
  165. package/packages/storefront/dist/client/_astro/rect8589_1f5opX.webp +0 -0
  166. package/packages/storefront/dist/client/_astro/rect8589_IUskt.webp +0 -0
  167. package/packages/storefront/dist/client/_astro/rect8589_Uxfdf.png +0 -0
  168. package/packages/storefront/dist/client/_astro/rect8589_Z15uApA.png +0 -0
  169. package/packages/storefront/dist/client/_astro/rect8589_Z1Ap1Im.avif +0 -0
  170. package/packages/storefront/dist/client/_astro/rect8589_Z1JT1HB.webp +0 -0
  171. package/packages/storefront/dist/client/_astro/rect8589_ZY9mtN.avif +0 -0
  172. package/packages/storefront/dist/client/_astro/rect8589_tMFW0.avif +0 -0
  173. package/packages/storefront/dist/client/_astro/rect859_1TgQXS.avif +0 -0
  174. package/packages/storefront/dist/client/_astro/rect859_2Nm1z.avif +0 -0
  175. package/packages/storefront/dist/client/_astro/rect859_DIqwR.png +0 -0
  176. package/packages/storefront/dist/client/_astro/rect859_Z1IKDb2.png +0 -0
  177. package/packages/storefront/dist/client/_astro/rect859_Z29FI4V.webp +0 -0
  178. package/packages/storefront/dist/client/_astro/rect859_Z2kFHGk.avif +0 -0
  179. package/packages/storefront/dist/client/_astro/rect859_ZkpPFI.webp +0 -0
  180. package/packages/storefront/dist/client/_astro/rect859_jXzBi.png +0 -0
  181. package/packages/storefront/dist/client/_astro/rect859_x1l16.webp +0 -0
  182. package/packages/storefront/dist/client/_astro/rect89_1TSfW7.avif +0 -0
  183. package/packages/storefront/dist/client/_astro/rect89_Z1re32x.webp +0 -0
  184. package/packages/storefront/dist/client/_astro/runtime-core.esm-bundler.XTSAdOlw.js +0 -13
  185. package/packages/storefront/dist/client/_astro/sf-utils.luvTU5uS.js +0 -1
  186. package/packages/storefront/dist/client/_astro/shopping-cart.ATTXCPd0.js +0 -1
  187. package/packages/storefront/dist/client/_astro/use-analytics.WpkjGsWi.js +0 -1
  188. package/packages/storefront/dist/client/_astro/use-product-card.BhUXhJIp.js +0 -1
  189. package/packages/storefront/dist/client/_astro/use-text-value.XE_A2nDM.js +0 -4
  190. package/packages/storefront/dist/client/app/account/index.html +0 -58
  191. package/packages/storefront/dist/client/app/index.html +0 -98
  192. package/packages/storefront/dist/client/blog/1/index.html +0 -86
  193. package/packages/storefront/dist/client/index.html +0 -131
  194. package/packages/storefront/dist/client/macbook-apple-pro-15.4-intel-core-i7-2.6ghz-ram-16gb-ssd-512gb-mr972ll/a-prata/index.html +0 -93
  195. package/packages/storefront/dist/client/monitores-gamer/index.html +0 -95
  196. package/packages/storefront/dist/client/mouse-gamer-corsair-optico-harpoon-rgb-ch-9301011-na/index.html +0 -93
  197. package/packages/storefront/dist/client/p/contato/index.html +0 -90
  198. package/packages/storefront/dist/client/p/terms/index.html +0 -101
  199. package/packages/storefront/dist/client/posts/3/index.html +0 -101
  200. package/packages/storefront/dist/client/posts/4/index.html +0 -101
  201. package/packages/storefront/dist/client/~fallback/index.html +0 -99
  202. package/packages/storefront/dist/server/_empty-middleware.mjs +0 -3
  203. package/packages/storefront/dist/server/chunks/_.._Lq3r7hpv.mjs +0 -6
  204. package/packages/storefront/dist/server/chunks/_page__LqbeNfr1.mjs +0 -6
  205. package/packages/storefront/dist/server/chunks/account_4n4rpirV.mjs +0 -6
  206. package/packages/storefront/dist/server/chunks/index_SwXtE1IM.mjs +0 -6
  207. package/packages/storefront/dist/server/chunks/node_Nzz44v5l.mjs +0 -6
  208. package/packages/storefront/dist/server/chunks/pages/account_frSUn7gD.mjs +0 -22
  209. package/packages/storefront/dist/server/chunks/pages/node_FoDIj_f7.mjs +0 -257
  210. package/packages/storefront/dist/server/chunks/pages/~fallback_t0lNhRm9.mjs +0 -33
  211. package/packages/storefront/dist/server/chunks/~fallback_EWqi0UyU.mjs +0 -6
  212. package/packages/storefront/dist/server/images.dist.csv +0 -30
  213. package/packages/storefront/dist/server/images.src.csv +0 -11
  214. package/packages/storefront/dist/server/manifest_ZHJUD8_m.mjs +0 -196
  215. package/packages/storefront/dist/server/static-builds.csv +0 -71
@@ -0,0 +1,202 @@
1
+ import '@astrojs/internal-helpers/path';
2
+ import 'cookie';
3
+ import { bold, red, yellow, dim, blue } from 'kleur/colors';
4
+ import 'string-width';
5
+ import './chunks/astro_u-oSb215.mjs';
6
+ import 'clsx';
7
+ import 'cssesc';
8
+ import { compile } from 'path-to-regexp';
9
+
10
+ const dateTimeFormat = new Intl.DateTimeFormat([], {
11
+ hour: "2-digit",
12
+ minute: "2-digit",
13
+ second: "2-digit",
14
+ hour12: false
15
+ });
16
+ const levels = {
17
+ debug: 20,
18
+ info: 30,
19
+ warn: 40,
20
+ error: 50,
21
+ silent: 90
22
+ };
23
+ function log(opts, level, label, message, newLine = true) {
24
+ const logLevel = opts.level;
25
+ const dest = opts.dest;
26
+ const event = {
27
+ label,
28
+ level,
29
+ message,
30
+ newLine
31
+ };
32
+ if (!isLogLevelEnabled(logLevel, level)) {
33
+ return;
34
+ }
35
+ dest.write(event);
36
+ }
37
+ function isLogLevelEnabled(configuredLogLevel, level) {
38
+ return levels[configuredLogLevel] <= levels[level];
39
+ }
40
+ function info(opts, label, message, newLine = true) {
41
+ return log(opts, "info", label, message, newLine);
42
+ }
43
+ function warn(opts, label, message, newLine = true) {
44
+ return log(opts, "warn", label, message, newLine);
45
+ }
46
+ function error(opts, label, message, newLine = true) {
47
+ return log(opts, "error", label, message, newLine);
48
+ }
49
+ function debug(...args) {
50
+ if ("_astroGlobalDebug" in globalThis) {
51
+ globalThis._astroGlobalDebug(...args);
52
+ }
53
+ }
54
+ function getEventPrefix({ level, label }) {
55
+ const timestamp = `${dateTimeFormat.format(/* @__PURE__ */ new Date())}`;
56
+ const prefix = [];
57
+ if (level === "error" || level === "warn") {
58
+ prefix.push(bold(timestamp));
59
+ prefix.push(`[${level.toUpperCase()}]`);
60
+ } else {
61
+ prefix.push(timestamp);
62
+ }
63
+ if (label) {
64
+ prefix.push(`[${label}]`);
65
+ }
66
+ if (level === "error") {
67
+ return red(prefix.join(" "));
68
+ }
69
+ if (level === "warn") {
70
+ return yellow(prefix.join(" "));
71
+ }
72
+ if (prefix.length === 1) {
73
+ return dim(prefix[0]);
74
+ }
75
+ return dim(prefix[0]) + " " + blue(prefix.splice(1).join(" "));
76
+ }
77
+ if (typeof process !== "undefined") {
78
+ let proc = process;
79
+ if ("argv" in proc && Array.isArray(proc.argv)) {
80
+ if (proc.argv.includes("--verbose")) ; else if (proc.argv.includes("--silent")) ; else ;
81
+ }
82
+ }
83
+ class Logger {
84
+ options;
85
+ constructor(options) {
86
+ this.options = options;
87
+ }
88
+ info(label, message, newLine = true) {
89
+ info(this.options, label, message, newLine);
90
+ }
91
+ warn(label, message, newLine = true) {
92
+ warn(this.options, label, message, newLine);
93
+ }
94
+ error(label, message, newLine = true) {
95
+ error(this.options, label, message, newLine);
96
+ }
97
+ debug(label, ...messages) {
98
+ debug(label, ...messages);
99
+ }
100
+ level() {
101
+ return this.options.level;
102
+ }
103
+ forkIntegrationLogger(label) {
104
+ return new AstroIntegrationLogger(this.options, label);
105
+ }
106
+ }
107
+ class AstroIntegrationLogger {
108
+ options;
109
+ label;
110
+ constructor(logging, label) {
111
+ this.options = logging;
112
+ this.label = label;
113
+ }
114
+ /**
115
+ * Creates a new logger instance with a new label, but the same log options.
116
+ */
117
+ fork(label) {
118
+ return new AstroIntegrationLogger(this.options, label);
119
+ }
120
+ info(message) {
121
+ info(this.options, this.label, message);
122
+ }
123
+ warn(message) {
124
+ warn(this.options, this.label, message);
125
+ }
126
+ error(message) {
127
+ error(this.options, this.label, message);
128
+ }
129
+ debug(message) {
130
+ debug(this.label, message);
131
+ }
132
+ }
133
+
134
+ function getRouteGenerator(segments, addTrailingSlash) {
135
+ const template = segments.map((segment) => {
136
+ return "/" + segment.map((part) => {
137
+ if (part.spread) {
138
+ return `:${part.content.slice(3)}(.*)?`;
139
+ } else if (part.dynamic) {
140
+ return `:${part.content}`;
141
+ } else {
142
+ return part.content.normalize().replace(/\?/g, "%3F").replace(/#/g, "%23").replace(/%5B/g, "[").replace(/%5D/g, "]").replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
143
+ }
144
+ }).join("");
145
+ }).join("");
146
+ let trailing = "";
147
+ if (addTrailingSlash === "always" && segments.length) {
148
+ trailing = "/";
149
+ }
150
+ const toPath = compile(template + trailing);
151
+ return toPath;
152
+ }
153
+
154
+ function deserializeRouteData(rawRouteData) {
155
+ return {
156
+ route: rawRouteData.route,
157
+ type: rawRouteData.type,
158
+ pattern: new RegExp(rawRouteData.pattern),
159
+ params: rawRouteData.params,
160
+ component: rawRouteData.component,
161
+ generate: getRouteGenerator(rawRouteData.segments, rawRouteData._meta.trailingSlash),
162
+ pathname: rawRouteData.pathname || void 0,
163
+ segments: rawRouteData.segments,
164
+ prerender: rawRouteData.prerender,
165
+ redirect: rawRouteData.redirect,
166
+ redirectRoute: rawRouteData.redirectRoute ? deserializeRouteData(rawRouteData.redirectRoute) : void 0,
167
+ fallbackRoutes: rawRouteData.fallbackRoutes.map((fallback) => {
168
+ return deserializeRouteData(fallback);
169
+ }),
170
+ isIndex: rawRouteData.isIndex
171
+ };
172
+ }
173
+
174
+ function deserializeManifest(serializedManifest) {
175
+ const routes = [];
176
+ for (const serializedRoute of serializedManifest.routes) {
177
+ routes.push({
178
+ ...serializedRoute,
179
+ routeData: deserializeRouteData(serializedRoute.routeData)
180
+ });
181
+ const route = serializedRoute;
182
+ route.routeData = deserializeRouteData(serializedRoute.routeData);
183
+ }
184
+ const assets = new Set(serializedManifest.assets);
185
+ const componentMetadata = new Map(serializedManifest.componentMetadata);
186
+ const clientDirectives = new Map(serializedManifest.clientDirectives);
187
+ return {
188
+ // in case user middleware exists, this no-op middleware will be reassigned (see plugin-ssr.ts)
189
+ middleware(_, next) {
190
+ return next();
191
+ },
192
+ ...serializedManifest,
193
+ assets,
194
+ componentMetadata,
195
+ clientDirectives,
196
+ routes
197
+ };
198
+ }
199
+
200
+ const manifest = deserializeManifest({"adapterName":"@astrojs/node","routes":[{"file":"","links":[],"scripts":[],"styles":[],"routeData":{"type":"endpoint","isIndex":false,"route":"/_image","pattern":"^\\/_image$","segments":[[{"content":"_image","dynamic":false,"spread":false}]],"params":[],"component":"../../node_modules/.pnpm/astro@4.3.2_@types+node@18.19.14_typescript@5.2.2/node_modules/astro/dist/assets/endpoint/node.js","pathname":"/_image","prerender":false,"fallbackRoutes":[],"_meta":{"trailingSlash":"ignore"}}},{"file":"","links":[],"scripts":[{"type":"external","value":"/_astro/hoisted.XOXTrHqn.js"}],"styles":[{"type":"external","src":"/_astro/_slug_.4W7qhV-L.css"}],"routeData":{"route":"/~fallback","isIndex":false,"type":"page","pattern":"^\\/~fallback\\/?$","segments":[[{"content":"~fallback","dynamic":false,"spread":false}]],"params":[],"component":"src/pages/~fallback.astro","pathname":"/~fallback","prerender":false,"fallbackRoutes":[],"_meta":{"trailingSlash":"ignore"}}},{"file":"","links":[],"scripts":[{"type":"external","value":"/_astro/hoisted.ICXGWNEA.js"}],"styles":[{"type":"external","src":"/_astro/_slug_.4W7qhV-L.css"}],"routeData":{"route":"/app","isIndex":true,"type":"page","pattern":"^\\/app\\/?$","segments":[[{"content":"app","dynamic":false,"spread":false}]],"params":[],"component":"src/pages/app/index.astro","pathname":"/app","prerender":false,"fallbackRoutes":[],"_meta":{"trailingSlash":"ignore"}}},{"file":"","links":[],"scripts":[{"type":"external","value":"/_astro/hoisted.GaT7bmE3.js"}],"styles":[{"type":"external","src":"/_astro/_slug_.4W7qhV-L.css"}],"routeData":{"route":"/app/account","isIndex":false,"type":"page","pattern":"^\\/app\\/account\\/?$","segments":[[{"content":"app","dynamic":false,"spread":false}],[{"content":"account","dynamic":false,"spread":false}]],"params":[],"component":"src/pages/app/account.astro","pathname":"/app/account","prerender":false,"fallbackRoutes":[],"_meta":{"trailingSlash":"ignore"}}},{"file":"","links":[],"scripts":[{"type":"external","value":"/_astro/hoisted.GaT7bmE3.js"}],"styles":[{"type":"external","src":"/_astro/_slug_.4W7qhV-L.css"}],"routeData":{"route":"/blog/[page]","isIndex":false,"type":"page","pattern":"^\\/blog\\/([^/]+?)\\/?$","segments":[[{"content":"blog","dynamic":false,"spread":false}],[{"content":"page","dynamic":true,"spread":false}]],"params":["page"],"component":"src/pages/blog/[page].astro","prerender":false,"fallbackRoutes":[],"_meta":{"trailingSlash":"ignore"}}},{"file":"","links":[],"scripts":[{"type":"external","value":"/_astro/hoisted.GaT7bmE3.js"}],"styles":[{"type":"external","src":"/_astro/_slug_.4W7qhV-L.css"}],"routeData":{"route":"/[...slug]","isIndex":false,"type":"page","pattern":"^(?:\\/(.*?))?\\/?$","segments":[[{"content":"...slug","dynamic":true,"spread":true}]],"params":["...slug"],"component":"src/pages/[...slug].astro","prerender":false,"fallbackRoutes":[],"_meta":{"trailingSlash":"ignore"}}}],"site":"https://demo.ecomplus.app","base":"/","trailingSlash":"ignore","compressHTML":false,"componentMetadata":[["/home/leo/code/ecomplus/cloud-commerce/packages/storefront/src/lib/layouts/BaseHead.astro",{"propagation":"in-tree","containsHead":false}],["/home/leo/code/ecomplus/cloud-commerce/packages/storefront/src/pages/[...slug].astro",{"propagation":"in-tree","containsHead":false}],["\u0000@astro-page:src/pages/[...slug]@_@astro",{"propagation":"in-tree","containsHead":false}],["\u0000@astrojs-ssr-virtual-entry",{"propagation":"in-tree","containsHead":false}],["/home/leo/code/ecomplus/cloud-commerce/packages/storefront/src/pages/app/account.astro",{"propagation":"in-tree","containsHead":false}],["\u0000@astro-page:src/pages/app/account@_@astro",{"propagation":"in-tree","containsHead":false}],["/home/leo/code/ecomplus/cloud-commerce/packages/storefront/src/pages/app/index.astro",{"propagation":"in-tree","containsHead":false}],["\u0000@astro-page:src/pages/app/index@_@astro",{"propagation":"in-tree","containsHead":false}],["/home/leo/code/ecomplus/cloud-commerce/packages/storefront/src/pages/blog/[page].astro",{"propagation":"in-tree","containsHead":false}],["\u0000@astro-page:src/pages/blog/[page]@_@astro",{"propagation":"in-tree","containsHead":false}],["/home/leo/code/ecomplus/cloud-commerce/packages/storefront/src/pages/~fallback.astro",{"propagation":"in-tree","containsHead":false}],["\u0000@astro-page:src/pages/~fallback@_@astro",{"propagation":"in-tree","containsHead":false}]],"renderers":[],"clientDirectives":[["idle","(()=>{var i=t=>{let e=async()=>{await(await t())()};\"requestIdleCallback\"in window?window.requestIdleCallback(e):setTimeout(e,200)};(self.Astro||(self.Astro={})).idle=i;window.dispatchEvent(new Event(\"astro:idle\"));})();"],["load","(()=>{var e=async t=>{await(await t())()};(self.Astro||(self.Astro={})).load=e;window.dispatchEvent(new Event(\"astro:load\"));})();"],["media","(()=>{var s=(i,t)=>{let a=async()=>{await(await i())()};if(t.value){let e=matchMedia(t.value);e.matches?a():e.addEventListener(\"change\",a,{once:!0})}};(self.Astro||(self.Astro={})).media=s;window.dispatchEvent(new Event(\"astro:media\"));})();"],["only","(()=>{var e=async t=>{await(await t())()};(self.Astro||(self.Astro={})).only=e;window.dispatchEvent(new Event(\"astro:only\"));})();"],["visible","(()=>{var l=(s,i,o)=>{let r=async()=>{await(await s())()},t=typeof i.value==\"object\"?i.value:void 0,c={rootMargin:t==null?void 0:t.rootMargin},n=new IntersectionObserver(e=>{for(let a of e)if(a.isIntersecting){n.disconnect(),r();break}},c);for(let e of o.children)n.observe(e)};(self.Astro||(self.Astro={})).visible=l;window.dispatchEvent(new Event(\"astro:visible\"));})();"],["context","(()=>{var a=(s,o)=>{let n=async()=>{await(await s())()},r=()=>{let t=Array.isArray(o.value)?o.value:[o.value];for(let e=0;e<t.length;e++)if(typeof t[e]==\"string\"&&t[e].startsWith(\"data:\")){let d=t[e].substring(5);if(!window.$storefront?.data?.[d]){window.addEventListener(`storefront:data:${d}`,r,{once:!0});return}}if(t.includes(\"idle\")){if(typeof window.requestIdleCallback==\"function\"){setTimeout(()=>window.requestIdleCallback(n),9);return}setTimeout(n,200);return}n()},i=window.$storefront?.apiContext?.doc._id||null;if(window._firstLoadContextId===i&&window._emitedContextId===i){console.log(\"[ctx] first load\"),r(),document.addEventListener(\"astro:beforeload\",()=>{delete window._firstLoadContextId},{once:!0});return}window.addEventListener(\"storefront:apiContext\",r,{once:!0})};(self.Astro||(self.Astro={})).context=a;window.dispatchEvent(new Event(\"astro:context\"));})();\n"]],"entryModules":{"\u0000@astrojs-ssr-virtual-entry":"entry.mjs","\u0000@astro-renderers":"renderers.mjs","\u0000noop-middleware":"_noop-middleware.mjs","/src/pages/blog/[page].astro":"chunks/pages/_page__0sN9U0SD.mjs","/src/pages/app/account.astro":"chunks/pages/account_OQr_6KN1.mjs","/src/pages/app/index.astro":"chunks/pages/index_3IjgOEIq.mjs","/../../node_modules/.pnpm/astro@4.3.2_@types+node@18.19.14_typescript@5.2.2/node_modules/astro/dist/assets/endpoint/node.js":"chunks/pages/node_OmjWRf8D.mjs","/src/pages/~fallback.astro":"chunks/pages/~fallback_133FK-CP.mjs","\u0000@astrojs-manifest":"manifest_9FASPYUE.mjs","\u0000@astro-page:../../node_modules/.pnpm/astro@4.3.2_@types+node@18.19.14_typescript@5.2.2/node_modules/astro/dist/assets/endpoint/node@_@js":"chunks/node_zqXXqc-u.mjs","\u0000@astro-page:src/pages/~fallback@_@astro":"chunks/~fallback_Wahcp9Wk.mjs","\u0000@astro-page:src/pages/app/index@_@astro":"chunks/index__05fnqFh.mjs","\u0000@astro-page:src/pages/app/account@_@astro":"chunks/account_vK6pmJlz.mjs","\u0000@astro-page:src/pages/blog/[page]@_@astro":"chunks/_page__qqIVxbal.mjs","\u0000@astro-page:src/pages/[...slug]@_@astro":"chunks/_.._19fCuQdO.mjs","/home/leo/code/ecomplus/cloud-commerce/packages/storefront/src/components/SearchModal.vue":"_astro/SearchModal.rasg5jV6.js","/home/leo/code/ecomplus/cloud-commerce/packages/storefront/src/components/CartSidebar.vue":"_astro/CartSidebar.L0Vbhsdt.js","/home/leo/code/ecomplus/cloud-commerce/node_modules/photoswipe/dist/photoswipe.css?inline":"_astro/photoswipe.0V7m2jWu.js","/astro/hoisted.js?q=1":"_astro/hoisted.XOXTrHqn.js","/home/leo/code/ecomplus/cloud-commerce/packages/storefront/src/lib/scripts/firebase-app.ts":"_astro/firebase-app.iLdzDVjL.js","~/components/PitchBar.vue":"_astro/PitchBar.yqD9ycx5.js","~/components/AccountPage.vue":"_astro/AccountPage.0M6_FdU6.js","@astrojs/vue/client.js":"_astro/client.YJ00ta5M.js","~/components/ProductDetails.vue":"_astro/ProductDetails.FQtM5kpd.js","/astro/hoisted.js?q=2":"_astro/hoisted.GaT7bmE3.js","~/components/ProductShelf.vue":"_astro/ProductShelf.GAAhKdTN.js","~/components/SearchShowcase.vue":"_astro/SearchShowcase.kA6jICYo.js","/astro/hoisted.js?q=0":"_astro/hoisted.ICXGWNEA.js","/home/leo/code/ecomplus/cloud-commerce/node_modules/photoswipe/dist/photoswipe-lightbox.esm.js":"_astro/photoswipe-lightbox.esm.dZBqKD9u.js","~/components/HeroSlider.vue":"_astro/HeroSlider.ju9TsLrJ.js","/home/leo/code/ecomplus/cloud-commerce/node_modules/photoswipe/dist/photoswipe.esm.js":"_astro/photoswipe.esm.Ylh9TGkz.js","~/components/ShopHeader.vue":"_astro/ShopHeader.v_L96Y90.js","astro:scripts/before-hydration.js":""},"assets":["/_astro/_slug_.4W7qhV-L.css","/robots.txt","/img/icon.png","/img/large-icon.png","/_astro/AccountPage.0M6_FdU6.js","/_astro/CartSidebar.L0Vbhsdt.js","/_astro/HeroSlider.ju9TsLrJ.js","/_astro/PitchBar.yqD9ycx5.js","/_astro/Prices.xI1rdM1e.js","/_astro/ProductDetails.FQtM5kpd.js","/_astro/ProductShelf.-4fsYkPB.js","/_astro/ProductShelf.GAAhKdTN.js","/_astro/QuantitySelector.v7L8EYOR.js","/_astro/SearchModal.rasg5jV6.js","/_astro/SearchShowcase.kA6jICYo.js","/_astro/ShopHeader.v_L96Y90.js","/_astro/_plugin-vue_export-helper.xATGHWd9.js","/_astro/afetch.OifQZgwR.js","/_astro/client.YJ00ta5M.js","/_astro/customer-session.ZD6tLDQJ.js","/_astro/firebase-app.iLdzDVjL.js","/_astro/format-money.1_HtF5S2.js","/_astro/grid-title.pK2Nn3i-.js","/_astro/hoisted.GaT7bmE3.js","/_astro/hoisted.ICXGWNEA.js","/_astro/hoisted.XOXTrHqn.js","/_astro/i18n.zhlBzJt8.js","/_astro/img-sizes.gxAI9JNh.js","/_astro/img.AnjeGdy_.js","/_astro/index-bea2a320.eWykogwr.js","/_astro/index.KfrHdfOH.js","/_astro/index.ShNlAyu1.js","/_astro/modules-info.HP6478mG.js","/_astro/name.VA3MEpe0.js","/_astro/photoswipe-lightbox.esm.dZBqKD9u.js","/_astro/photoswipe.0V7m2jWu.js","/_astro/photoswipe.esm.Ylh9TGkz.js","/_astro/price.Easct8WC.js","/_astro/server-data.4C60Esyt.js","/_astro/sf-utils.c42cbZ9W.js","/_astro/shopping-cart.nSNNOrp9.js","/_astro/use-analytics.wTmoP8B1.js","/_astro/use-product-card.UFr8SCuD.js","/_astro/use-text-value.lKqoIagH.js","/img/uploads/banner2.webp","/img/uploads/ecom-icon.png","/img/uploads/headphone.webp","/img/uploads/logo.png","/img/uploads/og-image.png","/img/uploads/passion.webp","/img/uploads/rect8589.png","/img/uploads/rect859.png","/img/uploads/rect89.webp"],"buildFormat":"directory"});
201
+
202
+ export { AstroIntegrationLogger as A, Logger as L, getEventPrefix as g, levels as l, manifest };
@@ -1,6 +1,6 @@
1
1
  import { defineComponent, h, createSSRApp } from 'vue';
2
2
  import { renderToString } from 'vue/server-renderer';
3
- import { m as mod, n as createApp } from './chunks/pages/__z8Igc_-f.mjs';
3
+ import { o as mod, p as createApp } from './chunks/pages/__ZucPYaOo.mjs';
4
4
 
5
5
  const setup = async (app) => {
6
6
  if ('default' in mod) {
@@ -8,6 +8,8 @@ const setup = async (app) => {
8
8
  }
9
9
  };
10
10
 
11
+ /* eslint-disable no-restricted-syntax */
12
+
11
13
  /**
12
14
  * Astro passes `children` as a string of HTML, so we need
13
15
  * a wrapper `div` to render that content as VNodes.
@@ -15,48 +17,57 @@ const setup = async (app) => {
15
17
  * This is the Vue + JSX equivalent of using `<div v-html="value" />`
16
18
  */
17
19
  const StaticHtml = defineComponent({
18
- props: {
19
- value: String,
20
- name: String,
21
- hydrate: {
22
- type: Boolean,
23
- default: true,
24
- },
25
- },
26
- setup({ name, value, hydrate }) {
27
- if (!value) return () => null;
28
- let tagName = hydrate ? 'astro-slot' : 'astro-static-slot';
29
- return () => h(tagName, { name, innerHTML: value });
30
- },
20
+ props: {
21
+ value: String,
22
+ name: String,
23
+ hydrate: {
24
+ type: Boolean,
25
+ default: true,
26
+ },
27
+ },
28
+ setup({ name, value, hydrate }) {
29
+ if (!value) return () => null;
30
+ const tagName = hydrate ? 'astro-slot' : 'astro-static-slot';
31
+ return () => h(tagName, { name, innerHTML: value });
32
+ },
31
33
  });
32
34
 
35
+ /**
36
+ * Other frameworks have `shouldComponentUpdate` in order to signal
37
+ * that this subtree is entirely static and will not be updated
38
+ *
39
+ * Fortunately, Vue is smart enough to figure that out without any
40
+ * help from us, so this just works out of the box!
41
+ */
42
+
33
43
  function check(Component) {
34
- return !!Component['ssrRender'] || !!Component['__ssrInlineRender'];
44
+ return !!Component.ssrRender || !!Component.__ssrInlineRender;
35
45
  }
36
46
 
37
47
  async function renderToStaticMarkup(Component, inputProps, slotted, metadata) {
38
- const slots = {};
39
- const props = { ...inputProps };
40
- delete props.slot;
41
- for (const [key, value] of Object.entries(slotted)) {
42
- slots[key] = () =>
43
- h(StaticHtml, {
44
- value,
45
- name: key === 'default' ? undefined : key,
46
- // Adjust how this is hydrated only when the version of Astro supports `astroStaticSlot`
47
- hydrate: metadata.astroStaticSlot ? !!metadata.hydrate : true,
48
- });
49
- }
50
- const app = createSSRApp({ render: () => h(Component, props, slots) });
51
- await setup(app);
52
- const html = await renderToString(app);
53
- return { html };
48
+ const slots = {};
49
+ const props = { ...inputProps };
50
+ delete props.slot;
51
+ const sid = this.result?.cookies?.get('sid')?.value;
52
+ for (const [key, value] of Object.entries(slotted)) {
53
+ slots[key] = () => h(StaticHtml, {
54
+ value,
55
+ name: key === 'default' ? undefined : key,
56
+ // Adjust how this is hydrated only when the version of Astro supports `astroStaticSlot`
57
+ hydrate: metadata.astroStaticSlot ? !!metadata.hydrate : true,
58
+ });
59
+ }
60
+ const app = createSSRApp({ render: () => h(Component, props, slots) });
61
+ app.provide('sid', sid);
62
+ await setup(app);
63
+ const html = await renderToString(app);
64
+ return { html };
54
65
  }
55
66
 
56
67
  const _renderer0 = {
57
- check,
58
- renderToStaticMarkup,
59
- supportsAstroStaticSlot: true,
68
+ check,
69
+ renderToStaticMarkup,
70
+ supportsAstroStaticSlot: true,
60
71
  };
61
72
 
62
73
  const renderers = [Object.assign({"name":"@astrojs/vue","clientEntrypoint":"@astrojs/vue/client.js","serverEntrypoint":"@astrojs/vue/server.js"}, { ssr: _renderer0 }),];
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/storefront",
3
3
  "type": "module",
4
- "version": "2.3.0",
4
+ "version": "2.3.2",
5
5
  "description": "E-Com Plus Cloud Commerce storefront with Astro",
6
6
  "bin": {
7
7
  "storefront": "./scripts/build-prod.sh"
@@ -30,7 +30,7 @@
30
30
  "lint:fix": "eslint -c ../eslint/storefront.staged.eslintrc.cjs src/lib/**/*.{ts,vue,astro} --fix"
31
31
  },
32
32
  "dependencies": {
33
- "@astrojs/node": "8.1.0",
33
+ "@astrojs/node": "8.2.0",
34
34
  "@astrojs/vue": "4.0.8",
35
35
  "@cloudcommerce/api": "workspace:*",
36
36
  "@cloudcommerce/config": "workspace:*",
@@ -43,18 +43,18 @@
43
43
  "@types/gtag.js": "^0.0.18",
44
44
  "@vite-pwa/astro": "^0.2.0",
45
45
  "@vueuse/core": "10.7.2",
46
- "astro": "4.2.8",
46
+ "astro": "4.3.2",
47
47
  "astro-capo": "^0.0.1",
48
48
  "chroma-js": "^2.4.2",
49
49
  "dotenv": "^16.4.1",
50
- "firebase": "^10.7.2",
50
+ "firebase": "^10.8.0",
51
51
  "image-size": "^1.1.1",
52
52
  "mime": "^3.0.0",
53
53
  "mitt": "^3.0.1",
54
54
  "semver": "^7.5.4",
55
55
  "sharp": "^0.32.6",
56
56
  "tailwindcss": "^3.4.1",
57
- "unocss": "^0.58.4",
57
+ "unocss": "^0.58.5",
58
58
  "unplugin-auto-import": "^0.17.5",
59
59
  "vite": "^5.0.11",
60
60
  "vite-plugin-pwa": "^0.17.5",
@@ -11,7 +11,6 @@ declare global {
11
11
  assetsPrefix: string,
12
12
  }
13
13
  }
14
- var astroUrl: URL;
15
14
 
16
15
  var $storefront: $Storefront & {
17
16
  onLoad: (callback: (...args: any[]) => void) => void,
@@ -7,24 +7,31 @@ import type {
7
7
  } from '@cloudcommerce/api/types';
8
8
  import type { SettingsContent } from '@@sf/content';
9
9
 
10
+ export type StorefrontApiContext = {
11
+ resource: 'products',
12
+ doc: Products,
13
+ timestamp: number,
14
+ } | {
15
+ resource: 'categories',
16
+ doc: Categories,
17
+ timestamp: number,
18
+ } | {
19
+ resource: 'brands',
20
+ doc: Brands,
21
+ timestamp: number,
22
+ } | {
23
+ resource: 'collections',
24
+ doc: Collections,
25
+ timestamp: number,
26
+ };
27
+
10
28
  export type $Storefront = {
11
29
  settings: Partial<SettingsContent>,
12
- apiContext?: {
13
- resource: 'products',
14
- doc: Products,
15
- timestamp: number,
16
- } | {
17
- resource: 'categories',
18
- doc: Categories,
19
- timestamp: number,
20
- } | {
21
- resource: 'brands',
22
- doc: Brands,
23
- timestamp: number,
24
- } | {
25
- resource: 'collections',
26
- doc: Collections,
27
- timestamp: number,
30
+ url: URL,
31
+ apiContext?: StorefrontApiContext,
32
+ getSession: (sid?: string) => {
33
+ url: URL,
34
+ apiContext?: StorefrontApiContext,
28
35
  },
29
36
  data: Record<string, any> & {
30
37
  categories?: Array<Partial<Categories>>,
@@ -57,9 +57,7 @@ const usePagination = (props: Props) => {
57
57
 
58
58
  const baseUrl = ref('');
59
59
  watch(toRef(props, 'isUrlPath'), () => {
60
- const url = import.meta.env.SSR
61
- ? global.astroUrl
62
- : new URL(window.location.toString());
60
+ const { url } = globalThis.$storefront;
63
61
  if (props.isUrlPath && !url.pathname.endsWith('/')) {
64
62
  url.pathname += '/';
65
63
  } else {
@@ -135,11 +135,16 @@ if (apiDoc) {
135
135
  inlineClientJS += `
136
136
  window._firstLoadContextId = '${apiDoc._id}';`;
137
137
  contextInlineClientJS = `
138
+ $storefront.url = new URL(window.location.toString());
138
139
  $storefront.apiContext = ${JSON.stringify({
139
140
  resource: apiContext.resource,
140
141
  doc: minifyApiDoc({ ...apiDoc }),
141
142
  timestamp: Date.now(),
142
143
  })};
144
+ $storefront.getSession = (/* sid */) => {
145
+ url: $storefront.url,
146
+ apiContext: $storefront.apiContext,
147
+ };
143
148
  $storefront.context /* DEPRECATED */ = $storefront.apiContext;
144
149
  _emitApiContext('${apiDoc._id}');`;
145
150
  } else {
@@ -0,0 +1,3 @@
1
+ // https://github.com/Herohtar/netlify-cms-oauth-firebase/blob/master/functions/index.js#L9-L25
2
+
3
+ // window.postMessage(...);
@@ -11,29 +11,36 @@ import afetch from '../../helpers/afetch';
11
11
  import parseGtagToFbq from '../../analytics/event-to-fbq';
12
12
  import parseGtagToTtq from '../../analytics/event-to-ttq';
13
13
 
14
+ const deployRand = import.meta.env.DEPLOY_RAND || '_';
15
+
14
16
  type AnalyticsEvent = {
15
17
  type: 'gtag' | 'fbq' | 'ttq',
16
18
  name: string,
17
19
  params?: Record<string, any>,
18
20
  };
21
+ type AnalyticsVariantCtx = Partial<ReturnType<typeof useAnalytics>>;
19
22
  let eventsToSend: Array<AnalyticsEvent> = [];
20
- const _sendServerEvents = useDebounceFn(() => {
23
+ const _sendServerEvents = useDebounceFn((variantCtx?: AnalyticsVariantCtx) => {
21
24
  afetch(`/_analytics`, {
22
25
  method: 'POST',
23
26
  body: {
27
+ exp_variant_string: variantCtx?.expVariantString,
24
28
  ...getAnalyticsContext(),
25
29
  events: eventsToSend,
26
30
  },
27
31
  });
28
32
  eventsToSend = [];
29
33
  }, 200);
30
- const sendServerEvent = (analyticsEvent: AnalyticsEvent) => {
31
- eventsToSend.push(analyticsEvent);
32
- _sendServerEvents();
33
- };
34
34
 
35
- if (!import.meta.env.SSR) {
36
- useAnalytics();
35
+ if (
36
+ !import.meta.env.SSR
37
+ && !window.location.search.includes(`__isrV=${deployRand}`)
38
+ ) {
39
+ const variantCtx = useAnalytics();
40
+ const sendServerEvent = (analyticsEvent: AnalyticsEvent) => {
41
+ eventsToSend.push(analyticsEvent);
42
+ _sendServerEvents(variantCtx);
43
+ };
37
44
  watchGtagEvents(async (evMessage) => {
38
45
  const { name, params } = evMessage.event;
39
46
  sendServerEvent({ type: 'gtag', name, params });
@@ -3,7 +3,9 @@ import type { BaseConfig } from '@cloudcommerce/config';
3
3
  import type { ApiError, ApiEndpoint } from '@cloudcommerce/api';
4
4
  import type { ResourceId, CategoriesList, BrandsList } from '@cloudcommerce/api/types';
5
5
  import type { ContentGetter, SettingsContent, PageContent } from '@@sf/content';
6
+ import type { StorefrontApiContext } from '@@sf/$storefront';
6
7
  import { EventEmitter } from 'node:events';
8
+ import { inject, getCurrentInstance } from 'vue';
7
9
  import api from '@cloudcommerce/api';
8
10
  import _getConfig from '../../config/storefront.config.mjs';
9
11
  import { termify } from '../helpers/sf-utils';
@@ -38,14 +40,42 @@ declare global {
38
40
  if (!globalThis.$apiPrefetchEndpoints) {
39
41
  globalThis.$apiPrefetchEndpoints = [];
40
42
  }
43
+ const sessions: Record<string, {
44
+ url: URL,
45
+ apiContext?: StorefrontApiContext,
46
+ _timer?: NodeJS.Timeout,
47
+ }> = {};
48
+ // Internal global just to early clear session objects from memory
49
+ global.__sfSessions = sessions;
41
50
  if (!globalThis.$storefront) {
42
- globalThis.$storefront = {
51
+ globalThis.$storefront = new Proxy({
43
52
  settings: {},
53
+ data: {},
54
+ url: undefined as any,
55
+ getSession(sid?: string) {
56
+ if (!sid && !!getCurrentInstance()) {
57
+ sid = inject('sid');
58
+ }
59
+ const {
60
+ url,
61
+ apiContext,
62
+ } = (sid && sessions[sid]) || (global.__sfSession as typeof sessions[string]);
63
+ return { url, apiContext };
64
+ },
44
65
  onLoad(callback: (...args: any[]) => void) {
45
66
  emitter.once('load', callback);
46
67
  },
47
- data: {},
48
- };
68
+ }, {
69
+ get(target, prop) {
70
+ if (prop === 'apiContext') {
71
+ return target.getSession().apiContext;
72
+ }
73
+ if (prop === 'url') {
74
+ return target.getSession().url;
75
+ }
76
+ return target[prop];
77
+ },
78
+ });
49
79
  }
50
80
 
51
81
  declare global {
@@ -81,7 +111,9 @@ const loadRouteContext = async (
81
111
  apiPrefetchEndpoints?: ApiPrefetchEndpoints;
82
112
  } = {},
83
113
  ) => {
84
- globalThis.astroUrl = Astro.url;
114
+ const sid = `${Date.now() + Math.random()}`;
115
+ sessions[sid] = { url: Astro.url };
116
+ global.__sfSession = sessions[sid];
85
117
  const startedAt = Date.now();
86
118
  let urlPath = Astro.url.pathname;
87
119
  const isPreview = urlPath.startsWith('/~preview');
@@ -154,11 +186,16 @@ const loadRouteContext = async (
154
186
  .catch(console.warn);
155
187
  const apiDoc = apiContext.doc as Record<string, any>;
156
188
  apiState[`${apiResource}/${apiDoc._id}`] = apiDoc;
157
- globalThis.$storefront.apiContext = {
189
+ sessions[sid].apiContext = {
158
190
  resource: apiResource,
159
191
  doc: apiDoc as any,
160
192
  timestamp: Date.now(),
161
193
  };
194
+ sessions[sid]._timer = setTimeout(() => {
195
+ // @ts-ignore
196
+ sessions[sid] = null;
197
+ delete sessions[sid];
198
+ }, 6000);
162
199
  resolve(null);
163
200
  })
164
201
  .catch((err: ApiError) => {
@@ -221,7 +258,9 @@ const loadRouteContext = async (
221
258
  } else {
222
259
  Astro.locals.assetsPrefix = '';
223
260
  }
224
- if (urlPath === '/~fallback') {
261
+ if (isPreview) {
262
+ setResponseCache(Astro, 0);
263
+ } else if (urlPath === '/~fallback') {
225
264
  setResponseCache(Astro, 3600, 86400);
226
265
  } else if (isHomepage) {
227
266
  setResponseCache(Astro, 180);
@@ -238,10 +277,13 @@ const loadRouteContext = async (
238
277
  apiContext,
239
278
  apiState,
240
279
  isPreview,
280
+ sid,
241
281
  // Astro,
242
282
  };
243
283
  Astro.locals.routeContext = routeContext;
244
- emitter.emit('load', routeContext);
284
+ Astro.cookies.set('sid', sid);
285
+ Astro.response.headers.set('X-SId', sid);
286
+ emitter.emit('load', { ...config, apiState });
245
287
  globalThis.__sfIds = {}; // see helpers/sf-utils.ts
246
288
  return routeContext;
247
289
  };