@shop-on/create-theme 0.11.1 → 0.13.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/dist/LICENSE.md +2 -2
- package/package.json +1 -1
- package/template/.claude/skills/theme-dev/recipes/custom-sections.md +2 -0
- package/template/LICENSE.md +2 -2
- package/template/package.json +10 -10
- package/template/src/blocks/custom-item.json +5 -0
- package/template/src/blocks/custom-item.test.ts +18 -0
- package/template/src/blocks/custom-item.tsx +9 -0
- package/template/src/locales/en.default.schema.json +2 -1
- package/template/src/locales/mn.default.schema.json +2 -1
- package/template/src/sections/custom-section.json +1 -0
- package/template/src/start.ts +8 -2
package/dist/LICENSE.md
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
#
|
|
1
|
+
# ShopOn Theme Development License
|
|
2
2
|
|
|
3
3
|
Copyright (c) 2026 Cody LLC. All rights reserved except as granted below.
|
|
4
4
|
|
|
5
5
|
"The Software" is this package, its source, and its documentation. "The
|
|
6
|
-
Platform" is
|
|
6
|
+
Platform" is ShopOn, the commerce platform operated by Cody LLC.
|
|
7
7
|
|
|
8
8
|
## 1. Grant
|
|
9
9
|
|
package/package.json
CHANGED
|
@@ -16,6 +16,7 @@ An instance carries a `definition` field next to its `settings`: `{ settings: Sc
|
|
|
16
16
|
| Section shell: width + padding settings | `src/sections/custom-section.json` |
|
|
17
17
|
| Draws the finished HTML, or the editor's error | `src/sections/custom-section.tsx` |
|
|
18
18
|
| Block (no settings, no shell) | `src/blocks/custom-block.{json,tsx}` |
|
|
19
|
+
| A custom section's items (renders nothing) | `src/blocks/custom-item.{json,tsx}` |
|
|
19
20
|
| The render pass | `loadTemplate` in `src/server/settings.ts` |
|
|
20
21
|
| The section that takes custom blocks | `main-product` (`"blocks": [{ "type": "custom-block" }]`) |
|
|
21
22
|
| How the AI should style for this theme | `## Custom sections` in `src/ai/guide.md` |
|
|
@@ -27,6 +28,7 @@ An instance carries a `definition` field next to its `settings`: `{ settings: Sc
|
|
|
27
28
|
- **Render through `CustomSectionHtml`, never anything else.** Not a bare `dangerouslySetInnerHTML`, and never a Custom HTML snippet that re-activates `<script>` tags: AI-written markup must never run one. `CustomSectionHtml` doesn't activate scripts, and it hands same-origin link clicks to the router, so internal links navigate client-side and keep the editor's preview.
|
|
28
29
|
- **Empty renders nothing.** `customHtml` is `""` when there is nothing to draw, and the section returns `null` so it takes no space. `customError` exists only in editor preview, since the pass writes it only when the request carries an editor `sid`.
|
|
29
30
|
- **The block declares no settings at all**: every setting it has comes from its definition. It has no shell either. The section around it owns width and spacing, and the base ids read as `nil` inside a block.
|
|
31
|
+
- **Items are `custom-item` blocks, and the component draws nothing.** A custom section's repeatable content (questions, team members) is items, each of a kind its definition declares. The template reads them as `section.blocks`, and the pass deletes them from the section before it renders, so `custom-item.tsx` returns `null`. It exists so an item that slips past the pass renders nothing instead of failing on an unregistered type. The section and the item both list `{ "type": "custom-item" }` and nothing else; `custom-item.test.ts` pins that. Delete `custom-item` and the theme's custom sections hold no items.
|
|
30
32
|
- **The pass runs after `runEnrichment`.** The enrichment's last phase re-scans string settings, so rendered HTML has to land after it. If you add a Custom Liquid pass, run this one after that too. Keep the `import()` dynamic, so liquidjs stays out of the client bundle. A page with no custom section loads neither liquidjs nor the validator.
|
|
31
33
|
- **`localizePath` only takes a locale the shop serves.** `req.locale` is server-fn input, and a crafted one would turn a site path into another host's (`//evil.example/…`). That's what the `isValidLocale` guard is for.
|
|
32
34
|
|
package/template/LICENSE.md
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
#
|
|
1
|
+
# ShopOn Theme Development License
|
|
2
2
|
|
|
3
3
|
Copyright (c) 2026 Cody LLC. All rights reserved except as granted below.
|
|
4
4
|
|
|
5
5
|
"The Software" is this package, its source, and its documentation. "The
|
|
6
|
-
Platform" is
|
|
6
|
+
Platform" is ShopOn, the commerce platform operated by Cody LLC.
|
|
7
7
|
|
|
8
8
|
## 1. Grant
|
|
9
9
|
|
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.13.0",
|
|
21
|
+
"@shop-on/theme-contract": "^0.13.0",
|
|
22
|
+
"@shop-on/theme-loader": "^0.13.0",
|
|
23
|
+
"@shop-on/theme-react": "^0.13.0",
|
|
24
|
+
"@shop-on/theme-routes": "^0.13.0",
|
|
25
|
+
"@shop-on/theme-runtime": "^0.13.0",
|
|
26
|
+
"@shop-on/theme-server": "^0.13.0",
|
|
27
|
+
"@shop-on/theme-system": "^0.13.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.
|
|
39
|
-
"@shop-on/theme-dev-host": "^0.
|
|
38
|
+
"@shop-on/theme-config": "^0.13.0",
|
|
39
|
+
"@shop-on/theme-dev-host": "^0.13.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",
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { CUSTOM_ITEM_TYPE } from "@shop-on/theme-contract";
|
|
2
|
+
import { expect, it } from "vitest";
|
|
3
|
+
import customSection from "../sections/custom-section.json";
|
|
4
|
+
import schema from "./custom-item.json";
|
|
5
|
+
|
|
6
|
+
// An item's settings are the ones its kind declares in the section's
|
|
7
|
+
// `definition`: any setting here could clash with a declared one.
|
|
8
|
+
it("declares no settings of its own", () => {
|
|
9
|
+
expect(schema.settings).toEqual([]);
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
// Items sit in a custom section and, one level down, in each other (a topic
|
|
13
|
+
// holding its questions). The editor tools offer items only on a theme
|
|
14
|
+
// version whose custom section lists this type.
|
|
15
|
+
it("is the one block a custom section and an item take", () => {
|
|
16
|
+
expect(customSection.blocks).toEqual([{ type: CUSTOM_ITEM_TYPE }]);
|
|
17
|
+
expect(schema.blocks).toEqual([{ type: CUSTOM_ITEM_TYPE }]);
|
|
18
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// An item of a custom section (a question, a team member, a step), of a kind
|
|
2
|
+
// the section's `definition` declares. The section's template reads its items
|
|
3
|
+
// as `section.blocks` on the server, and the custom-section pass deletes them
|
|
4
|
+
// from the section before the page renders, so this never draws anything. It
|
|
5
|
+
// is registered so an item that slips past the pass renders nothing instead
|
|
6
|
+
// of failing the page on an unregistered block type.
|
|
7
|
+
export default function CustomItem() {
|
|
8
|
+
return null;
|
|
9
|
+
}
|
package/template/src/start.ts
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import { createStart } from "@tanstack/react-start";
|
|
2
2
|
import { storefrontActivityMiddleware } from "@shop-on/theme-server/activity";
|
|
3
3
|
import { storefrontAvailabilityMiddleware } from "@shop-on/theme-server/availability";
|
|
4
|
+
import { storefrontCsrfMiddleware } from "@shop-on/theme-server/server-fn-csrf";
|
|
4
5
|
|
|
5
6
|
// Order matters: the activity middleware answers `/health` before the
|
|
6
|
-
// availability check can turn a closed store's probe into a 503.
|
|
7
|
+
// availability check can turn a closed store's probe into a 503. The CSRF
|
|
8
|
+
// check is listed because a `start.ts` with its own middleware drops Start's.
|
|
7
9
|
export const startInstance = createStart(() => ({
|
|
8
|
-
requestMiddleware: [
|
|
10
|
+
requestMiddleware: [
|
|
11
|
+
storefrontActivityMiddleware,
|
|
12
|
+
storefrontAvailabilityMiddleware,
|
|
13
|
+
storefrontCsrfMiddleware,
|
|
14
|
+
],
|
|
9
15
|
}));
|