tja-parser 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/class/Bar.d.ts +12 -5
- package/dist/class/Bar.d.ts.map +1 -1
- package/dist/class/Bar.js +60 -10
- package/dist/class/Bar.js.map +1 -1
- package/dist/class/BarLine.d.ts +14 -0
- package/dist/class/BarLine.d.ts.map +1 -0
- package/dist/class/BarLine.js +26 -0
- package/dist/class/BarLine.js.map +1 -0
- package/dist/class/Branch.d.ts +3 -4
- package/dist/class/Branch.d.ts.map +1 -1
- package/dist/class/Branch.js +5 -4
- package/dist/class/Branch.js.map +1 -1
- package/dist/class/Course.d.ts +5 -5
- package/dist/class/Course.d.ts.map +1 -1
- package/dist/class/Course.js +50 -31
- package/dist/class/Course.js.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/format.mediawiki +714 -714
- package/package.json +1 -1
- package/src/class/Bar.ts +85 -67
- package/src/class/Branch.ts +33 -33
- package/src/class/Command.ts +138 -138
- package/src/class/Course.ts +436 -418
- package/src/class/Item.ts +26 -26
- package/src/class/Note.ts +171 -171
- package/src/class/Song.ts +87 -87
- package/src/exception/ParseException.ts +12 -12
- package/src/index.ts +11 -12
- package/tsconfig.json +22 -22
- package/dist/class/NoteGroup.d.ts +0 -11
- package/dist/class/NoteGroup.d.ts.map +0 -1
- package/dist/class/NoteGroup.js +0 -59
- package/dist/class/NoteGroup.js.map +0 -1
- package/src/class/NoteGroup.ts +0 -24
package/package.json
CHANGED
package/src/class/Bar.ts
CHANGED
|
@@ -1,68 +1,86 @@
|
|
|
1
|
-
import { Command } from "./Command.js";
|
|
2
|
-
import { Item } from "./Item.js";
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
export class Bar
|
|
7
|
-
private items: Item[] = [];
|
|
8
|
-
private notes: Note[] = [];
|
|
9
|
-
private commands: Command[] = [];
|
|
10
|
-
|
|
11
|
-
private
|
|
12
|
-
private
|
|
13
|
-
private
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
this.
|
|
18
|
-
this.
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
return Array.from(this.
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
1
|
+
import { Command } from "./Command.js";
|
|
2
|
+
import { Item } from "./Item.js";
|
|
3
|
+
import * as math from 'mathjs';
|
|
4
|
+
import { Note } from "./Note.js";
|
|
5
|
+
|
|
6
|
+
export class Bar {
|
|
7
|
+
private items: Item[] = [];
|
|
8
|
+
private notes: Note[] = [];
|
|
9
|
+
private commands: Command[] = [];
|
|
10
|
+
private start: math.Fraction;
|
|
11
|
+
private end: math.Fraction;
|
|
12
|
+
private measure = math.fraction(1);
|
|
13
|
+
private barlineHidden = false;
|
|
14
|
+
private bpm: number = 160;
|
|
15
|
+
private scroll: number = 1;
|
|
16
|
+
constructor(start: math.Fraction, end: math.Fraction) {
|
|
17
|
+
this.start = start;
|
|
18
|
+
this.end = end;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
pushItem(...items: Item[]) {
|
|
22
|
+
this.items.push(...items);
|
|
23
|
+
this.notes.push(...items.filter((item) => item instanceof Note));
|
|
24
|
+
this.commands.push(...items.filter((item) => item instanceof Command));
|
|
25
|
+
}
|
|
26
|
+
getItems() {
|
|
27
|
+
return Array.from(this.items);
|
|
28
|
+
}
|
|
29
|
+
getNotes() {
|
|
30
|
+
return Array.from(this.notes);
|
|
31
|
+
}
|
|
32
|
+
getCommands() {
|
|
33
|
+
return Array.from(this.commands);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
setMeasure(measure: math.Fraction) {
|
|
37
|
+
this.measure = measure;
|
|
38
|
+
}
|
|
39
|
+
getMeasure() {
|
|
40
|
+
return this.measure;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
getStart() {
|
|
44
|
+
return math.fraction(this.start);
|
|
45
|
+
}
|
|
46
|
+
setStart(start: math.Fraction) {
|
|
47
|
+
this.start = math.fraction(start);
|
|
48
|
+
}
|
|
49
|
+
getEnd() {
|
|
50
|
+
return math.fraction(this.end);
|
|
51
|
+
}
|
|
52
|
+
setEnd(end: math.Fraction) {
|
|
53
|
+
this.end = math.fraction(end);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
getBarlineHidden() {
|
|
57
|
+
return this.barlineHidden;
|
|
58
|
+
}
|
|
59
|
+
setBarlineHidden(barlineHidden: boolean) {
|
|
60
|
+
this.barlineHidden = barlineHidden;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
setBpm(bpm: number) {
|
|
64
|
+
this.bpm = bpm;
|
|
65
|
+
}
|
|
66
|
+
getBpm() {
|
|
67
|
+
return this.bpm;
|
|
68
|
+
}
|
|
69
|
+
setScroll(scroll: number) {
|
|
70
|
+
this.scroll = scroll;
|
|
71
|
+
}
|
|
72
|
+
getScroll() {
|
|
73
|
+
return this.scroll;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
toJSON(): any {
|
|
77
|
+
return {
|
|
78
|
+
start: this.start.valueOf(),
|
|
79
|
+
end: this.end.valueOf(),
|
|
80
|
+
items: this.items,
|
|
81
|
+
notes: this.notes,
|
|
82
|
+
commands: this.commands,
|
|
83
|
+
type: 'bar'
|
|
84
|
+
}
|
|
85
|
+
}
|
|
68
86
|
}
|
package/src/class/Branch.ts
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
import * as math from 'mathjs';
|
|
2
|
-
import { Bar } from './Bar.js';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
this.
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
return {
|
|
20
|
-
start:
|
|
21
|
-
end:
|
|
22
|
-
normal: this.normal,
|
|
23
|
-
advanced: this.advanced,
|
|
24
|
-
master: this.master,
|
|
25
|
-
criteria: this.criteria,
|
|
26
|
-
type: 'branch',
|
|
27
|
-
branchType: this.type === Branch.Type.ROLL ? 'roll' : 'acc'
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export namespace Branch {
|
|
33
|
-
export enum Type { ROLL, ACCURACY }
|
|
1
|
+
import * as math from 'mathjs';
|
|
2
|
+
import { Bar } from './Bar.js';
|
|
3
|
+
|
|
4
|
+
export class Branch extends Bar {
|
|
5
|
+
type: Branch.Type;
|
|
6
|
+
criteria: [number, number];
|
|
7
|
+
normal?: Bar[];
|
|
8
|
+
advanced?: Bar[];
|
|
9
|
+
master?: Bar[];
|
|
10
|
+
|
|
11
|
+
constructor(type: Branch.Type, criteria1: [number, number], start: math.Fraction, end: math.Fraction) {
|
|
12
|
+
super(start, end);
|
|
13
|
+
this.type = type;
|
|
14
|
+
this.criteria = criteria1;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
toJSON(){
|
|
18
|
+
const superJSON = super.toJSON();
|
|
19
|
+
return {
|
|
20
|
+
start: superJSON.start,
|
|
21
|
+
end: superJSON.end,
|
|
22
|
+
normal: this.normal,
|
|
23
|
+
advanced: this.advanced,
|
|
24
|
+
master: this.master,
|
|
25
|
+
criteria: this.criteria,
|
|
26
|
+
type: 'branch',
|
|
27
|
+
branchType: this.type === Branch.Type.ROLL ? 'roll' : 'acc'
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export namespace Branch {
|
|
33
|
+
export enum Type { ROLL, ACCURACY }
|
|
34
34
|
}
|
package/src/class/Command.ts
CHANGED
|
@@ -1,139 +1,139 @@
|
|
|
1
|
-
import { Item } from "./Item.js";
|
|
2
|
-
import * as math from 'mathjs';
|
|
3
|
-
|
|
4
|
-
export class Command extends Item {
|
|
5
|
-
static parse(line: string): Command | null {
|
|
6
|
-
if (line === '#BARLINEON') {
|
|
7
|
-
return new BarlineCommand(false, math.fraction(0));
|
|
8
|
-
}
|
|
9
|
-
else if (line === "#BARLINEOFF") {
|
|
10
|
-
return new BarlineCommand(true, math.fraction(0));
|
|
11
|
-
}
|
|
12
|
-
else if (line === "#GOGOSTART") {
|
|
13
|
-
return new GOGOCommand(GOGOCommand.Type.START, math.fraction(0));
|
|
14
|
-
}
|
|
15
|
-
else if (line === "#GOGOEND") {
|
|
16
|
-
return new GOGOCommand(GOGOCommand.Type.END, math.fraction(0));
|
|
17
|
-
}
|
|
18
|
-
else if (line === "#SECTION") {
|
|
19
|
-
return new SectionCommand(math.fraction(0));
|
|
20
|
-
}
|
|
21
|
-
else if (line.startsWith('#BPMCHANGE')) {
|
|
22
|
-
const value = Number(line.replace('#BPMCHANGE', ''));
|
|
23
|
-
if (Number.isNaN(value)) return null;
|
|
24
|
-
return new BPMChangeCommand(value, math.fraction(0));
|
|
25
|
-
}
|
|
26
|
-
else if (line.startsWith('#MEASURE')) {
|
|
27
|
-
return new MeasureCommand(math.fraction(line.replace('#MEASURE', '').trim()), math.fraction(0));
|
|
28
|
-
}
|
|
29
|
-
else if (line.startsWith('#SCROLL')) {
|
|
30
|
-
const value = Number(line.replace('#SCROLL', ''));
|
|
31
|
-
if (Number.isNaN(value)) return null;
|
|
32
|
-
return new ScrollCommand(value, math.fraction(0));
|
|
33
|
-
}
|
|
34
|
-
return null;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
constructor(timing: math.Fraction) {
|
|
38
|
-
super(timing);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export class BarlineCommand extends Command {
|
|
43
|
-
private hide: boolean;
|
|
44
|
-
constructor(hide: boolean, timing: math.Fraction) {
|
|
45
|
-
super(timing);
|
|
46
|
-
this.hide = hide;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
getHide(){
|
|
50
|
-
return this.hide;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
toJSON(){
|
|
54
|
-
return {
|
|
55
|
-
...super.toJSON(),
|
|
56
|
-
type: 'command-barline',
|
|
57
|
-
hide: this.hide
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export class BPMChangeCommand extends Command {
|
|
63
|
-
value: number;
|
|
64
|
-
constructor(value: number, timing: math.Fraction) {
|
|
65
|
-
super(timing);
|
|
66
|
-
this.value = value;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
toJSON(){
|
|
70
|
-
return {
|
|
71
|
-
...super.toJSON(),
|
|
72
|
-
type: 'command-bpmchange',
|
|
73
|
-
value: this.value
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export class MeasureCommand extends Command {
|
|
79
|
-
value: math.Fraction;
|
|
80
|
-
constructor(value: math.Fraction, timing: math.Fraction) {
|
|
81
|
-
super(timing);
|
|
82
|
-
this.value = value;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
toJSON(){
|
|
86
|
-
return {
|
|
87
|
-
...super.toJSON(),
|
|
88
|
-
type: 'command-measure',
|
|
89
|
-
value: this.value.toString()
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
export class ScrollCommand extends Command {
|
|
95
|
-
value: number;
|
|
96
|
-
constructor(value: number, timing: math.Fraction) {
|
|
97
|
-
super(timing);
|
|
98
|
-
this.value = value;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
toJSON(){
|
|
102
|
-
return {
|
|
103
|
-
...super.toJSON(),
|
|
104
|
-
type: 'command-scroll',
|
|
105
|
-
value: this.value
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
export class SectionCommand extends Command {
|
|
111
|
-
toJSON() {
|
|
112
|
-
return {
|
|
113
|
-
...super.toJSON(),
|
|
114
|
-
type: 'command-section'
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
export class GOGOCommand extends Command {
|
|
120
|
-
type: GOGOCommand.Type;
|
|
121
|
-
constructor(type: GOGOCommand.Type, timing: math.Fraction) {
|
|
122
|
-
super(timing);
|
|
123
|
-
this.type = type;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
toJSON(){
|
|
127
|
-
return {
|
|
128
|
-
...super.toJSON(),
|
|
129
|
-
type: 'command-gogo',
|
|
130
|
-
start: this.type === GOGOCommand.Type.START
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
export namespace GOGOCommand {
|
|
135
|
-
export enum Type {
|
|
136
|
-
START,
|
|
137
|
-
END
|
|
138
|
-
}
|
|
1
|
+
import { Item } from "./Item.js";
|
|
2
|
+
import * as math from 'mathjs';
|
|
3
|
+
|
|
4
|
+
export class Command extends Item {
|
|
5
|
+
static parse(line: string): Command | null {
|
|
6
|
+
if (line === '#BARLINEON') {
|
|
7
|
+
return new BarlineCommand(false, math.fraction(0));
|
|
8
|
+
}
|
|
9
|
+
else if (line === "#BARLINEOFF") {
|
|
10
|
+
return new BarlineCommand(true, math.fraction(0));
|
|
11
|
+
}
|
|
12
|
+
else if (line === "#GOGOSTART") {
|
|
13
|
+
return new GOGOCommand(GOGOCommand.Type.START, math.fraction(0));
|
|
14
|
+
}
|
|
15
|
+
else if (line === "#GOGOEND") {
|
|
16
|
+
return new GOGOCommand(GOGOCommand.Type.END, math.fraction(0));
|
|
17
|
+
}
|
|
18
|
+
else if (line === "#SECTION") {
|
|
19
|
+
return new SectionCommand(math.fraction(0));
|
|
20
|
+
}
|
|
21
|
+
else if (line.startsWith('#BPMCHANGE')) {
|
|
22
|
+
const value = Number(line.replace('#BPMCHANGE', ''));
|
|
23
|
+
if (Number.isNaN(value)) return null;
|
|
24
|
+
return new BPMChangeCommand(value, math.fraction(0));
|
|
25
|
+
}
|
|
26
|
+
else if (line.startsWith('#MEASURE')) {
|
|
27
|
+
return new MeasureCommand(math.fraction(line.replace('#MEASURE', '').trim()), math.fraction(0));
|
|
28
|
+
}
|
|
29
|
+
else if (line.startsWith('#SCROLL')) {
|
|
30
|
+
const value = Number(line.replace('#SCROLL', ''));
|
|
31
|
+
if (Number.isNaN(value)) return null;
|
|
32
|
+
return new ScrollCommand(value, math.fraction(0));
|
|
33
|
+
}
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
constructor(timing: math.Fraction) {
|
|
38
|
+
super(timing);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export class BarlineCommand extends Command {
|
|
43
|
+
private hide: boolean;
|
|
44
|
+
constructor(hide: boolean, timing: math.Fraction) {
|
|
45
|
+
super(timing);
|
|
46
|
+
this.hide = hide;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
getHide(){
|
|
50
|
+
return this.hide;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
toJSON(){
|
|
54
|
+
return {
|
|
55
|
+
...super.toJSON(),
|
|
56
|
+
type: 'command-barline',
|
|
57
|
+
hide: this.hide
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export class BPMChangeCommand extends Command {
|
|
63
|
+
value: number;
|
|
64
|
+
constructor(value: number, timing: math.Fraction) {
|
|
65
|
+
super(timing);
|
|
66
|
+
this.value = value;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
toJSON(){
|
|
70
|
+
return {
|
|
71
|
+
...super.toJSON(),
|
|
72
|
+
type: 'command-bpmchange',
|
|
73
|
+
value: this.value
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export class MeasureCommand extends Command {
|
|
79
|
+
value: math.Fraction;
|
|
80
|
+
constructor(value: math.Fraction, timing: math.Fraction) {
|
|
81
|
+
super(timing);
|
|
82
|
+
this.value = value;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
toJSON(){
|
|
86
|
+
return {
|
|
87
|
+
...super.toJSON(),
|
|
88
|
+
type: 'command-measure',
|
|
89
|
+
value: this.value.toString()
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export class ScrollCommand extends Command {
|
|
95
|
+
value: number;
|
|
96
|
+
constructor(value: number, timing: math.Fraction) {
|
|
97
|
+
super(timing);
|
|
98
|
+
this.value = value;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
toJSON(){
|
|
102
|
+
return {
|
|
103
|
+
...super.toJSON(),
|
|
104
|
+
type: 'command-scroll',
|
|
105
|
+
value: this.value
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export class SectionCommand extends Command {
|
|
111
|
+
toJSON() {
|
|
112
|
+
return {
|
|
113
|
+
...super.toJSON(),
|
|
114
|
+
type: 'command-section'
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export class GOGOCommand extends Command {
|
|
120
|
+
type: GOGOCommand.Type;
|
|
121
|
+
constructor(type: GOGOCommand.Type, timing: math.Fraction) {
|
|
122
|
+
super(timing);
|
|
123
|
+
this.type = type;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
toJSON(){
|
|
127
|
+
return {
|
|
128
|
+
...super.toJSON(),
|
|
129
|
+
type: 'command-gogo',
|
|
130
|
+
start: this.type === GOGOCommand.Type.START
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
export namespace GOGOCommand {
|
|
135
|
+
export enum Type {
|
|
136
|
+
START,
|
|
137
|
+
END
|
|
138
|
+
}
|
|
139
139
|
}
|