cloudcommerce 2.3.1 → 2.3.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.
Files changed (275) hide show
  1. package/.gitmodules +3 -3
  2. package/CHANGELOG.md +22 -0
  3. package/ecomplus-stores/{barra-doce → barradoce}/functions/many/package.json +3 -3
  4. package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/package.json +8 -8
  5. package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/src/components/DocDescription.vue +1 -1
  6. package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/src/main/content/Hero.astro +2 -2
  7. package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/src/main/content/Sections.astro +13 -13
  8. package/ecomplus-stores/{barra-doce → barradoce}/functions/with-apps/package.json +3 -3
  9. package/ecomplus-stores/{barra-doce → barradoce}/package.json +5 -5
  10. package/ecomplus-stores/tia-sonia/package.json +1 -1
  11. package/package.json +6 -6
  12. package/packages/api/package.json +1 -1
  13. package/packages/api/types/brands.d.ts +0 -8
  14. package/packages/api/types/categories.d.ts +0 -8
  15. package/packages/api/types/collections.d.ts +0 -8
  16. package/packages/api/types/products.d.ts +0 -8
  17. package/packages/api/types/stores.d.ts +11 -0
  18. package/packages/apps/affiliate-program/package.json +1 -1
  19. package/packages/apps/correios/package.json +2 -2
  20. package/packages/apps/custom-payment/package.json +1 -1
  21. package/packages/apps/custom-shipping/package.json +1 -1
  22. package/packages/apps/datafrete/package.json +1 -1
  23. package/packages/apps/discounts/package.json +1 -1
  24. package/packages/apps/emails/package.json +1 -1
  25. package/packages/apps/fb-conversions/package.json +2 -2
  26. package/packages/apps/flash-courier/package.json +1 -1
  27. package/packages/apps/frenet/package.json +1 -1
  28. package/packages/apps/galaxpay/package.json +1 -1
  29. package/packages/apps/google-analytics/package.json +1 -1
  30. package/packages/apps/jadlog/package.json +1 -1
  31. package/packages/apps/loyalty-points/package.json +1 -1
  32. package/packages/apps/mandae/package.json +1 -1
  33. package/packages/apps/melhor-envio/package.json +1 -1
  34. package/packages/apps/mercadopago/package.json +1 -1
  35. package/packages/apps/pagarme/package.json +1 -1
  36. package/packages/apps/pagarme-v5/package.json +1 -1
  37. package/packages/apps/paghiper/package.json +1 -1
  38. package/packages/apps/pix/package.json +1 -1
  39. package/packages/apps/tiny-erp/package.json +1 -1
  40. package/packages/apps/webhooks/package.json +1 -1
  41. package/packages/cli/package.json +1 -1
  42. package/packages/config/package.json +1 -1
  43. package/packages/emails/package.json +1 -1
  44. package/packages/eslint/package.json +5 -5
  45. package/packages/eslint/storefront.eslintrc.cjs +1 -0
  46. package/packages/events/package.json +1 -1
  47. package/packages/feeds/package.json +1 -1
  48. package/packages/firebase/package.json +2 -2
  49. package/packages/i18n/package.json +1 -1
  50. package/packages/modules/package.json +1 -1
  51. package/packages/passport/package.json +1 -1
  52. package/packages/ssr/lib/lib/analytics/send-to-ga4.js +2 -1
  53. package/packages/ssr/lib/lib/analytics/send-to-ga4.js.map +1 -1
  54. package/packages/ssr/lib/lib/analytics-events.js +11 -1
  55. package/packages/ssr/lib/lib/analytics-events.js.map +1 -1
  56. package/packages/ssr/lib/lib/serve-storefront.js +35 -21
  57. package/packages/ssr/lib/lib/serve-storefront.js.map +1 -1
  58. package/packages/ssr/package.json +3 -3
  59. package/packages/ssr/src/lib/analytics/send-to-ga4.ts +2 -0
  60. package/packages/ssr/src/lib/analytics-events.ts +11 -1
  61. package/packages/ssr/src/lib/serve-storefront.ts +36 -22
  62. package/packages/storefront/astro.config.mjs +4 -1
  63. package/packages/storefront/client.d.ts +3 -0
  64. package/packages/storefront/config/astro/vue-server.mjs +64 -0
  65. package/packages/storefront/dist/client/_astro/{AccountPage.3-eqV6OR.js → AccountPage.0M6_FdU6.js} +1 -1
  66. package/packages/storefront/dist/client/_astro/{CartSidebar.-Gy6eqIy.js → CartSidebar.L0Vbhsdt.js} +1 -1
  67. package/packages/storefront/dist/client/_astro/ProductDetails.FQtM5kpd.js +7 -0
  68. package/packages/storefront/dist/client/_astro/{ProductShelf.qbTNzuvn.js → ProductShelf.-4fsYkPB.js} +1 -1
  69. package/packages/storefront/dist/client/_astro/{ProductShelf.b77WjhZZ.js → ProductShelf.GAAhKdTN.js} +1 -1
  70. package/packages/storefront/dist/client/_astro/{SearchModal.WzDMBjqi.js → SearchModal.rasg5jV6.js} +1 -1
  71. package/packages/storefront/dist/client/_astro/SearchShowcase.kA6jICYo.js +1 -0
  72. package/packages/storefront/dist/client/_astro/ShopHeader.v_L96Y90.js +7 -0
  73. package/packages/storefront/dist/client/_astro/{_slug_.WkuZ8tvp.css → _slug_.4W7qhV-L.css} +1 -1
  74. package/packages/storefront/dist/client/_astro/customer-session.ZD6tLDQJ.js +7 -0
  75. package/packages/storefront/dist/client/_astro/{firebase-app.VduCDgof.js → firebase-app.iLdzDVjL.js} +1 -1
  76. package/packages/storefront/dist/client/_astro/hoisted.GaT7bmE3.js +1 -0
  77. package/packages/storefront/dist/client/_astro/{hoisted.xTPkED8g.js → hoisted.ICXGWNEA.js} +1 -1
  78. package/packages/storefront/dist/client/_astro/hoisted.XOXTrHqn.js +1 -0
  79. package/packages/storefront/dist/client/_astro/{index-dd468b12.fl8bpn8l.js → index-bea2a320.eWykogwr.js} +93 -93
  80. package/packages/storefront/dist/client/_astro/{shopping-cart.v-dB3kHB.js → shopping-cart.nSNNOrp9.js} +1 -1
  81. package/packages/storefront/dist/client/_astro/use-analytics.wTmoP8B1.js +1 -0
  82. package/packages/storefront/dist/client/_astro/{use-product-card.nNtSJVtB.js → use-product-card.UFr8SCuD.js} +1 -1
  83. package/packages/storefront/dist/client/_astro/use-text-value.lKqoIagH.js +4 -0
  84. package/packages/storefront/dist/server/chunks/{CartSidebar_blvgfFa-.mjs → CartSidebar_3_1aFp67.mjs} +1 -1
  85. package/packages/storefront/dist/server/chunks/{SearchModal_Sktaq643.mjs → SearchModal_2azP1u7P.mjs} +1 -1
  86. package/packages/storefront/dist/server/chunks/_.._19fCuQdO.mjs +5 -0
  87. package/packages/storefront/dist/server/chunks/{_page__9PfWVh79.mjs → _page__qqIVxbal.mjs} +1 -1
  88. package/packages/storefront/dist/server/chunks/{account_R4bpY7O1.mjs → account_vK6pmJlz.mjs} +1 -1
  89. package/packages/storefront/dist/server/chunks/astro/{assets-service_oQ4-9MNg.mjs → assets-service_631fRtTy.mjs} +66 -11
  90. package/packages/storefront/dist/server/chunks/{astro_ECsNQeA2.mjs → astro_u-oSb215.mjs} +8 -2
  91. package/packages/storefront/dist/server/chunks/{index__PeYBuja.mjs → index__05fnqFh.mjs} +1 -1
  92. package/packages/storefront/dist/server/chunks/{node_njrZIjT6.mjs → node_zqXXqc-u.mjs} +1 -1
  93. package/packages/storefront/dist/server/chunks/pages/{__XOsz50la.mjs → __ZucPYaOo.mjs} +380 -118
  94. package/packages/storefront/dist/server/chunks/pages/{_page__cIw_KTpN.mjs → _page__0sN9U0SD.mjs} +19 -3
  95. package/packages/storefront/dist/server/chunks/pages/account_OQr_6KN1.mjs +33 -0
  96. package/packages/storefront/dist/server/chunks/pages/{index_KP7Gn0ld.mjs → index_3IjgOEIq.mjs} +15 -4
  97. package/packages/storefront/dist/server/chunks/pages/node_OmjWRf8D.mjs +112 -0
  98. package/packages/storefront/dist/server/chunks/pages/~fallback_133FK-CP.mjs +59 -0
  99. package/packages/storefront/dist/server/chunks/~fallback_Wahcp9Wk.mjs +5 -0
  100. package/packages/storefront/dist/server/entry.mjs +9 -9
  101. package/packages/storefront/dist/server/manifest_9FASPYUE.mjs +202 -0
  102. package/packages/storefront/dist/server/renderers.mjs +45 -34
  103. package/packages/storefront/package.json +6 -5
  104. package/packages/storefront/server.d.ts +0 -1
  105. package/packages/storefront/src/decap-cms/gen-preview-container.ts +32 -0
  106. package/packages/storefront/src/decap-cms/get-cms-config.ts +59 -0
  107. package/packages/storefront/src/lib/$storefront.d.ts +23 -16
  108. package/packages/storefront/src/lib/components/ViewTransitions.astro +4 -1
  109. package/packages/storefront/src/lib/composables/use-pagination.ts +1 -3
  110. package/packages/storefront/src/lib/layouts/BaseHead.astro +5 -0
  111. package/packages/storefront/src/lib/scripts/decap-cms.ts +117 -0
  112. package/packages/storefront/src/lib/scripts/push-analytics-events.ts +8 -6
  113. package/packages/storefront/src/lib/ssr-context.ts +46 -6
  114. package/packages/storefront/src/lib/state/use-analytics.ts +12 -11
  115. package/packages/storefront/src/lib/state/use-storage.ts +23 -9
  116. package/packages/test-base/package.json +1 -1
  117. package/packages/types/package.json +1 -1
  118. package/packages/storefront/dist/client/_astro/ProductDetails.ATGXfGhG.js +0 -7
  119. package/packages/storefront/dist/client/_astro/SearchShowcase.9gIA4Cq0.js +0 -1
  120. package/packages/storefront/dist/client/_astro/ShopHeader.Ee4OJr3q.js +0 -7
  121. package/packages/storefront/dist/client/_astro/customer-session.dSYHWdP4.js +0 -7
  122. package/packages/storefront/dist/client/_astro/ecom-icon_12falx.png +0 -0
  123. package/packages/storefront/dist/client/_astro/ecom-icon_15pqnO.png +0 -0
  124. package/packages/storefront/dist/client/_astro/ecom-icon_t3guw.png +0 -0
  125. package/packages/storefront/dist/client/_astro/headphone_T2Jjc.avif +0 -0
  126. package/packages/storefront/dist/client/_astro/headphone_Z1CG18r.webp +0 -0
  127. package/packages/storefront/dist/client/_astro/hoisted.d2SGwVMl.js +0 -1
  128. package/packages/storefront/dist/client/_astro/hoisted.x1b7VHef.js +0 -1
  129. package/packages/storefront/dist/client/_astro/logo_1UBsBq.webp +0 -0
  130. package/packages/storefront/dist/client/_astro/logo_Z1K5PE9.png +0 -0
  131. package/packages/storefront/dist/client/_astro/logo_Z1KIIl1.avif +0 -0
  132. package/packages/storefront/dist/client/_astro/passion_LHbe9.webp +0 -0
  133. package/packages/storefront/dist/client/_astro/passion_Z23MeUb.avif +0 -0
  134. package/packages/storefront/dist/client/_astro/rect8589_1TtOHY.png +0 -0
  135. package/packages/storefront/dist/client/_astro/rect8589_1f5opX.webp +0 -0
  136. package/packages/storefront/dist/client/_astro/rect8589_IUskt.webp +0 -0
  137. package/packages/storefront/dist/client/_astro/rect8589_Uxfdf.png +0 -0
  138. package/packages/storefront/dist/client/_astro/rect8589_Z15uApA.png +0 -0
  139. package/packages/storefront/dist/client/_astro/rect8589_Z1Ap1Im.avif +0 -0
  140. package/packages/storefront/dist/client/_astro/rect8589_Z1JT1HB.webp +0 -0
  141. package/packages/storefront/dist/client/_astro/rect8589_ZY9mtN.avif +0 -0
  142. package/packages/storefront/dist/client/_astro/rect8589_tMFW0.avif +0 -0
  143. package/packages/storefront/dist/client/_astro/rect859_1TgQXS.avif +0 -0
  144. package/packages/storefront/dist/client/_astro/rect859_2Nm1z.avif +0 -0
  145. package/packages/storefront/dist/client/_astro/rect859_DIqwR.png +0 -0
  146. package/packages/storefront/dist/client/_astro/rect859_Z1IKDb2.png +0 -0
  147. package/packages/storefront/dist/client/_astro/rect859_Z29FI4V.webp +0 -0
  148. package/packages/storefront/dist/client/_astro/rect859_Z2kFHGk.avif +0 -0
  149. package/packages/storefront/dist/client/_astro/rect859_ZkpPFI.webp +0 -0
  150. package/packages/storefront/dist/client/_astro/rect859_jXzBi.png +0 -0
  151. package/packages/storefront/dist/client/_astro/rect859_x1l16.webp +0 -0
  152. package/packages/storefront/dist/client/_astro/rect89_1TSfW7.avif +0 -0
  153. package/packages/storefront/dist/client/_astro/rect89_Z1re32x.webp +0 -0
  154. package/packages/storefront/dist/client/_astro/use-analytics._ef6TM4P.js +0 -1
  155. package/packages/storefront/dist/client/_astro/use-text-value.0OP9HCfP.js +0 -4
  156. package/packages/storefront/dist/client/~fallback.html +0 -99
  157. package/packages/storefront/dist/client/~index.html +0 -131
  158. package/packages/storefront/dist/server/chunks/_.._yTK2xBRC.mjs +0 -5
  159. package/packages/storefront/dist/server/chunks/pages/account_l-FHyDJd.mjs +0 -23
  160. package/packages/storefront/dist/server/chunks/pages/node_FoLtkdH1.mjs +0 -257
  161. package/packages/storefront/dist/server/chunks/pages/~fallback_KPp6Nh_p.mjs +0 -34
  162. package/packages/storefront/dist/server/chunks/~fallback_p7P7NIL5.mjs +0 -5
  163. package/packages/storefront/dist/server/images.dist.csv +0 -30
  164. package/packages/storefront/dist/server/images.src.csv +0 -11
  165. package/packages/storefront/dist/server/manifest_E6KbHQrT.mjs +0 -202
  166. package/packages/storefront/dist/server/static-builds.csv +0 -71
  167. package/packages/storefront/src/lib/scripts/git-cms-auth.ts +0 -3
  168. package/packages/storefront/src/lib/scripts/sso-ecom.ts +0 -0
  169. /package/ecomplus-stores/{barra-doce → barradoce}/.devcontainer/devcontainer.json +0 -0
  170. /package/ecomplus-stores/{barra-doce → barradoce}/.editorconfig +0 -0
  171. /package/ecomplus-stores/{barra-doce → barradoce}/.eslintrc.cjs +0 -0
  172. /package/ecomplus-stores/{barra-doce → barradoce}/.firebaserc +0 -0
  173. /package/ecomplus-stores/{barra-doce → barradoce}/.github/build-and-deploy +0 -0
  174. /package/ecomplus-stores/{barra-doce → barradoce}/.github/renovate.json +0 -0
  175. /package/ecomplus-stores/{barra-doce → barradoce}/.github/workflows/build-and-deploy.yml +0 -0
  176. /package/ecomplus-stores/{barra-doce → barradoce}/.github/workflows/calibreapp-image-actions.yml +0 -0
  177. /package/ecomplus-stores/{barra-doce → barradoce}/.gitpod.yml +0 -0
  178. /package/ecomplus-stores/{barra-doce → barradoce}/.husky/pre-commit +0 -0
  179. /package/ecomplus-stores/{barra-doce → barradoce}/.idx/dev.nix +0 -0
  180. /package/ecomplus-stores/{barra-doce → barradoce}/.nvmrc +0 -0
  181. /package/ecomplus-stores/{barra-doce → barradoce}/.vscode/extensions.json +0 -0
  182. /package/ecomplus-stores/{barra-doce → barradoce}/.vscode/launch.json +0 -0
  183. /package/ecomplus-stores/{barra-doce → barradoce}/.vscode/settings.json +0 -0
  184. /package/ecomplus-stores/{barra-doce → barradoce}/README.md +0 -0
  185. /package/ecomplus-stores/{barra-doce → barradoce}/SETUP.md +0 -0
  186. /package/ecomplus-stores/{barra-doce → barradoce}/SETUP.pt-BR.md +0 -0
  187. /package/ecomplus-stores/{barra-doce → barradoce}/conf/firebase.json +0 -0
  188. /package/ecomplus-stores/{barra-doce → barradoce}/functions/config.json +0 -0
  189. /package/ecomplus-stores/{barra-doce → barradoce}/functions/example.env +0 -0
  190. /package/ecomplus-stores/{barra-doce → barradoce}/functions/many/index.js +0 -0
  191. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/.eslintrc.cjs +0 -0
  192. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/.staged.eslintrc.cjs +0 -0
  193. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/astro.config.mjs +0 -0
  194. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/content/blog/3.md +0 -0
  195. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/content/blog/4.md +0 -0
  196. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/content/blog/5.md +0 -0
  197. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/content/blog/dos.md +0 -0
  198. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/content/blog/uno.md +0 -0
  199. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/content/extra-pages/contato.md +0 -0
  200. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/content/extra-pages/terms.md +0 -0
  201. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/content/extra-pages/trocas.md +0 -0
  202. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/content/layout.json +0 -0
  203. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/content/pages/brands.json +0 -0
  204. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/content/pages/categories.json +0 -0
  205. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/content/pages/collections.json +0 -0
  206. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/content/pages/home.json +0 -0
  207. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/content/pages/products.json +0 -0
  208. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/content/pages/search.json +0 -0
  209. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/content/settings.json +0 -0
  210. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/index.js +0 -0
  211. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/public/admin/.gitkeep +0 -0
  212. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/public/assets/.gitkeep +0 -0
  213. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/public/img/icon.png +0 -0
  214. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/public/img/large-icon.png +0 -0
  215. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/public/img/uploads/banner-forma-decora.jpg +0 -0
  216. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/public/img/uploads/ecom-icon.png +0 -0
  217. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/public/img/uploads/logo-barradoce.webp +0 -0
  218. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/public/img/uploads/og-image.png +0 -0
  219. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/public/robots.txt +0 -0
  220. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/scripts/build.sh +0 -0
  221. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/src/assets/style.css +0 -0
  222. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/src/components/AccountMenu.vue +0 -0
  223. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/src/components/AccountPage.vue +0 -0
  224. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/src/components/Banner.vue +0 -0
  225. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/src/components/BannersGrid.astro +0 -0
  226. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/src/components/BlogPosts.vue +0 -0
  227. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/src/components/Breadcrumbs.vue +0 -0
  228. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/src/components/CartItem.vue +0 -0
  229. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/src/components/CartSidebar.vue +0 -0
  230. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/src/components/CheckoutPage.vue +0 -0
  231. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/src/components/Collapse.vue +0 -0
  232. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/src/components/ContentEntry.vue +0 -0
  233. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/src/components/DocBanners.vue +0 -0
  234. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/src/components/FooterStamps.vue +0 -0
  235. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/src/components/HeroSlider.vue +0 -0
  236. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/src/components/ImagesGallery.vue +0 -0
  237. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/src/components/LoginForm.vue +0 -0
  238. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/src/components/PageTitle.vue +0 -0
  239. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/src/components/Pagination.vue +0 -0
  240. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/src/components/PitchBar.vue +0 -0
  241. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/src/components/Prices.vue +0 -0
  242. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/src/components/ProductCard.vue +0 -0
  243. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/src/components/ProductDetails.vue +0 -0
  244. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/src/components/ProductShelf.vue +0 -0
  245. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/src/components/ProductSpecifications.vue +0 -0
  246. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/src/components/SearchFilters.vue +0 -0
  247. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/src/components/SearchModal.vue +0 -0
  248. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/src/components/SearchShowcase.vue +0 -0
  249. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/src/components/ShopFooter.vue +0 -0
  250. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/src/components/ShopHeader.vue +0 -0
  251. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/src/components/ShopHeaderMenu.vue +0 -0
  252. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/src/components/ShopHeaderSubmenu.vue +0 -0
  253. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/src/components/ShopSidenav.vue +0 -0
  254. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/src/components/ShopSidenavCategory.vue +0 -0
  255. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/src/components/SkuSelector.vue +0 -0
  256. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/src/env.d.ts +0 -0
  257. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/src/layouts/Base.astro +0 -0
  258. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/src/layouts/PageFooter.astro +0 -0
  259. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/src/layouts/PageHeader.astro +0 -0
  260. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/src/main/Fallback.astro +0 -0
  261. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/src/main/Main.astro +0 -0
  262. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/src/pages/[...slug].astro +0 -0
  263. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/src/pages/_vue.ts +0 -0
  264. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/src/pages/app/account.astro +0 -0
  265. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/src/pages/app/index.astro +0 -0
  266. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/src/pages/blog/[page].astro +0 -0
  267. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/src/pages/blog/_blog-pages.ts +0 -0
  268. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/src/pages/~fallback.astro +0 -0
  269. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/src/scripts/InlineScripts.astro +0 -0
  270. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/tailwind.config.cjs +0 -0
  271. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/tsconfig.json +0 -0
  272. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/uno.config.cjs +0 -0
  273. /package/ecomplus-stores/{barra-doce → barradoce}/functions/with-apps/index.js +0 -0
  274. /package/ecomplus-stores/{barra-doce → barradoce}/scripts/install.sh +0 -0
  275. /package/ecomplus-stores/{barra-doce → barradoce}/tailwind.config.cjs +0 -0
@@ -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/__XOsz50la.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.1",
4
+ "version": "2.3.3",
5
5
  "description": "E-Com Plus Cloud Commerce storefront with Astro",
6
6
  "bin": {
7
7
  "storefront": "./scripts/build-prod.sh"
@@ -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.3.1",
46
+ "astro": "4.3.5",
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",
@@ -64,6 +64,7 @@
64
64
  },
65
65
  "devDependencies": {
66
66
  "@cloudcommerce/eslint": "workspace:*",
67
- "@cloudcommerce/types": "workspace:*"
67
+ "@cloudcommerce/types": "workspace:*",
68
+ "@webcontainer/api": "^1.1.9"
68
69
  }
69
70
  }
@@ -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,
@@ -0,0 +1,32 @@
1
+ import type { WebContainer as IWebContainer } from '@webcontainer/api';
2
+
3
+ export const genPreviewContainer = async ({ createClass, h, WebContainer }: {
4
+ createClass: (o: { render: () => HTMLElement }) => (...args: any) => any,
5
+ h: (n: string, ...args: any) => HTMLElement, // React.createElement
6
+ WebContainer: any,
7
+ }) => {
8
+ const webcontainerInstance: IWebContainer = await WebContainer.boot();
9
+ console.log({ webcontainerInstance });
10
+ // https://github.com/decaporg/decap-cms/issues/2183#issuecomment-997373169
11
+ return createClass({
12
+ render() {
13
+ const { entry } = (this as any).props;
14
+ console.log({ entry });
15
+ const { host } = window.location;
16
+ const slug = '';
17
+ const isLocal = host.startsWith('localhost') || host.startsWith('127.0.0.');
18
+ const src = `${isLocal ? 'http' : 'https'}://${host}/~preview/${slug}`;
19
+ const html = `
20
+ <iframe
21
+ border="0"
22
+ src="${src}"
23
+ width="100%"
24
+ height="100%"
25
+ style="border: 1px solid #EEE; height: calc(100dvh - 12px)"
26
+ ></iframe>`;
27
+ return h('div', { dangerouslySetInnerHTML: { __html: html } });
28
+ },
29
+ });
30
+ };
31
+
32
+ export default genPreviewContainer;
@@ -0,0 +1,59 @@
1
+ export const getCmsConfig = () => {
2
+ const baseDir = window.CMS_REPO_BASE_DIR || 'functions/ssr/';
3
+ const config: Record<string, any> = {
4
+ load_config_file: false,
5
+ media_folder: `${baseDir}template/public/img/uploads`,
6
+ public_folder: '/img/uploads',
7
+ slug: {
8
+ encoding: 'ascii',
9
+ clean_accents: true,
10
+ sanitize_replacement: '-',
11
+ },
12
+ collections: [
13
+ {
14
+ name: 'settings',
15
+ label: 'Configurações',
16
+ description: 'Configurações gerais para identidade e metadados do site',
17
+ delete: false,
18
+ editor: {
19
+ preview: false,
20
+ },
21
+ files: [
22
+ {
23
+ name: 'general',
24
+ label: 'Configurações gerais',
25
+ file: `${baseDir}content/settings.json`,
26
+ editor: {
27
+ preview: true,
28
+ },
29
+ fields: [
30
+ {
31
+ label: 'E-Com Plus Store ID',
32
+ name: 'store_id',
33
+ widget: 'hidden',
34
+ },
35
+ {
36
+ label: 'Repositório',
37
+ name: 'repository',
38
+ widget: 'hidden',
39
+ },
40
+ {
41
+ label: 'Domínio',
42
+ name: 'domain',
43
+ widget: 'string',
44
+ },
45
+ {
46
+ label: 'Nome da loja',
47
+ name: 'name',
48
+ widget: 'string',
49
+ },
50
+ ],
51
+ },
52
+ ],
53
+ },
54
+ ],
55
+ };
56
+ return config;
57
+ };
58
+
59
+ export default getCmsConfig;
@@ -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>>,
@@ -291,7 +291,8 @@ const { fallback = 'animate' } = Astro.props as Props;
291
291
 
292
292
  if (
293
293
  (supportsViewTransitions || getFallback() !== 'none') &&
294
- !location.pathname.startsWith('/app/')
294
+ !location.pathname.startsWith('/app/') &&
295
+ !location.pathname.startsWith('/admin/')
295
296
  ) {
296
297
  markScriptsExec();
297
298
 
@@ -310,6 +311,7 @@ const { fallback = 'animate' } = Astro.props as Props;
310
311
  link.hasAttribute('download') ||
311
312
  !link.href ||
312
313
  link.pathname.startsWith('/app/') || // "real" SPA routes
314
+ link.pathname.startsWith('/admin/') || // CMS route
313
315
  (link.target && link.target !== '_self') ||
314
316
  link.origin !== location.origin ||
315
317
  ev.button !== 0 || // left clicks only
@@ -390,6 +392,7 @@ const { fallback = 'animate' } = Astro.props as Props;
390
392
  el.origin === location.origin &&
391
393
  el.pathname !== location.pathname &&
392
394
  !el.pathname.startsWith('/app/') && // "real" SPA routes
395
+ !el.pathname.startsWith('/admin/') && // CMS route
393
396
  el.dataset.astroReload === undefined &&
394
397
  !el.hasAttribute('download') &&
395
398
  /* <a role=button> commonly used as no-JS interaction fallback,
@@ -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 {
@@ -88,6 +88,11 @@ if (!ogImage) {
88
88
 
89
89
  let inlineClientJS = `
90
90
  window._emitApiContext = (id = null) => {
91
+ $storefront.url = new URL(window.location.toString());
92
+ $storefront.getSession = (/* sid */) => ({
93
+ url: $storefront.url,
94
+ apiContext: $storefront.apiContext,
95
+ });
91
96
  console.log('[ctx] emit ' + id);
92
97
  window.dispatchEvent(new Event('storefront:apiContext'));
93
98
  window._emitedContextId = id;
@@ -0,0 +1,117 @@
1
+ import Deepmerge from '@fastify/deepmerge';
2
+ import getCmsConfig from '../../decap-cms/get-cms-config';
3
+ import genPreviewContainer from '../../decap-cms/gen-preview-container';
4
+
5
+ let cmsConfig: Record<string, any> = getCmsConfig();
6
+ const initCmsWithPreview = () => {
7
+ const {
8
+ CMS,
9
+ initCMS,
10
+ createClass,
11
+ h,
12
+ } = window as any as {
13
+ CMS: Record<string, any>,
14
+ initCMS: (c: { config: Record<string, any> }) => void,
15
+ createClass: any,
16
+ h: any,
17
+ };
18
+ initCMS({ config: cmsConfig });
19
+ /* eslint-disable import/no-unresolved */
20
+ // @ts-ignore
21
+ import(/* @vite-ignore */ 'https://esm.sh/@webcontainer/api@^1')
22
+ .then(({ WebContainer }) => {
23
+ const Preview = genPreviewContainer({ createClass, h, WebContainer });
24
+ CMS.registerPreviewTemplate('general', Preview);
25
+ })
26
+ .catch((err) => {
27
+ console.error(err);
28
+ // eslint-disable-next-line
29
+ window.alert('Failed importing WebContainer for live preview');
30
+ });
31
+ };
32
+
33
+ const initCmsAuth = () => {
34
+ if (import.meta.env.DEV) {
35
+ cmsConfig.local_backend = true;
36
+ cmsConfig.backend = { name: 'git-gateway' };
37
+ initCmsWithPreview();
38
+ return;
39
+ }
40
+ const {
41
+ location,
42
+ sessionStorage,
43
+ ECOM_STORE_ID,
44
+ CMS_SSO_URL = 'https://app.e-com.plus/pages/login?api_version=2',
45
+ } = window;
46
+ const sessionToken = sessionStorage.getItem('cms_token');
47
+ const searchParams = new URLSearchParams(location.search);
48
+ const ssoToken = searchParams.get('sso_token') || searchParams.get('access_token');
49
+ if (!cmsConfig.backend?.base_url) {
50
+ if (!sessionToken && !ssoToken && CMS_SSO_URL) {
51
+ const url = new URL(CMS_SSO_URL);
52
+ url.searchParams.set('sso_store_id', `${ECOM_STORE_ID}`);
53
+ url.searchParams.set('sso_redirect', location.href);
54
+ location.href = url.toString();
55
+ return;
56
+ }
57
+ cmsConfig.backend = {
58
+ repo: '_owner/_name',
59
+ api_root: 'https://ecomplus.app/api/git/github/',
60
+ name: 'github',
61
+ base_url: `https://${location.hostname}`,
62
+ auth_endpoint: location.pathname, // self
63
+ branch: 'main',
64
+ commit_messages: {
65
+ create: 'Create {{collection}} “{{slug}}”',
66
+ update: 'Update {{collection}} “{{slug}}”',
67
+ delete: 'Delete {{collection}} “{{slug}}”',
68
+ uploadMedia: 'Upload “{{path}}”',
69
+ deleteMedia: '[skip ci] Delete “{{path}}”',
70
+ openAuthoring: '{{message}}',
71
+ ...cmsConfig.backend?.commit_messages,
72
+ },
73
+ ...cmsConfig.backend,
74
+ };
75
+ }
76
+ if (sessionToken) {
77
+ initCmsWithPreview();
78
+ // Ref.: https://github.com/decaporg/decap-cms/blob/e93c94f1ce707719dfb7750af82b17c38b461831/packages/decap-cms-lib-auth/src/netlify-auth.js#L46
79
+ // E.g.: https://github.com/Herohtar/netlify-cms-oauth-firebase/blob/master/functions/index.js#L9-L25
80
+ const self = window.opener || window;
81
+ setTimeout(() => {
82
+ self.postMessage('authorizing:github', '*');
83
+ self.postMessage(
84
+ `authorization:github:success:${JSON.stringify({
85
+ sessionToken,
86
+ provider: cmsConfig.backend.name,
87
+ })}`,
88
+ cmsConfig.backend.base_url,
89
+ );
90
+ }, 100);
91
+ return;
92
+ }
93
+ if (ssoToken) {
94
+ window.history?.pushState(
95
+ 'hide-token',
96
+ document.title,
97
+ `${location.pathname}${location.search}${location.hash}`,
98
+ );
99
+ const provider = cmsConfig.backend.name;
100
+ if (provider && provider !== 'git-gateway') {
101
+ sessionStorage.setItem('cms_token', ssoToken);
102
+ }
103
+ }
104
+ initCmsWithPreview();
105
+ };
106
+
107
+ if (!import.meta.env.SSR) {
108
+ if (window.CMS_CUSTOM_CONFIG) {
109
+ const deepmerge = Deepmerge();
110
+ cmsConfig = deepmerge(cmsConfig, window.CMS_CUSTOM_CONFIG);
111
+ }
112
+ (window as any).CMS_MANUAL_INIT = true;
113
+ const cmsScript = document.createElement('script');
114
+ cmsScript.src = 'https://unpkg.com/decap-cms@^3.0.0/dist/decap-cms.js';
115
+ cmsScript.onload = initCmsAuth;
116
+ document.body.appendChild(cmsScript);
117
+ }
@@ -18,27 +18,29 @@ type AnalyticsEvent = {
18
18
  name: string,
19
19
  params?: Record<string, any>,
20
20
  };
21
+ type AnalyticsVariantCtx = Partial<ReturnType<typeof useAnalytics>>;
21
22
  let eventsToSend: Array<AnalyticsEvent> = [];
22
- const _sendServerEvents = useDebounceFn(() => {
23
+ const _sendServerEvents = useDebounceFn((variantCtx?: AnalyticsVariantCtx) => {
23
24
  afetch(`/_analytics`, {
24
25
  method: 'POST',
25
26
  body: {
27
+ exp_variant_string: variantCtx?.expVariantString,
26
28
  ...getAnalyticsContext(),
27
29
  events: eventsToSend,
28
30
  },
29
31
  });
30
32
  eventsToSend = [];
31
33
  }, 200);
32
- const sendServerEvent = (analyticsEvent: AnalyticsEvent) => {
33
- eventsToSend.push(analyticsEvent);
34
- _sendServerEvents();
35
- };
36
34
 
37
35
  if (
38
36
  !import.meta.env.SSR
39
37
  && !window.location.search.includes(`__isrV=${deployRand}`)
40
38
  ) {
41
- useAnalytics();
39
+ const variantCtx = useAnalytics();
40
+ const sendServerEvent = (analyticsEvent: AnalyticsEvent) => {
41
+ eventsToSend.push(analyticsEvent);
42
+ _sendServerEvents(variantCtx);
43
+ };
42
44
  watchGtagEvents(async (evMessage) => {
43
45
  const { name, params } = evMessage.event;
44
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) => {
@@ -240,10 +277,13 @@ const loadRouteContext = async (
240
277
  apiContext,
241
278
  apiState,
242
279
  isPreview,
280
+ sid,
243
281
  // Astro,
244
282
  };
245
283
  Astro.locals.routeContext = routeContext;
246
- emitter.emit('load', routeContext);
284
+ Astro.cookies.set('sid', sid);
285
+ Astro.response.headers.set('X-SId', sid);
286
+ emitter.emit('load', { ...config, apiState });
247
287
  globalThis.__sfIds = {}; // see helpers/sf-utils.ts
248
288
  return routeContext;
249
289
  };
@@ -227,8 +227,13 @@ export const useAnalytics = ({
227
227
  gtag,
228
228
  GTAG_TAG_ID,
229
229
  GA_TRACKING_ID,
230
+ GIT_BRANCH,
230
231
  } = window as { [k:string]: any, gtag?: Gtag.Gtag };
231
232
  const tagId = GTAG_TAG_ID || GA_TRACKING_ID;
233
+ // https://developers.google.com/analytics/devguides/collection/ga4/integration
234
+ const expVariantString: string | null = GIT_BRANCH && experimentId
235
+ ? `${experimentId}-${GIT_BRANCH}`
236
+ : (GIT_BRANCH?.startsWith('main-') && GIT_BRANCH) || null;
232
237
  if (typeof gtag === 'function') {
233
238
  if (tagId) {
234
239
  ['client_id', 'session_id', 'gclid'].forEach((key) => {
@@ -237,17 +242,10 @@ export const useAnalytics = ({
237
242
  });
238
243
  });
239
244
  }
240
- const { GIT_BRANCH } = window;
241
- if (GIT_BRANCH) {
242
- // https://developers.google.com/analytics/devguides/collection/ga4/integration
243
- const expVariantString = experimentId
244
- ? `${experimentId}-${window.GIT_BRANCH}`
245
- : GIT_BRANCH.startsWith('main-') && GIT_BRANCH;
246
- if (expVariantString) {
247
- gtag('event', 'experience_impression', {
248
- exp_variant_string: expVariantString,
249
- });
250
- }
245
+ if (expVariantString) {
246
+ gtag('event', 'experience_impression', {
247
+ exp_variant_string: expVariantString,
248
+ });
251
249
  }
252
250
  }
253
251
  const url = new URL(window.location.toString());
@@ -315,6 +313,9 @@ export const useAnalytics = ({
315
313
  }
316
314
  }, 300);
317
315
  }
316
+ return {
317
+ expVariantString,
318
+ };
318
319
  };
319
320
 
320
321
  export default useAnalytics;