mirror of
https://github.com/nexu-io/openmotion.git
synced 2026-12-06 23:17:22 +08:00
* feat(studio): refine template details and project handoff * feat(tracking): measure template handoff and enable approved details * test(studio): align handoff and related preview regressions * fix(tracking): link editable handoff intent to operation results * fix(studio): preserve and unblock template creation recovery * Preserve template handoff requirements in every locale * fix(studio): keep guide return and short brand previews usable * test(browser): make brand story selection deterministic --------- Co-authored-by: qiqi <qiqi@qiqideMBP.lan>
16 lines
902 B
TypeScript
16 lines
902 B
TypeScript
export type TemplateGuideFacts = { palette: string[]; editableDemo: boolean };
|
|
|
|
/** Read authored guide metadata, never invent a palette from a catalogue color category. */
|
|
export function templateGuideFacts(source: string): TemplateGuideFacts {
|
|
const document = new DOMParser().parseFromString(source, 'text/html');
|
|
const palette = [...new Set([...document.querySelectorAll('.palette [data-color]')]
|
|
.map(node => node.getAttribute('data-color') ?? '').filter(value => /^#[0-9a-f]{6}$/i.test(value)))].slice(0, 8);
|
|
const editableDemo = [...document.querySelectorAll('[data-demo]')].some(node => {
|
|
try {
|
|
const demo = JSON.parse(node.getAttribute('data-demo') ?? '{}');
|
|
return Array.isArray(demo.params) && demo.params.some((param: { type?: string }) => param.type === 'text' || param.type === 'color');
|
|
} catch { return false; }
|
|
});
|
|
return { palette, editableDemo };
|
|
}
|