From 424df2bc25c4f3a6380940bacaf5e113819bbf56 Mon Sep 17 00:00:00 2001 From: Nick Mazuk Date: Sun, 14 Aug 2022 21:29:39 -0700 Subject: [PATCH] fix build --- .github/actions/bundle/dist/index.js | 4 +- .github/actions/bundle/src/bundle.test.ts | 5 +- .github/actions/bundle/src/bundle.ts | 8 +- .../bundle/src/remove-comments.test.ts | 82 +++++++++++++++++++ 4 files changed, 90 insertions(+), 9 deletions(-) diff --git a/.github/actions/bundle/dist/index.js b/.github/actions/bundle/dist/index.js index 539b172e..5a9dab49 100644 --- a/.github/actions/bundle/dist/index.js +++ b/.github/actions/bundle/dist/index.js @@ -4548,11 +4548,11 @@ const bundleFileBase = (name, importedFiles, mixins, fetcher) => { } if (fileStack.length > 1) fileStack.push((0, lua_require_1.generateLuaRequire)()); - return fileStack.reverse().join('\n\n'); + return fileStack.reverse().map(remove_comments_1.removeComments).join('\n\n'); }; exports.bundleFileBase = bundleFileBase; const bundleFile = (name, sourcePath, mixins) => { - return (0, remove_comments_1.removeComments)((0, exports.bundleFileBase)(name, exports.files, mixins, (fileName) => fs_1.default.readFileSync(path_1.default.join(sourcePath, fileName)).toString())); + return (0, exports.bundleFileBase)(name, exports.files, mixins, (fileName) => fs_1.default.readFileSync(path_1.default.join(sourcePath, fileName)).toString()); }; exports.bundleFile = bundleFile; diff --git a/.github/actions/bundle/src/bundle.test.ts b/.github/actions/bundle/src/bundle.test.ts index b0e9d84b..10afb9be 100644 --- a/.github/actions/bundle/src/bundle.test.ts +++ b/.github/actions/bundle/src/bundle.test.ts @@ -1,5 +1,6 @@ import { bundleFileBase, ImportedFiles, importFileBase } from './bundle' import { generateLuaRequire } from './lua-require' +import { removeComments } from './remove-comments' describe('importFile', () => { it('files can be imported', () => { @@ -40,7 +41,7 @@ describe('bundle', () => { const bundle = bundleFileBase('a.lua', {}, [], fetcher) expect(bundle).toBe( [ - generateLuaRequire(), + removeComments(generateLuaRequire()), '', '__imports["b"] = function()', " local b = require('b')", @@ -70,7 +71,7 @@ describe('bundle', () => { const bundle = bundleFileBase('mixin.lua', {}, ['mixin.FCMControl', 'mixin.FCMString'], fetcher) expect(bundle).toBe( [ - generateLuaRequire(), + removeComments(generateLuaRequire()), '', '__imports["mixin.FCMControl"] = function()', ' return {}', diff --git a/.github/actions/bundle/src/bundle.ts b/.github/actions/bundle/src/bundle.ts index a03bc099..80c8a672 100644 --- a/.github/actions/bundle/src/bundle.ts +++ b/.github/actions/bundle/src/bundle.ts @@ -59,13 +59,11 @@ export const bundleFileBase = ( } if (fileStack.length > 1) fileStack.push(generateLuaRequire()) - return fileStack.reverse().join('\n\n') + return fileStack.reverse().map(removeComments).join('\n\n') } export const bundleFile = (name: string, sourcePath: string, mixins: string[]): string => { - return removeComments( - bundleFileBase(name, files, mixins, (fileName: string) => - fs.readFileSync(path.join(sourcePath, fileName)).toString() - ) + return bundleFileBase(name, files, mixins, (fileName: string) => + fs.readFileSync(path.join(sourcePath, fileName)).toString() ) } diff --git a/.github/actions/bundle/src/remove-comments.test.ts b/.github/actions/bundle/src/remove-comments.test.ts index 8c457a5f..bc9aba38 100644 --- a/.github/actions/bundle/src/remove-comments.test.ts +++ b/.github/actions/bundle/src/remove-comments.test.ts @@ -49,6 +49,88 @@ const tests: [string, string][] = [ return string.gsub(feature, "_", " ") end`, ], + [ + ` + +--[[ +$module Note Entry +]] -- +local note_entry = {} + +--[[ +% get_music_region +Returns an intance of \`FCMusicRegion\` that corresponds to the metric location of the input note entry. +@ entry (FCNoteEntry) +: (FCMusicRegion) +]] +function note_entry.get_music_region(entry) + local exp_region = finale.FCMusicRegion() + exp_region:SetCurrentSelection() -- called to match the selected IU list (e.g., if using Staff Sets) + exp_region.StartStaff = entry.Staff + exp_region.EndStaff = entry.Staff + exp_region.StartMeasure = entry.Measure + exp_region.EndMeasure = entry.Measure + exp_region.StartMeasurePos = entry.MeasurePos + exp_region.EndMeasurePos = entry.MeasurePos + return exp_region +end + +-- entry_metrics can be omitted, in which case they are constructed and released here +-- return entry_metrics, loaded_here +local use_or_get_passed_in_entry_metrics = function(entry, entry_metrics) + if entry_metrics then + return entry_metrics, false + end + entry_metrics = finale.FCEntryMetrics() + if entry_metrics:Load(entry) then + return entry_metrics, true + end + return nil, false +end + +--[[ +% get_evpu_notehead_height +Returns the calculated height of the notehead rectangle. +@ entry (FCNoteEntry) +: (number) the EVPU height +]] +function note_entry.get_evpu_notehead_height(entry) + local highest_note = entry:CalcHighestNote(nil) + local lowest_note = entry:CalcLowestNote(nil) + local evpu_height = (2 + highest_note:CalcStaffPosition() - lowest_note:CalcStaffPosition()) * 12 -- 12 evpu per staff step; add 2 staff steps to accommodate for notehead height at top and bottom + return evpu_height +end`, + ` + +local note_entry = {} +function note_entry.get_music_region(entry) + local exp_region = finale.FCMusicRegion() + exp_region:SetCurrentSelection() + exp_region.StartStaff = entry.Staff + exp_region.EndStaff = entry.Staff + exp_region.StartMeasure = entry.Measure + exp_region.EndMeasure = entry.Measure + exp_region.StartMeasurePos = entry.MeasurePos + exp_region.EndMeasurePos = entry.MeasurePos + return exp_region +end +local use_or_get_passed_in_entry_metrics = function(entry, entry_metrics) + if entry_metrics then + return entry_metrics, false + end + entry_metrics = finale.FCEntryMetrics() + if entry_metrics:Load(entry) then + return entry_metrics, true + end + return nil, false +end +function note_entry.get_evpu_notehead_height(entry) + local highest_note = entry:CalcHighestNote(nil) + local lowest_note = entry:CalcLowestNote(nil) + local evpu_height = (2 + highest_note:CalcStaffPosition() - lowest_note:CalcStaffPosition()) * 12 + return evpu_height +end`, + ], ] it.each(tests)(`removeComments(%p)`, (input, expected) => {