create-abcart-theme 0.0.0-stage → 0.10.1

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 (253) hide show
  1. package/CHANGELOG.md +127 -0
  2. package/LICENSE +202 -0
  3. package/NOTICE +2 -0
  4. package/README.md +64 -2
  5. package/bin/create-abcart-theme.mjs +4 -0
  6. package/package.json +47 -4
  7. package/src/args.mjs +113 -0
  8. package/src/banner.mjs +21 -0
  9. package/src/cli.mjs +119 -0
  10. package/src/create.mjs +82 -0
  11. package/src/package-manager.mjs +32 -0
  12. package/src/style.mjs +17 -0
  13. package/templates/default/.agents/skills/shopify-theme-asset-collector/SKILL.md +125 -0
  14. package/templates/default/.agents/skills/shopify-theme-asset-collector/scripts/collect_public_assets.py +370 -0
  15. package/templates/default/.agents/skills/wocart-docs/SKILL.md +146 -0
  16. package/templates/default/.agents/skills/wocart-theme-from-design/SKILL.md +58 -0
  17. package/templates/default/.agents/skills/wocart-theme-from-design/references/inputs-and-rights.md +47 -0
  18. package/templates/default/.agents/skills/wocart-theme-from-design/references/layout-rtl-and-phone.md +36 -0
  19. package/templates/default/.agents/skills/wocart-theme-from-design/references/measure-the-design.md +60 -0
  20. package/templates/default/.agents/skills/wocart-theme-from-design/references/tokens-sections-content.md +103 -0
  21. package/templates/default/.agents/skills/wocart-theme-from-design/references/verify-and-report.md +102 -0
  22. package/templates/default/.agents/skills/wocart-theme-from-design/scripts/compare-design.cjs +230 -0
  23. package/templates/default/.agents/skills/wocart-theme-from-design/scripts/qa-pages.cjs +219 -0
  24. package/templates/default/.dev.vars.example +12 -0
  25. package/templates/default/AGENTS.md +240 -0
  26. package/templates/default/README.md +184 -0
  27. package/templates/default/_gitignore +11 -0
  28. package/templates/default/astro.config.mjs +85 -0
  29. package/templates/default/package.json +36 -0
  30. package/templates/default/public/fonts/OFL.txt +96 -0
  31. package/templates/default/public/fonts/alexandria-arabic.woff2 +0 -0
  32. package/templates/default/public/fonts/fraunces-latin.woff2 +0 -0
  33. package/templates/default/src/actions/index.ts +22 -0
  34. package/templates/default/src/components/cart/AddToCartButton.astro +45 -0
  35. package/templates/default/src/components/cart/CartDrawer.astro +47 -0
  36. package/templates/default/src/components/cart/CartSummary.astro +11 -0
  37. package/templates/default/src/components/cart/FreeShipping.astro +7 -0
  38. package/templates/default/src/components/checkout/CheckoutMain.astro +29 -0
  39. package/templates/default/src/components/checkout/OrderForm.astro +280 -0
  40. package/templates/default/src/components/checkout/ThankYouMain.astro +68 -0
  41. package/templates/default/src/components/landing/LandingImages.astro +51 -0
  42. package/templates/default/src/components/landing/LandingOrder.astro +46 -0
  43. package/templates/default/src/components/landing/LandingProduct.astro +41 -0
  44. package/templates/default/src/components/listing/ListingMain.astro +93 -0
  45. package/templates/default/src/components/listing/PageMain.astro +52 -0
  46. package/templates/default/src/components/listing/Pagination.astro +31 -0
  47. package/templates/default/src/components/listing/SortControl.astro +35 -0
  48. package/templates/default/src/components/product/BuyBox.astro +96 -0
  49. package/templates/default/src/components/product/Description.astro +24 -0
  50. package/templates/default/src/components/product/Gallery.astro +66 -0
  51. package/templates/default/src/components/product/MobileBuyBar.astro +29 -0
  52. package/templates/default/src/components/product/OfferChoice.astro +66 -0
  53. package/templates/default/src/components/product/ProductMain.astro +40 -0
  54. package/templates/default/src/components/product/ProductReviews.astro +72 -0
  55. package/templates/default/src/components/product/RelatedProducts.astro +30 -0
  56. package/templates/default/src/components/product/blocks/BenefitsBlock.astro +13 -0
  57. package/templates/default/src/components/product/blocks/CollapsibleBlock.astro +20 -0
  58. package/templates/default/src/components/product/blocks/DescriptionBlock.astro +19 -0
  59. package/templates/default/src/components/product/blocks/DetailsBlock.astro +33 -0
  60. package/templates/default/src/components/product/blocks/GalleryBlock.astro +12 -0
  61. package/templates/default/src/components/product/blocks/OrderBlock.astro +30 -0
  62. package/templates/default/src/components/product/blocks/PriceBlock.astro +23 -0
  63. package/templates/default/src/components/product/blocks/RatingBlock.astro +16 -0
  64. package/templates/default/src/components/product/blocks/StockBlock.astro +22 -0
  65. package/templates/default/src/components/product/blocks/TextBlock.astro +11 -0
  66. package/templates/default/src/components/product/blocks/TitleBlock.astro +20 -0
  67. package/templates/default/src/components/reviews/ReviewCard.astro +46 -0
  68. package/templates/default/src/components/reviews/ReviewForm.astro +113 -0
  69. package/templates/default/src/components/reviews/VoiceNote.astro +60 -0
  70. package/templates/default/src/components/sections/CollectionCards.astro +65 -0
  71. package/templates/default/src/components/sections/Countdown.astro +57 -0
  72. package/templates/default/src/components/sections/Faq.astro +44 -0
  73. package/templates/default/src/components/sections/FeaturedProduct.astro +71 -0
  74. package/templates/default/src/components/sections/Hero.astro +99 -0
  75. package/templates/default/src/components/sections/ImageBanner.astro +46 -0
  76. package/templates/default/src/components/sections/ProductGrid.astro +47 -0
  77. package/templates/default/src/components/sections/RichText.astro +35 -0
  78. package/templates/default/src/components/sections/Steps.astro +46 -0
  79. package/templates/default/src/components/sections/Testimonials.astro +57 -0
  80. package/templates/default/src/components/shell/Footer.astro +80 -0
  81. package/templates/default/src/components/shell/Header.astro +89 -0
  82. package/templates/default/src/components/shell/LanguageMenu.astro +33 -0
  83. package/templates/default/src/components/shell/MobileMenu.astro +65 -0
  84. package/templates/default/src/components/shell/SearchDialog.astro +19 -0
  85. package/templates/default/src/components/shell/TopBar.astro +54 -0
  86. package/templates/default/src/components/shell/WhatsAppWidget.astro +111 -0
  87. package/templates/default/src/components/store/ContactMain.astro +79 -0
  88. package/templates/default/src/components/store/SearchMain.astro +56 -0
  89. package/templates/default/src/components/store/TrackOrderMain.astro +161 -0
  90. package/templates/default/src/components/surface/Area.astro +20 -0
  91. package/templates/default/src/components/surface/PreviewBridge.astro +24 -0
  92. package/templates/default/src/components/surface/Sections.astro +35 -0
  93. package/templates/default/src/components/ui/Breadcrumbs.astro +36 -0
  94. package/templates/default/src/components/ui/Button.astro +45 -0
  95. package/templates/default/src/components/ui/EditorPlaceholder.astro +24 -0
  96. package/templates/default/src/components/ui/Icon.astro +93 -0
  97. package/templates/default/src/components/ui/Logo.astro +36 -0
  98. package/templates/default/src/components/ui/Photo.astro +46 -0
  99. package/templates/default/src/components/ui/Price.astro +24 -0
  100. package/templates/default/src/components/ui/ProductCard.astro +41 -0
  101. package/templates/default/src/components/ui/Rating.astro +22 -0
  102. package/templates/default/src/components/ui/Section.astro +34 -0
  103. package/templates/default/src/components/ui/SectionHeading.astro +19 -0
  104. package/templates/default/src/env.d.ts +23 -0
  105. package/templates/default/src/layouts/StoreLayout.astro +145 -0
  106. package/templates/default/src/lib/browser-copy.ts +37 -0
  107. package/templates/default/src/lib/context.ts +89 -0
  108. package/templates/default/src/lib/coupon-notice.ts +47 -0
  109. package/templates/default/src/lib/i18n.ts +32 -0
  110. package/templates/default/src/lib/images.ts +38 -0
  111. package/templates/default/src/lib/listing-query.ts +41 -0
  112. package/templates/default/src/lib/money.ts +16 -0
  113. package/templates/default/src/lib/motion.ts +16 -0
  114. package/templates/default/src/lib/nav.ts +26 -0
  115. package/templates/default/src/lib/offer-tiles.ts +105 -0
  116. package/templates/default/src/lib/order-outcome.ts +66 -0
  117. package/templates/default/src/lib/otp-message.ts +21 -0
  118. package/templates/default/src/lib/products.ts +38 -0
  119. package/templates/default/src/lib/review-refusals.ts +31 -0
  120. package/templates/default/src/lib/store.ts +31 -0
  121. package/templates/default/src/lib/whatsapp.ts +29 -0
  122. package/templates/default/src/middleware.ts +23 -0
  123. package/templates/default/src/pages/404.astro +22 -0
  124. package/templates/default/src/pages/api/abandoned/convert.ts +4 -0
  125. package/templates/default/src/pages/api/abandoned/upsert.ts +4 -0
  126. package/templates/default/src/pages/api/cart/validate.ts +4 -0
  127. package/templates/default/src/pages/api/communes/[wilayaId].ts +4 -0
  128. package/templates/default/src/pages/api/otp/send.ts +4 -0
  129. package/templates/default/src/pages/api/otp/verify.ts +4 -0
  130. package/templates/default/src/pages/api/reviews/[productId].ts +3 -0
  131. package/templates/default/src/pages/api/reviews/eligibility.ts +3 -0
  132. package/templates/default/src/pages/api/reviews/submit.ts +3 -0
  133. package/templates/default/src/pages/api/reviews/upload.ts +3 -0
  134. package/templates/default/src/pages/category/[slug].astro +20 -0
  135. package/templates/default/src/pages/checkout.astro +25 -0
  136. package/templates/default/src/pages/collections/[handle].astro +20 -0
  137. package/templates/default/src/pages/contact.astro +17 -0
  138. package/templates/default/src/pages/index.astro +9 -0
  139. package/templates/default/src/pages/lp/[slug].astro +47 -0
  140. package/templates/default/src/pages/pages/[slug].astro +16 -0
  141. package/templates/default/src/pages/products/[handle].astro +37 -0
  142. package/templates/default/src/pages/products/index.astro +15 -0
  143. package/templates/default/src/pages/robots.txt.ts +9 -0
  144. package/templates/default/src/pages/search.astro +19 -0
  145. package/templates/default/src/pages/sitemap.xml.ts +12 -0
  146. package/templates/default/src/pages/thank-you.astro +33 -0
  147. package/templates/default/src/pages/track-order.astro +17 -0
  148. package/templates/default/src/pages/wocart-preview.astro +43 -0
  149. package/templates/default/src/pages/wocart-revalidate.ts +10 -0
  150. package/templates/default/src/pages/wocart-styles.css.ts +5 -0
  151. package/templates/default/src/pages/wocart-theme.json.ts +5 -0
  152. package/templates/default/src/scripts/cart.ts +371 -0
  153. package/templates/default/src/scripts/checkout/coupon.ts +96 -0
  154. package/templates/default/src/scripts/checkout/delivery.ts +86 -0
  155. package/templates/default/src/scripts/checkout/form.ts +54 -0
  156. package/templates/default/src/scripts/checkout/otp.ts +106 -0
  157. package/templates/default/src/scripts/checkout/picker.ts +169 -0
  158. package/templates/default/src/scripts/checkout/quote.ts +169 -0
  159. package/templates/default/src/scripts/checkout/submit.ts +113 -0
  160. package/templates/default/src/scripts/checkout/tracking.ts +74 -0
  161. package/templates/default/src/scripts/countdown.ts +29 -0
  162. package/templates/default/src/scripts/events.ts +4 -0
  163. package/templates/default/src/scripts/hero.ts +49 -0
  164. package/templates/default/src/scripts/listing.ts +13 -0
  165. package/templates/default/src/scripts/order-form.ts +100 -0
  166. package/templates/default/src/scripts/product.ts +306 -0
  167. package/templates/default/src/scripts/public-config.ts +79 -0
  168. package/templates/default/src/scripts/reviews.ts +358 -0
  169. package/templates/default/src/scripts/site.ts +131 -0
  170. package/templates/default/src/scripts/thank-you.ts +11 -0
  171. package/templates/default/src/scripts/voice-note.ts +94 -0
  172. package/templates/default/src/styles/base.css +1030 -0
  173. package/templates/default/src/styles/checkout.css +1111 -0
  174. package/templates/default/src/styles/global.css +12 -0
  175. package/templates/default/src/styles/product.css +871 -0
  176. package/templates/default/src/styles/reviews.css +533 -0
  177. package/templates/default/src/styles/sections.css +931 -0
  178. package/templates/default/src/styles/shell.css +970 -0
  179. package/templates/default/src/styles/tokens.css +583 -0
  180. package/templates/default/src/theme/api-routes.ts +10 -0
  181. package/templates/default/src/theme/content/catalog.ts +117 -0
  182. package/templates/default/src/theme/content/checkout.ts +168 -0
  183. package/templates/default/src/theme/content/editor.ts +21 -0
  184. package/templates/default/src/theme/content/index.ts +45 -0
  185. package/templates/default/src/theme/content/reviews.ts +76 -0
  186. package/templates/default/src/theme/content/shell.ts +59 -0
  187. package/templates/default/src/theme/content/types.ts +12 -0
  188. package/templates/default/src/theme/documents/catalog.json +11 -0
  189. package/templates/default/src/theme/documents/category.json +11 -0
  190. package/templates/default/src/theme/documents/checkout.json +11 -0
  191. package/templates/default/src/theme/documents/collection.json +11 -0
  192. package/templates/default/src/theme/documents/contact.json +11 -0
  193. package/templates/default/src/theme/documents/footer.area.json +11 -0
  194. package/templates/default/src/theme/documents/header.area.json +16 -0
  195. package/templates/default/src/theme/documents/home.json +313 -0
  196. package/templates/default/src/theme/documents/landing.json +8 -0
  197. package/templates/default/src/theme/documents/page.json +11 -0
  198. package/templates/default/src/theme/documents/product.json +125 -0
  199. package/templates/default/src/theme/documents/search.json +11 -0
  200. package/templates/default/src/theme/documents/thank-you.json +11 -0
  201. package/templates/default/src/theme/documents/track-order.json +11 -0
  202. package/templates/default/src/theme/fields.ts +61 -0
  203. package/templates/default/src/theme/key.ts +11 -0
  204. package/templates/default/src/theme/labels.ts +231 -0
  205. package/templates/default/src/theme/locales.ts +11 -0
  206. package/templates/default/src/theme/palette.ts +14 -0
  207. package/templates/default/src/theme/sections/collection-cards.ts +65 -0
  208. package/templates/default/src/theme/sections/faq.ts +74 -0
  209. package/templates/default/src/theme/sections/featured-product.ts +42 -0
  210. package/templates/default/src/theme/sections/hero.ts +47 -0
  211. package/templates/default/src/theme/sections/image-banner.ts +25 -0
  212. package/templates/default/src/theme/sections/index.ts +40 -0
  213. package/templates/default/src/theme/sections/landing.ts +150 -0
  214. package/templates/default/src/theme/sections/listing.ts +84 -0
  215. package/templates/default/src/theme/sections/product-grid.ts +42 -0
  216. package/templates/default/src/theme/sections/product.ts +297 -0
  217. package/templates/default/src/theme/sections/rich-text.ts +39 -0
  218. package/templates/default/src/theme/sections/shared.ts +54 -0
  219. package/templates/default/src/theme/sections/shell.ts +85 -0
  220. package/templates/default/src/theme/sections/store-pages.ts +101 -0
  221. package/templates/default/src/theme/sections/testimonials.ts +61 -0
  222. package/templates/default/src/theme/sections/thank-you.ts +35 -0
  223. package/templates/default/src/theme/settings.ts +124 -0
  224. package/templates/default/src/theme/theme.ts +65 -0
  225. package/templates/default/tests/fixtures/canvas-tote.json +62 -0
  226. package/templates/default/tests/fixtures/linen-shirt.json +128 -0
  227. package/templates/default/tests/unit/checkout.test.ts +241 -0
  228. package/templates/default/tests/unit/contract.test.ts +169 -0
  229. package/templates/default/tests/unit/contrast.test.ts +68 -0
  230. package/templates/default/tests/unit/copy.test.ts +101 -0
  231. package/templates/default/tests/unit/design-values.test.ts +95 -0
  232. package/templates/default/tests/unit/editability.test.ts +180 -0
  233. package/templates/default/tests/unit/fixtures.ts +91 -0
  234. package/templates/default/tests/unit/footer.test.ts +54 -0
  235. package/templates/default/tests/unit/guards.test.ts +340 -0
  236. package/templates/default/tests/unit/images.test.ts +26 -0
  237. package/templates/default/tests/unit/landing.test.ts +151 -0
  238. package/templates/default/tests/unit/languages.test.ts +42 -0
  239. package/templates/default/tests/unit/middleware.test.ts +53 -0
  240. package/templates/default/tests/unit/offer-tiles.test.ts +75 -0
  241. package/templates/default/tests/unit/render.ts +38 -0
  242. package/templates/default/tests/unit/reviews.test.ts +25 -0
  243. package/templates/default/tests/unit/rules.test.ts +59 -0
  244. package/templates/default/tests/unit/source.ts +75 -0
  245. package/templates/default/tests/unit/store-pages.test.ts +147 -0
  246. package/templates/default/tests/unit/studio.test.ts +202 -0
  247. package/templates/default/tests/unit/testimonials.test.ts +52 -0
  248. package/templates/default/tests/unit/thank-you.test.ts +52 -0
  249. package/templates/default/tests/unit/tracking.test.ts +29 -0
  250. package/templates/default/tests/unit/voice-note.test.ts +42 -0
  251. package/templates/default/tsconfig.json +13 -0
  252. package/templates/default/vitest.config.ts +15 -0
  253. package/templates/default/wrangler.jsonc +17 -0
@@ -0,0 +1,219 @@
1
+ /**
2
+ * Page QA for a running theme: every page the store links to, at a desktop
3
+ * width and at a phone width, in one language. It reports what the eye can
4
+ * miss in a screenshot and what a check can name:
5
+ *
6
+ * overflow an element wider than the viewport (outside a swipe row)
7
+ * broken an image that did not load
8
+ * keys a translation key printed as text
9
+ * errors a console error or an uncaught exception
10
+ * contrast text below WCAG AA on the surface it is read from
11
+ * partial-row a grid whose last row leaves empty columns (a warning)
12
+ *
13
+ * Usage (Node 20+, Playwright installed where Node can find it):
14
+ * BASE=http://localhost:4321 LANG_CODE=ar node qa-pages.cjs
15
+ * FRAMES=1 … also save a viewport-sized frame per scroll step
16
+ * CHROME=/path/to/chrome optional: a Chromium binary to launch
17
+ * PLAYWRIGHT=/path/to/playwright optional: where to load Playwright from
18
+ * Exit status 1 when a page has an overflow, a broken image, a leaked key,
19
+ * a console error or a contrast failure. Warnings never fail the run.
20
+ */
21
+ const fs = require("fs");
22
+ const path = require("path");
23
+ const { chromium } = require(process.env.PLAYWRIGHT || "playwright");
24
+
25
+ const BASE = (process.env.BASE || "http://localhost:4321").replace(/\/$/, "");
26
+ const LANG = process.env.LANG_CODE || "ar";
27
+ const OUT = process.env.OUT || path.join(process.cwd(), "qa-out");
28
+ const FRAMES = process.env.FRAMES === "1";
29
+ const VIEWPORTS = {
30
+ desktop: { viewport: { width: 1440, height: 900 } },
31
+ phone: { viewport: { width: 390, height: 844 }, isMobile: true, hasTouch: true },
32
+ };
33
+
34
+ /** Pages to visit: the fixed ones, then the first few the home page links to. */
35
+ async function languagePrefix(page) {
36
+ await page.goto(`${BASE}/`, { waitUntil: "networkidle" });
37
+ const root = await page.getAttribute("html", "lang");
38
+ return root === LANG ? "" : `/${LANG}`;
39
+ }
40
+
41
+ async function discoverRoutes(page, prefix) {
42
+ await page.goto(`${BASE}${prefix}/`, { waitUntil: "networkidle" });
43
+ const links = await page.$$eval("a[href]", (as) => [...new Set(as.map((a) => a.getAttribute("href")))]);
44
+ const internal = [...new Set(links.filter((h) => h && h.startsWith("/")).map((h) => h.split(/[?#]/)[0]))];
45
+ const pick = (needle, count) => internal.filter((h) => h.includes(needle)).slice(0, count);
46
+ const strip = (href) => href.replace(/^\/(ar|fr|en)(?=\/|$)/, "").replace(/^\//, "");
47
+ const routes = [
48
+ "",
49
+ ...pick("/products/", 2).map(strip),
50
+ ...pick("/collections/", 1).map(strip),
51
+ ...pick("/pages/", 1).map(strip),
52
+ "products",
53
+ "search?q=a",
54
+ "contact",
55
+ "track-order",
56
+ "checkout",
57
+ "this-page-does-not-exist",
58
+ ];
59
+ return [...new Set(routes)];
60
+ }
61
+
62
+ /** The page's own checks, run inside the page. */
63
+ const AUDIT = () => {
64
+ const vw = window.innerWidth;
65
+ const visible = (el) => {
66
+ const r = el.getBoundingClientRect();
67
+ if (r.width === 0 || r.height === 0) return null;
68
+ const cs = getComputedStyle(el);
69
+ if (cs.display === "none" || cs.visibility === "hidden") return null;
70
+ return { r, cs };
71
+ };
72
+ const clippedByAncestor = (el) => {
73
+ for (let p = el.parentElement; p && p !== document.body; p = p.parentElement) {
74
+ const pc = getComputedStyle(p);
75
+ if (pc.overflowX !== "visible" && pc.overflow !== "visible") {
76
+ const pr = p.getBoundingClientRect();
77
+ if (pr.right <= vw + 1 && pr.left >= -1) return true;
78
+ }
79
+ }
80
+ return false;
81
+ };
82
+ const overflow = [];
83
+ for (const el of document.querySelectorAll("body *")) {
84
+ const v = visible(el);
85
+ if (!v || (v.r.right <= vw + 1 && v.r.left >= -1)) continue;
86
+ if (!clippedByAncestor(el)) overflow.push(`${el.tagName.toLowerCase()}.${String(el.className).split(" ")[0]} ${Math.round(v.r.left)}..${Math.round(v.r.right)}`);
87
+ }
88
+
89
+ const broken = [...document.images].filter((img) => img.complete && img.naturalWidth === 0 && img.getAttribute("src")).map((img) => img.getAttribute("src").slice(0, 90));
90
+
91
+ const keys = (document.body.innerText.match(/\b[a-z]{3,}\.[a-z][A-Za-z]{2,}\b/g) || []).filter((k) => /^(cart|checkout|product|order|common|nav|footer|home|search|contact|track|header|offer|reviews|theme|store)\./.test(k));
92
+
93
+ const parse = (c) => {
94
+ const m = c.match(/rgba?\(([^)]+)\)/);
95
+ if (!m) return null;
96
+ const p = m[1].split(/[ ,/]+/).filter(Boolean).map(Number);
97
+ return { r: p[0], g: p[1], b: p[2], a: p.length > 3 ? p[3] : 1 };
98
+ };
99
+ const luminance = ({ r, g, b }) => {
100
+ const f = (v) => { v /= 255; return v <= 0.03928 ? v / 12.92 : ((v + 0.055) / 1.055) ** 2.4; };
101
+ return 0.2126 * f(r) + 0.7152 * f(g) + 0.0722 * f(b);
102
+ };
103
+ const over = (top, bottom) => ({ r: top.r * top.a + bottom.r * (1 - top.a), g: top.g * top.a + bottom.g * (1 - top.a), b: top.b * top.a + bottom.b * (1 - top.a), a: 1 });
104
+ const surface = (el) => {
105
+ const layers = [];
106
+ let photo = false;
107
+ for (let n = el; n; n = n.parentElement) {
108
+ const cs = getComputedStyle(n);
109
+ if (cs.backgroundImage !== "none" || (n.querySelector && n.querySelector(":scope > img, :scope > picture"))) photo = true;
110
+ const c = parse(cs.backgroundColor);
111
+ if (c && c.a > 0) { layers.push(c); if (c.a >= 1) break; }
112
+ }
113
+ let base = { r: 255, g: 255, b: 255, a: 1 };
114
+ for (let i = layers.length - 1; i >= 0; i--) base = over(layers[i], base);
115
+ return { base, photo };
116
+ };
117
+ const contrast = [];
118
+ const walker = document.createTreeWalker(document.body, NodeFilter.SHOW_TEXT);
119
+ for (let node = walker.nextNode(); node; node = walker.nextNode()) {
120
+ if (node.textContent.trim().length < 2) continue;
121
+ const el = node.parentElement;
122
+ if (!el || ["SCRIPT", "STYLE", "NOSCRIPT"].includes(el.tagName)) continue;
123
+ const v = visible(el);
124
+ if (!v) continue;
125
+ let opacity = 1;
126
+ for (let n = el; n; n = n.parentElement) opacity *= parseFloat(getComputedStyle(n).opacity);
127
+ if (opacity < 0.99) continue;
128
+ const fg0 = parse(v.cs.color);
129
+ if (!fg0) continue;
130
+ const { base, photo } = surface(el);
131
+ const fg = over(fg0, base);
132
+ const [hi, lo] = [luminance(fg), luminance(base)].sort((a, b) => b - a);
133
+ const ratio = (hi + 0.05) / (lo + 0.05);
134
+ const size = parseFloat(v.cs.fontSize);
135
+ const large = size >= 24 || (size >= 18.66 && parseInt(v.cs.fontWeight, 10) >= 700);
136
+ const need = large ? 3 : 4.5;
137
+ if (ratio < need) contrast.push({ ratio: Math.round(ratio * 100) / 100, need, photo, text: node.textContent.trim().slice(0, 40), cls: String(el.className).split(" ")[0] || el.tagName.toLowerCase() });
138
+ }
139
+
140
+ const partialRows = [];
141
+ for (const grid of document.querySelectorAll("[class*='grid'], [class*='cards'], [class*='testimonials']")) {
142
+ const cs = getComputedStyle(grid);
143
+ if (cs.display !== "grid") continue;
144
+ const kids = [...grid.children].filter((k) => visible(k));
145
+ if (kids.length < 2) continue;
146
+ const rows = new Map();
147
+ for (const k of kids) { const top = Math.round(k.getBoundingClientRect().top); rows.set(top, (rows.get(top) || 0) + 1); }
148
+ const perRow = Math.max(...rows.values());
149
+ const last = rows.get([...rows.keys()].sort((a, b) => b - a)[0]);
150
+ if (rows.size > 1 && last < perRow && cs.gridTemplateColumns.split(" ").length === perRow) {
151
+ partialRows.push(`${grid.className.split(" ")[0]} last row ${last} of ${perRow}`);
152
+ }
153
+ }
154
+ return { scrollWidth: document.documentElement.scrollWidth, innerWidth: vw, overflow: overflow.slice(0, 8), overflowCount: overflow.length, broken: broken.slice(0, 5), keys: keys.slice(0, 5), contrast, partialRows };
155
+ };
156
+
157
+ (async () => {
158
+ fs.mkdirSync(OUT, { recursive: true });
159
+ const launch = process.env.CHROME ? { executablePath: process.env.CHROME } : {};
160
+ const browser = await chromium.launch(launch);
161
+ const probe = await browser.newPage();
162
+ const prefix = await languagePrefix(probe);
163
+ const routes = await discoverRoutes(probe, prefix);
164
+ await probe.close();
165
+ const failures = [];
166
+ const warnings = [];
167
+ for (const [vpName, vpOpts] of Object.entries(VIEWPORTS)) {
168
+ const context = await browser.newContext({ ...vpOpts, locale: LANG === "ar" ? "ar-DZ" : LANG === "fr" ? "fr-DZ" : "en-US" });
169
+ for (const route of routes) {
170
+ const page = await context.newPage();
171
+ const errors = [];
172
+ page.on("console", (m) => { if (m.type() === "error") errors.push(m.text()); });
173
+ page.on("pageerror", (e) => errors.push(`uncaught ${e.message}`));
174
+ const url = `${BASE}${prefix}/${route}`.replace(/\/$/, "");
175
+ const label = `${LANG} ${vpName} /${route}`;
176
+ try {
177
+ await page.goto(url, { waitUntil: "networkidle", timeout: 45000 });
178
+ await page.evaluate(async () => {
179
+ for (let y = 0; y < document.body.scrollHeight; y += 500) { window.scrollTo(0, y); await new Promise((r) => setTimeout(r, 40)); }
180
+ window.scrollTo(0, 0);
181
+ });
182
+ await page.waitForTimeout(900);
183
+ const info = await page.evaluate(AUDIT);
184
+ const realErrors = errors.filter((e) => !/status of 404/.test(e) || !route.includes("this-page-does-not-exist"));
185
+ if (info.horizontalScroll || info.scrollWidth > info.innerWidth) failures.push(`${label}: wider than the viewport (${info.scrollWidth}px)`);
186
+ if (info.overflowCount) failures.push(`${label}: ${info.overflowCount} overflow, e.g. ${info.overflow.slice(0, 2).join("; ")}`);
187
+ if (info.broken.length) failures.push(`${label}: broken images ${info.broken.join(", ")}`);
188
+ if (info.keys.length) failures.push(`${label}: translation keys printed ${info.keys.join(", ")}`);
189
+ if (realErrors.length) failures.push(`${label}: console errors ${realErrors.slice(0, 2).join(" | ").slice(0, 180)}`);
190
+ for (const c of info.contrast) {
191
+ const line = `${label}: text "${c.text}" ${c.ratio}:1 (needs ${c.need}) on ${c.cls}${c.photo ? " over a photo, check by eye" : ""}`;
192
+ (c.photo ? warnings : failures).push(line);
193
+ }
194
+ for (const row of info.partialRows) warnings.push(`${label}: ${row}`);
195
+ if (FRAMES) {
196
+ const dir = path.join(OUT, `${LANG}-${vpName}-${(route || "home").replace(/[^a-z0-9]+/gi, "_")}`);
197
+ fs.mkdirSync(dir, { recursive: true });
198
+ const h = vpOpts.viewport.height;
199
+ const total = await page.evaluate(() => document.documentElement.scrollHeight);
200
+ for (let y = 0, i = 0; y < total && i < 14; y += h - 80, i++) {
201
+ await page.evaluate((yy) => window.scrollTo(0, yy), y);
202
+ await page.waitForTimeout(700);
203
+ await page.screenshot({ path: path.join(dir, `${String(i).padStart(2, "0")}.png`) });
204
+ }
205
+ }
206
+ } catch (e) {
207
+ failures.push(`${label}: did not load (${e.message.split("\n")[0].slice(0, 120)})`);
208
+ }
209
+ await page.close();
210
+ }
211
+ await context.close();
212
+ }
213
+ await browser.close();
214
+ console.log(`routes: ${routes.map((r) => "/" + r).join(" ")}`);
215
+ console.log(`page-viewports: ${routes.length * Object.keys(VIEWPORTS).length}`);
216
+ console.log(`warnings (${warnings.length}):`); warnings.forEach((w) => console.log(" " + w));
217
+ console.log(`failures (${failures.length}):`); failures.forEach((f) => console.log(" " + f));
218
+ process.exit(failures.length ? 1 : 0);
219
+ })().catch((e) => { console.error("QA could not run:", e.message); process.exit(2); });
@@ -0,0 +1,12 @@
1
+ # Local secrets for `npm run dev` and `npm run preview`.
2
+ # Copy this file to .dev.vars and fill it in. .dev.vars is never committed.
3
+
4
+ # Your store's API: http://localhost:8787 for a store running on this machine.
5
+ COD_SERVER_URL=http://localhost:8787
6
+
7
+ # Your store's API key, from the store's dashboard (or your local store's seed).
8
+ STORE_API_KEY=your-store-api-key
9
+
10
+ # Optional: the editor's preview public key, an Ed25519 JWK on one line.
11
+ # Unset: /wocart-preview and /wocart-revalidate answer 404.
12
+ # WOCART_PREVIEW_KEY=
@@ -0,0 +1,240 @@
1
+ # Instructions for coding agents
2
+
3
+ This is a Wocart storefront theme: an Astro project on `@abcart/storefront`
4
+ (the store's data and commerce rules) and `@abcart/theme` (the contract Wocart
5
+ Studio edits). It sells cash on delivery in Algeria, in Arabic (right to left,
6
+ the default), French and English. Read this file before changing anything.
7
+
8
+ ## Skills
9
+
10
+ Three skills ship with the theme, in `.agents/skills/`. Start from the row
11
+ that matches the request:
12
+
13
+ | The request | Start with |
14
+ | --- | --- |
15
+ | Build or restyle a theme that must match a design: a screenshot or image, a live website URL, or a Shopify theme measured with the collector | **`wocart-theme-from-design`**: the route from the empty folder to a home page on a store, its design as tokens, its sections, content and claims, its layout and phone patterns, and the measured match to the design. Its steps are in its references folder |
16
+ | Collect a Shopify theme's public frontend to measure it | **`shopify-theme-asset-collector`**: finds the demo storefront and saves its pages, styles, scripts, images and fonts, with a manifest of the sections. Its output is for measuring, never for shipping |
17
+ | Any SDK name, field, platform behaviour, or a failing check | **`wocart-docs`**: find the answer in this theme's code, the installed declarations and the documentation. Never guess |
18
+
19
+ A whole theme can be built unattended: give the agent the brief that `wocart-theme-from-design` asks for in one message, and it runs to the end, committing after each gate and finishing with its report.
20
+
21
+ ## What it is made of
22
+
23
+ | Where | What |
24
+ | --- | --- |
25
+ | `src/theme/theme.ts` | The theme: 12 pages (surfaces), the header and footer (areas), settings, every section. What Studio reads (`/wocart-theme.json`) |
26
+ | `src/theme/sections/*.ts` | One definition per section or family: its fields, its data (`load`), its presets |
27
+ | `src/theme/documents/*.json` | The layout each page starts with, before a merchant edits it |
28
+ | `src/theme/content/*.ts` | Every word the shopper reads, ar/fr/en side by side, by area |
29
+ | `src/theme/labels.ts` | What Studio calls each page, section, field and option |
30
+ | `src/theme/palette.ts` | The starter's colors, written once: the only literal colors in the theme's code (with `tokens.css`) |
31
+ | `src/theme/settings.ts` | Store-wide settings: color schemes, corners, product cards, promises, social links |
32
+ | `src/theme/key.ts`, `locales.ts` | The theme's permanent key and version; its languages |
33
+ | `src/components/` | Presentation. A section renders through `src/components/ui/Section.astro`; product blocks live in `src/components/product/blocks/` |
34
+ | `src/pages/` | Thin routes: read the resource, `return notFound(Astro)` when missing, render the surface with `src/components/surface/Sections.astro` |
35
+ | `src/lib/` | Server-side glue, no business rules. `store.ts` is the only file that creates an SDK client |
36
+ | `src/scripts/` | Everything the browser runs. `order-form.ts` binds each order form and wires its parts in `src/scripts/checkout/`: `delivery`, `quote`, `coupon`, `otp`, `submit`, `tracking` |
37
+ | `src/styles/` | `tokens.css` is the design system; the other files style areas from its tokens |
38
+ | `src/middleware.ts`, `src/actions/` | Wiring only: `createStorefrontMiddleware` decides the store, the language, redirects, the preview and the order |
39
+ | `tests/` | Contract, guard, Studio, checkout and copy tests |
40
+ | `.agents/skills/` | The three skills above, each with its own references and scripts |
41
+
42
+ ## Commands
43
+
44
+ ```sh
45
+ npm install
46
+ npm run dev # http://localhost:4321, needs .dev.vars (see .dev.vars.example)
47
+ npm run check # astro check: 0 errors, 0 warnings
48
+ npm test # contract, guard, Studio, checkout and copy tests
49
+ npm run build # Cloudflare Workers build
50
+ npm run build:vercel # Vercel build
51
+ ```
52
+
53
+ **Definition of done:** `npm run check`, `npm test`, `npm run build` and
54
+ `npm run build:vercel` pass, and every page you touched was looked at on a
55
+ phone (390 px) and a desktop, in Arabic and in one left-to-right language.
56
+
57
+ ## Restyling this theme
58
+
59
+ The look is made of tokens, fonts and colour schemes, so one file restyles the
60
+ store and the theme can take any brand.
61
+
62
+ **Change freely:**
63
+ - `src/styles/tokens.css`: every design value (type, motion, shapes, borders,
64
+ surfaces, corners, shadows) and the right-to-left values for Arabic.
65
+ - The fonts in `public/fonts/`: one Arabic and one Latin family, each limited to
66
+ its script. A new file needs its `@font-face` rule in `tokens.css`, its
67
+ preload in `src/layouts/StoreLayout.astro` and its licence line in
68
+ `public/fonts/OFL.txt`; a test checks all three.
69
+ - The starter's colours in `src/theme/palette.ts`, and the default colour schemes
70
+ in `src/theme/settings.ts` that use them.
71
+ - The layout rules in the stylesheets, and the markup of presentational
72
+ components.
73
+
74
+ **Keep working:**
75
+ - **No design value is a literal.** Every size, line height, letter-spacing,
76
+ weight, colour, radius, shadow, border, surface, filter, aspect ratio, motion
77
+ and opacity is a token (`var(--…)`). A colour inside a rule, in `tokens.css`
78
+ or in `palette.ts` only. Layout geometry (gaps, padding, margins, widths,
79
+ insets, grids, z-index) stays in the stylesheets. `design-values.test.ts`
80
+ names each literal that breaks this.
81
+ - **Token names say where they are used:** `--<category>-<role>` with an
82
+ optional `-narrow`, `-wide`, `-touch` or `-reduced`. A phone rule is always
83
+ `-narrow`, never `-phone`, and a name never ends in a number: a second value for
84
+ a role gets a role name. Search before you add one. A name is never reused for
85
+ another value.
86
+ - **Text is readable on its band:** every colour scheme keeps its text, headings
87
+ and accents at WCAG AA (4.5:1) on its background, and its button words on its
88
+ button. A light band takes dark ink: white words on sand are 2.3:1. `contrast.test.ts`
89
+ names each failing pair, and the offer ribbon's words are checked on its fill.
90
+ - **Names keep their own direction:** a reviewer's or customer's name carries
91
+ `dir="auto"`, so a Latin name's full stop stays after it. `rules.test.ts` checks it.
92
+ - **Card rows fill their row:** a grid of cards uses
93
+ `repeat(auto-fit, minmax(min(100%, 340px), 1fr))`, not a fixed column count. Two
94
+ cards in a three-column grid then fill the row, and six make two even rows.
95
+ - **A confirmation never covers a drawer:** the add-to-cart confirmation shows only
96
+ when no cart drawer opens with it. `rules.test.ts` checks it.
97
+ - **Colour-dependent tokens** (one that reads a colour of the scheme) live in the
98
+ `:root, .wc-scheme` block, so they resolve on each section that sets a scheme.
99
+ - **Timings:** a script reads each timing from a motion token through
100
+ `motionMs()` in `src/lib/motion.ts`. A behaviour timer (a debounce, a clock
101
+ tick) stays literal, and the guard names it.
102
+ - **Inline styles carry data only**: an index, a merchant's value, never a
103
+ design number.
104
+ - **Colours a merchant picks:** `.wc-scheme` derives the tokens from
105
+ `--wc-color-*`; an element wearing a scheme carries `schemeClass(id)` only.
106
+ - **Every part is editable through the SDK:** each field reaches the component
107
+ that renders it (or its `load`); every select says what its options mean; every
108
+ number is bounded; every list has a bound and a title per item; every label and
109
+ help text is in each language. Every insertable section starts from a preset, or
110
+ `NO_PRESET` in `editability.test.ts` says why it does not. A preset is rendered
111
+ for a shopper and in the editor's preview in every language. Use the SDK's
112
+ validators (`validateThemeDefinition`, `validateThemeManifest`, `validatePageData`)
113
+ as they are. Never invent a field kind or a rule the SDK does not have.
114
+ - **Help where a choice is not obvious:** `HELP` in `labels.ts`, shown as a field's
115
+ `description`. A field that depends on another is hidden with `visibleIf`.
116
+ - **Right to left:** logical properties (`margin-inline-start`,
117
+ `inset-inline-end`), never `left` or `right` for layout, except in a rule that
118
+ names one direction or the WhatsApp widget's side (a test checks it).
119
+ Directional icons carry `icon-directional`. Phone and order numbers stay left
120
+ to right.
121
+ - **Layouts that mirror:** a split section is a two-column grid with the photo
122
+ first; text on a photo sits in its own panel; a grid that replaces a flex row
123
+ sets its own `justify-content`.
124
+ - **What scripts and forms rely on:** every `name="…"` in the order form, every
125
+ `data-*` attribute a script reads, the `#order` anchor, and the form's `action`.
126
+ - **Text:** never write visible words in markup; use the copy files.
127
+ - **Studio:** never remove `Sections.astro`, `Area.astro` or `PreviewBridge.astro`.
128
+ Keep `class` and `style` from a section's props on its outer element, through
129
+ `Section.astro`.
130
+
131
+ ## Rules
132
+
133
+ **Both hosts, every feature.** The theme builds for Cloudflare Workers and
134
+ for Vercel (`DEPLOY_TARGET` in `astro.config.mjs`), so Wocart Cloud can deploy
135
+ it wherever a merchant chooses, and it supports every feature the platform
136
+ has (reviews, the basket, the phone check, codes…), each shown only when the
137
+ store turns it on. Never remove a host or a feature; a test checks the hosts.
138
+
139
+ **The platform is the SDK's.** Import `@wocart/*` through published entry
140
+ points only. Prices, offers, delivery fees, coupons, stock and order validity
141
+ are the server's: show what the SDK and the server's quote say, never compute
142
+ them. A missing capability is an SDK change, never a second implementation
143
+ here.
144
+
145
+ **One client per request.** Only `src/lib/store.ts` creates an SDK client;
146
+ everything else reads `Astro.locals.store.client`. The API key never reaches
147
+ browser code.
148
+
149
+ **No validator in the browser.** Browser code never imports Zod or a schema.
150
+ From `@abcart/theme` it takes only `./lifecycle` and `./messages`.
151
+
152
+ **Sections read data in `load`, never in the component.** A definition's
153
+ `load` reads through `reads.get(key, …)` so sections share one read per page.
154
+ A section reads its page's product or landing page through `routeProduct` /
155
+ `routeLanding` (`src/theme/sections/shared.ts`).
156
+
157
+ **Every section is editable the same way.** A `scheme` field
158
+ (`schemeField()`), a `style` field
159
+ (`styleField()`), rendered through `Section.astro`; a test checks that every
160
+ section has both. A photo a merchant picks
161
+ is an `image` field, never a `url`; prose is `richtext`. A section with
162
+ nothing to show renders nothing for a shopper and an `EditorPlaceholder` in
163
+ Studio (`isPreview(blocks)`).
164
+
165
+ **The style classes win.** Never set padding or width on what a `style` field
166
+ controls.
167
+
168
+ **Every behaviour survives the preview.** Browser scripts bind with
169
+ `bindEach()` / `onEachPage()` from `@abcart/theme/lifecycle`, so Studio can
170
+ swap a section and the script binds the new markup once.
171
+
172
+ **The browser asks through the SDK.** The order form quotes with
173
+ `createQuoter`, tracks an unfinished checkout with
174
+ `createBrowserAbandonedCheckoutTracker`, and the review form runs a
175
+ `createReviewSession`. Their paths are the SDK's `STOREFRONT_API_PATHS`
176
+ (`storefrontApiPath` fills a parameter), each mounted by a one-line file
177
+ under `src/pages/api/`; a test checks both ways and that no other file
178
+ writes an `/api/` path.
179
+
180
+ **Words come from the copy.** Every key exists in ar, fr and en; a count is a
181
+ plural message with each language's CLDR forms (Arabic has six); no key that
182
+ nothing reads. The browser gets only the keys listed in
183
+ `src/lib/browser-copy.ts`.
184
+
185
+ **The theme states no fact about a store.** Delivery reach, delivery or
186
+ exchange periods, guarantees, percentages, opening hours, phone calls,
187
+ prices, phone numbers and addresses are the store's: they come from its data
188
+ (the catalog, its contact details, the order form's quote) or from a field
189
+ the merchant fills in. Copy, section defaults, presets, settings and page
190
+ documents say only what is true of every store; a test checks them.
191
+
192
+ **A store that cannot be read still renders.** The middleware falls back to
193
+ the SDK's `unavailableStoreConfig`, in this one place.
194
+
195
+ **Links go through the SDK.** Platform pages are `storefrontPath()` +
196
+ `localizeHref()`; a shopper on `/fr/…` stays in French. A landing page
197
+ (`/lp/…`) is the exception: one campaign in the store's primary language,
198
+ so it has no language prefix, menu or alternate links: the SDK redirects
199
+ `/fr/lp/…` and its `isSingleLanguagePage` empties the language menu
200
+ (`pageLanguages` in `src/lib/context.ts`).
201
+
202
+ **A not-found is never cached.** Return `notFound(Astro)`.
203
+
204
+ **Every cached page carries the `pages` tag** in `astro.config.mjs`
205
+ `routeRules`, as `PAGES_CACHE_TAG` (never the literal), so a Studio publish
206
+ shows at once; `src/pages/wocart-revalidate.ts` is the SDK's
207
+ `revalidateEndpoint`.
208
+
209
+ **The WhatsApp widget is the merchant's.** Every WhatsApp link comes from
210
+ `storeWhatsApp` (`src/lib/whatsapp.ts`); no file writes a `wa.me` link.
211
+
212
+ **The theme key is permanent.** `THEME_KEY` names every merchant's saved
213
+ edits; never change it once a store uses the theme. `THEME_VERSION` equals
214
+ `package.json` `version`; a change that removes a section, a field or a copy
215
+ key merchants may have edited needs a new major version.
216
+
217
+ ## Testing
218
+
219
+ - `tests/unit/contract.test.ts` renders every page and area through the SDK's
220
+ renderer, for a shopper and in Studio's preview, from store answers in
221
+ `tests/fixtures/`.
222
+ - `tests/unit/guards.test.ts` enforces the rules above on the source
223
+ (`tests/unit/source.ts` is the one walker every guard reads).
224
+ - `tests/unit/design-values.test.ts` enforces the token rules: no literal design
225
+ value in a stylesheet, no literal timing in a script, data-only inline styles,
226
+ and colour-dependent tokens on the scheme.
227
+ - `tests/unit/studio.test.ts` checks the manifest, the preview and the publish
228
+ revalidation with real Ed25519 keys, and that every composed route is cached.
229
+ - `tests/unit/checkout.test.ts` maps order outcomes and checks the order form's
230
+ delivery fields against the store's checkout settings.
231
+ - `tests/unit/copy.test.ts` checks every key in every language, the plural forms,
232
+ no unused key, no store fact, and the browser's key list.
233
+ - `tests/unit/footer.test.ts` checks that the logo, social links and contact
234
+ details come from the store's settings.
235
+ - `tests/unit/middleware.test.ts` checks the SDK's middleware, wired to this
236
+ store: a 404 keeps the shopper's language.
237
+ - `tests/unit/languages.test.ts` checks that landing pages are single-language.
238
+
239
+ A new rule gets a guard, and a guard is proven by breaking the code once and
240
+ watching it fail.
@@ -0,0 +1,184 @@
1
+ # My Theme
2
+
3
+ A Wocart storefront theme: an Astro project for a store that sells cash on
4
+ delivery. It reads the store through
5
+ [`@abcart/storefront`](https://docs.wocart.store/sdk/storefront) and describes
6
+ itself to Wocart Studio through [`@abcart/theme`](https://docs.wocart.store/sdk/theme).
7
+ It is plain on purpose: its look is tokens, fonts and colour schemes, so it
8
+ takes any brand. It speaks Arabic (right to left, the default), French and English.
9
+
10
+ **Built on** `@abcart/storefront` 4.7.0 and `@abcart/theme` 4.3.0. **Needs** a
11
+ Wocart store on platform v9.0.0 or newer.
12
+
13
+ ## Requirements
14
+
15
+ - Node.js 22.12 or newer.
16
+ - A Wocart store to read: its API address and a store API key. A self-hosted
17
+ Wocart gives you both, and so does a Wocart Cloud store. Without a reachable
18
+ store, every page renders as the SDK's unavailable store
19
+ (`unavailableStoreConfig`): the layout and the words, with nothing to buy.
20
+
21
+ ## First run
22
+
23
+ ```sh
24
+ npm install
25
+ cp .dev.vars.example .dev.vars # set COD_SERVER_URL and STORE_API_KEY
26
+ npm run dev # http://localhost:4321
27
+ npm test
28
+ ```
29
+
30
+ ## Environment variables
31
+
32
+ | Name | Required | Local value | In production |
33
+ | --- | --- | --- | --- |
34
+ | `COD_SERVER_URL` | yes | `http://localhost:8787` for a store on this machine | The store's API address |
35
+ | `STORE_API_KEY` | yes | Your store's key | A secret on your host |
36
+ | `WOCART_PREVIEW_KEY` | no | Unset | Studio's Ed25519 public key (a JWK on one line). Unset, `/wocart-preview` and `/wocart-revalidate` answer 404 |
37
+
38
+ Locally they go in `.dev.vars`, which is never committed. In production they
39
+ are the host's secrets. The API key stays on the server.
40
+
41
+ ## Project map
42
+
43
+ ```
44
+ src/
45
+ theme/ what Studio reads
46
+ theme.ts the theme: pages, header and footer, settings, sections
47
+ key.ts the permanent theme key and the version
48
+ sections/ one definition per section: fields, data (load), presets
49
+ documents/ the layout each page starts with
50
+ content/ every word a shopper reads, in ar, fr and en
51
+ labels.ts what Studio calls each page, section, field and option
52
+ palette.ts the starter's colours, written once
53
+ settings.ts store-wide settings and the default colour schemes
54
+ components/ presentation; surface/ renders a page's sections
55
+ pages/ thin routes, plus the manifest, preview and revalidate routes
56
+ layouts/ StoreLayout.astro: the document head, header, footer, cart
57
+ lib/ server-side glue; store.ts is the only SDK client
58
+ scripts/ everything the browser runs
59
+ styles/ tokens.css is the design system; one file per area
60
+ middleware.ts the store, the language, redirects and preview
61
+ actions/ placing an order and looking one up, through the SDK
62
+ tests/unit/ contract, guards, design values, Studio, checkout, copy
63
+ .agents/skills/ three skills for coding agents (see below)
64
+ ```
65
+
66
+ A new section is a definition in `src/theme/sections/`, a component in
67
+ `src/components/sections/`, its words in `src/theme/content/` and its editor
68
+ labels in `src/theme/labels.ts`. A new word is a copy key, never text in markup.
69
+
70
+ ## The theme contract in five rules
71
+
72
+ 1. **The theme key is permanent.** `THEME_KEY` names every merchant's saved
73
+ edits. Renaming it after a store edits the theme loses them.
74
+ 2. **Definitions are code; documents are data.** Sections and their fields are
75
+ TypeScript; a page's starting layout is a JSON document.
76
+ 3. **Sections read data only in `load`**, through `reads.get`, so a page reads
77
+ each thing once.
78
+ 4. **Every string is in `src/theme/content/`**, in every language, with each
79
+ language's plural forms.
80
+ 5. **Every cached page carries the `pages` tag** (the SDK's `PAGES_CACHE_TAG`),
81
+ so a publish in Studio shows at once.
82
+
83
+ `AGENTS.md` has the full rules, and `npm test` enforces them.
84
+
85
+ ## Skills
86
+
87
+ Three skills for coding agents live in `.agents/skills/`. `AGENTS.md` says when
88
+ to use each:
89
+
90
+ - **`wocart-theme-from-design`**: a whole theme from a design: a screenshot, an
91
+ image, a live URL, or a Shopify theme measured with the collector. It builds
92
+ the design as tokens and sections, runs the theme to a store, and measures how
93
+ closely it matches.
94
+ - **`shopify-theme-asset-collector`**: collects a Shopify theme's public pages,
95
+ styles, scripts, images and fonts, with a manifest of the homepage sections.
96
+ The output is for measuring a design, not for shipping.
97
+ - **`wocart-docs`**: where each SDK name, field and platform rule is defined,
98
+ and the test that checks each rule.
99
+
100
+ ## Make it your brand
101
+
102
+ Three places restyle the whole store:
103
+
104
+ 1. **`src/styles/tokens.css`** holds every design value. Change a value there,
105
+ and every stylesheet that uses it follows. `npm test` rejects a literal
106
+ value anywhere else.
107
+ 2. **The fonts** in `public/fonts/`: one Arabic and one Latin family, each
108
+ limited to its script. A new file needs its `@font-face` rule at the top of
109
+ `tokens.css`, its preload in `src/layouts/StoreLayout.astro`, and its licence
110
+ line in `public/fonts/OFL.txt`. A test checks all three.
111
+ 3. **The starter's colours** in `src/theme/palette.ts`, which the default colour
112
+ schemes in `src/theme/settings.ts` use: what a store starts with before the
113
+ merchant picks colours in Studio.
114
+
115
+ Keep four things while restyling: colours through tokens (merchants recolour
116
+ sections with schemes), text readable on its band (`contrast.test.ts` checks
117
+ every scheme at WCAG AA), logical properties (`margin-inline-start`, never
118
+ `left`) for right to left, and every `name` and `data-*` attribute that the
119
+ order form and the scripts use.
120
+
121
+ ## Commands
122
+
123
+ ```sh
124
+ npm run dev # the dev server, against the store in .dev.vars
125
+ npm run check # astro check: 0 errors, 0 warnings
126
+ npm test # the contract, guard, design-value, contrast, rules, Studio, checkout and copy tests; no network
127
+ npm run build # the Cloudflare Workers build (dist/)
128
+ npm run preview # the Cloudflare build, served locally by Wrangler
129
+ npm run build:vercel # the Vercel build (.vercel/output/)
130
+ ```
131
+
132
+ ## Deploying
133
+
134
+ **Cloudflare Workers.** `npm run build`, then `npx wrangler deploy`.
135
+ `wrangler.jsonc` holds the Worker's mechanics only: add your own routes or a
136
+ custom domain, and set each variable with `npx wrangler secret put <NAME>`.
137
+
138
+ **Vercel.** `npm run build:vercel` writes `.vercel/output/`. Deploy it with the
139
+ Vercel CLI (`vercel deploy --prebuilt`, from a project linked to Vercel). The
140
+ CLI is not one of this project's dependencies. Set the variables in the
141
+ project's environment variables.
142
+
143
+ Each page route that can be cached has a rule and tags in `astro.config.mjs`
144
+ (`routeRules`), served by the host's cache provider. Every one carries the
145
+ `pages` tag. With `WOCART_PREVIEW_KEY` set, a signed request from the platform
146
+ to `/wocart-revalidate` drops that tag, so a publish in Studio shows at once.
147
+ Without it, a page refreshes when its cache rule lets it.
148
+
149
+ ## Studio
150
+
151
+ "Studio-ready" means Wocart Studio can read the manifest (`/wocart-theme.json`,
152
+ built with the site), frame a draft at `/wocart-preview`, and refresh the store
153
+ after a publish through `/wocart-revalidate`. `npm test` checks those three the
154
+ way Studio uses them, with real Ed25519 keys (`tests/unit/studio.test.ts`).
155
+
156
+ The editability tests (`tests/unit/editability.test.ts`) check the rest of what
157
+ Studio shows: each field reaches its component, every section starts from a
158
+ preset, and every preset renders for a shopper and in the editor's preview.
159
+
160
+ Every page renders the document and settings the store has saved for this
161
+ theme's key. When it has none, it renders the theme's defaults in
162
+ `src/theme/documents/` and `src/theme/settings.ts`.
163
+
164
+ ## Upgrading
165
+
166
+ Update `@abcart/storefront` and `@abcart/theme` together, to the versions a
167
+ release pairs, as exact versions. Each package's `CHANGELOG.md`
168
+ (`node_modules/@wocart/*/CHANGELOG.md`) says which platform it needs and what a
169
+ theme changes in its "Theme migration" section. Then run `npm run check`,
170
+ `npm test` and `npm run build`.
171
+
172
+ A theme release that removes a section, a field or a copy key merchants may have
173
+ edited is a new major version (`THEME_VERSION` and `package.json`).
174
+
175
+ ## Links
176
+
177
+ The documentation is written from the SDKs and around this starter. The
178
+ installed declarations (`node_modules/@wocart/*/dist/*.d.ts`) are the final word
179
+ on every name and type.
180
+
181
+ - This starter, file by file: https://docs.wocart.store/sdk/theme/project
182
+ - Make it your own: https://docs.wocart.store/sdk/theme/customize
183
+ - Theme SDK: https://docs.wocart.store/sdk/theme
184
+ - Storefront SDK: https://docs.wocart.store/sdk/storefront
@@ -0,0 +1,11 @@
1
+ dist/
2
+ node_modules/
3
+ .astro/
4
+ .wrangler/
5
+ .wrangler-output/
6
+ .dev.vars
7
+ .vercel/
8
+ .env*
9
+ .DS_Store
10
+
11
+