@shop-on/create-theme 0.13.2 → 0.14.0-next.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.
- package/package.json +1 -1
- package/template/.claude/skills/theme-dev/SKILL.md +23 -3
- package/template/.claude/skills/theme-dev/recipes/quality.md +2 -1
- package/template/.themeignore +6 -0
- package/template/package.json +10 -10
- package/template/src/assets/theme.css +13 -0
- package/template/src/lib/use-analytics.ts +3 -0
package/package.json
CHANGED
|
@@ -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).
|
|
@@ -229,7 +249,7 @@ pnpm theme:check
|
|
|
229
249
|
pnpm theme:check --release # before you hand the theme off: also theme_info
|
|
230
250
|
|
|
231
251
|
# Build (prebuild backfills defaults + runs oxfmt; postbuild emits .output/theme.json
|
|
232
|
-
# and fails on a server bundle over
|
|
252
|
+
# and fails on a server bundle over 3.5 MB or holding a test file)
|
|
233
253
|
pnpm build
|
|
234
254
|
|
|
235
255
|
# Fetching/resolver changes
|
|
@@ -242,7 +262,7 @@ If you added a section/block, it's available in the editor immediately after a h
|
|
|
242
262
|
|
|
243
263
|
## Bundle hygiene — the server artifact is downloaded per cold start
|
|
244
264
|
|
|
245
|
-
`pnpm build` emits a Nitro `cloudflare-module` artifact. Every file under `.output/server/` is packed into the module map a storefront Worker loads on a cold start, whether or not a request ever imports it — so a leaked module costs every shop on every cold start. A full-featured theme sits around ~
|
|
265
|
+
`pnpm build` emits a Nitro `cloudflare-module` artifact. Every file under `.output/server/` is packed into the module map a storefront Worker loads on a cold start, whether or not a request ever imports it — so a leaked module costs every shop on every cold start. A full-featured theme sits around ~2.3.5 MB (minified, names kept); a jump on a small change is a leak. Postbuild fails the build past 3.5 MB, or when `.output/server` holds a `*.test*` file.
|
|
246
266
|
|
|
247
267
|
- **Tests may sit beside the component they cover.** The registries in `src/components/template-renderer.tsx` glob `*.tsx` with `!*.test.tsx` excluded; a `.test.tsx` that slipped in would register as a phantom type and pull the vitest runtime (~800 KB) into the artifact. Don't widen those globs. `src/components/template-renderer.test.ts` guards this.
|
|
248
268
|
- **Browser-only libraries: dynamic `import()` in an effect or handler, AND an entry in `BROWSER_ONLY_IMPORTS`.** A static import puts the library in the server graph; a dynamic one alone still gets inlined, because Nitro's cloudflare preset has no externals. The list makes Nitro leave `import("hls.js/light")` as a bare specifier the server never executes. It lives inside the published `@shop-on/theme-config` (`createThemeViteConfig` takes only `port`), so a theme can't extend it from `vite.config.ts`; it covers `hls.js/light`, `photoswipe`, `photoswipe/lightbox` and `simple-parallax-js/vanilla`. Any other client-only dependency (player, lightbox, parallax, chart) lands in the server artifact — check `_libs/` after adding one.
|
|
@@ -251,7 +271,7 @@ If you added a section/block, it's available in the editor immediately after a h
|
|
|
251
271
|
|
|
252
272
|
```bash
|
|
253
273
|
pnpm build
|
|
254
|
-
du -sh .output/server # postbuild fails past
|
|
274
|
+
du -sh .output/server # postbuild fails past 3.5 MB
|
|
255
275
|
ls -S .output/server/_libs | head # biggest third-party chunks
|
|
256
276
|
```
|
|
257
277
|
|
|
@@ -50,7 +50,7 @@ by hand, as each one says.
|
|
|
50
50
|
| Line | How | Learn it in |
|
|
51
51
|
| ------------------------------------------------------------------------------------------- | ------------------------------------- | --------------------------------------------------------------------------------------------------------- |
|
|
52
52
|
| Lighthouse performance ≥ 60, averaged over home, product and collection, desktop and mobile | audit: 3 runs each, the median counts | [data-fetching.md](data-fetching.md) |
|
|
53
|
-
| `.output/server` under
|
|
53
|
+
| `.output/server` under 3.5 MB | build | [SKILL.md § Bundle hygiene](../SKILL.md#bundle-hygiene--the-server-artifact-is-downloaded-per-cold-start) |
|
|
54
54
|
| no test file in `.output/server` | build | [SKILL.md § Bundle hygiene](../SKILL.md#bundle-hygiene--the-server-artifact-is-downloaded-per-cold-start) |
|
|
55
55
|
| no browser-only library in `.output/server/_libs` | review: `ls -S .output/server/_libs` | [SKILL.md § Bundle hygiene](../SKILL.md#bundle-hygiene--the-server-artifact-is-downloaded-per-cold-start) |
|
|
56
56
|
|
|
@@ -83,6 +83,7 @@ LCP by seconds.
|
|
|
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
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
# What `shop-on theme source` leaves out of the tarball you submit, in gitignore
|
|
2
|
+
# syntax. It already leaves out installs, build output, credentials, `.git` and
|
|
3
|
+
# `.claude/`, and nothing here brings those back. Keep what the build needs.
|
|
4
|
+
#
|
|
5
|
+
# /notes/
|
|
6
|
+
# *.stories.tsx
|
package/template/package.json
CHANGED
|
@@ -17,14 +17,14 @@
|
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"@bprogress/core": "1.3.4",
|
|
20
|
-
"@shop-on/i18n": "^0.
|
|
21
|
-
"@shop-on/theme-contract": "^0.
|
|
22
|
-
"@shop-on/theme-loader": "^0.
|
|
23
|
-
"@shop-on/theme-react": "^0.
|
|
24
|
-
"@shop-on/theme-routes": "^0.
|
|
25
|
-
"@shop-on/theme-runtime": "^0.
|
|
26
|
-
"@shop-on/theme-server": "^0.
|
|
27
|
-
"@shop-on/theme-system": "^0.
|
|
20
|
+
"@shop-on/i18n": "^0.14.0-next.1",
|
|
21
|
+
"@shop-on/theme-contract": "^0.14.0-next.1",
|
|
22
|
+
"@shop-on/theme-loader": "^0.14.0-next.1",
|
|
23
|
+
"@shop-on/theme-react": "^0.14.0-next.1",
|
|
24
|
+
"@shop-on/theme-routes": "^0.14.0-next.1",
|
|
25
|
+
"@shop-on/theme-runtime": "^0.14.0-next.1",
|
|
26
|
+
"@shop-on/theme-server": "^0.14.0-next.1",
|
|
27
|
+
"@shop-on/theme-system": "^0.14.0-next.1",
|
|
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.
|
|
39
|
-
"@shop-on/theme-dev-host": "^0.
|
|
38
|
+
"@shop-on/theme-config": "^0.14.0-next.1",
|
|
39
|
+
"@shop-on/theme-dev-host": "^0.14.0-next.1",
|
|
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);
|
|
@@ -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
|