@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.
- package/README.md +17 -0
- package/dist/index.js +553 -0
- package/dist/index.js.map +1 -0
- package/dist/ssg-BZ5FYTw7.js +1802 -0
- package/dist/ssg-BZ5FYTw7.js.map +1 -0
- package/dist/ssg.js +8 -0
- package/dist/ssg.js.map +1 -0
- package/dist/types/SectionTree.d.ts +8 -0
- package/dist/types/cart.d.ts +86 -0
- package/dist/types/composition.d.ts +13 -0
- package/dist/types/config.d.ts +19 -0
- package/dist/types/data.d.ts +357 -0
- package/dist/types/defineSection.d.ts +7 -0
- package/dist/types/dynamic-source.d.ts +84 -0
- package/dist/types/editor.d.ts +5 -0
- package/dist/types/index.d.ts +20 -0
- package/dist/types/jsx-to-json.d.ts +13 -0
- package/dist/types/mount.d.ts +42 -0
- package/dist/types/preview-bridge.d.ts +9 -0
- package/dist/types/registry.d.ts +5 -0
- package/dist/types/ssg.d.ts +11 -0
- package/dist/types/storefront.d.ts +333 -0
- package/dist/types/theme-context.d.ts +14 -0
- package/dist/types/types.d.ts +44 -0
- package/package.json +43 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/defineSection.ts","../src/config.ts","../src/editor.tsx","../src/preview-bridge.tsx","../src/mount.tsx","../src/dynamic-source.tsx","../src/jsx-to-json.ts","../src/composition.ts"],"sourcesContent":["import type { SectionDef } from './types'\n\n/**\n * Declare a section (a top-level, editor-placeable unit). Attaches `blockName`\n * to the component so a JSX composition (`<Hero/>`) can be walked back into the\n * content tree (see jsx-to-json.ts).\n */\nexport function defineSection(def: SectionDef): SectionDef {\n ;(def.component as unknown as { blockName?: string }).blockName = def.name\n return def\n}\n","export interface ThemeConfig {\n name: string\n routes: Record<string, string>\n data: {\n mode: 'mock' | 'live'\n /** Cell store-api base, e.g. https://api-do-sgp1.tanqory.com (live mode). */\n endpoint?: string | undefined\n /** Store UUID to preview against (live mode). */\n storeId?: string | undefined\n /** Publishable storefront token — `x-publishable-key` (live mode, optional). */\n token?: string | undefined\n }\n tokens?: string\n}\n\nexport function defineTheme(config: ThemeConfig): ThemeConfig {\n return config\n}\n\nimport type { AttrSpec } from './types'\n\n/** Global theme settings schema (drives the editor's \"Theme settings\" panel). */\nexport type SettingsSchema = Record<string, AttrSpec>\n\nexport function defineSettings(schema: SettingsSchema): SettingsSchema {\n return schema\n}\n","import { useState } from 'react'\nimport type { AttrSpec, ContentNode } from './types'\nimport { getSection, allSections } from './registry'\nimport { SectionTree } from './SectionTree'\n\n// ─── tree helpers (path = number[] into nested .blocks) ─────────────────────\ntype Path = number[]\nconst samePath = (a: Path, b: Path) => a.length === b.length && a.every((v, i) => v === b[i])\n\nfunction nodeAt(tree: ContentNode[], path: Path): ContentNode | undefined {\n let nodes = tree\n let node: ContentNode | undefined\n for (const i of path) { node = nodes[i]; nodes = node?.blocks ?? [] }\n return node\n}\nfunction updateAt(tree: ContentNode[], path: Path, fn: (n: ContentNode) => ContentNode): ContentNode[] {\n const [i, ...rest] = path\n return tree.map((n, k) =>\n k !== i ? n : rest.length === 0 ? fn(n) : { ...n, blocks: updateAt(n.blocks ?? [], rest, fn) },\n )\n}\nfunction removeAt(tree: ContentNode[], path: Path): ContentNode[] {\n const [i, ...rest] = path\n if (rest.length === 0) return tree.filter((_, k) => k !== i)\n return tree.map((n, k) => (k !== i ? n : { ...n, blocks: removeAt(n.blocks ?? [], rest) }))\n}\nfunction insertChild(tree: ContentNode[], parent: Path, node: ContentNode): ContentNode[] {\n if (parent.length === 0) return [...tree, node]\n const [i, ...rest] = parent\n return tree.map((n, k) => (k !== i ? n : { ...n, blocks: insertChild(n.blocks ?? [], rest, node) }))\n}\nfunction reorder(tree: ContentNode[], parent: Path, from: number, to: number): ContentNode[] {\n const moveArr = (arr: ContentNode[]) => { const c = [...arr]; const [m] = c.splice(from, 1); c.splice(to, 0, m); return c }\n if (parent.length === 0) return moveArr(tree)\n const [i, ...rest] = parent\n return tree.map((n, k) => (k !== i ? n : { ...n, blocks: reorder(n.blocks ?? [], rest, from, to) }))\n}\nfunction defaultsFor(type: string): Record<string, unknown> {\n const out: Record<string, unknown> = {}\n for (const [k, s] of Object.entries(getSection(type)?.attributes ?? {})) if (s.default !== undefined) out[k] = s.default\n return out\n}\nconst newNode = (type: string): ContentNode => ({ type, id: `${type}-${Date.now()}-${Math.random().toString(36).slice(2, 6)}`, settings: defaultsFor(type) })\n\n// ─── inputs ──────────────────────────────────────────────────────────────\nfunction Field({ name, spec, value, onChange }: { name: string; spec: AttrSpec; value: unknown; onChange: (v: unknown) => void }): JSX.Element {\n const label = spec.label ?? name\n const c = { style: { width: '100%', padding: '6px 8px', boxSizing: 'border-box' as const } }\n let input: JSX.Element\n if (spec.type === 'textarea') input = <textarea {...c} rows={3} value={String(value ?? '')} onChange={(e) => onChange(e.target.value)} />\n else if (spec.type === 'color') input = <input type=\"color\" value={String(value ?? '#000000')} onChange={(e) => onChange(e.target.value)} />\n else if (spec.type === 'number') input = <input {...c} type=\"number\" value={Number(value ?? 0)} onChange={(e) => onChange(Number(e.target.value))} />\n else if (spec.type === 'boolean') input = <input type=\"checkbox\" checked={Boolean(value)} onChange={(e) => onChange(e.target.checked)} />\n else input = <input {...c} type=\"text\" value={String(value ?? '')} onChange={(e) => onChange(e.target.value)} />\n return <label style={{ display: 'block', margin: '0 0 12px' }}><span style={{ display: 'block', fontSize: 12, color: '#666', marginBottom: 4 }}>{label}</span>{input}</label>\n}\nconst btn = (active = false): React.CSSProperties => ({ border: '1px solid', borderColor: active ? '#111' : '#e5e5e5', borderRadius: 6, background: active ? '#111' : '#fff', color: active ? '#fff' : '#111', cursor: 'pointer', font: 'inherit' })\n\n// ─── editor (multi-page + nested + drag-drop) ───────────────────────────────\nexport function Editor({ pages, initialPage = 'index' }: { pages: Record<string, ContentNode[]>; initialPage?: string }): JSX.Element {\n const pageNames = Object.keys(pages)\n const [trees, setTrees] = useState<Record<string, ContentNode[]>>(pages)\n const [page, setPage] = useState(pageNames.includes(initialPage) ? initialPage : pageNames[0] ?? 'index')\n const [sel, setSel] = useState<Path>([0])\n const [addParent, setAddParent] = useState<Path | null>(null)\n const [status, setStatus] = useState('')\n const [drag, setDrag] = useState<{ parent: string; index: number } | null>(null)\n\n const tree = trees[page] ?? []\n const setTree = (fn: (t: ContentNode[]) => ContentNode[]) => setTrees((all) => ({ ...all, [page]: fn(all[page] ?? []) }))\n const node = nodeAt(tree, sel)\n const def = node ? getSection(node.type) : undefined\n\n const save = async () => {\n setStatus('saving…')\n const res = await fetch('/__studio/save', {\n method: 'POST', headers: { 'content-type': 'application/json' },\n body: JSON.stringify({ page, doc: { sections: trees[page] ?? [] } }),\n })\n setStatus(res.ok ? `saved ${page} ✓` : 'save failed')\n }\n\n const onDrop = (parent: Path, to: number) => {\n if (drag && drag.parent === parent.join('.')) setTree((t) => reorder(t, parent, drag.index, to))\n setDrag(null)\n }\n\n const inserter = (parent: Path, allow?: string[]) => {\n const opts = allSections().filter((s) => !allow || allow.includes(s.name))\n return (\n <div style={{ margin: '2px 0 8px', marginLeft: (parent.length + 1) * 14, border: '1px solid #eee', borderRadius: 6, padding: 6 }}>\n {opts.map((s) => (\n <button key={s.name} onClick={() => { setTree((t) => insertChild(t, parent, newNode(s.name))); setAddParent(null) }}\n style={{ ...btn(), display: 'block', width: '100%', textAlign: 'left', padding: '5px 8px', marginBottom: 2 }}>\n {s.icon ?? '▪'} {s.title}\n </button>\n ))}\n </div>\n )\n }\n\n const renderList = (nodes: ContentNode[], parent: Path): JSX.Element[] =>\n nodes.map((n, i) => {\n const path = [...parent, i]\n const sec = getSection(n.type)\n return (\n <div key={n.id ?? i}>\n <div draggable onDragStart={() => setDrag({ parent: parent.join('.'), index: i })}\n onDragOver={(e) => e.preventDefault()} onDrop={() => onDrop(parent, i)}\n style={{ display: 'flex', gap: 4, marginBottom: 4, marginLeft: parent.length * 14 }}>\n <span style={{ cursor: 'grab', color: '#bbb', padding: '0 2px' }}>⠿</span>\n <button onClick={() => setSel(path)} style={{ ...btn(samePath(path, sel)), flex: 1, textAlign: 'left', padding: '6px 8px' }}>\n {sec?.icon ?? '▪'} {sec?.title ?? n.type}\n </button>\n {sec?.allowedBlocks?.length ? <button title=\"add child\" onClick={() => setAddParent(path)} style={{ ...btn(), width: 26 }}>+</button> : null}\n <button title=\"remove\" onClick={() => { setTree((t) => removeAt(t, path)); setSel([0]) }} style={{ ...btn(), width: 26, color: '#c0392b' }}>✕</button>\n </div>\n {n.blocks?.length ? renderList(n.blocks, path) : null}\n {addParent && samePath(addParent, path) ? inserter(path, sec?.allowedBlocks) : null}\n </div>\n )\n })\n\n return (\n <div style={{ display: 'grid', gridTemplateColumns: '300px 1fr 320px', height: '100vh', fontFamily: 'system-ui' }}>\n {/* LEFT — section tree (drag to reorder, add / remove / nest) */}\n <aside style={{ borderRight: '1px solid #e5e5e5', overflow: 'auto', padding: 16 }}>\n <select value={page} onChange={(e) => { setPage(e.target.value); setSel([0]) }} style={{ width: '100%', padding: '6px 8px', marginBottom: 12 }}>\n {pageNames.map((p) => <option key={p} value={p}>{p}</option>)}\n </select>\n\n <strong style={{ fontSize: 13 }}>SECTIONS — drag ⠿ to reorder</strong>\n <div style={{ margin: '8px 0' }}>{renderList(tree, [])}</div>\n\n <button onClick={() => setAddParent([])} style={{ ...btn(), padding: '8px 10px', width: '100%' }}>+ Add section</button>\n {addParent && addParent.length === 0 ? inserter([]) : null}\n\n <button onClick={save} style={{ marginTop: 16, padding: '10px 16px', border: 'none', borderRadius: 6, background: '#111', color: '#fff', cursor: 'pointer', width: '100%' }}>Save</button>\n <div style={{ fontSize: 12, color: '#666', marginTop: 8 }}>{status}</div>\n </aside>\n\n {/* MIDDLE — live canvas */}\n <main style={{ overflow: 'auto' }}><SectionTree tree={tree} /></main>\n\n {/* RIGHT — props of the selected section (from its schema) */}\n <aside style={{ borderLeft: '1px solid #e5e5e5', overflow: 'auto', padding: 16 }}>\n {def ? (\n <>\n <strong style={{ fontSize: 13 }}>{def.title.toUpperCase()} SETTINGS</strong>\n <div style={{ marginTop: 8 }}>\n {Object.entries(def.attributes ?? {}).map(([k, spec]) => (\n <Field key={k} name={k} spec={spec} value={node!.settings?.[k] ?? spec.default}\n onChange={(v) => setTree((t) => updateAt(t, sel, (nn) => ({ ...nn, settings: { ...nn.settings, [k]: v } })))} />\n ))}\n </div>\n </>\n ) : (\n <div style={{ color: '#888', fontSize: 13 }}>Select a section in the tree to edit its settings.</div>\n )}\n </aside>\n </div>\n )\n}\n","import React, { useEffect, useRef, useState, type FC, type ReactNode } from 'react'\nimport { SectionTree } from './SectionTree'\nimport { useData } from './data'\nimport type { ContentNode } from './types'\n\n/**\n * Preview bridge — the EDIT-plane runtime that lives INSIDE the iframe.\n *\n * Unlike `?edit` (which mounts the whole editor inside the theme bundle), the\n * bridge ships no editor UI: it only (1) renders the content tree and (2) speaks\n * postMessage with the parent editor app. The editor chrome lives in a separate\n * app (apps/studio-editor) and drives this iframe.\n *\n * Protocol (namespaced `tq:`):\n * iframe → parent : { type:'tq:ready', pages } on mount\n * { type:'tq:select', path } when a section is clicked\n * parent → iframe : { type:'tq:set-content', page?, doc? } render this tree\n * { type:'tq:select', path } highlight a node\n */\nconst isMsg = (m: unknown): m is { type: string; [k: string]: unknown } =>\n !!m && typeof m === 'object' && typeof (m as { type?: unknown }).type === 'string'\n\nexport function PreviewBridge({\n pages,\n initialPage,\n Shell,\n}: {\n pages: Record<string, ContentNode[]>\n initialPage: string\n Shell: FC<{ children: ReactNode }>\n}): JSX.Element {\n const [tree, setTree] = useState<ContentNode[]>(pages[initialPage] ?? [])\n const [selected, setSelected] = useState<number[] | null>(null)\n const data = useData()\n // Post to the parent AND the top window. The editor canvas may nest this\n // preview inside another iframe (e.g. the block-editor canvas iframe), in which\n // case `window.parent` is that intermediate frame, not the editor window that\n // listens for selection/content messages — so we also target `window.top`.\n const send = (msg: object) => {\n try {\n window.parent?.postMessage(msg, '*')\n if (window.top && window.top !== window.parent) window.top.postMessage(msg, '*')\n } catch {\n /* cross-origin top access can throw — parent post already attempted */\n }\n }\n\n // Keep the latest tree in a ref so the message handler can return it on\n // demand (the editor's Publish reads the LIVE-edited content straight from\n // the preview — the source of truth for \"what's on screen\").\n const treeRef = useRef<ContentNode[]>(tree)\n useEffect(() => { treeRef.current = tree }, [tree])\n\n // Write-through (lovable-style): on every content change, push the current\n // content to the editor host so it persists the draft immediately — no\n // explicit \"save\". `firstRender` skips the initial mount so we don't re-save\n // the just-loaded draft. The host debounces.\n const firstRender = useRef(true)\n useEffect(() => {\n if (firstRender.current) { firstRender.current = false; return }\n send({ type: 'tanqory-content-changed', content: { sections: tree } })\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [tree])\n\n useEffect(() => {\n const onMsg = (e: MessageEvent) => {\n if (!isMsg(e.data)) return\n if (e.data.type === 'tanqory-get-content') {\n // reply with the current (live-edited) page content in theme-kit format\n send({ type: 'tanqory-content', requestId: e.data.requestId ?? null, content: { sections: treeRef.current } })\n } else if (e.data.type === 'tq:set-content') {\n if (Array.isArray(e.data.doc)) setTree(e.data.doc as ContentNode[])\n else if (typeof e.data.page === 'string' && pages[e.data.page]) setTree(pages[e.data.page])\n } else if (e.data.type === 'tq:select') {\n setSelected(Array.isArray(e.data.path) ? (e.data.path as number[]) : null)\n } else if (e.data.type === 'tanqory-preview-update-section') {\n // studio-editor edited a section's settings (and possibly its child\n // blocks) → merge + re-render live. The editor sends blocks in its\n // OWN shape (object map keyed by id + order[]) — convert to\n // theme-kit's array here so render code only ever sees arrays.\n const id = e.data.sectionId as string\n const s = (e.data.settings ?? {}) as Record<string, unknown>\n const rawBlocks = e.data.blocks as Record<string, ContentNode> | ContentNode[] | null\n const order = e.data.order as string[] | null\n let blocks: ContentNode[] | undefined\n if (Array.isArray(rawBlocks)) {\n blocks = rawBlocks\n } else if (rawBlocks && typeof rawBlocks === 'object') {\n const ids = Array.isArray(order) && order.length ? order : Object.keys(rawBlocks)\n blocks = ids\n .filter((bid) => rawBlocks[bid])\n .map((bid) => ({ ...rawBlocks[bid], id: rawBlocks[bid].id ?? bid }))\n }\n setTree((t) =>\n t.map((n) =>\n n.id === id\n ? { ...n, settings: { ...n.settings, ...s }, ...(blocks ? { blocks } : {}) }\n : n,\n ),\n )\n } else if (e.data.type === 'tanqory-preview-select') {\n const id = e.data.sectionId as string\n setTree((t) => { const i = t.findIndex((n) => n.id === id); setSelected(i >= 0 ? [i] : null); return t })\n // Scroll the canvas to the clicked section (editor tree → preview, like\n // Shopify). The section wrapper is `display:contents` (no layout box), so\n // scroll its first real child element into view instead.\n if (typeof document !== 'undefined' && id) {\n const sel = typeof CSS !== 'undefined' && CSS.escape ? CSS.escape(id) : id\n requestAnimationFrame(() => {\n const wrap = document.querySelector(`[data-tq-section-id=\"${sel}\"]`)\n const target = (wrap?.firstElementChild as HTMLElement | null) ?? (wrap as HTMLElement | null)\n target?.scrollIntoView({ behavior: 'smooth', block: 'start' })\n })\n }\n } else if (e.data.type === 'tanqory-preview-reorder-sections') {\n // Reorder the EXISTING nodes in place (same object refs, keyed by id)\n // so React moves the DOM instead of rebuilding the whole tree — this is\n // what kills the flicker on drag/swap. A full `tq:set-content` would\n // re-mount every section. Any node the editor didn't list is preserved.\n const order = e.data.order as string[]\n if (Array.isArray(order)) {\n setTree((t) => {\n const byId = new Map(t.map((n) => [n.id, n]))\n const next = order.map((id) => byId.get(id)).filter(Boolean) as ContentNode[]\n for (const n of t) if (!order.includes(n.id as string)) next.push(n)\n return next.length ? next : t\n })\n }\n } else if (e.data.type === 'tanqory-preview-remove-section') {\n const id = e.data.sectionId as string\n setTree((t) => t.filter((n) => n.id !== id))\n } else if (e.data.type === 'tanqory-preview-insert-section') {\n // Splice ONE new node in after `afterSectionId` (or at the top) — no\n // full-tree replace. Blocks arrive as the editor's id-map + order array;\n // convert to theme-kit's array shape (same as update-section).\n const id = e.data.sectionId as string\n const rawBlocks = e.data.blocks as Record<string, ContentNode> | ContentNode[] | null\n const order = e.data.order as string[] | null\n let blocks: ContentNode[] | undefined\n if (Array.isArray(rawBlocks)) {\n blocks = rawBlocks\n } else if (rawBlocks && typeof rawBlocks === 'object') {\n const ids = Array.isArray(order) && order.length ? order : Object.keys(rawBlocks)\n blocks = ids\n .filter((bid) => rawBlocks[bid])\n .map((bid) => ({ ...rawBlocks[bid], id: rawBlocks[bid].id ?? bid }))\n }\n const node: ContentNode = {\n id,\n type: e.data.sectionType as string,\n settings: (e.data.settings ?? {}) as Record<string, unknown>,\n ...(blocks ? { blocks } : {}),\n }\n const after = e.data.afterSectionId as string | null\n setTree((t) => {\n if (t.some((n) => n.id === id)) return t\n const idx = after ? t.findIndex((n) => n.id === after) : -1\n const next = [...t]\n next.splice(idx + 1, 0, node)\n return next\n })\n } else if (e.data.type === 'tanqory-request-collections') {\n // Editor needs to populate a `type: 'collection'` picker — reply with\n // every collection the bootstrap query loaded so the merchant sees\n // their actual storefront catalogue, not a typed-in handle.\n const collections = data.allCollections().map((c) => ({\n handle: c.handle,\n title: c.title,\n productCount: c.products.length,\n }))\n send({ type: 'tanqory-collections', requestId: e.data.requestId ?? null, collections })\n } else if (e.data.type === 'tanqory-request-menus') {\n // Editor needs to populate a `type: 'link_list'` picker — reply with\n // every menu the store has (Dashboard → Navigation), so the merchant\n // picks a real menu instead of typing a handle.\n const requestId = e.data.requestId ?? null\n void Promise.resolve(data.listMenus?.() ?? [])\n .then((menus) => send({ type: 'tanqory-menus', requestId, menus }))\n .catch(() => send({ type: 'tanqory-menus', requestId, menus: [] }))\n } else if (e.data.type === 'tanqory-request-products') {\n // Same idea as collections — flatten every product across collections,\n // dedupe by handle (first occurrence wins, matching SectionTree's\n // canonical-handle rule), and hand the editor enough metadata to\n // render a search/filter picker without a second round-trip.\n const seen = new Set<string>()\n const products: Array<{ handle: string; title: string; price: string; image: string | null }> = []\n for (const c of data.allCollections()) {\n for (const p of c.products) {\n if (seen.has(p.handle)) continue\n seen.add(p.handle)\n products.push({\n handle: p.handle,\n title: p.title,\n price: p.price?.amount ?? '',\n image: p.featuredImage?.url ?? null,\n })\n }\n }\n send({ type: 'tanqory-products', requestId: e.data.requestId ?? null, products })\n }\n }\n window.addEventListener('message', onMsg)\n send({ type: 'tq:ready', pages: Object.keys(pages) })\n return () => window.removeEventListener('message', onMsg)\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [])\n\n // Click any element inside a rendered section → report its identity so the\n // editor can highlight the matching row in the tree and surface its\n // settings panel. We send BOTH the legacy `tq:select` (with path) and the\n // editor's `tanqory-section-selected` (with sectionId) — the editor side\n // only listens to the latter, but external tooling may still be on tq:.\n //\n // Preview-mode click handling also short-circuits internal navigation:\n // anchors inside a section would otherwise pull the iframe off the page\n // the editor is editing. Section CTAs become \"select this\" while the\n // editor is open.\n const onClickCapture = (e: React.MouseEvent) => {\n const target = e.target as HTMLElement\n // The innermost wrapper is the node actually clicked — a child BLOCK when the\n // click lands inside one (RenderNode wraps every node), otherwise the section.\n const nodeEl = target.closest<HTMLElement>('[data-tq-section-id]')\n if (!nodeEl) return\n const nodeId = nodeEl.dataset.tqSectionId\n const pathAttr = nodeEl.dataset.tqPath\n if (target.closest('a, button[type=\"submit\"]')) {\n e.preventDefault()\n }\n // Visible selection feedback ON THE CANVAS. The node wrapper is\n // display:contents (no box of its own), so outline its first rendered child.\n // This is what makes a canvas click feel like an outline-tree selection.\n const root = e.currentTarget as HTMLElement\n const prevBox = root.querySelector<HTMLElement>('[data-tq-outlined]')\n if (prevBox) {\n prevBox.style.outline = ''\n prevBox.style.outlineOffset = ''\n prevBox.removeAttribute('data-tq-outlined')\n }\n const box = nodeEl.firstElementChild as HTMLElement | null\n if (box) {\n box.style.outline = '2px solid #2563eb'\n box.style.outlineOffset = '-2px'\n box.setAttribute('data-tq-outlined', '1')\n }\n if (pathAttr) {\n const path = pathAttr.split('.').map(Number)\n setSelected(path)\n send({ type: 'tq:select', path })\n }\n // A nested path (e.g. \"3.1\") means a child BLOCK was clicked — select it\n // WITHIN its parent section so the editor opens the block's settings, not the\n // whole section's. The parent section is the node at the path's first segment.\n // blockId is the block's id (data-tq-section-id), which the editor keys blocks\n // by — so it resolves to the same block the outline + settings panel use.\n const container = e.currentTarget as HTMLElement\n const isBlock = !!pathAttr && pathAttr.includes('.')\n if (isBlock && nodeId) {\n const sectionPath = (pathAttr as string).split('.')[0]\n const sectionEl =\n container.querySelector<HTMLElement>(`[data-tq-path=\"${sectionPath}\"]`) ??\n nodeEl.parentElement?.closest<HTMLElement>('[data-tq-section-id]')\n const sectionId = sectionEl?.dataset.tqSectionId\n if (sectionId) {\n send({ type: 'tanqory-block-selected', sectionId, blockId: nodeId })\n return\n }\n }\n if (nodeId) {\n send({ type: 'tanqory-section-selected', sectionId: nodeId })\n }\n }\n\n return (\n <div onClickCapture={onClickCapture} data-tq-selected={selected?.join('.') ?? ''}>\n <Shell>\n <SectionTree tree={tree} />\n </Shell>\n </div>\n )\n}\n","import React, { type FC, type ReactNode } from 'react'\nimport { createRoot, hydrateRoot } from 'react-dom/client'\n\nimport { registerSections } from './registry'\nimport { SectionTree } from './SectionTree'\nimport { DataProvider, type DataApi } from './data'\nimport { CartProvider } from './cart'\nimport { ThemeProvider } from './theme-context'\nimport { Editor } from './editor'\nimport { PreviewBridge } from './preview-bridge'\nimport type { SectionDef, PageDoc, ContentNode } from './types'\n\n// Vite's import.meta.glob(..., { eager: true }) types each value as `unknown`,\n// so the theme entry passes plain glob maps with no generics. We narrow here.\ntype GlobMap = Record<string, unknown>\n\nexport interface MountOptions {\n /** import.meta.glob('./sections/*.tsx', { eager: true }) — run in the THEME. */\n sections: GlobMap\n /** import.meta.glob('./templates/*.json', { eager: true }). */\n pages: GlobMap\n /** import.meta.glob('./layouts/*.tsx', { eager: true }) — optional. */\n shell?: GlobMap\n /** Data source the theme provides (createMockData(...) or a live client). */\n data: DataApi\n /** Global settings values (config/settings.json). */\n settings?: Record<string, unknown>\n /** Locale strings (locales/<lang>.json). */\n locale?: Record<string, string>\n /** Which page to render (default 'index'). */\n page?: string\n /** Mount target id (default 'root'). */\n rootId?: string\n /**\n * SWR refresh: the initial render uses `data` (the SSG snapshot — so\n * hydration matches the server markup by construction), then this runs once\n * after mount and the fresh result is swapped in. Return null/reject to keep\n * the snapshot data (e.g. the network is down).\n */\n revalidate?: () => Promise<DataApi | null>\n /**\n * Force client rendering even when SSG markup exists in the root (wipe +\n * createRoot instead of hydrateRoot). Pass when the prerendered markup is\n * known NOT to match what the client will render — a different page than the\n * one that was prerendered, or no data snapshot to hydrate with — because\n * hydrating against mismatched markup throws React #418/#425.\n */\n forceClientRender?: boolean\n}\n\nfunction defaultsOf<T>(map: GlobMap): T[] {\n return Object.values(map).map((m) => (m as { default: T }).default)\n}\n\nfunction pickByName<T>(map: GlobMap, name: string): T | undefined {\n const hit = Object.entries(map).find(\n ([key]) => key.endsWith(`/${name}.json`) || key.endsWith(`/${name}.tsx`),\n )\n return hit ? (hit[1] as { default: T }).default : undefined\n}\n\n/**\n * Boot a theme. The theme's entry passes its globbed sections/templates/layouts\n * (so Vite resolves them relative to the theme) plus a data source. Everything\n * else — registry, tree rendering, providers — is the framework.\n */\nexport function mount(opts: MountOptions): void {\n registerSections(defaultsOf<SectionDef>(opts.sections))\n\n const shells = opts.shell ? defaultsOf<FC<{ children: ReactNode }>>(opts.shell) : []\n const Shell: FC<{ children: ReactNode }> = shells[0] ?? (({ children }) => <>{children}</>)\n\n const pageDoc = pickByName<PageDoc>(opts.pages, opts.page ?? 'index') ?? { sections: [] }\n const rootEl = document.getElementById(opts.rootId ?? 'root')\n if (!rootEl) throw new Error('[tanqory] mount target not found')\n\n // `?edit=true` → visual editor (EDIT plane); otherwise the storefront (SERVE).\n // Bare `?edit` counts as on; an explicit falsey value (`?edit=false` / `?edit=0`)\n // stays on the storefront, so the flag can be toggled off from the URL without\n // dropping the param. Editing only persists on the EDIT-plane sandbox (vite dev,\n // `preview-<slug>`); the published `<slug>` is static and has no save endpoint.\n const params = typeof location !== 'undefined' ? new URLSearchParams(location.search) : new URLSearchParams()\n const on = (k: string) => { const v = params.get(k); return v !== null && v !== 'false' && v !== '0' }\n // PREVIEW plane = the dedicated `preview-<themeId>.<domain>` host (the editor\n // canvas) — render the postMessage bridge. `?preview`/`?edit` still work for\n // local/dev. Otherwise the storefront (SERVE plane / production <slug>).\n const previewHost = typeof location !== 'undefined' && /^preview-/.test(location.hostname)\n const previewMode = previewHost || on('preview')\n const editMode = on('edit')\n\n // All pages (name → sections) so the editor can switch between templates.\n const pagesByName: Record<string, ContentNode[]> = {}\n for (const [key, mod] of Object.entries(opts.pages)) {\n const name = key.replace(/^.*\\//, '').replace(/\\.json$/, '')\n pagesByName[name] = (mod as { default?: PageDoc }).default?.sections ?? []\n }\n\n const content = previewMode ? (\n <PreviewBridge pages={pagesByName} initialPage={opts.page ?? 'index'} Shell={Shell} />\n ) : editMode ? (\n <Editor pages={pagesByName} initialPage={opts.page ?? 'index'} />\n ) : (\n <Shell>\n <SectionTree tree={pageDoc.sections} />\n </Shell>\n )\n\n // Holds the DataApi in state so `revalidate` can swap fresh data in AFTER\n // hydration: first render = the SSG snapshot (markup matches the server\n // byte-for-byte), then the fresh fetch reconciles in place (SWR).\n const Root: FC = () => {\n const [data, setData] = React.useState(opts.data)\n React.useEffect(() => {\n if (!opts.revalidate) return\n let live = true\n opts\n .revalidate()\n .then((fresh) => {\n if (live && fresh) setData(fresh)\n })\n .catch(() => {\n /* keep the snapshot data — a failed refresh must not blank the page */\n })\n return () => {\n live = false\n }\n // mount() runs once per page load; opts never changes afterwards.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [])\n return (\n <DataProvider value={data}>\n <ThemeProvider settings={opts.settings} locale={opts.locale}>\n <CartProvider>{content}</CartProvider>\n </ThemeProvider>\n </DataProvider>\n )\n }\n\n const app = (\n <React.StrictMode>\n <Root />\n </React.StrictMode>\n )\n\n // Storefront (SERVE plane) is prerendered to static HTML at build time (SSG,\n // see ssg.tsx) — hydrate it so the markup is reused (no flash, SEO-ready).\n // Preview/edit planes are always client-rendered (not prerendered).\n // forceClientRender = the SSG markup is known not to match (different page /\n // no snapshot): wipe it and client-render — hydrating would mismatch (#418).\n const isStorefront = !previewMode && !editMode\n const hasSSG = rootEl.firstChild != null\n if (isStorefront && hasSSG && !opts.forceClientRender) {\n hydrateRoot(rootEl, app)\n } else {\n if (hasSSG) rootEl.replaceChildren()\n createRoot(rootEl).render(app)\n }\n}\n","/**\n * Dynamic sources — bind a section/block setting to a live metafield, resource\n * property, or metaobject field (Shopify \"Insert dynamic source\", the ⛁ icon).\n *\n * A setting value is normally a primitive. When the merchant connects a dynamic\n * source the editor stores a `{ '@source': '<path>' }` object instead, and the\n * theme resolves it at render against the CURRENT page resource:\n *\n * product.metafields.custom.subtitle → the page product's metafield\n * collection.metafields.custom.tagline → the page collection's metafield\n * shop.metafields.custom.announcement → the store's metafield (any page)\n * product.title / shop.name → a plain resource property\n * metaobject:size:medium.label → a metaobject field (type:handle.key)\n *\n * The path grammar mirrors Shopify so themes/docs are portable. Resolution is\n * synchronous against already-loaded resources — the provider is responsible\n * for loading the bound metafields (see `collectBoundIdentifiers`).\n */\nimport { createContext, useContext, type ReactNode } from 'react'\nimport { useData } from './data'\nimport type { Product, Collection } from './data'\nimport type { Shop, Metaobject } from './storefront'\n\n/** A setting bound to a dynamic source instead of a literal value. */\nexport interface BoundSource {\n '@source': string\n}\n\nexport type Bound<T> = T | BoundSource\n\nexport function isBoundSource(v: unknown): v is BoundSource {\n return (\n typeof v === 'object' &&\n v !== null &&\n typeof (v as Record<string, unknown>)['@source'] === 'string'\n )\n}\n\n/** Resources a dynamic source can read from on the current page. */\nexport interface ResourceContextValue {\n shop?: (Shop & { metafields?: Record<string, string | null> }) | null\n product?: (Product & { metafields?: Record<string, string | null> }) | null\n collection?: (Collection & { metafields?: Record<string, string | null> }) | null\n /** Synchronous metaobject lookup (type, handle) → entry, from a warmed cache. */\n metaobject?: (type: string, handle: string) => Metaobject | null\n}\n\nconst ResourceContext = createContext<ResourceContextValue>({})\n\n/**\n * Provide the current page's resources to dynamic sources. Wrap the page once\n * (the layout does this). `shop` falls back to the data source so shop-level\n * bindings work on every page without extra wiring.\n */\nexport function DynamicSourceProvider({\n value,\n children,\n}: {\n value: ResourceContextValue\n children: ReactNode\n}): JSX.Element {\n return <ResourceContext.Provider value={value}>{children}</ResourceContext.Provider>\n}\n\nexport function useResourceContext(): ResourceContextValue {\n const data = useData()\n const ctx = useContext(ResourceContext)\n // Shop is always available from the data source; an explicit provider value\n // (carrying loaded shop metafields) takes precedence.\n return { shop: data.shop, ...ctx }\n}\n\nconst METAOBJECT_RE = /^metaobject:([^:]+):([^.]+)\\.(.+)$/\n\n/** Resolve a `@source` path against a resource context. Returns null if unbound. */\nexport function resolveBoundSource(\n source: string,\n ctx: ResourceContextValue,\n): string | null {\n const mo = source.match(METAOBJECT_RE)\n if (mo) {\n const [, type, handle, field] = mo\n const obj = ctx.metaobject?.(type, handle)\n return obj?.values?.[field] ?? null\n }\n const parts = source.split('.')\n const root = parts[0]\n const resource =\n root === 'product'\n ? ctx.product\n : root === 'collection'\n ? ctx.collection\n : root === 'shop'\n ? ctx.shop\n : null\n if (!resource) return null\n if (parts[1] === 'metafields') {\n const ns = parts[2]\n const key = parts.slice(3).join('.')\n if (!ns || !key) return null\n return resource.metafields?.[`${ns}.${key}`] ?? null\n }\n // Plain resource property: product.title, shop.name, collection.title…\n const direct = (resource as unknown as Record<string, unknown>)[parts[1]]\n return direct == null ? null : String(direct)\n}\n\n/**\n * Resolve a possibly-bound setting value for the current page.\n * const heading = useBound(attributes.heading) // string | the literal | null\n * A plain value passes through unchanged; a `{ '@source' }` object resolves to\n * the live value (or null when the source has no value on this resource).\n */\nexport function useBound(value: unknown): unknown {\n const ctx = useResourceContext()\n if (!isBoundSource(value)) return value\n return resolveBoundSource(value['@source'], ctx)\n}\n\n/** Convenience: resolve to a string (empty when null/unbound-empty). */\nexport function useBoundText(value: unknown, fallback = ''): string {\n const resolved = useBound(value)\n if (resolved == null) return fallback\n return typeof resolved === 'string' ? resolved : String(resolved)\n}\n\n/**\n * Walk a content tree's section/block settings and collect every bound metafield\n * identifier, grouped by resource. The provider uses this to request exactly the\n * metafields the page binds (the live product/collection query takes identifiers).\n */\nexport function collectBoundIdentifiers(\n nodes: Array<{ settings?: Record<string, unknown>; blocks?: unknown[] }> | undefined,\n): { product: Array<{ namespace: string; key: string }>; collection: Array<{ namespace: string; key: string }>; shop: Array<{ namespace: string; key: string }> } {\n const out = {\n product: [] as Array<{ namespace: string; key: string }>,\n collection: [] as Array<{ namespace: string; key: string }>,\n shop: [] as Array<{ namespace: string; key: string }>,\n }\n const seen = new Set<string>()\n const visitSettings = (settings?: Record<string, unknown>): void => {\n if (!settings) return\n for (const v of Object.values(settings)) {\n if (!isBoundSource(v)) continue\n const parts = v['@source'].split('.')\n const root = parts[0] as 'product' | 'collection' | 'shop'\n if (parts[1] !== 'metafields') continue\n const namespace = parts[2]\n const key = parts.slice(3).join('.')\n if (!namespace || !key || !(root in out)) continue\n const dedupe = `${root}:${namespace}.${key}`\n if (seen.has(dedupe)) continue\n seen.add(dedupe)\n out[root].push({ namespace, key })\n }\n }\n // Sections + blocks may store children as an array OR an object map (the\n // editor's `{ id: node }` shape) — normalize both before iterating.\n const toNodes = (v: unknown): Array<{ settings?: Record<string, unknown>; blocks?: unknown }> => {\n if (Array.isArray(v)) return v\n if (v && typeof v === 'object') return Object.values(v as Record<string, { settings?: Record<string, unknown>; blocks?: unknown }>)\n return []\n }\n const walk = (list?: unknown): void => {\n for (const node of toNodes(list)) {\n visitSettings(node.settings)\n walk(node.blocks)\n }\n }\n walk(nodes)\n return out\n}\n","import { Children, isValidElement, type ReactNode } from 'react'\nimport type { ContentNode } from './types'\n\n/**\n * Compile a *static* JSX composition into the canonical JSON block tree.\n *\n * <Hero settings={{…}}><Button settings={{…}} /></Hero>\n * → [{ type:'hero', settings:{…}, blocks:[{ type:'button', settings:{…} }] }]\n *\n * Only nesting + literal `settings` are read — there is no place for logic, which\n * is exactly what keeps a page round-trippable by the editor. (Logic lives in\n * the block components, never in a page composition.)\n */\nexport function jsxToJSON(node: ReactNode): ContentNode[] {\n return Children.toArray(node).flatMap((el): ContentNode[] => {\n if (!isValidElement(el)) return []\n const name = (el.type as { blockName?: string })?.blockName\n if (!name) return []\n const props = el.props as { settings?: Record<string, unknown>; children?: ReactNode }\n const out: ContentNode = { type: name }\n if (props.settings) out.settings = props.settings\n const blocks = jsxToJSON(props.children)\n if (blocks.length) out.blocks = blocks\n return [out]\n })\n}\n","import type { FC, ReactNode } from 'react'\nimport type { SectionDef } from './types'\n\n/**\n * A section used inside a *page composition* takes `settings` (literal) + nested\n * children — never `attributes`. `tag(SectionDef)` returns it typed for that\n * composition use. The element is only ever walked by jsxToJSON (never rendered\n * directly), which is what keeps page files pure data.\n */\nexport type Tag = FC<{ settings?: Record<string, unknown>; children?: ReactNode }>\n\nexport function tag(def: SectionDef): Tag {\n return def.component as unknown as Tag\n}\n"],"names":["b","i","k","c","e"],"mappings":";;;;;AAOO,SAAS,cAAc,KAA6B;AACvD,MAAI,UAAgD,YAAY,IAAI;AACtE,SAAO;AACT;ACKO,SAAS,YAAY,QAAkC;AAC5D,SAAO;AACT;AAOO,SAAS,eAAe,QAAwC;AACrE,SAAO;AACT;ACnBA,MAAM,WAAW,CAAC,GAASA,OAAY,EAAE,WAAWA,GAAE,UAAU,EAAE,MAAM,CAAC,GAAGC,OAAM,MAAMD,GAAEC,EAAC,CAAC;AAE5F,SAAS,OAAO,MAAqB,MAAqC;AACxE,MAAI,QAAQ;AACZ,MAAI;AACJ,aAAWA,MAAK,MAAM;AAAE,WAAO,MAAMA,EAAC;AAAG,YAAQ,MAAM,UAAU,CAAA;AAAA,EAAG;AACpE,SAAO;AACT;AACA,SAAS,SAAS,MAAqB,MAAY,IAAoD;AACrG,QAAM,CAACA,IAAG,GAAG,IAAI,IAAI;AACrB,SAAO,KAAK;AAAA,IAAI,CAAC,GAAGC,OAClBA,OAAMD,KA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