diff --git a/CHANGELOG.md b/CHANGELOG.md index b429d6e..251dca2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,16 @@ All notable changes to muSRFlow are recorded here. The project follows the release path documented in [`TODO.md`](TODO.md). +## 1.0.0-rc.5 (unreleased) + +### Custom parameters +- The custom-parameter name reservation now covers only real built-in theory + parameters derived from the model catalogue. Environment-style default-value + entries that were never theory parameters (e.g. `Field` and `Energy`) can be + used as custom parameter names again. +- `npm run checksums` generates `md5`/`sha256` sidecar files for the packaged + `.rpm` and `.AppImage` artifacts in `dist/`, matching the release workflow. + ## 1.0.0-rc.4 (2026-09-23) ### Parameter ordering diff --git a/muSRFitlib.js b/muSRFitlib.js index c6209dd..6c43fc6 100644 --- a/muSRFitlib.js +++ b/muSRFitlib.js @@ -892,6 +892,17 @@ for (let key in funcDictionary) { funcDictionary[key].pars = pars; } +// The parameter names that appear in the built-in theory blocks. Custom +// parameters must not shadow these so the generated FITPARAMETER block and +// FUNCTIONS constraints stay unambiguous. This set is derived from +// funcDictionary rather than defVals: defVals may also carry default-value +// entries (e.g. Field, Energy) that are not theory parameters and remain +// available as custom parameter names. +const musrfitBuiltinParameterNames = new Set(); +for (let key in funcDictionary) { + for (let par of funcDictionary[key].pars) musrfitBuiltinParameterNames.add(par); +} + // This is the default values of parameters // parName : { // value : starting_value, @@ -8358,9 +8369,10 @@ function addCustomParam() { input.value = ""; return; } - // Prevent collision with defVals — custom params must not shadow built-in param names - // (built-in names come from funcDictionary, so this check is belt-and-suspenders) - if (defVals[name]) { + // Prevent collision with built-in parameter names. Only names that actually + // appear in a built-in theory block are reserved; defVals-only default-value + // entries (e.g. Field, Energy) are not theory parameters and may be reused. + if (musrfitBuiltinParameterNames.has(name)) { alert("'" + name + "' is a built-in parameter name. Choose a different name."); input.value = ""; return; diff --git a/package.json b/package.json index 881d6ec..33a4443 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,9 @@ "dist:linux": "npm run test:electron && npx --yes electron-builder@26.15.3 --linux rpm AppImage --x64", "dist:rpm": "npm run test:electron && npx --yes electron-builder@26.15.3 --linux rpm --x64", "dist:appimage": "npm run test:electron && npx --yes electron-builder@26.15.3 --linux AppImage --x64", + "checksums:md5": "sh -c 'd=dist; [ -d \"$d\" ] || exit 0; for f in \"$d\"/*; do [ -f \"$f\" ] || continue; case \"$f\" in *.rpm|*.AppImage) base=$(basename \"$f\"); (cd \"$d\" && md5sum \"$base\" > \"$base.md5\");; esac; done'", + "checksums:sha256": "sh -c 'd=dist; [ -d \"$d\" ] || exit 0; for f in \"$d\"/*; do [ -f \"$f\" ] || continue; case \"$f\" in *.rpm|*.AppImage) base=$(basename \"$f\"); (cd \"$d\" && sha256sum \"$base\" > \"$base.sha256\");; esac; done'", + "checksums": "npm run checksums:md5 && npm run checksums:sha256", "test:electron": "node tests/log-highlighting.test.js && node tests/action-state.test.js && node tests/electron-missing-data.test.js && node tests/electron-msr-title.test.js && node tests/window-layering.test.js && node tests/msr-generation.test.js && node tests/root-plot-clean.test.js && node tests/parameter-plot.test.js && node tests/help-window.test.js && node tests/release-packaging.test.js && node tests/addrun.test.js && node tests/fit-statistic.test.js && node tests/series-fit-planner.test.js && node tests/series-fit-result.test.js && node tests/series-fit-inventory.test.js && node tests/series-fit-msr-preparation.test.js && node tests/series-artifact-contract.test.js && node tests/series-global-merge.test.js && node tests/series-fit-staging.test.js && node tests/series-fit-runner.test.js && node tests/series-runner-adapters.test.js && node tests/series-fit-routing.test.js && node tests/series-action-chips.test.js && node tests/singlehist-parity.test.js && node tests/url-parameters.test.js && node tests/run-naming.test.js && node tests/electron-portable-naming.test.js && node tests/shared-configuration.test.js && node tests/session-persistence.test.js && node tests/reference-fixtures.test.js && node tests/electron-bridge.test.js" }, "repository": { diff --git a/tests/msr-generation.test.js b/tests/msr-generation.test.js index 62e84d0..fd6315d 100644 --- a/tests/msr-generation.test.js +++ b/tests/msr-generation.test.js @@ -2642,6 +2642,61 @@ function testApplyMSRParametersUpdatesParameterTable(lib) { assert.strictEqual(elements.maxAlpha.value, "1.5"); } +function testCustomParameterNameReservation(lib) { + // "Field" and "Energy" are default-value entries in defVals but are not + // theory parameters, so they must be usable as custom parameter names. + // Real built-in names (from funcDictionary theory blocks) stay reserved. + function makeElements(name) { + const funSel = { + options: [], + appendChild: function() {} + }; + const container = { + innerHTML: "" + }; + const elements = { + newParamName: { value: name, focus: function() {} }, + funSel: funSel, + customParamList: container + }; + lib.document = { + getElementById: function(id) { + return elements[id] || null; + }, + createElement: function() { + return { id: "", textContent: "", value: "" }; + } + }; + lib.cfgParams = function() {}; + lib.markAllCurrentSeriesRunsEdited = function() {}; + return { elements: elements, container: container }; + } + + lib.customParams = []; + let warning = ""; + lib.alert = function(message) { warning = message; }; + + // Field: previously blocked via defVals.Field, must now be accepted. + makeElements("Field"); + lib.addCustomParam(); + assert.strictEqual(lib.customParams.includes("Field"), true); + + // Energy: likewise previously blocked via defVals.Energy. + makeElements("Energy"); + lib.addCustomParam(); + assert.strictEqual(lib.customParams.includes("Energy"), true); + + // A real built-in theory parameter is still rejected. + const builtIn = ["Asy", "Lam", "Sgm", "Phi", "Frq"]; + for (let name of builtIn) { + makeElements(name); + lib.addCustomParam(); + assert.strictEqual(warning, "'" + name + "' is a built-in parameter name. Choose a different name."); + assert.strictEqual(lib.customParams.includes(name), false); + warning = ""; + } +} + function testSyncSeriesParametersFromCombinedMSR(lib) { const elements = { valAsy_0514: { value: "old-514" }, @@ -3882,6 +3937,7 @@ testT0BgValidationRejectsIncompletePairs(lib); testT0BgUseCommonIgnoresStaleRowBackground(lib); testSeedRunParametersFromShared(lib); testApplyMSRParametersUpdatesParameterTable(lib); +testCustomParameterNameReservation(lib); testSyncSeriesParametersFromCombinedMSR(lib); testDirtyEditorOverwriteGuard(lib); testMSREditorEnterInsertsTextNewline(lib); diff --git a/tests/release-packaging.test.js b/tests/release-packaging.test.js index d0cb0d4..7a3900b 100644 --- a/tests/release-packaging.test.js +++ b/tests/release-packaging.test.js @@ -18,6 +18,9 @@ assert(pkg.build.linux.target.includes('rpm')); assert(pkg.build.linux.target.includes('AppImage')); assert(pkg.scripts['dist:rpm'].includes('electron-builder@26.15.3')); assert(pkg.scripts['dist:appimage'].includes('electron-builder@26.15.3')); +assert(pkg.scripts['checksums:md5'].includes('md5sum')); +assert(pkg.scripts['checksums:sha256'].includes('sha256sum')); +assert.strictEqual(pkg.scripts.checksums, 'npm run checksums:md5 && npm run checksums:sha256'); assert(main.includes('app.getVersion()'), 'About dialog should report the package version'); assert(main.includes('Author: Zaher Salman'), 'About dialog should report the author'); assert(main.includes('Copyright (C) 2026 Zaher Salman'), 'About dialog should report copyright');