cloudcommerce 2.3.2 → 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 (170) hide show
  1. package/.gitmodules +3 -3
  2. package/CHANGELOG.md +10 -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 +2 -2
  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 +1 -1
  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 +1 -1
  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 +1 -1
  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 +1 -1
  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/package.json +2 -2
  53. package/packages/storefront/client.d.ts +3 -0
  54. package/packages/storefront/package.json +4 -3
  55. package/packages/storefront/src/decap-cms/gen-preview-container.ts +32 -0
  56. package/packages/storefront/src/decap-cms/get-cms-config.ts +59 -0
  57. package/packages/storefront/src/lib/components/ViewTransitions.astro +4 -1
  58. package/packages/storefront/src/lib/layouts/BaseHead.astro +5 -5
  59. package/packages/storefront/src/lib/scripts/decap-cms.ts +117 -0
  60. package/packages/test-base/package.json +1 -1
  61. package/packages/types/package.json +1 -1
  62. package/packages/storefront/src/lib/scripts/git-cms-auth.ts +0 -3
  63. package/packages/storefront/src/lib/scripts/sso-ecom.ts +0 -0
  64. /package/ecomplus-stores/{barra-doce → barradoce}/.devcontainer/devcontainer.json +0 -0
  65. /package/ecomplus-stores/{barra-doce → barradoce}/.editorconfig +0 -0
  66. /package/ecomplus-stores/{barra-doce → barradoce}/.eslintrc.cjs +0 -0
  67. /package/ecomplus-stores/{barra-doce → barradoce}/.firebaserc +0 -0
  68. /package/ecomplus-stores/{barra-doce → barradoce}/.github/build-and-deploy +0 -0
  69. /package/ecomplus-stores/{barra-doce → barradoce}/.github/renovate.json +0 -0
  70. /package/ecomplus-stores/{barra-doce → barradoce}/.github/workflows/build-and-deploy.yml +0 -0
  71. /package/ecomplus-stores/{barra-doce → barradoce}/.github/workflows/calibreapp-image-actions.yml +0 -0
  72. /package/ecomplus-stores/{barra-doce → barradoce}/.gitpod.yml +0 -0
  73. /package/ecomplus-stores/{barra-doce → barradoce}/.husky/pre-commit +0 -0
  74. /package/ecomplus-stores/{barra-doce → barradoce}/.idx/dev.nix +0 -0
  75. /package/ecomplus-stores/{barra-doce → barradoce}/.nvmrc +0 -0
  76. /package/ecomplus-stores/{barra-doce → barradoce}/.vscode/extensions.json +0 -0
  77. /package/ecomplus-stores/{barra-doce → barradoce}/.vscode/launch.json +0 -0
  78. /package/ecomplus-stores/{barra-doce → barradoce}/.vscode/settings.json +0 -0
  79. /package/ecomplus-stores/{barra-doce → barradoce}/README.md +0 -0
  80. /package/ecomplus-stores/{barra-doce → barradoce}/SETUP.md +0 -0
  81. /package/ecomplus-stores/{barra-doce → barradoce}/SETUP.pt-BR.md +0 -0
  82. /package/ecomplus-stores/{barra-doce → barradoce}/conf/firebase.json +0 -0
  83. /package/ecomplus-stores/{barra-doce → barradoce}/functions/config.json +0 -0
  84. /package/ecomplus-stores/{barra-doce → barradoce}/functions/example.env +0 -0
  85. /package/ecomplus-stores/{barra-doce → barradoce}/functions/many/index.js +0 -0
  86. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/.eslintrc.cjs +0 -0
  87. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/.staged.eslintrc.cjs +0 -0
  88. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/astro.config.mjs +0 -0
  89. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/content/blog/3.md +0 -0
  90. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/content/blog/4.md +0 -0
  91. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/content/blog/5.md +0 -0
  92. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/content/blog/dos.md +0 -0
  93. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/content/blog/uno.md +0 -0
  94. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/content/extra-pages/contato.md +0 -0
  95. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/content/extra-pages/terms.md +0 -0
  96. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/content/extra-pages/trocas.md +0 -0
  97. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/content/layout.json +0 -0
  98. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/content/pages/brands.json +0 -0
  99. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/content/pages/categories.json +0 -0
  100. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/content/pages/collections.json +0 -0
  101. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/content/pages/home.json +0 -0
  102. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/content/pages/products.json +0 -0
  103. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/content/pages/search.json +0 -0
  104. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/content/settings.json +0 -0
  105. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/index.js +0 -0
  106. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/public/admin/.gitkeep +0 -0
  107. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/public/assets/.gitkeep +0 -0
  108. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/public/img/icon.png +0 -0
  109. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/public/img/large-icon.png +0 -0
  110. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/public/img/uploads/banner-forma-decora.jpg +0 -0
  111. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/public/img/uploads/ecom-icon.png +0 -0
  112. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/public/img/uploads/logo-barradoce.webp +0 -0
  113. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/public/img/uploads/og-image.png +0 -0
  114. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/public/robots.txt +0 -0
  115. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/scripts/build.sh +0 -0
  116. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/src/assets/style.css +0 -0
  117. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/src/components/AccountMenu.vue +0 -0
  118. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/src/components/AccountPage.vue +0 -0
  119. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/src/components/Banner.vue +0 -0
  120. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/src/components/BannersGrid.astro +0 -0
  121. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/src/components/BlogPosts.vue +0 -0
  122. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/src/components/Breadcrumbs.vue +0 -0
  123. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/src/components/CartItem.vue +0 -0
  124. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/src/components/CartSidebar.vue +0 -0
  125. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/src/components/CheckoutPage.vue +0 -0
  126. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/src/components/Collapse.vue +0 -0
  127. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/src/components/ContentEntry.vue +0 -0
  128. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/src/components/DocBanners.vue +0 -0
  129. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/src/components/FooterStamps.vue +0 -0
  130. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/src/components/HeroSlider.vue +0 -0
  131. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/src/components/ImagesGallery.vue +0 -0
  132. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/src/components/LoginForm.vue +0 -0
  133. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/src/components/PageTitle.vue +0 -0
  134. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/src/components/Pagination.vue +0 -0
  135. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/src/components/PitchBar.vue +0 -0
  136. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/src/components/Prices.vue +0 -0
  137. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/src/components/ProductCard.vue +0 -0
  138. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/src/components/ProductDetails.vue +0 -0
  139. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/src/components/ProductShelf.vue +0 -0
  140. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/src/components/ProductSpecifications.vue +0 -0
  141. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/src/components/SearchFilters.vue +0 -0
  142. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/src/components/SearchModal.vue +0 -0
  143. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/src/components/SearchShowcase.vue +0 -0
  144. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/src/components/ShopFooter.vue +0 -0
  145. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/src/components/ShopHeader.vue +0 -0
  146. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/src/components/ShopHeaderMenu.vue +0 -0
  147. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/src/components/ShopHeaderSubmenu.vue +0 -0
  148. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/src/components/ShopSidenav.vue +0 -0
  149. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/src/components/ShopSidenavCategory.vue +0 -0
  150. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/src/components/SkuSelector.vue +0 -0
  151. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/src/env.d.ts +0 -0
  152. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/src/layouts/Base.astro +0 -0
  153. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/src/layouts/PageFooter.astro +0 -0
  154. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/src/layouts/PageHeader.astro +0 -0
  155. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/src/main/Fallback.astro +0 -0
  156. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/src/main/Main.astro +0 -0
  157. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/src/pages/[...slug].astro +0 -0
  158. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/src/pages/_vue.ts +0 -0
  159. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/src/pages/app/account.astro +0 -0
  160. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/src/pages/app/index.astro +0 -0
  161. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/src/pages/blog/[page].astro +0 -0
  162. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/src/pages/blog/_blog-pages.ts +0 -0
  163. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/src/pages/~fallback.astro +0 -0
  164. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/src/scripts/InlineScripts.astro +0 -0
  165. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/tailwind.config.cjs +0 -0
  166. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/tsconfig.json +0 -0
  167. /package/ecomplus-stores/{barra-doce → barradoce}/functions/ssr/uno.config.cjs +0 -0
  168. /package/ecomplus-stores/{barra-doce → barradoce}/functions/with-apps/index.js +0 -0
  169. /package/ecomplus-stores/{barra-doce → barradoce}/scripts/install.sh +0 -0
  170. /package/ecomplus-stores/{barra-doce → barradoce}/tailwind.config.cjs +0 -0
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/feeds",
3
3
  "type": "module",
4
- "version": "2.3.2",
4
+ "version": "2.3.3",
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.3.2",
4
+ "version": "2.3.3",
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.3.2",
4
+ "version": "2.3.3",
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.3.2",
4
+ "version": "2.3.3",
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.3.2",
4
+ "version": "2.3.3",
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.3.2",
4
+ "version": "2.3.3",
5
5
  "description": "E-Com Plus Cloud Commerce storefront SSR",
6
6
  "main": "lib/index.js",
7
7
  "exports": {
@@ -32,7 +32,7 @@
32
32
  "@cloudcommerce/i18n": "workspace:*",
33
33
  "@ecomplus/utils": "1.5.0-rc.6",
34
34
  "@vueuse/core": "10.7.2",
35
- "astro": "4.3.2",
35
+ "astro": "4.3.5",
36
36
  "astro-capo": "^0.0.1",
37
37
  "axios": "^1.6.7",
38
38
  "firebase-admin": "^12.0.0",
@@ -27,6 +27,9 @@ interface Window {
27
27
  ECOM_COUNTRY_CODE: string;
28
28
  GIT_BRANCH: string;
29
29
  AB_EXPERIMENT_ID?: string;
30
+ CMS_CUSTOM_CONFIG?: Record<string, any>;
31
+ CMS_SSO_URL?: string | null;
32
+ CMS_REPO_BASE_DIR?: string;
30
33
  $storefront?: import('@@sf/$storefront').$Storefront & {
31
34
  modulesInfoPreset?: Partial<typeof import('./src/lib/state/modules-info').default>,
32
35
  };
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/storefront",
3
3
  "type": "module",
4
- "version": "2.3.2",
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,7 +43,7 @@
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.2",
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",
@@ -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
  }
@@ -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;
@@ -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,
@@ -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;
@@ -135,16 +140,11 @@ if (apiDoc) {
135
140
  inlineClientJS += `
136
141
  window._firstLoadContextId = '${apiDoc._id}';`;
137
142
  contextInlineClientJS = `
138
- $storefront.url = new URL(window.location.toString());
139
143
  $storefront.apiContext = ${JSON.stringify({
140
144
  resource: apiContext.resource,
141
145
  doc: minifyApiDoc({ ...apiDoc }),
142
146
  timestamp: Date.now(),
143
147
  })};
144
- $storefront.getSession = (/* sid */) => {
145
- url: $storefront.url,
146
- apiContext: $storefront.apiContext,
147
- };
148
148
  $storefront.context /* DEPRECATED */ = $storefront.apiContext;
149
149
  _emitApiContext('${apiDoc._id}');`;
150
150
  } else {
@@ -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
+ }
@@ -2,7 +2,7 @@
2
2
  "name": "@cloudcommerce/test-base",
3
3
  "private": true,
4
4
  "type": "module",
5
- "version": "2.3.2",
5
+ "version": "2.3.3",
6
6
  "description": "E-Com Plus Cloud Commerce basic setup for testing",
7
7
  "main": "lib/index.js",
8
8
  "repository": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/types",
3
3
  "type": "module",
4
- "version": "2.3.2",
4
+ "version": "2.3.3",
5
5
  "description": "E-Com Plus Cloud Commerce reusable type definitions",
6
6
  "main": "index.ts",
7
7
  "repository": {
@@ -1,3 +0,0 @@
1
- // https://github.com/Herohtar/netlify-cms-oauth-firebase/blob/master/functions/index.js#L9-L25
2
-
3
- // window.postMessage(...);
File without changes