Files
vue3js-app-proposal-for-sdk…/static/node-views.js
2026-07-06 21:10:28 +02:00

39 lines
1.7 KiB
JavaScript

export function shortView(node) {
if (!node) return { typeTag: '?', label: '?', meta: [] };
switch (node.type) {
case 'score':
return {
typeTag: 'score',
label: node.info?.title ?? '(untitled)',
meta: node.info?.composer ? [{ key: 'composer', value: node.info.composer }] : [],
};
case 'instrument':
return { typeTag: 'instrument', label: node.name, meta: [] };
case 'variation': {
const dep = node.dependsOn;
const label = dep == null ? '(root variation)'
: isNaN(Number(dep)) ? `ATTR: ${dep}`
: String(dep);
return { typeTag: 'variation', label, meta: [] };
}
case 'label_spec':
return { typeTag: 'label', label: node.label ?? '(no label)', meta: [] };
case 'bar':
return { typeTag: 'bar', label: node.id, meta: [] };
case 'voice':
return { typeTag: 'voice', label: node.name, meta: [] };
case 'offset':
return { typeTag: 'tick', label: String(node.tick ?? '?'), meta: [] };
case 'motif':
return { typeTag: 'motif', label: node.label, meta: node.isStatic ? [{ key: 'static', value: '✓' }] : [] };
case 'stem_note':
return { typeTag: 'stem_note', label: String(node.pitch), meta: [] };
case 'article': {
const n = node.properties?.length ?? 0;
return { typeTag: 'article', label: node.name, meta: n ? [{ key: 'props', value: n }] : [] };
}
default:
return { typeTag: node.type, label: node.type, meta: [] };
}
}