@tanqory/theme-kit 0.1.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.
@@ -0,0 +1,357 @@
1
+ import { type ReactNode } from 'react';
2
+ import { type StorefrontExtensions } from './storefront';
3
+ export interface Money {
4
+ amount: string;
5
+ currencyCode: string;
6
+ }
7
+ export interface ProductOption {
8
+ name: string;
9
+ values: string[];
10
+ }
11
+ export interface ImageRef {
12
+ url: string;
13
+ altText?: string;
14
+ }
15
+ /** SEO snapshot (Product/Page/Article). */
16
+ export interface Seo {
17
+ title?: string | null;
18
+ description?: string | null;
19
+ }
20
+ /** Per-variant cart quantity bounds (wholesale / case-of-N). Storefront cart enforces these. */
21
+ export interface QuantityRule {
22
+ minimum: number;
23
+ maximum: number | null;
24
+ increment: number;
25
+ }
26
+ /** Per-unit pricing ("$2.50 / 100ml"). */
27
+ export interface UnitPriceMeasurement {
28
+ measuredType: string;
29
+ quantityValue: number;
30
+ quantityUnit: string;
31
+ referenceValue: number;
32
+ referenceUnit: string;
33
+ }
34
+ /** Pickup / in-store stock for one location. */
35
+ export interface StoreAvailability {
36
+ available: boolean;
37
+ quantityAvailable: number;
38
+ pickUpTime?: string | null;
39
+ location: {
40
+ id: string;
41
+ name: string;
42
+ };
43
+ }
44
+ export interface SellingPlanOption {
45
+ name: string;
46
+ value: string;
47
+ }
48
+ export interface SellingPlan {
49
+ id: string;
50
+ name: string;
51
+ description?: string | null;
52
+ recurringDeliveries: boolean;
53
+ options: SellingPlanOption[];
54
+ }
55
+ export interface SellingPlanGroup {
56
+ name: string;
57
+ appName?: string | null;
58
+ options: Array<{
59
+ name: string;
60
+ values: string[];
61
+ }>;
62
+ sellingPlans: SellingPlan[];
63
+ }
64
+ export interface ProductVariant {
65
+ id: string;
66
+ title: string;
67
+ price: Money;
68
+ /** "Was" price — present when the variant is on sale (compareAtPrice > price). */
69
+ compareAtPrice?: Money | null;
70
+ availableForSale: boolean;
71
+ selectedOptions?: {
72
+ name: string;
73
+ value: string;
74
+ }[];
75
+ image?: ImageRef | null;
76
+ /** Stock-keeping unit. Only after `fetchProduct()`. */
77
+ sku?: string | null;
78
+ /** Cart quantity bounds (min/max/increment). */
79
+ quantityRule?: QuantityRule;
80
+ /** Per-unit price ("$2.50 / 100ml") for measured products. */
81
+ unitPrice?: Money | null;
82
+ unitPriceMeasurement?: UnitPriceMeasurement | null;
83
+ /** Pickup availability per location (only after `fetchProduct()`). */
84
+ storeAvailability?: StoreAvailability[];
85
+ }
86
+ export interface Product {
87
+ /** Storefront GraphQL node id (present for live data). */
88
+ id?: string;
89
+ handle: string;
90
+ title: string;
91
+ price: Money;
92
+ /** Range "was" price (max compareAtPrice across variants) — sale badge on cards. */
93
+ compareAtPrice?: Money | null;
94
+ featuredImage?: ImageRef | null;
95
+ /** Default purchasable variant id (`firstAvailableVariant`) — enough to add
96
+ * to cart from a grid/card without loading the full variant list. */
97
+ variantId?: string;
98
+ availableForSale?: boolean;
99
+ /** Catalog facets (card badges / filtering). Present from boot. */
100
+ vendor?: string | null;
101
+ productType?: string | null;
102
+ tags?: string[];
103
+ /** Long description — only populated by `fetchProduct()` (PDP). */
104
+ description?: string;
105
+ /** Image gallery — only after `fetchProduct()` (PDP). */
106
+ images?: ImageRef[];
107
+ /** Option definitions (Size, Color…) — only after `fetchProduct()`. */
108
+ options?: ProductOption[];
109
+ /** Full variant list — only after `fetchProduct()` (PDP). */
110
+ variants?: ProductVariant[];
111
+ /** Subscription / selling-plan groups — only after `fetchProduct()`. */
112
+ sellingPlanGroups?: SellingPlanGroup[];
113
+ /** Requested custom metafields ("namespace.key" → value) — pass identifiers to fetchProduct(). */
114
+ metafields?: Record<string, string | null>;
115
+ /** SEO override — only after `fetchProduct()`. */
116
+ seo?: Seo | null;
117
+ }
118
+ export interface Collection {
119
+ handle: string;
120
+ title: string;
121
+ /** Optional hero image; falls back to first product's featuredImage. */
122
+ image?: {
123
+ url?: string;
124
+ altText?: string;
125
+ } | null;
126
+ products: Product[];
127
+ /** Custom metafields ("namespace.key" → value) for dynamic sources. */
128
+ metafields?: Record<string, string | null>;
129
+ }
130
+ export interface Page {
131
+ handle: string;
132
+ title: string;
133
+ /** HTML body — rendered via dangerouslySetInnerHTML by the PageBody section. */
134
+ body: string;
135
+ bodySummary?: string;
136
+ author?: string | null;
137
+ publishedAt?: string;
138
+ updatedAt?: string;
139
+ }
140
+ /**
141
+ * The data interface every block consumes. Themes provide an implementation.
142
+ *
143
+ * Core read methods (collections/products/pages/localization) are always
144
+ * present. The Shopify-compatible extensions (shop, menus, search, blog,
145
+ * recommendations, metaobjects, customer account) come from `StorefrontExtensions`
146
+ * and are LIVE-ONLY — undefined under mock data, so themes feature-detect them
147
+ * (`data.search?.(...)`, `data.customer?.login(...)`).
148
+ */
149
+ export interface DataApi extends StorefrontExtensions {
150
+ collectionByHandle: (handle: string) => Collection | null;
151
+ /** All known collections (used by CollectionList). */
152
+ allCollections: () => Collection[];
153
+ /**
154
+ * List every navigation menu the store has (Dashboard → Navigation), for the
155
+ * editor's `link_list` picker. Identity only (handle/title/count) — fetch a
156
+ * menu's items with `fetchMenu(handle)`. Optional: older payloads may omit it.
157
+ */
158
+ listMenus?: () => Promise<Array<{
159
+ handle: string;
160
+ title: string;
161
+ itemsCount: number;
162
+ }>>;
163
+ /** Connected tracking pixels (Settings → Customer events) to inject on the
164
+ * storefront. Optional — older payloads / mock mode return []. */
165
+ pixels?: () => Promise<Array<{
166
+ id: string;
167
+ name: string;
168
+ provider: string | null;
169
+ providerPixelId: string | null;
170
+ code: string | null;
171
+ }>>;
172
+ /** Physical store locations (Settings → Locations) for a store-locator. */
173
+ locations?: () => Promise<Array<{
174
+ id: string;
175
+ name: string;
176
+ code: string | null;
177
+ address: {
178
+ country: string | null;
179
+ address: string | null;
180
+ city: string | null;
181
+ province: string | null;
182
+ postalCode: string | null;
183
+ phone: string | null;
184
+ } | null;
185
+ }>>;
186
+ /**
187
+ * Look up a single product by its handle. Returns null when the handle
188
+ * isn't found. Required by FeaturedProduct / ProductDetails sections
189
+ * (ported from the canonical examples/react theme in PR #2).
190
+ */
191
+ productByHandle: (handle: string) => Product | null;
192
+ /**
193
+ * Look up a Page by handle (the storefront's `/pages/<handle>` content).
194
+ * Returns null if the handle wasn't prefetched at boot or the merchant
195
+ * hasn't published a page with that handle. Live data prefetches only the
196
+ * page matching the current URL, so other handles return null even when
197
+ * they exist in the backend — themes should only call this for the page
198
+ * the user is on.
199
+ */
200
+ pageByHandle: (handle: string) => Page | null;
201
+ /** Localization snapshot — what markets/countries the store has live.
202
+ * null = mock data; the country switcher should hide itself. */
203
+ localization: Localization | null;
204
+ /**
205
+ * Raw GraphQL escape hatch against the same storefront endpoint the live
206
+ * data source was booted with. Present ONLY for live data — undefined for
207
+ * mock data. Powers post-boot interactions (the cart's mutations live here).
208
+ */
209
+ graphql?: <T = unknown>(query: string, variables?: Record<string, unknown>) => Promise<T>;
210
+ /**
211
+ * Fetch a single product WITH its full options + variants on demand (for the
212
+ * product page's variant picker). Live data hits the backend; mock data
213
+ * resolves synchronously from the prefetched cache. Returns null if missing.
214
+ */
215
+ fetchProduct?: (handle: string, opts?: {
216
+ metafields?: Array<{
217
+ namespace: string;
218
+ key: string;
219
+ }>;
220
+ }) => Promise<Product | null>;
221
+ /**
222
+ * Fetch the shop's custom metafields by identifier (for dynamic sources).
223
+ * Live data queries `shop { metafields(identifiers) }`; mock data returns {}
224
+ * (no metafields offline). Result keys are "namespace.key".
225
+ */
226
+ fetchShopMetafields?: (identifiers: Array<{
227
+ namespace: string;
228
+ key: string;
229
+ }>) => Promise<Record<string, string | null>>;
230
+ /**
231
+ * Fetch a collection's custom metafields by identifier (for dynamic sources).
232
+ * Result keys are "namespace.key".
233
+ */
234
+ fetchCollectionMetafields?: (handle: string, identifiers: Array<{
235
+ namespace: string;
236
+ key: string;
237
+ }>) => Promise<Record<string, string | null>>;
238
+ /**
239
+ * The raw serializable bootstrap payload this live DataApi was built from
240
+ * (null for mock data). The SSG step embeds it into the page as
241
+ * `window.__TQ_STATE__` so the client can rebuild the identical DataApi
242
+ * synchronously at hydration via createLiveDataFromSnapshot — SSR markup and
243
+ * the client's first render match by construction.
244
+ */
245
+ getSnapshot?: () => unknown;
246
+ }
247
+ /** Country/market shape mirrored from storefront GraphQL `Localization`. */
248
+ export interface LocalizedCurrency {
249
+ isoCode: string;
250
+ name?: string;
251
+ symbol?: string;
252
+ }
253
+ export interface LocalizedMarket {
254
+ id: string;
255
+ handle: string;
256
+ name: string;
257
+ }
258
+ export interface LocalizedCountry {
259
+ isoCode: string;
260
+ name: string;
261
+ currency: LocalizedCurrency;
262
+ market: LocalizedMarket | null;
263
+ }
264
+ /** A language the store has published (dashboard → Markets / Languages). */
265
+ export interface LocalizedLanguage {
266
+ isoCode: string;
267
+ name: string;
268
+ }
269
+ export interface Localization {
270
+ /** Currently-active country (resolved from the request's X-Tanqory-Country). */
271
+ country: LocalizedCountry;
272
+ /** Every country the store has an active Market for — what the picker shows. */
273
+ availableCountries: LocalizedCountry[];
274
+ /**
275
+ * Currently-active language + every language the store has PUBLISHED. These
276
+ * are STORE/dashboard data (the merchant's published locales), not a theme
277
+ * config list — the theme only ships the translations. Optional so older live
278
+ * payloads (countries only) still satisfy the type; the picker falls back to a
279
+ * single default when absent.
280
+ */
281
+ language?: LocalizedLanguage;
282
+ availableLanguages?: LocalizedLanguage[];
283
+ }
284
+ /** Wraps the app with a theme-provided data source (mock or live). */
285
+ export declare function DataProvider({ value, children }: {
286
+ value: DataApi;
287
+ children: ReactNode;
288
+ }): JSX.Element;
289
+ export declare function useData(): DataApi;
290
+ /** Build an offline data source from fixture collections (theme passes its JSON). */
291
+ export declare function createMockData(collections: Collection[]): DataApi;
292
+ /**
293
+ * Live data source backed by the Tanqory Storefront GraphQL API.
294
+ *
295
+ * const data = await createLiveData({
296
+ * endpoint: 'https://api-do-sgp1.tanqory.com',
297
+ * storeId: '<store-uuid>',
298
+ * token: '<publishable-storefront-token>',
299
+ * prefetch: { collectionLimit: 20, productLimitPerCollection: 24 },
300
+ * })
301
+ *
302
+ * Returns the same `DataApi` shape as `createMockData` (sync read methods)
303
+ * by pre-fetching collections + their products at boot and serving every
304
+ * subsequent lookup from an in-memory cache. The trade-off: a single GraphQL
305
+ * round-trip at boot, then zero network on render — exactly what the SSG
306
+ * step + first hydration need.
307
+ *
308
+ * Per-handle pages (e.g. /products/<handle>) that miss the prefetch can
309
+ * still be fetched lazily via `dataApi.refresh()` (TODO) — for now, raise
310
+ * `prefetch.productLimitPerCollection` to cover the catalogue size.
311
+ */
312
+ export interface LiveDataOptions {
313
+ /** Base URL of the store-api (e.g. https://api-do-sgp1.tanqory.com). */
314
+ endpoint: string;
315
+ /** Store UUID (the `:storeId` path param). */
316
+ storeId: string;
317
+ /** Publishable storefront token — passed as `x-publishable-key`. */
318
+ token?: string;
319
+ /**
320
+ * ISO 3166 alpha-2 (e.g. "TH", "SG", "US"). When set, the backend resolves
321
+ * the matching Market for this country, applies its currency + exchange
322
+ * rate, and returns Money fields in that currency. Falls back to store
323
+ * base currency if no Market matches the country.
324
+ */
325
+ country?: string;
326
+ /** Optional fetch override (testing / SSR). */
327
+ fetcher?: typeof fetch;
328
+ /**
329
+ * Page handle (from `/pages/<handle>`) to fetch alongside the homepage
330
+ * bootstrap. The theme entry resolves the current URL once at boot and
331
+ * passes the matching handle here so the PageBody section can read
332
+ * `dataApi.pageByHandle(handle)` synchronously during hydration.
333
+ */
334
+ pageHandle?: string;
335
+ /** Tune how much to load at boot. */
336
+ prefetch?: {
337
+ /** Max collections to fetch (default 20). */
338
+ collectionLimit?: number;
339
+ /** Max products to inline under each collection (default 24). */
340
+ productLimitPerCollection?: number;
341
+ /** Max products to fetch at the top level (default 24) — these power the
342
+ * synthesized `featured` / `all` virtual collections when the store has
343
+ * no real collections yet. */
344
+ topProductLimit?: number;
345
+ };
346
+ }
347
+ export declare function createLiveData(opts: LiveDataOptions): Promise<DataApi>;
348
+ /**
349
+ * Build a live DataApi SYNCHRONOUSLY from a previously-fetched bootstrap
350
+ * payload (`data.getSnapshot()`, serialized into the SSG HTML as
351
+ * `window.__TQ_STATE__` by the prerender step). This is what makes hydration
352
+ * deterministic: the client's first render uses the EXACT data the server
353
+ * rendered with — no network round-trip, no drift, no mock fallback — and
354
+ * mount()'s `revalidate` swaps in fresh data after hydration (SWR).
355
+ */
356
+ export declare function createLiveDataFromSnapshot(snapshot: unknown, opts: LiveDataOptions): DataApi;
357
+ export declare function formatMoney(money: Money): string;
@@ -0,0 +1,7 @@
1
+ import type { SectionDef } from './types';
2
+ /**
3
+ * Declare a section (a top-level, editor-placeable unit). Attaches `blockName`
4
+ * to the component so a JSX composition (`<Hero/>`) can be walked back into the
5
+ * content tree (see jsx-to-json.ts).
6
+ */
7
+ export declare function defineSection(def: SectionDef): SectionDef;
@@ -0,0 +1,84 @@
1
+ /**
2
+ * Dynamic sources — bind a section/block setting to a live metafield, resource
3
+ * property, or metaobject field (Shopify "Insert dynamic source", the ⛁ icon).
4
+ *
5
+ * A setting value is normally a primitive. When the merchant connects a dynamic
6
+ * source the editor stores a `{ '@source': '<path>' }` object instead, and the
7
+ * theme resolves it at render against the CURRENT page resource:
8
+ *
9
+ * product.metafields.custom.subtitle → the page product's metafield
10
+ * collection.metafields.custom.tagline → the page collection's metafield
11
+ * shop.metafields.custom.announcement → the store's metafield (any page)
12
+ * product.title / shop.name → a plain resource property
13
+ * metaobject:size:medium.label → a metaobject field (type:handle.key)
14
+ *
15
+ * The path grammar mirrors Shopify so themes/docs are portable. Resolution is
16
+ * synchronous against already-loaded resources — the provider is responsible
17
+ * for loading the bound metafields (see `collectBoundIdentifiers`).
18
+ */
19
+ import { type ReactNode } from 'react';
20
+ import type { Product, Collection } from './data';
21
+ import type { Shop, Metaobject } from './storefront';
22
+ /** A setting bound to a dynamic source instead of a literal value. */
23
+ export interface BoundSource {
24
+ '@source': string;
25
+ }
26
+ export type Bound<T> = T | BoundSource;
27
+ export declare function isBoundSource(v: unknown): v is BoundSource;
28
+ /** Resources a dynamic source can read from on the current page. */
29
+ export interface ResourceContextValue {
30
+ shop?: (Shop & {
31
+ metafields?: Record<string, string | null>;
32
+ }) | null;
33
+ product?: (Product & {
34
+ metafields?: Record<string, string | null>;
35
+ }) | null;
36
+ collection?: (Collection & {
37
+ metafields?: Record<string, string | null>;
38
+ }) | null;
39
+ /** Synchronous metaobject lookup (type, handle) → entry, from a warmed cache. */
40
+ metaobject?: (type: string, handle: string) => Metaobject | null;
41
+ }
42
+ /**
43
+ * Provide the current page's resources to dynamic sources. Wrap the page once
44
+ * (the layout does this). `shop` falls back to the data source so shop-level
45
+ * bindings work on every page without extra wiring.
46
+ */
47
+ export declare function DynamicSourceProvider({ value, children, }: {
48
+ value: ResourceContextValue;
49
+ children: ReactNode;
50
+ }): JSX.Element;
51
+ export declare function useResourceContext(): ResourceContextValue;
52
+ /** Resolve a `@source` path against a resource context. Returns null if unbound. */
53
+ export declare function resolveBoundSource(source: string, ctx: ResourceContextValue): string | null;
54
+ /**
55
+ * Resolve a possibly-bound setting value for the current page.
56
+ * const heading = useBound(attributes.heading) // string | the literal | null
57
+ * A plain value passes through unchanged; a `{ '@source' }` object resolves to
58
+ * the live value (or null when the source has no value on this resource).
59
+ */
60
+ export declare function useBound(value: unknown): unknown;
61
+ /** Convenience: resolve to a string (empty when null/unbound-empty). */
62
+ export declare function useBoundText(value: unknown, fallback?: string): string;
63
+ /**
64
+ * Walk a content tree's section/block settings and collect every bound metafield
65
+ * identifier, grouped by resource. The provider uses this to request exactly the
66
+ * metafields the page binds (the live product/collection query takes identifiers).
67
+ */
68
+ export declare function collectBoundIdentifiers(nodes: Array<{
69
+ settings?: Record<string, unknown>;
70
+ blocks?: unknown[];
71
+ }> | undefined): {
72
+ product: Array<{
73
+ namespace: string;
74
+ key: string;
75
+ }>;
76
+ collection: Array<{
77
+ namespace: string;
78
+ key: string;
79
+ }>;
80
+ shop: Array<{
81
+ namespace: string;
82
+ key: string;
83
+ }>;
84
+ };
@@ -0,0 +1,5 @@
1
+ import type { ContentNode } from './types';
2
+ export declare function Editor({ pages, initialPage }: {
3
+ pages: Record<string, ContentNode[]>;
4
+ initialPage?: string;
5
+ }): JSX.Element;
@@ -0,0 +1,20 @@
1
+ export { defineSection } from './defineSection';
2
+ export { defineTheme, defineSettings, type ThemeConfig, type SettingsSchema } from './config';
3
+ export { ThemeProvider, useSettings, useT } from './theme-context';
4
+ export { mount, type MountOptions } from './mount';
5
+ export { renderStorefrontHTML, renderSectionPreviewHTML } from './ssg';
6
+ export { SectionTree } from './SectionTree';
7
+ export { Editor } from './editor';
8
+ export { registerSections, getSection, allSections } from './registry';
9
+ export { DataProvider, useData, createMockData, createLiveData, createLiveDataFromSnapshot, formatMoney, } from './data';
10
+ export { CartProvider, useCart } from './cart';
11
+ export { DynamicSourceProvider, useResourceContext, useBound, useBoundText, isBoundSource, resolveBoundSource, collectBoundIdentifiers, } from './dynamic-source';
12
+ export type { Bound, BoundSource, ResourceContextValue } from './dynamic-source';
13
+ export type { CartApi, CartLine, CartState, AddToCartInput, AppliedDiscountCode, AppliedGiftCard, } from './cart';
14
+ export type { LiveDataOptions, Localization, LocalizedCountry, LocalizedMarket, LocalizedCurrency, ProductOption, ProductVariant, ImageRef, QuantityRule, UnitPriceMeasurement, StoreAvailability, SellingPlan, SellingPlanOption, SellingPlanGroup, } from './data';
15
+ export { jsxToJSON } from './jsx-to-json';
16
+ export { tag, type Tag } from './composition';
17
+ export type { Money, Product, Collection, DataApi } from './data';
18
+ export type { SectionDef, SectionProps, ContentNode, PageDoc, AttrSpec } from './types';
19
+ export { customerTokenStore } from './storefront';
20
+ export type { StorefrontExtensions, Menu, MenuItem, MenuItemType, Blog, Article, SearchResults, CollectionProductsPage, PredictiveSearchResults, PageInfo, Filter, Metaobject, MetaobjectField, Shop, ShopPolicy, Image as StorefrontImage, Seo, CustomerApi, Customer, CustomerAddress, CustomerAddressInput, Order, OrderLineItem, AuthResult, MutationResult, } from './storefront';
@@ -0,0 +1,13 @@
1
+ import { type ReactNode } from 'react';
2
+ import type { ContentNode } from './types';
3
+ /**
4
+ * Compile a *static* JSX composition into the canonical JSON block tree.
5
+ *
6
+ * <Hero settings={{…}}><Button settings={{…}} /></Hero>
7
+ * → [{ type:'hero', settings:{…}, blocks:[{ type:'button', settings:{…} }] }]
8
+ *
9
+ * Only nesting + literal `settings` are read — there is no place for logic, which
10
+ * is exactly what keeps a page round-trippable by the editor. (Logic lives in
11
+ * the block components, never in a page composition.)
12
+ */
13
+ export declare function jsxToJSON(node: ReactNode): ContentNode[];
@@ -0,0 +1,42 @@
1
+ import { type DataApi } from './data';
2
+ type GlobMap = Record<string, unknown>;
3
+ export interface MountOptions {
4
+ /** import.meta.glob('./sections/*.tsx', { eager: true }) — run in the THEME. */
5
+ sections: GlobMap;
6
+ /** import.meta.glob('./templates/*.json', { eager: true }). */
7
+ pages: GlobMap;
8
+ /** import.meta.glob('./layouts/*.tsx', { eager: true }) — optional. */
9
+ shell?: GlobMap;
10
+ /** Data source the theme provides (createMockData(...) or a live client). */
11
+ data: DataApi;
12
+ /** Global settings values (config/settings.json). */
13
+ settings?: Record<string, unknown>;
14
+ /** Locale strings (locales/<lang>.json). */
15
+ locale?: Record<string, string>;
16
+ /** Which page to render (default 'index'). */
17
+ page?: string;
18
+ /** Mount target id (default 'root'). */
19
+ rootId?: string;
20
+ /**
21
+ * SWR refresh: the initial render uses `data` (the SSG snapshot — so
22
+ * hydration matches the server markup by construction), then this runs once
23
+ * after mount and the fresh result is swapped in. Return null/reject to keep
24
+ * the snapshot data (e.g. the network is down).
25
+ */
26
+ revalidate?: () => Promise<DataApi | null>;
27
+ /**
28
+ * Force client rendering even when SSG markup exists in the root (wipe +
29
+ * createRoot instead of hydrateRoot). Pass when the prerendered markup is
30
+ * known NOT to match what the client will render — a different page than the
31
+ * one that was prerendered, or no data snapshot to hydrate with — because
32
+ * hydrating against mismatched markup throws React #418/#425.
33
+ */
34
+ forceClientRender?: boolean;
35
+ }
36
+ /**
37
+ * Boot a theme. The theme's entry passes its globbed sections/templates/layouts
38
+ * (so Vite resolves them relative to the theme) plus a data source. Everything
39
+ * else — registry, tree rendering, providers — is the framework.
40
+ */
41
+ export declare function mount(opts: MountOptions): void;
42
+ export {};
@@ -0,0 +1,9 @@
1
+ import { type FC, type ReactNode } from 'react';
2
+ import type { ContentNode } from './types';
3
+ export declare function PreviewBridge({ pages, initialPage, Shell, }: {
4
+ pages: Record<string, ContentNode[]>;
5
+ initialPage: string;
6
+ Shell: FC<{
7
+ children: ReactNode;
8
+ }>;
9
+ }): JSX.Element;
@@ -0,0 +1,5 @@
1
+ import type { SectionDef } from './types';
2
+ export declare function registerSections(defs: SectionDef[]): void;
3
+ export declare function getSection(name: string): SectionDef | undefined;
4
+ /** All registered sections — the editor uses this to build its inserter. */
5
+ export declare function allSections(): SectionDef[];
@@ -0,0 +1,11 @@
1
+ import type { MountOptions } from './mount';
2
+ /** Render a theme page to an HTML string (same tree mount() renders client-side). */
3
+ export declare function renderStorefrontHTML(opts: MountOptions): string;
4
+ /**
5
+ * Render ONE section to an HTML string for the editor's "Add section" preview —
6
+ * no Shell/layout, no page routing, no client SPA boot. This is the fast path
7
+ * (Shopify-style): the runtime server-renders just the requested section with
8
+ * the theme's providers + data and returns instant HTML. Block-composed sections
9
+ * are seeded with their preset blocks so they aren't empty.
10
+ */
11
+ export declare function renderSectionPreviewHTML(opts: Pick<MountOptions, 'sections' | 'data' | 'settings' | 'locale'>, type: string, settingsOverride?: Record<string, unknown>): string;