@tanqory/partner-cli 0.0.0-stage → 0.1.0-alpha.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.
Files changed (53) hide show
  1. package/LICENSE +21 -0
  2. package/bin/tanqory-partner.mjs +10 -0
  3. package/config/mirror-allowlist.json +17 -0
  4. package/config/theme-licences.json +108 -0
  5. package/config/third-party-toolchains.json +45 -0
  6. package/lib/api.mjs +109 -0
  7. package/lib/auth.mjs +211 -0
  8. package/lib/check.mjs +63 -0
  9. package/lib/cli.mjs +217 -0
  10. package/lib/mcp.mjs +177 -0
  11. package/lib/ops.mjs +179 -0
  12. package/lib/theme.mjs +121 -0
  13. package/lib/vendor/partner-checks.cjs +1617 -0
  14. package/package.json +59 -4
  15. package/starter/LICENSE +18 -0
  16. package/starter/README.md +38 -0
  17. package/starter/config/settings.json +3 -0
  18. package/starter/gitignore +3 -0
  19. package/starter/locales/en.json +22 -0
  20. package/starter/locales/th.json +22 -0
  21. package/starter/package.json +29 -0
  22. package/starter/regions/footer.json +35 -0
  23. package/starter/regions/header.json +13 -0
  24. package/starter/scripts/build.mjs +195 -0
  25. package/starter/scripts/probe.ts +4 -0
  26. package/starter/src/bundle.ts +15 -0
  27. package/starter/src/components/parts.tsx +32 -0
  28. package/starter/src/entry.client.tsx +6 -0
  29. package/starter/src/entry.server.tsx +13 -0
  30. package/starter/src/sections/chrome.tsx +132 -0
  31. package/starter/src/sections/commerce.tsx +242 -0
  32. package/starter/src/sections/content.tsx +111 -0
  33. package/starter/src/sections/editorial.tsx +107 -0
  34. package/starter/src/settings.ts +15 -0
  35. package/starter/src/styles/theme.css +224 -0
  36. package/starter/src/templates.ts +14 -0
  37. package/starter/src/theme.tsx +76 -0
  38. package/starter/templates/404.json +14 -0
  39. package/starter/templates/account.json +14 -0
  40. package/starter/templates/article.json +14 -0
  41. package/starter/templates/blog.json +14 -0
  42. package/starter/templates/cart.json +14 -0
  43. package/starter/templates/collection.json +14 -0
  44. package/starter/templates/index.json +36 -0
  45. package/starter/templates/page.contact.json +18 -0
  46. package/starter/templates/page.json +14 -0
  47. package/starter/templates/product.json +18 -0
  48. package/starter/templates/search.json +14 -0
  49. package/starter/tsconfig.json +17 -0
  50. package/starter/vite.client.config.ts +17 -0
  51. package/starter/vite.probe.config.ts +16 -0
  52. package/starter/vite.server.config.ts +32 -0
  53. package/README.md +0 -3
package/package.json CHANGED
@@ -1,6 +1,61 @@
1
1
  {
2
2
  "name": "@tanqory/partner-cli",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0-alpha.0",
4
+ "description": "Build, check and upload Tanqory partner themes: a starter that passes every partner check, the platform's own partner source checks run locally, packaging, upload through the Partner API with your partner sign-in, and an MCP server with the same operations.",
5
+ "license": "MIT",
6
+ "author": "Tanqory",
7
+ "keywords": [
8
+ "tanqory",
9
+ "theme",
10
+ "partner",
11
+ "cli",
12
+ "mcp",
13
+ "model-context-protocol"
14
+ ],
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "git+https://github.com/tanqory/tanqory-platform-v2.git",
18
+ "directory": "packages/partner-cli"
19
+ },
20
+ "type": "module",
21
+ "bin": {
22
+ "tanqory-partner": "./bin/tanqory-partner.mjs"
23
+ },
24
+ "exports": {
25
+ ".": "./lib/ops.mjs",
26
+ "./mcp": "./lib/mcp.mjs",
27
+ "./package.json": "./package.json"
28
+ },
29
+ "files": [
30
+ "bin",
31
+ "lib",
32
+ "config",
33
+ "starter",
34
+ "README.md",
35
+ "LICENSE"
36
+ ],
37
+ "engines": {
38
+ "node": ">=20.11.0"
39
+ },
40
+ "dependencies": {
41
+ "@tanqory/theme-abi": "2.0.0-alpha.14",
42
+ "acorn": "^8.15.0",
43
+ "acorn-walk": "^8.3.4",
44
+ "tar": "^7.5.2",
45
+ "yaml": "^2.9.1",
46
+ "zod": "^3.25.76"
47
+ },
48
+ "devDependencies": {
49
+ "esbuild": "0.28.2"
50
+ },
51
+ "scripts": {
52
+ "prepare:vendor": "node scripts/prepare.mjs",
53
+ "check:vendor": "node scripts/prepare.mjs --check",
54
+ "test": "node --test test/*.test.mjs"
55
+ },
56
+ "publishConfig": {
57
+ "access": "public",
58
+ "registry": "https://registry.npmjs.org/",
59
+ "tag": "next"
60
+ }
61
+ }
@@ -0,0 +1,18 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 the author of this theme
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
6
+ documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
7
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
8
+ persons to whom the Software is furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
11
+ Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
14
+ WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
15
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16
+ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17
+
18
+ Third-party software this theme runs on: @tanqory/theme-kit (MIT) and React (MIT).
@@ -0,0 +1,38 @@
1
+ # Tanqory partner theme starter
2
+
3
+ A small, plain theme for Tanqory stores on Theme Runtime ABI v2 and `@tanqory/theme-kit/headless`. It passes every
4
+ partner check as it is, so you start from a green version and keep it green.
5
+
6
+ ```sh
7
+ npm install -g @tanqory/partner-cli@next
8
+ tanqory-partner theme init my-theme
9
+ cd my-theme && npm install
10
+ tanqory-partner theme check # build, then the partner checks that need no sandbox
11
+ tanqory-partner theme package # dist/partner/<name>-<version>.tgz and manifest.json
12
+ tanqory-partner login
13
+ tanqory-partner theme push --org <organization id> --theme <handle>
14
+ ```
15
+
16
+ ## What is here
17
+
18
+ | Path | What it is |
19
+ |---|---|
20
+ | `src/theme.tsx` | `defineTheme`: the sections list and the layout |
21
+ | `src/sections/*.tsx` | Header, footer, home sections, product, collection, cart, search, page, blog, account, 404 |
22
+ | `src/components/`, `src/styles/` | Your markup and all of the theme's CSS (the kit ships none) |
23
+ | `src/settings.ts`, `src/templates.ts` | Theme settings (the editor's Theme panel) and the page types |
24
+ | `templates/*.json`, `regions/*.json`, `config/settings.json` | Starter content a merchant sees first |
25
+ | `locales/en.json`, `locales/th.json` | Every visible string |
26
+ | `scripts/build.mjs`, `vite.*.config.ts`, `src/entry.*`, `src/bundle.ts` | The build into `dist/abi` (the platform runs this same build in its sandbox) |
27
+ | `LICENSE` | Your theme's licence. Put your name in it. The licences check needs it. |
28
+
29
+ ## Rules the checks hold you to
30
+
31
+ - `package.json` pins `@tanqory/theme-kit` and `@tanqory/theme-abi` exactly to versions the platform's builder
32
+ carries. Other runtime dependencies are not installed by the builder; bundle what you need into `src/`.
33
+ - No `pnpm.overrides`, `resolutions`, workspaces, patches, `.npmrc`, `.env` files, shell scripts or native addons.
34
+ - The uploaded source has no lockfile: `theme package` leaves `package-lock.json` and `pnpm-lock.yaml` out (the builder
35
+ never installs from one, and the licences check would list your local developer tools as shipped).
36
+ - No network calls from the theme, no `eval` or `new Function`, no other commerce platform's name in any file.
37
+ - WCAG 2.2 AA: no serious or critical axe-core violation, touch targets at least 24 by 24 px, Lighthouse accessibility
38
+ 90 or more and performance 60 or more on the home, product and collection pages.
@@ -0,0 +1,3 @@
1
+ {
2
+ "scheme": "light"
3
+ }
@@ -0,0 +1,3 @@
1
+ node_modules/
2
+ dist/
3
+ src/generated/
@@ -0,0 +1,22 @@
1
+ {
2
+ "starter.nav.main": "Main menu",
3
+ "starter.footer.menu": "More",
4
+ "starter.footer.rights": "Copyright {name}. All rights reserved.",
5
+ "starter.price.from": "From {price}",
6
+ "starter.shelf.viewAll": "View all",
7
+ "starter.shelf.empty": "Nothing on this shelf yet.",
8
+ "starter.product.missing": "This product is not available.",
9
+ "starter.collection.kicker": "Collection",
10
+ "starter.collection.none": "This collection is empty for now.",
11
+ "starter.cart.continue": "Continue shopping",
12
+ "starter.cart.view": "View cart",
13
+ "starter.cart.taxes": "Taxes and shipping are calculated at checkout.",
14
+ "starter.drawer.qty": "Qty {count}",
15
+ "starter.journal.read": "Read more",
16
+ "starter.journal.back": "Back to {blog}",
17
+ "starter.journal.by": "By {author}",
18
+ "starter.notFound.title": "Page not found",
19
+ "starter.notFound.body": "The link may be old, or the page has moved.",
20
+ "starter.notFound.home": "Back to home",
21
+ "seo.homeDescription": "{name}: shop online."
22
+ }
@@ -0,0 +1,22 @@
1
+ {
2
+ "starter.nav.main": "เมนูหลัก",
3
+ "starter.footer.menu": "เพิ่มเติม",
4
+ "starter.footer.rights": "ลิขสิทธิ์ {name} สงวนลิขสิทธิ์",
5
+ "starter.price.from": "เริ่มต้น {price}",
6
+ "starter.shelf.viewAll": "ดูทั้งหมด",
7
+ "starter.shelf.empty": "ยังไม่มีสินค้าบนชั้นนี้",
8
+ "starter.product.missing": "สินค้านี้ไม่มีจำหน่าย",
9
+ "starter.collection.kicker": "คอลเลกชัน",
10
+ "starter.collection.none": "คอลเลกชันนี้ยังไม่มีสินค้า",
11
+ "starter.cart.continue": "เลือกซื้อสินค้าต่อ",
12
+ "starter.cart.view": "ดูตะกร้า",
13
+ "starter.cart.taxes": "ภาษีและค่าจัดส่งคำนวณตอนชำระเงิน",
14
+ "starter.drawer.qty": "จำนวน {count}",
15
+ "starter.journal.read": "อ่านต่อ",
16
+ "starter.journal.back": "กลับไปที่ {blog}",
17
+ "starter.journal.by": "โดย {author}",
18
+ "starter.notFound.title": "ไม่พบหน้านี้",
19
+ "starter.notFound.body": "ลิงก์อาจเก่าแล้ว หรือหน้านี้ถูกย้ายไป",
20
+ "starter.notFound.home": "กลับหน้าแรก",
21
+ "seo.homeDescription": "{name}: ช้อปออนไลน์"
22
+ }
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "tanqory-partner-starter",
3
+ "version": "1.0.0",
4
+ "private": true,
5
+ "type": "module",
6
+ "description": "A partner theme starter for Tanqory stores (Theme Runtime ABI v2, @tanqory/theme-kit/headless). Made with `tanqory-partner theme init`; checked with `tanqory-partner theme check`; uploaded with `tanqory-partner theme push`.",
7
+ "license": "SEE LICENSE IN LICENSE",
8
+ "tanqory": {
9
+ "build": "scripts/build.mjs",
10
+ "out": "dist/abi"
11
+ },
12
+ "scripts": {
13
+ "build": "node scripts/build.mjs",
14
+ "typecheck": "tsc --noEmit"
15
+ },
16
+ "dependencies": {
17
+ "@tanqory/theme-kit": "2.0.0-alpha.17",
18
+ "react": "18.3.1",
19
+ "react-dom": "18.3.1"
20
+ },
21
+ "devDependencies": {
22
+ "@tanqory/theme-abi": "2.0.0-alpha.14",
23
+ "@types/react": "^18.3.12",
24
+ "@types/react-dom": "^18.3.1",
25
+ "@vitejs/plugin-react": "^4.3.4",
26
+ "typescript": "~5.9.3",
27
+ "vite": "^5.4.10"
28
+ }
29
+ }
@@ -0,0 +1,35 @@
1
+ {
2
+ "contentVersion": 1,
3
+ "region": "footer",
4
+ "sections": [
5
+ {
6
+ "id": "footer",
7
+ "type": "footer",
8
+ "blocks": [
9
+ {
10
+ "id": "footer-brand",
11
+ "type": "footer-brand",
12
+ "settings": {
13
+ "tagline": "Thank you for shopping with us."
14
+ }
15
+ },
16
+ {
17
+ "id": "footer-menu",
18
+ "type": "footer-menu",
19
+ "settings": {
20
+ "heading": "Explore",
21
+ "menu": "main-menu"
22
+ }
23
+ },
24
+ {
25
+ "id": "footer-menu-2",
26
+ "type": "footer-menu",
27
+ "settings": {
28
+ "heading": "Help",
29
+ "menu": "footer"
30
+ }
31
+ }
32
+ ]
33
+ }
34
+ ]
35
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "contentVersion": 1,
3
+ "region": "header",
4
+ "sections": [
5
+ {
6
+ "id": "header",
7
+ "type": "header",
8
+ "settings": {
9
+ "menu": "main-menu"
10
+ }
11
+ }
12
+ ]
13
+ }
@@ -0,0 +1,195 @@
1
+ /**
2
+ * Build the theme as a Theme ABI v2 theme directory (the layout `theme-conformance` runs and the platform's build
3
+ * service packages into an artifact):
4
+ *
5
+ * dist/abi/manifest.json ThemeManifest v2, JCS + "\n" (from the theme's declarations)
6
+ * dist/abi/server/entry.mjs render(request, ctx) + manifest: one file, no imports
7
+ * dist/abi/client/client-manifest.json every browser file with its sha256 digest and SRI; one isEntry script
8
+ * dist/abi/client/assets/* content-hashed browser files
9
+ * dist/abi/defaults/{settings.json, regions/*.json, templates/*.json}
10
+ * dist/abi/locales/<lang>.json the theme's strings over the kit's
11
+ *
12
+ * node scripts/build.mjs exit 1 on any contract problem or hard size limit
13
+ *
14
+ * Vite and every package resolve from this theme's own node_modules.
15
+ */
16
+ import { execFileSync } from 'node:child_process'
17
+ import { createRequire } from 'node:module'
18
+ import { createHash } from 'node:crypto'
19
+ import { existsSync, mkdirSync, readFileSync, readdirSync, rmSync, statSync, writeFileSync } from 'node:fs'
20
+ import { dirname, join, relative } from 'node:path'
21
+ import { fileURLToPath, pathToFileURL } from 'node:url'
22
+ import { gzipSync } from 'node:zlib'
23
+
24
+ const theme = join(dirname(fileURLToPath(import.meta.url)), '..')
25
+ const out = join(theme, 'dist', 'abi')
26
+ const require = createRequire(join(theme, 'package.json'))
27
+ const pkg = JSON.parse(readFileSync(join(theme, 'package.json'), 'utf8'))
28
+ const vitePkg = require.resolve('vite/package.json')
29
+ const vite = join(dirname(vitePkg), JSON.parse(readFileSync(vitePkg, 'utf8')).bin.vite)
30
+ const load = (spec) => import(pathToFileURL(require.resolve(spec)).href)
31
+
32
+ const { buildManifest, checkContent, withKitStrings, canonicalize } = await load('@tanqory/theme-kit/build')
33
+ const { validateManifest, validateFieldValue, PLATFORM_ROUTES } = await load('@tanqory/theme-abi')
34
+ const { LIMITS } = await load('@tanqory/theme-abi/limits')
35
+
36
+ const fail = (msg, list = []) => {
37
+ console.error(`✗ ${msg}`)
38
+ for (const l of list) console.error(` - ${l}`)
39
+ process.exit(1)
40
+ }
41
+ const readJson = (p) => JSON.parse(readFileSync(p, 'utf8'))
42
+ const writeJcs = (path, value) => {
43
+ mkdirSync(dirname(path), { recursive: true })
44
+ writeFileSync(path, `${canonicalize(value)}\n`)
45
+ }
46
+ const viteBuild = (config) => execFileSync(process.execPath, [vite, 'build', '--config', config, '--logLevel', 'warn'], { cwd: theme, stdio: 'inherit' })
47
+
48
+ // The kit's browser wire uses the contract's two prefixes.
49
+ if (PLATFORM_ROUTES.data !== '/_tq/data/' || PLATFORM_ROUTES.actions !== '/_tq/actions/') fail('PLATFORM_ROUTES changed: update @tanqory/theme-kit')
50
+
51
+ // Registry 2 (Appendix B.2): image/video may name a shipped `asset:client/assets/<file>`; text_alignment adds start/end.
52
+ const ASSET = /^asset:client\/assets\/([A-Za-z0-9._-]+)$/
53
+ const assetDir = join(theme, 'assets')
54
+ const shipped = new Set(existsSync(assetDir) ? readdirSync(assetDir) : [])
55
+ const checkValue = (type, value, spec) => {
56
+ if (type === 'text_alignment' && (value === 'start' || value === 'end')) return { ok: true }
57
+ if ((type === 'image' || type === 'video') && typeof value === 'string' && value.startsWith('asset:')) {
58
+ const m = ASSET.exec(value)
59
+ return m && shipped.has(m[1]) ? { ok: true } : { ok: false, errors: [{ message: `${value} is not a file under assets/`, code: 'asset_ref_missing' }] }
60
+ }
61
+ return validateFieldValue(type, value, spec)
62
+ }
63
+
64
+ // 1. the theme's declarations, loaded in Node
65
+ viteBuild('vite.probe.config.ts')
66
+ const probe = await import(pathToFileURL(join(theme, 'dist', '.probe', 'probe.mjs')).href)
67
+
68
+ // 2. the manifest + starter content, every stored value checked
69
+ const { manifest, problems } = buildManifest({
70
+ name: pkg.name,
71
+ version: pkg.version,
72
+ theme: probe.theme,
73
+ settings: probe.settings,
74
+ templates: probe.TEMPLATES,
75
+ forms: { newsletter: true, contact: true },
76
+ // Stock counts on the product page ("Only 3 left").
77
+ capabilities: { server: ['data:inventory'], browser: ['data:inventory'] },
78
+ checkValue,
79
+ })
80
+ const templates = {}
81
+ for (const f of readdirSync(join(theme, 'templates')).filter((n) => n.endsWith('.json')).sort()) {
82
+ const name = f.replace(/\.json$/, '')
83
+ if (!probe.TEMPLATES[name]) problems.push(`templates/${f}: not in src/templates.ts`)
84
+ const doc = readJson(join(theme, 'templates', f))
85
+ if (doc.template !== name) problems.push(`templates/${f}: "template" must be "${name}"`)
86
+ for (const [rid, r] of Object.entries(doc.regions ?? {})) problems.push(...checkContent(`templates/${f}.regions.${rid}`, r.sections ?? [], manifest, checkValue))
87
+ templates[name] = doc
88
+ }
89
+ for (const name of Object.keys(probe.TEMPLATES)) if (!templates[name]) problems.push(`templates/${name}.json is missing`)
90
+ const regions = {}
91
+ for (const r of ['header', 'footer']) {
92
+ const doc = readJson(join(theme, 'regions', `${r}.json`))
93
+ problems.push(...checkContent(`regions/${r}.json`, doc.sections ?? [], manifest, checkValue))
94
+ regions[r] = doc
95
+ }
96
+ const values = readJson(join(theme, 'config', 'settings.json'))
97
+ const specs = new Map(manifest.settingsSchema.flatMap((g) => g.items.map((it) => [it.key, it])))
98
+ for (const [k, v] of Object.entries(values)) {
99
+ const spec = specs.get(k)
100
+ if (!spec) problems.push(`config/settings.json.${k}: not a theme setting`)
101
+ else {
102
+ const r = checkValue(spec.type, v, spec)
103
+ if (!r.ok) problems.push(`config/settings.json.${k}: ${r.errors.map((e) => e.message).join('; ')}`)
104
+ }
105
+ }
106
+ const valid = validateManifest(manifest)
107
+ if (!valid.ok) for (const e of valid.errors) problems.push(`manifest${e.path}: ${e.message} (${e.code ?? e.keyword})`)
108
+ if (problems.length) fail(`${problems.length} contract problem(s)`, problems)
109
+
110
+ // 3. strings: the theme's over the kit's, for the bundle and for the artifact
111
+ const locales = {}
112
+ for (const f of readdirSync(join(theme, 'locales')).filter((n) => n.endsWith('.json'))) locales[f.replace(/\.json$/, '')] = readJson(join(theme, 'locales', f))
113
+ const merged = withKitStrings(locales)
114
+ const gen = join(theme, 'src', 'generated')
115
+ rmSync(gen, { recursive: true, force: true })
116
+ for (const [lang, map] of Object.entries(merged)) writeJcs(join(gen, 'locales', `${lang}.json`), map)
117
+ writeJcs(join(gen, 'manifest.json'), manifest)
118
+
119
+ // 4. the browser bundle, then the serve entry (which imports the generated manifest)
120
+ rmSync(out, { recursive: true, force: true })
121
+ viteBuild('vite.client.config.ts')
122
+ viteBuild('vite.server.config.ts')
123
+
124
+ // 5. the theme directory
125
+ mkdirSync(join(out, 'server'), { recursive: true })
126
+ writeFileSync(join(out, 'server', 'entry.mjs'), readFileSync(join(theme, 'dist', 'build', 'server', 'entry.mjs')))
127
+ writeJcs(join(out, 'manifest.json'), manifest)
128
+ const built = join(theme, 'dist', 'build', 'client')
129
+ const clientDir = join(out, 'client')
130
+ const viteManifest = readJson(join(built, '.vite', 'manifest.json'))
131
+ const files = []
132
+ const walk = (dir) => {
133
+ for (const name of readdirSync(dir)) {
134
+ const p = join(dir, name)
135
+ if (statSync(p).isDirectory()) {
136
+ if (name !== '.vite') walk(p)
137
+ } else files.push(relative(built, p).split('\\').join('/'))
138
+ }
139
+ }
140
+ walk(built)
141
+ for (const f of shipped) files.push(`assets/${f}`)
142
+ const source = (f) => (f.startsWith('assets/') && shipped.has(f.slice(7)) && !existsSync(join(built, f)) ? join(assetDir, f.slice(7)) : join(built, f))
143
+ const kindOf = (f) => (/\.m?js$/.test(f) ? 'script' : /\.css$/.test(f) ? 'style' : /\.(woff2?|ttf|otf)$/.test(f) ? 'font' : /\.(png|jpe?g|gif|svg|webp|avif|ico)$/.test(f) ? 'image' : 'other')
144
+ const entryKey = Object.keys(viteManifest).find((k) => viteManifest[k].isEntry)
145
+ if (!entryKey) fail('vite produced no entry chunk')
146
+ const importsOf = (key, seen = new Set()) => {
147
+ for (const imp of viteManifest[key]?.imports ?? []) if (!seen.has(imp)) importsOf(imp, seen.add(imp))
148
+ return seen
149
+ }
150
+ const entryImports = [...importsOf(entryKey)].map((k) => viteManifest[k].file)
151
+ const entryCss = [...new Set([entryKey, ...importsOf(entryKey)].flatMap((k) => viteManifest[k].css ?? []))]
152
+ const clientManifest = {}
153
+ for (const f of [...new Set(files)].sort()) {
154
+ const bytes = readFileSync(source(f))
155
+ mkdirSync(dirname(join(clientDir, f)), { recursive: true })
156
+ writeFileSync(join(clientDir, f), bytes)
157
+ const sha = createHash('sha256').update(bytes).digest()
158
+ const isEntry = f === viteManifest[entryKey].file
159
+ clientManifest[isEntry ? 'main' : f] = {
160
+ file: f,
161
+ kind: kindOf(f),
162
+ ...(isEntry ? { isEntry: true, css: entryCss, imports: entryImports } : {}),
163
+ size: bytes.length,
164
+ digest: `sha256:${sha.toString('hex')}`,
165
+ integrity: `sha256-${sha.toString('base64')}`,
166
+ }
167
+ }
168
+ writeJcs(join(clientDir, 'client-manifest.json'), clientManifest)
169
+ writeJcs(join(out, 'defaults', 'settings.json'), { contentVersion: manifest.contentVersion, values })
170
+ for (const [name, doc] of Object.entries(regions)) writeJcs(join(out, 'defaults', 'regions', `${name}.json`), doc)
171
+ for (const [name, doc] of Object.entries(templates)) writeJcs(join(out, 'defaults', 'templates', `${name}.json`), doc)
172
+ for (const [lang, map] of Object.entries(merged)) writeJcs(join(out, 'locales', `${lang}.json`), map)
173
+ // the theme's licence (the licences check reads dist/abi/LICENSE)
174
+ writeFileSync(join(out, 'LICENSE'), readFileSync(join(theme, 'LICENSE')))
175
+
176
+ // 6. sizes against the limits table (§8): over budget warns, over hard fails
177
+ const entry = readFileSync(join(out, 'server', 'entry.mjs'))
178
+ const gz = (b) => gzipSync(b, { level: 9 }).length
179
+ const initial = [viteManifest[entryKey].file, ...entryImports, ...entryCss].reduce((n, f) => n + gz(readFileSync(join(clientDir, f))), 0)
180
+ const rows = [
181
+ ['ssrEntryRawBytes', entry.length],
182
+ ['ssrEntryGzipBytes', gz(entry)],
183
+ ['manifestBytes', readFileSync(join(out, 'manifest.json')).length],
184
+ ['clientInitialGzipBytes', initial],
185
+ ['clientTotalRawBytes', files.reduce((n, f) => n + statSync(join(clientDir, f)).size, 0)],
186
+ ]
187
+ let over = false
188
+ for (const [k, v] of rows) {
189
+ const { budget, hard } = LIMITS[k]
190
+ const verdict = v > hard ? 'OVER HARD' : budget !== null && v > budget ? 'over budget' : 'ok'
191
+ if (v > hard) over = true
192
+ console.log(`${k.padEnd(24)} ${String(v).padStart(10)} budget ${String(budget).padStart(10)} hard ${String(hard).padStart(10)} ${verdict}`)
193
+ }
194
+ if (over) fail('a hard size limit is exceeded')
195
+ console.log(`✓ ${relative(process.cwd(), out) || out}`)
@@ -0,0 +1,4 @@
1
+ /** The theme's declarations, for the build (bundled by vite.probe.config.ts and imported in Node). */
2
+ export { default as theme } from '../src/theme'
3
+ export { settings } from '../src/settings'
4
+ export { TEMPLATES } from '../src/templates'
@@ -0,0 +1,15 @@
1
+ /** What the kit runtime is handed: the theme and its strings (store-independent, module scope). */
2
+ import type { ThemeBundle } from '@tanqory/theme-kit/headless'
3
+ import theme from './theme'
4
+
5
+ export const bundle: ThemeBundle = {
6
+ theme,
7
+ templates: {},
8
+ groups: {},
9
+ // The build lays locales/*.json over the kit's own strings into generated/locales.
10
+ locales: import.meta.glob('./generated/locales/*.json', { eager: true }),
11
+ settings: {},
12
+ settingsSchema: {},
13
+ customSections: {},
14
+ manifest: null,
15
+ }
@@ -0,0 +1,32 @@
1
+ /** Starter's small shared parts: the product card and the section heading. All markup and classes are Starter's. */
2
+ import { Image, formatMoney, useTranslate, type Product } from '@tanqory/theme-kit/headless'
3
+
4
+ export const cx = (...names: Array<string | false | null | undefined>): string => names.filter(Boolean).join(' ')
5
+
6
+ export function ProductCard({ product, eager = false }: { product: Product; eager?: boolean }): JSX.Element {
7
+ const t = useTranslate()
8
+ const min = product.priceRange.min
9
+ const ranged = product.priceRange.max.amount > min.amount
10
+ return (
11
+ <li className="st-card">
12
+ <a className="st-card__link" href={product.url}>
13
+ <span className="st-card__frame">
14
+ <Image image={product.featuredImage} alt="" className="st-card__img" loading={eager ? 'eager' : 'lazy'} sizes="(max-width: 720px) 50vw, 25vw" fallback={<span className="st-card__img st-card__img--empty" />} />
15
+ </span>
16
+ <span className="st-card__title">{product.title}</span>
17
+ <span className="st-card__price">
18
+ {ranged ? t('starter.price.from', { price: formatMoney(min) }) : formatMoney(min)}
19
+ {product.available ? null : <span className="st-card__flag"> · {t('product.soldOut')}</span>}
20
+ </span>
21
+ </a>
22
+ </li>
23
+ )
24
+ }
25
+
26
+ export function Grid({ products, busy, eager = 0 }: { products: readonly Product[]; busy?: boolean; eager?: number }): JSX.Element {
27
+ return (
28
+ <ul className="st-grid" aria-busy={busy || undefined}>
29
+ {products.map((p, i) => <ProductCard key={p.id} product={p} eager={i < eager} />)}
30
+ </ul>
31
+ )
32
+ }
@@ -0,0 +1,6 @@
1
+ /** Starter's browser entry: hydrates what the server rendered; on the editor canvas, live edits apply in place. */
2
+ import { hydrate } from '@tanqory/theme-kit/client'
3
+ import { bundle } from './bundle'
4
+ import './styles/theme.css'
5
+
6
+ hydrate({ bundle })
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Starter's serve entry (Theme ABI v2 §1): `render(request, ctx)` + `manifest`, built into one file with no imports.
3
+ * The render is the kit's; `storefront` turns on what the headless API needs, and `plan.localization` lists the
4
+ * store's countries for the header's market selector.
5
+ */
6
+ import type { ThemeManifest } from '@tanqory/theme-abi'
7
+ import { createRender } from '@tanqory/theme-kit/server'
8
+ import { bundle } from './bundle'
9
+ import manifestJson from './generated/manifest.json'
10
+
11
+ export const manifest = manifestJson as unknown as ThemeManifest
12
+
13
+ export const render = createRender({ manifest, bundle, storefront: { plan: { localization: true, recommendations: true } } })