@shop-on/create-theme 0.10.0 → 0.11.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 (30) hide show
  1. package/dist/cli.mjs +1 -2
  2. package/dist/index.d.mts +1 -3
  3. package/dist/index.mjs +1 -2
  4. package/package.json +3 -3
  5. package/template/.claude/skills/theme-dev/SKILL.md +2 -2
  6. package/template/.claude/skills/theme-dev/recipes/concepts.md +2 -2
  7. package/template/.claude/skills/theme-dev/recipes/customer-auth.md +2 -1
  8. package/template/.claude/skills/theme-dev/recipes/data-fetching.md +2 -2
  9. package/template/.claude/skills/theme-dev/recipes/input-settings.md +4 -5
  10. package/template/.claude/skills/theme-dev/recipes/locales.md +1 -1
  11. package/template/.claude/skills/theme-dev/recipes/picker-data.md +2 -2
  12. package/template/.env.example +2 -3
  13. package/template/.oxfmtrc.json +0 -1
  14. package/template/package.json +21 -22
  15. package/template/src/lib/i18n.server.ts +2 -2
  16. package/template/src/lib/listing-search.ts +7 -12
  17. package/template/src/lib/use-analytics.ts +11 -11
  18. package/template/src/route-adapter.tsx +0 -2
  19. package/template/src/routes/__root.tsx +2 -2
  20. package/template/src/routes/robots[.]txt.tsx +5 -5
  21. package/template/src/routes/sitemap[.]xml.tsx +5 -4
  22. package/template/src/routes/{-$locale}/checkout.tsx +13 -8
  23. package/template/src/routes/{-$locale}/collections/index.tsx +1 -1
  24. package/template/src/sections/main-collection.test.tsx +21 -7
  25. package/template/src/server/i18n.server.test.ts +2 -2
  26. package/template/src/server/i18n.server.ts +7 -19
  27. package/template/src/server/settings.ts +0 -1
  28. package/template/src/server/template-loader.ts +2 -2
  29. package/template/tsconfig.json +0 -7
  30. package/template/src/server/checkout-redirect.ts +0 -21
package/dist/cli.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { packageManagerCommands, scaffoldTheme } from "./index.mjs";
3
3
  import path from "node:path";
4
- //#region src/cli.ts
4
+ // src/cli.ts
5
5
  const USAGE = "usage: npm create @shop-on/theme <dir>";
6
6
  const dir = process.argv[2];
7
7
  if (dir === "-h" || dir === "--help") {
@@ -36,5 +36,4 @@ ${steps.map((step, i) => ` ${i + 1}. ${step}`).join("\n")}
36
36
 
37
37
  Once the Shop-On CLI is published, \`shop-on theme init\` does all this and fills in .env for you.
38
38
  `);
39
- //#endregion
40
39
  export {};
package/dist/index.d.mts CHANGED
@@ -1,4 +1,3 @@
1
- //#region src/index.d.ts
2
1
  /**
3
2
  * `{ [name]: packedName }`: the files `npm pack` leaves out of a tarball, which
4
3
  * `template/` stores renamed and `scaffoldTheme` restores.
@@ -28,5 +27,4 @@ export declare function scaffoldTheme({ dir }: {
28
27
  export declare function packageManagerCommands(userAgent: string | undefined): {
29
28
  install: string[];
30
29
  dev: string[];
31
- };
32
- //#endregion
30
+ };
package/dist/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import fs from "node:fs";
2
2
  import path from "node:path";
3
3
  import { fileURLToPath } from "node:url";
4
- //#region src/index.ts
4
+ // src/index.ts
5
5
  /**
6
6
  * `{ [name]: packedName }`: the files `npm pack` leaves out of a tarball, which
7
7
  * `template/` stores renamed and `scaffoldTheme` restores.
@@ -77,5 +77,4 @@ function packageManagerCommands(userAgent) {
77
77
  };
78
78
  }
79
79
  }
80
- //#endregion
81
80
  export { PACKED_NAMES, packageManagerCommands, scaffoldTheme };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shop-on/create-theme",
3
- "version": "0.10.0",
3
+ "version": "0.11.1",
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": {
@@ -16,9 +16,9 @@
16
16
  "./package.json": "./package.json"
17
17
  },
18
18
  "devDependencies": {
19
- "@types/node": "26.6.5",
19
+ "@types/node": "26.6.6",
20
20
  "typescript": "7.0.2",
21
- "vitest": "5.0.5"
21
+ "vitest": "5.1.0"
22
22
  },
23
23
  "engines": {
24
24
  "node": "^20.19.0 || >=22.12.0"
@@ -129,8 +129,8 @@ Pick the matching recipe and follow it end-to-end:
129
129
  | `product_list` | Multi-product picker → resolved sibling: `{id}Data: ProductData[]`. `limit?` caps |
130
130
  | `metaobject` | Entry picker scoped by `metaobject_type` → stores a GID; resolved sibling: `{id}Data: MetaobjectData \| null` |
131
131
  | `metaobject_list` | Multi-entry picker, same `metaobject_type` → stores GIDs; `{id}Data: MetaobjectData[]` (unresolved drop). `limit?` ≤ 50 |
132
- | `review` | Published-review picker (shop-wide) → stores a GID; `{id}Data: ReviewData \| null` |
133
- | `review_list` | Multi-review picker → stores GIDs; `{id}Data: ReviewData[]` (unresolved drop). `limit?` ≤ 50 |
132
+ | `review` | Published-review picker (shop-wide) → stores an id; `{id}Data: ReviewCardData \| null` |
133
+ | `review_list` | Multi-review picker → stores ids; `{id}Data: ReviewCardData[]` (unresolved drop). `limit?` ≤ 50 |
134
134
  | `page` | CMS-page handle picker → resolved sibling: `{id}Data` (narrow title + body), both scopes |
135
135
  | `html` | CodeMirror HTML editor → raw, **unsanitized** merchant markup; render via the theme's `CustomHtml` snippet, never by hand |
136
136
  | `liquid` | CodeMirror Liquid editor → merchant Liquid, rendered **server-side** during enrichment into a `liquidData` sibling |
@@ -69,8 +69,8 @@ locales. The `@shop-on/*` packages own the plumbing, and you don't edit them:
69
69
 
70
70
  - `@shop-on/theme-routes` — what each route does (load a product, run a search,
71
71
  sign a buyer in). Your `src/routes/` files stay thin and call into it.
72
- - `@shop-on/theme-server` — server-only data loaders against the store's
73
- storefront API (GraphQL), cart, buyer auth.
72
+ - `@shop-on/theme-server` — server-only data loaders on the store's storefront
73
+ API (its typed procedures client), cart, buyer auth.
74
74
  - `@shop-on/theme-loader`, `@shop-on/theme-react` — load the right template for
75
75
  a request and render it; the editor preview bridge.
76
76
  - `@shop-on/theme-runtime` — small pure helpers: money, prices on sale,
@@ -50,7 +50,8 @@ rides inside theme-server.
50
50
  5. **Cart adapter** — read the customer token via `readCustomerSession()`;
51
51
  `resolveCart` branches anonymous-read vs `resolveCartForCustomer`;
52
52
  cookie-less adds go through `mintOrClaimCart({session, customerToken})`
53
- (handles anonymous too); forward `customerToken` into every shared op.
53
+ (handles anonymous too). The cart's own ops (`cart-mutations`) take only the
54
+ cart token: the api's cart has no customer link until buyer sign-in.
54
55
  Checkout: the `/checkout` route reads `checkout_state` in `validateSearch`
55
56
  and passes it to `startCheckoutHandoff({ state, customerToken })` (`state`
56
57
  is a required key). Without a state it returns checkout's `/begin`, which
@@ -39,12 +39,12 @@ The shared fetchers in `@shop-on/theme-server` are a published API with a compat
39
39
 
40
40
  ## Writing a new loader
41
41
 
42
- **Spread a fragment, don't retype the projection.** Before writing a selection set, check whether `@shop-on/theme-server` already exports one. Retyped copies of one projection drift apart silently (a search query missing `tags` draws no badges its collection page draws). One gql.tada fragment plus one mapper keeps them in step — `CollectionProductNodeFragment` / `toCollectionProduct` from `@shop-on/theme-server/collection` is the worked example. Mark it `@_unmask` so callers read fields straight off the node instead of round-tripping through `readFragment`, and note that a fragment may reference the SPREADING operation's variables (`$mediaFirst`, `$includeOptions`), which is what keeps the per-surface knobs working.
42
+ **Build on a loader, don't re-map its answer.** The theme reads the api only through `@shop-on/theme-server`'s loaders (`/product`, `/collection`, `/search`, `/page`, `/menu`, …): each calls the api's storefront procedures through a typed client and maps the answer to the shapes the theme renders (`ProductData`, `CollectionData`, …) once. Before writing a new mapping, check whether a loader already returns the shape. Re-mapped copies of one shape drift apart silently (a search card missing `tags` draws no badges its collection page draws). Narrow a loader with its own arguments (`first`, `mediaFirst`, `includeOptions`) rather than trimming its answer after the fact.
43
43
 
44
44
  **Catch the failure OUTSIDE `memoTTL`, not inside the memoized function.** `memoTTL` (`@shop-on/theme-server/cache`) never caches a rejection, which is the whole mechanism for "don't pin a transient 500 for a TTL". A `try/catch` inside the wrapped function defeats it: the failure is flattened into the same `[]` / `null` an empty-but-successful read returns, and no `shouldCache` predicate can tell them apart afterwards. Guarding with `shouldCache: (v) => v.length > 0` then makes the _legitimately empty_ answer uncacheable — a new shop with nothing published re-queries on every render, forever. Let the memoized function throw and wrap the exported one:
45
45
 
46
46
  ```ts
47
- const loadThing = memoTTL(async (…) => { const res = await request(…); return map(res); }, { key, version: getContentVersion });
47
+ const loadThing = memoTTL(async (…) => { const res = await fetchUpstream(…); return map(res); }, { key, version: getContentVersion });
48
48
 
49
49
  export async function fetchThing(…) {
50
50
  try {
@@ -402,14 +402,13 @@ Product-review pickers, for social-proof surfaces that feature hand-picked revie
402
402
  { "type": "review_list", "id": "reviews", "label": "t:settings.reviews", "limit": 6 }
403
403
  ```
404
404
 
405
- - **Value:** `string` (review GID) / `string[]` (review GIDs). Reviews have no handle
406
- - **Sibling prop:** `reviewData: ReviewData | null` / `reviewsData: ReviewData[]` (from `@shop-on/theme-server/review`) — `{ id, rating, title, body, authorName, verified, createdAt, upvoteCount, downvoteCount, media[], merchantReply }`
405
+ - **Value:** `string` (review id, `review_…`) / `string[]` (review ids). Reviews have no handle
406
+ - **Sibling prop:** `reviewData: ReviewCardData | null` / `reviewsData: ReviewCardData[]` (from `@shop-on/theme-server/review`) — `{ id, rating, title, body, authorName, verifiedBuyer, createdAt, answers[], reply, product: { id, handle, title, url, image } }`. No votes and no buyer photos
407
407
  - **Single keeps null, list drops.** An unpublished / deleted pick leaves `reviewData` null (the section decides its fallback); in a list it's dropped, so a grid never null-guards per entry — same contract as `metaobject_list`
408
408
  - **`limit` defaults to and caps at 50**
409
- - **No defaults** — review GIDs are tenant-specific
409
+ - **No defaults** — review ids are tenant-specific
410
410
  - **`body` is plain text, not HTML.** Render as text; never `dangerouslySetInnerHTML`
411
- - **The storefront cannot see which product a review belongs to.** The review's product is exposed to the admin picker row but NOT in `ReviewData`, so a "reviewed product" line can't be built from it
412
- - **No viewer-dependent fields.** `mine` / `myVote` / `pending` are deliberately absent — the loader result is memoized shop-wide, so caching them would leak one buyer's vote state to everyone
411
+ - **A picked review carries its product** (`product.url` links to it); the api only answers reviews of live products, so there is no status to check
413
412
  - **No id allowlist:** any setting declared `review` / `review_list` in a section or block schema resolves, under whatever id you give it
414
413
  - Not dynamic-source bindable — there's no review metafield reference type
415
414
 
@@ -105,7 +105,7 @@ Plain `.ts` helpers (no JSX, not a component) cannot call the hook either: have
105
105
  This starter ships all four pieces already; they are listed so you know where each lives:
106
106
 
107
107
  1. `src/locales/<locale>.default.json` per declared locale.
108
- 2. `src/server/i18n.server.ts` — `getMessagesForLocale`, merging the merchant's `locale_content` rows over the shipped catalog with `applyCatalogOverrides` (this is what makes admin → Translations able to override the theme's own copy).
108
+ 2. `src/server/i18n.server.ts` — `getMessagesForLocale`, laying the merchant's `strings` rows over the shipped catalog with `themeStrings` from `@shop-on/theme-server/translations` (this is what makes admin → Translations able to override the theme's own copy).
109
109
  3. `src/server/i18n.ts` — a `createServerFn` wrapper, so the `node:*`/env-reading module stays out of the client bundle.
110
110
  4. `__root.tsx` — fetch it in the loader (pass the **display** locale, `getCurrentLocale()`, not `getContentLocale()`) and wrap the shell in `<IntlProvider locale messages timeZone>`.
111
111
 
@@ -24,8 +24,8 @@ The sibling is always the setting's own `id` plus `Data`, verbatim.
24
24
  | `article` | `article` | `articleData` |
25
25
  | `metaobject` | `author` | `authorData: MetaobjectData \| null` |
26
26
  | `metaobject_list` | `authors` | `authorsData: MetaobjectData[]` |
27
- | `review` | `review` | `reviewData: ReviewData \| null` |
28
- | `review_list` | `reviews` | `reviewsData: ReviewData[]` |
27
+ | `review` | `review` | `reviewData: ReviewCardData \| null` |
28
+ | `review_list` | `reviews` | `reviewsData: ReviewCardData[]` |
29
29
 
30
30
  Every one of these resolves at **both** section and block scope, including a container block's children.
31
31
 
@@ -1,7 +1,6 @@
1
- # Your store's storefront API client.
1
+ # Your store's storefront key (`shop-on theme init` writes all of this).
2
2
  STOREFRONT_API_URL=
3
- STOREFRONT_CLIENT_ID=
4
- STOREFRONT_CLIENT_SECRET=
3
+ STOREFRONT_KEY=
5
4
  STORE_SLUG=
6
5
 
7
6
  # Signs the buyer session cookies the theme sets. Any random value:
@@ -2,7 +2,6 @@
2
2
  "$schema": "./node_modules/oxfmt/configuration_schema.json",
3
3
  "ignorePatterns": [
4
4
  "**/routeTree.gen.ts",
5
- "**/graphql-env.d.ts",
6
5
  "src/listings/**/*.json",
7
6
  "src/templates/**/*.json",
8
7
  "src/section-groups/**/*.json",
@@ -17,37 +17,36 @@
17
17
  },
18
18
  "dependencies": {
19
19
  "@bprogress/core": "1.3.4",
20
- "@shop-on/i18n": "^0.10.0",
21
- "@shop-on/theme-contract": "^0.10.0",
22
- "@shop-on/theme-loader": "^0.10.0",
23
- "@shop-on/theme-react": "^0.10.0",
24
- "@shop-on/theme-routes": "^0.10.0",
25
- "@shop-on/theme-runtime": "^0.10.0",
26
- "@shop-on/theme-server": "^0.10.0",
27
- "@shop-on/theme-system": "^0.10.0",
28
- "@tailwindcss/vite": "4.3.3",
29
- "@tanstack/react-router": "1.170.45",
30
- "@tanstack/react-start": "1.169.3",
31
- "dotenv": "18.0.8",
32
- "nitro": "3.0.260903-beta",
20
+ "@shop-on/i18n": "^0.11.1",
21
+ "@shop-on/theme-contract": "^0.11.1",
22
+ "@shop-on/theme-loader": "^0.11.1",
23
+ "@shop-on/theme-react": "^0.11.1",
24
+ "@shop-on/theme-routes": "^0.11.1",
25
+ "@shop-on/theme-runtime": "^0.11.1",
26
+ "@shop-on/theme-server": "^0.11.1",
27
+ "@shop-on/theme-system": "^0.11.1",
28
+ "@tailwindcss/vite": "4.3.5",
29
+ "@tanstack/react-router": "1.170.46",
30
+ "@tanstack/react-start": "1.169.5",
31
+ "dotenv": "18.0.10",
32
+ "nitro": "3.0.261103-rc",
33
33
  "react": "19.3.1",
34
34
  "react-dom": "19.3.1",
35
- "tailwindcss": "4.3.3"
35
+ "tailwindcss": "4.3.5"
36
36
  },
37
37
  "devDependencies": {
38
- "@shop-on/theme-config": "^0.10.0",
39
- "@shop-on/theme-dev-host": "^0.10.0",
38
+ "@shop-on/theme-config": "^0.11.1",
39
+ "@shop-on/theme-dev-host": "^0.11.1",
40
40
  "@spiriit/vite-plugin-svg-spritemap": "7.2.0",
41
- "@types/node": "26.6.5",
41
+ "@types/node": "26.6.6",
42
42
  "@types/react": "19.3.0",
43
43
  "@types/react-dom": "19.3.0",
44
- "@vitejs/plugin-react": "6.1.2",
45
- "gql.tada": "1.11.4",
44
+ "@vitejs/plugin-react": "6.3.0",
46
45
  "happy-dom": "21.0.4",
47
- "oxfmt": "^0.74.0",
46
+ "oxfmt": "^0.78.0",
48
47
  "tsx": "^4.23.15",
49
48
  "typescript": "7.0.2",
50
- "vite": "8.3.5",
51
- "vitest": "5.0.5"
49
+ "vite": "8.3.8",
50
+ "vitest": "5.1.0"
52
51
  }
53
52
  }
@@ -16,8 +16,8 @@ const { handleLocaleMiddleware } = createI18nServer(
16
16
 
17
17
  export { handleLocaleMiddleware };
18
18
 
19
- // Snapshot the shop's locale config (primary + published extras, as the
20
- // storefront-scoped API already filters them) for the sync i18n call sites.
19
+ // Snapshot the shop's locale config (primary + published extras, as
20
+ // `fetchShopInfo` already filters them) for the sync i18n call sites.
21
21
  // `fetchShopInfo` is memoTTL-cached, so this is a no-op-cheap await on warm
22
22
  // requests. Failures keep the previous snapshot (or the build-time fallback
23
23
  // on a cold process) rather than failing the request.
@@ -13,12 +13,12 @@
13
13
  import type { ParsedBlogSearch, ParsedListingSearch } from "@shop-on/theme-routes";
14
14
  import {
15
15
  asParam,
16
+ type ListingFilters,
16
17
  narrowedListingPath,
17
18
  parseListingFilters,
18
- toFilterInput,
19
19
  } from "@shop-on/theme-runtime/listing-filters";
20
- import type { CollectionFilterInput, CollectionSort } from "@shop-on/theme-server/collection";
21
- import type { ProductSearchFilterInput, ProductSearchSort } from "@shop-on/theme-server/search";
20
+ import type { CollectionSort } from "@shop-on/theme-server/collection";
21
+ import type { ProductSearchSort } from "@shop-on/theme-server/search";
22
22
 
23
23
  /** The listing's implicit ordering when `?sort=` is absent. */
24
24
  export const DEFAULT_COLLECTION_SORT: CollectionSort = "FEATURED";
@@ -74,10 +74,9 @@ export function parseCollectionSearch(search: unknown): ParsedListingSearch {
74
74
  };
75
75
  }
76
76
 
77
- /** URL state → the GraphQL filter input. `undefined` when nothing is applied, so
78
- * the resolver short-circuits to the unfiltered base scope. */
79
- export function searchToFilterInput(state: ParsedListingSearch): CollectionFilterInput | undefined {
80
- return toFilterInput(state);
77
+ /** URL state → a listing's `filter`: the ticked facet values and the price bounds. */
78
+ export function searchToFilterInput(state: ParsedListingSearch): ListingFilters {
79
+ return { filters: state.filters, price_min: state.price_min, price_max: state.price_max };
81
80
  }
82
81
 
83
82
  /** Self-canonical for a narrowed listing view — filters, sort and page in the
@@ -97,11 +96,7 @@ export function parseProductSearch(search: unknown): ParsedListingSearch & { q?:
97
96
  }
98
97
 
99
98
  /** /search narrows on the same grammar as a collection. */
100
- export function searchToProductFilterInput(
101
- state: ParsedListingSearch & { q?: string },
102
- ): ProductSearchFilterInput | undefined {
103
- return toFilterInput(state);
104
- }
99
+ export const searchToProductFilterInput = searchToFilterInput;
105
100
 
106
101
  export function parseBlogSearch(search: unknown): ParsedBlogSearch {
107
102
  const raw = (search ?? {}) as Record<string, unknown>;
@@ -2,11 +2,11 @@ import { type MouseEvent, useEffect, useLayoutEffect, useRef, useState } from "r
2
2
  import {
3
3
  ensureVisit,
4
4
  type ProductListType,
5
- toInt,
6
5
  track,
7
6
  trackProductClicked,
8
7
  trackProductListViewed,
9
8
  trackSearchSubmitted,
9
+ wireIdOf,
10
10
  } from "@shop-on/theme-react/analytics";
11
11
 
12
12
  // The view-side of storefront analytics: hooks a section calls to report what
@@ -22,16 +22,16 @@ import {
22
22
  // await `trackCheckoutStarted` before the checkout redirect — all four are in
23
23
  // `@shop-on/theme-react/analytics`.
24
24
 
25
- /** `product_viewed` — once per PDP page load. The numeric id is the join key
25
+ /** `product_viewed` — once per PDP page load. The product's id is the join key
26
26
  * the recommendation trainer and the popularity fallback both use, so a
27
- * product whose id won't parse is skipped rather than logged malformed. */
27
+ * value that is not a product's id is skipped rather than logged malformed. */
28
28
  export function useProductViewed(
29
- productId: string | number | null | undefined,
29
+ productId: string | null | undefined,
30
30
  productHandle: string | undefined,
31
31
  ): void {
32
32
  useEffect(() => {
33
33
  if (!productHandle) return;
34
- const id = toInt(productId);
34
+ const id = wireIdOf(productId, "prod");
35
35
  if (id === null) return;
36
36
  ensureVisit();
37
37
  void track("product_viewed", { product_id: id, product_handle: productHandle });
@@ -40,12 +40,12 @@ export function useProductViewed(
40
40
 
41
41
  /** `collection_viewed` — once per collection PLP page load. */
42
42
  export function useCollectionViewed(
43
- collectionId: string | number | null | undefined,
43
+ collectionId: string | null | undefined,
44
44
  collectionHandle: string | undefined,
45
45
  ): void {
46
46
  useEffect(() => {
47
47
  if (!collectionHandle) return;
48
- const id = toInt(collectionId);
48
+ const id = wireIdOf(collectionId, "collection");
49
49
  if (id === null) return;
50
50
  ensureVisit();
51
51
  void track("collection_viewed", { collection_id: id, collection_handle: collectionHandle });
@@ -63,7 +63,7 @@ export function useSearchSubmitted(query: string, totalCount: number): void {
63
63
  }, [query, totalCount]);
64
64
  }
65
65
 
66
- type ListProduct = { id?: string | number | null; handle?: string };
66
+ type ListProduct = { id?: string | null; handle?: string };
67
67
 
68
68
  /** Impression + click tracking for a product list. Spread the returned
69
69
  * `{ ref, onClickCapture }` onto the grid container and annotate each card
@@ -87,7 +87,7 @@ export function useProductListTracking({
87
87
  products,
88
88
  }: {
89
89
  listType: ProductListType;
90
- listId?: string | number | null;
90
+ listId?: string | null;
91
91
  listHandle?: string;
92
92
  totalCount?: number;
93
93
  products: ReadonlyArray<ListProduct>;
@@ -103,8 +103,8 @@ export function useProductListTracking({
103
103
  // without being torn down and rebuilt on every render; only a signature
104
104
  // change re-creates it.
105
105
  const payloadRef = useRef<{
106
- items: { productId: string | number | null | undefined; position: number }[];
107
- listId?: string | number | null;
106
+ items: { productId: string | null | undefined; position: number }[];
107
+ listId?: string | null;
108
108
  listHandle?: string;
109
109
  totalCount?: number;
110
110
  }>({ items: [] });
@@ -19,7 +19,6 @@ import {
19
19
  } from "@/src/lib/listing-search";
20
20
  import { isPreviewSearch, paginatedPath, templateSeoHead } from "@/src/lib/seo-head";
21
21
  import { getAccountRedirectUrlFn } from "@/src/server/customer";
22
- import { startCheckoutFn } from "@/src/server/checkout-redirect";
23
22
  import {
24
23
  getArticleTemplateFn,
25
24
  getBlogPageTemplateFn,
@@ -71,7 +70,6 @@ export const routeAdapter: ThemeRouteAdapter = {
71
70
  parseBlogSearch,
72
71
  },
73
72
  account: { getAccountRedirectUrlFn },
74
- checkout: { startCheckoutFn },
75
73
  // Add a `Wrapper` here if sections need to know they're in a picker preview.
76
74
  preview: { Unavailable: PreviewUnavailable },
77
75
  };
@@ -141,7 +141,7 @@ function RootComponent() {
141
141
  const { preview } = Route.useSearch();
142
142
  const { shop, i18nMessages, settings } = Route.useLoaderData();
143
143
 
144
- // The shop's PUBLISHED locales, primary first — `ShopType#locales` composes
144
+ // The shop's PUBLISHED locales, primary first — `fetchShopInfo` composes
145
145
  // it that way, and it is the same list the router's locale prefixes are
146
146
  // built from (the i18n snapshot below).
147
147
  const localeCluster = (shop?.locales ?? []).map((l: { locale: string }) => l.locale);
@@ -217,7 +217,7 @@ function RootComponent() {
217
217
  {/* The shop's locale config, inlined into <head> so the client-side
218
218
  i18n snapshot exists before hydration (the router rewrite and
219
219
  getCurrentLocale read it synchronously). `shop.locales` arrives
220
- primary-first and published-only from the storefront scope. */}
220
+ primary-first and published-only from `fetchShopInfo`. */}
221
221
  {shop && localeCluster.length > 0 && (
222
222
  <script
223
223
  dangerouslySetInnerHTML={{
@@ -4,9 +4,9 @@
4
4
  //
5
5
  // Deliberately component-less. `server.handlers` short-circuits before
6
6
  // `executeRouter`, so the root `beforeLoad` password gate never runs here —
7
- // which is exactly right: a locked shop must still answer crawlers, and Rails is
8
- // what decides the body is `Disallow: /`. Adding a `component` would silently
9
- // start 302-ing this route to `/password`.
7
+ // which is exactly right: a locked shop must still answer crawlers, and the
8
+ // api's `locked` is what makes the body `Disallow: /`. Adding a `component`
9
+ // would silently start 302-ing this route to `/password`.
10
10
  //
11
11
  // `server: { handlers: … }` is spelled out here rather than handed back by a
12
12
  // factory: `@tanstack/start-plugin-core` deletes the `server` key from the
@@ -16,12 +16,12 @@
16
16
  // BODY is what's shared, from `@shop-on/theme-routes`.
17
17
  import { createFileRoute } from "@tanstack/react-router";
18
18
  import { robotsHandler } from "@shop-on/theme-routes";
19
- import { getSeoDocument } from "@shop-on/theme-server/seo-proxy";
19
+ import { seoDocuments } from "@shop-on/theme-server/seo-documents";
20
20
 
21
21
  export const Route = createFileRoute("/robots.txt")({
22
22
  server: {
23
23
  handlers: {
24
- GET: robotsHandler({ getSeoDocument }),
24
+ GET: robotsHandler(seoDocuments),
25
25
  },
26
26
  },
27
27
  });
@@ -1,5 +1,6 @@
1
- // `/sitemap.xml` — the index and every chunk off `?kind=&page=`, proxied from
2
- // Rails. Component-less for the same reason as `robots[.]txt.tsx`.
1
+ // `/sitemap.xml` — the index and every file off `?kind=&page=`, written by
2
+ // theme-server from the api's facts. Component-less for the same reason as
3
+ // `robots[.]txt.tsx`.
3
4
  //
4
5
  // `server: { handlers: … }` is spelled out here rather than handed back by a
5
6
  // factory: `@tanstack/start-plugin-core` deletes the `server` key from the
@@ -9,12 +10,12 @@
9
10
  // BODY is what's shared, from `@shop-on/theme-routes`.
10
11
  import { createFileRoute } from "@tanstack/react-router";
11
12
  import { sitemapHandler } from "@shop-on/theme-routes";
12
- import { getSeoDocument } from "@shop-on/theme-server/seo-proxy";
13
+ import { seoDocuments } from "@shop-on/theme-server/seo-documents";
13
14
 
14
15
  export const Route = createFileRoute("/sitemap.xml")({
15
16
  server: {
16
17
  handlers: {
17
- GET: sitemapHandler({ getSeoDocument }),
18
+ GET: sitemapHandler(seoDocuments),
18
19
  },
19
20
  },
20
21
  });
@@ -1,12 +1,17 @@
1
1
  import { createFileRoute } from "@tanstack/react-router";
2
- import { checkoutRouteOptions } from "@shop-on/theme-routes";
3
- import { routeAdapter } from "@/src/route-adapter";
4
-
5
- // The cart → checkout bounce, via checkout's `/begin` on the first visit. See
6
- // docs/theme-cart.md#checkout-handoff.
7
- const { validateSearch, beforeLoad } = checkoutRouteOptions(routeAdapter.checkout);
8
2
 
3
+ // The cart → checkout hand-off (docs/account-checkout-handoff.md): a server
4
+ // route, so its answer can be the form that POSTs the checkout token to the
5
+ // checkout app, never a URL holding it. The node-only body is
6
+ // `@shop-on/theme-server/checkout`, imported inside the handler. `server` is an
7
+ // object literal so the client build drops it (see `customer_logout.tsx`).
9
8
  export const Route = createFileRoute("/{-$locale}/checkout")({
10
- validateSearch,
11
- beforeLoad,
9
+ server: {
10
+ handlers: {
11
+ GET: async ({ request, params }) => {
12
+ const { handleCheckoutGet } = await import("@shop-on/theme-server/checkout");
13
+ return handleCheckoutGet(request, { locale: params.locale });
14
+ },
15
+ },
16
+ },
12
17
  });
@@ -2,7 +2,7 @@ import { createFileRoute } from "@tanstack/react-router";
2
2
  import { collectionsIndexRouteOptions, templatePageComponent } from "@shop-on/theme-routes";
3
3
  import { routeAdapter } from "@/src/route-adapter";
4
4
 
5
- // Collections list. `?after=` is an opaque cursor loader dep.
5
+ // Collections list. `?page=` is a loader dep.
6
6
  const { staticData, loaderDeps, loader, head } = collectionsIndexRouteOptions(routeAdapter);
7
7
  const component = templatePageComponent(routeAdapter);
8
8
 
@@ -11,11 +11,11 @@ const trackProductClicked = vi.fn();
11
11
  const trackProductListViewed = vi.fn();
12
12
  vi.mock("@shop-on/theme-react/analytics", () => ({
13
13
  ensureVisit,
14
- toInt: (value: unknown) => Number.parseInt(String(value), 10),
15
14
  track,
16
15
  trackProductClicked,
17
16
  trackProductListViewed,
18
17
  trackSearchSubmitted: vi.fn(),
18
+ wireIdOf: (value: string | null | undefined) => value ?? null,
19
19
  }));
20
20
  // The real `Link` needs a router; a plain anchor is what it renders anyway.
21
21
  vi.mock("@/src/snippets/link", () => ({
@@ -25,13 +25,25 @@ vi.mock("@/src/snippets/link", () => ({
25
25
  const { default: MainCollection } = await import("./main-collection");
26
26
 
27
27
  const collectionData = {
28
- id: "7",
28
+ id: "collection_01h455vb4pex5vsknk084sn02q",
29
29
  handle: "all",
30
30
  title: "All",
31
31
  total_count: 2,
32
32
  products: [
33
- { id: "11", handle: "a", title: "A", price: { amount: 1000, currencyCode: "MNT" }, media: [] },
34
- { id: "12", handle: "b", title: "B", price: { amount: 2000, currencyCode: "MNT" }, media: [] },
33
+ {
34
+ id: "prod_01h455vb4pex5vsknk084sn0aa",
35
+ handle: "a",
36
+ title: "A",
37
+ price: { amount: 1000, currencyCode: "MNT" },
38
+ media: [],
39
+ },
40
+ {
41
+ id: "prod_01h455vb4pex5vsknk084sn0bb",
42
+ handle: "b",
43
+ title: "B",
44
+ price: { amount: 2000, currencyCode: "MNT" },
45
+ media: [],
46
+ },
35
47
  ],
36
48
  } as unknown as CollectionPageData;
37
49
 
@@ -63,16 +75,18 @@ afterEach(() => {
63
75
 
64
76
  it("reports a click-through from a product card", async () => {
65
77
  await render(<MainCollection collectionData={collectionData} />);
66
- const link = container.querySelector<HTMLAnchorElement>('[data-product-id="12"] a');
78
+ const link = container.querySelector<HTMLAnchorElement>(
79
+ '[data-product-id="prod_01h455vb4pex5vsknk084sn0bb"] a',
80
+ );
67
81
  expect(link?.getAttribute("href")).toBe("/products/b");
68
82
 
69
83
  link?.dispatchEvent(new MouseEvent("click", { bubbles: true, cancelable: true }));
70
84
 
71
85
  expect(trackProductClicked).toHaveBeenCalledWith({
72
- productId: "12",
86
+ productId: "prod_01h455vb4pex5vsknk084sn0bb",
73
87
  productHandle: "b",
74
88
  listType: "collection",
75
- listId: "7",
89
+ listId: "collection_01h455vb4pex5vsknk084sn02q",
76
90
  position: 1,
77
91
  });
78
92
  });
@@ -9,8 +9,8 @@ import config from "../../theme.config.json";
9
9
  // default-language copy. `check:locales` compares keys file by file and cannot
10
10
  // see it.
11
11
  //
12
- // `INSTALL_ID` is read at import, and with one set the merchant's overrides
13
- // would be fetched over the shipped copy — pin it empty before importing.
12
+ // With an `INSTALL_ID` set, the merchant's overrides would be read over the
13
+ // shipped copy — pin it empty.
14
14
  vi.stubEnv("INSTALL_ID", "");
15
15
  const { getMessagesForLocale } = await import("./i18n.server");
16
16
 
@@ -1,5 +1,5 @@
1
1
  import type { AbstractIntlMessages } from "@shop-on/i18n";
2
- import { applyCatalogOverrides, fetchThemeContent } from "@shop-on/theme-server/translations";
2
+ import { themeStrings } from "@shop-on/theme-server/translations";
3
3
  import type { Locale } from "@/src/lib/i18n";
4
4
 
5
5
  // The theme's own strings — every word a buyer reads that the merchant did not
@@ -19,23 +19,11 @@ const SHIPPED: Partial<Record<Locale, AbstractIntlMessages>> = Object.fromEntrie
19
19
 
20
20
  const DEFAULT_MESSAGES = SHIPPED.en!;
21
21
 
22
- const INSTALL_ID = process.env.INSTALL_ID || "";
23
-
22
+ // The merchant's `strings` rows for the locale, from admin → Translations, laid
23
+ // over the shipped catalog. The primary locale's are included: those reword the
24
+ // theme's own copy ("Add to cart" → "Add to bag"), which is why this is a read
25
+ // and not just a bundled import. With no install (local `pnpm dev`) or a failed
26
+ // read, the shipped catalog as it is: default-language copy beats a 500.
24
27
  export async function getMessagesForLocale(locale: Locale): Promise<AbstractIntlMessages> {
25
- const base = SHIPPED[locale] ?? DEFAULT_MESSAGES;
26
- // Local `pnpm dev` has no install identity and often no backend — serve the
27
- // shipped catalog rather than failing the root loader over it.
28
- if (!INSTALL_ID) return base;
29
-
30
- try {
31
- // The merchant's `locale_content` rows for the active locale, from admin →
32
- // Translations. Primary-locale rows are included: those are overrides of the
33
- // theme's own default copy ("Add to cart" → "Add to bag"), which is why this
34
- // is a fetch and not just a bundled import.
35
- const rows = await fetchThemeContent(INSTALL_ID, locale, { type: "LOCALE_CONTENT" });
36
- return applyCatalogOverrides(base, rows) as AbstractIntlMessages;
37
- } catch {
38
- // Transient API failure: a page in default-language copy beats a 500.
39
- return base;
40
- }
28
+ return themeStrings(SHIPPED[locale] ?? DEFAULT_MESSAGES, locale);
41
29
  }
@@ -149,7 +149,6 @@ interface TemplateRequestInput {
149
149
  collectionHandle?: string;
150
150
  variantId?: string;
151
151
  previewTemplate?: string;
152
- after?: string;
153
152
  tag?: string;
154
153
  q?: string;
155
154
  page?: number;
@@ -25,8 +25,8 @@ export const CONFIG_DIR = process.env.CONFIG_DIR || DEV_CONFIG_DIR;
25
25
  export const loaderConfig: ThemeLoaderConfig = {
26
26
  orchestratorUrl: process.env.ORCHESTRATOR_URL || "http://localhost:4100",
27
27
  // Both empty on a plain `vite dev`, which is what disables the preview path
28
- // (and, for INSTALL_ID, the merchant translation overlays) rather than
29
- // pointing them at a store that isn't there.
28
+ // rather than pointing it at a store that isn't there. (An empty INSTALL_ID
29
+ // also leaves the merchant's translations unread: theme-server's own read.)
30
30
  storeSlug: process.env.STORE_SLUG || "",
31
31
  installId: process.env.INSTALL_ID || "",
32
32
  configDir: CONFIG_DIR,
@@ -15,13 +15,6 @@
15
15
  "isolatedModules": true,
16
16
  "jsx": "react-jsx",
17
17
  "incremental": true,
18
- "plugins": [
19
- {
20
- "name": "gql.tada/ts-plugin",
21
- "schema": "./node_modules/@shop-on/theme-server/dist/schema.storefront.graphql",
22
- "tadaOutputLocation": "src/server/graphql-env.d.ts"
23
- }
24
- ],
25
18
  "paths": {
26
19
  "@/*": ["./*"]
27
20
  }
@@ -1,21 +0,0 @@
1
- // Server-side cart→checkout bounce. The cart-cookie read + `cartCheckout` call
2
- // + result mapping live in the shared `@shop-on/theme-server/checkout` helper;
3
- // this forwards the buyer token so a signed-in checkout arrives prefilled
4
- // (anonymous buyers forward nothing). The node-only helpers are dynamic-
5
- // imported inside the handler so this module stays safe to import from the
6
- // client-side `/checkout` route.
7
- import { createServerFn } from "@tanstack/react-start";
8
- import type { CheckoutHandoffResult } from "@shop-on/theme-server/checkout";
9
-
10
- export type { CheckoutHandoffResult };
11
-
12
- // `state` is the `checkout_state` checkout's `/begin` sent back; without one the
13
- // result is the `/begin` URL itself (what a browser-side caller gets).
14
- export const startCheckoutFn = createServerFn({ method: "POST" })
15
- .validator((data: { state?: string } | undefined) => ({ state: data?.state }))
16
- .handler(async ({ data }): Promise<CheckoutHandoffResult> => {
17
- const { readCustomerSession } = await import("@shop-on/theme-server/customer-session");
18
- const { startCheckoutHandoff } = await import("@shop-on/theme-server/checkout");
19
- const session = await readCustomerSession();
20
- return startCheckoutHandoff({ state: data.state, customerToken: session?.token });
21
- });