Skip to content

Commit

Permalink
Merge pull request #1009 from rvilarl/migration/vex
Browse files Browse the repository at this point in the history
Migration/vex
  • Loading branch information
0xfe authored Jun 26, 2021
2 parents 267e350 + ef50228 commit f305f6c
Show file tree
Hide file tree
Showing 45 changed files with 1,602 additions and 1,518 deletions.
2 changes: 1 addition & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module.exports = (grunt) => {
const BUILD_DIR = path.join(BASE_DIR, 'build');
const RELEASE_DIR = path.join(BASE_DIR, 'releases');
const REFERENCE_DIR = path.join(BASE_DIR, 'reference');
const MODULE_ENTRY = path.join(BASE_DIR, 'src/index.js');
const MODULE_ENTRY = path.join(BASE_DIR, 'src/index.ts');
const MODULE_ENTRY_TESTS = path.join(BASE_DIR, 'tests/run.js');
const TARGET_RAW = 'vexflow-debug.js';
const TARGET_MIN = 'vexflow-min.js';
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "vexflow",
"version": "3.0.9",
"description": "A JavaScript library for rendering music notation and guitar tablature",
"main": "src/index.js",
"main": "src/index.ts",
"repository": {
"type": "git",
"url": "https://github.com/0xfe/vexflow.git"
Expand Down
2 changes: 1 addition & 1 deletion src/accidental.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

import { RuntimeError, log } from './util';
import { Fraction } from './fraction';
import { Flow } from './tables';
import { Flow } from './flow';
import { Music } from './music';
import { Modifier } from './modifier';
import { Glyph } from './glyph';
Expand Down
2 changes: 1 addition & 1 deletion src/annotation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// See `tests/annotation_tests.js` for usage examples.

import { log } from './util';
import { Flow } from './tables';
import { Flow } from './flow';
import { Modifier } from './modifier';
import { TextFont } from './textfont';
import { FontInfo } from './types/common';
Expand Down
13 changes: 6 additions & 7 deletions src/articulation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,22 @@
//
// See `tests/articulation_tests.js` for usage examples.

import { RuntimeError, log } from './util';
import { Flow } from './tables';
import { RuntimeError, log, check } from './util';
import { Flow } from './flow';
import { Modifier } from './modifier';
import { Glyph } from './glyph';
import { Stem } from './stem';
import { Note } from './note';
import { StaveNote } from './stavenote';
import { ModifierContextState } from './modifiercontext';
import { check } from './common';
import { Builder } from './easyscore';
import { TabNote } from './tabnote';
import { GraceNote } from './gracenote';

export interface ArticulationStruct {
code: string;
aboveCode: string;
belowCode: string;
code?: string;
aboveCode?: string;
belowCode?: string;
between_lines: boolean;
}

Expand Down Expand Up @@ -269,7 +268,7 @@ export class Articulation extends Modifier {

const code =
(this.position === ABOVE ? this.articulation.aboveCode : this.articulation.belowCode) || this.articulation.code;
this.glyph = new Glyph(code, this.render_options.font_scale);
this.glyph = new Glyph(code ?? '', this.render_options.font_scale);

this.setWidth(check<number>(this.glyph.getMetrics().width));
}
Expand Down
2 changes: 1 addition & 1 deletion src/beam.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// This file implements `Beams` that span over a set of `StemmableNotes`.

import { RuntimeError } from './util';
import { Flow } from './tables';
import { Flow } from './flow';
import { Element } from './element';
import { Fraction } from './fraction';
import { Tuplet } from './tuplet';
Expand Down
2 changes: 1 addition & 1 deletion src/bend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// This file implements tablature bends.

import { RuntimeError } from './util';
import { Flow } from './tables';
import { Flow } from './flow';
import { Modifier } from './modifier';
import { ModifierContextState } from './modifiercontext';

Expand Down
5 changes: 2 additions & 3 deletions src/chordsymbol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@
// See `tests/chordsymbol_tests.js` for usage examples.

import { log } from './util';
import { Flow } from './tables';
import { Flow } from './flow';
import { Glyph } from './glyph';
import { TextFont } from './textfont';
import { Modifier } from './modifier';
import { FontInfo } from './types/common';
import { StemmableNote } from './stemmablenote';
import { Font } from './font';

export interface ChordSymbolBlock {
vAlign: boolean;
Expand Down Expand Up @@ -117,7 +116,7 @@ export class ChordSymbol extends Modifier {
}

static get engravingFontResolution(): number {
return (Flow.DEFAULT_FONT_STACK[0] as Font).getResolution();
return Flow.DEFAULT_FONT_STACK[0].getResolution();
}

static get spacingBetweenBlocks(): number {
Expand Down
17 changes: 0 additions & 17 deletions src/common.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { Registry } from './registry';
import { BoundingBox } from './boundingbox';
import { Font } from './font';
import { RenderContext } from './types/common';
import { Flow } from './tables';
import { Flow } from './flow';

/** Element attributes. */
export interface ElementAttributes {
Expand Down
167 changes: 83 additions & 84 deletions src/index.js → src/flow.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
// [VexFlow](http://vexflow.com) - Copyright (c) Mohit Muthanna 2010.

import { Vex } from './vex';
import { Flow } from './tables';
import { Element } from './element';
import { Fraction } from './fraction';
import { Renderer } from './renderer';
Expand Down Expand Up @@ -78,86 +74,89 @@ import { RepeatNote } from './repeatnote';
import { TextFont } from './textfont';
import { PetalumaScriptTextMetrics } from './fonts/petalumascript_textmetrics';
import { RobotoSlabTextMetrics } from './fonts/robotoslab_textmetrics';

import { Font, Fonts } from './font';
import { Tables } from './tables';

Vex.Flow = Flow;
Vex.Flow.Element = Element;
Vex.Flow.Fraction = Fraction;
Vex.Flow.Renderer = Renderer;
Vex.Flow.Formatter = Formatter;
Vex.Flow.Music = Music;
Vex.Flow.Glyph = Glyph;
Vex.Flow.Stave = Stave;
Vex.Flow.StaveNote = StaveNote;
Vex.Flow.StaveModifier = StaveModifier;
Vex.Flow.StaveTempo = StaveTempo;
Vex.Flow.Voice = Voice;
Vex.Flow.Accidental = Accidental;
Vex.Flow.Beam = Beam;
Vex.Flow.StaveTie = StaveTie;
Vex.Flow.TabStave = TabStave;
Vex.Flow.TabNote = TabNote;
Vex.Flow.Bend = Bend;
Vex.Flow.Vibrato = Vibrato;
Vex.Flow.VibratoBracket = VibratoBracket;
Vex.Flow.Note = Note;
Vex.Flow.ModifierContext = ModifierContext;
Vex.Flow.MultiMeasureRest = MultiMeasureRest;
Vex.Flow.TickContext = TickContext;
Vex.Flow.Articulation = Articulation;
Vex.Flow.Annotation = Annotation;
Vex.Flow.ChordSymbol = ChordSymbol;
Vex.Flow.Barline = Barline;
Vex.Flow.NoteHead = NoteHead;
Vex.Flow.StaveConnector = StaveConnector;
Vex.Flow.ClefNote = ClefNote;
Vex.Flow.KeySignature = KeySignature;
Vex.Flow.KeySigNote = KeySigNote;
Vex.Flow.TimeSignature = TimeSignature;
Vex.Flow.TimeSigNote = TimeSigNote;
Vex.Flow.Stem = Stem;
Vex.Flow.TabTie = TabTie;
Vex.Flow.Clef = Clef;
Vex.Flow.Dot = Dot;
Vex.Flow.Modifier = Modifier;
Vex.Flow.TabSlide = TabSlide;
Vex.Flow.Tuplet = Tuplet;
Vex.Flow.GraceNote = GraceNote;
Vex.Flow.GraceTabNote = GraceTabNote;
Vex.Flow.Tuning = Tuning;
Vex.Flow.KeyManager = KeyManager;
Vex.Flow.StaveHairpin = StaveHairpin;
Vex.Flow.BoundingBox = BoundingBox;
Vex.Flow.Stroke = Stroke;
Vex.Flow.TextNote = TextNote;
Vex.Flow.Curve = Curve;
Vex.Flow.TextDynamics = TextDynamics;
Vex.Flow.StaveLine = StaveLine;
Vex.Flow.Ornament = Ornament;
Vex.Flow.PedalMarking = PedalMarking;
Vex.Flow.TextBracket = TextBracket;
Vex.Flow.FretHandFinger = FretHandFinger;
Vex.Flow.Repetition = Repetition;
Vex.Flow.BarNote = BarNote;
Vex.Flow.GhostNote = GhostNote;
Vex.Flow.NoteSubGroup = NoteSubGroup;
Vex.Flow.GraceNoteGroup = GraceNoteGroup;
Vex.Flow.Tremolo = Tremolo;
Vex.Flow.StringNumber = StringNumber;
Vex.Flow.Crescendo = Crescendo;
Vex.Flow.Volta = Volta;
Vex.Flow.System = System;
Vex.Flow.Factory = Factory;
Vex.Flow.Parser = Parser;
Vex.Flow.EasyScore = EasyScore;
Vex.Flow.Registry = Registry;
Vex.Flow.StaveText = StaveText;
Vex.Flow.GlyphNote = GlyphNote;
Vex.Flow.RepeatNote = RepeatNote;
Vex.Flow.Font = Font;
Vex.Flow.Fonts = Fonts;
Vex.Flow.TextFont = TextFont;
Vex.Flow.PetalumaScriptTextMetrics = PetalumaScriptTextMetrics;
Vex.Flow.RobotoSlabTextMetrics = RobotoSlabTextMetrics;
export const Flow = {
...Tables,
Element: Element,
Fraction: Fraction,
Renderer: Renderer,
Formatter: Formatter,
Music: Music,
Glyph: Glyph,
Stave: Stave,
StaveNote: StaveNote,
StaveModifier: StaveModifier,
StaveTempo: StaveTempo,
Voice: Voice,
Accidental: Accidental,
Beam: Beam,
StaveTie: StaveTie,
TabStave: TabStave,
TabNote: TabNote,
Bend: Bend,
Vibrato: Vibrato,
VibratoBracket: VibratoBracket,
Note: Note,
ModifierContext: ModifierContext,
MultiMeasureRest: MultiMeasureRest,
TickContext: TickContext,
Articulation: Articulation,
Annotation: Annotation,
ChordSymbol: ChordSymbol,
Barline: Barline,
NoteHead: NoteHead,
StaveConnector: StaveConnector,
ClefNote: ClefNote,
KeySignature: KeySignature,
KeySigNote: KeySigNote,
TimeSignature: TimeSignature,
TimeSigNote: TimeSigNote,
Stem: Stem,
TabTie: TabTie,
Clef: Clef,
Dot: Dot,
Modifier: Modifier,
TabSlide: TabSlide,
Tuplet: Tuplet,
GraceNote: GraceNote,
GraceTabNote: GraceTabNote,
Tuning: Tuning,
KeyManager: KeyManager,
StaveHairpin: StaveHairpin,
BoundingBox: BoundingBox,
Stroke: Stroke,
TextNote: TextNote,
Curve: Curve,
TextDynamics: TextDynamics,
StaveLine: StaveLine,
Ornament: Ornament,
PedalMarking: PedalMarking,
TextBracket: TextBracket,
FretHandFinger: FretHandFinger,
Repetition: Repetition,
BarNote: BarNote,
GhostNote: GhostNote,
NoteSubGroup: NoteSubGroup,
GraceNoteGroup: GraceNoteGroup,
Tremolo: Tremolo,
StringNumber: StringNumber,
Crescendo: Crescendo,
Volta: Volta,
System: System,
Factory: Factory,
Parser: Parser,
EasyScore: EasyScore,
Registry: Registry,
StaveText: StaveText,
GlyphNote: GlyphNote,
RepeatNote: RepeatNote,

export default Vex;
Font: Font,
Fonts: Fonts,
TextFont: TextFont,
PetalumaScriptTextMetrics: PetalumaScriptTextMetrics,
RobotoSlabTextMetrics: RobotoSlabTextMetrics,
};
5 changes: 2 additions & 3 deletions src/formatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
// See `tests/formatter_tests.js` for usage examples. The helper functions included
// here (`FormatAndDraw`, `FormatAndDrawTab`) also serve as useful usage examples.

import { RuntimeError, midLine, log } from './util';
import { RuntimeError, midLine, log, check } from './util';
import { Beam } from './beam';
import { Flow } from './tables';
import { Flow } from './flow';
import { Fraction } from './fraction';
import { Voice } from './voice';
import { StaveConnector } from './staveconnector';
Expand All @@ -34,7 +34,6 @@ import { TabStave } from './tabstave';
import { TabNote } from './tabnote';
import { BoundingBox } from './boundingbox';
import { StaveNote } from './stavenote';
import { check } from './common';

interface Distance {
maxNegativeShiftPx: number;
Expand Down
2 changes: 1 addition & 1 deletion src/glyph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { Font, FontGlyph } from './font';
import { RenderContext, TypeProps } from './types/common';
import { Stave } from './stave';
import { Stem } from './stem';
import { Flow } from './tables';
import { Flow } from './flow';

export interface DurationCode {
common: TypeProps;
Expand Down
2 changes: 1 addition & 1 deletion src/gracenote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { RuntimeError } from './util';
import { StaveNote, StaveNoteStruct } from './stavenote';
import { Stem } from './stem';
import { Flow } from './tables';
import { Flow } from './flow';

export interface GraceNoteStruct extends StaveNoteStruct {
slash: boolean;
Expand Down
2 changes: 1 addition & 1 deletion src/gracenotegroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// render grace notes.

import { log } from './util';
import { Flow } from './tables';
import { Flow } from './flow';
import { Modifier } from './modifier';
import { Formatter } from './formatter';
import { Voice } from './voice';
Expand Down
5 changes: 5 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// [VexFlow](http://vexflow.com) - Copyright (c) Mohit Muthanna 2010.

import { Vex } from './vex';

export default Vex;
2 changes: 1 addition & 1 deletion src/keysignature.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// and indicates the notes with implicit accidentals.

import { RuntimeError } from './util';
import { Flow } from './tables';
import { Flow } from './flow';
import { StaveModifier } from './stavemodifier';
import { Glyph } from './glyph';

Expand Down
2 changes: 1 addition & 1 deletion src/multimeasurerest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// This class implements multiple measure rests

import { RuntimeError } from './util';
import { Flow } from './tables';
import { Flow } from './flow';
import { Element } from './element';
import { Glyph } from './glyph';
import { NoteHead } from './notehead';
Expand Down
Loading

0 comments on commit f305f6c

Please sign in to comment.