You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

simai.js

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

simai.js - npm Package Compare versions

Comparing version

to
1.0.9

60

dist/index.d.ts

@@ -7,22 +7,2 @@ declare enum EachStyle {

declare enum NoteGroup {
Tap = 0,
ASensor = 1,
BSensor = 2,
CSensor = 3,
DSensor = 4,
ESensor = 5
}
declare class Location {
/**
* Describes which button / sensor in the <see cref="group" /> this element is pointing to.
*/
index: number;
group: NoteGroup;
constructor(index: number, noteGroup: NoteGroup);
equals(other: Location): boolean;
toString(): string;
}
declare enum NoteAppearance {

@@ -44,11 +24,2 @@ Default = 0,

declare enum NoteType {
Tap = 0,
Touch = 1,
Hold = 2,
Slide = 3,
Break = 4,
ForceInvalidate = 5
}
declare enum SlideMorph {

@@ -74,2 +45,22 @@ FadeIn = 0,

declare enum NoteGroup {
Tap = 0,
ASensor = 1,
BSensor = 2,
CSensor = 3,
DSensor = 4,
ESensor = 5
}
declare class Location {
/**
* Describes which button / sensor in the {@link group} this element is pointing to.
*/
index: number;
group: NoteGroup;
constructor(index: number, noteGroup: NoteGroup);
equals(other: Location): boolean;
toString(): string;
}
declare class SlideSegment {

@@ -84,2 +75,11 @@ /**

declare enum NoteType {
Tap = 0,
Touch = 1,
Hold = 2,
Slide = 3,
Break = 4,
ForceInvalidate = 5
}
declare class SlidePath {

@@ -131,3 +131,3 @@ startLocation: Location;

constructor(data: string);
toKeyValuePairs(): Map<string, string>;
toKeyValuePairs(): ReadonlyMap<string, string>;
getValue(key: string): string;

@@ -134,0 +134,0 @@ }

@@ -1,6 +0,5 @@

"use strict";var U=Object.defineProperty;var G=Object.getOwnPropertyDescriptor;var Q=Object.getOwnPropertyNames;var X=Object.prototype.hasOwnProperty;var Y=(a,e)=>{for(var r in e)U(a,r,{get:e[r],enumerable:!0})},ee=(a,e,r,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Q(e))!X.call(a,n)&&n!==r&&U(a,n,{get:()=>e[n],enumerable:!(t=G(e,n))||t.enumerable});return a};var re=a=>ee(U({},"__esModule",{value:!0}),a);var te={};Y(te,{EachStyle:()=>E,Location:()=>p,MaiChart:()=>b,Note:()=>v,NoteAppearance:()=>_,NoteCollection:()=>C,NoteGroup:()=>w,NoteStyles:()=>T,NoteType:()=>x,SimaiConvert:()=>V,SimaiFile:()=>z,SlideMorph:()=>L,SlidePath:()=>F,SlideSegment:()=>N,SlideType:()=>S});module.exports=re(te);var h=class extends Error{constructor(r,t,n){super(n);this.name="SimaiException",this.character=t,this.line=r}};var u=class extends h{constructor(r,t,n,o){super(r,t,o);this.name="UnexpectedCharacterException",this.expected=n}};var m=class extends h{constructor(e,r,t){super(e,r,t),this.name="UnsupportedSyntaxException"}};var y=class extends h{constructor(e,r,t){super(e,r,t),this.name="UnterminatedSectionException"}};var k=class{constructor(e,r,t,n){this.type=e,this.lexeme=r,this.line=t,this.character=n}};var I=class a{constructor(e){this.space=String.fromCharCode(32);this.enSpace=String.fromCharCode(8194);this.punctuationSpace=String.fromCharCode(8200);this.ideographicSpace=String.fromCharCode(12288);this.lineSeparator=String.fromCharCode(8232);this.paragraphSeparator=String.fromCharCode(8233);this.endOfFileChar="E";this.eachDividerChars=new Set(["/","`"]);this.decoratorChars=new Set(["f","b","x","h","m","!","?","@","$"]);this.slideChars=new Set(["-",">","<","^","p","q","v","V","s","z","w"]);this.separatorChars=new Set(["\r"," ",this.lineSeparator,this.paragraphSeparator,this.space,this.enSpace,this.punctuationSpace,this.ideographicSpace]);this._current=0;this._charIndex=0;this._line=1;this._start=0;this._sequence=e}get isAtEnd(){return this._current>=this._sequence.length}*getTokens(){for(;!this.isAtEnd;){this._start=this._current;let e=this.scanToken();e!==void 0&&(yield e)}}scanToken(){this._charIndex++;let e=this.advance();if(this.decoratorChars.has(e))return this.compileToken(4);if(this.eachDividerChars.has(e))return this.compileToken(9);if(this.separatorChars.has(e))return;let[r,t]=this.tryScanLocationToken();if(r)return this._current+=t-1,this.compileToken(3);let[n,o]=this.isReadingSlideDeclaration();if(n)return this._current+=o-1,this.compileToken(5);switch(e){case",":return this.compileToken(8);case"(":return this.compileSectionToken(1,"(",")");case"{":return this.compileSectionToken(2,"{","}");case"[":return this.compileSectionToken(6,"[","]");case"*":return this.compileToken(7);case`
"use strict";var U=Object.defineProperty;var G=Object.getOwnPropertyDescriptor;var Q=Object.getOwnPropertyNames;var X=Object.prototype.hasOwnProperty;var Y=(a,e)=>{for(var r in e)U(a,r,{get:e[r],enumerable:!0})},ee=(a,e,r,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Q(e))!X.call(a,n)&&n!==r&&U(a,n,{get:()=>e[n],enumerable:!(t=G(e,n))||t.enumerable});return a};var re=a=>ee(U({},"__esModule",{value:!0}),a);var te={};Y(te,{EachStyle:()=>N,Location:()=>d,MaiChart:()=>w,Note:()=>S,NoteAppearance:()=>_,NoteCollection:()=>b,NoteGroup:()=>E,NoteStyles:()=>T,NoteType:()=>x,SimaiConvert:()=>V,SimaiFile:()=>z,SlideMorph:()=>y,SlidePath:()=>F,SlideSegment:()=>D,SlideType:()=>C});module.exports=re(te);var p=class extends Error{constructor(r,t,n){super(n);this.name="SimaiException",this.character=t,this.line=r}};var h=class extends p{constructor(r,t,n,o){super(r,t,o);this.name="ScopeMismatchException",this.correctScope=n}};var m=class extends p{constructor(e,r,t){super(e,r,t),this.name="UnsupportedSyntaxException"}};var N=(t=>(t[t.Default=0]="Default",t[t.ForceBroken=1]="ForceBroken",t[t.ForceEach=2]="ForceEach",t))(N||{});var b=class extends Array{constructor(r){super();this.eachStyle=0;this.time=r}addNote(r){r.parentCollection=this,this.push(r)}};var u=class extends p{constructor(r,t,n,o){super(r,t,o);this.name="UnexpectedCharacterException",this.expected=n}};var L=class{static process(e,r){if(r.lexeme[0]==="#"){let n=parseFloat(r.lexeme.slice(1));if(isNaN(n))throw new u(r.line,r.character+1,'0~9, or "."');e.currentTiming.explicitOverride(n);return}let t=parseFloat(r.lexeme);if(isNaN(t))throw new u(r.line,r.character,'0~9, or "."');e.currentTiming.subdivisions=t}};var E=(i=>(i[i.Tap=0]="Tap",i[i.ASensor=1]="ASensor",i[i.BSensor=2]="BSensor",i[i.CSensor=3]="CSensor",i[i.DSensor=4]="DSensor",i[i.ESensor=5]="ESensor",i))(E||{});var C=(s=>(s[s.StraightLine=0]="StraightLine",s[s.RingCw=1]="RingCw",s[s.RingCcw=2]="RingCcw",s[s.Fold=3]="Fold",s[s.CurveCw=4]="CurveCw",s[s.CurveCcw=5]="CurveCcw",s[s.ZigZagS=6]="ZigZagS",s[s.ZigZagZ=7]="ZigZagZ",s[s.EdgeFold=8]="EdgeFold",s[s.EdgeCurveCw=9]="EdgeCurveCw",s[s.EdgeCurveCcw=10]="EdgeCurveCcw",s[s.Fan=11]="Fan",s))(C||{});var d=class{constructor(e,r){this.index=e,this.group=r}equals(e){return this.index===e.index&&this.group===e.group}toString(){return`index: ${this.index}, group: ${this.group.toString()}`}};var w=class{constructor(){this.noteCollections=[]}};var k=class{static process(e,r){let t=parseFloat(r.lexeme);if(isNaN(t))throw new u(r.line,r.character,'0~9, or "."');e.currentTiming.tempo=t}};var I=class extends p{constructor(e,r,t){super(e,r,t),this.name="InvalidSyntaxException"}};var _=(n=>(n[n.Default=0]="Default",n[n.ForceNormal=1]="ForceNormal",n[n.ForceStar=2]="ForceStar",n[n.ForceStarSpinning=3]="ForceStarSpinning",n))(_||{});var T=(i=>(i[i.None=0]="None",i[i.Ex=1]="Ex",i[i.Star=2]="Star",i[i.StarPower=4]="StarPower",i[i.Fireworks=5]="Fireworks",i[i.Mine=6]="Mine",i))(T||{});var y=(r=>(r[r.FadeIn=0]="FadeIn",r[r.SuddenIn=1]="SuddenIn",r))(y||{});var x=(i=>(i[i.Tap=0]="Tap",i[i.Touch=1]="Touch",i[i.Hold=2]="Hold",i[i.Slide=3]="Slide",i[i.Break=4]="Break",i[i.ForceInvalidate=5]="ForceInvalidate",i))(x||{});var S=class{constructor(e){this.location=new d(0,0);this.styles=0;this.appearance=0;this.type=0;this.slideMorph=0;this.slidePaths=[];this.parentCollection=e}get isEx(){return(this.styles&1)!=0}get isStar(){return this.appearance>=2||this.slidePaths.length>0&&this.appearance!==1}getVisibleDuration(){var r;var e=(r=this.length)!=null?r:0;return this.slidePaths.length>0&&(e=Math.max(...this.slidePaths.map(t=>t.delay+t.duration))),e}};var v=class{get secondsPerBar(){return this.tempo===0?0:60/this.tempo}get secondsPerBeat(){return this.secondsPerBar/((this.subdivisions===0?4:this.subdivisions)/4)}constructor(e,r=4){this.tempo=e,this.subdivisions=r}explicitOverride(e){this.tempo=60/e,this.subdivisions=4}};var D=class{constructor(e){this.vertices=e!=null?e:[],this.slideType=0}};var F=class{constructor(e){this.startLocation=new d(0,0);this.delay=0;this.duration=0;this.type=3;this.segments=e}};var O=class a{static process(e,r,t,n){let o=new F([]);o.delay=n.secondsPerBeat,a.readSegment(e,t,r.location,o);let i=!0;for(;!e.endOfFile&&(i||e.moveNext());){var c=e.enumerator.current;switch(i=!1,c.type){case 1:case 2:throw new h(c.line,c.character,4);case 4:{a.decorateSlide(c,o);break}case 5:{let l=o.segments[o.segments.length-1];a.readSegment(e,c,l.vertices[l.vertices.length-1],o),i=!0;break}case 6:{a.readDuration(c,e.currentTiming,o);break}case 7:return e.moveNext(),o;case 8:case 9:case 10:case 3:return o;case 0:break;default:throw new m(c.line,c.character)}}return o}static readSegment(e,r,t,n){let o=new D([]),i=r.lexeme.length;a.assignVertices(e,r,o),o.slideType=a.identifySlideType(r,t,o,i),n.segments.push(o)}static decorateSlide(e,r){switch(e.lexeme[0]){case"b":r.type=4;return;default:throw new m(e.line,e.character)}}static identifySlideType(e,r,t,n){switch(e.lexeme[0]){case"-":return 0;case">":return f.determineRingType(r,t.vertices[0],1);case"<":return f.determineRingType(r,t.vertices[0],-1);case"^":return f.determineRingType(r,t.vertices[0]);case"q":return n===2&&e.lexeme[1]==="q"?9:4;case"p":return n===2&&e.lexeme[1]==="p"?10:5;case"v":return 3;case"V":return 8;case"s":return 6;case"z":return 7;case"w":return 11;default:throw new m(e.line,e.character)}}static assignVertices(e,r,t){do{if(!e.moveNext())throw new m(r.line,r.character);let n=e.enumerator.current,[o,i]=f.tryReadLocation(n);o&&t.vertices.push(i)}while(e.enumerator.current.type===3)}static readDuration(e,r,t){let o=r,i=e.lexeme.indexOf("#");if(i>-1){let K=e.lexeme.lastIndexOf("#")+1-1,W=e.lexeme.substring(0,i),j=i!==K,q=parseFloat(W);if(isNaN(q))throw new u(e.line,e.character,'0~9, or "."');j?t.delay=q:(o.tempo=q,t.delay=o.secondsPerBar)}let l=e.lexeme.substring(0),g=l.indexOf(":");if(g===-1){let s=parseFloat(l);if(isNaN(s))throw new u(e.line,e.character+0,'0~9, or "."');t.duration+=s;return}let H=parseFloat(l.substring(0,g));if(isNaN(H))throw new u(e.line,e.character+0,'0~9, or "."');let J=parseFloat(l.substring(g+1));if(isNaN(J))throw new m(e.line,e.character+0+g+1,'0~9, or "."');t.duration+=o.secondsPerBar/(H/4)*J}};var P=class a{static process(e,r){let[t,n]=f.tryReadLocation(r);if(!t)throw new I(r.line,r.character);let o=new S(e.currentNoteCollection);o.location=n;let i=new v(e.currentNoteCollection.time);n.group!==0&&(o.type=1);let c=!1;for(;!e.endOfFile&&(c||e.moveNext());){let l=e.enumerator.current;switch(c=!1,l.type){case 1:case 2:throw new h(l.line,l.character,4);case 4:{a.decorateNote(l,o);break}case 5:{o.type===2&&(o.length=i.secondsPerBeat);let g=O.process(e,o,l,i);c=!0,o.slidePaths.push(g);break}case 6:{a.readDuration(l,e.currentTiming,o);break}case 7:throw new h(l.line,l.character,2);case 8:case 9:case 10:case 3:return o;case 0:break;default:throw new m(l.line,l.character)}}return o}static decorateNote(e,r){var t;switch(e.lexeme[0]){case"f":r.styles|=5;return;case"b":if(r.type===5)break;r.type=4;return;case"x":r.styles|=1;return;case"m":r.styles|=6;return;case"h":if(r.type===4||r.type===5)break;r.type=2,(t=r.length)!=null||(r.length=0);return;case"?":r.type=5,r.slideMorph=0;return;case"!":r.type=5,r.slideMorph=1;return;case"@":r.appearance=1;return;case"$":r.appearance=r.appearance===2?3:2;return}}static readDuration(e,r,t){if(t.type!==4&&(t.type=2),e.lexeme[0]==="#"){let c=parseFloat(e.lexeme.slice(1));if(isNaN(c))throw new u(e.line,e.character+1,'0~9, or "."');t.length=c;return}let n=e.lexeme.indexOf(":"),o=parseFloat(e.lexeme.slice(0,n)),i=parseFloat(e.lexeme.slice(n+1));if(isNaN(o)||isNaN(i))throw new u(e.line,e.character+1,'0~9, or "."');t.length=r.secondsPerBar/(o/4)*i}};var R=class{constructor(e){this._source=e;this._index=-1;this._done=!1}get current(){return this._current}get index(){return this._index}get done(){return this._done}moveNext(){let e=this._source[Symbol.iterator](),{value:r,done:t}=e.next();return this._current=r,this._done=!!t,this._index++,!t}reset(){this._index=-1,this._done=!1,this._current=void 0}};var f=class{constructor(e){this._chart=new w;this._maxFinishTime=0;this._currentTime=0;this.currentTiming=new v(0,0);this.endOfFile=!1;this.enumerator=new R(e)}getChart(){var t,n,o;let e=[],r=!1;for(;!this.endOfFile&&(r||this.moveNext());){let i=this.enumerator.current;switch(r=!1,i.type){case 1:{k.process(this,i);break}case 2:{L.process(this,i);break}case 3:{if((t=this.currentNoteCollection)!=null||(this.currentNoteCollection=new b(this._currentTime)),i.lexeme[0]==="0"){this.currentNoteCollection.eachStyle!==1&&(this.currentNoteCollection.eachStyle=2);break}let c=P.process(this,i);this.currentNoteCollection.addNote(c),r=!0,this._maxFinishTime=Math.max(this._maxFinishTime,this.currentNoteCollection.time+c.getVisibleDuration());break}case 8:this.currentNoteCollection!=null&&(e.push(this.currentNoteCollection),this.currentNoteCollection=void 0),this._currentTime+=this.currentTiming.secondsPerBeat;break;case 9:switch(i.lexeme[0]){case"/":break;case"`":this.currentNoteCollection!=null&&(this.currentNoteCollection.eachStyle=1);break}break;case 4:throw new h(i.line,i.character,1);case 5:throw new h(i.line,i.character,1);case 6:throw new h(i.line,i.character,3);case 7:throw new h(i.line,i.character,2);case 10:this._chart.finishTiming=this._currentTime;break;case 0:break;default:throw new m(i.line,i.character)}}return(o=(n=this._chart).finishTiming)!=null||(n.finishTiming=this._maxFinishTime),this.currentNoteCollection!==void 0&&(e.push(this.currentNoteCollection),this.currentNoteCollection=void 0),this._chart.noteCollections=e,this._chart}static determineRingType(e,r,t=0){switch(t){case 1:return(e.index+2)%8>=4?2:1;case-1:return(e.index+2)%8>=4?1:2;default:var n=r.index-e.index,o=n>=0?n>4?-1:1:n<-4?1:-1;return o>0?1:2}}static tryReadLocation(e){let r=e.lexeme[0].charCodeAt(0)>="A".charCodeAt(0)&&e.lexeme[0].charCodeAt(0)<="E".charCodeAt(0),t=r?e.lexeme.substring(1):e.lexeme.substring(0),n=0;if(r&&(n=e.lexeme[0].charCodeAt(0)-"A".charCodeAt(0)+1,n===3))return[!0,new d(0,n)];let o=parseInt(t);return o?[!0,new d(o-1,n)]:[!1,new d(0,0)]}moveNext(){return this.endOfFile=!this.enumerator.moveNext(),!this.endOfFile}};var B=class extends p{constructor(e,r,t){super(e,r,t),this.name="UnterminatedSectionException"}};var M=class{constructor(e,r,t,n){this.type=e,this.lexeme=r,this.line=t,this.character=n}};var A=class a{constructor(e){this.space=String.fromCharCode(32);this.enSpace=String.fromCharCode(8194);this.punctuationSpace=String.fromCharCode(8200);this.ideographicSpace=String.fromCharCode(12288);this.lineSeparator=String.fromCharCode(8232);this.paragraphSeparator=String.fromCharCode(8233);this.endOfFileChar="E";this.eachDividerChars=new Set(["/","`"]);this.decoratorChars=new Set(["f","b","x","h","m","!","?","@","$"]);this.slideChars=new Set(["-",">","<","^","p","q","v","V","s","z","w"]);this.separatorChars=new Set(["\r"," ",this.lineSeparator,this.paragraphSeparator,this.space,this.enSpace,this.punctuationSpace,this.ideographicSpace]);this._current=0;this._charIndex=0;this._line=1;this._start=0;this._sequence=e}get isAtEnd(){return this._current>=this._sequence.length}*getTokens(){for(;!this.isAtEnd;){this._start=this._current;let e=this.scanToken();e!==void 0&&(yield e)}}scanToken(){this._charIndex++;let e=this.advance();if(this.decoratorChars.has(e))return this.compileToken(4);if(this.eachDividerChars.has(e))return this.compileToken(9);if(this.separatorChars.has(e))return;switch(e){case",":return this.compileToken(8);case"(":return this.compileSectionToken(1,"(",")");case"{":return this.compileSectionToken(2,"{","}");case"[":return this.compileSectionToken(6,"[","]");case"*":return this.compileToken(7);case`
`:this._line++,this._charIndex=0;return;case this.endOfFileChar:return this.compileToken(10);case"|":{if(this.peek()!=="|")throw new u(this._line,this._charIndex,"|");for(;this.peek()!==`
`&&!this.isAtEnd;)this.advance();return}default:throw new m(this._line,this._charIndex)}}tryScanLocationToken(){let e=this.peekPrevious();if(a.isButtonLocation(e))return[!0,1];if(!a.isSensorLocation(e))return[!1,0];let r=this.peek();if(a.isButtonLocation(r))return[!0,2];if(e==="C")return[!0,1];let t=this.separatorChars.has(r)||r===`
`||r==="\0";if(e===this.endOfFileChar&&t)return[!1,0];throw new u(this._line,this._charIndex,"1, 2, 3, 4, 5, 6, 7, 8")}isReadingSlideDeclaration(){if(!this.slideChars.has(this.peekPrevious()))return[!1,0];let e=this.peek();return[!0,e==="p"||e==="q"?2:1]}compileSectionToken(e,r,t){for(this._start++;this.peek()!==t;){if(this.isAtEnd||this.peek()===r)throw new y(this._line,this._charIndex);this.advance()}let n=this.compileToken(e);return this.advance(),n}compileToken(e){let r=this._sequence.substring(this._start,this._current);return new k(e,r,this._line,this._charIndex)}static isSensorLocation(e){return e.charCodeAt(0)>="A".charCodeAt(0)&&e.charCodeAt(0)<="E".charCodeAt(0)}static isButtonLocation(e){return e.charCodeAt(0)>="0".charCodeAt(0)&&e.charCodeAt(0)<="8".charCodeAt(0)}advance(){return this._sequence[this._current++]}peek(){return this.isAtEnd?"":this._sequence[this._current]}peekPrevious(){return this._current==0?"":this._sequence[this._current-1]}};var E=(t=>(t[t.Default=0]="Default",t[t.ForceBroken=1]="ForceBroken",t[t.ForceEach=2]="ForceEach",t))(E||{});var p=class{constructor(e,r){this.index=e,this.group=r}equals(e){return this.index===e.index&&this.group===e.group}toString(){return`index: ${this.index}, group: ${this.group.toString()}`}};var b=class{constructor(){this.noteCollections=[]}};var C=class extends Array{constructor(r){super();this.eachStyle=0;this.time=r}addNote(r){r.parentCollection=this,this.push(r)}};var w=(i=>(i[i.Tap=0]="Tap",i[i.ASensor=1]="ASensor",i[i.BSensor=2]="BSensor",i[i.CSensor=3]="CSensor",i[i.DSensor=4]="DSensor",i[i.ESensor=5]="ESensor",i))(w||{});var S=(s=>(s[s.StraightLine=0]="StraightLine",s[s.RingCw=1]="RingCw",s[s.RingCcw=2]="RingCcw",s[s.Fold=3]="Fold",s[s.CurveCw=4]="CurveCw",s[s.CurveCcw=5]="CurveCcw",s[s.ZigZagS=6]="ZigZagS",s[s.ZigZagZ=7]="ZigZagZ",s[s.EdgeFold=8]="EdgeFold",s[s.EdgeCurveCw=9]="EdgeCurveCw",s[s.EdgeCurveCcw=10]="EdgeCurveCcw",s[s.Fan=11]="Fan",s))(S||{});var O=class{constructor(e){this._source=e;this._index=-1;this._done=!1}get current(){return this._current}get index(){return this._index}get done(){return this._done}moveNext(){let e=this._source[Symbol.iterator](),{value:r,done:t}=e.next();return this._current=r,this._done=!!t,this._index++,!t}reset(){this._index=-1,this._done=!1,this._current=void 0}};var d=class extends h{constructor(r,t,n,o){super(r,t,o);this.name="ScopeMismatchException",this.correctScope=n}};var _=(n=>(n[n.Default=0]="Default",n[n.ForceNormal=1]="ForceNormal",n[n.ForceStar=2]="ForceStar",n[n.ForceStarSpinning=3]="ForceStarSpinning",n))(_||{});var T=(i=>(i[i.None=0]="None",i[i.Ex=1]="Ex",i[i.Star=2]="Star",i[i.StarPower=4]="StarPower",i[i.Fireworks=5]="Fireworks",i[i.Mine=6]="Mine",i))(T||{});var x=(i=>(i[i.Tap=0]="Tap",i[i.Touch=1]="Touch",i[i.Hold=2]="Hold",i[i.Slide=3]="Slide",i[i.Break=4]="Break",i[i.ForceInvalidate=5]="ForceInvalidate",i))(x||{});var L=(r=>(r[r.FadeIn=0]="FadeIn",r[r.SuddenIn=1]="SuddenIn",r))(L||{});var v=class{constructor(e){this.location=new p(0,0);this.styles=0;this.appearance=0;this.type=0;this.slideMorph=0;this.slidePaths=[];this.parentCollection=e}get isEx(){return(this.styles&1)!=0}get isStar(){return this.appearance>=2||this.slidePaths.length>0&&this.appearance!==1}getVisibleDuration(){var r;var e=(r=this.length)!=null?r:0;return this.slidePaths.length>0&&(e=Math.max(...this.slidePaths.map(t=>t.delay+t.duration))),e}};var P=class extends h{constructor(e,r,t){super(e,r,t),this.name="InvalidSyntaxException"}};var D=class{get secondsPerBar(){return this.tempo===0?0:60/this.tempo}get secondsPerBeat(){return this.secondsPerBar/((this.subdivisions===0?4:this.subdivisions)/4)}constructor(e,r=4){this.tempo=e,this.subdivisions=r}explicitOverride(e){this.tempo=60/e,this.subdivisions=4}};var F=class{constructor(e){this.startLocation=new p(0,0);this.delay=0;this.duration=0;this.type=3;this.segments=e}};var N=class{constructor(e){this.vertices=e!=null?e:[],this.slideType=0}};var B=class a{static process(e,r,t,n){let o=new F([]);o.delay=n.secondsPerBeat,a.readSegment(e,t,r.location,o);let i=!0;for(;!e.endOfFile&&(i||e.moveNext());){var c=e.enumerator.current;switch(i=!1,c.type){case 1:case 2:throw new d(c.line,c.character,4);case 4:{a.decorateSlide(c,o);break}case 5:{let l=o.segments[o.segments.length-1];a.readSegment(e,c,l.vertices[l.vertices.length-1],o),i=!0;break}case 6:{a.readDuration(c,e.currentTiming,o);break}case 7:return e.moveNext(),o;case 8:case 9:case 10:case 3:return o;case 0:break;default:throw new m(c.line,c.character)}}return o}static readSegment(e,r,t,n){let o=new N([]),i=r.lexeme.length;a.assignVertices(e,r,o),o.slideType=a.identifySlideType(r,t,o,i),n.segments.push(o)}static decorateSlide(e,r){switch(e.lexeme[0]){case"b":r.type=4;return;default:throw new m(e.line,e.character)}}static identifySlideType(e,r,t,n){switch(e.lexeme[0]){case"-":return 0;case">":return f.determineRingType(r,t.vertices[0],1);case"<":return f.determineRingType(r,t.vertices[0],-1);case"^":return f.determineRingType(r,t.vertices[0]);case"q":return n===2&&e.lexeme[1]==="q"?9:4;case"p":return n===2&&e.lexeme[1]==="p"?10:5;case"v":return 3;case"V":return 8;case"s":return 6;case"z":return 7;case"w":return 11;default:throw new m(e.line,e.character)}}static assignVertices(e,r,t){do{if(!e.moveNext())throw new m(r.line,r.character);let n=e.enumerator.current,[o,i]=f.tryReadLocation(n);o&&t.vertices.push(i)}while(e.enumerator.current.type===3)}static readDuration(e,r,t){let o=r,i=e.lexeme.indexOf("#");if(i>-1){let K=e.lexeme.lastIndexOf("#")+1-1,W=e.lexeme.substring(0,i),j=i!==K,q=parseFloat(W);if(isNaN(q))throw new u(e.line,e.character,'0~9, or "."');j?t.delay=q:(o.tempo=q,t.delay=o.secondsPerBar)}let l=e.lexeme.substring(0),g=l.indexOf(":");if(g===-1){let s=parseFloat(l);if(isNaN(s))throw new u(e.line,e.character+0,'0~9, or "."');t.duration+=s;return}let H=parseFloat(l.substring(0,g));if(isNaN(H))throw new u(e.line,e.character+0,'0~9, or "."');let J=parseFloat(l.substring(g+1));if(isNaN(J))throw new m(e.line,e.character+0+g+1,'0~9, or "."');t.duration+=o.secondsPerBar/(H/4)*J}};var M=class a{static process(e,r){let[t,n]=f.tryReadLocation(r);if(!t)throw new P(r.line,r.character);let o=new v(e.currentNoteCollection);o.location=n;let i=new D(e.currentNoteCollection.time);n.group!==0&&(o.type=1);let c=!1;for(;!e.endOfFile&&(c||e.moveNext());){let l=e.enumerator.current;switch(c=!1,l.type){case 1:case 2:throw new d(l.line,l.character,4);case 4:{a.decorateNote(l,o);break}case 5:{o.type===2&&(o.length=i.secondsPerBeat);let g=B.process(e,o,l,i);c=!0,o.slidePaths.push(g);break}case 6:{a.readDuration(l,e.currentTiming,o);break}case 7:throw new d(l.line,l.character,2);case 8:case 9:case 10:case 3:return o;case 0:break;default:throw new m(l.line,l.character)}}return o}static decorateNote(e,r){var t;switch(e.lexeme[0]){case"f":r.styles|=5;return;case"b":if(r.type===5)break;r.type=4;return;case"x":r.styles|=1;return;case"m":r.styles|=6;return;case"h":if(r.type===4||r.type===5)break;r.type=2,(t=r.length)!=null||(r.length=0);return;case"?":r.type=5,r.slideMorph=0;return;case"!":r.type=5,r.slideMorph=1;return;case"@":r.appearance=1;return;case"$":r.appearance=r.appearance===2?3:2;return}}static readDuration(e,r,t){if(t.type!==4&&(t.type=2),e.lexeme[0]==="#"){let c=parseFloat(e.lexeme.slice(1));if(isNaN(c))throw new u(e.line,e.character+1,'0~9, or "."');t.length=c;return}let n=e.lexeme.indexOf(":"),o=parseFloat(e.lexeme.slice(0,n)),i=parseFloat(e.lexeme.slice(n+1));if(isNaN(o)||isNaN(i))throw new u(e.line,e.character+1,'0~9, or "."');t.length=r.secondsPerBar/(o/4)*i}};var A=class{static process(e,r){if(r.lexeme[0]==="#"){let n=parseFloat(r.lexeme.slice(1));if(isNaN(n))throw new u(r.line,r.character+1,'0~9, or "."');e.currentTiming.explicitOverride(n);return}let t=parseFloat(r.lexeme);if(isNaN(t))throw new u(r.line,r.character,'0~9, or "."');e.currentTiming.subdivisions=t}};var R=class{static process(e,r){let t=parseFloat(r.lexeme);if(isNaN(t))throw new u(r.line,r.character,'0~9, or "."');e.currentTiming.tempo=t}};var f=class{constructor(e){this._chart=new b;this._maxFinishTime=0;this._currentTime=0;this.currentTiming=new D(0,0);this.endOfFile=!1;this.enumerator=new O(e)}getChart(){var t,n,o;let e=[],r=!1;for(;!this.endOfFile&&(r||this.moveNext());){let i=this.enumerator.current;switch(r=!1,i.type){case 1:{R.process(this,i);break}case 2:{A.process(this,i);break}case 3:{if((t=this.currentNoteCollection)!=null||(this.currentNoteCollection=new C(this._currentTime)),i.lexeme[0]==="0"){this.currentNoteCollection.eachStyle!==1&&(this.currentNoteCollection.eachStyle=2);break}let c=M.process(this,i);this.currentNoteCollection.addNote(c),r=!0,this._maxFinishTime=Math.max(this._maxFinishTime,this.currentNoteCollection.time+c.getVisibleDuration());break}case 8:this.currentNoteCollection!=null&&(e.push(this.currentNoteCollection),this.currentNoteCollection=void 0),this._currentTime+=this.currentTiming.secondsPerBeat;break;case 9:switch(i.lexeme[0]){case"/":break;case"`":this.currentNoteCollection!=null&&(this.currentNoteCollection.eachStyle=1);break}break;case 4:throw new d(i.line,i.character,1);case 5:throw new d(i.line,i.character,1);case 6:throw new d(i.line,i.character,3);case 7:throw new d(i.line,i.character,2);case 10:this._chart.finishTiming=this._currentTime;break;case 0:break;default:throw new m(i.line,i.character)}}return(o=(n=this._chart).finishTiming)!=null||(n.finishTiming=this._maxFinishTime),this.currentNoteCollection!==void 0&&(e.push(this.currentNoteCollection),this.currentNoteCollection=void 0),this._chart.noteCollections=e,this._chart}static determineRingType(e,r,t=0){switch(t){case 1:return(e.index+2)%8>=4?2:1;case-1:return(e.index+2)%8>=4?1:2;default:var n=r.index-e.index,o=n>=0?n>4?-1:1:n<-4?1:-1;return o>0?1:2}}static tryReadLocation(e){let r=e.lexeme[0].charCodeAt(0)>="A".charCodeAt(0)&&e.lexeme[0].charCodeAt(0)<="E".charCodeAt(0),t=r?e.lexeme.substring(1):e.lexeme.substring(0),n=0;if(r&&(n=w[e.lexeme[0].charCodeAt(0)-"A".charCodeAt(0)+1],n===3))return[!0,new p(0,n)];let o=parseInt(t);return o?[!0,new p(o-1,n)]:[!1,new p(0,0)]}moveNext(){return this.endOfFile=!this.enumerator.moveNext(),!this.endOfFile}};var V=class{static deserialize(e){let r=new I(e).getTokens();return new f(r).getChart()}};var z=class{constructor(e){this.data="";this.data=e}toKeyValuePairs(){let e="",r="",t=this.data.replace(`\r
`,`
`&&!this.isAtEnd;)this.advance();return}}let[r,t]=this.tryScanLocationToken();if(r)return this._current+=t-1,this.compileToken(3);let[n,o]=this.isReadingSlideDeclaration();if(n)return this._current+=o-1,this.compileToken(5);throw new m(this._line,this._charIndex)}tryScanLocationToken(){let e=this.peekPrevious();if(a.isButtonLocation(e))return[!0,1];if(!a.isSensorLocation(e))return[!1,0];let r=this.peek();if(a.isButtonLocation(r))return[!0,2];if(e==="C")return[!0,1];let t=this.separatorChars.has(r)||r===`
`||r==="\0";if(e===this.endOfFileChar&&t)return[!1,0];throw new u(this._line,this._charIndex,"1, 2, 3, 4, 5, 6, 7, 8")}isReadingSlideDeclaration(){if(!this.slideChars.has(this.peekPrevious()))return[!1,0];let e=this.peek();return[!0,e==="p"||e==="q"?2:1]}compileSectionToken(e,r,t){for(this._start++;this.peek()!==t;){if(this.isAtEnd||this.peek()===r)throw new B(this._line,this._charIndex);this.advance()}let n=this.compileToken(e);return this.advance(),n}compileToken(e){let r=this._sequence.substring(this._start,this._current);return new M(e,r,this._line,this._charIndex)}static isSensorLocation(e){return e.charCodeAt(0)>="A".charCodeAt(0)&&e.charCodeAt(0)<="E".charCodeAt(0)}static isButtonLocation(e){return e.charCodeAt(0)>="0".charCodeAt(0)&&e.charCodeAt(0)<="8".charCodeAt(0)}advance(){return this._sequence[this._current++]}peek(){return this.isAtEnd?"":this._sequence[this._current]}peekPrevious(){return this._current==0?"":this._sequence[this._current-1]}};var V=class{static deserialize(e){let r=new A(e).getTokens();return new f(r).getChart()}};var z=class{constructor(e){this.data="";this.data=e}toKeyValuePairs(){let e="",r="",t=this.data.replace(/\r\n/g,`
`).split(`

@@ -10,2 +9,1 @@ `),n=new Map;for(let o of t)if(o.startsWith("&")){e!=""&&(n.set(e,r.trim()),r="");let i=o.split("=",2);e=i[0].substring(1),r+=i[1]+`

`;return e&&n.set(e,r.trim()),n}getValue(e){var r;return(r=this.toKeyValuePairs().get(e))!=null?r:""}};0&&(module.exports={EachStyle,Location,MaiChart,Note,NoteAppearance,NoteCollection,NoteGroup,NoteStyles,NoteType,SimaiConvert,SimaiFile,SlideMorph,SlidePath,SlideSegment,SlideType});
//# sourceMappingURL=index.js.map
{
"name": "simai.js",
"version": "1.0.8",
"version": "1.0.9",
"description": "A serializer(wip)/deserializer for the rhythm game chart format simai.",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet