@tanqory/theme-kit 0.1.0 → 2.0.0-alpha.19

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 (233) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +128 -10
  3. package/dist/abi/canvas-live.d.ts +72 -0
  4. package/dist/abi/canvas-live.js +159 -0
  5. package/dist/abi/cart.d.ts +60 -0
  6. package/dist/abi/cart.js +396 -0
  7. package/dist/abi/convert.d.ts +360 -0
  8. package/dist/abi/convert.js +1330 -0
  9. package/dist/abi/data-api.d.ts +15 -0
  10. package/dist/abi/data-api.js +213 -0
  11. package/dist/abi/jcs.d.ts +6 -0
  12. package/dist/abi/jcs.js +28 -0
  13. package/dist/abi/labels.d.ts +3 -0
  14. package/dist/abi/labels.js +34 -0
  15. package/dist/abi/page-data.d.ts +264 -0
  16. package/dist/abi/page-data.js +746 -0
  17. package/dist/abi/page.d.ts +28 -0
  18. package/dist/abi/page.js +57 -0
  19. package/dist/abi/referrals.d.ts +23 -0
  20. package/dist/abi/referrals.js +89 -0
  21. package/dist/abi/rewards.d.ts +27 -0
  22. package/dist/abi/rewards.js +82 -0
  23. package/dist/abi/seo.d.ts +47 -0
  24. package/dist/abi/seo.js +68 -0
  25. package/dist/abi/shell.d.ts +23 -0
  26. package/dist/abi/shell.js +10 -0
  27. package/dist/abi/state-pack.d.ts +17 -0
  28. package/dist/abi/state-pack.js +43 -0
  29. package/dist/abi/wire.d.ts +46 -0
  30. package/dist/abi/wire.js +114 -0
  31. package/dist/build.d.ts +121 -0
  32. package/dist/build.js +401 -0
  33. package/dist/chunks.d.ts +23 -0
  34. package/dist/chunks.js +41 -0
  35. package/dist/client.d.ts +26 -0
  36. package/dist/client.js +101 -0
  37. package/dist/contract.d.ts +6 -0
  38. package/dist/contract.js +6 -0
  39. package/dist/headless/ai.d.ts +132 -0
  40. package/dist/headless/ai.js +99 -0
  41. package/dist/headless/hooks.d.ts +276 -0
  42. package/dist/headless/hooks.js +544 -0
  43. package/dist/headless/i18n.d.ts +13 -0
  44. package/dist/headless/i18n.js +45 -0
  45. package/dist/headless/index.d.ts +44 -0
  46. package/dist/headless/index.js +48 -0
  47. package/dist/headless/lazy-component.d.ts +72 -0
  48. package/dist/headless/lazy-component.js +225 -0
  49. package/dist/headless/lazy-section.d.ts +38 -0
  50. package/dist/headless/lazy-section.js +97 -0
  51. package/dist/headless/model.d.ts +73 -0
  52. package/dist/headless/model.js +115 -0
  53. package/dist/headless/money.d.ts +17 -0
  54. package/dist/headless/money.js +63 -0
  55. package/dist/headless/page.d.ts +45 -0
  56. package/dist/headless/page.js +53 -0
  57. package/dist/headless/platform.d.ts +55 -0
  58. package/dist/headless/platform.js +77 -0
  59. package/dist/headless/primitives/cart.d.ts +90 -0
  60. package/dist/headless/primitives/cart.js +153 -0
  61. package/dist/headless/primitives/collection.d.ts +68 -0
  62. package/dist/headless/primitives/collection.js +80 -0
  63. package/dist/headless/primitives/product.d.ts +101 -0
  64. package/dist/headless/primitives/product.js +117 -0
  65. package/dist/headless/primitives/storefront.d.ts +106 -0
  66. package/dist/headless/primitives/storefront.js +187 -0
  67. package/dist/headless/primitives/util.d.ts +19 -0
  68. package/dist/headless/primitives/util.js +42 -0
  69. package/dist/headless/strings.d.ts +9 -0
  70. package/dist/headless/strings.js +198 -0
  71. package/dist/headless/structured-data.d.ts +31 -0
  72. package/dist/headless/structured-data.js +57 -0
  73. package/dist/headless/tanqory-money.generated.d.ts +493 -0
  74. package/dist/headless/tanqory-money.generated.js +507 -0
  75. package/dist/headless/theme.d.ts +109 -0
  76. package/dist/headless/theme.js +62 -0
  77. package/dist/index.d.ts +21 -0
  78. package/dist/index.js +21 -553
  79. package/dist/runtime/data/StoreProvider.d.ts +84 -0
  80. package/dist/runtime/data/StoreProvider.js +380 -0
  81. package/dist/runtime/data/handle.d.ts +14 -0
  82. package/dist/runtime/data/handle.js +16 -0
  83. package/dist/runtime/data/routes.d.ts +87 -0
  84. package/dist/runtime/data/routes.js +158 -0
  85. package/dist/runtime/data/to-ui.d.ts +286 -0
  86. package/dist/runtime/data/to-ui.js +1009 -0
  87. package/dist/runtime/entries/register.d.ts +9 -0
  88. package/dist/runtime/entries/register.js +9 -0
  89. package/dist/runtime/entries/sections.d.ts +16 -0
  90. package/dist/runtime/entries/sections.js +19 -0
  91. package/dist/{types → runtime/kit}/SectionTree.d.ts +2 -1
  92. package/dist/runtime/kit/SectionTree.js +100 -0
  93. package/dist/runtime/kit/analytics.d.ts +63 -0
  94. package/dist/runtime/kit/analytics.js +250 -0
  95. package/dist/runtime/kit/cart.d.ts +222 -0
  96. package/dist/runtime/kit/cart.js +545 -0
  97. package/dist/{types → runtime/kit}/composition.d.ts +1 -1
  98. package/dist/runtime/kit/composition.js +3 -0
  99. package/dist/{types → runtime/kit}/config.d.ts +2 -2
  100. package/dist/runtime/kit/config.js +6 -0
  101. package/dist/runtime/kit/consent.d.ts +29 -0
  102. package/dist/runtime/kit/consent.js +159 -0
  103. package/dist/runtime/kit/contract/content.d.ts +213 -0
  104. package/dist/runtime/kit/contract/content.js +119 -0
  105. package/dist/runtime/kit/contract/field-types.d.ts +360 -0
  106. package/dist/runtime/kit/contract/field-types.js +216 -0
  107. package/dist/runtime/kit/contract/groups.d.ts +230 -0
  108. package/dist/runtime/kit/contract/groups.js +402 -0
  109. package/dist/runtime/kit/contract/index.d.ts +33 -0
  110. package/dist/runtime/kit/contract/index.js +33 -0
  111. package/dist/runtime/kit/contract/transform.d.ts +82 -0
  112. package/dist/runtime/kit/contract/transform.js +133 -0
  113. package/dist/runtime/kit/contract/validate.d.ts +77 -0
  114. package/dist/runtime/kit/contract/validate.js +520 -0
  115. package/dist/runtime/kit/data.d.ts +732 -0
  116. package/dist/runtime/kit/data.js +1131 -0
  117. package/dist/{types → runtime/kit}/defineSection.d.ts +1 -1
  118. package/dist/runtime/kit/defineSection.js +10 -0
  119. package/dist/runtime/kit/dynamic-source.d.ts +118 -0
  120. package/dist/runtime/kit/dynamic-source.js +311 -0
  121. package/dist/runtime/kit/index.d.ts +24 -0
  122. package/dist/runtime/kit/index.js +24 -0
  123. package/dist/{types → runtime/kit}/jsx-to-json.d.ts +1 -1
  124. package/dist/runtime/kit/jsx-to-json.js +28 -0
  125. package/dist/{types → runtime/kit}/mount.d.ts +25 -4
  126. package/dist/runtime/kit/mount.js +124 -0
  127. package/dist/{types → runtime/kit}/registry.d.ts +1 -1
  128. package/dist/runtime/kit/registry.js +12 -0
  129. package/dist/{types → runtime/kit}/ssg.d.ts +9 -3
  130. package/dist/runtime/kit/ssg.js +56 -0
  131. package/dist/runtime/kit/storefront.d.ts +652 -0
  132. package/dist/runtime/kit/storefront.js +723 -0
  133. package/dist/{types → runtime/kit}/theme-context.d.ts +8 -2
  134. package/dist/runtime/kit/theme-context.js +25 -0
  135. package/dist/runtime/kit/types.d.ts +155 -0
  136. package/dist/runtime/kit/types.js +1 -0
  137. package/dist/runtime/platform/TrackingPixels.d.ts +14 -0
  138. package/dist/runtime/platform/TrackingPixels.js +63 -0
  139. package/dist/runtime/platform/environment.d.ts +68 -0
  140. package/dist/runtime/platform/environment.js +85 -0
  141. package/dist/runtime/platform/locale.d.ts +27 -0
  142. package/dist/runtime/platform/locale.js +42 -0
  143. package/dist/runtime/platform/route-analytics.d.ts +15 -0
  144. package/dist/runtime/platform/route-analytics.js +72 -0
  145. package/dist/runtime/platform/safe-href.d.ts +25 -0
  146. package/dist/runtime/platform/safe-href.js +69 -0
  147. package/dist/runtime/platform/safe-values.d.ts +37 -0
  148. package/dist/runtime/platform/safe-values.js +140 -0
  149. package/dist/runtime/render/SectionRenderer.d.ts +4 -0
  150. package/dist/runtime/render/SectionRenderer.js +199 -0
  151. package/dist/runtime/render/listing-query.d.ts +52 -0
  152. package/dist/runtime/render/listing-query.js +122 -0
  153. package/dist/runtime/render/localized-copy.d.ts +86 -0
  154. package/dist/runtime/render/localized-copy.js +129 -0
  155. package/dist/runtime/render/product-listing.d.ts +11 -0
  156. package/dist/runtime/render/product-listing.js +243 -0
  157. package/dist/runtime/render/resolved.d.ts +47 -0
  158. package/dist/runtime/render/resolved.js +80 -0
  159. package/dist/runtime/render/section-actions.d.ts +67 -0
  160. package/dist/runtime/render/section-actions.js +205 -0
  161. package/dist/runtime/render/starter.d.ts +11 -0
  162. package/dist/runtime/render/starter.js +96 -0
  163. package/dist/runtime/seo/head.d.ts +115 -0
  164. package/dist/runtime/seo/head.js +281 -0
  165. package/dist/runtime/seo/structured-data.d.ts +83 -0
  166. package/dist/runtime/seo/structured-data.js +252 -0
  167. package/dist/runtime/shell/PageShell.d.ts +18 -0
  168. package/dist/runtime/shell/PageShell.js +118 -0
  169. package/dist/runtime/shell/RuntimeBridge.d.ts +18 -0
  170. package/dist/runtime/shell/RuntimeBridge.js +124 -0
  171. package/dist/runtime/shell/overlay-state.d.ts +31 -0
  172. package/dist/runtime/shell/overlay-state.js +59 -0
  173. package/dist/runtime/shell/preview-mode.d.ts +2 -0
  174. package/dist/runtime/shell/preview-mode.js +11 -0
  175. package/dist/runtime/shell/spa-router.d.ts +14 -0
  176. package/dist/runtime/shell/spa-router.js +76 -0
  177. package/dist/runtime/shell/url-redirects.d.ts +6 -0
  178. package/dist/runtime/shell/url-redirects.js +37 -0
  179. package/dist/runtime/slots.d.ts +74 -0
  180. package/dist/runtime/slots.js +16 -0
  181. package/dist/runtime.d.ts +34 -0
  182. package/dist/runtime.js +40 -0
  183. package/dist/sdk/app-block.d.ts +29 -0
  184. package/dist/sdk/app-block.js +22 -0
  185. package/dist/sdk/font-hooks.d.ts +7 -0
  186. package/dist/sdk/font-hooks.js +21 -0
  187. package/dist/sdk/fonts.d.ts +144 -0
  188. package/dist/sdk/fonts.js +241 -0
  189. package/dist/sdk/index.d.ts +32 -0
  190. package/dist/sdk/index.js +36 -0
  191. package/dist/sdk/motion-hooks.d.ts +23 -0
  192. package/dist/sdk/motion-hooks.js +46 -0
  193. package/dist/sdk/motion.d.ts +78 -0
  194. package/dist/sdk/motion.js +292 -0
  195. package/dist/sdk/referrals.d.ts +62 -0
  196. package/dist/sdk/referrals.js +20 -0
  197. package/dist/sdk/rewards.d.ts +85 -0
  198. package/dist/sdk/rewards.js +29 -0
  199. package/dist/sdk/runtime-context.d.ts +230 -0
  200. package/dist/sdk/runtime-context.js +73 -0
  201. package/dist/sdk/schema.d.ts +249 -0
  202. package/dist/sdk/schema.js +168 -0
  203. package/dist/sdk/server-render.d.ts +8 -0
  204. package/dist/sdk/server-render.js +12 -0
  205. package/dist/sdk/store-lookup.d.ts +32 -0
  206. package/dist/sdk/store-lookup.js +48 -0
  207. package/dist/sdk/store.d.ts +164 -0
  208. package/dist/sdk/store.js +5 -0
  209. package/dist/sdk/sx.d.ts +45 -0
  210. package/dist/sdk/sx.js +117 -0
  211. package/dist/sdk/theme.d.ts +212 -0
  212. package/dist/sdk/theme.js +27 -0
  213. package/dist/sdk/types.d.ts +789 -0
  214. package/dist/sdk/types.js +7 -0
  215. package/dist/server.d.ts +112 -0
  216. package/dist/server.js +589 -0
  217. package/dist/vite-chunks.d.ts +10 -0
  218. package/dist/vite-chunks.js +44 -0
  219. package/docs/headless-api.md +250 -0
  220. package/package.json +72 -26
  221. package/dist/index.js.map +0 -1
  222. package/dist/ssg-BZ5FYTw7.js +0 -1802
  223. package/dist/ssg-BZ5FYTw7.js.map +0 -1
  224. package/dist/ssg.js +0 -8
  225. package/dist/ssg.js.map +0 -1
  226. package/dist/types/cart.d.ts +0 -86
  227. package/dist/types/data.d.ts +0 -357
  228. package/dist/types/dynamic-source.d.ts +0 -84
  229. package/dist/types/editor.d.ts +0 -5
  230. package/dist/types/index.d.ts +0 -20
  231. package/dist/types/preview-bridge.d.ts +0 -9
  232. package/dist/types/storefront.d.ts +0 -333
  233. package/dist/types/types.d.ts +0 -44
@@ -0,0 +1,114 @@
1
+ import { canonicalize } from './jcs.js';
2
+ /** `PLATFORM_ROUTES` values (the type pins them to the contract; scripts/abi/build.mjs re-checks at build). */
3
+ const DATA = '/_tq/data/';
4
+ const ACTIONS = '/_tq/actions/';
5
+ const MAX_ACTION_BYTES = 8 * 1024;
6
+ export class AbiWireError extends Error {
7
+ constructor(status, code,
8
+ /** The server's `Retry-After`, in ms from now; null when it sent none (or one we cannot read). */
9
+ retryAfterMs = null) {
10
+ super(`[nova] /_tq request failed: HTTP ${status}${code ? ` ${code}` : ''}`);
11
+ this.status = status;
12
+ this.code = code;
13
+ this.retryAfterMs = retryAfterMs;
14
+ this.name = 'AbiWireError';
15
+ }
16
+ }
17
+ /**
18
+ * `Retry-After` (RFC 9110 §10.2.3) as ms from `now`: delay-seconds or an HTTP-date. A rate-limited
19
+ * `/_tq/data` answers `429` with `retry-after: 30`; the cart waits that long rather than hammering
20
+ * the same budget (QA test-2 F1).
21
+ */
22
+ export function parseRetryAfter(value, now = Date.now()) {
23
+ if (value === null)
24
+ return null;
25
+ const v = value.trim();
26
+ if (/^\d+$/.test(v))
27
+ return Number(v) * 1000;
28
+ const at = Date.parse(v);
29
+ return Number.isNaN(at) ? null : Math.max(0, at - now);
30
+ }
31
+ /**
32
+ * How long a /_tq request may take before the page gives up on it. A request the gateway never answers left Add to cart
33
+ * on "Adding…" for good (Dev 2026-11-19, store Evermade, board 35 #85 side finding): the cart and the button await this
34
+ * promise, and fetch has no timeout of its own. Past it the request fails as `timeout` (status 0), which the cart reports
35
+ * like any failed request (the button returns, the cart says it could not update; a cart read backs off and retries).
36
+ */
37
+ export const WIRE_TIMEOUT_MS = 20_000;
38
+ export async function timedFetch(url, init, ms = WIRE_TIMEOUT_MS) {
39
+ // A plain timer, cleared as soon as the whole answer is read: no timer outlives its request (AbortSignal.timeout's
40
+ // would stay pending for the full 20 s, which a page that waits for idle, such as the theme checks' hydration run,
41
+ // reads as work still going on).
42
+ if (typeof AbortController === 'undefined')
43
+ return fetch(url, init);
44
+ const controller = new AbortController();
45
+ const timer = setTimeout(() => controller.abort(), ms);
46
+ try {
47
+ const res = await fetch(url, { ...init, signal: controller.signal });
48
+ // The body is read inside the timeout too: an answer whose body never ends is as stuck as no answer.
49
+ const body = await res.text();
50
+ return new Response(body, { status: res.status, statusText: res.statusText, headers: res.headers });
51
+ }
52
+ catch (e) {
53
+ if (controller.signal.aborted)
54
+ throw new AbiWireError(0, 'timeout');
55
+ throw e;
56
+ }
57
+ finally {
58
+ clearTimeout(timer);
59
+ }
60
+ }
61
+ function base64url(text) {
62
+ const bytes = new TextEncoder().encode(text);
63
+ let bin = '';
64
+ for (const b of bytes)
65
+ bin += String.fromCharCode(b);
66
+ return btoa(bin).replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
67
+ }
68
+ function csrfToken() {
69
+ return document.querySelector('meta[name="tq-csrf"]')?.content || null;
70
+ }
71
+ async function envelope(res) {
72
+ let body = null;
73
+ try {
74
+ body = await res.json();
75
+ }
76
+ catch {
77
+ body = null;
78
+ }
79
+ if (body && typeof body === 'object' && 'ok' in body)
80
+ return body;
81
+ return { ok: false, error: { code: res.ok ? 'invalid_envelope' : 'unavailable', requestId: '' } };
82
+ }
83
+ /** Browser-only; the routes are relative to the page's own origin. */
84
+ export function createAbiRemote() {
85
+ return {
86
+ async data(op, args) {
87
+ const qs = args.length ? `?a=${base64url(canonicalize(args))}` : '';
88
+ const res = await timedFetch(`${DATA}${op}${qs}`, { method: 'GET', credentials: 'same-origin', headers: { accept: 'application/json' } });
89
+ const env = await envelope(res);
90
+ if (!env.ok)
91
+ throw new AbiWireError(res.status, env.error.code, parseRetryAfter(res.headers.get('retry-after')));
92
+ return env.data;
93
+ },
94
+ async action(name, args) {
95
+ const body = JSON.stringify({ v: 2, args });
96
+ if (new TextEncoder().encode(body).length > MAX_ACTION_BYTES)
97
+ throw new AbiWireError(413, 'invalid_argument');
98
+ const post = async () => {
99
+ const token = csrfToken();
100
+ return timedFetch(`${ACTIONS}${name}`, {
101
+ method: 'POST',
102
+ credentials: 'same-origin',
103
+ headers: { 'content-type': 'application/json', accept: 'application/json', ...(token ? { 'x-tq-csrf': token } : {}) },
104
+ body,
105
+ });
106
+ };
107
+ let env = await envelope(await post());
108
+ // §4.1: a first visit has no CSRF cookie yet — the token is re-read once and the call retried.
109
+ if (!env.ok && env.error.code === 'csrf_failed')
110
+ env = await envelope(await post());
111
+ return env;
112
+ },
113
+ };
114
+ }
@@ -0,0 +1,121 @@
1
+ /**
2
+ * `@tanqory/theme-kit/build` — derive a theme's ABI v2 manifest from what the theme already declares: its
3
+ * `defineSection` / `defineBlock` schemas, its theme settings, its templates, and the `ai` roles of its sections
4
+ * (printed as `x-tanqory-ai`). Pure (no file system, no React): a theme's build script loads the theme, calls
5
+ * `buildManifest`, validates the result with `@tanqory/theme-abi` `validateManifest`, and writes the files.
6
+ *
7
+ * const { manifest, problems } = buildManifest({ name, version, theme, settings, templates, forms: { newsletter: true } })
8
+ *
9
+ * Capabilities: the kit's runtime needs the defaults below. `data:shop` is always declared (decision D6: the
10
+ * platform hands shop data to the browser snapshot only to a theme that declares it). Add more with
11
+ * `capabilities` (e.g. `data:inventory` to show stock counts).
12
+ */
13
+ import type { Field } from './sdk/schema.js';
14
+ import type { SettingSpec, ThemeDefinition } from './sdk/theme.js';
15
+ import { type AiProfile } from './headless/ai.js';
16
+ import { type Strings } from './headless/strings.js';
17
+ export { aiProfileOf, checkAiProfile, type AiProfile, type AiRole } from './headless/ai.js';
18
+ export { KIT_STRINGS, kitStrings } from './headless/strings.js';
19
+ /** RFC 8785 JSON canonicalization: `manifest.json` is its JCS bytes plus one trailing LF. */
20
+ export { canonicalize } from './abi/jcs.js';
21
+ /** What the kit's server render reads (`ctx.data`, `ctx.actions`). `data:shop` is always declared (D6). */
22
+ export declare const SERVER_CAPABILITIES: readonly string[];
23
+ /** What the kit's browser runtime calls over `/_tq/data` and `/_tq/actions`. `data:shop` is always declared (D6). */
24
+ export declare const BROWSER_CAPABILITIES: readonly string[];
25
+ /** The fields each platform form posts (`forms.<id>.fields`); `website` is the honeypot. */
26
+ export declare const FORM_FIELDS: Readonly<Record<'newsletter' | 'contact', readonly string[]>>;
27
+ export interface RegionSpec {
28
+ title: string;
29
+ scope: 'shared' | 'template';
30
+ accepts?: readonly string[];
31
+ min?: number;
32
+ max?: number;
33
+ }
34
+ /** Header (shared), the template's body, footer (shared): where `zone` header / main / footer place a section. */
35
+ export declare const DEFAULT_REGIONS: Readonly<Record<string, RegionSpec>>;
36
+ /** A value check for stored values (`@tanqory/theme-abi` `validateFieldValue`, or the registry-2 wrapper a theme uses). */
37
+ export type ValueCheck = (type: string, value: unknown, spec: Record<string, unknown>) => {
38
+ ok: boolean;
39
+ errors?: readonly {
40
+ message: string;
41
+ code?: string;
42
+ }[];
43
+ };
44
+ export interface BuildManifestInput {
45
+ /** Package-style theme name (`@scope/name`). */
46
+ name: string;
47
+ version: string;
48
+ theme: ThemeDefinition;
49
+ /** Theme settings (`defineSettings`), grouped by each setting's `group`. */
50
+ settings?: Readonly<Record<string, SettingSpec>>;
51
+ /** Template name → its route kind (`home`, `product`, …, `not_found`, `custom:<id>`) and regions in order. */
52
+ templates: Readonly<Record<string, {
53
+ route: string;
54
+ title?: string;
55
+ regions?: readonly string[];
56
+ }>>;
57
+ regions?: Readonly<Record<string, RegionSpec>>;
58
+ /** `custom:<id>` route paths. */
59
+ customRoutes?: Readonly<Record<string, {
60
+ path: string;
61
+ }>>;
62
+ /** Added to the kit's defaults. */
63
+ capabilities?: {
64
+ server?: readonly string[];
65
+ browser?: readonly string[];
66
+ };
67
+ /** Platform forms the theme renders (`<NewsletterForm>`, `<ContactForm>`). */
68
+ forms?: {
69
+ newsletter?: boolean | {
70
+ title: string;
71
+ };
72
+ contact?: boolean | {
73
+ title: string;
74
+ };
75
+ };
76
+ /** The theme's content document version (default 1). */
77
+ contentVersion?: number;
78
+ /**
79
+ * `engines["tanqory-field-types"]` (default "2": `asset:client/…` image values in defaults and presets; "3" adds
80
+ * `color_palette`, B.3; "4" adds `model`, B.4). Unset and a section declares a `model` setting: "4".
81
+ */
82
+ fieldTypes?: '1' | '2' | '3' | '4';
83
+ /** The AI-compat profile; from the sections' `ai` roles by default, `false` for none. */
84
+ aiProfile?: AiProfile | false;
85
+ /** Checks every default and preset value (e.g. `validateFieldValue` from `@tanqory/theme-abi`). */
86
+ checkValue?: ValueCheck;
87
+ /** Extra top-level `x-*` members. */
88
+ extensions?: Readonly<Record<`x-${string}`, unknown>>;
89
+ /**
90
+ * The font families the theme ships itself (assets/*.woff2 with its own `@font-face`): a font setting may offer
91
+ * them. Absent: every Theme-group family a font setting names is taken as declared.
92
+ */
93
+ themeFontFamilies?: readonly string[];
94
+ }
95
+ export interface BuiltManifest {
96
+ manifest: Record<string, unknown>;
97
+ /** Contract problems found while deriving it; a build should refuse to ship with any. */
98
+ problems: string[];
99
+ }
100
+ /** "buttonLabel" → "Button label". */
101
+ export declare function humanize(key: string): string;
102
+ /** A settings-DSL field as a manifest attribute (registry field spec). */
103
+ export declare function fieldSpecOf(key: string, f: Field): Record<string, unknown>;
104
+ /** The manifest of a headless theme. */
105
+ export declare function buildManifest(input: BuildManifestInput): BuiltManifest;
106
+ interface Node {
107
+ id?: string;
108
+ type?: string;
109
+ settings?: Record<string, unknown>;
110
+ blocks?: readonly Node[];
111
+ }
112
+ /**
113
+ * Problems in starter content (a template's or region's sections): every node names a declared component, has an
114
+ * ABI node id, and holds only its component's attributes (each value through `checkValue` when given).
115
+ */
116
+ export declare function checkContent(where: string, nodes: readonly Node[], manifest: Record<string, unknown>, checkValue?: ValueCheck): string[];
117
+ /**
118
+ * The theme's locale files with the kit's words underneath: every key the kit's primitives use exists in every
119
+ * language the kit has words for, and the theme's own values win.
120
+ */
121
+ export declare function withKitStrings(locales: Readonly<Record<string, Strings>>): Record<string, Record<string, string>>;
package/dist/build.js ADDED
@@ -0,0 +1,401 @@
1
+ import { aiProfileOf, checkAiProfile } from './headless/ai.js';
2
+ import { KIT_STRINGS } from './headless/strings.js';
3
+ import { APP_BLOCKS, acceptsAppBlocks } from './runtime/kit/contract/content.js';
4
+ import { editorOnlyReplacement } from './runtime/kit/contract/validate.js';
5
+ import { fontValueProblem, FAMILY_NAME } from './sdk/fonts.js';
6
+ export { aiProfileOf, checkAiProfile } from './headless/ai.js';
7
+ export { KIT_STRINGS, kitStrings } from './headless/strings.js';
8
+ /** RFC 8785 JSON canonicalization: `manifest.json` is its JCS bytes plus one trailing LF. */
9
+ export { canonicalize } from './abi/jcs.js';
10
+ /** What the kit's server render reads (`ctx.data`, `ctx.actions`). `data:shop` is always declared (D6). */
11
+ export const SERVER_CAPABILITIES = [
12
+ 'data:shop',
13
+ 'data:localization',
14
+ 'data:catalog',
15
+ 'data:content',
16
+ 'data:search',
17
+ 'data:cart',
18
+ 'data:products.recommendations',
19
+ 'actions:cart',
20
+ 'actions:consent',
21
+ 'actions:form.submit',
22
+ ];
23
+ /** What the kit's browser runtime calls over `/_tq/data` and `/_tq/actions`. `data:shop` is always declared (D6). */
24
+ export const BROWSER_CAPABILITIES = [
25
+ 'data:shop',
26
+ 'data:localization',
27
+ 'data:catalog',
28
+ 'data:content',
29
+ 'data:search',
30
+ 'data:cart',
31
+ 'data:products.recommendations',
32
+ 'actions:cart',
33
+ 'actions:consent',
34
+ ];
35
+ /** The fields each platform form posts (`forms.<id>.fields`); `website` is the honeypot. */
36
+ export const FORM_FIELDS = {
37
+ newsletter: ['email', 'consent', 'website'],
38
+ contact: ['name', 'email', 'phone', 'message', 'website'],
39
+ };
40
+ /** Header (shared), the template's body, footer (shared): where `zone` header / main / footer place a section. */
41
+ export const DEFAULT_REGIONS = {
42
+ header: { title: 'Header', scope: 'shared' },
43
+ main: { title: 'Template', scope: 'template' },
44
+ footer: { title: 'Footer', scope: 'shared' },
45
+ };
46
+ const ZONE_REGION = { header: 'header', main: 'main', footer: 'footer' };
47
+ /** "buttonLabel" → "Button label". */
48
+ export function humanize(key) {
49
+ const words = key.replace(/[-_]+/g, ' ').replace(/([a-z0-9])([A-Z])/g, '$1 $2').trim().toLowerCase();
50
+ return words ? words[0].toUpperCase() + words.slice(1) : key;
51
+ }
52
+ const RESOLVED = new Set(['collection', 'product', 'page', 'blog', 'menu']);
53
+ /** A settings-DSL field as a manifest attribute (registry field spec). */
54
+ export function fieldSpecOf(key, f) {
55
+ const out = { type: f.control, label: f.label ?? humanize(key) };
56
+ if (f.info)
57
+ out.info = f.info;
58
+ if (f.placeholder)
59
+ out.placeholder = f.placeholder;
60
+ if (f.group)
61
+ out.group = f.group;
62
+ if (f.control === 'select') {
63
+ out.options = f.options.map((v) => ({ value: v, label: f.optionLabels?.[v] ?? humanize(v) }));
64
+ }
65
+ else if (f.control === 'range' || f.control === 'number') {
66
+ out.min = f.min;
67
+ out.max = f.max;
68
+ out.step = f.step;
69
+ if (f.control === 'range' && f.unit)
70
+ out.unit = f.unit;
71
+ }
72
+ else if (f.control === 'list') {
73
+ // A resource list (registry `list`): each entry is a handle the platform resolves into snapshot.refs, one ref per
74
+ // entry (`${nodeId}.${key}.${index}`), like a single resource setting.
75
+ out.items = { type: f.items, ...(RESOLVED.has(f.items) ? { resolve: true } : {}) };
76
+ out.max = f.max;
77
+ }
78
+ if (RESOLVED.has(f.control))
79
+ out.resolve = true;
80
+ // "Not set" is an absent key: an empty default (text or list) is no default.
81
+ const empty = f.default === '' || f.default === null || f.default === undefined || (Array.isArray(f.default) && f.default.length === 0);
82
+ if (!empty)
83
+ out.default = f.default;
84
+ return out;
85
+ }
86
+ function attributesOf(schema) {
87
+ const out = {};
88
+ for (const [k, f] of Object.entries(schema.fields))
89
+ if (!f.legacyHidden)
90
+ out[k] = fieldSpecOf(k, f);
91
+ return out;
92
+ }
93
+ /** A theme setting (`defineSettings`) as a manifest settings item. */
94
+ function settingItem(key, s) {
95
+ const out = { key, type: s.type, label: s.label ?? humanize(key) };
96
+ if (s.info)
97
+ out.info = s.info;
98
+ if (s.placeholder)
99
+ out.placeholder = s.placeholder;
100
+ if (s.options)
101
+ out.options = s.options.map((o) => ({ value: o.value, label: o.label }));
102
+ if (s.type === 'range' || s.type === 'number') {
103
+ if (s.min !== undefined)
104
+ out.min = s.min;
105
+ if (s.max !== undefined)
106
+ out.max = s.max;
107
+ if (s.step !== undefined)
108
+ out.step = s.step;
109
+ if (s.type === 'range' && s.unit)
110
+ out.unit = s.unit;
111
+ }
112
+ if (s.type === 'list') {
113
+ if (s.items)
114
+ out.items = { ...s.items };
115
+ if (s.min !== undefined)
116
+ out.min = s.min;
117
+ if (s.max !== undefined)
118
+ out.max = s.max;
119
+ }
120
+ // A palette's cap (registry 3, B.3): a lower `max` than 20 only.
121
+ if (s.type === 'color_palette' && s.max !== undefined)
122
+ out.max = s.max;
123
+ if (s.default !== '' && s.default !== null && s.default !== undefined)
124
+ out.default = s.default;
125
+ return out;
126
+ }
127
+ const cleanSettings = (settings) => Object.fromEntries(Object.entries(settings ?? {}).filter(([, v]) => v !== '' && v !== null && v !== undefined));
128
+ /** The manifest of a headless theme. */
129
+ export function buildManifest(input) {
130
+ const problems = [];
131
+ const check = (where, type, value, spec) => {
132
+ if (!input.checkValue)
133
+ return;
134
+ const r = input.checkValue(type, value, spec);
135
+ if (!r.ok)
136
+ problems.push(`${where} ${JSON.stringify(value).slice(0, 80)}: ${(r.errors ?? []).map((e) => `${e.message}${e.code ? ` (${e.code})` : ''}`).join('; ')}`);
137
+ };
138
+ // ── components ───────────────────────────────────────────────────────
139
+ const components = {};
140
+ const sections = input.theme.sections;
141
+ for (const s of sections) {
142
+ if (components[s.id])
143
+ problems.push(`sections: "${s.id}" is declared twice`);
144
+ const c = {
145
+ role: s.zone === 'main' ? 'section' : 'layout',
146
+ title: s.title ?? humanize(s.id),
147
+ attributes: attributesOf(s.schema),
148
+ regions: [ZONE_REGION[s.zone] ?? 'main'],
149
+ category: s.category,
150
+ };
151
+ if (s.description)
152
+ c.description = s.description;
153
+ if (s.icon)
154
+ c.icon = s.icon;
155
+ const blocks = s.blocks ?? [];
156
+ // theme-abi §7.2: `'@app'` in the section's schema blocks accepts the blocks of installed apps (never on layout).
157
+ const appBlocks = acceptsAppBlocks(s.schema.blocks);
158
+ // a header or footer section may accept app blocks too (theme-abi §7.2 AppBlocks-1)
159
+ if (blocks.length || appBlocks)
160
+ c.children = [...blocks.map((b) => b.name), ...(appBlocks ? [APP_BLOCKS] : [])];
161
+ if (s.requiresContext?.length)
162
+ c.requires = [...s.requiresContext];
163
+ if (s.presets?.length) {
164
+ c.presets = s.presets.map((p, pi) => {
165
+ const settings = cleanSettings(p.settings);
166
+ return {
167
+ name: p.name,
168
+ ...(Object.keys(settings).length ? { settings } : {}),
169
+ ...(p.blocks?.length ? { blocks: p.blocks.map((b, bi) => ({ type: b.type, id: `${s.id}-preset${pi}-${bi}`, ...(Object.keys(cleanSettings(b.settings)).length ? { settings: cleanSettings(b.settings) } : {}) })) } : {}),
170
+ };
171
+ });
172
+ }
173
+ components[s.id] = c;
174
+ for (const b of blocks) {
175
+ const existing = components[b.name];
176
+ if (existing && existing.role !== 'block') {
177
+ problems.push(`blocks: "${b.name}" is also a section type`);
178
+ continue;
179
+ }
180
+ const parents = new Set([...(existing?.parents ?? []), ...(b.parents ?? []), s.id]);
181
+ components[b.name] = { role: 'block', title: b.title ?? humanize(b.name), attributes: attributesOf(b), parents: [...parents], ...(b.description ? { description: b.description } : {}), ...(b.requiresContext?.length ? { requires: [...b.requiresContext] } : {}) };
182
+ }
183
+ }
184
+ // MCP limits item 7: an editor-only type written as a control is refused here with its declarable form named
185
+ // (the manifest schema would only say the type is not allowed)
186
+ for (const [cid, c] of Object.entries(components))
187
+ for (const [k, spec] of Object.entries(c.attributes)) {
188
+ const instead = editorOnlyReplacement(spec.type);
189
+ if (instead)
190
+ problems.push(`components.${cid}.attributes.${k}: "${String(spec.type)}" cannot be declared by a theme. ${instead}`);
191
+ }
192
+ // Defaults and preset values against their attributes.
193
+ for (const [cid, c] of Object.entries(components)) {
194
+ const attrs = c.attributes;
195
+ for (const [k, spec] of Object.entries(attrs))
196
+ if (spec.default !== undefined)
197
+ check(`components.${cid}.attributes.${k}.default`, String(spec.type), spec.default, spec);
198
+ c.presets?.forEach((p, i) => {
199
+ for (const [k, v] of Object.entries(p.settings ?? {})) {
200
+ const spec = attrs[k];
201
+ if (!spec)
202
+ problems.push(`components.${cid}.presets[${i}].settings.${k}: not an attribute of "${cid}"`);
203
+ else
204
+ check(`components.${cid}.presets[${i}].settings.${k}`, String(spec.type), v, spec);
205
+ }
206
+ for (const b of p.blocks ?? []) {
207
+ const bc = components[b.type];
208
+ if (!bc)
209
+ problems.push(`components.${cid}.presets[${i}].blocks: "${b.type}" is not a block`);
210
+ else
211
+ for (const [k, v] of Object.entries(b.settings ?? {})) {
212
+ const spec = bc.attributes[k];
213
+ if (!spec)
214
+ problems.push(`components.${cid}.presets[${i}].blocks.${b.type}.${k}: not an attribute`);
215
+ else
216
+ check(`components.${cid}.presets[${i}].blocks.${b.type}.${k}`, String(spec.type), v, spec);
217
+ }
218
+ }
219
+ });
220
+ }
221
+ // ── settings ─────────────────────────────────────────────────────────
222
+ const groups = new Map();
223
+ for (const [key, spec] of Object.entries(input.settings ?? {})) {
224
+ const g = spec.group ?? 'General';
225
+ if (!groups.has(g))
226
+ groups.set(g, []);
227
+ const item = settingItem(key, spec);
228
+ const instead = editorOnlyReplacement(spec.type);
229
+ if (instead)
230
+ problems.push(`settingsSchema.${g}.${key}: "${String(spec.type)}" cannot be declared by a theme. ${instead}`);
231
+ if (item.default !== undefined)
232
+ check(`settingsSchema.${g}.${key}.default`, spec.type, item.default, item);
233
+ groups.get(g).push(item);
234
+ }
235
+ const settingsSchema = [...groups].map(([group, items]) => ({ group, items }));
236
+ // ── the editor's hints (`x-tanqory-editor`): what the ABI manifest does not carry ──────────────────────────────
237
+ // A font select (fontSetting / field.font) is a plain `select` to the ABI (registry 1-3); the editor draws it as its
238
+ // font picker from these hints (studio-api artifact-workspace.mjs merges them into what the editor reads).
239
+ const editor = { settings: {}, components: {} };
240
+ const declared = input.themeFontFamilies ? new Set(input.themeFontFamilies) : null;
241
+ const fontChecks = (where, values, groups, def) => {
242
+ const theme = new Set(values.filter((v) => groups[v] === 'Theme'));
243
+ for (const f of theme) {
244
+ if (!FAMILY_NAME.test(f))
245
+ problems.push(`${where}: theme font "${f}" is not a family name (letters, digits, spaces, hyphens)`);
246
+ else if (declared && !declared.has(f))
247
+ problems.push(`${where}: theme font "${f}" is not one of the theme's fonts (themeFontFamilies)`);
248
+ }
249
+ for (const v of values) {
250
+ const p = fontValueProblem(v, theme);
251
+ if (p)
252
+ problems.push(`${where}: ${p}`);
253
+ }
254
+ if (typeof def === 'string' && !values.includes(def))
255
+ problems.push(`${where}: the default "${def}" is not one of its fonts`);
256
+ };
257
+ for (const [key, spec] of Object.entries(input.settings ?? {})) {
258
+ if (spec.control !== 'font' && spec.control !== 'color_scheme' && !spec.weight_setting && !spec.options?.some((o) => o.group || o.scripts))
259
+ continue;
260
+ const hints = {};
261
+ if (spec.control)
262
+ hints.control = spec.control;
263
+ if (spec.weight_setting)
264
+ hints.weight_setting = spec.weight_setting;
265
+ const opts = (spec.options ?? []).filter((o) => o.group || o.scripts);
266
+ if (opts.length)
267
+ hints.options = Object.fromEntries(opts.map((o) => [o.value, { ...(o.group ? { group: o.group } : {}), ...(o.scripts ? { scripts: [...o.scripts] } : {}) }]));
268
+ editor.settings[key] = hints;
269
+ if (spec.control === 'font') {
270
+ if (spec.type !== 'select')
271
+ problems.push(`settingsSchema.${key}: a font setting is a select`);
272
+ fontChecks(`settingsSchema.${key}`, (spec.options ?? []).map((o) => o.value), Object.fromEntries((spec.options ?? []).map((o) => [o.value, o.group])), spec.default);
273
+ if (spec.weight_setting && !input.settings?.[spec.weight_setting])
274
+ problems.push(`settingsSchema.${key}: weight_setting "${spec.weight_setting}" is not a theme setting`);
275
+ }
276
+ }
277
+ const hintsOf = (cid, fields) => {
278
+ for (const [k, f] of Object.entries(fields)) {
279
+ if (f.control !== 'select' || !f.editor || f.legacyHidden)
280
+ continue;
281
+ (editor.components[cid] ??= {})[k] = { ...f.editor };
282
+ fontChecks(`components.${cid}.attributes.${k}`, f.options, Object.fromEntries(Object.entries(f.editor.options).map(([v, o]) => [v, o.group])), f.default);
283
+ if (f.editor.weight_setting && !fields[f.editor.weight_setting])
284
+ problems.push(`components.${cid}.attributes.${k}: weight_setting "${f.editor.weight_setting}" is not a setting of "${cid}"`);
285
+ }
286
+ };
287
+ for (const s of sections) {
288
+ hintsOf(s.id, s.schema.fields);
289
+ for (const b of s.blocks ?? [])
290
+ hintsOf(b.name, b.fields);
291
+ }
292
+ // ── routes, templates, regions ───────────────────────────────────────
293
+ const regions = input.regions ?? DEFAULT_REGIONS;
294
+ const templates = {};
295
+ const routes = {};
296
+ for (const [name, t] of Object.entries(input.templates)) {
297
+ const order = t.regions ?? ['header', 'main', 'footer'];
298
+ for (const r of order)
299
+ if (!regions[r])
300
+ problems.push(`templates.${name}: region "${r}" is not declared`);
301
+ templates[name] = { route: t.route, regions: [...order], ...(t.title ? { title: t.title } : {}) };
302
+ // The unsuffixed template of a kind is its default (`product.bundle` is chosen by templateSuffix).
303
+ if (!name.includes('.') && !routes[t.route])
304
+ routes[t.route] = name;
305
+ }
306
+ for (const [name, t] of Object.entries(input.templates))
307
+ if (!routes[t.route])
308
+ routes[t.route] = name;
309
+ for (const kind of Object.keys(routes))
310
+ if (kind.startsWith('custom:') && !input.customRoutes?.[kind.slice(7)])
311
+ problems.push(`routes.${kind}: no customRoutes.${kind.slice(7)}.path`);
312
+ // ── capabilities, forms, AI ──────────────────────────────────────────
313
+ const uniq = (a, b = []) => [...new Set([...a, ...b])];
314
+ const capabilities = { server: uniq(SERVER_CAPABILITIES, input.capabilities?.server), browser: uniq(BROWSER_CAPABILITIES, input.capabilities?.browser) };
315
+ const forms = {};
316
+ for (const id of ['newsletter', 'contact']) {
317
+ const f = input.forms?.[id];
318
+ if (!f)
319
+ continue;
320
+ forms[id] = { title: typeof f === 'object' ? f.title : humanize(id), fields: [...FORM_FIELDS[id]] };
321
+ }
322
+ // A `model` setting exists only in field-type registry 4 (B.4). Registries only add (B.3, B.4: "every registry-3 entry
323
+ // and value rule verbatim"), so a theme that declares a model setting and names no registry gets "4": the platform's
324
+ // build files (the custom and partner starters' scripts/build.mjs) pass none, and no theme could use field.model
325
+ // otherwise (MCP item 3, Dev 2026-11-20). A theme that names a lower registry keeps the refusal.
326
+ const modelFields = [];
327
+ for (const [cid, c] of Object.entries(components)) {
328
+ for (const [k, spec] of Object.entries((c.attributes) ?? {})) {
329
+ if (spec?.type === 'model')
330
+ modelFields.push(`components.${cid}.attributes.${k}`);
331
+ }
332
+ }
333
+ const fieldTypes = input.fieldTypes ?? (modelFields.length ? '4' : '2');
334
+ if (fieldTypes !== '4')
335
+ for (const at of modelFields)
336
+ problems.push(`${at}: field.model needs fieldTypes: '4' (tanqory-field-types@4, B.4)`);
337
+ const profile = input.aiProfile === false ? null : (input.aiProfile ?? aiProfileOf(sections));
338
+ if (profile)
339
+ problems.push(...checkAiProfile(profile, components));
340
+ const manifest = {
341
+ abi: '2.0',
342
+ name: input.name,
343
+ version: input.version,
344
+ engines: { 'tanqory-abi': '^2.0', 'tanqory-field-types': fieldTypes },
345
+ capabilities,
346
+ client: { hydration: 'full' },
347
+ ...(Object.keys(forms).length ? { forms } : {}),
348
+ contentVersion: input.contentVersion ?? 1,
349
+ routes,
350
+ ...(input.customRoutes ? { customRoutes: input.customRoutes } : {}),
351
+ templates,
352
+ regions,
353
+ components,
354
+ settingsSchema,
355
+ ...(profile ? { 'x-tanqory-ai': profile } : {}),
356
+ ...(Object.keys(editor.settings).length || Object.keys(editor.components).length ? { 'x-tanqory-editor': { v: 1, ...(Object.keys(editor.settings).length ? { settings: editor.settings } : {}), ...(Object.keys(editor.components).length ? { components: editor.components } : {}) } } : {}),
357
+ ...(input.extensions ?? {}),
358
+ };
359
+ return { manifest, problems };
360
+ }
361
+ const NODE_ID = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
362
+ /**
363
+ * Problems in starter content (a template's or region's sections): every node names a declared component, has an
364
+ * ABI node id, and holds only its component's attributes (each value through `checkValue` when given).
365
+ */
366
+ export function checkContent(where, nodes, manifest, checkValue) {
367
+ const problems = [];
368
+ const components = (manifest.components ?? {});
369
+ const walk = (list, at) => list.forEach((n, i) => {
370
+ const here = `${at}[${i}]`;
371
+ const c = n.type ? components[n.type] : undefined;
372
+ if (!c)
373
+ return void problems.push(`${here}: component "${n.type}" is not declared`);
374
+ if (!n.id || !NODE_ID.test(n.id) || n.id.length > 64)
375
+ problems.push(`${here}: node id ${JSON.stringify(n.id)} does not match the ABI id pattern`);
376
+ for (const [k, v] of Object.entries(n.settings ?? {})) {
377
+ const spec = c.attributes?.[k];
378
+ if (!spec)
379
+ problems.push(`${here}.settings.${k}: not an attribute of "${n.type}"`);
380
+ else if (checkValue) {
381
+ const r = checkValue(String(spec.type), v, spec);
382
+ if (!r.ok)
383
+ problems.push(`${here}.settings.${k} ${JSON.stringify(v).slice(0, 80)}: ${(r.errors ?? []).map((e) => e.message).join('; ')}`);
384
+ }
385
+ }
386
+ if (n.blocks)
387
+ walk(n.blocks, `${here}.blocks`);
388
+ });
389
+ walk(nodes, where);
390
+ return problems;
391
+ }
392
+ /**
393
+ * The theme's locale files with the kit's words underneath: every key the kit's primitives use exists in every
394
+ * language the kit has words for, and the theme's own values win.
395
+ */
396
+ export function withKitStrings(locales) {
397
+ const out = {};
398
+ for (const [lang, map] of Object.entries(locales))
399
+ out[lang] = { ...(KIT_STRINGS[lang] ?? KIT_STRINGS.en), ...map };
400
+ return out;
401
+ }
@@ -0,0 +1,23 @@
1
+ /**
2
+ * `@tanqory/theme-kit/chunks` — what build-service's bundler routes every `import()` of a client-chunks theme
3
+ * through (theme-abi-v2.md §2.2.1). Theme code never imports this module itself: the platform bundler rewrites
4
+ * `import('./x')` into `__tqChunk("<key>", () => import('./x'))` (client) or `__tqChunkStatic("<key>", x)`
5
+ * (server, where `import()` stays banned), and adds the import of this module.
6
+ *
7
+ * 'split' the build's chunks: the boot's gate (`globalThis.__tqGate`, defined by the SRI-verified boot, not
8
+ * writable) preloads the chunk's whole closure with integrity, waits, then imports. With no gate the
9
+ * promise never settles: nothing loads unverified, and the section keeps its server HTML.
10
+ * 'single' the single-bundle fallback (esbuild inlined the import): load directly.
11
+ * anything else (a theme's own dev build, a unit test): load directly.
12
+ */
13
+ /** A loading chunk, with the key the bundler gave it (the theme path of the imported module). */
14
+ export type ChunkPromise<T> = PromiseLike<T> & {
15
+ readonly key: string;
16
+ };
17
+ export declare function __tqChunk<T>(key: string, load: () => Promise<T>): ChunkPromise<T>;
18
+ /**
19
+ * The server's form: the module is a static import, so the chunk is already "loaded". A thenable that calls back
20
+ * synchronously, so `React.lazy` renders it in the same `renderToString` pass (React reads the module as soon as
21
+ * `then` resolves it).
22
+ */
23
+ export declare function __tqChunkStatic<T>(key: string, mod: T): ChunkPromise<T>;