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.10

10

dist/index.js

@@ -1,8 +0,8 @@

"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}}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,`
"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,i)=>{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:!(i=G(e,n))||i.enumerable});return a};var re=a=>ee(U({},"__esModule",{value:!0}),a);var te={};Y(te,{EachStyle:()=>N,Location:()=>d,MaiChart:()=>S,Note:()=>w,NoteAppearance:()=>E,NoteCollection:()=>b,NoteGroup:()=>_,NoteStyles:()=>T,NoteType:()=>x,SimaiConvert:()=>V,SimaiFile:()=>z,SlideMorph:()=>y,SlidePath:()=>F,SlideSegment:()=>D,SlideType:()=>C});module.exports=re(te);var h=class extends Error{constructor(r,i,n){super(n);this.name="SimaiException",this.character=i,this.line=r}};var p=class extends h{constructor(r,i,n,o){super(r,i,o);this.name="ScopeMismatchException",this.correctScope=n}};var m=class extends h{constructor(e,r,i){super(e,r,i),this.name="UnsupportedSyntaxException"}};var N=(i=>(i[i.Default=0]="Default",i[i.ForceBroken=1]="ForceBroken",i[i.ForceEach=2]="ForceEach",i))(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 h{constructor(r,i,n,o){super(r,i,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 i=parseFloat(r.lexeme);if(isNaN(i))throw new u(r.line,r.character,'0~9, or "."');e.currentTiming.subdivisions=i}};var _=(t=>(t[t.Tap=0]="Tap",t[t.ASensor=1]="ASensor",t[t.BSensor=2]="BSensor",t[t.CSensor=3]="CSensor",t[t.DSensor=4]="DSensor",t[t.ESensor=5]="ESensor",t))(_||{});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 S=class{constructor(){this.noteCollections=[]}};var k=class{static process(e,r){let i=parseFloat(r.lexeme);if(isNaN(i))throw new u(r.line,r.character,'0~9, or "."');e.currentTiming.tempo=i}};var I=class extends h{constructor(e,r,i){super(e,r,i),this.name="InvalidSyntaxException"}};var E=(n=>(n[n.Default=0]="Default",n[n.ForceNormal=1]="ForceNormal",n[n.ForceStar=2]="ForceStar",n[n.ForceStarSpinning=3]="ForceStarSpinning",n))(E||{});var T=(t=>(t[t.None=0]="None",t[t.Ex=1]="Ex",t[t.Star=2]="Star",t[t.StarPower=4]="StarPower",t[t.Fireworks=5]="Fireworks",t[t.Mine=6]="Mine",t))(T||{});var y=(r=>(r[r.FadeIn=0]="FadeIn",r[r.SuddenIn=1]="SuddenIn",r))(y||{});var x=(t=>(t[t.Tap=0]="Tap",t[t.Touch=1]="Touch",t[t.Hold=2]="Hold",t[t.Slide=3]="Slide",t[t.Break=4]="Break",t[t.ForceInvalidate=5]="ForceInvalidate",t))(x||{});var w=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(i=>i.delay+i.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,i,n){let o=new F([]);o.delay=n.secondsPerBeat,a.readSegment(e,i,r.location,o);let t=!0;for(;!e.endOfFile&&(t||e.moveNext());){var c=e.enumerator.current;switch(t=!1,c.type){case 1:case 2:throw new p(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),t=!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,i,n){let o=new D([]),t=r.lexeme.length;a.assignVertices(e,r,o),o.slideType=a.identifySlideType(r,i,o,t),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,i,n){switch(e.lexeme[0]){case"-":return 0;case">":return f.determineRingType(r,i.vertices[0],1);case"<":return f.determineRingType(r,i.vertices[0],-1);case"^":return f.determineRingType(r,i.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,i){do{if(!e.moveNext())throw new m(r.line,r.character);let n=e.enumerator.current,[o,t]=f.tryReadLocation(n);o&&i.vertices.push(t)}while(e.enumerator.current.type===3)}static readDuration(e,r,i){let o=r,t=e.lexeme.indexOf("#");if(t>-1){let K=e.lexeme.lastIndexOf("#")+1-1,W=e.lexeme.substring(0,t),j=t!==K,q=parseFloat(W);if(isNaN(q))throw new u(e.line,e.character,'0~9, or "."');j?i.delay=q:(o.tempo=q,i.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 "."');i.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 "."');i.duration+=o.secondsPerBar/(H/4)*J}};var P=class a{static process(e,r){let[i,n]=f.tryReadLocation(r);if(!i)throw new I(r.line,r.character);let o=new w(e.currentNoteCollection);o.location=n;let t=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 p(l.line,l.character,4);case 4:{a.decorateNote(l,o);break}case 5:{o.type===2&&(o.length=t.secondsPerBeat);let g=O.process(e,o,l,t);c=!0,o.slidePaths.push(g);break}case 6:{a.readDuration(l,e.currentTiming,o);break}case 7:throw new p(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 i;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,(i=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,i){if(i.type!==4&&(i.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 "."');i.length=c;return}let n=e.lexeme.indexOf(":"),o=parseFloat(e.lexeme.slice(0,n)),t=parseFloat(e.lexeme.slice(n+1));if(isNaN(o)||isNaN(t))throw new u(e.line,e.character+1,'0~9, or "."');i.length=r.secondsPerBar/(o/4)*t}};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:i}=e.next();return this._current=r,this._done=!!i,this._index++,!i}reset(){this._index=-1,this._done=!1,this._current=void 0}};var f=class{constructor(e){this._chart=new S;this._maxFinishTime=0;this._currentTime=0;this.currentTiming=new v(0,0);this.endOfFile=!1;this.enumerator=new R(e)}getChart(){var i,n,o;let e=[],r=!1;for(;!this.endOfFile&&(r||this.moveNext());){let t=this.enumerator.current;switch(r=!1,t.type){case 1:{k.process(this,t);break}case 2:{L.process(this,t);break}case 3:{if((i=this.currentNoteCollection)!=null||(this.currentNoteCollection=new b(this._currentTime)),t.lexeme[0]==="0"){this.currentNoteCollection.eachStyle!==1&&(this.currentNoteCollection.eachStyle=2);break}let c=P.process(this,t);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(t.lexeme[0]){case"/":break;case"`":this.currentNoteCollection!=null&&(this.currentNoteCollection.eachStyle=1);break}break;case 4:throw new p(t.line,t.character,1);case 5:throw new p(t.line,t.character,1);case 6:throw new p(t.line,t.character,3);case 7:throw new p(t.line,t.character,2);case 10:this._chart.finishTiming=this._currentTime;break;case 0:break;default:throw new m(t.line,t.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,i=0){switch(i){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),i=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(i);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 h{constructor(e,r,i){super(e,r,i),this.name="UnterminatedSectionException"}};var M=class{constructor(e,r,i,n){this.type=e,this.lexeme=r,this.line=i,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:try{let[t,c]=this.tryScanLocationToken();if(t)return this._current+=c-1,this.compileToken(3)}catch(t){}return this.compileToken(10);case"|":{if(this.peek()!=="|")throw new u(this._line,this._charIndex,"|");for(;this.peek()!==`
`&&!this.isAtEnd;)this.advance();return}}let[r,i]=this.tryScanLocationToken();if(r)return this._current+=i-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 i=this.separatorChars.has(r)||r===`
`||r==="\0";if(e===this.endOfFileChar&&i)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,i){for(this._start++;this.peek()!==i;){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="",i=this.data.replace(/\r\n/g,`
`).split(`
`),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]+`
`),n=new Map;for(let o of i)if(o.startsWith("&")){e!=""&&(n.set(e,r.trim()),r="");let t=o.split("=",2);e=t[0].substring(1),r+=t[1]+`
`}else r+=o+`
`;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});
{
"name": "simai.js",
"version": "1.0.9",
"version": "1.0.10",
"description": "A serializer(wip)/deserializer for the rhythm game chart format simai.",

@@ -36,4 +36,4 @@ "main": "dist/index.js",

"devDependencies": {
"@types/mocha": "^10.0.3",
"@types/node": "^20.8.10",
"@types/mocha": "^10.0.4",
"@types/node": "^20.9.0",
"del-cli": "^5.1.0",

@@ -40,0 +40,0 @@ "mocha": "^10.2.0",

Sorry, the diff of this file is not supported yet