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

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 (210) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +125 -10
  3. package/dist/abi/canvas-live.d.ts +67 -0
  4. package/dist/abi/canvas-live.js +154 -0
  5. package/dist/abi/cart.d.ts +59 -0
  6. package/dist/abi/cart.js +387 -0
  7. package/dist/abi/convert.d.ts +344 -0
  8. package/dist/abi/convert.js +1278 -0
  9. package/dist/abi/data-api.d.ts +15 -0
  10. package/dist/abi/data-api.js +209 -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 +256 -0
  16. package/dist/abi/page-data.js +678 -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 +38 -0
  30. package/dist/abi/wire.js +84 -0
  31. package/dist/build.d.ts +116 -0
  32. package/dist/build.js +310 -0
  33. package/dist/client.d.ts +19 -0
  34. package/dist/client.js +87 -0
  35. package/dist/contract.d.ts +6 -0
  36. package/dist/contract.js +6 -0
  37. package/dist/headless/ai.d.ts +132 -0
  38. package/dist/headless/ai.js +99 -0
  39. package/dist/headless/hooks.d.ts +276 -0
  40. package/dist/headless/hooks.js +540 -0
  41. package/dist/headless/i18n.d.ts +13 -0
  42. package/dist/headless/i18n.js +45 -0
  43. package/dist/headless/index.d.ts +37 -0
  44. package/dist/headless/index.js +38 -0
  45. package/dist/headless/money.d.ts +25 -0
  46. package/dist/headless/money.js +61 -0
  47. package/dist/headless/page.d.ts +43 -0
  48. package/dist/headless/page.js +53 -0
  49. package/dist/headless/platform.d.ts +55 -0
  50. package/dist/headless/platform.js +77 -0
  51. package/dist/headless/primitives/cart.d.ts +90 -0
  52. package/dist/headless/primitives/cart.js +153 -0
  53. package/dist/headless/primitives/collection.d.ts +68 -0
  54. package/dist/headless/primitives/collection.js +80 -0
  55. package/dist/headless/primitives/product.d.ts +101 -0
  56. package/dist/headless/primitives/product.js +117 -0
  57. package/dist/headless/primitives/storefront.d.ts +106 -0
  58. package/dist/headless/primitives/storefront.js +186 -0
  59. package/dist/headless/primitives/util.d.ts +19 -0
  60. package/dist/headless/primitives/util.js +42 -0
  61. package/dist/headless/strings.d.ts +9 -0
  62. package/dist/headless/strings.js +190 -0
  63. package/dist/headless/structured-data.d.ts +31 -0
  64. package/dist/headless/structured-data.js +57 -0
  65. package/dist/headless/theme.d.ts +99 -0
  66. package/dist/headless/theme.js +54 -0
  67. package/dist/index.d.ts +20 -0
  68. package/dist/index.js +18 -553
  69. package/dist/runtime/data/StoreProvider.d.ts +84 -0
  70. package/dist/runtime/data/StoreProvider.js +373 -0
  71. package/dist/runtime/data/handle.d.ts +14 -0
  72. package/dist/runtime/data/handle.js +16 -0
  73. package/dist/runtime/data/routes.d.ts +87 -0
  74. package/dist/runtime/data/routes.js +158 -0
  75. package/dist/runtime/data/to-ui.d.ts +281 -0
  76. package/dist/runtime/data/to-ui.js +977 -0
  77. package/dist/runtime/entries/register.d.ts +9 -0
  78. package/dist/runtime/entries/register.js +9 -0
  79. package/dist/runtime/entries/sections.d.ts +16 -0
  80. package/dist/runtime/entries/sections.js +19 -0
  81. package/dist/{types → runtime/kit}/SectionTree.d.ts +2 -1
  82. package/dist/runtime/kit/SectionTree.js +100 -0
  83. package/dist/runtime/kit/analytics.d.ts +63 -0
  84. package/dist/runtime/kit/analytics.js +250 -0
  85. package/dist/runtime/kit/cart.d.ts +215 -0
  86. package/dist/runtime/kit/cart.js +545 -0
  87. package/dist/{types → runtime/kit}/composition.d.ts +1 -1
  88. package/dist/runtime/kit/composition.js +3 -0
  89. package/dist/{types → runtime/kit}/config.d.ts +2 -2
  90. package/dist/runtime/kit/config.js +6 -0
  91. package/dist/runtime/kit/consent.d.ts +29 -0
  92. package/dist/runtime/kit/consent.js +159 -0
  93. package/dist/runtime/kit/contract/content.d.ts +199 -0
  94. package/dist/runtime/kit/contract/content.js +106 -0
  95. package/dist/runtime/kit/contract/field-types.d.ts +337 -0
  96. package/dist/runtime/kit/contract/field-types.js +206 -0
  97. package/dist/runtime/kit/contract/groups.d.ts +230 -0
  98. package/dist/runtime/kit/contract/groups.js +402 -0
  99. package/dist/runtime/kit/contract/index.d.ts +33 -0
  100. package/dist/runtime/kit/contract/index.js +33 -0
  101. package/dist/runtime/kit/contract/transform.d.ts +82 -0
  102. package/dist/runtime/kit/contract/transform.js +133 -0
  103. package/dist/runtime/kit/contract/validate.d.ts +75 -0
  104. package/dist/runtime/kit/contract/validate.js +480 -0
  105. package/dist/runtime/kit/data.d.ts +720 -0
  106. package/dist/runtime/kit/data.js +1117 -0
  107. package/dist/{types → runtime/kit}/defineSection.d.ts +1 -1
  108. package/dist/runtime/kit/defineSection.js +10 -0
  109. package/dist/{types → runtime/kit}/dynamic-source.d.ts +40 -18
  110. package/dist/runtime/kit/dynamic-source.js +294 -0
  111. package/dist/runtime/kit/index.d.ts +24 -0
  112. package/dist/runtime/kit/index.js +24 -0
  113. package/dist/{types → runtime/kit}/jsx-to-json.d.ts +1 -1
  114. package/dist/runtime/kit/jsx-to-json.js +28 -0
  115. package/dist/{types → runtime/kit}/mount.d.ts +25 -4
  116. package/dist/runtime/kit/mount.js +124 -0
  117. package/dist/{types → runtime/kit}/registry.d.ts +1 -1
  118. package/dist/runtime/kit/registry.js +12 -0
  119. package/dist/{types → runtime/kit}/ssg.d.ts +9 -3
  120. package/dist/runtime/kit/ssg.js +56 -0
  121. package/dist/runtime/kit/storefront.d.ts +639 -0
  122. package/dist/runtime/kit/storefront.js +723 -0
  123. package/dist/{types → runtime/kit}/theme-context.d.ts +8 -2
  124. package/dist/runtime/kit/theme-context.js +25 -0
  125. package/dist/runtime/kit/types.d.ts +147 -0
  126. package/dist/runtime/kit/types.js +1 -0
  127. package/dist/runtime/platform/TrackingPixels.d.ts +14 -0
  128. package/dist/runtime/platform/TrackingPixels.js +63 -0
  129. package/dist/runtime/platform/environment.d.ts +68 -0
  130. package/dist/runtime/platform/environment.js +85 -0
  131. package/dist/runtime/platform/locale.d.ts +27 -0
  132. package/dist/runtime/platform/locale.js +42 -0
  133. package/dist/runtime/platform/route-analytics.d.ts +15 -0
  134. package/dist/runtime/platform/route-analytics.js +72 -0
  135. package/dist/runtime/platform/safe-href.d.ts +25 -0
  136. package/dist/runtime/platform/safe-href.js +69 -0
  137. package/dist/runtime/platform/safe-values.d.ts +37 -0
  138. package/dist/runtime/platform/safe-values.js +140 -0
  139. package/dist/runtime/render/SectionRenderer.d.ts +4 -0
  140. package/dist/runtime/render/SectionRenderer.js +166 -0
  141. package/dist/runtime/render/listing-query.d.ts +52 -0
  142. package/dist/runtime/render/listing-query.js +122 -0
  143. package/dist/runtime/render/localized-copy.d.ts +86 -0
  144. package/dist/runtime/render/localized-copy.js +129 -0
  145. package/dist/runtime/render/product-listing.d.ts +11 -0
  146. package/dist/runtime/render/product-listing.js +243 -0
  147. package/dist/runtime/render/section-actions.d.ts +66 -0
  148. package/dist/runtime/render/section-actions.js +202 -0
  149. package/dist/runtime/render/starter.d.ts +11 -0
  150. package/dist/runtime/render/starter.js +81 -0
  151. package/dist/runtime/seo/head.d.ts +115 -0
  152. package/dist/runtime/seo/head.js +281 -0
  153. package/dist/runtime/seo/structured-data.d.ts +83 -0
  154. package/dist/runtime/seo/structured-data.js +252 -0
  155. package/dist/runtime/shell/PageShell.d.ts +18 -0
  156. package/dist/runtime/shell/PageShell.js +113 -0
  157. package/dist/runtime/shell/RuntimeBridge.d.ts +14 -0
  158. package/dist/runtime/shell/RuntimeBridge.js +93 -0
  159. package/dist/runtime/shell/overlay-state.d.ts +31 -0
  160. package/dist/runtime/shell/overlay-state.js +59 -0
  161. package/dist/runtime/shell/preview-mode.d.ts +2 -0
  162. package/dist/runtime/shell/preview-mode.js +11 -0
  163. package/dist/runtime/shell/spa-router.d.ts +14 -0
  164. package/dist/runtime/shell/spa-router.js +76 -0
  165. package/dist/runtime/shell/url-redirects.d.ts +6 -0
  166. package/dist/runtime/shell/url-redirects.js +37 -0
  167. package/dist/runtime/slots.d.ts +74 -0
  168. package/dist/runtime/slots.js +16 -0
  169. package/dist/runtime.d.ts +34 -0
  170. package/dist/runtime.js +40 -0
  171. package/dist/sdk/app-block.d.ts +29 -0
  172. package/dist/sdk/app-block.js +22 -0
  173. package/dist/sdk/index.d.ts +26 -0
  174. package/dist/sdk/index.js +26 -0
  175. package/dist/sdk/referrals.d.ts +62 -0
  176. package/dist/sdk/referrals.js +20 -0
  177. package/dist/sdk/rewards.d.ts +85 -0
  178. package/dist/sdk/rewards.js +29 -0
  179. package/dist/sdk/runtime-context.d.ts +202 -0
  180. package/dist/sdk/runtime-context.js +73 -0
  181. package/dist/sdk/schema.d.ts +206 -0
  182. package/dist/sdk/schema.js +121 -0
  183. package/dist/sdk/server-render.d.ts +8 -0
  184. package/dist/sdk/server-render.js +12 -0
  185. package/dist/sdk/store-lookup.d.ts +27 -0
  186. package/dist/sdk/store-lookup.js +29 -0
  187. package/dist/sdk/store.d.ts +149 -0
  188. package/dist/sdk/store.js +5 -0
  189. package/dist/sdk/sx.d.ts +40 -0
  190. package/dist/sdk/sx.js +112 -0
  191. package/dist/sdk/theme.d.ts +191 -0
  192. package/dist/sdk/theme.js +10 -0
  193. package/dist/sdk/types.d.ts +757 -0
  194. package/dist/sdk/types.js +7 -0
  195. package/dist/server.d.ts +111 -0
  196. package/dist/server.js +533 -0
  197. package/docs/headless-api.md +220 -0
  198. package/package.json +76 -22
  199. package/dist/index.js.map +0 -1
  200. package/dist/ssg-BZ5FYTw7.js +0 -1802
  201. package/dist/ssg-BZ5FYTw7.js.map +0 -1
  202. package/dist/ssg.js +0 -8
  203. package/dist/ssg.js.map +0 -1
  204. package/dist/types/cart.d.ts +0 -86
  205. package/dist/types/data.d.ts +0 -357
  206. package/dist/types/editor.d.ts +0 -5
  207. package/dist/types/index.d.ts +0 -20
  208. package/dist/types/preview-bridge.d.ts +0 -9
  209. package/dist/types/storefront.d.ts +0 -333
  210. package/dist/types/types.d.ts +0 -44
package/dist/sdk/sx.js ADDED
@@ -0,0 +1,112 @@
1
+ /** id of the server-emitted `<style>` that carries the page's rules. */
2
+ export const STYLE_RULES_ID = 'tq-style-rules';
3
+ const UNITLESS = new Set([
4
+ 'aspectRatio', 'flex', 'flexGrow', 'flexShrink', 'fontWeight', 'lineHeight', 'opacity', 'order', 'zIndex', 'zoom',
5
+ 'animationIterationCount', 'columnCount', 'gridColumn', 'gridRow', 'scale',
6
+ ]);
7
+ const UNSAFE = /[<>{};\\\n\r]/;
8
+ const hyphenate = (prop) => prop.startsWith('--') ? prop : prop.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`).replace(/^ms-/, '-ms-');
9
+ /** Declarations text of a style object (`prop:value;…`), unsafe values dropped. */
10
+ export function declarations(style) {
11
+ const out = [];
12
+ for (const [prop, raw] of Object.entries(style)) {
13
+ if (raw === undefined || raw === null || raw === '' || typeof raw === 'boolean')
14
+ continue;
15
+ const value = typeof raw === 'number' && raw !== 0 && !prop.startsWith('--') && !UNITLESS.has(prop) ? `${raw}px` : String(raw);
16
+ if (UNSAFE.test(value) && !/^url\("[^"<>\\\n]*"\)$/.test(value))
17
+ continue;
18
+ out.push(`${hyphenate(prop)}:${value}`);
19
+ }
20
+ return out.join(';');
21
+ }
22
+ /** FNV-1a 32-bit, base36 — the same on the server and in the browser. */
23
+ function hash(text) {
24
+ let h = 0x811c9dc5;
25
+ for (let i = 0; i < text.length; i++) {
26
+ h ^= text.charCodeAt(i);
27
+ h = Math.imul(h, 0x01000193);
28
+ }
29
+ return (h >>> 0).toString(36);
30
+ }
31
+ // ── server: one sink per synchronous render ─────────────────────────────────
32
+ let serverSink = null;
33
+ /**
34
+ * Run `render` (a synchronous `renderToString`) with a fresh sink and return its output plus the
35
+ * rules it used. The sink exists only for that call.
36
+ */
37
+ export function collectStyles(render) {
38
+ const rules = new Map();
39
+ const prev = serverSink;
40
+ serverSink = { add: (c, d) => { if (!rules.has(c))
41
+ rules.set(c, d); } };
42
+ try {
43
+ const result = render();
44
+ return { result, css: [...rules].map(([c, d]) => `.${c}{${d}}`).join('') };
45
+ }
46
+ finally {
47
+ serverSink = prev;
48
+ }
49
+ }
50
+ // ── browser: CSSOM ──────────────────────────────────────────────────────────
51
+ let browserSink = null;
52
+ function constructedSheet() {
53
+ if (typeof CSSStyleSheet === 'function' && 'adoptedStyleSheets' in document) {
54
+ try {
55
+ const sheet = new CSSStyleSheet();
56
+ document.adoptedStyleSheets = [...document.adoptedStyleSheets, sheet];
57
+ return sheet;
58
+ }
59
+ catch {
60
+ /* fall through */
61
+ }
62
+ }
63
+ // Environments without constructable stylesheets (jsdom in unit tests).
64
+ const el = document.createElement('style');
65
+ el.setAttribute('data-tq-rules', 'live');
66
+ document.head.appendChild(el);
67
+ return el.sheet;
68
+ }
69
+ function getBrowserSink() {
70
+ if (typeof document === 'undefined')
71
+ return null;
72
+ if (browserSink)
73
+ return browserSink;
74
+ const known = new Set();
75
+ const el = document.getElementById(STYLE_RULES_ID);
76
+ for (const m of (el?.textContent ?? '').matchAll(/\.(tqs-[a-z0-9]+)\{/g))
77
+ known.add(m[1]);
78
+ let sheet = null;
79
+ browserSink = {
80
+ add(className, decl) {
81
+ if (known.has(className))
82
+ return;
83
+ known.add(className);
84
+ sheet ??= constructedSheet();
85
+ if (!sheet)
86
+ return;
87
+ try {
88
+ sheet.insertRule(`.${className}{${decl}}`, sheet.cssRules.length);
89
+ }
90
+ catch {
91
+ /* a declaration the browser rejects is simply not applied */
92
+ }
93
+ },
94
+ };
95
+ return browserSink;
96
+ }
97
+ /** `sx(style)` → a class name carrying those declarations (undefined for an empty style). */
98
+ export function sx(style) {
99
+ if (!style)
100
+ return undefined;
101
+ const decl = declarations(style);
102
+ if (!decl)
103
+ return undefined;
104
+ const className = `tqs-${hash(decl)}`;
105
+ (serverSink ?? getBrowserSink())?.add(className, decl);
106
+ return className;
107
+ }
108
+ /** Join class names, skipping empty ones. */
109
+ export function cx(...names) {
110
+ const s = names.filter(Boolean).join(' ');
111
+ return s || undefined;
112
+ }
@@ -0,0 +1,191 @@
1
+ /**
2
+ * How a theme describes itself to the platform: its sections and its shell.
3
+ *
4
+ * export default defineTheme({ name, sections, Provider, Layout, labels })
5
+ *
6
+ * The theme compiler reads this to build the editor's catalog; the theme
7
+ * runtime reads it to render pages. Neither needs anything else from the theme.
8
+ */
9
+ import type { ComponentType, ReactNode } from 'react';
10
+ import type { Field, Schema } from './schema.js';
11
+ import type { SavedSection, StoreContext } from './store.js';
12
+ import type { ThemeActions, ThemeContextValue, ThemeMode } from './runtime-context.js';
13
+ export type SectionZone = 'header' | 'main' | 'footer';
14
+ export interface SectionPreset {
15
+ name: string;
16
+ label?: string;
17
+ settings: Record<string, unknown>;
18
+ blocks?: {
19
+ type: string;
20
+ settings?: Record<string, unknown>;
21
+ }[];
22
+ }
23
+ /** What a section's data binding receives besides the saved node and the store. */
24
+ export interface SectionBindingContext {
25
+ /** The platform actions (for callback props: add to cart, search …). */
26
+ actions: ThemeActions;
27
+ /** Page state (cart line status, mode, locale). */
28
+ context: ThemeContextValue;
29
+ /** The page this section is on. */
30
+ page: {
31
+ /** The first section of the page body (a header over a hero goes transparent). */
32
+ firstBodySection: SavedSection | null;
33
+ /** This section is that first body section. */
34
+ isFirstBodySection: boolean;
35
+ };
36
+ }
37
+ export interface ThemeSection<P = any> {
38
+ /** The persisted section type — never changes once stores have saved it. */
39
+ id: string;
40
+ /** Settings (persisted ids, controls, defaults, legacy values). */
41
+ schema: Schema;
42
+ /**
43
+ * The block schemas this section accepts — one per name in `schema.blocks`
44
+ * and `schema.legacyBlocks`. The section owns its block contracts: the
45
+ * compiler reads blocks from here, never from a separate registry.
46
+ */
47
+ blocks?: readonly Schema[];
48
+ component: ComponentType<P>;
49
+ /** Picker group. */
50
+ category: string;
51
+ /** Where the page places it: header zone, page body, footer zone. */
52
+ zone: SectionZone;
53
+ /** How the editor names it in "Add section". */
54
+ title?: string;
55
+ /** One line for the editor's picker: what it shows and when to use it. */
56
+ description?: string;
57
+ icon?: string;
58
+ /** Route context it needs (`product`, `collection`, `cart` …): offered only on templates that have it. */
59
+ requiresContext?: readonly string[];
60
+ /** Starting points "Add section" offers. */
61
+ presets?: readonly SectionPreset[];
62
+ /** Pages through a collection: the runtime adds paging (load more) to its props. */
63
+ listing?: boolean;
64
+ /**
65
+ * Saved node + store data → the component's props. Absent: the resolved
66
+ * settings are the props.
67
+ */
68
+ data?: (node: SavedSection, store: StoreContext, binding: SectionBindingContext) => P | null;
69
+ }
70
+ export interface ThemeProviderProps {
71
+ mode: ThemeMode;
72
+ locale: string;
73
+ /** The language the page's content is in (the request's), when the host knows it; `lang` follows it. */
74
+ contentLanguage?: string;
75
+ settings: Readonly<Record<string, unknown>>;
76
+ /**
77
+ * The merchant's words for the theme's own strings in the page's language (Settings > Languages > Translate, the
78
+ * theme's "Default theme content"; abi/labels.ts): string key -> text. A theme lays them over its locale file, so a
79
+ * language it ships no file for still reads in the shopper's language. Absent or empty: the theme's own words.
80
+ */
81
+ labels?: Readonly<Record<string, string>>;
82
+ children: ReactNode;
83
+ }
84
+ export interface ThemeDefinition {
85
+ name: string;
86
+ /** Every section, in the editor picker's order. */
87
+ sections: readonly ThemeSection[];
88
+ /** Wraps every page and the editor's single-section preview: tokens, theme settings, strings. */
89
+ Provider: ComponentType<ThemeProviderProps>;
90
+ /** The page layout around the page's sections — and where page-level overlays render. */
91
+ Layout: ComponentType<{
92
+ children: ReactNode;
93
+ }>;
94
+ /**
95
+ * Interface words the runtime needs for the breadcrumb trail, in a locale. Each key is also the key of the same word
96
+ * in the theme's locale files: the merchant's translation of that key (`ThemeProviderProps.labels`) wins over it.
97
+ */
98
+ labels(locale: string): {
99
+ home: string;
100
+ collections?: string;
101
+ search?: string;
102
+ cart?: string;
103
+ account?: string;
104
+ };
105
+ /** External stylesheets every page loads in <head> (web fonts). */
106
+ stylesheets?: readonly string[];
107
+ /**
108
+ * Starter text: words that only tell the merchant what to write ("Describe
109
+ * your returns window.", "Customer name"). The editor shows them as they are;
110
+ * on the live storefront a section whose own settings still hold one is not
111
+ * rendered, and a block that holds one is left out — a shopper never reads an
112
+ * instruction, or a review nobody wrote. Exact strings, compared trimmed.
113
+ */
114
+ starterText?: readonly string[];
115
+ /**
116
+ * Shipped copy: the English words this theme ships in setting defaults,
117
+ * starter templates and presets, as `<prefix>*` keys of its English locale
118
+ * map. A copy field whose value is exactly one of them (unset → its default)
119
+ * renders as that key in the page's locale; any other value is the
120
+ * merchant's and renders verbatim (runtime/render/localized-copy.ts).
121
+ */
122
+ shippedCopy?: {
123
+ english: Readonly<Record<string, string>>;
124
+ prefix: string;
125
+ /** Fields whose renderer tests the value against the shipped English: never localized (`block:footer-brand.title`). */
126
+ keep?: readonly string[];
127
+ /** Fields whose unset value is derived from data: their default is never filled in (`block:footer-menu.heading`). */
128
+ derivedWhenUnset?: readonly string[];
129
+ };
130
+ /**
131
+ * The settings every section shares (width, spacing, background …), with the
132
+ * editor group of each — published so a custom section can fold them in.
133
+ */
134
+ sharedSettings?: {
135
+ fields: Readonly<Record<string, Field>>;
136
+ groups?: Readonly<Record<string, string>>;
137
+ contentSlots?: readonly string[];
138
+ };
139
+ }
140
+ /** One theme setting (config/settings.schema.ts): the control the editor's Theme panel shows. */
141
+ export interface SettingSpec {
142
+ type: 'text' | 'textarea' | 'richtext' | 'url' | 'color' | 'image' | 'select' | 'radio' | 'boolean' | 'range' | 'number' | 'menu' | 'list' | 'color_palette';
143
+ /**
144
+ * A `list` setting's element. A theme's colour palette is `color_palette` (field-type registry 3): named
145
+ * colours `{ name, color }`, at most 20; the editor offers them in every colour picker.
146
+ */
147
+ items?: {
148
+ type: 'color';
149
+ };
150
+ label?: string;
151
+ /** Theme panel group. */
152
+ group?: string;
153
+ info?: string;
154
+ default?: unknown;
155
+ /**
156
+ * `group`: the option's heading in the editor's list (the font picker's System / Library).
157
+ * `scripts`: the writing systems a font option covers (`'latin'`, `'thai'`), shown as a tag in the font picker.
158
+ * Both are editor-only: the ABI manifest keeps `{ value, label }`.
159
+ */
160
+ options?: {
161
+ value: string;
162
+ label: string;
163
+ group?: string;
164
+ scripts?: readonly string[];
165
+ }[];
166
+ /**
167
+ * How the editor draws a select: `font` = the font picker (search, system fonts, the hosted library);
168
+ * `color_scheme` = the scheme picker, each option shown with its colours (`swatches`). Editor-only.
169
+ */
170
+ control?: 'font' | 'color_scheme';
171
+ /** A font setting's weight: the id of the select setting that holds it (the font picker's Weight). Editor-only. */
172
+ weight_setting?: string;
173
+ /** A `color_scheme` select's colours per option (`setting` = this setting's id). Editor-only. */
174
+ swatches?: {
175
+ setting: string;
176
+ colours: {
177
+ label: string;
178
+ values: Record<string, string>;
179
+ }[];
180
+ };
181
+ min?: number;
182
+ /** `range` / `number`: the largest value. `list` / `color_palette`: the most entries. */
183
+ max?: number;
184
+ step?: number;
185
+ unit?: string;
186
+ placeholder?: string;
187
+ }
188
+ /** Declare the theme's settings (the Theme panel). */
189
+ export declare function defineSettings<T extends Record<string, SettingSpec>>(settings: T): T;
190
+ export declare function defineTheme(theme: ThemeDefinition): ThemeDefinition;
191
+ export declare function defineSection<P>(section: ThemeSection<P>): ThemeSection<P>;
@@ -0,0 +1,10 @@
1
+ /** Declare the theme's settings (the Theme panel). */
2
+ export function defineSettings(settings) {
3
+ return settings;
4
+ }
5
+ export function defineTheme(theme) {
6
+ return theme;
7
+ }
8
+ export function defineSection(section) {
9
+ return section;
10
+ }