refactor: underscore-prefix all non-exported functions
This commit is contained in:
@@ -7,19 +7,19 @@ import { coerce, stressorToString } from '../util.js';
|
||||
|
||||
const H4 = { style: 'margin:0 0 0.5rem' };
|
||||
|
||||
function unknownPropFields(node) {
|
||||
function _unknownPropFields(node) {
|
||||
return Object.entries(node.unknownProps ?? {})
|
||||
.map(([key, value]) => ({ key, value: String(value), editable: false }));
|
||||
}
|
||||
|
||||
function parseStressor(str) {
|
||||
function _parseStressor(str) {
|
||||
const groups = str.split(';').map(seg =>
|
||||
seg.split(',').map(n => parseInt(n, 10)).filter(n => !isNaN(n))
|
||||
).filter(g => g.length > 0);
|
||||
return groups.length ? { type: 'stressor', groups } : null;
|
||||
}
|
||||
|
||||
function scoreInfoFields(info) {
|
||||
function _scoreInfoFields(info) {
|
||||
return [
|
||||
{ key: 'title', value: info?.title ?? '', editable: true },
|
||||
{ key: 'composer', value: info?.composer ?? '', editable: true },
|
||||
@@ -28,7 +28,7 @@ function scoreInfoFields(info) {
|
||||
];
|
||||
}
|
||||
|
||||
function instrFields(instr) {
|
||||
function _instrFields(instr) {
|
||||
return [
|
||||
{ key: 'name', value: instr.name, editable: false },
|
||||
{ key: 'linked', value: instr.isLinked, editable: false, type: 'boolean' },
|
||||
@@ -36,11 +36,11 @@ function instrFields(instr) {
|
||||
];
|
||||
}
|
||||
|
||||
function variationFields(v) {
|
||||
function _variationFields(v) {
|
||||
return [{ key: 'depends_on', value: v.dependsOn ?? '—', editable: true }];
|
||||
}
|
||||
|
||||
function shapeSection(label, shape, onChange) {
|
||||
function _shapeSection(label, shape, onChange) {
|
||||
if (!shape) return null;
|
||||
return h('div', { style: 'margin-top:0.5rem' }, [
|
||||
h('strong', null, label),
|
||||
@@ -101,7 +101,7 @@ export const PaneFO = {
|
||||
return h('div', { class: 'se-fo-pane' }, [
|
||||
h('h4', H4, 'Score'),
|
||||
h(ObjectExtended, {
|
||||
fields: scoreInfoFields(model.info),
|
||||
fields: _scoreInfoFields(model.info),
|
||||
onChange: ({ key, value }) => {
|
||||
if (!model.info) model.info = {};
|
||||
model.info[key] = value;
|
||||
@@ -114,7 +114,7 @@ export const PaneFO = {
|
||||
if (node.type === 'instrument') {
|
||||
children.push(
|
||||
h('h4', H4, `Instrument: ${node.name}`),
|
||||
h(ObjectExtended, { fields: instrFields(node), onChange: null }),
|
||||
h(ObjectExtended, { fields: _instrFields(node), onChange: null }),
|
||||
);
|
||||
} else if (node.type === 'variation') {
|
||||
const instr = props.store.scoreModel.instruments.find(
|
||||
@@ -125,7 +125,7 @@ export const PaneFO = {
|
||||
|
||||
children.push(
|
||||
h('h4', H4, 'Variation'),
|
||||
h(ObjectExtended, { fields: variationFields(node), onChange: ({ key, value }) => {
|
||||
h(ObjectExtended, { fields: _variationFields(node), onChange: ({ key, value }) => {
|
||||
if (key === 'depends_on') {
|
||||
const old = node.dependsOn;
|
||||
node.dependsOn = value;
|
||||
@@ -223,13 +223,13 @@ export const PaneFO = {
|
||||
onChange: ({ key, value }) => {
|
||||
if (key === 'id') { node.id = value; markBarDirty(); return; }
|
||||
if (key === 'beats_per_minute') node.tempoLevels = isNaN(value) ? null : value;
|
||||
if (key === 'stress_pattern') node.stressor = parseStressor(value);
|
||||
if (key === 'stress_pattern') node.stressor = _parseStressor(value);
|
||||
markBarDirty();
|
||||
},
|
||||
}),
|
||||
shapeSection('Upper stress bound', node.upperStressBound, markBarDirty),
|
||||
shapeSection('Lower stress bound', node.lowerStressBound, markBarDirty),
|
||||
shapeSection('Tempo shape', node.tempoShape, markBarDirty),
|
||||
_shapeSection('Upper stress bound', node.upperStressBound, markBarDirty),
|
||||
_shapeSection('Lower stress bound', node.lowerStressBound, markBarDirty),
|
||||
_shapeSection('Tempo shape', node.tempoShape, markBarDirty),
|
||||
);
|
||||
} else if (node.type === 'voice') {
|
||||
children.push(
|
||||
@@ -254,7 +254,7 @@ export const PaneFO = {
|
||||
node.motifRefs?.length
|
||||
? { key: 'motifRefs', value: node.motifRefs.map(m => m.chord ? `${m.label}(${m.chord})` : m.label).join(', '), editable: false }
|
||||
: null,
|
||||
...unknownPropFields(node),
|
||||
..._unknownPropFields(node),
|
||||
].filter(Boolean),
|
||||
onChange: null,
|
||||
}),
|
||||
@@ -269,7 +269,7 @@ export const PaneFO = {
|
||||
{ key: 'label', value: node.label, editable: false },
|
||||
{ key: 'static', value: node.isStatic, editable: false, type: 'boolean' },
|
||||
{ key: 'stem notes', value: node.stemNotes.map(pitchLabel).join(', ') || '—', editable: false },
|
||||
...unknownPropFields(node),
|
||||
..._unknownPropFields(node),
|
||||
],
|
||||
onChange: null,
|
||||
}),
|
||||
@@ -291,7 +291,7 @@ export const PaneFO = {
|
||||
{ key: 'adj_stress', value: node.adjStress != null ? String(node.adjStress) : '', editable: true, type: 'number' },
|
||||
{ key: 'chain', value: node.chainText, editable: true },
|
||||
{ key: 'clauses', value: String(node.clauses.length), editable: false },
|
||||
...unknownPropFields(node),
|
||||
..._unknownPropFields(node),
|
||||
],
|
||||
onChange: ({ key, value }) => {
|
||||
if (key === 'pitch') node.pitch = value;
|
||||
|
||||
Reference in New Issue
Block a user