From 50c0701fe16816bdac746deeeef3556bc4287b5d Mon Sep 17 00:00:00 2001 From: Danielku15 <danielku15@coderline.net> Date: Sun, 28 Nov 2021 15:19:12 +0100 Subject: [PATCH 1/3] Rework exports to allow using classes in type hints --- package-lock.json | 6 + package.json | 1 + rollup.resolve.js | 25 +- src/AlphaTabApiBase.ts | 6 +- src/Environment.ts | 12 +- src/alphatab.ts | 268 ++---------------- src/exporter/Gp7Exporter.ts | 4 +- src/exporter/index.ts | 2 + src/importer/CapellaImporter.ts | 2 +- src/importer/index.ts | 3 + src/io/ByteBuffer.ts | 2 +- src/io/IOHelper.ts | 2 +- src/midi/AlphaSynthMidiFileHandler.ts | 2 +- src/midi/BeatTickLookup.ts | 2 +- src/midi/index.ts | 14 + src/model/Beat.ts | 2 +- src/model/Color.ts | 2 +- src/model/GraceGroup.ts | 2 +- src/model/Note.ts | 2 +- src/model/Score.ts | 2 +- src/model/Staff.ts | 2 +- src/model/Track.ts | 2 +- src/model/Voice.ts | 2 +- src/model/index.ts | 47 +++ .../AlphaSynthAudioWorkletOutput.ts | 4 +- .../AlphaSynthScriptProcessorOutput.ts | 2 +- src/platform/javascript/BrowserUiFacade.ts | 2 +- src/rendering/BarRendererBase.ts | 4 +- src/rendering/TabBarRenderer.ts | 2 +- .../effects/LeftHandTapEffectInfo.ts | 2 +- src/rendering/glyphs/AccidentalGroupGlyph.ts | 2 +- src/rendering/glyphs/BeatContainerGlyph.ts | 10 +- src/rendering/glyphs/BeatOnNoteGlyphBase.ts | 4 +- .../glyphs/ChordDiagramContainerGlyph.ts | 2 +- src/rendering/glyphs/NoteNumberGlyph.ts | 2 +- .../glyphs/PercussionNoteHeadGlyph.ts | 2 +- src/rendering/glyphs/RowGlyphContainer.ts | 2 +- src/rendering/glyphs/ScoreBeatGlyph.ts | 20 +- src/rendering/glyphs/ScoreBendGlyph.ts | 2 +- src/rendering/glyphs/ScoreBrushGlyph.ts | 2 +- .../glyphs/ScoreHelperNotesBaseGlyph.ts | 2 +- src/rendering/glyphs/ScoreNoteChordGlyph.ts | 4 +- src/rendering/glyphs/ScoreSlurGlyph.ts | 10 +- src/rendering/glyphs/ScoreTieGlyph.ts | 2 +- src/rendering/glyphs/ScoreWhammyBarGlyph.ts | 2 +- src/rendering/glyphs/TabBeatGlyph.ts | 4 +- src/rendering/glyphs/TabBrushGlyph.ts | 2 +- src/rendering/glyphs/TabNoteChordGlyph.ts | 4 +- src/rendering/glyphs/TuningContainerGlyph.ts | 4 +- src/rendering/glyphs/TuningGlyph.ts | 2 +- src/rendering/index.ts | 10 + src/rendering/layout/ScoreLayout.ts | 2 +- src/rendering/utils/AccidentalHelper.ts | 4 +- src/rendering/utils/BarHelpers.ts | 4 +- src/rendering/utils/BeamingHelper.ts | 4 +- src/rendering/utils/NoteBounds.ts | 2 +- src/synth/AlphaSynth.ts | 6 +- src/synth/IAlphaSynth.ts | 2 +- src/synth/MidiFileSequencer.ts | 2 +- src/synth/index.ts | 6 + src/synth/synthesis/TinySoundFont.ts | 2 +- src/synth/synthesis/Voice.ts | 4 +- src/xml/XmlDocument.ts | 2 +- src/xml/XmlWriter.ts | 2 +- src/zip/DeflaterHuffman.ts | 4 +- src/zip/ZipReader.ts | 2 +- src/zip/ZipWriter.ts | 6 +- test/visualTests/VisualTestHelper.ts | 2 +- 68 files changed, 230 insertions(+), 350 deletions(-) create mode 100644 src/exporter/index.ts create mode 100644 src/importer/index.ts create mode 100644 src/midi/index.ts create mode 100644 src/model/index.ts create mode 100644 src/rendering/index.ts create mode 100644 src/synth/index.ts diff --git a/package-lock.json b/package-lock.json index 2df39cb9b..d7f40f8e6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -159,6 +159,12 @@ "integrity": "sha512-vt+kDhq/M2ayberEtJcIN/hxXy1Pk+59g2FV/ZQceeaTyCtCucjL2Q7FXlFjtWn4n15KCr1NE2lNNFhp0lEThw==", "dev": true }, + "@types/css-font-loading-module": { + "version": "0.0.7", + "resolved": "https://registry.npmjs.org/@types/css-font-loading-module/-/css-font-loading-module-0.0.7.tgz", + "integrity": "sha512-nl09VhutdjINdWyXxHWN/w9zlNCfr60JUqJbd24YXUuCwgeL0TpFSdElCwb6cxfB6ybE19Gjj4g0jsgkXxKv1Q==", + "dev": true + }, "@types/estree": { "version": "0.0.39", "resolved": "https://registry.npmjs.org/@types/estree/-/estree-0.0.39.tgz", diff --git a/package.json b/package.json index 8a4e6dc77..419372c4c 100644 --- a/package.json +++ b/package.json @@ -54,6 +54,7 @@ }, "devDependencies": { "@rollup/plugin-commonjs": "^21.0.1", + "@types/css-font-loading-module": "0.0.7", "@types/jasmine": "^3.10.2", "@types/resize-observer-browser": "^0.1.6", "concurrently": "^6.3.0", diff --git a/rollup.resolve.js b/rollup.resolve.js index c470c9d64..9f5939ade 100644 --- a/rollup.resolve.js +++ b/rollup.resolve.js @@ -1,4 +1,4 @@ -const join = require('path').join; +const path = require('path'); const glob = require('glob').sync; const fs = require('fs'); @@ -17,19 +17,24 @@ module.exports = function (options) { if (importee.startsWith('**')) { return importee; } else { + const importerDir = path.dirname(importer); + let resolved = importee; + const match = Object.entries(mappings).filter(m => importee.startsWith(m[0])); - if (!match || match.length === 0) { - return null; + if (match && match.length > 0) { + if (match[0][1].endsWith(extension)) { + resolved = path.join(process.cwd(), match[0][1]); + } else { + resolved = path.join(process.cwd(), match[0][1], importee.substring(match[0][0].length)); + } + } else { + resolved = path.join(importerDir, importee); } - if (match[0][1].endsWith(extension)) { - return join(process.cwd(), match[0][1]); + if (fs.existsSync(path.join(resolved, 'index' + extension))) { + resolved = path.join(resolved, 'index'); } - let resolved = join(process.cwd(), match[0][1], importee.substring(match[0][0].length)); - if (fs.existsSync(join(resolved, 'index' + extension))) { - return join(resolved, 'index' + extension); - } return resolved + extension; } }, @@ -41,7 +46,7 @@ module.exports = function (options) { const source = files .map( (file, i) => - `import _${i} from ${JSON.stringify(join(process.cwd(), file))}; + `import _${i} from ${JSON.stringify(path.join(process.cwd(), file))}; export { _${i} };` ) .join('\r\n'); diff --git a/src/AlphaTabApiBase.ts b/src/AlphaTabApiBase.ts index 68b94ae9f..6f9f0af78 100644 --- a/src/AlphaTabApiBase.ts +++ b/src/AlphaTabApiBase.ts @@ -39,9 +39,9 @@ import { Settings } from '@src/Settings'; import { Logger } from '@src/Logger'; import { ModelUtils } from '@src/model/ModelUtils'; import { AlphaTabError, AlphaTabErrorType } from '@src/AlphaTabError'; -import { Note } from './model/Note'; -import { MidiEventType } from './midi/MidiEvent'; -import { MidiEventsPlayedEventArgs } from './synth/MidiEventsPlayedEventArgs'; +import { Note } from '@src/model/Note'; +import { MidiEventType } from '@src/midi/MidiEvent'; +import { MidiEventsPlayedEventArgs } from '@src/synth/MidiEventsPlayedEventArgs'; class SelectionInfo { public beat: Beat; diff --git a/src/Environment.ts b/src/Environment.ts index f816e235c..414582f6d 100644 --- a/src/Environment.ts +++ b/src/Environment.ts @@ -50,12 +50,12 @@ import { ScoreRenderer } from '@src/rendering/ScoreRenderer'; import { TabBarRendererFactory } from '@src/rendering/TabBarRendererFactory'; import { FontLoadingChecker } from '@src/util/FontLoadingChecker'; import { Logger } from '@src/Logger'; -import { LeftHandTapEffectInfo } from './rendering/effects/LeftHandTapEffectInfo'; -import { CapellaImporter } from './importer/CapellaImporter'; -import { ResizeObserverPolyfill } from './platform/javascript/ResizeObserverPolyfill'; -import { WebPlatform } from './platform/javascript/WebPlatform'; -import { IntersectionObserverPolyfill } from './platform/javascript/IntersectionObserverPolyfill'; -import { AlphaSynthWebWorklet } from './platform/javascript/AlphaSynthAudioWorkletOutput'; +import { LeftHandTapEffectInfo } from '@src/rendering/effects/LeftHandTapEffectInfo'; +import { CapellaImporter } from '@src/importer/CapellaImporter'; +import { ResizeObserverPolyfill } from '@src/platform/javascript/ResizeObserverPolyfill'; +import { WebPlatform } from '@src/platform/javascript/WebPlatform'; +import { IntersectionObserverPolyfill } from '@src/platform/javascript/IntersectionObserverPolyfill'; +import { AlphaSynthWebWorklet } from '@src/platform/javascript/AlphaSynthAudioWorkletOutput'; export class LayoutEngineFactory { public readonly vertical: boolean; diff --git a/src/alphatab.ts b/src/alphatab.ts index cac9384af..3a0e17147 100644 --- a/src/alphatab.ts +++ b/src/alphatab.ts @@ -1,241 +1,27 @@ -import { CoreSettings } from '@src/CoreSettings'; -import { DisplaySettings } from '@src/DisplaySettings'; -import { LayoutMode } from '@src/LayoutMode'; -import { StaveProfile } from '@src/StaveProfile'; -import { ImporterSettings } from '@src/ImporterSettings'; -import { FingeringMode, NotationMode, NotationSettings, TabRhythmMode } from '@src/NotationSettings'; -import { PlayerSettings, ScrollMode, VibratoPlaybackSettings } from '@src/PlayerSettings'; -import { ProgressEventArgs } from '@src/ProgressEventArgs'; -import { RenderingResources } from '@src/RenderingResources'; -import { ResizeEventArgs } from '@src/ResizeEventArgs'; -import { Settings } from '@src/Settings'; -import { AlphaTabError, AlphaTabErrorType } from '@src/AlphaTabError'; -import { FormatError } from '@src/FormatError'; -import { LogLevel } from '@src/LogLevel'; -import { Logger } from '@src/Logger'; -import { FileLoadError } from '@src/FileLoadError'; - -import { AlphaTabApi } from '@src/platform/javascript/AlphaTabApi'; - -export { - AlphaTabApi, - AlphaTabError, - AlphaTabErrorType, - FileLoadError, - CoreSettings, - StaveProfile, - LayoutMode, - DisplaySettings, - FormatError, - ImporterSettings, - TabRhythmMode, - FingeringMode, - NotationMode, - NotationSettings, - ScrollMode, - VibratoPlaybackSettings, - PlayerSettings, - ProgressEventArgs, - RenderingResources, - ResizeEventArgs, - Settings, - LogLevel, - Logger -}; - -import { VersionInfo } from '@src/generated/VersionInfo'; -export const meta = VersionInfo; - -import { ScoreImporter } from '@src/importer/ScoreImporter'; -import { ScoreLoader } from '@src/importer/ScoreLoader'; -import { UnsupportedFormatError } from '@src/importer/UnsupportedFormatError'; - -export const importer = { - ScoreImporter, - ScoreLoader, - UnsupportedFormatError -}; - -import { ScoreExporter } from '@src/exporter/ScoreExporter'; -import { Gp7Exporter } from '@src/exporter/Gp7Exporter'; - -export const exporter = { - ScoreExporter, - Gp7Exporter -}; - -import { BeatTickLookup } from '@src/midi/BeatTickLookup'; -import { MasterBarTickLookup } from '@src/midi/MasterBarTickLookup'; -import { MidiTickLookup, MidiTickLookupFindBeatResult } from '@src/midi/MidiTickLookup'; -import { MidiFile } from '@src/midi/MidiFile'; -import { ControllerType } from '@src/midi/ControllerType'; -import { MetaDataEvent } from '@src/midi/MetaDataEvent'; -import { MetaEvent, MetaEventType } from '@src/midi/MetaEvent'; -import { MetaNumberEvent } from '@src/midi/MetaNumberEvent'; -import { MidiEvent, MidiEventType } from '@src/midi/MidiEvent'; -import { Midi20PerNotePitchBendEvent } from '@src/midi/Midi20PerNotePitchBendEvent'; -import { SystemCommonEvent, SystemCommonType } from '@src/midi/SystemCommonEvent'; -import { SystemExclusiveEvent } from '@src/midi/SystemExclusiveEvent'; -import { MidiFileGenerator } from '@src/midi/MidiFileGenerator'; -import { AlphaSynthMidiFileHandler } from '@src/midi/AlphaSynthMidiFileHandler'; - -export const midi = { - BeatTickLookup, - MasterBarTickLookup, - MidiTickLookup, - MidiTickLookupFindBeatResult, - MidiFile, - ControllerType, - MetaDataEvent, - MetaEvent, - MetaEventType, - MetaNumberEvent, - MidiEvent, - MidiEventType, - Midi20PerNotePitchBendEvent, - SystemCommonEvent, - SystemCommonType, - SystemExclusiveEvent, - MidiFileGenerator, - AlphaSynthMidiFileHandler -}; - -import { AccentuationType } from '@src/model/AccentuationType'; -import { AccidentalType } from '@src/model/AccidentalType'; -import { AutomationType, Automation } from '@src/model/Automation'; -import { Bar } from '@src/model/Bar'; -import { Beat } from '@src/model/Beat'; -import { BendPoint } from '@src/model/BendPoint'; -import { BendStyle } from '@src/model/BendStyle'; -import { BendType } from '@src/model/BendType'; -import { BrushType } from '@src/model/BrushType'; -import { Chord } from '@src/model/Chord'; -import { Clef } from '@src/model/Clef'; -import { Color } from '@src/model/Color'; -import { CrescendoType } from '@src/model/CrescendoType'; -import { Duration } from '@src/model/Duration'; -import { DynamicValue } from '@src/model/DynamicValue'; -import { FermataType, Fermata } from '@src/model/Fermata'; -import { Fingers } from '@src/model/Fingers'; -import { FontStyle, Font } from '@src/model/Font'; -import { GraceType } from '@src/model/GraceType'; -import { HarmonicType } from '@src/model/HarmonicType'; -import { InstrumentArticulation } from '@src/model/InstrumentArticulation'; -import { JsonConverter } from '@src/model/JsonConverter'; -import { KeySignature } from '@src/model/KeySignature'; -import { KeySignatureType } from '@src/model/KeySignatureType'; -import { Lyrics } from '@src/model/Lyrics'; -import { MasterBar } from '@src/model/MasterBar'; -import { MusicFontSymbol } from '@src/model/MusicFontSymbol'; -import { Note } from '@src/model/Note'; -import { NoteAccidentalMode } from '@src/model/NoteAccidentalMode'; -import { Ottavia } from '@src/model/Ottavia'; -import { PickStroke } from '@src/model/PickStroke'; -import { PlaybackInformation } from '@src/model/PlaybackInformation'; -import { RenderStylesheet } from '@src/model/RenderStylesheet'; -import { RepeatGroup } from '@src/model/RepeatGroup'; -import { Score } from '@src/model/Score'; -import { Section } from '@src/model/Section'; -import { SimileMark } from '@src/model/SimileMark'; -import { SlideInType } from '@src/model/SlideInType'; -import { SlideOutType } from '@src/model/SlideOutType'; -import { Staff } from '@src/model/Staff'; -import { Track } from '@src/model/Track'; -import { TripletFeel } from '@src/model/TripletFeel'; -import { Tuning } from '@src/model/Tuning'; -import { TupletGroup } from '@src/model/TupletGroup'; -import { VibratoType } from '@src/model/VibratoType'; -import { Voice } from '@src/model/Voice'; -import { WhammyType } from '@src/model/WhammyType'; - -export const model = { - AccentuationType, - AccidentalType, - AutomationType, - Automation, - Bar, - Beat, - BendPoint, - BendStyle, - BendType, - BrushType, - Chord, - Clef, - Color, - CrescendoType, - Duration, - DynamicValue, - FermataType, - Fermata, - Fingers, - FontStyle, - Font, - GraceType, - HarmonicType, - InstrumentArticulation, - JsonConverter, - KeySignature, - KeySignatureType, - Lyrics, - MasterBar, - MusicFontSymbol, - Note, - NoteAccidentalMode, - Ottavia, - PickStroke, - PlaybackInformation, - RenderStylesheet, - RepeatGroup, - Score, - Section, - SimileMark, - SlideInType, - SlideOutType, - Staff, - Track, - TripletFeel, - Tuning, - TupletGroup, - VibratoType, - Voice, - WhammyType -}; - -import { RenderFinishedEventArgs } from '@src/rendering/RenderFinishedEventArgs'; -import { ScoreRenderer } from '@src/rendering/ScoreRenderer'; - -import { BarBounds } from '@src/rendering/utils/BarBounds'; -import { BeatBounds } from '@src/rendering/utils/BeatBounds'; -import { Bounds } from '@src/rendering/utils/Bounds'; -import { BoundsLookup } from '@src/rendering/utils/BoundsLookup'; -import { MasterBarBounds } from '@src/rendering/utils/MasterBarBounds'; -import { NoteBounds } from '@src/rendering/utils/NoteBounds'; -import { StaveGroupBounds } from '@src/rendering/utils/StaveGroupBounds'; - -export const rendering = { - ScoreRenderer, - RenderFinishedEventArgs, - BarBounds, - BeatBounds, - Bounds, - BoundsLookup, - MasterBarBounds, - NoteBounds, - StaveGroupBounds -}; - -import { AlphaSynth } from '@src/synth/AlphaSynth'; -import { PlaybackRange } from '@src/synth/PlaybackRange'; -import { PlayerState } from '@src/synth/PlayerState'; -import { PlayerStateChangedEventArgs } from '@src/synth/PlayerStateChangedEventArgs'; -import { PositionChangedEventArgs } from '@src/synth/PositionChangedEventArgs'; -import { AlphaSynthWebWorkerApi } from '@src/platform/javascript/AlphaSynthWebWorkerApi' - -export const synth = { - AlphaSynth, - PlaybackRange, - PlayerState, - PlayerStateChangedEventArgs, - PositionChangedEventArgs, - AlphaSynthWebWorkerApi -}; +export { CoreSettings } from '@src/CoreSettings'; +export { DisplaySettings } from '@src/DisplaySettings'; +export { LayoutMode } from '@src/LayoutMode'; +export { StaveProfile } from '@src/StaveProfile'; +export { ImporterSettings } from '@src/ImporterSettings'; +export { FingeringMode, NotationMode, NotationSettings, TabRhythmMode } from '@src/NotationSettings'; +export { PlayerSettings, ScrollMode, VibratoPlaybackSettings } from '@src/PlayerSettings'; +export { ProgressEventArgs } from '@src/ProgressEventArgs'; +export { RenderingResources } from '@src/RenderingResources'; +export { ResizeEventArgs } from '@src/ResizeEventArgs'; +export { Settings } from '@src/Settings'; +export { AlphaTabError, AlphaTabErrorType } from '@src/AlphaTabError'; +export { FormatError } from '@src/FormatError'; +export { LogLevel } from '@src/LogLevel'; +export { Logger } from '@src/Logger'; +export { FileLoadError } from '@src/FileLoadError'; + +export { AlphaTabApi } from '@src/platform/javascript/AlphaTabApi'; + +export { VersionInfo as meta } from '@src/generated/VersionInfo'; + +export * as importer from "./importer"; +export * as exporter from "./exporter"; +export * as midi from "./midi"; +export * as model from "./model"; +export * as rendering from "./rendering"; +export * as synth from "./synth"; \ No newline at end of file diff --git a/src/exporter/Gp7Exporter.ts b/src/exporter/Gp7Exporter.ts index 56a59dbe0..60c54f43e 100644 --- a/src/exporter/Gp7Exporter.ts +++ b/src/exporter/Gp7Exporter.ts @@ -1,11 +1,11 @@ import { Logger } from '@src/Logger'; import { Score } from '@src/model/Score'; import { ZipEntry } from '@src/zip/ZipEntry'; -import { ScoreExporter } from './ScoreExporter'; +import { ScoreExporter } from '@src/exporter/ScoreExporter'; +import { GpifWriter } from '@src/exporter//GpifWriter'; import { IOHelper } from '@src/io/IOHelper'; import { BinaryStylesheet } from '@src/importer/BinaryStylesheet'; import { PartConfiguration } from '@src/importer/PartConfiguration'; -import { GpifWriter } from './GpifWriter'; import { ZipWriter } from '@src/zip/ZipWriter'; /** * This ScoreExporter can write Guitar Pro 7 (gp) files. diff --git a/src/exporter/index.ts b/src/exporter/index.ts new file mode 100644 index 000000000..0480fec7d --- /dev/null +++ b/src/exporter/index.ts @@ -0,0 +1,2 @@ +export { ScoreExporter } from '@src/exporter/ScoreExporter'; +export { Gp7Exporter } from '@src/exporter/Gp7Exporter'; diff --git a/src/importer/CapellaImporter.ts b/src/importer/CapellaImporter.ts index 132b52323..bc2c91f82 100644 --- a/src/importer/CapellaImporter.ts +++ b/src/importer/CapellaImporter.ts @@ -8,7 +8,7 @@ import { Logger } from '@src/Logger'; import { ZipReader } from '@src/zip/ZipReader'; import { ZipEntry } from "@src/zip/ZipEntry"; import { IOHelper } from '@src/io/IOHelper'; -import { CapellaParser } from './CapellaParser'; +import { CapellaParser } from '@src/importer/CapellaParser'; /** * This ScoreImporter can read Capella (cap/capx) files. diff --git a/src/importer/index.ts b/src/importer/index.ts new file mode 100644 index 000000000..1d101e0bd --- /dev/null +++ b/src/importer/index.ts @@ -0,0 +1,3 @@ +export { ScoreImporter } from '@src/importer/ScoreImporter'; +export { ScoreLoader } from '@src/importer/ScoreLoader'; +export { UnsupportedFormatError } from '@src/importer/UnsupportedFormatError'; diff --git a/src/io/ByteBuffer.ts b/src/io/ByteBuffer.ts index e196d4007..2b3cacb79 100644 --- a/src/io/ByteBuffer.ts +++ b/src/io/ByteBuffer.ts @@ -1,6 +1,6 @@ import { IReadable } from '@src/io/IReadable'; import { IWriteable } from '@src/io/IWriteable'; -import { IOHelper } from './IOHelper'; +import { IOHelper } from '@src/io/IOHelper'; export class ByteBuffer implements IWriteable, IReadable { private _buffer!: Uint8Array; diff --git a/src/io/IOHelper.ts b/src/io/IOHelper.ts index 45188f4f9..96520a8f0 100644 --- a/src/io/IOHelper.ts +++ b/src/io/IOHelper.ts @@ -1,6 +1,6 @@ import { IReadable } from '@src/io/IReadable'; import { TypeConversions } from '@src/io/TypeConversions'; -import { IWriteable } from './IWriteable'; +import { IWriteable } from '@src/io/IWriteable'; export class IOHelper { public static readInt32BE(input: IReadable): number { diff --git a/src/midi/AlphaSynthMidiFileHandler.ts b/src/midi/AlphaSynthMidiFileHandler.ts index 5163ea57e..d0a651be3 100644 --- a/src/midi/AlphaSynthMidiFileHandler.ts +++ b/src/midi/AlphaSynthMidiFileHandler.ts @@ -9,7 +9,7 @@ import { MidiFile } from '@src/midi/MidiFile'; import { MidiUtils } from '@src/midi/MidiUtils'; import { DynamicValue } from '@src/model/DynamicValue'; import { SynthConstants } from '@src/synth/SynthConstants'; -import { Midi20PerNotePitchBendEvent } from './Midi20PerNotePitchBendEvent'; +import { Midi20PerNotePitchBendEvent } from '@src/midi/Midi20PerNotePitchBendEvent'; /** * This implementation of the {@link IMidiFileHandler} diff --git a/src/midi/BeatTickLookup.ts b/src/midi/BeatTickLookup.ts index acb426780..20038bdeb 100644 --- a/src/midi/BeatTickLookup.ts +++ b/src/midi/BeatTickLookup.ts @@ -1,5 +1,5 @@ import { Beat } from '@src/model/Beat'; -import { MasterBarTickLookup } from './MasterBarTickLookup'; +import { MasterBarTickLookup } from '@src/midi/MasterBarTickLookup'; /** * Represents the time period, for which a {@link Beat} is played. diff --git a/src/midi/index.ts b/src/midi/index.ts new file mode 100644 index 000000000..55bb0a2ec --- /dev/null +++ b/src/midi/index.ts @@ -0,0 +1,14 @@ +export { BeatTickLookup } from '@src/midi/BeatTickLookup'; +export { MasterBarTickLookup } from '@src/midi/MasterBarTickLookup'; +export { MidiTickLookup, MidiTickLookupFindBeatResult } from '@src/midi/MidiTickLookup'; +export { MidiFile } from '@src/midi/MidiFile'; +export { ControllerType } from '@src/midi/ControllerType'; +export { MetaDataEvent } from '@src/midi/MetaDataEvent'; +export { MetaEvent, MetaEventType } from '@src/midi/MetaEvent'; +export { MetaNumberEvent } from '@src/midi/MetaNumberEvent'; +export { MidiEvent, MidiEventType } from '@src/midi/MidiEvent'; +export { Midi20PerNotePitchBendEvent } from '@src/midi/Midi20PerNotePitchBendEvent'; +export { SystemCommonEvent, SystemCommonType } from '@src/midi/SystemCommonEvent'; +export { SystemExclusiveEvent } from '@src/midi/SystemExclusiveEvent'; +export { MidiFileGenerator } from '@src/midi/MidiFileGenerator'; +export { AlphaSynthMidiFileHandler } from '@src/midi/AlphaSynthMidiFileHandler'; diff --git a/src/model/Beat.ts b/src/model/Beat.ts index 81e904ccb..24f4580ca 100644 --- a/src/model/Beat.ts +++ b/src/model/Beat.ts @@ -22,7 +22,7 @@ import { Settings } from '@src/Settings'; import { Logger } from '@src/Logger'; import { BeamDirection } from '@src/rendering/utils/BeamDirection'; import { BeatCloner } from '@src/generated/model/BeatCloner'; -import { GraceGroup } from './GraceGroup'; +import { GraceGroup } from '@src/model/GraceGroup'; /** * Lists the different modes on how beaming for a beat should be done. diff --git a/src/model/Color.ts b/src/model/Color.ts index c18d3c2a3..ca98a98ab 100644 --- a/src/model/Color.ts +++ b/src/model/Color.ts @@ -1,5 +1,5 @@ import { FormatError } from '@src/FormatError'; -import { ModelUtils } from './ModelUtils'; +import { ModelUtils } from '@src/model/ModelUtils'; /** * @json_immutable diff --git a/src/model/GraceGroup.ts b/src/model/GraceGroup.ts index a7d4c0f92..b54ea29dd 100644 --- a/src/model/GraceGroup.ts +++ b/src/model/GraceGroup.ts @@ -1,4 +1,4 @@ -import { Beat } from './Beat'; +import { Beat } from '@src/model/Beat'; /** * Represents a group of grace beats that belong together diff --git a/src/model/Note.ts b/src/model/Note.ts index 555ffa3ab..b636d8ab4 100644 --- a/src/model/Note.ts +++ b/src/model/Note.ts @@ -18,7 +18,7 @@ import { Settings } from '@src/Settings'; import { Lazy } from '@src/util/Lazy'; import { Logger } from '@src/Logger'; import { ModelUtils } from '@src/model/ModelUtils'; -import { PickStroke } from './PickStroke'; +import { PickStroke } from '@src/model/PickStroke'; import { PercussionMapper } from '@src/model/PercussionMapper'; /** diff --git a/src/model/Score.ts b/src/model/Score.ts index 2baadc108..4a9bcc18e 100644 --- a/src/model/Score.ts +++ b/src/model/Score.ts @@ -3,7 +3,7 @@ import { RenderStylesheet } from '@src/model/RenderStylesheet'; import { RepeatGroup } from '@src/model/RepeatGroup'; import { Track } from '@src/model/Track'; import { Settings } from '@src/Settings'; -import { Note } from './Note'; +import { Note } from '@src/model/Note'; /** * The score is the root node of the complete diff --git a/src/model/Staff.ts b/src/model/Staff.ts index 73093dd6d..058a1e9dc 100644 --- a/src/model/Staff.ts +++ b/src/model/Staff.ts @@ -2,7 +2,7 @@ import { Bar } from '@src/model/Bar'; import { Chord } from '@src/model/Chord'; import { Track } from '@src/model/Track'; import { Settings } from '@src/Settings'; -import { Tuning } from './Tuning'; +import { Tuning } from '@src/model/Tuning'; /** * This class describes a single staff within a track. There are instruments like pianos diff --git a/src/model/Track.ts b/src/model/Track.ts index 7c6327d3b..4f7f83c30 100644 --- a/src/model/Track.ts +++ b/src/model/Track.ts @@ -5,7 +5,7 @@ import { PlaybackInformation } from '@src/model/PlaybackInformation'; import { Score } from '@src/model/Score'; import { Staff } from '@src/model/Staff'; import { Settings } from '@src/Settings'; -import { InstrumentArticulation } from './InstrumentArticulation'; +import { InstrumentArticulation } from '@src/model/InstrumentArticulation'; /** * This public class describes a single track or instrument of score. diff --git a/src/model/Voice.ts b/src/model/Voice.ts index c6224a8cf..fa41a0efd 100644 --- a/src/model/Voice.ts +++ b/src/model/Voice.ts @@ -2,7 +2,7 @@ import { Bar } from '@src/model/Bar'; import { Beat } from '@src/model/Beat'; import { GraceType } from '@src/model/GraceType'; import { Settings } from '@src/Settings'; -import { GraceGroup } from './GraceGroup'; +import { GraceGroup } from '@src/model/GraceGroup'; /** * A voice represents a group of beats diff --git a/src/model/index.ts b/src/model/index.ts new file mode 100644 index 000000000..537298896 --- /dev/null +++ b/src/model/index.ts @@ -0,0 +1,47 @@ +export { AccentuationType } from '@src/model/AccentuationType'; +export { AccidentalType } from '@src/model/AccidentalType'; +export { AutomationType, Automation } from '@src/model/Automation'; +export { Bar } from '@src/model/Bar'; +export { Beat } from '@src/model/Beat'; +export { BendPoint } from '@src/model/BendPoint'; +export { BendStyle } from '@src/model/BendStyle'; +export { BendType } from '@src/model/BendType'; +export { BrushType } from '@src/model/BrushType'; +export { Chord } from '@src/model/Chord'; +export { Clef } from '@src/model/Clef'; +export { Color } from '@src/model/Color'; +export { CrescendoType } from '@src/model/CrescendoType'; +export { Duration } from '@src/model/Duration'; +export { DynamicValue } from '@src/model/DynamicValue'; +export { FermataType, Fermata } from '@src/model/Fermata'; +export { Fingers } from '@src/model/Fingers'; +export { FontStyle, Font } from '@src/model/Font'; +export { GraceType } from '@src/model/GraceType'; +export { HarmonicType } from '@src/model/HarmonicType'; +export { InstrumentArticulation } from '@src/model/InstrumentArticulation'; +export { JsonConverter } from '@src/model/JsonConverter'; +export { KeySignature } from '@src/model/KeySignature'; +export { KeySignatureType } from '@src/model/KeySignatureType'; +export { Lyrics } from '@src/model/Lyrics'; +export { MasterBar } from '@src/model/MasterBar'; +export { MusicFontSymbol } from '@src/model/MusicFontSymbol'; +export { Note } from '@src/model/Note'; +export { NoteAccidentalMode } from '@src/model/NoteAccidentalMode'; +export { Ottavia } from '@src/model/Ottavia'; +export { PickStroke } from '@src/model/PickStroke'; +export { PlaybackInformation } from '@src/model/PlaybackInformation'; +export { RenderStylesheet } from '@src/model/RenderStylesheet'; +export { RepeatGroup } from '@src/model/RepeatGroup'; +export { Score } from '@src/model/Score'; +export { Section } from '@src/model/Section'; +export { SimileMark } from '@src/model/SimileMark'; +export { SlideInType } from '@src/model/SlideInType'; +export { SlideOutType } from '@src/model/SlideOutType'; +export { Staff } from '@src/model/Staff'; +export { Track } from '@src/model/Track'; +export { TripletFeel } from '@src/model/TripletFeel'; +export { Tuning } from '@src/model/Tuning'; +export { TupletGroup } from '@src/model/TupletGroup'; +export { VibratoType } from '@src/model/VibratoType'; +export { Voice } from '@src/model/Voice'; +export { WhammyType } from '@src/model/WhammyType'; \ No newline at end of file diff --git a/src/platform/javascript/AlphaSynthAudioWorkletOutput.ts b/src/platform/javascript/AlphaSynthAudioWorkletOutput.ts index d7f016353..5e2699acf 100644 --- a/src/platform/javascript/AlphaSynthAudioWorkletOutput.ts +++ b/src/platform/javascript/AlphaSynthAudioWorkletOutput.ts @@ -1,8 +1,8 @@ import { CircularSampleBuffer } from '@src/synth/ds/CircularSampleBuffer'; import { Environment } from '@src/Environment'; import { Logger } from '@src/Logger'; -import { AlphaSynthWorkerSynthOutput } from './AlphaSynthWorkerSynthOutput'; -import { AlphaSynthWebAudioOutputBase } from './AlphaSynthWebAudioOutputBase'; +import { AlphaSynthWorkerSynthOutput } from '@src/platform/javascript/AlphaSynthWorkerSynthOutput'; +import { AlphaSynthWebAudioOutputBase } from '@src/platform/javascript/AlphaSynthWebAudioOutputBase'; /** * @target web diff --git a/src/platform/javascript/AlphaSynthScriptProcessorOutput.ts b/src/platform/javascript/AlphaSynthScriptProcessorOutput.ts index 1ad068f5d..7b57e973d 100644 --- a/src/platform/javascript/AlphaSynthScriptProcessorOutput.ts +++ b/src/platform/javascript/AlphaSynthScriptProcessorOutput.ts @@ -1,5 +1,5 @@ import { CircularSampleBuffer } from '@src/synth/ds/CircularSampleBuffer'; -import { AlphaSynthWebAudioOutputBase } from './AlphaSynthWebAudioOutputBase'; +import { AlphaSynthWebAudioOutputBase } from '@src/platform/javascript/AlphaSynthWebAudioOutputBase'; // tslint:disable: deprecation diff --git a/src/platform/javascript/BrowserUiFacade.ts b/src/platform/javascript/BrowserUiFacade.ts index feabc666c..640fd4b7a 100644 --- a/src/platform/javascript/BrowserUiFacade.ts +++ b/src/platform/javascript/BrowserUiFacade.ts @@ -25,7 +25,7 @@ import { BrowserMouseEventArgs } from '@src/platform/javascript/BrowserMouseEven import { Cursors } from '@src/platform/Cursors'; import { JsonConverter } from '@src/model/JsonConverter'; import { SettingsSerializer } from '@src/generated/SettingsSerializer'; -import { WebPlatform } from './WebPlatform'; +import { WebPlatform } from '@src/platform/javascript/WebPlatform'; import { AlphaTabError, AlphaTabErrorType } from '@src/AlphaTabError'; import { AlphaSynthAudioWorkletOutput } from '@src/platform/javascript/AlphaSynthAudioWorkletOutput'; diff --git a/src/rendering/BarRendererBase.ts b/src/rendering/BarRendererBase.ts index cf358c115..53f2ac6be 100644 --- a/src/rendering/BarRendererBase.ts +++ b/src/rendering/BarRendererBase.ts @@ -20,8 +20,8 @@ import { Bounds } from '@src/rendering/utils/Bounds'; import { MasterBarBounds } from '@src/rendering/utils/MasterBarBounds'; import { RenderingResources } from '@src/RenderingResources'; import { Settings } from '@src/Settings'; -import { BeatOnNoteGlyphBase } from './glyphs/BeatOnNoteGlyphBase'; -import { BeamingHelper } from './utils/BeamingHelper'; +import { BeatOnNoteGlyphBase } from '@src/rendering/glyphs/BeatOnNoteGlyphBase'; +import { BeamingHelper } from '@src/rendering/utils/BeamingHelper'; /** * Lists the different position modes for {@link BarRendererBase.getNoteY} diff --git a/src/rendering/TabBarRenderer.ts b/src/rendering/TabBarRenderer.ts index a2c8d5865..39dcc53df 100644 --- a/src/rendering/TabBarRenderer.ts +++ b/src/rendering/TabBarRenderer.ts @@ -26,7 +26,7 @@ import { BeamDirection } from '@src/rendering/utils/BeamDirection'; import { BeamingHelper } from '@src/rendering/utils/BeamingHelper'; import { RenderingResources } from '@src/RenderingResources'; import { ModelUtils } from '@src/model/ModelUtils'; -import { ReservedLayoutAreaSlot } from './utils/BarCollisionHelper'; +import { ReservedLayoutAreaSlot } from '@src/rendering/utils/BarCollisionHelper'; /** * This BarRenderer renders a bar using guitar tablature notation diff --git a/src/rendering/effects/LeftHandTapEffectInfo.ts b/src/rendering/effects/LeftHandTapEffectInfo.ts index f79643bd1..95862f167 100644 --- a/src/rendering/effects/LeftHandTapEffectInfo.ts +++ b/src/rendering/effects/LeftHandTapEffectInfo.ts @@ -3,7 +3,7 @@ import { BarRendererBase } from '@src/rendering/BarRendererBase'; import { EffectBarGlyphSizing } from '@src/rendering/EffectBarGlyphSizing'; import { EffectGlyph } from '@src/rendering/glyphs/EffectGlyph'; import { NotationElement } from '@src/NotationSettings'; -import { NoteEffectInfoBase } from './NoteEffectInfoBase'; +import { NoteEffectInfoBase } from '@src/rendering/effects/NoteEffectInfoBase'; import { Note } from '@src/model/Note'; import { LeftHandTapGlyph } from '@src/rendering/glyphs/LeftHandTapGlyph'; diff --git a/src/rendering/glyphs/AccidentalGroupGlyph.ts b/src/rendering/glyphs/AccidentalGroupGlyph.ts index 9e027a59a..1f40ed60d 100644 --- a/src/rendering/glyphs/AccidentalGroupGlyph.ts +++ b/src/rendering/glyphs/AccidentalGroupGlyph.ts @@ -1,6 +1,6 @@ import { Glyph } from '@src/rendering/glyphs/Glyph'; import { GlyphGroup } from '@src/rendering/glyphs/GlyphGroup'; -import { AccidentalGlyph } from './AccidentalGlyph'; +import { AccidentalGlyph } from '@src/rendering/glyphs/AccidentalGlyph'; class AccidentalColumnInfo { public x: number = 0; diff --git a/src/rendering/glyphs/BeatContainerGlyph.ts b/src/rendering/glyphs/BeatContainerGlyph.ts index 5d9308929..6f90c20dd 100644 --- a/src/rendering/glyphs/BeatContainerGlyph.ts +++ b/src/rendering/glyphs/BeatContainerGlyph.ts @@ -8,11 +8,11 @@ import { BeatOnNoteGlyphBase } from '@src/rendering/glyphs/BeatOnNoteGlyphBase'; import { Glyph } from '@src/rendering/glyphs/Glyph'; import { VoiceContainerGlyph } from '@src/rendering/glyphs/VoiceContainerGlyph'; import { BarLayoutingInfo } from '@src/rendering/staves/BarLayoutingInfo'; -import { BarBounds } from '../utils/BarBounds'; -import { BeatBounds } from '../utils/BeatBounds'; -import { Bounds } from '../utils/Bounds'; -import { FlagGlyph } from './FlagGlyph'; -import { NoteHeadGlyph } from './NoteHeadGlyph'; +import { BarBounds } from '@src/rendering/utils/BarBounds'; +import { BeatBounds } from '@src/rendering/utils/BeatBounds'; +import { Bounds } from '@src/rendering/utils/Bounds'; +import { FlagGlyph } from '@src/rendering/glyphs/FlagGlyph'; +import { NoteHeadGlyph } from '@src/rendering/glyphs/NoteHeadGlyph'; export class BeatContainerGlyph extends Glyph { public static readonly GraceBeatPadding:number = 3; diff --git a/src/rendering/glyphs/BeatOnNoteGlyphBase.ts b/src/rendering/glyphs/BeatOnNoteGlyphBase.ts index 9751ff06e..793bb073a 100644 --- a/src/rendering/glyphs/BeatOnNoteGlyphBase.ts +++ b/src/rendering/glyphs/BeatOnNoteGlyphBase.ts @@ -1,8 +1,8 @@ import { BeatGlyphBase } from '@src/rendering/glyphs/BeatGlyphBase'; import { BeamingHelper } from '@src/rendering/utils/BeamingHelper'; -import { NoteXPosition, NoteYPosition } from '../BarRendererBase'; +import { NoteXPosition, NoteYPosition } from '@src/rendering/BarRendererBase'; import { Note } from '@src/model/Note'; -import { BeatBounds } from '../utils/BeatBounds'; +import { BeatBounds } from '@src/rendering/utils/BeatBounds'; export class BeatOnNoteGlyphBase extends BeatGlyphBase { public beamingHelper!: BeamingHelper; diff --git a/src/rendering/glyphs/ChordDiagramContainerGlyph.ts b/src/rendering/glyphs/ChordDiagramContainerGlyph.ts index 27fd1fad8..4f74294dd 100644 --- a/src/rendering/glyphs/ChordDiagramContainerGlyph.ts +++ b/src/rendering/glyphs/ChordDiagramContainerGlyph.ts @@ -1,6 +1,6 @@ import { Chord } from '@src/model/Chord'; import { ChordDiagramGlyph } from '@src/rendering/glyphs/ChordDiagramGlyph'; -import { RowContainerGlyph } from './RowContainerGlyph'; +import { RowContainerGlyph } from '@src/rendering/glyphs/RowContainerGlyph'; export class ChordDiagramContainerGlyph extends RowContainerGlyph { public constructor(x: number, y: number) { diff --git a/src/rendering/glyphs/NoteNumberGlyph.ts b/src/rendering/glyphs/NoteNumberGlyph.ts index 91e221573..0f09ac9c9 100644 --- a/src/rendering/glyphs/NoteNumberGlyph.ts +++ b/src/rendering/glyphs/NoteNumberGlyph.ts @@ -8,7 +8,7 @@ import { Bounds } from '@src/rendering/utils/Bounds'; import { NoteBounds } from '@src/rendering/utils/NoteBounds'; import { ModelUtils } from '@src/model/ModelUtils'; import { NotationElement, NotationMode } from '@src/NotationSettings'; -import { BeatBounds } from '../utils/BeatBounds'; +import { BeatBounds } from '@src/rendering/utils/BeatBounds'; export class NoteNumberGlyph extends Glyph { private _note: Note; diff --git a/src/rendering/glyphs/PercussionNoteHeadGlyph.ts b/src/rendering/glyphs/PercussionNoteHeadGlyph.ts index 46b9f5433..b0dd35f67 100644 --- a/src/rendering/glyphs/PercussionNoteHeadGlyph.ts +++ b/src/rendering/glyphs/PercussionNoteHeadGlyph.ts @@ -1,7 +1,7 @@ import { ICanvas, TextBaseline } from '@src/platform/ICanvas'; import { MusicFontGlyph } from '@src/rendering/glyphs/MusicFontGlyph'; import { MusicFontSymbol } from '@src/model/MusicFontSymbol'; -import { NoteHeadGlyph } from './NoteHeadGlyph'; +import { NoteHeadGlyph } from '@src/rendering/glyphs/NoteHeadGlyph'; import { Duration } from '@src/model/Duration'; import { InstrumentArticulation } from '@src/model/InstrumentArticulation'; diff --git a/src/rendering/glyphs/RowGlyphContainer.ts b/src/rendering/glyphs/RowGlyphContainer.ts index f365d7a1a..5ff2586f9 100644 --- a/src/rendering/glyphs/RowGlyphContainer.ts +++ b/src/rendering/glyphs/RowGlyphContainer.ts @@ -1,6 +1,6 @@ import { TextAlign } from '@src/platform/ICanvas'; import { GlyphGroup } from '@src/rendering/glyphs/GlyphGroup'; -import { Glyph } from './Glyph'; +import { Glyph } from '@src/rendering/glyphs/Glyph'; export class RowGlyphContainer extends GlyphGroup { private _glyphWidth: number = 0; diff --git a/src/rendering/glyphs/ScoreBeatGlyph.ts b/src/rendering/glyphs/ScoreBeatGlyph.ts index 626362b12..be2151ce5 100644 --- a/src/rendering/glyphs/ScoreBeatGlyph.ts +++ b/src/rendering/glyphs/ScoreBeatGlyph.ts @@ -17,19 +17,19 @@ import { ScoreRestGlyph } from '@src/rendering/glyphs/ScoreRestGlyph'; import { ScoreWhammyBarGlyph } from '@src/rendering/glyphs/ScoreWhammyBarGlyph'; import { SpacingGlyph } from '@src/rendering/glyphs/SpacingGlyph'; import { ScoreBarRenderer } from '@src/rendering/ScoreBarRenderer'; -import { NoteXPosition, NoteYPosition } from '../BarRendererBase'; -import { BeatBounds } from '../utils/BeatBounds'; -import { PercussionMapper } from '../../model/PercussionMapper'; -import { PercussionNoteHeadGlyph } from './PercussionNoteHeadGlyph'; +import { NoteXPosition, NoteYPosition } from '@src/rendering/BarRendererBase'; +import { BeatBounds } from '@src/rendering/utils/BeatBounds'; +import { PercussionMapper } from '@src/model/PercussionMapper'; +import { PercussionNoteHeadGlyph } from '@src/rendering/glyphs/PercussionNoteHeadGlyph'; import { Logger } from '@src/Logger'; -import { ArticStaccatoAboveGlyph } from './ArticStaccatoAboveGlyph'; -import { MusicFontSymbol } from '../../model/MusicFontSymbol'; +import { ArticStaccatoAboveGlyph } from '@src/rendering/glyphs/ArticStaccatoAboveGlyph'; +import { MusicFontSymbol } from '@src/model/MusicFontSymbol'; import { ICanvas, TextBaseline } from '@src/platform/ICanvas'; -import { PictEdgeOfCymbalGlyph } from './PictEdgeOfCymbalGlyph'; -import { PickStrokeGlyph } from './PickStrokeGlyph'; +import { PictEdgeOfCymbalGlyph } from '@src/rendering/glyphs/PictEdgeOfCymbalGlyph'; +import { PickStrokeGlyph } from '@src/rendering/glyphs/PickStrokeGlyph'; import { PickStroke } from '@src/model/PickStroke'; -import { GuitarGolpeGlyph } from './GuitarGolpeGlyph'; -import { BeamingHelper } from '../utils/BeamingHelper'; +import { GuitarGolpeGlyph } from '@src/rendering/glyphs/GuitarGolpeGlyph'; +import { BeamingHelper } from '@src/rendering/utils/BeamingHelper'; export class ScoreBeatGlyph extends BeatOnNoteGlyphBase { private _collisionOffset: number = -1000; diff --git a/src/rendering/glyphs/ScoreBendGlyph.ts b/src/rendering/glyphs/ScoreBendGlyph.ts index 80f601841..f30cdbbb4 100644 --- a/src/rendering/glyphs/ScoreBendGlyph.ts +++ b/src/rendering/glyphs/ScoreBendGlyph.ts @@ -13,7 +13,7 @@ import { TieGlyph } from '@src/rendering/glyphs/TieGlyph'; import { ScoreBarRenderer } from '@src/rendering/ScoreBarRenderer'; import { BeamDirection } from '@src/rendering/utils/BeamDirection'; import { NoteHeadGlyph } from '@src/rendering/glyphs/NoteHeadGlyph'; -import { NoteYPosition } from '../BarRendererBase'; +import { NoteYPosition } from '@src/rendering/BarRendererBase'; export class ScoreBendGlyph extends ScoreHelperNotesBaseGlyph { private _beat: Beat; diff --git a/src/rendering/glyphs/ScoreBrushGlyph.ts b/src/rendering/glyphs/ScoreBrushGlyph.ts index d91652f34..97ddac879 100644 --- a/src/rendering/glyphs/ScoreBrushGlyph.ts +++ b/src/rendering/glyphs/ScoreBrushGlyph.ts @@ -5,7 +5,7 @@ import { ICanvas } from '@src/platform/ICanvas'; import { Glyph } from '@src/rendering/glyphs/Glyph'; import { NoteVibratoGlyph } from '@src/rendering/glyphs/NoteVibratoGlyph'; import { ScoreBarRenderer } from '@src/rendering/ScoreBarRenderer'; -import { NoteYPosition } from '../BarRendererBase'; +import { NoteYPosition } from '@src/rendering/BarRendererBase'; export class ScoreBrushGlyph extends Glyph { private _beat: Beat; diff --git a/src/rendering/glyphs/ScoreHelperNotesBaseGlyph.ts b/src/rendering/glyphs/ScoreHelperNotesBaseGlyph.ts index cb44913d7..bd717a19d 100644 --- a/src/rendering/glyphs/ScoreHelperNotesBaseGlyph.ts +++ b/src/rendering/glyphs/ScoreHelperNotesBaseGlyph.ts @@ -4,7 +4,7 @@ import { BendNoteHeadGroupGlyph } from '@src/rendering/glyphs/BendNoteHeadGroupG import { Glyph } from '@src/rendering/glyphs/Glyph'; import { ScoreBarRenderer } from '@src/rendering/ScoreBarRenderer'; import { BeamDirection } from '@src/rendering/utils/BeamDirection'; -import { TieGlyph } from './TieGlyph'; +import { TieGlyph } from '@src/rendering/glyphs/TieGlyph'; export class ScoreHelperNotesBaseGlyph extends Glyph { public static readonly EndPadding: number = ((10 / 2) | 0) + 3; diff --git a/src/rendering/glyphs/ScoreNoteChordGlyph.ts b/src/rendering/glyphs/ScoreNoteChordGlyph.ts index 442aaee40..8d654fa0b 100644 --- a/src/rendering/glyphs/ScoreNoteChordGlyph.ts +++ b/src/rendering/glyphs/ScoreNoteChordGlyph.ts @@ -12,8 +12,8 @@ import { BeamDirection } from '@src/rendering/utils/BeamDirection'; import { BeamingHelper } from '@src/rendering/utils/BeamingHelper'; import { Bounds } from '@src/rendering/utils/Bounds'; import { NoteBounds } from '@src/rendering/utils/NoteBounds'; -import { NoteXPosition, NoteYPosition } from '../BarRendererBase'; -import { BeatBounds } from '../utils/BeatBounds'; +import { NoteXPosition, NoteYPosition } from '@src/rendering/BarRendererBase'; +import { BeatBounds } from '@src/rendering/utils/BeatBounds'; export class ScoreNoteChordGlyph extends ScoreNoteChordGlyphBase { private _noteGlyphLookup: Map<number, EffectGlyph> = new Map(); diff --git a/src/rendering/glyphs/ScoreSlurGlyph.ts b/src/rendering/glyphs/ScoreSlurGlyph.ts index 3f5624353..e56b737c1 100644 --- a/src/rendering/glyphs/ScoreSlurGlyph.ts +++ b/src/rendering/glyphs/ScoreSlurGlyph.ts @@ -1,10 +1,10 @@ import { Note } from '@src/model/Note'; -import { ScoreLegatoGlyph } from './ScoreLegatoGlyph'; -import { ScoreBarRenderer } from '../ScoreBarRenderer'; -import { NoteYPosition, NoteXPosition } from '../BarRendererBase'; -import { BeamDirection } from '../utils/BeamDirection'; +import { ScoreLegatoGlyph } from '@src/rendering/glyphs/ScoreLegatoGlyph'; +import { ScoreBarRenderer } from '@src/rendering/ScoreBarRenderer'; +import { NoteYPosition, NoteXPosition } from '@src/rendering/BarRendererBase'; +import { BeamDirection } from '@src/rendering/utils/BeamDirection'; import { GraceType } from '@src/model/GraceType'; -import { BeatXPosition } from '../BeatXPosition'; +import { BeatXPosition } from '@src/rendering/BeatXPosition'; export class ScoreSlurGlyph extends ScoreLegatoGlyph { private _startNote: Note; diff --git a/src/rendering/glyphs/ScoreTieGlyph.ts b/src/rendering/glyphs/ScoreTieGlyph.ts index b9b4ab16e..195371ee2 100644 --- a/src/rendering/glyphs/ScoreTieGlyph.ts +++ b/src/rendering/glyphs/ScoreTieGlyph.ts @@ -4,7 +4,7 @@ import { BarRendererBase, NoteYPosition } from '@src/rendering/BarRendererBase'; import { TieGlyph } from '@src/rendering/glyphs/TieGlyph'; import { ScoreBarRenderer } from '@src/rendering/ScoreBarRenderer'; import { BeamDirection } from '@src/rendering/utils/BeamDirection'; -import { BeatXPosition } from '../BeatXPosition'; +import { BeatXPosition } from '@src/rendering/BeatXPosition'; export class ScoreTieGlyph extends TieGlyph { protected startNote: Note; diff --git a/src/rendering/glyphs/ScoreWhammyBarGlyph.ts b/src/rendering/glyphs/ScoreWhammyBarGlyph.ts index b9cbc0e1e..cc5292591 100644 --- a/src/rendering/glyphs/ScoreWhammyBarGlyph.ts +++ b/src/rendering/glyphs/ScoreWhammyBarGlyph.ts @@ -15,7 +15,7 @@ import { BeamDirection } from '@src/rendering/utils/BeamDirection'; import { RenderingResources } from '@src/RenderingResources'; import { TabWhammyBarGlyph } from '@src/rendering/glyphs/TabWhammyBarGlyph'; import { NoteHeadGlyph } from '@src/rendering/glyphs/NoteHeadGlyph'; -import { NoteYPosition } from '../BarRendererBase'; +import { NoteYPosition } from '@src/rendering/BarRendererBase'; export class ScoreWhammyBarGlyph extends ScoreHelperNotesBaseGlyph { public static readonly SimpleDipHeight: number = TabWhammyBarGlyph.PerHalfSize * 2; diff --git a/src/rendering/glyphs/TabBeatGlyph.ts b/src/rendering/glyphs/TabBeatGlyph.ts index 8e4e90628..bdc1b534c 100644 --- a/src/rendering/glyphs/TabBeatGlyph.ts +++ b/src/rendering/glyphs/TabBeatGlyph.ts @@ -12,8 +12,8 @@ import { TabRestGlyph } from '@src/rendering/glyphs/TabRestGlyph'; import { TabWhammyBarGlyph } from '@src/rendering/glyphs/TabWhammyBarGlyph'; import { TremoloPickingGlyph } from '@src/rendering/glyphs/TremoloPickingGlyph'; import { TabBarRenderer } from '@src/rendering/TabBarRenderer'; -import { NoteXPosition, NoteYPosition } from '../BarRendererBase'; -import { BeatBounds } from '../utils/BeatBounds'; +import { NoteXPosition, NoteYPosition } from '@src/rendering/BarRendererBase'; +import { BeatBounds } from '@src/rendering/utils/BeatBounds'; export class TabBeatGlyph extends BeatOnNoteGlyphBase { public noteNumbers: TabNoteChordGlyph | null = null; diff --git a/src/rendering/glyphs/TabBrushGlyph.ts b/src/rendering/glyphs/TabBrushGlyph.ts index 33cfcd677..d846bffb1 100644 --- a/src/rendering/glyphs/TabBrushGlyph.ts +++ b/src/rendering/glyphs/TabBrushGlyph.ts @@ -5,7 +5,7 @@ import { ICanvas } from '@src/platform/ICanvas'; import { Glyph } from '@src/rendering/glyphs/Glyph'; import { NoteVibratoGlyph } from '@src/rendering/glyphs/NoteVibratoGlyph'; import { TabBarRenderer } from '@src/rendering/TabBarRenderer'; -import { NoteYPosition } from '../BarRendererBase'; +import { NoteYPosition } from '@src/rendering/BarRendererBase'; export class TabBrushGlyph extends Glyph { private _beat: Beat; diff --git a/src/rendering/glyphs/TabNoteChordGlyph.ts b/src/rendering/glyphs/TabNoteChordGlyph.ts index e17a8b8bc..ef3d8f17e 100644 --- a/src/rendering/glyphs/TabNoteChordGlyph.ts +++ b/src/rendering/glyphs/TabNoteChordGlyph.ts @@ -5,8 +5,8 @@ import { Glyph } from '@src/rendering/glyphs/Glyph'; import { NoteNumberGlyph } from '@src/rendering/glyphs/NoteNumberGlyph'; import { BeamingHelper } from '@src/rendering/utils/BeamingHelper'; import { RenderingResources } from '@src/RenderingResources'; -import { NoteXPosition, NoteYPosition } from '../BarRendererBase'; -import { BeatBounds } from '../utils/BeatBounds'; +import { NoteXPosition, NoteYPosition } from '@src/rendering/BarRendererBase'; +import { BeatBounds } from '@src/rendering/utils/BeatBounds'; export class TabNoteChordGlyph extends Glyph { private _notes: NoteNumberGlyph[] = []; diff --git a/src/rendering/glyphs/TuningContainerGlyph.ts b/src/rendering/glyphs/TuningContainerGlyph.ts index 5facb7498..6c4c01ba3 100644 --- a/src/rendering/glyphs/TuningContainerGlyph.ts +++ b/src/rendering/glyphs/TuningContainerGlyph.ts @@ -1,7 +1,7 @@ import { Tuning } from '@src/model/Tuning'; import { TextAlign } from '@src/platform/ICanvas'; -import { RowContainerGlyph } from './RowContainerGlyph'; -import { TuningGlyph } from './TuningGlyph'; +import { RowContainerGlyph } from '@src/rendering/glyphs/RowContainerGlyph'; +import { TuningGlyph } from '@src/rendering/glyphs/TuningGlyph'; export class TuningContainerGlyph extends RowContainerGlyph { public constructor(x: number, y: number) { diff --git a/src/rendering/glyphs/TuningGlyph.ts b/src/rendering/glyphs/TuningGlyph.ts index 56d9fa7d2..9c8a43199 100644 --- a/src/rendering/glyphs/TuningGlyph.ts +++ b/src/rendering/glyphs/TuningGlyph.ts @@ -3,7 +3,7 @@ import { Tuning } from '@src/model/Tuning'; import { TextAlign } from '@src/platform/ICanvas'; import { GlyphGroup } from '@src/rendering/glyphs/GlyphGroup'; import { TextGlyph } from '@src/rendering/glyphs/TextGlyph'; -import { MusicFontGlyph } from './MusicFontGlyph'; +import { MusicFontGlyph } from '@src/rendering/glyphs/MusicFontGlyph'; export class TuningGlyph extends GlyphGroup { private _tuning: Tuning; diff --git a/src/rendering/index.ts b/src/rendering/index.ts new file mode 100644 index 000000000..501f4c9a2 --- /dev/null +++ b/src/rendering/index.ts @@ -0,0 +1,10 @@ +export { RenderFinishedEventArgs } from '@src/rendering/RenderFinishedEventArgs'; +export { ScoreRenderer } from '@src/rendering/ScoreRenderer'; + +export { BarBounds } from '@src/rendering/utils/BarBounds'; +export { BeatBounds } from '@src/rendering/utils/BeatBounds'; +export { Bounds } from '@src/rendering/utils/Bounds'; +export { BoundsLookup } from '@src/rendering/utils/BoundsLookup'; +export { MasterBarBounds } from '@src/rendering/utils/MasterBarBounds'; +export { NoteBounds } from '@src/rendering/utils/NoteBounds'; +export { StaveGroupBounds } from '@src/rendering/utils/StaveGroupBounds'; diff --git a/src/rendering/layout/ScoreLayout.ts b/src/rendering/layout/ScoreLayout.ts index 081dab281..fe42f05a4 100644 --- a/src/rendering/layout/ScoreLayout.ts +++ b/src/rendering/layout/ScoreLayout.ts @@ -19,7 +19,7 @@ import { RenderingResources } from '@src/RenderingResources'; import { Logger } from '@src/Logger'; import { EventEmitterOfT } from '@src/EventEmitter'; import { NotationSettings, NotationElement } from '@src/NotationSettings'; -import { TuningContainerGlyph } from '../glyphs/TuningContainerGlyph'; +import { TuningContainerGlyph } from '@src/rendering/glyphs/TuningContainerGlyph'; /** * This is the base public class for creating new layouting engines for the score renderer. diff --git a/src/rendering/utils/AccidentalHelper.ts b/src/rendering/utils/AccidentalHelper.ts index d5f254af5..99d006453 100644 --- a/src/rendering/utils/AccidentalHelper.ts +++ b/src/rendering/utils/AccidentalHelper.ts @@ -4,8 +4,8 @@ import { Beat } from '@src/model/Beat'; import { Note } from '@src/model/Note'; import { NoteAccidentalMode } from '@src/model/NoteAccidentalMode'; import { ModelUtils } from '@src/model/ModelUtils'; -import { PercussionMapper } from '../../model/PercussionMapper'; -import { ScoreBarRenderer } from '../ScoreBarRenderer'; +import { PercussionMapper } from '@src/model/PercussionMapper'; +import { ScoreBarRenderer } from '@src/rendering/ScoreBarRenderer'; class BeatLines { diff --git a/src/rendering/utils/BarHelpers.ts b/src/rendering/utils/BarHelpers.ts index 4042ba2b4..a8073834d 100644 --- a/src/rendering/utils/BarHelpers.ts +++ b/src/rendering/utils/BarHelpers.ts @@ -2,8 +2,8 @@ import { Beat } from '@src/model/Beat'; import { GraceType } from '@src/model/GraceType'; import { Voice } from '@src/model/Voice'; import { BeamingHelper } from '@src/rendering/utils/BeamingHelper'; -import { BarRendererBase } from '../BarRendererBase'; -import { BarCollisionHelper } from './BarCollisionHelper'; +import { BarRendererBase } from '@src/rendering/BarRendererBase'; +import { BarCollisionHelper } from '@src/rendering/utils/BarCollisionHelper'; export class BarHelpers { private _renderer: BarRendererBase; diff --git a/src/rendering/utils/BeamingHelper.ts b/src/rendering/utils/BeamingHelper.ts index 808c0a231..d7d8704e0 100644 --- a/src/rendering/utils/BeamingHelper.ts +++ b/src/rendering/utils/BeamingHelper.ts @@ -10,8 +10,8 @@ import { Voice } from '@src/model/Voice'; import { BeamDirection } from '@src/rendering/utils/BeamDirection'; import { ModelUtils } from '@src/model/ModelUtils'; import { MidiUtils } from '@src/midi/MidiUtils'; -import { AccidentalHelper } from './AccidentalHelper'; -import { BarRendererBase, NoteYPosition } from '../BarRendererBase'; +import { AccidentalHelper } from '@src/rendering/utils/AccidentalHelper'; +import { BarRendererBase, NoteYPosition } from '@src/rendering/BarRendererBase'; class BeatLinePositions { public staffId: string = ''; diff --git a/src/rendering/utils/NoteBounds.ts b/src/rendering/utils/NoteBounds.ts index 8b52d9209..5d1d6875b 100644 --- a/src/rendering/utils/NoteBounds.ts +++ b/src/rendering/utils/NoteBounds.ts @@ -1,6 +1,6 @@ import { Note } from '@src/model/Note'; import { Bounds } from '@src/rendering/utils/Bounds'; -import { BeatBounds } from './BeatBounds'; +import { BeatBounds } from '@src/rendering/utils/BeatBounds'; /** * Represents the bounds of a single note diff --git a/src/synth/AlphaSynth.ts b/src/synth/AlphaSynth.ts index 4aafaf526..324e5567d 100644 --- a/src/synth/AlphaSynth.ts +++ b/src/synth/AlphaSynth.ts @@ -14,9 +14,9 @@ import { ByteBuffer } from '@src/io/ByteBuffer'; import { Logger } from '@src/Logger'; import { LogLevel } from '@src/LogLevel'; import { SynthConstants } from '@src/synth/SynthConstants'; -import { SynthEvent } from './synthesis/SynthEvent'; -import { Queue } from './ds/Queue'; -import { MidiEventsPlayedEventArgs } from './MidiEventsPlayedEventArgs'; +import { SynthEvent } from '@src/synth/synthesis/SynthEvent'; +import { Queue } from '@src/synth/ds/Queue'; +import { MidiEventsPlayedEventArgs } from '@src/synth/MidiEventsPlayedEventArgs'; import { MidiEvent, MidiEventType } from '@src/midi/MidiEvent'; /** diff --git a/src/synth/IAlphaSynth.ts b/src/synth/IAlphaSynth.ts index 406b61a3b..4062e145a 100644 --- a/src/synth/IAlphaSynth.ts +++ b/src/synth/IAlphaSynth.ts @@ -5,7 +5,7 @@ import { PlayerStateChangedEventArgs } from '@src/synth/PlayerStateChangedEventA import { PositionChangedEventArgs } from '@src/synth/PositionChangedEventArgs'; import { IEventEmitter, IEventEmitterOfT } from '@src/EventEmitter'; import { LogLevel } from '@src/LogLevel'; -import { MidiEventsPlayedEventArgs } from './MidiEventsPlayedEventArgs'; +import { MidiEventsPlayedEventArgs } from '@src/synth/MidiEventsPlayedEventArgs'; import { MidiEventType } from '@src/midi/MidiEvent'; /** diff --git a/src/synth/MidiFileSequencer.ts b/src/synth/MidiFileSequencer.ts index 79c2a955d..d90bedb5c 100644 --- a/src/synth/MidiFileSequencer.ts +++ b/src/synth/MidiFileSequencer.ts @@ -7,7 +7,7 @@ import { PlaybackRange } from '@src/synth/PlaybackRange'; import { SynthEvent } from '@src/synth/synthesis/SynthEvent'; import { TinySoundFont } from '@src/synth/synthesis/TinySoundFont'; import { Logger } from '@src/Logger'; -import { SynthConstants } from './SynthConstants'; +import { SynthConstants } from '@src/synth/SynthConstants'; export class MidiFileSequencerTempoChange { public bpm: number; diff --git a/src/synth/index.ts b/src/synth/index.ts new file mode 100644 index 000000000..5e8cb1fe8 --- /dev/null +++ b/src/synth/index.ts @@ -0,0 +1,6 @@ +export { AlphaSynth } from '@src/synth/AlphaSynth'; +export { PlaybackRange } from '@src/synth/PlaybackRange'; +export { PlayerState } from '@src/synth/PlayerState'; +export { PlayerStateChangedEventArgs } from '@src/synth/PlayerStateChangedEventArgs'; +export { PositionChangedEventArgs } from '@src/synth/PositionChangedEventArgs'; +export { AlphaSynthWebWorkerApi } from '@src/platform/javascript/AlphaSynthWebWorkerApi'; diff --git a/src/synth/synthesis/TinySoundFont.ts b/src/synth/synthesis/TinySoundFont.ts index 24523e20c..eb0fc19f0 100644 --- a/src/synth/synthesis/TinySoundFont.ts +++ b/src/synth/synthesis/TinySoundFont.ts @@ -29,7 +29,7 @@ import { Midi20PerNotePitchBendEvent } from '@src/midi/Midi20PerNotePitchBendEve import { MetaEventType } from '@src/midi/MetaEvent'; import { MetaNumberEvent } from '@src/midi/MetaNumberEvent'; import { MetaDataEvent } from '@src/midi/MetaDataEvent'; -import { Queue } from '../ds/Queue'; +import { Queue } from '@src/synth/ds/Queue'; /** * This is a tiny soundfont based synthesizer. diff --git a/src/synth/synthesis/Voice.ts b/src/synth/synthesis/Voice.ts index 41ebe04f6..f33b419c8 100644 --- a/src/synth/synthesis/Voice.ts +++ b/src/synth/synthesis/Voice.ts @@ -10,8 +10,8 @@ import { VoiceEnvelope, VoiceEnvelopeSegment } from '@src/synth/synthesis/VoiceE import { VoiceLfo } from '@src/synth/synthesis/VoiceLfo'; import { VoiceLowPass } from '@src/synth/synthesis/VoiceLowPass'; import { SynthHelper } from '@src/synth/SynthHelper'; -import { SynthConstants } from '../SynthConstants'; -import { Channel } from './Channel'; +import { SynthConstants } from '@src/synth/SynthConstants'; +import { Channel } from '@src/synth/synthesis/Channel'; export class Voice { /** diff --git a/src/xml/XmlDocument.ts b/src/xml/XmlDocument.ts index 060df9761..769b95986 100644 --- a/src/xml/XmlDocument.ts +++ b/src/xml/XmlDocument.ts @@ -23,7 +23,7 @@ import { XmlNode, XmlNodeType } from '@src/xml/XmlNode'; import { XmlParser } from '@src/xml/XmlParser'; -import { XmlWriter } from './XmlWriter'; +import { XmlWriter } from '@src/xml/XmlWriter'; export class XmlDocument extends XmlNode { public constructor() { diff --git a/src/xml/XmlWriter.ts b/src/xml/XmlWriter.ts index 29a035894..801368b6f 100644 --- a/src/xml/XmlWriter.ts +++ b/src/xml/XmlWriter.ts @@ -1,4 +1,4 @@ -import { XmlNode, XmlNodeType } from './XmlNode'; +import { XmlNode, XmlNodeType } from '@src/xml/XmlNode'; export class XmlWriter { public static write(xml: XmlNode, indention: string, xmlHeader: boolean): string { diff --git a/src/zip/DeflaterHuffman.ts b/src/zip/DeflaterHuffman.ts index 3d1e51286..06c4d2344 100644 --- a/src/zip/DeflaterHuffman.ts +++ b/src/zip/DeflaterHuffman.ts @@ -19,8 +19,8 @@ * DEALINGS IN THE SOFTWARE. */ -import { DeflaterConstants } from './DeflaterConstants'; -import { PendingBuffer } from './PendingBuffer'; +import { DeflaterConstants } from '@src/zip/DeflaterConstants'; +import { PendingBuffer } from '@src/zip/PendingBuffer'; class Tree { // repeat previous bit length 3-6 times (2 bits of repeat count) diff --git a/src/zip/ZipReader.ts b/src/zip/ZipReader.ts index ea5f3f094..2482c8080 100644 --- a/src/zip/ZipReader.ts +++ b/src/zip/ZipReader.ts @@ -2,7 +2,7 @@ import { ByteBuffer } from '@src/io/ByteBuffer'; import { IOHelper } from '@src/io/IOHelper'; import { IReadable } from '@src/io/IReadable'; import { Inflate } from '@src/zip/Inflate'; -import { ZipEntry } from './ZipEntry'; +import { ZipEntry } from '@src/zip/ZipEntry'; export class ZipReader { diff --git a/src/zip/ZipWriter.ts b/src/zip/ZipWriter.ts index 862c8e7a1..93a287062 100644 --- a/src/zip/ZipWriter.ts +++ b/src/zip/ZipWriter.ts @@ -1,9 +1,9 @@ import { ByteBuffer } from '@src/io/ByteBuffer'; import { IOHelper } from '@src/io/IOHelper'; import { IWriteable } from '@src/io/IWriteable'; -import { Crc32 } from './Crc32'; -import { Deflater } from './Deflater'; -import { ZipEntry } from './ZipEntry'; +import { Crc32 } from '@src/zip/Crc32'; +import { Deflater } from '@src/zip/Deflater'; +import { ZipEntry } from '@src/zip/ZipEntry'; class ZipCentralDirectoryHeader { public entry: ZipEntry; diff --git a/test/visualTests/VisualTestHelper.ts b/test/visualTests/VisualTestHelper.ts index 05c894759..5b26d4ab0 100644 --- a/test/visualTests/VisualTestHelper.ts +++ b/test/visualTests/VisualTestHelper.ts @@ -8,7 +8,7 @@ import { Environment } from '@src/Environment'; import { RenderFinishedEventArgs } from '@src/rendering/RenderFinishedEventArgs'; import { AlphaTexImporter } from '@src/importer/AlphaTexImporter'; import { ByteBuffer } from '@src/io/ByteBuffer'; -import { PixelMatch, PixelMatchOptions } from './PixelMatch'; +import { PixelMatch, PixelMatchOptions } from '@test/visualTests/PixelMatch'; import { JsonConverter } from '@src/model/JsonConverter'; /** From ef595042bdf5a7aeb56ba8734c04dc523de7d241 Mon Sep 17 00:00:00 2001 From: Danielku15 <danielku15@coderline.net> Date: Sun, 28 Nov 2021 15:42:53 +0100 Subject: [PATCH 2/3] Fix rollup issue with wildcard imports --- rollup.resolve.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/rollup.resolve.js b/rollup.resolve.js index 9f5939ade..740315ae5 100644 --- a/rollup.resolve.js +++ b/rollup.resolve.js @@ -14,7 +14,9 @@ module.exports = function (options) { const extension = types ? '.d.ts' : '.js'; - if (importee.startsWith('**')) { + if (fs.existsSync(importee)) { + return importee; + } else if (importee.startsWith('**')) { return importee; } else { const importerDir = path.dirname(importer); @@ -44,11 +46,7 @@ module.exports = function (options) { cwd: process.cwd() }); const source = files - .map( - (file, i) => - `import _${i} from ${JSON.stringify(path.join(process.cwd(), file))}; - export { _${i} };` - ) + .map((file, i) => `export * as _${i} from ${JSON.stringify(path.join(process.cwd(), file))};`) .join('\r\n'); return source; } From c421c55d5357f22aeb9eee530a055c4b4e4c9253 Mon Sep 17 00:00:00 2001 From: Danielku15 <danielku15@coderline.net> Date: Sun, 28 Nov 2021 15:56:53 +0100 Subject: [PATCH 3/3] Add support for namespace exports --- src.compiler/csharp/CSharpAstTransformer.ts | 48 +++++++++++++-------- 1 file changed, 31 insertions(+), 17 deletions(-) diff --git a/src.compiler/csharp/CSharpAstTransformer.ts b/src.compiler/csharp/CSharpAstTransformer.ts index 03f63e811..a1c06e800 100644 --- a/src.compiler/csharp/CSharpAstTransformer.ts +++ b/src.compiler/csharp/CSharpAstTransformer.ts @@ -14,10 +14,9 @@ export default class CSharpAstTransformer { protected _testMethodAttribute: string = 'microsoft.visualStudio.testTools.unitTesting.TestMethod'; public get extension(): string { - return '.cs' + return '.cs'; } - public constructor(typeScript: ts.SourceFile, context: CSharpEmitterContext) { this._typeScriptFile = typeScript; this._context = context; @@ -143,11 +142,27 @@ export default class CSharpAstTransformer { globalExports.forEach(x => { if (!x.name && x.exportClause) { if (ts.isNamespaceExport(x.exportClause)) { - this._context.addTsNodeDiagnostics( - x.exportClause, - 'Namespace exports are not yet supported', - ts.DiagnosticCategory.Error - ); + if (!x.moduleSpecifier) { + this._context.addTsNodeDiagnostics( + x.exportClause, + 'Failed to export namespace, missing module specifier', + ts.DiagnosticCategory.Error + ); + } else { + const module = this._context.typeChecker.getSymbolAtLocation(x.moduleSpecifier); + if (!module) { + this._context.addTsNodeDiagnostics( + x.exportClause, + 'Failed to export namespace, cannot resolve module', + ts.DiagnosticCategory.Error + ); + } else { + const exports = this._context.typeChecker.getExportsOfModule(module); + for (const exp of exports) { + this._context.registerSymbolAsExported(exp); + } + } + } } else { x.exportClause.elements.forEach(e => { const symbol = this._context.typeChecker.getTypeAtLocation(e.name)?.symbol; @@ -1853,10 +1868,10 @@ export default class CSharpAstTransformer { this._context.registerSymbol(csMethod); } protected mapVisibility(node: ts.Node): cs.Visibility { - if(this._context.isInternal(node)) { + if (this._context.isInternal(node)) { return cs.Visibility.Internal; } - + if (node.modifiers) { for (const m of node.modifiers) { switch (m.kind) { @@ -1931,10 +1946,13 @@ export default class CSharpAstTransformer { block.statements.length > 0 && cs.isExpressionStatement(block.statements[0]) && cs.isInvocationExpression((block.statements[0] as cs.ExpressionStatement).expression) && - cs.isBaseLiteralExpression(((block.statements[0] as cs.ExpressionStatement).expression as cs.InvocationExpression).expression) + cs.isBaseLiteralExpression( + ((block.statements[0] as cs.ExpressionStatement).expression as cs.InvocationExpression).expression + ) ) { - csConstructor.baseConstructorArguments = ((block.statements[0] as cs.ExpressionStatement) - .expression as cs.InvocationExpression).arguments; + csConstructor.baseConstructorArguments = ( + (block.statements[0] as cs.ExpressionStatement).expression as cs.InvocationExpression + ).arguments; block.statements.shift(); } } @@ -2098,11 +2116,7 @@ export default class CSharpAstTransformer { } protected visitThisExpression(parent: cs.Node, expression: ts.ThisExpression) { - if ( - cs.isMemberAccessExpression(parent) && - parent.tsSymbol && - this._context.isStaticSymbol(parent.tsSymbol) - ) { + if (cs.isMemberAccessExpression(parent) && parent.tsSymbol && this._context.isStaticSymbol(parent.tsSymbol)) { const identifier = { parent: parent, tsNode: expression,