@shop-on/create-theme 0.13.1 → 0.14.0-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shop-on/create-theme",
3
- "version": "0.13.1",
3
+ "version": "0.14.0-next.0",
4
4
  "description": "Scaffolds a Shop-On storefront theme: `npm create @shop-on/theme <dir>`.",
5
5
  "license": "SEE LICENSE IN dist/LICENSE.md",
6
6
  "bin": {
@@ -166,6 +166,26 @@ Conditional visibility: `"visible_if": "{{ section.settings.layout == 'carousel'
166
166
  - **Editor selection border invisible over drawers/dialogs →** `EditorPreviewBridge` is mounted inside a stacking context. Its highlight overlay is `position: fixed` at max z-index, but if any ancestor isolates (a `.root { isolation: isolate }` wrapper, or a `transform`/`filter` wrapper), the overlay is trapped under Base UI portals (`z-50` siblings of `.root` at the end of `<body>`). Mount the bridge as a **direct `<body>` child outside `.root`** in `src/routes/__root.tsx` (where the starter already has it) — never inside the page wrapper. Raising the overlay's z-index can't fix this; only the mount point can.
167
167
  - **A store hangs, or a request never answers →** one request awaited another's in-flight promise. The storefront runs on Cloudflare Workers: every request a store gets shares one Worker instance, and the runtime binds each fetch and timer to the request that started it, so share values and settled outcomes, never in-flight work: `createLease` / `requestSlot` (`@shop-on/theme-server/lease`, `/request-scope`) for server coordination, a `Promise.race` loser's fetch dies with its request, cached values are read-only, and a component's module-level promise cache (a store-availability cache, say) sits behind `ClientOnly` so SSR never fills it. The two named exceptions are inside `@shop-on/theme-loader`: its memoized `import()` promises and its promise-valued schema and locale caches are shared in flight on purpose, because both read from the bundle with no network I/O for the runtime to bind to a request.
168
168
 
169
+ ## App intercepts
170
+
171
+ **Every theme honours app intercepts.** Today: `buy-buttons`. An app (a booking, a hold) may take over what adding a product does, from a block on the product page or from an app embed on the products its app claims. A new intercept point is added to the shared packages with a check, and every theme adopts it in the same PR.
172
+
173
+ What a theme author does:
174
+
175
+ - **Every add of the page's product** (the buy box, a sticky bar, a quantity block that reads `hideQuantity`) goes through `const intercept = useIntercept("buy-buttons", productData)` (`@shop-on/theme-react/template-renderer`), passing the product the control adds. Its three states:
176
+ - `null`: no app intercepts this product; the control works as always.
177
+ - `{ state: "pending" }`: disable the add-to-cart (the server HTML already is), hide buy-it-now and dynamic checkout, and drop the quantity picker when `intercept.hideQuantity`.
178
+ - `{ state: "ready" }`: label the button `intercept.label(ctx) ?? <your label>`, and on a click `await intercept.run(ctx)`, running your own add only on `"pass"`. `ctx` is `buyButtonContextOf(productData, variant, quantity)`.
179
+ - **Every add off the product page** (a card's quick add, quick view, recommendations, a quiz, a lookbook, a quick order list) checks `mustOpenProductPage(product)` (`@shop-on/theme-runtime/app-intercepts`) and, when true, opens the product page (client-side, through the router) instead of adding or opening a quick view.
180
+
181
+ What not to do:
182
+
183
+ - No click handler that adds around the hook (a second button, a form `onSubmit` that calls the cart directly, a keyboard shortcut).
184
+ - No client-only disabling: the pending state must be in the server HTML, or a buyer adds before the app's script loads. Read the hook during render, never in an effect.
185
+ - No per-app checks (an app id, a handle, a tag): the hook and the helper decide for every app.
186
+
187
+ The gate: theme:check's `app-intercepts` rule fails any file that adds to the cart (`addToCart(`, `cartLinesAdd(`, `addLines(` …, or the theme's own wrapper of one: a function a file exports, or returns from an exported hook, that adds, such as `useCart().add(` or `buy(`) without one of the two. A wrapper that adds is the cart's layer and is not flagged itself; its callers are. A wrapper that honours the intercept covers its callers. A surface that adds a variant another component already vetted (a rail's `onAdd`) says so with `// theme-check-disable-next-line app-intercepts: <who vets it>`. Run `pnpm theme:check`; it runs on every submission, and review never waives it.
188
+
169
189
  ## Section previews (picker)
170
190
 
171
191
  Hovering a section in the editor's add-section picker renders it **live and standalone** — the one section through the `empty` layout, built from its schema/preset defaults, with `t:` resolved, and with **no picker-data enrichment** and no editor bridge. Code path: route `src/routes/{-$locale}/preview/section.tsx` → `getSectionPreviewTemplateFn` (`src/server/settings.ts`) → `buildSectionPreviewTemplate` (`@shop-on/theme-loader/section-preview`, which owns the `?block=` host lookup and calls theme-contract's `buildSectionInstance` internally).
@@ -110,5 +110,6 @@ needs a dev-server restart to register.
110
110
  `pnpm theme:check`, `pnpm build`. The full bar is [quality.md](quality.md).
111
111
 
112
112
  Fill in `theme_info` at the top of `src/config/settings-schema.json` — your
113
- name as `theme_author`, plus documentation and support URLs — before you hand
114
- the theme to anyone.
113
+ name as `theme_author` — before you hand the theme to anyone. The support email
114
+ and documentation link merchants see are set on the theme in the developer
115
+ portal, not here.
@@ -79,10 +79,11 @@ LCP by seconds.
79
79
  | ---------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------- | --------------------------------------------------------------- |
80
80
  | every root template renders: home, product, collection, collections list, search, cart, page, blog, article, policy, password; an unknown path answers 404 | audit; by hand, open each on `pnpm dev` | [template.md](template.md) |
81
81
  | every declared locale has every key | check: `locales-complete` | [locales.md](locales.md#adding-a-key) |
82
- | `theme_info` filled: name, author, documentation and support URLs | check: `theme-info` (`--release`) | [concepts.md](concepts.md) |
82
+ | `theme_info` filled: name and author | check: `theme-info` (`--release`) | [concepts.md](concepts.md) |
83
83
  | `release-notes.md` has a `## X.Y.Z` section for `package.json#version` | check: `release-notes-version` | [SKILL.md § Shipping a version](../SKILL.md#shipping-a-version) |
84
84
  | every section a merchant can add has `presets` | check: `section-presets` | [section.md](section.md#top-level-fields) |
85
85
  | every section previews standalone, with no picker data | audit: `/preview/section?type=<name>` | [section.md](section.md#preview-readiness) |
86
+ | every add to the cart honours app intercepts (`useIntercept("buy-buttons", product)` or `mustOpenProductPage(product)`) | check: `app-intercepts` | [SKILL.md § App intercepts](../SKILL.md#app-intercepts) |
86
87
 
87
88
  `theme-info` runs only with `--release`: a fresh starter has no author yet,
88
89
  and a plain `pnpm theme:check` should pass on it. Fill `theme_info` before
@@ -17,14 +17,14 @@
17
17
  },
18
18
  "dependencies": {
19
19
  "@bprogress/core": "1.3.4",
20
- "@shop-on/i18n": "^0.13.1",
21
- "@shop-on/theme-contract": "^0.13.1",
22
- "@shop-on/theme-loader": "^0.13.1",
23
- "@shop-on/theme-react": "^0.13.1",
24
- "@shop-on/theme-routes": "^0.13.1",
25
- "@shop-on/theme-runtime": "^0.13.1",
26
- "@shop-on/theme-server": "^0.13.1",
27
- "@shop-on/theme-system": "^0.13.1",
20
+ "@shop-on/i18n": "^0.14.0-next.0",
21
+ "@shop-on/theme-contract": "^0.14.0-next.0",
22
+ "@shop-on/theme-loader": "^0.14.0-next.0",
23
+ "@shop-on/theme-react": "^0.14.0-next.0",
24
+ "@shop-on/theme-routes": "^0.14.0-next.0",
25
+ "@shop-on/theme-runtime": "^0.14.0-next.0",
26
+ "@shop-on/theme-server": "^0.14.0-next.0",
27
+ "@shop-on/theme-system": "^0.14.0-next.0",
28
28
  "@tailwindcss/vite": "4.3.5",
29
29
  "@tanstack/react-router": "1.170.46",
30
30
  "@tanstack/react-start": "1.169.5",
@@ -35,8 +35,8 @@
35
35
  "tailwindcss": "4.3.5"
36
36
  },
37
37
  "devDependencies": {
38
- "@shop-on/theme-config": "^0.13.1",
39
- "@shop-on/theme-dev-host": "^0.13.1",
38
+ "@shop-on/theme-config": "^0.14.0-next.0",
39
+ "@shop-on/theme-dev-host": "^0.14.0-next.0",
40
40
  "@spiriit/vite-plugin-svg-spritemap": "7.2.0",
41
41
  "@types/node": "26.6.6",
42
42
  "@types/react": "19.3.0",
@@ -16,6 +16,19 @@
16
16
  ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
17
17
  }
18
18
 
19
+ /* Your primary button, published to app elements (blocks, sections, embeds) so
20
+ * an app's own button matches it (docs/app-blocks.md, "Button tokens"). Mapped
21
+ * to the search page's accent button until you build an add-to-cart button;
22
+ * then point these at its tokens. Declared on the app element, not `:root`, so
23
+ * a colour that changes per section resolves there. */
24
+ :where([data-app-block-id], [data-app-section-id], [data-app-embed-id]) {
25
+ --shopon-app-button-bg: var(--color-accent);
26
+ --shopon-app-button-fg: var(--color-accent-foreground);
27
+ --shopon-app-button-radius: var(--radius-lg);
28
+ --shopon-app-button-height: calc(var(--spacing) * 10);
29
+ --shopon-app-button-font: 500 var(--text-sm) / var(--text-sm--line-height) var(--font-sans);
30
+ }
31
+
19
32
  html {
20
33
  font-family: var(--font-sans);
21
34
  background-color: var(--color-background);
@@ -2,9 +2,7 @@
2
2
  {
3
3
  "name": "theme_info",
4
4
  "theme_name": "Starter",
5
- "theme_author": "",
6
- "theme_documentation_url": "",
7
- "theme_support_url": ""
5
+ "theme_author": ""
8
6
  },
9
7
  {
10
8
  "name": "t:names.custom_css",
@@ -21,6 +21,9 @@ import {
21
21
  // from the cart mutations, `trackCartViewed` from the cart page and drawer, and
22
22
  // await `trackCheckoutStarted` before the checkout redirect — all four are in
23
23
  // `@shop-on/theme-react/analytics`.
24
+ // Every add to that cart honours app intercepts: `useIntercept("buy-buttons",
25
+ // product)` on the product page, `mustOpenProductPage(product)` anywhere else
26
+ // (docs/app-blocks.md; `pnpm theme:check` fails without them).
24
27
 
25
28
  /** `product_viewed` — once per PDP page load. The product's id is the join key
26
29
  * the recommendation trainer and the popularity fallback both use, so a