Spaces:
Sleeping
Sleeping
| const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./jszip.min-C1swU7HS.js","./bool-store-input-BqSYkTSj.js","./index-DvfQQ4hm.js","./index-BTzhfVTa.css"])))=>i.map(i=>d[i]); | |
| import{p as watch,q as computed,s as toValue,u as shallowRef,x as onMounted,y as getCurrentInstance,_ as _export_sfc,c as createElementBlock,o as openBlock,F as Fragment,e as renderList,a as createBaseVNode,b as createCommentVNode,l as normalizeClass,t as toDisplayString,r as resolveComponent,f as createBlock,z as renderSlot,k as withModifiers,w as withDirectives,g as vShow,d as createVNode,v as vModelSelect,h as createTextVNode,j as vModelText,A as withCtx,m as __vitePreload}from"./index-DvfQQ4hm.js";import{t as tryOnScopeDispose,i as isClient,u as useDebounceFn,I as Icon,C as CheckButton,S as SheetSigns,a as SheetLive,b as bakeRawSvgs,m as matchNotations,c as Scheduler,p as parseNotationFromSheetDocument,d as assignTickByLocationTable}from"./check-button-DKH0cWTY.js";import{g as ContextedMusic,V as Variable,h as Command,D as Duration,i as Lyric,F as FractionNumber,T as Times,M as MusicBlock,j as LyricMode,k as LiteralString,W as WHOLE_DURATION_MAGNITUDE,t as termDictionary,u as ue,l as he,X,p as pick,B as BoolStoreInput,S as StoreInput,m as mutexDelay,n as SingleMLayout,o as VoltaMLayout,r as recoverJSON,q as measureLayout,s as replaceSourceToken,e as SheetDocument,f as StaffToken,d as downloadUrl,C as CM_TO_PX,v as TextSource,P as PitchContextTable,w as matchWithExactMIDI,x as LogRecorder,y as pe,z as animationDelay,A as f,E as npmPackage}from"./bool-store-input-BqSYkTSj.js";import{L as Loading,S as SheetSimple,a as SourceEditor,M as MusicTrack,b as LilyDocument,l as load}from"./loading-dots-Dk5xtdK1.js";const COLOR_NAMES=["lyrGray","lyrRed","lyrGreen","lyrYellow"],createPianoRhythmTrack=({ticks:t,durationMagnitude:e,subdivider:r,color:s=null})=>{const n=WHOLE_DURATION_MAGNITUDE/r,o=2**Math.floor(Math.log2(r)),l=new Duration({number:o,dots:0});let a=[];s&&a.push(new Variable({name:s}));for(let u=0;u<e;u+=n){const c=new Variable({name:t.has(u)?"dotB":"dotW"}),h=new Lyric({content:c,duration:u===0?l.clone():null});a.push(h)}if(o!==r){const u=new FractionNumber(o,r).reduced;a=[new Times({cmd:"times",args:[u.toString(),new MusicBlock({body:a})]})]}return new LyricMode({cmd:"lyricmode",args:[new MusicBlock({body:a})]})},createPianoNumberTrack=({durationMagnitude:t,subdivider:e,measureTicks:r,trackTicks:s,colored:n})=>{const o=WHOLE_DURATION_MAGNITUDE/e,l=2**Math.floor(Math.log2(e)),a=new Duration({number:l,dots:0}),u=[];let c=1;for(let d=0;d<t;d+=o){r.some(([p,g])=>g===d)&&(c=1);let m=0;s.forEach((p,g)=>p.has(d)&&(m+=2**g)),u.push({number:c,type:m}),++c}let h=[].concat(...u.map(({number:d,type:m},p)=>[n?new Variable({name:COLOR_NAMES[m]}):null,new Lyric({content:LiteralString.fromString(d.toString()),duration:p===0?a.clone():null})])).map(d=>d);if(l!==e){const d=new FractionNumber(l,e).reduced;h=[new Times({cmd:"times",args:[d.toString(),new MusicBlock({body:h})]})]}return new LyricMode({cmd:"lyricmode",args:[new MusicBlock({body:h})]})},isPianoStaff=t=>t instanceof ContextedMusic&&t.type==="PianoStaff",createPianoRhythm=(t,{dotTracks:e=!0,numberTrack:r,colored:s}={})=>{console.assert(!!t.scores.length,"interpreter.scores is empty.");let n=t.mainScore&&t.mainScore.findFirst(isPianoStaff);if(n||(n=t.scores[0]&&t.scores[0].findFirst(isPianoStaff)),!n)throw new Error("[createPianoRhythm] no pianoMusic");const o=n.body;o.list=o.list.filter(m=>!(m instanceof ContextedMusic)||m.type!=="Lyrics");const l=o.list.filter(m=>m instanceof ContextedMusic&&m.type==="Staff"),a=o.list.indexOf(l[0])+1;t.updateTrackAssignments();const u=t.layoutMusic,c=l.map(m=>{const p=m.findAll(Variable).map(y=>y.name),g=u.musicTracks.filter(y=>p.includes(y.name));return new Set([].concat(...g.map(y=>y.block.noteTicks)))}),h=u.getNoteDurationSubdivider(),d=u.musicTracks[0].durationMagnitude;if(e&&c.forEach((m,p)=>{const g=COLOR_NAMES[2**Math.min(p,1)],y=createPianoRhythmTrack({ticks:m,durationMagnitude:d,subdivider:h,color:s?g:null}),w=new ContextedMusic({head:new Command({cmd:"new",args:["Lyrics"]}),body:y});o.list.splice(a+p,0,w)}),r){const m=a+(e?1:0),p=u.musicTracks[0].block.measureTicks,g=createPianoNumberTrack({durationMagnitude:d,subdivider:h,measureTicks:p,trackTicks:c,colored:s}),y=new ContextedMusic({head:new Command({cmd:"new",args:["Lyrics"]}),body:g});o.list.splice(m,0,y)}t.addIncludeFile("rhythmSymbols.ly"),t.appendReservedVariables(["dotB","dotW","lyrRed","lyrGreen","lyrYellow","lyrGray"])},LilyTerms=termDictionary,defaultWindow=isClient?window:void 0;function unrefElement(t){var e;const r=toValue(t);return(e=r==null?void 0:r.$el)!==null&&e!==void 0?e:r}function useMounted(){const t=shallowRef(!1),e=getCurrentInstance();return e&&onMounted(()=>{t.value=!0},e),t}function useSupported(t){const e=useMounted();return computed(()=>(e.value,!!t()))}function useResizeObserver(t,e,r={}){const{window:s=defaultWindow,...n}=r;let o;const l=useSupported(()=>s&&"ResizeObserver"in s),a=()=>{o&&(o.disconnect(),o=void 0)},u=watch(computed(()=>{const h=toValue(t);return Array.isArray(h)?h.map(d=>unrefElement(d)):[unrefElement(h)]}),h=>{if(a(),l.value&&s){o=new ResizeObserver(e);for(const d of h)d&&o.observe(d,n)}},{immediate:!0,flush:"post"}),c=()=>{a(),u()};return tryOnScopeDispose(c),{isSupported:l,stop:c}}const _sfc_main$6={name:"svg-piano-roll",props:{notation:Object,timeScale:{type:Number,default:.001},pitchScale:{type:Number,default:1},focusNoteIndex:Number,tooltips:{type:Boolean,default:!1}},computed:{notationObj(){return this.notation?this.notation:(console.warn("property of 'notation' is required."),null)}},methods:{onClickNote(t){this.$emit("clickNote",t)}}},_hoisted_1$6={class:"piano-roll-root"},_hoisted_2$5=["transform"],_hoisted_3$3=["width","height","onClick"],_hoisted_4$3=["y2"],_hoisted_5$3={key:0};function _sfc_render$6(t,e,r,s,n,o){return openBlock(),createElementBlock("g",_hoisted_1$6,[(openBlock(!0),createElementBlock(Fragment,null,renderList(o.notationObj.notes,(l,a)=>(openBlock(),createElementBlock("g",{key:a,class:"note",transform:`translate(${l.start*r.timeScale}, ${-l.pitch*r.pitchScale})`},[createBaseVNode("rect",{width:l.duration*r.timeScale,height:r.pitchScale,onClick:u=>o.onClickNote(l),class:normalizeClass({focus:l.index===r.focusNoteIndex,...l.classes||{},on:l.on})},null,10,_hoisted_3$3),createBaseVNode("line",{x1:0,x2:0,y1:0,y2:r.pitchScale},null,8,_hoisted_4$3),r.tooltips?(openBlock(),createElementBlock("title",_hoisted_5$3,` | |
| p: `+toDisplayString(l.pitch)+` | |
| <tspan v-if="note.id"> | |
| id: `+toDisplayString(l.id)+` | |
| </tspan> | |
| `,1)):createCommentVNode("",!0)],8,_hoisted_2$5))),128))])}const SvgPianoRoll=_export_sfc(_sfc_main$6,[["render",_sfc_render$6],["__scopeId","data-v-4f7393e0"]]),{parseMidiData}=ue,{Notation}=he,PADDINGS={left:3,right:1},_sfc_main$5={name:"midi-roll",props:{midiURL:String,player:Object,height:{type:Number,default:200},width:Number,timeScale:{type:Number,default:.001}},components:{SvgPianoRoll},data(){return{notation:null,timeScroll:0}},computed:{widthLimited(){return Number.isFinite(this.width)},aspectRatio(){return this.widthLimited?this.width/this.height:1.6},viewHeight(){if(this.notation){const{low:t,high:e}=this.notation.keyRange;return e-t+5}return 90},justifyWidth(){return(this.notation?this.notation.endTime:this.height*this.aspectRatio)*this.timeScale+PADDINGS.left+PADDINGS.right},viewWidth(){return this.widthLimited?this.width*this.viewHeight/this.height:this.justifyWidth},viewBox(){return`-${PADDINGS.left} ${this.notation?-this.notation.keyRange.high-1:0} ${this.viewWidth} ${this.viewHeight}`},pitchScales(){return this.notation?Array(9).fill().map((t,e)=>e*12).filter(t=>t>=this.notation.keyRange.low):[]},timeScales(){return this.notation?Array(Math.ceil(this.notation.endTime/15e3)).fill().map((t,e)=>e*15e3):[]},progressTime(){return this.player?this.player.progressTime:null},visibleTimeSpan(){return this.widthLimited?(this.viewWidth-(PADDINGS.left+PADDINGS.right))/this.timeScale:1/0},xScroll(){return this.timeScroll*this.timeScale}},created(){this.$nextTick(()=>this.load())},methods:{async load(){if(this.notation=null,this.player)this.notation=this.player.notation,this.updateNoteStatus();else if(this.midiURL){const t=await(await fetch(this.midiURL)).arrayBuffer(),e=parseMidiData(t);this.notation=Notation.parseMidi(e)}},updateNoteStatus(){if(!this.notation)return;const t=Number.isFinite(this.progressTime);for(const e of this.notation.notes)e.on=t&&e.start<this.progressTime&&e.start+e.duration>this.progressTime},onClickCanvas(t){if(this.player){const e=(this.notation.keyRange.high-this.notation.keyRange.low+5)/this.height,s=(t.offsetX*e-PADDINGS.left+this.xScroll)/this.timeScale;s>=0&&s<this.notation.endTime&&this.player.turnCursor(s)}},onMouseWheel(t){this.timeScroll+=t.deltaY*.4/this.timeScale},adjustTimeScroll(){this.progressTime-this.timeScroll>this.visibleTimeSpan*.6?this.timeScroll=Math.max(Math.min(this.progressTime-this.visibleTimeSpan*.6,this.notation.endTime-this.visibleTimeSpan),0):this.progressTime-this.timeScroll<this.visibleTimeSpan*.4&&(this.timeScroll=Math.max(this.progressTime-this.visibleTimeSpan*.4,0))}},watch:{midiURL:"load",player:"load",progressTime(){this.updateNoteStatus(),this.widthLimited&&this.adjustTimeScroll()}}},_hoisted_1$5=["viewBox","height"],_hoisted_2$4=["transform"],_hoisted_3$2={key:0,class:"progress"},_hoisted_4$2=["height","width"],_hoisted_5$2=["x1","x2","y1"],_hoisted_6$2={key:1},_hoisted_7$1=["x1","x2","y1"],_hoisted_8$1=["x2","y1","y2"],_hoisted_9$1={key:0,class:"scales"},_hoisted_10$1=["height"],_hoisted_11$1=["y1"],_hoisted_12$1=["x2","y1","y2"],_hoisted_13$1=["y1","y2"],_hoisted_14$1=["y"],_hoisted_15$1=["transform"],_hoisted_16$1=["x1","x2","y1","y2"],_hoisted_17$1=["x","y"];function _sfc_render$5(t,e,r,s,n,o){const l=resolveComponent("SvgPianoRoll");return openBlock(),createElementBlock("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:o.viewBox,height:r.height,onClick:e[0]||(e[0]=(...a)=>o.onClickCanvas&&o.onClickCanvas(...a)),onMousewheel:e[1]||(e[1]=(...a)=>o.onMouseWheel&&o.onMouseWheel(...a))},[createBaseVNode("g",{transform:`translate(${-o.xScroll}, 0)`},[o.progressTime?(openBlock(),createElementBlock("g",_hoisted_3$2,[createBaseVNode("rect",{x:0,y:-120,height:121-n.notation.keyRange.low,width:o.progressTime*r.timeScale},null,8,_hoisted_4$2),createBaseVNode("line",{x1:o.progressTime*r.timeScale,x2:o.progressTime*r.timeScale,y1:-n.notation.keyRange.low+1,y2:"-120"},null,8,_hoisted_5$2)])):createCommentVNode("",!0),n.notation?(openBlock(),createElementBlock("g",_hoisted_6$2,[(openBlock(!0),createElementBlock(Fragment,null,renderList(n.notation.bars,(a,u)=>(openBlock(),createElementBlock("g",{class:"bar measure",key:u},[a.index===0?(openBlock(),createElementBlock("line",{key:0,x1:a.time*r.timeScale,x2:a.time*r.timeScale,y1:-n.notation.keyRange.low+1,y2:"-120"},null,8,_hoisted_7$1)):createCommentVNode("",!0)]))),128)),(openBlock(!0),createElementBlock(Fragment,null,renderList(o.pitchScales,a=>(openBlock(),createElementBlock("g",{class:"bar pitch-group",key:`p-${a}`},[createBaseVNode("line",{x1:0,x2:r.timeScale*n.notation.endTime,y1:-a+1,y2:-a+1},null,8,_hoisted_8$1)]))),128))])):createCommentVNode("",!0),n.notation?(openBlock(),createBlock(l,{key:2,notation:n.notation,timeScale:r.timeScale,pitchScale:1},null,8,["notation","timeScale"])):createCommentVNode("",!0)],8,_hoisted_2$4),n.notation?(openBlock(),createElementBlock("g",_hoisted_9$1,[createBaseVNode("rect",{class:"pitch-padding",x:-10,y:-120,width:10,height:-n.notation.keyRange.low+121},null,8,_hoisted_10$1),createBaseVNode("line",{x1:"0",x2:"0",y1:-n.notation.keyRange.low+1,y2:"-120"},null,8,_hoisted_11$1),createBaseVNode("line",{x1:"0",x2:r.timeScale*n.notation.endTime-o.xScroll,y1:-n.notation.keyRange.low+1,y2:-n.notation.keyRange.low+1},null,8,_hoisted_12$1),(openBlock(!0),createElementBlock(Fragment,null,renderList(o.pitchScales,a=>(openBlock(),createElementBlock("g",{class:"pitch-bar",key:`p-${a}`},[createBaseVNode("line",{x1:"-.8",x2:"0",y1:-a+.5,y2:-a+.5},null,8,_hoisted_13$1),createBaseVNode("text",{x:"-2",y:-a+1},toDisplayString(a),9,_hoisted_14$1)]))),128)),createBaseVNode("g",{transform:`translate(${-o.xScroll}, 0)`},[(openBlock(!0),createElementBlock(Fragment,null,renderList(o.timeScales,a=>(openBlock(),createElementBlock("g",{class:"time-bar",key:`t-${a}`},[createBaseVNode("line",{x1:a*r.timeScale,x2:a*r.timeScale,y1:-n.notation.keyRange.low+1,y2:-n.notation.keyRange.low+1.8},null,8,_hoisted_16$1),createBaseVNode("text",{x:a*r.timeScale,y:-n.notation.keyRange.low+4},toDisplayString(a*.001)+"s",9,_hoisted_17$1)]))),128))],8,_hoisted_15$1)])):createCommentVNode("",!0)],40,_hoisted_1$5)}const MidiRoll=_export_sfc(_sfc_main$5,[["render",_sfc_render$5],["__scopeId","data-v-6b70e64a"]]),copyNotation=t=>({notes:t.notes.map(e=>pick(e,["startTick","endTick","softIndex","duration","classes","pitch","index","id"]))}),_sfc_main$4={name:"notations-matcher",props:{criterion:Object,sample:Object,path:Array,softIndexAsX:{type:Boolean,default:!1},timeFactorC:{type:Number,default:1}},components:{PinaoRoll:X},data(){return{timeScale:.001,positionC:{x:0,y:90},positionS:{x:0,y:160}}},computed:{links(){return this.path&&this.path.map((t,e)=>({ci:t,si:e})).filter(({ci:t})=>t>=0).map(({ci:t,si:e})=>({c:this.innerCriterion.notes[t],s:this.innerSample.notes[e]}))},linkIndices(){return this.path&&this.path.map((t,e)=>({c:t,s:e}))},width(){const t=this.innerCriterion&&this.innerCriterion.notes[this.innerCriterion.notes.length-1],e=this.innerSample&&this.innerSample.notes[this.innerSample.notes.length-1],r=t?t.start+t.duration:0,s=e?e.start+e.duration:0;return Math.max(r,s,1)*this.timeScale},innerCriterion(){if(!this.criterion)return null;const t=copyNotation(this.criterion);return this.satisfyNotation(t,"c"),t},innerSample(){if(!this.sample)return null;const t=copyNotation(this.sample);return this.satisfyNotation(t,"s"),t}},methods:{satisfyNotation(t,e){t&&t.notes.forEach(r=>{this.softIndexAsX?(r.start=r.softIndex*4e3,r.duration=2e3):(r.start=r.startTick*32*(e==="s"?this.timeFactorC:1),r.duration=2e3),r.classes=r.classes||{};const s=this.linkIndices.some(n=>n[e]===r.index);r.classes.missed=!s})},onClickCNote(t){const e=this.criterion.notes[t.index];this.$emit("clickCNote",e)},onClickSNote(t){const e=this.sample.notes[t.index];this.$emit("clickSNote",e)}}},_hoisted_1$4={class:"notations-matcher"},_hoisted_2$3=["viewBox"],_hoisted_3$1=["transform"],_hoisted_4$1=["transform"],_hoisted_5$1={key:0,class:"links"},_hoisted_6$1=["x1","x2","y1","y2"];function _sfc_render$4(t,e,r,s,n,o){const l=resolveComponent("PinaoRoll");return openBlock(),createElementBlock("div",_hoisted_1$4,[(openBlock(),createElementBlock("svg",{xmlns:"http://www.w3.org/2000/svg",height:"480",viewBox:`-20 -20 ${o.width+40} 160`},[createBaseVNode("g",{transform:`translate(${n.positionC.x}, ${n.positionC.y})`,class:"criterion"},[o.innerCriterion?(openBlock(),createBlock(l,{key:0,notation:o.innerCriterion,timeScale:n.timeScale,pitchScale:1,tooltips:!0,onClickNote:o.onClickCNote},null,8,["notation","timeScale","onClickNote"])):createCommentVNode("",!0)],8,_hoisted_3$1),createBaseVNode("g",{transform:`translate(${n.positionS.x}, ${n.positionS.y})`,class:"sample"},[o.innerSample?(openBlock(),createBlock(l,{key:0,notation:o.innerSample,timeScale:n.timeScale,pitchScale:1,tooltips:!0,onClickNote:o.onClickSNote},null,8,["notation","timeScale","onClickNote"])):createCommentVNode("",!0)],8,_hoisted_4$1),o.links?(openBlock(),createElementBlock("g",_hoisted_5$1,[(openBlock(!0),createElementBlock(Fragment,null,renderList(o.links,a=>(openBlock(),createElementBlock("line",{key:a.s.index,class:normalizeClass({oblique:a.s.start!==a.c.start,"heavy-oblique":Math.abs(a.s.start-a.c.start)>128}),x1:n.positionS.x+a.s.start*n.timeScale,x2:n.positionC.x+a.c.start*n.timeScale,y1:n.positionS.y-a.s.pitch+.5,y2:n.positionC.y-a.c.pitch+.5},null,10,_hoisted_6$1))),128))])):createCommentVNode("",!0)],8,_hoisted_2$3))])}const NotationsMatcher=_export_sfc(_sfc_main$4,[["render",_sfc_render$4],["__scopeId","data-v-b7701f59"]]),_sfc_main$3={name:"popup-dialog",props:{visible:Boolean},methods:{close(){this.$emit("update:visible",!1)}}},_hoisted_1$3=["open"];function _sfc_render$3(t,e,r,s,n,o){return openBlock(),createElementBlock("dialog",{open:r.visible,onClick:e[1]||(e[1]=(...l)=>o.close&&o.close(...l))},[createBaseVNode("main",{onClick:e[0]||(e[0]=withModifiers(()=>{},["stop"]))},[renderSlot(t.$slots,"default",{},void 0,!0)])],8,_hoisted_1$3)}const Dialog=_export_sfc(_sfc_main$3,[["render",_sfc_render$3],["__scopeId","data-v-42cf594d"]]);var LIB=function(t){var e={};function r(s){if(e[s])return e[s].exports;var n=e[s]={i:s,l:!1,exports:{}};return t[s].call(n.exports,n,n.exports,r),n.l=!0,n.exports}return r.m=t,r.c=e,r.d=function(s,n,o){r.o(s,n)||Object.defineProperty(s,n,{enumerable:!0,get:o})},r.r=function(s){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(s,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(s,"__esModule",{value:!0})},r.t=function(s,n){if(n&1&&(s=r(s)),n&8||n&4&&typeof s=="object"&&s&&s.__esModule)return s;var o=Object.create(null);if(r.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:s}),n&2&&typeof s!="string")for(var l in s)r.d(o,l,(function(a){return s[a]}).bind(null,l));return o},r.n=function(s){var n=s&&s.__esModule?function(){return s.default}:function(){return s};return r.d(n,"a",n),n},r.o=function(s,n){return Object.prototype.hasOwnProperty.call(s,n)},r.p="",r(r.s="./lib.browser/index.frontend.js")}({"./lib.browser/frontend/remoteFile.js":function(module,__webpack_exports__,__webpack_require__){eval(`__webpack_require__.r(__webpack_exports__); | |
| /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js"); | |
| /* harmony import */ var events__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! events */ "./node_modules/events/events.js"); | |
| /* harmony import */ var events__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(events__WEBPACK_IMPORTED_MODULE_1__); | |
| /* harmony import */ var sha1__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! sha1 */ "./node_modules/sha1/sha1.js"); | |
| /* harmony import */ var sha1__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(sha1__WEBPACK_IMPORTED_MODULE_2__); | |
| /* harmony import */ var diff__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! diff */ "./node_modules/diff/dist/diff.js"); | |
| /* harmony import */ var diff__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(diff__WEBPACK_IMPORTED_MODULE_3__); | |
| var RemoteFile = /** @class */ (function (_super) { | |
| Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(RemoteFile, _super); | |
| function RemoteFile(_a) { | |
| var _b = _a === void 0 ? {} : _a, _c = _b.autoReconnect, autoReconnect = _c === void 0 ? false : _c; | |
| var _this = _super.call(this) || this; | |
| _this.connected = false; | |
| _this.autoReconnect = autoReconnect; | |
| return _this; | |
| } | |
| Object.defineProperty(RemoteFile.prototype, "hash", { | |
| get: function () { | |
| return sha1__WEBPACK_IMPORTED_MODULE_2___default()(this._content); | |
| }, | |
| enumerable: false, | |
| configurable: true | |
| }); | |
| Object.defineProperty(RemoteFile.prototype, "content", { | |
| get: function () { | |
| return this._content; | |
| }, | |
| set: function (value) { | |
| var timestamp = Date.now(); | |
| var patch = diff__WEBPACK_IMPORTED_MODULE_3__["createPatch"](this.filePath, this._content, value); | |
| this.socket.send(JSON.stringify({ | |
| command: "increase", | |
| timestamp: timestamp, | |
| fromHash: this.hash, | |
| toHash: sha1__WEBPACK_IMPORTED_MODULE_2___default()(value), | |
| patch: patch, | |
| })); | |
| this.timestamp = timestamp; | |
| this._content = value; | |
| }, | |
| enumerable: false, | |
| configurable: true | |
| }); | |
| RemoteFile.prototype.connect = function (host, filePath) { | |
| var _this = this; | |
| if (this.socket) | |
| this.socket.close(); | |
| this.socket = new WebSocket(host, "editor-frontend"); | |
| this.socket.onopen = function () { | |
| console.debug("[RemoteFile] socket open."); | |
| _this.connected = true; | |
| _this.emit("connected"); | |
| _this.socket.send(JSON.stringify({ command: "bindFile", filePath: filePath })); | |
| }; | |
| this.socket.onclose = function (event) { | |
| console.debug("Synchronizer service socket closed:", event.code, event.reason); | |
| _this.connected = false; | |
| _this.emit("disconnected"); | |
| if (_this.autoReconnect && event.code === 1006) { | |
| console.log("[RemoteFile] try to reconnect..."); | |
| setTimeout(function () { return _this.connect(host, filePath); }, 100); | |
| } | |
| }; | |
| this.socket.onmessage = function (event) { | |
| var message = JSON.parse(event.data); | |
| switch (message.command) { | |
| case "failure": | |
| console.warn("service failure:", message.description); | |
| _this.close(); | |
| break; | |
| case "fullSync": | |
| _this.timestamp = message.timestamp; | |
| _this._content = message.content; | |
| console.assert(_this.hash === message.hash, "[RemoteFile] verify failed:", _this.hash, message.hash); | |
| _this.emit("sync", { timestamp: _this.timestamp }); | |
| break; | |
| case "increase": | |
| //console.log("increase:", this.hash, message); | |
| // already consistent with remote, update timestemp only | |
| if (_this.hash === message.toHash) { | |
| _this.timestamp = Math.max(_this.timestamp, message.timestamp); | |
| break; | |
| } | |
| if (_this.hash !== message.fromHash) { | |
| if (message.timestamp < _this.timestamp) | |
| break; | |
| console.warn("hash mismatched:", _this.hash, message.fromHash); | |
| _this.socket.send(JSON.stringify({ command: "requestFullSync", timestamp: _this.timestamp })); | |
| } | |
| else { | |
| _this.timestamp = message.timestamp; | |
| _this._content = diff__WEBPACK_IMPORTED_MODULE_3__["applyPatch"](_this._content, message.patch); | |
| console.assert(_this.hash === message.toHash, "[RemoteFile] verify failed:", _this.hash, message.toHash); | |
| _this.emit("sync", { timestamp: _this.timestamp }); | |
| } | |
| break; | |
| default: | |
| console.warn("[RemoteFile] unexpected command:", message); | |
| } | |
| }; | |
| this.filePath = filePath; | |
| }; | |
| RemoteFile.prototype.close = function () { | |
| this.socket.close(); | |
| }; | |
| return RemoteFile; | |
| }(events__WEBPACK_IMPORTED_MODULE_1__["EventEmitter"])); | |
| /* harmony default export */ __webpack_exports__["default"] = (RemoteFile); | |
| ; | |
| //# sourceMappingURL=remoteFile.js.map | |
| //# sourceURL=webpack://LIB/./lib.browser/frontend/remoteFile.js?`)},"./lib.browser/index.frontend.js":function(module,__webpack_exports__,__webpack_require__){eval(`__webpack_require__.r(__webpack_exports__); | |
| /* harmony import */ var _frontend_remoteFile__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./frontend/remoteFile */ "./lib.browser/frontend/remoteFile.js"); | |
| /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RemoteFile", function() { return _frontend_remoteFile__WEBPACK_IMPORTED_MODULE_0__["default"]; }); | |
| //# sourceMappingURL=index.frontend.js.map | |
| //# sourceURL=webpack://LIB/./lib.browser/index.frontend.js?`)},"./node_modules/base64-js/index.js":function(module,exports,__webpack_require__){eval(` | |
| exports.byteLength = byteLength | |
| exports.toByteArray = toByteArray | |
| exports.fromByteArray = fromByteArray | |
| var lookup = [] | |
| var revLookup = [] | |
| var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array | |
| var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' | |
| for (var i = 0, len = code.length; i < len; ++i) { | |
| lookup[i] = code[i] | |
| revLookup[code.charCodeAt(i)] = i | |
| } | |
| // Support decoding URL-safe base64 strings, as Node.js does. | |
| // See: https://en.wikipedia.org/wiki/Base64#URL_applications | |
| revLookup['-'.charCodeAt(0)] = 62 | |
| revLookup['_'.charCodeAt(0)] = 63 | |
| function getLens (b64) { | |
| var len = b64.length | |
| if (len % 4 > 0) { | |
| throw new Error('Invalid string. Length must be a multiple of 4') | |
| } | |
| // Trim off extra bytes after placeholder bytes are found | |
| // See: https://github.com/beatgammit/base64-js/issues/42 | |
| var validLen = b64.indexOf('=') | |
| if (validLen === -1) validLen = len | |
| var placeHoldersLen = validLen === len | |
| ? 0 | |
| : 4 - (validLen % 4) | |
| return [validLen, placeHoldersLen] | |
| } | |
| // base64 is 4/3 + up to two characters of the original data | |
| function byteLength (b64) { | |
| var lens = getLens(b64) | |
| var validLen = lens[0] | |
| var placeHoldersLen = lens[1] | |
| return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen | |
| } | |
| function _byteLength (b64, validLen, placeHoldersLen) { | |
| return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen | |
| } | |
| function toByteArray (b64) { | |
| var tmp | |
| var lens = getLens(b64) | |
| var validLen = lens[0] | |
| var placeHoldersLen = lens[1] | |
| var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen)) | |
| var curByte = 0 | |
| // if there are placeholders, only get up to the last complete 4 chars | |
| var len = placeHoldersLen > 0 | |
| ? validLen - 4 | |
| : validLen | |
| var i | |
| for (i = 0; i < len; i += 4) { | |
| tmp = | |
| (revLookup[b64.charCodeAt(i)] << 18) | | |
| (revLookup[b64.charCodeAt(i + 1)] << 12) | | |
| (revLookup[b64.charCodeAt(i + 2)] << 6) | | |
| revLookup[b64.charCodeAt(i + 3)] | |
| arr[curByte++] = (tmp >> 16) & 0xFF | |
| arr[curByte++] = (tmp >> 8) & 0xFF | |
| arr[curByte++] = tmp & 0xFF | |
| } | |
| if (placeHoldersLen === 2) { | |
| tmp = | |
| (revLookup[b64.charCodeAt(i)] << 2) | | |
| (revLookup[b64.charCodeAt(i + 1)] >> 4) | |
| arr[curByte++] = tmp & 0xFF | |
| } | |
| if (placeHoldersLen === 1) { | |
| tmp = | |
| (revLookup[b64.charCodeAt(i)] << 10) | | |
| (revLookup[b64.charCodeAt(i + 1)] << 4) | | |
| (revLookup[b64.charCodeAt(i + 2)] >> 2) | |
| arr[curByte++] = (tmp >> 8) & 0xFF | |
| arr[curByte++] = tmp & 0xFF | |
| } | |
| return arr | |
| } | |
| function tripletToBase64 (num) { | |
| return lookup[num >> 18 & 0x3F] + | |
| lookup[num >> 12 & 0x3F] + | |
| lookup[num >> 6 & 0x3F] + | |
| lookup[num & 0x3F] | |
| } | |
| function encodeChunk (uint8, start, end) { | |
| var tmp | |
| var output = [] | |
| for (var i = start; i < end; i += 3) { | |
| tmp = | |
| ((uint8[i] << 16) & 0xFF0000) + | |
| ((uint8[i + 1] << 8) & 0xFF00) + | |
| (uint8[i + 2] & 0xFF) | |
| output.push(tripletToBase64(tmp)) | |
| } | |
| return output.join('') | |
| } | |
| function fromByteArray (uint8) { | |
| var tmp | |
| var len = uint8.length | |
| var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes | |
| var parts = [] | |
| var maxChunkLength = 16383 // must be multiple of 3 | |
| // go through the array every three bytes, we'll deal with trailing stuff later | |
| for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) { | |
| parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength))) | |
| } | |
| // pad the end with zeros, but make sure to not forget the extra bytes | |
| if (extraBytes === 1) { | |
| tmp = uint8[len - 1] | |
| parts.push( | |
| lookup[tmp >> 2] + | |
| lookup[(tmp << 4) & 0x3F] + | |
| '==' | |
| ) | |
| } else if (extraBytes === 2) { | |
| tmp = (uint8[len - 2] << 8) + uint8[len - 1] | |
| parts.push( | |
| lookup[tmp >> 10] + | |
| lookup[(tmp >> 4) & 0x3F] + | |
| lookup[(tmp << 2) & 0x3F] + | |
| '=' | |
| ) | |
| } | |
| return parts.join('') | |
| } | |
| //# sourceURL=webpack://LIB/./node_modules/base64-js/index.js?`)},"./node_modules/buffer/index.js":function(module,exports,__webpack_require__){eval(`/* WEBPACK VAR INJECTION */(function(global) {/*! | |
| * The buffer module from node.js, for the browser. | |
| * | |
| * @author Feross Aboukhadijeh <http://feross.org> | |
| * @license MIT | |
| */ | |
| /* eslint-disable no-proto */ | |
| var base64 = __webpack_require__(/*! base64-js */ "./node_modules/base64-js/index.js") | |
| var ieee754 = __webpack_require__(/*! ieee754 */ "./node_modules/ieee754/index.js") | |
| var isArray = __webpack_require__(/*! isarray */ "./node_modules/isarray/index.js") | |
| exports.Buffer = Buffer | |
| exports.SlowBuffer = SlowBuffer | |
| exports.INSPECT_MAX_BYTES = 50 | |
| /** | |
| * If \`Buffer.TYPED_ARRAY_SUPPORT\`: | |
| * === true Use Uint8Array implementation (fastest) | |
| * === false Use Object implementation (most compatible, even IE6) | |
| * | |
| * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+, | |
| * Opera 11.6+, iOS 4.2+. | |
| * | |
| * Due to various browser bugs, sometimes the Object implementation will be used even | |
| * when the browser supports typed arrays. | |
| * | |
| * Note: | |
| * | |
| * - Firefox 4-29 lacks support for adding new properties to \`Uint8Array\` instances, | |
| * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438. | |
| * | |
| * - Chrome 9-10 is missing the \`TypedArray.prototype.subarray\` function. | |
| * | |
| * - IE10 has a broken \`TypedArray.prototype.subarray\` function which returns arrays of | |
| * incorrect length in some situations. | |
| * We detect these buggy browsers and set \`Buffer.TYPED_ARRAY_SUPPORT\` to \`false\` so they | |
| * get the Object implementation, which is slower but behaves correctly. | |
| */ | |
| Buffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined | |
| ? global.TYPED_ARRAY_SUPPORT | |
| : typedArraySupport() | |
| /* | |
| * Export kMaxLength after typed array support is determined. | |
| */ | |
| exports.kMaxLength = kMaxLength() | |
| function typedArraySupport () { | |
| try { | |
| var arr = new Uint8Array(1) | |
| arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }} | |
| return arr.foo() === 42 && // typed array instances can be augmented | |
| typeof arr.subarray === 'function' && // chrome 9-10 lack \`subarray\` | |
| arr.subarray(1, 1).byteLength === 0 // ie10 has broken \`subarray\` | |
| } catch (e) { | |
| return false | |
| } | |
| } | |
| function kMaxLength () { | |
| return Buffer.TYPED_ARRAY_SUPPORT | |
| ? 0x7fffffff | |
| : 0x3fffffff | |
| } | |
| function createBuffer (that, length) { | |
| if (kMaxLength() < length) { | |
| throw new RangeError('Invalid typed array length') | |
| } | |
| if (Buffer.TYPED_ARRAY_SUPPORT) { | |
| // Return an augmented \`Uint8Array\` instance, for best performance | |
| that = new Uint8Array(length) | |
| that.__proto__ = Buffer.prototype | |
| } else { | |
| // Fallback: Return an object instance of the Buffer class | |
| if (that === null) { | |
| that = new Buffer(length) | |
| } | |
| that.length = length | |
| } | |
| return that | |
| } | |
| /** | |
| * The Buffer constructor returns instances of \`Uint8Array\` that have their | |
| * prototype changed to \`Buffer.prototype\`. Furthermore, \`Buffer\` is a subclass of | |
| * \`Uint8Array\`, so the returned instances will have all the node \`Buffer\` methods | |
| * and the \`Uint8Array\` methods. Square bracket notation works as expected -- it | |
| * returns a single octet. | |
| * | |
| * The \`Uint8Array\` prototype remains unmodified. | |
| */ | |
| function Buffer (arg, encodingOrOffset, length) { | |
| if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) { | |
| return new Buffer(arg, encodingOrOffset, length) | |
| } | |
| // Common case. | |
| if (typeof arg === 'number') { | |
| if (typeof encodingOrOffset === 'string') { | |
| throw new Error( | |
| 'If encoding is specified then the first argument must be a string' | |
| ) | |
| } | |
| return allocUnsafe(this, arg) | |
| } | |
| return from(this, arg, encodingOrOffset, length) | |
| } | |
| Buffer.poolSize = 8192 // not used by this implementation | |
| // TODO: Legacy, not needed anymore. Remove in next major version. | |
| Buffer._augment = function (arr) { | |
| arr.__proto__ = Buffer.prototype | |
| return arr | |
| } | |
| function from (that, value, encodingOrOffset, length) { | |
| if (typeof value === 'number') { | |
| throw new TypeError('"value" argument must not be a number') | |
| } | |
| if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) { | |
| return fromArrayBuffer(that, value, encodingOrOffset, length) | |
| } | |
| if (typeof value === 'string') { | |
| return fromString(that, value, encodingOrOffset) | |
| } | |
| return fromObject(that, value) | |
| } | |
| /** | |
| * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError | |
| * if value is a number. | |
| * Buffer.from(str[, encoding]) | |
| * Buffer.from(array) | |
| * Buffer.from(buffer) | |
| * Buffer.from(arrayBuffer[, byteOffset[, length]]) | |
| **/ | |
| Buffer.from = function (value, encodingOrOffset, length) { | |
| return from(null, value, encodingOrOffset, length) | |
| } | |
| if (Buffer.TYPED_ARRAY_SUPPORT) { | |
| Buffer.prototype.__proto__ = Uint8Array.prototype | |
| Buffer.__proto__ = Uint8Array | |
| if (typeof Symbol !== 'undefined' && Symbol.species && | |
| Buffer[Symbol.species] === Buffer) { | |
| // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97 | |
| Object.defineProperty(Buffer, Symbol.species, { | |
| value: null, | |
| configurable: true | |
| }) | |
| } | |
| } | |
| function assertSize (size) { | |
| if (typeof size !== 'number') { | |
| throw new TypeError('"size" argument must be a number') | |
| } else if (size < 0) { | |
| throw new RangeError('"size" argument must not be negative') | |
| } | |
| } | |
| function alloc (that, size, fill, encoding) { | |
| assertSize(size) | |
| if (size <= 0) { | |
| return createBuffer(that, size) | |
| } | |
| if (fill !== undefined) { | |
| // Only pay attention to encoding if it's a string. This | |
| // prevents accidentally sending in a number that would | |
| // be interpretted as a start offset. | |
| return typeof encoding === 'string' | |
| ? createBuffer(that, size).fill(fill, encoding) | |
| : createBuffer(that, size).fill(fill) | |
| } | |
| return createBuffer(that, size) | |
| } | |
| /** | |
| * Creates a new filled Buffer instance. | |
| * alloc(size[, fill[, encoding]]) | |
| **/ | |
| Buffer.alloc = function (size, fill, encoding) { | |
| return alloc(null, size, fill, encoding) | |
| } | |
| function allocUnsafe (that, size) { | |
| assertSize(size) | |
| that = createBuffer(that, size < 0 ? 0 : checked(size) | 0) | |
| if (!Buffer.TYPED_ARRAY_SUPPORT) { | |
| for (var i = 0; i < size; ++i) { | |
| that[i] = 0 | |
| } | |
| } | |
| return that | |
| } | |
| /** | |
| * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance. | |
| * */ | |
| Buffer.allocUnsafe = function (size) { | |
| return allocUnsafe(null, size) | |
| } | |
| /** | |
| * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance. | |
| */ | |
| Buffer.allocUnsafeSlow = function (size) { | |
| return allocUnsafe(null, size) | |
| } | |
| function fromString (that, string, encoding) { | |
| if (typeof encoding !== 'string' || encoding === '') { | |
| encoding = 'utf8' | |
| } | |
| if (!Buffer.isEncoding(encoding)) { | |
| throw new TypeError('"encoding" must be a valid string encoding') | |
| } | |
| var length = byteLength(string, encoding) | 0 | |
| that = createBuffer(that, length) | |
| var actual = that.write(string, encoding) | |
| if (actual !== length) { | |
| // Writing a hex string, for example, that contains invalid characters will | |
| // cause everything after the first invalid character to be ignored. (e.g. | |
| // 'abxxcd' will be treated as 'ab') | |
| that = that.slice(0, actual) | |
| } | |
| return that | |
| } | |
| function fromArrayLike (that, array) { | |
| var length = array.length < 0 ? 0 : checked(array.length) | 0 | |
| that = createBuffer(that, length) | |
| for (var i = 0; i < length; i += 1) { | |
| that[i] = array[i] & 255 | |
| } | |
| return that | |
| } | |
| function fromArrayBuffer (that, array, byteOffset, length) { | |
| array.byteLength // this throws if \`array\` is not a valid ArrayBuffer | |
| if (byteOffset < 0 || array.byteLength < byteOffset) { | |
| throw new RangeError('\\'offset\\' is out of bounds') | |
| } | |
| if (array.byteLength < byteOffset + (length || 0)) { | |
| throw new RangeError('\\'length\\' is out of bounds') | |
| } | |
| if (byteOffset === undefined && length === undefined) { | |
| array = new Uint8Array(array) | |
| } else if (length === undefined) { | |
| array = new Uint8Array(array, byteOffset) | |
| } else { | |
| array = new Uint8Array(array, byteOffset, length) | |
| } | |
| if (Buffer.TYPED_ARRAY_SUPPORT) { | |
| // Return an augmented \`Uint8Array\` instance, for best performance | |
| that = array | |
| that.__proto__ = Buffer.prototype | |
| } else { | |
| // Fallback: Return an object instance of the Buffer class | |
| that = fromArrayLike(that, array) | |
| } | |
| return that | |
| } | |
| function fromObject (that, obj) { | |
| if (Buffer.isBuffer(obj)) { | |
| var len = checked(obj.length) | 0 | |
| that = createBuffer(that, len) | |
| if (that.length === 0) { | |
| return that | |
| } | |
| obj.copy(that, 0, 0, len) | |
| return that | |
| } | |
| if (obj) { | |
| if ((typeof ArrayBuffer !== 'undefined' && | |
| obj.buffer instanceof ArrayBuffer) || 'length' in obj) { | |
| if (typeof obj.length !== 'number' || isnan(obj.length)) { | |
| return createBuffer(that, 0) | |
| } | |
| return fromArrayLike(that, obj) | |
| } | |
| if (obj.type === 'Buffer' && isArray(obj.data)) { | |
| return fromArrayLike(that, obj.data) | |
| } | |
| } | |
| throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.') | |
| } | |
| function checked (length) { | |
| // Note: cannot use \`length < kMaxLength()\` here because that fails when | |
| // length is NaN (which is otherwise coerced to zero.) | |
| if (length >= kMaxLength()) { | |
| throw new RangeError('Attempt to allocate Buffer larger than maximum ' + | |
| 'size: 0x' + kMaxLength().toString(16) + ' bytes') | |
| } | |
| return length | 0 | |
| } | |
| function SlowBuffer (length) { | |
| if (+length != length) { // eslint-disable-line eqeqeq | |
| length = 0 | |
| } | |
| return Buffer.alloc(+length) | |
| } | |
| Buffer.isBuffer = function isBuffer (b) { | |
| return !!(b != null && b._isBuffer) | |
| } | |
| Buffer.compare = function compare (a, b) { | |
| if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) { | |
| throw new TypeError('Arguments must be Buffers') | |
| } | |
| if (a === b) return 0 | |
| var x = a.length | |
| var y = b.length | |
| for (var i = 0, len = Math.min(x, y); i < len; ++i) { | |
| if (a[i] !== b[i]) { | |
| x = a[i] | |
| y = b[i] | |
| break | |
| } | |
| } | |
| if (x < y) return -1 | |
| if (y < x) return 1 | |
| return 0 | |
| } | |
| Buffer.isEncoding = function isEncoding (encoding) { | |
| switch (String(encoding).toLowerCase()) { | |
| case 'hex': | |
| case 'utf8': | |
| case 'utf-8': | |
| case 'ascii': | |
| case 'latin1': | |
| case 'binary': | |
| case 'base64': | |
| case 'ucs2': | |
| case 'ucs-2': | |
| case 'utf16le': | |
| case 'utf-16le': | |
| return true | |
| default: | |
| return false | |
| } | |
| } | |
| Buffer.concat = function concat (list, length) { | |
| if (!isArray(list)) { | |
| throw new TypeError('"list" argument must be an Array of Buffers') | |
| } | |
| if (list.length === 0) { | |
| return Buffer.alloc(0) | |
| } | |
| var i | |
| if (length === undefined) { | |
| length = 0 | |
| for (i = 0; i < list.length; ++i) { | |
| length += list[i].length | |
| } | |
| } | |
| var buffer = Buffer.allocUnsafe(length) | |
| var pos = 0 | |
| for (i = 0; i < list.length; ++i) { | |
| var buf = list[i] | |
| if (!Buffer.isBuffer(buf)) { | |
| throw new TypeError('"list" argument must be an Array of Buffers') | |
| } | |
| buf.copy(buffer, pos) | |
| pos += buf.length | |
| } | |
| return buffer | |
| } | |
| function byteLength (string, encoding) { | |
| if (Buffer.isBuffer(string)) { | |
| return string.length | |
| } | |
| if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' && | |
| (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) { | |
| return string.byteLength | |
| } | |
| if (typeof string !== 'string') { | |
| string = '' + string | |
| } | |
| var len = string.length | |
| if (len === 0) return 0 | |
| // Use a for loop to avoid recursion | |
| var loweredCase = false | |
| for (;;) { | |
| switch (encoding) { | |
| case 'ascii': | |
| case 'latin1': | |
| case 'binary': | |
| return len | |
| case 'utf8': | |
| case 'utf-8': | |
| case undefined: | |
| return utf8ToBytes(string).length | |
| case 'ucs2': | |
| case 'ucs-2': | |
| case 'utf16le': | |
| case 'utf-16le': | |
| return len * 2 | |
| case 'hex': | |
| return len >>> 1 | |
| case 'base64': | |
| return base64ToBytes(string).length | |
| default: | |
| if (loweredCase) return utf8ToBytes(string).length // assume utf8 | |
| encoding = ('' + encoding).toLowerCase() | |
| loweredCase = true | |
| } | |
| } | |
| } | |
| Buffer.byteLength = byteLength | |
| function slowToString (encoding, start, end) { | |
| var loweredCase = false | |
| // No need to verify that "this.length <= MAX_UINT32" since it's a read-only | |
| // property of a typed array. | |
| // This behaves neither like String nor Uint8Array in that we set start/end | |
| // to their upper/lower bounds if the value passed is out of range. | |
| // undefined is handled specially as per ECMA-262 6th Edition, | |
| // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization. | |
| if (start === undefined || start < 0) { | |
| start = 0 | |
| } | |
| // Return early if start > this.length. Done here to prevent potential uint32 | |
| // coercion fail below. | |
| if (start > this.length) { | |
| return '' | |
| } | |
| if (end === undefined || end > this.length) { | |
| end = this.length | |
| } | |
| if (end <= 0) { | |
| return '' | |
| } | |
| // Force coersion to uint32. This will also coerce falsey/NaN values to 0. | |
| end >>>= 0 | |
| start >>>= 0 | |
| if (end <= start) { | |
| return '' | |
| } | |
| if (!encoding) encoding = 'utf8' | |
| while (true) { | |
| switch (encoding) { | |
| case 'hex': | |
| return hexSlice(this, start, end) | |
| case 'utf8': | |
| case 'utf-8': | |
| return utf8Slice(this, start, end) | |
| case 'ascii': | |
| return asciiSlice(this, start, end) | |
| case 'latin1': | |
| case 'binary': | |
| return latin1Slice(this, start, end) | |
| case 'base64': | |
| return base64Slice(this, start, end) | |
| case 'ucs2': | |
| case 'ucs-2': | |
| case 'utf16le': | |
| case 'utf-16le': | |
| return utf16leSlice(this, start, end) | |
| default: | |
| if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) | |
| encoding = (encoding + '').toLowerCase() | |
| loweredCase = true | |
| } | |
| } | |
| } | |
| // The property is used by \`Buffer.isBuffer\` and \`is-buffer\` (in Safari 5-7) to detect | |
| // Buffer instances. | |
| Buffer.prototype._isBuffer = true | |
| function swap (b, n, m) { | |
| var i = b[n] | |
| b[n] = b[m] | |
| b[m] = i | |
| } | |
| Buffer.prototype.swap16 = function swap16 () { | |
| var len = this.length | |
| if (len % 2 !== 0) { | |
| throw new RangeError('Buffer size must be a multiple of 16-bits') | |
| } | |
| for (var i = 0; i < len; i += 2) { | |
| swap(this, i, i + 1) | |
| } | |
| return this | |
| } | |
| Buffer.prototype.swap32 = function swap32 () { | |
| var len = this.length | |
| if (len % 4 !== 0) { | |
| throw new RangeError('Buffer size must be a multiple of 32-bits') | |
| } | |
| for (var i = 0; i < len; i += 4) { | |
| swap(this, i, i + 3) | |
| swap(this, i + 1, i + 2) | |
| } | |
| return this | |
| } | |
| Buffer.prototype.swap64 = function swap64 () { | |
| var len = this.length | |
| if (len % 8 !== 0) { | |
| throw new RangeError('Buffer size must be a multiple of 64-bits') | |
| } | |
| for (var i = 0; i < len; i += 8) { | |
| swap(this, i, i + 7) | |
| swap(this, i + 1, i + 6) | |
| swap(this, i + 2, i + 5) | |
| swap(this, i + 3, i + 4) | |
| } | |
| return this | |
| } | |
| Buffer.prototype.toString = function toString () { | |
| var length = this.length | 0 | |
| if (length === 0) return '' | |
| if (arguments.length === 0) return utf8Slice(this, 0, length) | |
| return slowToString.apply(this, arguments) | |
| } | |
| Buffer.prototype.equals = function equals (b) { | |
| if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer') | |
| if (this === b) return true | |
| return Buffer.compare(this, b) === 0 | |
| } | |
| Buffer.prototype.inspect = function inspect () { | |
| var str = '' | |
| var max = exports.INSPECT_MAX_BYTES | |
| if (this.length > 0) { | |
| str = this.toString('hex', 0, max).match(/.{2}/g).join(' ') | |
| if (this.length > max) str += ' ... ' | |
| } | |
| return '<Buffer ' + str + '>' | |
| } | |
| Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) { | |
| if (!Buffer.isBuffer(target)) { | |
| throw new TypeError('Argument must be a Buffer') | |
| } | |
| if (start === undefined) { | |
| start = 0 | |
| } | |
| if (end === undefined) { | |
| end = target ? target.length : 0 | |
| } | |
| if (thisStart === undefined) { | |
| thisStart = 0 | |
| } | |
| if (thisEnd === undefined) { | |
| thisEnd = this.length | |
| } | |
| if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) { | |
| throw new RangeError('out of range index') | |
| } | |
| if (thisStart >= thisEnd && start >= end) { | |
| return 0 | |
| } | |
| if (thisStart >= thisEnd) { | |
| return -1 | |
| } | |
| if (start >= end) { | |
| return 1 | |
| } | |
| start >>>= 0 | |
| end >>>= 0 | |
| thisStart >>>= 0 | |
| thisEnd >>>= 0 | |
| if (this === target) return 0 | |
| var x = thisEnd - thisStart | |
| var y = end - start | |
| var len = Math.min(x, y) | |
| var thisCopy = this.slice(thisStart, thisEnd) | |
| var targetCopy = target.slice(start, end) | |
| for (var i = 0; i < len; ++i) { | |
| if (thisCopy[i] !== targetCopy[i]) { | |
| x = thisCopy[i] | |
| y = targetCopy[i] | |
| break | |
| } | |
| } | |
| if (x < y) return -1 | |
| if (y < x) return 1 | |
| return 0 | |
| } | |
| // Finds either the first index of \`val\` in \`buffer\` at offset >= \`byteOffset\`, | |
| // OR the last index of \`val\` in \`buffer\` at offset <= \`byteOffset\`. | |
| // | |
| // Arguments: | |
| // - buffer - a Buffer to search | |
| // - val - a string, Buffer, or number | |
| // - byteOffset - an index into \`buffer\`; will be clamped to an int32 | |
| // - encoding - an optional encoding, relevant is val is a string | |
| // - dir - true for indexOf, false for lastIndexOf | |
| function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) { | |
| // Empty buffer means no match | |
| if (buffer.length === 0) return -1 | |
| // Normalize byteOffset | |
| if (typeof byteOffset === 'string') { | |
| encoding = byteOffset | |
| byteOffset = 0 | |
| } else if (byteOffset > 0x7fffffff) { | |
| byteOffset = 0x7fffffff | |
| } else if (byteOffset < -0x80000000) { | |
| byteOffset = -0x80000000 | |
| } | |
| byteOffset = +byteOffset // Coerce to Number. | |
| if (isNaN(byteOffset)) { | |
| // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer | |
| byteOffset = dir ? 0 : (buffer.length - 1) | |
| } | |
| // Normalize byteOffset: negative offsets start from the end of the buffer | |
| if (byteOffset < 0) byteOffset = buffer.length + byteOffset | |
| if (byteOffset >= buffer.length) { | |
| if (dir) return -1 | |
| else byteOffset = buffer.length - 1 | |
| } else if (byteOffset < 0) { | |
| if (dir) byteOffset = 0 | |
| else return -1 | |
| } | |
| // Normalize val | |
| if (typeof val === 'string') { | |
| val = Buffer.from(val, encoding) | |
| } | |
| // Finally, search either indexOf (if dir is true) or lastIndexOf | |
| if (Buffer.isBuffer(val)) { | |
| // Special case: looking for empty string/buffer always fails | |
| if (val.length === 0) { | |
| return -1 | |
| } | |
| return arrayIndexOf(buffer, val, byteOffset, encoding, dir) | |
| } else if (typeof val === 'number') { | |
| val = val & 0xFF // Search for a byte value [0-255] | |
| if (Buffer.TYPED_ARRAY_SUPPORT && | |
| typeof Uint8Array.prototype.indexOf === 'function') { | |
| if (dir) { | |
| return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset) | |
| } else { | |
| return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset) | |
| } | |
| } | |
| return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir) | |
| } | |
| throw new TypeError('val must be string, number or Buffer') | |
| } | |
| function arrayIndexOf (arr, val, byteOffset, encoding, dir) { | |
| var indexSize = 1 | |
| var arrLength = arr.length | |
| var valLength = val.length | |
| if (encoding !== undefined) { | |
| encoding = String(encoding).toLowerCase() | |
| if (encoding === 'ucs2' || encoding === 'ucs-2' || | |
| encoding === 'utf16le' || encoding === 'utf-16le') { | |
| if (arr.length < 2 || val.length < 2) { | |
| return -1 | |
| } | |
| indexSize = 2 | |
| arrLength /= 2 | |
| valLength /= 2 | |
| byteOffset /= 2 | |
| } | |
| } | |
| function read (buf, i) { | |
| if (indexSize === 1) { | |
| return buf[i] | |
| } else { | |
| return buf.readUInt16BE(i * indexSize) | |
| } | |
| } | |
| var i | |
| if (dir) { | |
| var foundIndex = -1 | |
| for (i = byteOffset; i < arrLength; i++) { | |
| if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) { | |
| if (foundIndex === -1) foundIndex = i | |
| if (i - foundIndex + 1 === valLength) return foundIndex * indexSize | |
| } else { | |
| if (foundIndex !== -1) i -= i - foundIndex | |
| foundIndex = -1 | |
| } | |
| } | |
| } else { | |
| if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength | |
| for (i = byteOffset; i >= 0; i--) { | |
| var found = true | |
| for (var j = 0; j < valLength; j++) { | |
| if (read(arr, i + j) !== read(val, j)) { | |
| found = false | |
| break | |
| } | |
| } | |
| if (found) return i | |
| } | |
| } | |
| return -1 | |
| } | |
| Buffer.prototype.includes = function includes (val, byteOffset, encoding) { | |
| return this.indexOf(val, byteOffset, encoding) !== -1 | |
| } | |
| Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) { | |
| return bidirectionalIndexOf(this, val, byteOffset, encoding, true) | |
| } | |
| Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) { | |
| return bidirectionalIndexOf(this, val, byteOffset, encoding, false) | |
| } | |
| function hexWrite (buf, string, offset, length) { | |
| offset = Number(offset) || 0 | |
| var remaining = buf.length - offset | |
| if (!length) { | |
| length = remaining | |
| } else { | |
| length = Number(length) | |
| if (length > remaining) { | |
| length = remaining | |
| } | |
| } | |
| // must be an even number of digits | |
| var strLen = string.length | |
| if (strLen % 2 !== 0) throw new TypeError('Invalid hex string') | |
| if (length > strLen / 2) { | |
| length = strLen / 2 | |
| } | |
| for (var i = 0; i < length; ++i) { | |
| var parsed = parseInt(string.substr(i * 2, 2), 16) | |
| if (isNaN(parsed)) return i | |
| buf[offset + i] = parsed | |
| } | |
| return i | |
| } | |
| function utf8Write (buf, string, offset, length) { | |
| return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length) | |
| } | |
| function asciiWrite (buf, string, offset, length) { | |
| return blitBuffer(asciiToBytes(string), buf, offset, length) | |
| } | |
| function latin1Write (buf, string, offset, length) { | |
| return asciiWrite(buf, string, offset, length) | |
| } | |
| function base64Write (buf, string, offset, length) { | |
| return blitBuffer(base64ToBytes(string), buf, offset, length) | |
| } | |
| function ucs2Write (buf, string, offset, length) { | |
| return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length) | |
| } | |
| Buffer.prototype.write = function write (string, offset, length, encoding) { | |
| // Buffer#write(string) | |
| if (offset === undefined) { | |
| encoding = 'utf8' | |
| length = this.length | |
| offset = 0 | |
| // Buffer#write(string, encoding) | |
| } else if (length === undefined && typeof offset === 'string') { | |
| encoding = offset | |
| length = this.length | |
| offset = 0 | |
| // Buffer#write(string, offset[, length][, encoding]) | |
| } else if (isFinite(offset)) { | |
| offset = offset | 0 | |
| if (isFinite(length)) { | |
| length = length | 0 | |
| if (encoding === undefined) encoding = 'utf8' | |
| } else { | |
| encoding = length | |
| length = undefined | |
| } | |
| // legacy write(string, encoding, offset, length) - remove in v0.13 | |
| } else { | |
| throw new Error( | |
| 'Buffer.write(string, encoding, offset[, length]) is no longer supported' | |
| ) | |
| } | |
| var remaining = this.length - offset | |
| if (length === undefined || length > remaining) length = remaining | |
| if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) { | |
| throw new RangeError('Attempt to write outside buffer bounds') | |
| } | |
| if (!encoding) encoding = 'utf8' | |
| var loweredCase = false | |
| for (;;) { | |
| switch (encoding) { | |
| case 'hex': | |
| return hexWrite(this, string, offset, length) | |
| case 'utf8': | |
| case 'utf-8': | |
| return utf8Write(this, string, offset, length) | |
| case 'ascii': | |
| return asciiWrite(this, string, offset, length) | |
| case 'latin1': | |
| case 'binary': | |
| return latin1Write(this, string, offset, length) | |
| case 'base64': | |
| // Warning: maxLength not taken into account in base64Write | |
| return base64Write(this, string, offset, length) | |
| case 'ucs2': | |
| case 'ucs-2': | |
| case 'utf16le': | |
| case 'utf-16le': | |
| return ucs2Write(this, string, offset, length) | |
| default: | |
| if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) | |
| encoding = ('' + encoding).toLowerCase() | |
| loweredCase = true | |
| } | |
| } | |
| } | |
| Buffer.prototype.toJSON = function toJSON () { | |
| return { | |
| type: 'Buffer', | |
| data: Array.prototype.slice.call(this._arr || this, 0) | |
| } | |
| } | |
| function base64Slice (buf, start, end) { | |
| if (start === 0 && end === buf.length) { | |
| return base64.fromByteArray(buf) | |
| } else { | |
| return base64.fromByteArray(buf.slice(start, end)) | |
| } | |
| } | |
| function utf8Slice (buf, start, end) { | |
| end = Math.min(buf.length, end) | |
| var res = [] | |
| var i = start | |
| while (i < end) { | |
| var firstByte = buf[i] | |
| var codePoint = null | |
| var bytesPerSequence = (firstByte > 0xEF) ? 4 | |
| : (firstByte > 0xDF) ? 3 | |
| : (firstByte > 0xBF) ? 2 | |
| : 1 | |
| if (i + bytesPerSequence <= end) { | |
| var secondByte, thirdByte, fourthByte, tempCodePoint | |
| switch (bytesPerSequence) { | |
| case 1: | |
| if (firstByte < 0x80) { | |
| codePoint = firstByte | |
| } | |
| break | |
| case 2: | |
| secondByte = buf[i + 1] | |
| if ((secondByte & 0xC0) === 0x80) { | |
| tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F) | |
| if (tempCodePoint > 0x7F) { | |
| codePoint = tempCodePoint | |
| } | |
| } | |
| break | |
| case 3: | |
| secondByte = buf[i + 1] | |
| thirdByte = buf[i + 2] | |
| if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) { | |
| tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F) | |
| if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) { | |
| codePoint = tempCodePoint | |
| } | |
| } | |
| break | |
| case 4: | |
| secondByte = buf[i + 1] | |
| thirdByte = buf[i + 2] | |
| fourthByte = buf[i + 3] | |
| if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) { | |
| tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F) | |
| if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) { | |
| codePoint = tempCodePoint | |
| } | |
| } | |
| } | |
| } | |
| if (codePoint === null) { | |
| // we did not generate a valid codePoint so insert a | |
| // replacement char (U+FFFD) and advance only 1 byte | |
| codePoint = 0xFFFD | |
| bytesPerSequence = 1 | |
| } else if (codePoint > 0xFFFF) { | |
| // encode to utf16 (surrogate pair dance) | |
| codePoint -= 0x10000 | |
| res.push(codePoint >>> 10 & 0x3FF | 0xD800) | |
| codePoint = 0xDC00 | codePoint & 0x3FF | |
| } | |
| res.push(codePoint) | |
| i += bytesPerSequence | |
| } | |
| return decodeCodePointsArray(res) | |
| } | |
| // Based on http://stackoverflow.com/a/22747272/680742, the browser with | |
| // the lowest limit is Chrome, with 0x10000 args. | |
| // We go 1 magnitude less, for safety | |
| var MAX_ARGUMENTS_LENGTH = 0x1000 | |
| function decodeCodePointsArray (codePoints) { | |
| var len = codePoints.length | |
| if (len <= MAX_ARGUMENTS_LENGTH) { | |
| return String.fromCharCode.apply(String, codePoints) // avoid extra slice() | |
| } | |
| // Decode in chunks to avoid "call stack size exceeded". | |
| var res = '' | |
| var i = 0 | |
| while (i < len) { | |
| res += String.fromCharCode.apply( | |
| String, | |
| codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH) | |
| ) | |
| } | |
| return res | |
| } | |
| function asciiSlice (buf, start, end) { | |
| var ret = '' | |
| end = Math.min(buf.length, end) | |
| for (var i = start; i < end; ++i) { | |
| ret += String.fromCharCode(buf[i] & 0x7F) | |
| } | |
| return ret | |
| } | |
| function latin1Slice (buf, start, end) { | |
| var ret = '' | |
| end = Math.min(buf.length, end) | |
| for (var i = start; i < end; ++i) { | |
| ret += String.fromCharCode(buf[i]) | |
| } | |
| return ret | |
| } | |
| function hexSlice (buf, start, end) { | |
| var len = buf.length | |
| if (!start || start < 0) start = 0 | |
| if (!end || end < 0 || end > len) end = len | |
| var out = '' | |
| for (var i = start; i < end; ++i) { | |
| out += toHex(buf[i]) | |
| } | |
| return out | |
| } | |
| function utf16leSlice (buf, start, end) { | |
| var bytes = buf.slice(start, end) | |
| var res = '' | |
| for (var i = 0; i < bytes.length; i += 2) { | |
| res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256) | |
| } | |
| return res | |
| } | |
| Buffer.prototype.slice = function slice (start, end) { | |
| var len = this.length | |
| start = ~~start | |
| end = end === undefined ? len : ~~end | |
| if (start < 0) { | |
| start += len | |
| if (start < 0) start = 0 | |
| } else if (start > len) { | |
| start = len | |
| } | |
| if (end < 0) { | |
| end += len | |
| if (end < 0) end = 0 | |
| } else if (end > len) { | |
| end = len | |
| } | |
| if (end < start) end = start | |
| var newBuf | |
| if (Buffer.TYPED_ARRAY_SUPPORT) { | |
| newBuf = this.subarray(start, end) | |
| newBuf.__proto__ = Buffer.prototype | |
| } else { | |
| var sliceLen = end - start | |
| newBuf = new Buffer(sliceLen, undefined) | |
| for (var i = 0; i < sliceLen; ++i) { | |
| newBuf[i] = this[i + start] | |
| } | |
| } | |
| return newBuf | |
| } | |
| /* | |
| * Need to make sure that buffer isn't trying to write out of bounds. | |
| */ | |
| function checkOffset (offset, ext, length) { | |
| if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint') | |
| if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length') | |
| } | |
| Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) { | |
| offset = offset | 0 | |
| byteLength = byteLength | 0 | |
| if (!noAssert) checkOffset(offset, byteLength, this.length) | |
| var val = this[offset] | |
| var mul = 1 | |
| var i = 0 | |
| while (++i < byteLength && (mul *= 0x100)) { | |
| val += this[offset + i] * mul | |
| } | |
| return val | |
| } | |
| Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) { | |
| offset = offset | 0 | |
| byteLength = byteLength | 0 | |
| if (!noAssert) { | |
| checkOffset(offset, byteLength, this.length) | |
| } | |
| var val = this[offset + --byteLength] | |
| var mul = 1 | |
| while (byteLength > 0 && (mul *= 0x100)) { | |
| val += this[offset + --byteLength] * mul | |
| } | |
| return val | |
| } | |
| Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) { | |
| if (!noAssert) checkOffset(offset, 1, this.length) | |
| return this[offset] | |
| } | |
| Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) { | |
| if (!noAssert) checkOffset(offset, 2, this.length) | |
| return this[offset] | (this[offset + 1] << 8) | |
| } | |
| Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) { | |
| if (!noAssert) checkOffset(offset, 2, this.length) | |
| return (this[offset] << 8) | this[offset + 1] | |
| } | |
| Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) { | |
| if (!noAssert) checkOffset(offset, 4, this.length) | |
| return ((this[offset]) | | |
| (this[offset + 1] << 8) | | |
| (this[offset + 2] << 16)) + | |
| (this[offset + 3] * 0x1000000) | |
| } | |
| Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) { | |
| if (!noAssert) checkOffset(offset, 4, this.length) | |
| return (this[offset] * 0x1000000) + | |
| ((this[offset + 1] << 16) | | |
| (this[offset + 2] << 8) | | |
| this[offset + 3]) | |
| } | |
| Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) { | |
| offset = offset | 0 | |
| byteLength = byteLength | 0 | |
| if (!noAssert) checkOffset(offset, byteLength, this.length) | |
| var val = this[offset] | |
| var mul = 1 | |
| var i = 0 | |
| while (++i < byteLength && (mul *= 0x100)) { | |
| val += this[offset + i] * mul | |
| } | |
| mul *= 0x80 | |
| if (val >= mul) val -= Math.pow(2, 8 * byteLength) | |
| return val | |
| } | |
| Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) { | |
| offset = offset | 0 | |
| byteLength = byteLength | 0 | |
| if (!noAssert) checkOffset(offset, byteLength, this.length) | |
| var i = byteLength | |
| var mul = 1 | |
| var val = this[offset + --i] | |
| while (i > 0 && (mul *= 0x100)) { | |
| val += this[offset + --i] * mul | |
| } | |
| mul *= 0x80 | |
| if (val >= mul) val -= Math.pow(2, 8 * byteLength) | |
| return val | |
| } | |
| Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) { | |
| if (!noAssert) checkOffset(offset, 1, this.length) | |
| if (!(this[offset] & 0x80)) return (this[offset]) | |
| return ((0xff - this[offset] + 1) * -1) | |
| } | |
| Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) { | |
| if (!noAssert) checkOffset(offset, 2, this.length) | |
| var val = this[offset] | (this[offset + 1] << 8) | |
| return (val & 0x8000) ? val | 0xFFFF0000 : val | |
| } | |
| Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) { | |
| if (!noAssert) checkOffset(offset, 2, this.length) | |
| var val = this[offset + 1] | (this[offset] << 8) | |
| return (val & 0x8000) ? val | 0xFFFF0000 : val | |
| } | |
| Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) { | |
| if (!noAssert) checkOffset(offset, 4, this.length) | |
| return (this[offset]) | | |
| (this[offset + 1] << 8) | | |
| (this[offset + 2] << 16) | | |
| (this[offset + 3] << 24) | |
| } | |
| Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) { | |
| if (!noAssert) checkOffset(offset, 4, this.length) | |
| return (this[offset] << 24) | | |
| (this[offset + 1] << 16) | | |
| (this[offset + 2] << 8) | | |
| (this[offset + 3]) | |
| } | |
| Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) { | |
| if (!noAssert) checkOffset(offset, 4, this.length) | |
| return ieee754.read(this, offset, true, 23, 4) | |
| } | |
| Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) { | |
| if (!noAssert) checkOffset(offset, 4, this.length) | |
| return ieee754.read(this, offset, false, 23, 4) | |
| } | |
| Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) { | |
| if (!noAssert) checkOffset(offset, 8, this.length) | |
| return ieee754.read(this, offset, true, 52, 8) | |
| } | |
| Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) { | |
| if (!noAssert) checkOffset(offset, 8, this.length) | |
| return ieee754.read(this, offset, false, 52, 8) | |
| } | |
| function checkInt (buf, value, offset, ext, max, min) { | |
| if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance') | |
| if (value > max || value < min) throw new RangeError('"value" argument is out of bounds') | |
| if (offset + ext > buf.length) throw new RangeError('Index out of range') | |
| } | |
| Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) { | |
| value = +value | |
| offset = offset | 0 | |
| byteLength = byteLength | 0 | |
| if (!noAssert) { | |
| var maxBytes = Math.pow(2, 8 * byteLength) - 1 | |
| checkInt(this, value, offset, byteLength, maxBytes, 0) | |
| } | |
| var mul = 1 | |
| var i = 0 | |
| this[offset] = value & 0xFF | |
| while (++i < byteLength && (mul *= 0x100)) { | |
| this[offset + i] = (value / mul) & 0xFF | |
| } | |
| return offset + byteLength | |
| } | |
| Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) { | |
| value = +value | |
| offset = offset | 0 | |
| byteLength = byteLength | 0 | |
| if (!noAssert) { | |
| var maxBytes = Math.pow(2, 8 * byteLength) - 1 | |
| checkInt(this, value, offset, byteLength, maxBytes, 0) | |
| } | |
| var i = byteLength - 1 | |
| var mul = 1 | |
| this[offset + i] = value & 0xFF | |
| while (--i >= 0 && (mul *= 0x100)) { | |
| this[offset + i] = (value / mul) & 0xFF | |
| } | |
| return offset + byteLength | |
| } | |
| Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) { | |
| value = +value | |
| offset = offset | 0 | |
| if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0) | |
| if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value) | |
| this[offset] = (value & 0xff) | |
| return offset + 1 | |
| } | |
| function objectWriteUInt16 (buf, value, offset, littleEndian) { | |
| if (value < 0) value = 0xffff + value + 1 | |
| for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) { | |
| buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>> | |
| (littleEndian ? i : 1 - i) * 8 | |
| } | |
| } | |
| Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) { | |
| value = +value | |
| offset = offset | 0 | |
| if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) | |
| if (Buffer.TYPED_ARRAY_SUPPORT) { | |
| this[offset] = (value & 0xff) | |
| this[offset + 1] = (value >>> 8) | |
| } else { | |
| objectWriteUInt16(this, value, offset, true) | |
| } | |
| return offset + 2 | |
| } | |
| Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) { | |
| value = +value | |
| offset = offset | 0 | |
| if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) | |
| if (Buffer.TYPED_ARRAY_SUPPORT) { | |
| this[offset] = (value >>> 8) | |
| this[offset + 1] = (value & 0xff) | |
| } else { | |
| objectWriteUInt16(this, value, offset, false) | |
| } | |
| return offset + 2 | |
| } | |
| function objectWriteUInt32 (buf, value, offset, littleEndian) { | |
| if (value < 0) value = 0xffffffff + value + 1 | |
| for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) { | |
| buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff | |
| } | |
| } | |
| Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) { | |
| value = +value | |
| offset = offset | 0 | |
| if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) | |
| if (Buffer.TYPED_ARRAY_SUPPORT) { | |
| this[offset + 3] = (value >>> 24) | |
| this[offset + 2] = (value >>> 16) | |
| this[offset + 1] = (value >>> 8) | |
| this[offset] = (value & 0xff) | |
| } else { | |
| objectWriteUInt32(this, value, offset, true) | |
| } | |
| return offset + 4 | |
| } | |
| Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) { | |
| value = +value | |
| offset = offset | 0 | |
| if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) | |
| if (Buffer.TYPED_ARRAY_SUPPORT) { | |
| this[offset] = (value >>> 24) | |
| this[offset + 1] = (value >>> 16) | |
| this[offset + 2] = (value >>> 8) | |
| this[offset + 3] = (value & 0xff) | |
| } else { | |
| objectWriteUInt32(this, value, offset, false) | |
| } | |
| return offset + 4 | |
| } | |
| Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) { | |
| value = +value | |
| offset = offset | 0 | |
| if (!noAssert) { | |
| var limit = Math.pow(2, 8 * byteLength - 1) | |
| checkInt(this, value, offset, byteLength, limit - 1, -limit) | |
| } | |
| var i = 0 | |
| var mul = 1 | |
| var sub = 0 | |
| this[offset] = value & 0xFF | |
| while (++i < byteLength && (mul *= 0x100)) { | |
| if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) { | |
| sub = 1 | |
| } | |
| this[offset + i] = ((value / mul) >> 0) - sub & 0xFF | |
| } | |
| return offset + byteLength | |
| } | |
| Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) { | |
| value = +value | |
| offset = offset | 0 | |
| if (!noAssert) { | |
| var limit = Math.pow(2, 8 * byteLength - 1) | |
| checkInt(this, value, offset, byteLength, limit - 1, -limit) | |
| } | |
| var i = byteLength - 1 | |
| var mul = 1 | |
| var sub = 0 | |
| this[offset + i] = value & 0xFF | |
| while (--i >= 0 && (mul *= 0x100)) { | |
| if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) { | |
| sub = 1 | |
| } | |
| this[offset + i] = ((value / mul) >> 0) - sub & 0xFF | |
| } | |
| return offset + byteLength | |
| } | |
| Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) { | |
| value = +value | |
| offset = offset | 0 | |
| if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80) | |
| if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value) | |
| if (value < 0) value = 0xff + value + 1 | |
| this[offset] = (value & 0xff) | |
| return offset + 1 | |
| } | |
| Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) { | |
| value = +value | |
| offset = offset | 0 | |
| if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) | |
| if (Buffer.TYPED_ARRAY_SUPPORT) { | |
| this[offset] = (value & 0xff) | |
| this[offset + 1] = (value >>> 8) | |
| } else { | |
| objectWriteUInt16(this, value, offset, true) | |
| } | |
| return offset + 2 | |
| } | |
| Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) { | |
| value = +value | |
| offset = offset | 0 | |
| if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) | |
| if (Buffer.TYPED_ARRAY_SUPPORT) { | |
| this[offset] = (value >>> 8) | |
| this[offset + 1] = (value & 0xff) | |
| } else { | |
| objectWriteUInt16(this, value, offset, false) | |
| } | |
| return offset + 2 | |
| } | |
| Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) { | |
| value = +value | |
| offset = offset | 0 | |
| if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) | |
| if (Buffer.TYPED_ARRAY_SUPPORT) { | |
| this[offset] = (value & 0xff) | |
| this[offset + 1] = (value >>> 8) | |
| this[offset + 2] = (value >>> 16) | |
| this[offset + 3] = (value >>> 24) | |
| } else { | |
| objectWriteUInt32(this, value, offset, true) | |
| } | |
| return offset + 4 | |
| } | |
| Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) { | |
| value = +value | |
| offset = offset | 0 | |
| if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) | |
| if (value < 0) value = 0xffffffff + value + 1 | |
| if (Buffer.TYPED_ARRAY_SUPPORT) { | |
| this[offset] = (value >>> 24) | |
| this[offset + 1] = (value >>> 16) | |
| this[offset + 2] = (value >>> 8) | |
| this[offset + 3] = (value & 0xff) | |
| } else { | |
| objectWriteUInt32(this, value, offset, false) | |
| } | |
| return offset + 4 | |
| } | |
| function checkIEEE754 (buf, value, offset, ext, max, min) { | |
| if (offset + ext > buf.length) throw new RangeError('Index out of range') | |
| if (offset < 0) throw new RangeError('Index out of range') | |
| } | |
| function writeFloat (buf, value, offset, littleEndian, noAssert) { | |
| if (!noAssert) { | |
| checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38) | |
| } | |
| ieee754.write(buf, value, offset, littleEndian, 23, 4) | |
| return offset + 4 | |
| } | |
| Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) { | |
| return writeFloat(this, value, offset, true, noAssert) | |
| } | |
| Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) { | |
| return writeFloat(this, value, offset, false, noAssert) | |
| } | |
| function writeDouble (buf, value, offset, littleEndian, noAssert) { | |
| if (!noAssert) { | |
| checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308) | |
| } | |
| ieee754.write(buf, value, offset, littleEndian, 52, 8) | |
| return offset + 8 | |
| } | |
| Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) { | |
| return writeDouble(this, value, offset, true, noAssert) | |
| } | |
| Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) { | |
| return writeDouble(this, value, offset, false, noAssert) | |
| } | |
| // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length) | |
| Buffer.prototype.copy = function copy (target, targetStart, start, end) { | |
| if (!start) start = 0 | |
| if (!end && end !== 0) end = this.length | |
| if (targetStart >= target.length) targetStart = target.length | |
| if (!targetStart) targetStart = 0 | |
| if (end > 0 && end < start) end = start | |
| // Copy 0 bytes; we're done | |
| if (end === start) return 0 | |
| if (target.length === 0 || this.length === 0) return 0 | |
| // Fatal error conditions | |
| if (targetStart < 0) { | |
| throw new RangeError('targetStart out of bounds') | |
| } | |
| if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds') | |
| if (end < 0) throw new RangeError('sourceEnd out of bounds') | |
| // Are we oob? | |
| if (end > this.length) end = this.length | |
| if (target.length - targetStart < end - start) { | |
| end = target.length - targetStart + start | |
| } | |
| var len = end - start | |
| var i | |
| if (this === target && start < targetStart && targetStart < end) { | |
| // descending copy from end | |
| for (i = len - 1; i >= 0; --i) { | |
| target[i + targetStart] = this[i + start] | |
| } | |
| } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) { | |
| // ascending copy from start | |
| for (i = 0; i < len; ++i) { | |
| target[i + targetStart] = this[i + start] | |
| } | |
| } else { | |
| Uint8Array.prototype.set.call( | |
| target, | |
| this.subarray(start, start + len), | |
| targetStart | |
| ) | |
| } | |
| return len | |
| } | |
| // Usage: | |
| // buffer.fill(number[, offset[, end]]) | |
| // buffer.fill(buffer[, offset[, end]]) | |
| // buffer.fill(string[, offset[, end]][, encoding]) | |
| Buffer.prototype.fill = function fill (val, start, end, encoding) { | |
| // Handle string cases: | |
| if (typeof val === 'string') { | |
| if (typeof start === 'string') { | |
| encoding = start | |
| start = 0 | |
| end = this.length | |
| } else if (typeof end === 'string') { | |
| encoding = end | |
| end = this.length | |
| } | |
| if (val.length === 1) { | |
| var code = val.charCodeAt(0) | |
| if (code < 256) { | |
| val = code | |
| } | |
| } | |
| if (encoding !== undefined && typeof encoding !== 'string') { | |
| throw new TypeError('encoding must be a string') | |
| } | |
| if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) { | |
| throw new TypeError('Unknown encoding: ' + encoding) | |
| } | |
| } else if (typeof val === 'number') { | |
| val = val & 255 | |
| } | |
| // Invalid ranges are not set to a default, so can range check early. | |
| if (start < 0 || this.length < start || this.length < end) { | |
| throw new RangeError('Out of range index') | |
| } | |
| if (end <= start) { | |
| return this | |
| } | |
| start = start >>> 0 | |
| end = end === undefined ? this.length : end >>> 0 | |
| if (!val) val = 0 | |
| var i | |
| if (typeof val === 'number') { | |
| for (i = start; i < end; ++i) { | |
| this[i] = val | |
| } | |
| } else { | |
| var bytes = Buffer.isBuffer(val) | |
| ? val | |
| : utf8ToBytes(new Buffer(val, encoding).toString()) | |
| var len = bytes.length | |
| for (i = 0; i < end - start; ++i) { | |
| this[i + start] = bytes[i % len] | |
| } | |
| } | |
| return this | |
| } | |
| // HELPER FUNCTIONS | |
| // ================ | |
| var INVALID_BASE64_RE = /[^+\\/0-9A-Za-z-_]/g | |
| function base64clean (str) { | |
| // Node strips out invalid characters like \\n and \\t from the string, base64-js does not | |
| str = stringtrim(str).replace(INVALID_BASE64_RE, '') | |
| // Node converts strings with length < 2 to '' | |
| if (str.length < 2) return '' | |
| // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not | |
| while (str.length % 4 !== 0) { | |
| str = str + '=' | |
| } | |
| return str | |
| } | |
| function stringtrim (str) { | |
| if (str.trim) return str.trim() | |
| return str.replace(/^\\s+|\\s+$/g, '') | |
| } | |
| function toHex (n) { | |
| if (n < 16) return '0' + n.toString(16) | |
| return n.toString(16) | |
| } | |
| function utf8ToBytes (string, units) { | |
| units = units || Infinity | |
| var codePoint | |
| var length = string.length | |
| var leadSurrogate = null | |
| var bytes = [] | |
| for (var i = 0; i < length; ++i) { | |
| codePoint = string.charCodeAt(i) | |
| // is surrogate component | |
| if (codePoint > 0xD7FF && codePoint < 0xE000) { | |
| // last char was a lead | |
| if (!leadSurrogate) { | |
| // no lead yet | |
| if (codePoint > 0xDBFF) { | |
| // unexpected trail | |
| if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) | |
| continue | |
| } else if (i + 1 === length) { | |
| // unpaired lead | |
| if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) | |
| continue | |
| } | |
| // valid lead | |
| leadSurrogate = codePoint | |
| continue | |
| } | |
| // 2 leads in a row | |
| if (codePoint < 0xDC00) { | |
| if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) | |
| leadSurrogate = codePoint | |
| continue | |
| } | |
| // valid surrogate pair | |
| codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000 | |
| } else if (leadSurrogate) { | |
| // valid bmp char, but last char was a lead | |
| if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) | |
| } | |
| leadSurrogate = null | |
| // encode utf8 | |
| if (codePoint < 0x80) { | |
| if ((units -= 1) < 0) break | |
| bytes.push(codePoint) | |
| } else if (codePoint < 0x800) { | |
| if ((units -= 2) < 0) break | |
| bytes.push( | |
| codePoint >> 0x6 | 0xC0, | |
| codePoint & 0x3F | 0x80 | |
| ) | |
| } else if (codePoint < 0x10000) { | |
| if ((units -= 3) < 0) break | |
| bytes.push( | |
| codePoint >> 0xC | 0xE0, | |
| codePoint >> 0x6 & 0x3F | 0x80, | |
| codePoint & 0x3F | 0x80 | |
| ) | |
| } else if (codePoint < 0x110000) { | |
| if ((units -= 4) < 0) break | |
| bytes.push( | |
| codePoint >> 0x12 | 0xF0, | |
| codePoint >> 0xC & 0x3F | 0x80, | |
| codePoint >> 0x6 & 0x3F | 0x80, | |
| codePoint & 0x3F | 0x80 | |
| ) | |
| } else { | |
| throw new Error('Invalid code point') | |
| } | |
| } | |
| return bytes | |
| } | |
| function asciiToBytes (str) { | |
| var byteArray = [] | |
| for (var i = 0; i < str.length; ++i) { | |
| // Node's code seems to be doing this and not & 0x7F.. | |
| byteArray.push(str.charCodeAt(i) & 0xFF) | |
| } | |
| return byteArray | |
| } | |
| function utf16leToBytes (str, units) { | |
| var c, hi, lo | |
| var byteArray = [] | |
| for (var i = 0; i < str.length; ++i) { | |
| if ((units -= 2) < 0) break | |
| c = str.charCodeAt(i) | |
| hi = c >> 8 | |
| lo = c % 256 | |
| byteArray.push(lo) | |
| byteArray.push(hi) | |
| } | |
| return byteArray | |
| } | |
| function base64ToBytes (str) { | |
| return base64.toByteArray(base64clean(str)) | |
| } | |
| function blitBuffer (src, dst, offset, length) { | |
| for (var i = 0; i < length; ++i) { | |
| if ((i + offset >= dst.length) || (i >= src.length)) break | |
| dst[i + offset] = src[i] | |
| } | |
| return i | |
| } | |
| function isnan (val) { | |
| return val !== val // eslint-disable-line no-self-compare | |
| } | |
| /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../webpack/buildin/global.js */ "./node_modules/webpack/buildin/global.js"))) | |
| //# sourceURL=webpack://LIB/./node_modules/buffer/index.js?`)},"./node_modules/charenc/charenc.js":function(module,exports){eval(`var charenc = { | |
| // UTF-8 encoding | |
| utf8: { | |
| // Convert a string to a byte array | |
| stringToBytes: function(str) { | |
| return charenc.bin.stringToBytes(unescape(encodeURIComponent(str))); | |
| }, | |
| // Convert a byte array to a string | |
| bytesToString: function(bytes) { | |
| return decodeURIComponent(escape(charenc.bin.bytesToString(bytes))); | |
| } | |
| }, | |
| // Binary encoding | |
| bin: { | |
| // Convert a string to a byte array | |
| stringToBytes: function(str) { | |
| for (var bytes = [], i = 0; i < str.length; i++) | |
| bytes.push(str.charCodeAt(i) & 0xFF); | |
| return bytes; | |
| }, | |
| // Convert a byte array to a string | |
| bytesToString: function(bytes) { | |
| for (var str = [], i = 0; i < bytes.length; i++) | |
| str.push(String.fromCharCode(bytes[i])); | |
| return str.join(''); | |
| } | |
| } | |
| }; | |
| module.exports = charenc; | |
| //# sourceURL=webpack://LIB/./node_modules/charenc/charenc.js?`)},"./node_modules/crypt/crypt.js":function(module,exports){eval(`(function() { | |
| var base64map | |
| = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/', | |
| crypt = { | |
| // Bit-wise rotation left | |
| rotl: function(n, b) { | |
| return (n << b) | (n >>> (32 - b)); | |
| }, | |
| // Bit-wise rotation right | |
| rotr: function(n, b) { | |
| return (n << (32 - b)) | (n >>> b); | |
| }, | |
| // Swap big-endian to little-endian and vice versa | |
| endian: function(n) { | |
| // If number given, swap endian | |
| if (n.constructor == Number) { | |
| return crypt.rotl(n, 8) & 0x00FF00FF | crypt.rotl(n, 24) & 0xFF00FF00; | |
| } | |
| // Else, assume array and swap all items | |
| for (var i = 0; i < n.length; i++) | |
| n[i] = crypt.endian(n[i]); | |
| return n; | |
| }, | |
| // Generate an array of any length of random bytes | |
| randomBytes: function(n) { | |
| for (var bytes = []; n > 0; n--) | |
| bytes.push(Math.floor(Math.random() * 256)); | |
| return bytes; | |
| }, | |
| // Convert a byte array to big-endian 32-bit words | |
| bytesToWords: function(bytes) { | |
| for (var words = [], i = 0, b = 0; i < bytes.length; i++, b += 8) | |
| words[b >>> 5] |= bytes[i] << (24 - b % 32); | |
| return words; | |
| }, | |
| // Convert big-endian 32-bit words to a byte array | |
| wordsToBytes: function(words) { | |
| for (var bytes = [], b = 0; b < words.length * 32; b += 8) | |
| bytes.push((words[b >>> 5] >>> (24 - b % 32)) & 0xFF); | |
| return bytes; | |
| }, | |
| // Convert a byte array to a hex string | |
| bytesToHex: function(bytes) { | |
| for (var hex = [], i = 0; i < bytes.length; i++) { | |
| hex.push((bytes[i] >>> 4).toString(16)); | |
| hex.push((bytes[i] & 0xF).toString(16)); | |
| } | |
| return hex.join(''); | |
| }, | |
| // Convert a hex string to a byte array | |
| hexToBytes: function(hex) { | |
| for (var bytes = [], c = 0; c < hex.length; c += 2) | |
| bytes.push(parseInt(hex.substr(c, 2), 16)); | |
| return bytes; | |
| }, | |
| // Convert a byte array to a base-64 string | |
| bytesToBase64: function(bytes) { | |
| for (var base64 = [], i = 0; i < bytes.length; i += 3) { | |
| var triplet = (bytes[i] << 16) | (bytes[i + 1] << 8) | bytes[i + 2]; | |
| for (var j = 0; j < 4; j++) | |
| if (i * 8 + j * 6 <= bytes.length * 8) | |
| base64.push(base64map.charAt((triplet >>> 6 * (3 - j)) & 0x3F)); | |
| else | |
| base64.push('='); | |
| } | |
| return base64.join(''); | |
| }, | |
| // Convert a base-64 string to a byte array | |
| base64ToBytes: function(base64) { | |
| // Remove non-base-64 characters | |
| base64 = base64.replace(/[^A-Z0-9+\\/]/ig, ''); | |
| for (var bytes = [], i = 0, imod4 = 0; i < base64.length; | |
| imod4 = ++i % 4) { | |
| if (imod4 == 0) continue; | |
| bytes.push(((base64map.indexOf(base64.charAt(i - 1)) | |
| & (Math.pow(2, -2 * imod4 + 8) - 1)) << (imod4 * 2)) | |
| | (base64map.indexOf(base64.charAt(i)) >>> (6 - imod4 * 2))); | |
| } | |
| return bytes; | |
| } | |
| }; | |
| module.exports = crypt; | |
| })(); | |
| //# sourceURL=webpack://LIB/./node_modules/crypt/crypt.js?`)},"./node_modules/diff/dist/diff.js":function(module,exports,__webpack_require__){eval(`/*! | |
| diff v4.0.1 | |
| Software License Agreement (BSD License) | |
| Copyright (c) 2009-2015, Kevin Decker <kpdecker@gmail.com> | |
| All rights reserved. | |
| Redistribution and use of this software in source and binary forms, with or without modification, | |
| are permitted provided that the following conditions are met: | |
| * Redistributions of source code must retain the above | |
| copyright notice, this list of conditions and the | |
| following disclaimer. | |
| * Redistributions in binary form must reproduce the above | |
| copyright notice, this list of conditions and the | |
| following disclaimer in the documentation and/or other | |
| materials provided with the distribution. | |
| * Neither the name of Kevin Decker nor the names of its | |
| contributors may be used to endorse or promote products | |
| derived from this software without specific prior | |
| written permission. | |
| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR | |
| IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND | |
| FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | |
| CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
| DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
| DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER | |
| IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | |
| OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| @license | |
| */ | |
| (function (global, factory) { | |
| true ? factory(exports) : | |
| undefined; | |
| }(this, function (exports) { 'use strict'; | |
| function Diff() {} | |
| Diff.prototype = { | |
| diff: function diff(oldString, newString) { | |
| var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | |
| var callback = options.callback; | |
| if (typeof options === 'function') { | |
| callback = options; | |
| options = {}; | |
| } | |
| this.options = options; | |
| var self = this; | |
| function done(value) { | |
| if (callback) { | |
| setTimeout(function () { | |
| callback(undefined, value); | |
| }, 0); | |
| return true; | |
| } else { | |
| return value; | |
| } | |
| } // Allow subclasses to massage the input prior to running | |
| oldString = this.castInput(oldString); | |
| newString = this.castInput(newString); | |
| oldString = this.removeEmpty(this.tokenize(oldString)); | |
| newString = this.removeEmpty(this.tokenize(newString)); | |
| var newLen = newString.length, | |
| oldLen = oldString.length; | |
| var editLength = 1; | |
| var maxEditLength = newLen + oldLen; | |
| var bestPath = [{ | |
| newPos: -1, | |
| components: [] | |
| }]; // Seed editLength = 0, i.e. the content starts with the same values | |
| var oldPos = this.extractCommon(bestPath[0], newString, oldString, 0); | |
| if (bestPath[0].newPos + 1 >= newLen && oldPos + 1 >= oldLen) { | |
| // Identity per the equality and tokenizer | |
| return done([{ | |
| value: this.join(newString), | |
| count: newString.length | |
| }]); | |
| } // Main worker method. checks all permutations of a given edit length for acceptance. | |
| function execEditLength() { | |
| for (var diagonalPath = -1 * editLength; diagonalPath <= editLength; diagonalPath += 2) { | |
| var basePath = void 0; | |
| var addPath = bestPath[diagonalPath - 1], | |
| removePath = bestPath[diagonalPath + 1], | |
| _oldPos = (removePath ? removePath.newPos : 0) - diagonalPath; | |
| if (addPath) { | |
| // No one else is going to attempt to use this value, clear it | |
| bestPath[diagonalPath - 1] = undefined; | |
| } | |
| var canAdd = addPath && addPath.newPos + 1 < newLen, | |
| canRemove = removePath && 0 <= _oldPos && _oldPos < oldLen; | |
| if (!canAdd && !canRemove) { | |
| // If this path is a terminal then prune | |
| bestPath[diagonalPath] = undefined; | |
| continue; | |
| } // Select the diagonal that we want to branch from. We select the prior | |
| // path whose position in the new string is the farthest from the origin | |
| // and does not pass the bounds of the diff graph | |
| if (!canAdd || canRemove && addPath.newPos < removePath.newPos) { | |
| basePath = clonePath(removePath); | |
| self.pushComponent(basePath.components, undefined, true); | |
| } else { | |
| basePath = addPath; // No need to clone, we've pulled it from the list | |
| basePath.newPos++; | |
| self.pushComponent(basePath.components, true, undefined); | |
| } | |
| _oldPos = self.extractCommon(basePath, newString, oldString, diagonalPath); // If we have hit the end of both strings, then we are done | |
| if (basePath.newPos + 1 >= newLen && _oldPos + 1 >= oldLen) { | |
| return done(buildValues(self, basePath.components, newString, oldString, self.useLongestToken)); | |
| } else { | |
| // Otherwise track this path as a potential candidate and continue. | |
| bestPath[diagonalPath] = basePath; | |
| } | |
| } | |
| editLength++; | |
| } // Performs the length of edit iteration. Is a bit fugly as this has to support the | |
| // sync and async mode which is never fun. Loops over execEditLength until a value | |
| // is produced. | |
| if (callback) { | |
| (function exec() { | |
| setTimeout(function () { | |
| // This should not happen, but we want to be safe. | |
| /* istanbul ignore next */ | |
| if (editLength > maxEditLength) { | |
| return callback(); | |
| } | |
| if (!execEditLength()) { | |
| exec(); | |
| } | |
| }, 0); | |
| })(); | |
| } else { | |
| while (editLength <= maxEditLength) { | |
| var ret = execEditLength(); | |
| if (ret) { | |
| return ret; | |
| } | |
| } | |
| } | |
| }, | |
| pushComponent: function pushComponent(components, added, removed) { | |
| var last = components[components.length - 1]; | |
| if (last && last.added === added && last.removed === removed) { | |
| // We need to clone here as the component clone operation is just | |
| // as shallow array clone | |
| components[components.length - 1] = { | |
| count: last.count + 1, | |
| added: added, | |
| removed: removed | |
| }; | |
| } else { | |
| components.push({ | |
| count: 1, | |
| added: added, | |
| removed: removed | |
| }); | |
| } | |
| }, | |
| extractCommon: function extractCommon(basePath, newString, oldString, diagonalPath) { | |
| var newLen = newString.length, | |
| oldLen = oldString.length, | |
| newPos = basePath.newPos, | |
| oldPos = newPos - diagonalPath, | |
| commonCount = 0; | |
| while (newPos + 1 < newLen && oldPos + 1 < oldLen && this.equals(newString[newPos + 1], oldString[oldPos + 1])) { | |
| newPos++; | |
| oldPos++; | |
| commonCount++; | |
| } | |
| if (commonCount) { | |
| basePath.components.push({ | |
| count: commonCount | |
| }); | |
| } | |
| basePath.newPos = newPos; | |
| return oldPos; | |
| }, | |
| equals: function equals(left, right) { | |
| if (this.options.comparator) { | |
| return this.options.comparator(left, right); | |
| } else { | |
| return left === right || this.options.ignoreCase && left.toLowerCase() === right.toLowerCase(); | |
| } | |
| }, | |
| removeEmpty: function removeEmpty(array) { | |
| var ret = []; | |
| for (var i = 0; i < array.length; i++) { | |
| if (array[i]) { | |
| ret.push(array[i]); | |
| } | |
| } | |
| return ret; | |
| }, | |
| castInput: function castInput(value) { | |
| return value; | |
| }, | |
| tokenize: function tokenize(value) { | |
| return value.split(''); | |
| }, | |
| join: function join(chars) { | |
| return chars.join(''); | |
| } | |
| }; | |
| function buildValues(diff, components, newString, oldString, useLongestToken) { | |
| var componentPos = 0, | |
| componentLen = components.length, | |
| newPos = 0, | |
| oldPos = 0; | |
| for (; componentPos < componentLen; componentPos++) { | |
| var component = components[componentPos]; | |
| if (!component.removed) { | |
| if (!component.added && useLongestToken) { | |
| var value = newString.slice(newPos, newPos + component.count); | |
| value = value.map(function (value, i) { | |
| var oldValue = oldString[oldPos + i]; | |
| return oldValue.length > value.length ? oldValue : value; | |
| }); | |
| component.value = diff.join(value); | |
| } else { | |
| component.value = diff.join(newString.slice(newPos, newPos + component.count)); | |
| } | |
| newPos += component.count; // Common case | |
| if (!component.added) { | |
| oldPos += component.count; | |
| } | |
| } else { | |
| component.value = diff.join(oldString.slice(oldPos, oldPos + component.count)); | |
| oldPos += component.count; // Reverse add and remove so removes are output first to match common convention | |
| // The diffing algorithm is tied to add then remove output and this is the simplest | |
| // route to get the desired output with minimal overhead. | |
| if (componentPos && components[componentPos - 1].added) { | |
| var tmp = components[componentPos - 1]; | |
| components[componentPos - 1] = components[componentPos]; | |
| components[componentPos] = tmp; | |
| } | |
| } | |
| } // Special case handle for when one terminal is ignored (i.e. whitespace). | |
| // For this case we merge the terminal into the prior string and drop the change. | |
| // This is only available for string mode. | |
| var lastComponent = components[componentLen - 1]; | |
| if (componentLen > 1 && typeof lastComponent.value === 'string' && (lastComponent.added || lastComponent.removed) && diff.equals('', lastComponent.value)) { | |
| components[componentLen - 2].value += lastComponent.value; | |
| components.pop(); | |
| } | |
| return components; | |
| } | |
| function clonePath(path) { | |
| return { | |
| newPos: path.newPos, | |
| components: path.components.slice(0) | |
| }; | |
| } | |
| var characterDiff = new Diff(); | |
| function diffChars(oldStr, newStr, options) { | |
| return characterDiff.diff(oldStr, newStr, options); | |
| } | |
| function generateOptions(options, defaults) { | |
| if (typeof options === 'function') { | |
| defaults.callback = options; | |
| } else if (options) { | |
| for (var name in options) { | |
| /* istanbul ignore else */ | |
| if (options.hasOwnProperty(name)) { | |
| defaults[name] = options[name]; | |
| } | |
| } | |
| } | |
| return defaults; | |
| } | |
| // | |
| // Ranges and exceptions: | |
| // Latin-1 Supplement, 0080–00FF | |
| // - U+00D7 × Multiplication sign | |
| // - U+00F7 ÷ Division sign | |
| // Latin Extended-A, 0100–017F | |
| // Latin Extended-B, 0180–024F | |
| // IPA Extensions, 0250–02AF | |
| // Spacing Modifier Letters, 02B0–02FF | |
| // - U+02C7 ˇ ˇ Caron | |
| // - U+02D8 ˘ ˘ Breve | |
| // - U+02D9 ˙ ˙ Dot Above | |
| // - U+02DA ˚ ˚ Ring Above | |
| // - U+02DB ˛ ˛ Ogonek | |
| // - U+02DC ˜ ˜ Small Tilde | |
| // - U+02DD ˝ ˝ Double Acute Accent | |
| // Latin Extended Additional, 1E00–1EFF | |
| var extendedWordChars = /^[A-Za-z\\xC0-\\u02C6\\u02C8-\\u02D7\\u02DE-\\u02FF\\u1E00-\\u1EFF]+$/; | |
| var reWhitespace = /\\S/; | |
| var wordDiff = new Diff(); | |
| wordDiff.equals = function (left, right) { | |
| if (this.options.ignoreCase) { | |
| left = left.toLowerCase(); | |
| right = right.toLowerCase(); | |
| } | |
| return left === right || this.options.ignoreWhitespace && !reWhitespace.test(left) && !reWhitespace.test(right); | |
| }; | |
| wordDiff.tokenize = function (value) { | |
| var tokens = value.split(/(\\s+|[()[\\]{}'"]|\\b)/); // Join the boundary splits that we do not consider to be boundaries. This is primarily the extended Latin character set. | |
| for (var i = 0; i < tokens.length - 1; i++) { | |
| // If we have an empty string in the next field and we have only word chars before and after, merge | |
| if (!tokens[i + 1] && tokens[i + 2] && extendedWordChars.test(tokens[i]) && extendedWordChars.test(tokens[i + 2])) { | |
| tokens[i] += tokens[i + 2]; | |
| tokens.splice(i + 1, 2); | |
| i--; | |
| } | |
| } | |
| return tokens; | |
| }; | |
| function diffWords(oldStr, newStr, options) { | |
| options = generateOptions(options, { | |
| ignoreWhitespace: true | |
| }); | |
| return wordDiff.diff(oldStr, newStr, options); | |
| } | |
| function diffWordsWithSpace(oldStr, newStr, options) { | |
| return wordDiff.diff(oldStr, newStr, options); | |
| } | |
| var lineDiff = new Diff(); | |
| lineDiff.tokenize = function (value) { | |
| var retLines = [], | |
| linesAndNewlines = value.split(/(\\n|\\r\\n)/); // Ignore the final empty token that occurs if the string ends with a new line | |
| if (!linesAndNewlines[linesAndNewlines.length - 1]) { | |
| linesAndNewlines.pop(); | |
| } // Merge the content and line separators into single tokens | |
| for (var i = 0; i < linesAndNewlines.length; i++) { | |
| var line = linesAndNewlines[i]; | |
| if (i % 2 && !this.options.newlineIsToken) { | |
| retLines[retLines.length - 1] += line; | |
| } else { | |
| if (this.options.ignoreWhitespace) { | |
| line = line.trim(); | |
| } | |
| retLines.push(line); | |
| } | |
| } | |
| return retLines; | |
| }; | |
| function diffLines(oldStr, newStr, callback) { | |
| return lineDiff.diff(oldStr, newStr, callback); | |
| } | |
| function diffTrimmedLines(oldStr, newStr, callback) { | |
| var options = generateOptions(callback, { | |
| ignoreWhitespace: true | |
| }); | |
| return lineDiff.diff(oldStr, newStr, options); | |
| } | |
| var sentenceDiff = new Diff(); | |
| sentenceDiff.tokenize = function (value) { | |
| return value.split(/(\\S.+?[.!?])(?=\\s+|$)/); | |
| }; | |
| function diffSentences(oldStr, newStr, callback) { | |
| return sentenceDiff.diff(oldStr, newStr, callback); | |
| } | |
| var cssDiff = new Diff(); | |
| cssDiff.tokenize = function (value) { | |
| return value.split(/([{}:;,]|\\s+)/); | |
| }; | |
| function diffCss(oldStr, newStr, callback) { | |
| return cssDiff.diff(oldStr, newStr, callback); | |
| } | |
| function _typeof(obj) { | |
| if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { | |
| _typeof = function (obj) { | |
| return typeof obj; | |
| }; | |
| } else { | |
| _typeof = function (obj) { | |
| return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; | |
| }; | |
| } | |
| return _typeof(obj); | |
| } | |
| function _toConsumableArray(arr) { | |
| return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); | |
| } | |
| function _arrayWithoutHoles(arr) { | |
| if (Array.isArray(arr)) { | |
| for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; | |
| return arr2; | |
| } | |
| } | |
| function _iterableToArray(iter) { | |
| if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); | |
| } | |
| function _nonIterableSpread() { | |
| throw new TypeError("Invalid attempt to spread non-iterable instance"); | |
| } | |
| var objectPrototypeToString = Object.prototype.toString; | |
| var jsonDiff = new Diff(); // Discriminate between two lines of pretty-printed, serialized JSON where one of them has a | |
| // dangling comma and the other doesn't. Turns out including the dangling comma yields the nicest output: | |
| jsonDiff.useLongestToken = true; | |
| jsonDiff.tokenize = lineDiff.tokenize; | |
| jsonDiff.castInput = function (value) { | |
| var _this$options = this.options, | |
| undefinedReplacement = _this$options.undefinedReplacement, | |
| _this$options$stringi = _this$options.stringifyReplacer, | |
| stringifyReplacer = _this$options$stringi === void 0 ? function (k, v) { | |
| return typeof v === 'undefined' ? undefinedReplacement : v; | |
| } : _this$options$stringi; | |
| return typeof value === 'string' ? value : JSON.stringify(canonicalize(value, null, null, stringifyReplacer), stringifyReplacer, ' '); | |
| }; | |
| jsonDiff.equals = function (left, right) { | |
| return Diff.prototype.equals.call(jsonDiff, left.replace(/,([\\r\\n])/g, '$1'), right.replace(/,([\\r\\n])/g, '$1')); | |
| }; | |
| function diffJson(oldObj, newObj, options) { | |
| return jsonDiff.diff(oldObj, newObj, options); | |
| } // This function handles the presence of circular references by bailing out when encountering an | |
| // object that is already on the "stack" of items being processed. Accepts an optional replacer | |
| function canonicalize(obj, stack, replacementStack, replacer, key) { | |
| stack = stack || []; | |
| replacementStack = replacementStack || []; | |
| if (replacer) { | |
| obj = replacer(key, obj); | |
| } | |
| var i; | |
| for (i = 0; i < stack.length; i += 1) { | |
| if (stack[i] === obj) { | |
| return replacementStack[i]; | |
| } | |
| } | |
| var canonicalizedObj; | |
| if ('[object Array]' === objectPrototypeToString.call(obj)) { | |
| stack.push(obj); | |
| canonicalizedObj = new Array(obj.length); | |
| replacementStack.push(canonicalizedObj); | |
| for (i = 0; i < obj.length; i += 1) { | |
| canonicalizedObj[i] = canonicalize(obj[i], stack, replacementStack, replacer, key); | |
| } | |
| stack.pop(); | |
| replacementStack.pop(); | |
| return canonicalizedObj; | |
| } | |
| if (obj && obj.toJSON) { | |
| obj = obj.toJSON(); | |
| } | |
| if (_typeof(obj) === 'object' && obj !== null) { | |
| stack.push(obj); | |
| canonicalizedObj = {}; | |
| replacementStack.push(canonicalizedObj); | |
| var sortedKeys = [], | |
| _key; | |
| for (_key in obj) { | |
| /* istanbul ignore else */ | |
| if (obj.hasOwnProperty(_key)) { | |
| sortedKeys.push(_key); | |
| } | |
| } | |
| sortedKeys.sort(); | |
| for (i = 0; i < sortedKeys.length; i += 1) { | |
| _key = sortedKeys[i]; | |
| canonicalizedObj[_key] = canonicalize(obj[_key], stack, replacementStack, replacer, _key); | |
| } | |
| stack.pop(); | |
| replacementStack.pop(); | |
| } else { | |
| canonicalizedObj = obj; | |
| } | |
| return canonicalizedObj; | |
| } | |
| var arrayDiff = new Diff(); | |
| arrayDiff.tokenize = function (value) { | |
| return value.slice(); | |
| }; | |
| arrayDiff.join = arrayDiff.removeEmpty = function (value) { | |
| return value; | |
| }; | |
| function diffArrays(oldArr, newArr, callback) { | |
| return arrayDiff.diff(oldArr, newArr, callback); | |
| } | |
| function parsePatch(uniDiff) { | |
| var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | |
| var diffstr = uniDiff.split(/\\r\\n|[\\n\\v\\f\\r\\x85]/), | |
| delimiters = uniDiff.match(/\\r\\n|[\\n\\v\\f\\r\\x85]/g) || [], | |
| list = [], | |
| i = 0; | |
| function parseIndex() { | |
| var index = {}; | |
| list.push(index); // Parse diff metadata | |
| while (i < diffstr.length) { | |
| var line = diffstr[i]; // File header found, end parsing diff metadata | |
| if (/^(\\-\\-\\-|\\+\\+\\+|@@)\\s/.test(line)) { | |
| break; | |
| } // Diff index | |
| var header = /^(?:Index:|diff(?: -r \\w+)+)\\s+(.+?)\\s*$/.exec(line); | |
| if (header) { | |
| index.index = header[1]; | |
| } | |
| i++; | |
| } // Parse file headers if they are defined. Unified diff requires them, but | |
| // there's no technical issues to have an isolated hunk without file header | |
| parseFileHeader(index); | |
| parseFileHeader(index); // Parse hunks | |
| index.hunks = []; | |
| while (i < diffstr.length) { | |
| var _line = diffstr[i]; | |
| if (/^(Index:|diff|\\-\\-\\-|\\+\\+\\+)\\s/.test(_line)) { | |
| break; | |
| } else if (/^@@/.test(_line)) { | |
| index.hunks.push(parseHunk()); | |
| } else if (_line && options.strict) { | |
| // Ignore unexpected content unless in strict mode | |
| throw new Error('Unknown line ' + (i + 1) + ' ' + JSON.stringify(_line)); | |
| } else { | |
| i++; | |
| } | |
| } | |
| } // Parses the --- and +++ headers, if none are found, no lines | |
| // are consumed. | |
| function parseFileHeader(index) { | |
| var fileHeader = /^(---|\\+\\+\\+)\\s+(.*)$/.exec(diffstr[i]); | |
| if (fileHeader) { | |
| var keyPrefix = fileHeader[1] === '---' ? 'old' : 'new'; | |
| var data = fileHeader[2].split('\\t', 2); | |
| var fileName = data[0].replace(/\\\\\\\\/g, '\\\\'); | |
| if (/^".*"$/.test(fileName)) { | |
| fileName = fileName.substr(1, fileName.length - 2); | |
| } | |
| index[keyPrefix + 'FileName'] = fileName; | |
| index[keyPrefix + 'Header'] = (data[1] || '').trim(); | |
| i++; | |
| } | |
| } // Parses a hunk | |
| // This assumes that we are at the start of a hunk. | |
| function parseHunk() { | |
| var chunkHeaderIndex = i, | |
| chunkHeaderLine = diffstr[i++], | |
| chunkHeader = chunkHeaderLine.split(/@@ -(\\d+)(?:,(\\d+))? \\+(\\d+)(?:,(\\d+))? @@/); | |
| var hunk = { | |
| oldStart: +chunkHeader[1], | |
| oldLines: +chunkHeader[2] || 1, | |
| newStart: +chunkHeader[3], | |
| newLines: +chunkHeader[4] || 1, | |
| lines: [], | |
| linedelimiters: [] | |
| }; | |
| var addCount = 0, | |
| removeCount = 0; | |
| for (; i < diffstr.length; i++) { | |
| // Lines starting with '---' could be mistaken for the "remove line" operation | |
| // But they could be the header for the next file. Therefore prune such cases out. | |
| if (diffstr[i].indexOf('--- ') === 0 && i + 2 < diffstr.length && diffstr[i + 1].indexOf('+++ ') === 0 && diffstr[i + 2].indexOf('@@') === 0) { | |
| break; | |
| } | |
| var operation = diffstr[i].length == 0 && i != diffstr.length - 1 ? ' ' : diffstr[i][0]; | |
| if (operation === '+' || operation === '-' || operation === ' ' || operation === '\\\\') { | |
| hunk.lines.push(diffstr[i]); | |
| hunk.linedelimiters.push(delimiters[i] || '\\n'); | |
| if (operation === '+') { | |
| addCount++; | |
| } else if (operation === '-') { | |
| removeCount++; | |
| } else if (operation === ' ') { | |
| addCount++; | |
| removeCount++; | |
| } | |
| } else { | |
| break; | |
| } | |
| } // Handle the empty block count case | |
| if (!addCount && hunk.newLines === 1) { | |
| hunk.newLines = 0; | |
| } | |
| if (!removeCount && hunk.oldLines === 1) { | |
| hunk.oldLines = 0; | |
| } // Perform optional sanity checking | |
| if (options.strict) { | |
| if (addCount !== hunk.newLines) { | |
| throw new Error('Added line count did not match for hunk at line ' + (chunkHeaderIndex + 1)); | |
| } | |
| if (removeCount !== hunk.oldLines) { | |
| throw new Error('Removed line count did not match for hunk at line ' + (chunkHeaderIndex + 1)); | |
| } | |
| } | |
| return hunk; | |
| } | |
| while (i < diffstr.length) { | |
| parseIndex(); | |
| } | |
| return list; | |
| } | |
| // Iterator that traverses in the range of [min, max], stepping | |
| // by distance from a given start position. I.e. for [0, 4], with | |
| // start of 2, this will iterate 2, 3, 1, 4, 0. | |
| function distanceIterator (start, minLine, maxLine) { | |
| var wantForward = true, | |
| backwardExhausted = false, | |
| forwardExhausted = false, | |
| localOffset = 1; | |
| return function iterator() { | |
| if (wantForward && !forwardExhausted) { | |
| if (backwardExhausted) { | |
| localOffset++; | |
| } else { | |
| wantForward = false; | |
| } // Check if trying to fit beyond text length, and if not, check it fits | |
| // after offset location (or desired location on first iteration) | |
| if (start + localOffset <= maxLine) { | |
| return localOffset; | |
| } | |
| forwardExhausted = true; | |
| } | |
| if (!backwardExhausted) { | |
| if (!forwardExhausted) { | |
| wantForward = true; | |
| } // Check if trying to fit before text beginning, and if not, check it fits | |
| // before offset location | |
| if (minLine <= start - localOffset) { | |
| return -localOffset++; | |
| } | |
| backwardExhausted = true; | |
| return iterator(); | |
| } // We tried to fit hunk before text beginning and beyond text length, then | |
| // hunk can't fit on the text. Return undefined | |
| }; | |
| } | |
| function applyPatch(source, uniDiff) { | |
| var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | |
| if (typeof uniDiff === 'string') { | |
| uniDiff = parsePatch(uniDiff); | |
| } | |
| if (Array.isArray(uniDiff)) { | |
| if (uniDiff.length > 1) { | |
| throw new Error('applyPatch only works with a single input.'); | |
| } | |
| uniDiff = uniDiff[0]; | |
| } // Apply the diff to the input | |
| var lines = source.split(/\\r\\n|[\\n\\v\\f\\r\\x85]/), | |
| delimiters = source.match(/\\r\\n|[\\n\\v\\f\\r\\x85]/g) || [], | |
| hunks = uniDiff.hunks, | |
| compareLine = options.compareLine || function (lineNumber, line, operation, patchContent) { | |
| return line === patchContent; | |
| }, | |
| errorCount = 0, | |
| fuzzFactor = options.fuzzFactor || 0, | |
| minLine = 0, | |
| offset = 0, | |
| removeEOFNL, | |
| addEOFNL; | |
| /** | |
| * Checks if the hunk exactly fits on the provided location | |
| */ | |
| function hunkFits(hunk, toPos) { | |
| for (var j = 0; j < hunk.lines.length; j++) { | |
| var line = hunk.lines[j], | |
| operation = line.length > 0 ? line[0] : ' ', | |
| content = line.length > 0 ? line.substr(1) : line; | |
| if (operation === ' ' || operation === '-') { | |
| // Context sanity check | |
| if (!compareLine(toPos + 1, lines[toPos], operation, content)) { | |
| errorCount++; | |
| if (errorCount > fuzzFactor) { | |
| return false; | |
| } | |
| } | |
| toPos++; | |
| } | |
| } | |
| return true; | |
| } // Search best fit offsets for each hunk based on the previous ones | |
| for (var i = 0; i < hunks.length; i++) { | |
| var hunk = hunks[i], | |
| maxLine = lines.length - hunk.oldLines, | |
| localOffset = 0, | |
| toPos = offset + hunk.oldStart - 1; | |
| var iterator = distanceIterator(toPos, minLine, maxLine); | |
| for (; localOffset !== undefined; localOffset = iterator()) { | |
| if (hunkFits(hunk, toPos + localOffset)) { | |
| hunk.offset = offset += localOffset; | |
| break; | |
| } | |
| } | |
| if (localOffset === undefined) { | |
| return false; | |
| } // Set lower text limit to end of the current hunk, so next ones don't try | |
| // to fit over already patched text | |
| minLine = hunk.offset + hunk.oldStart + hunk.oldLines; | |
| } // Apply patch hunks | |
| var diffOffset = 0; | |
| for (var _i = 0; _i < hunks.length; _i++) { | |
| var _hunk = hunks[_i], | |
| _toPos = _hunk.oldStart + _hunk.offset + diffOffset - 1; | |
| diffOffset += _hunk.newLines - _hunk.oldLines; | |
| if (_toPos < 0) { | |
| // Creating a new file | |
| _toPos = 0; | |
| } | |
| for (var j = 0; j < _hunk.lines.length; j++) { | |
| var line = _hunk.lines[j], | |
| operation = line.length > 0 ? line[0] : ' ', | |
| content = line.length > 0 ? line.substr(1) : line, | |
| delimiter = _hunk.linedelimiters[j]; | |
| if (operation === ' ') { | |
| _toPos++; | |
| } else if (operation === '-') { | |
| lines.splice(_toPos, 1); | |
| delimiters.splice(_toPos, 1); | |
| /* istanbul ignore else */ | |
| } else if (operation === '+') { | |
| lines.splice(_toPos, 0, content); | |
| delimiters.splice(_toPos, 0, delimiter); | |
| _toPos++; | |
| } else if (operation === '\\\\') { | |
| var previousOperation = _hunk.lines[j - 1] ? _hunk.lines[j - 1][0] : null; | |
| if (previousOperation === '+') { | |
| removeEOFNL = true; | |
| } else if (previousOperation === '-') { | |
| addEOFNL = true; | |
| } | |
| } | |
| } | |
| } // Handle EOFNL insertion/removal | |
| if (removeEOFNL) { | |
| while (!lines[lines.length - 1]) { | |
| lines.pop(); | |
| delimiters.pop(); | |
| } | |
| } else if (addEOFNL) { | |
| lines.push(''); | |
| delimiters.push('\\n'); | |
| } | |
| for (var _k = 0; _k < lines.length - 1; _k++) { | |
| lines[_k] = lines[_k] + delimiters[_k]; | |
| } | |
| return lines.join(''); | |
| } // Wrapper that supports multiple file patches via callbacks. | |
| function applyPatches(uniDiff, options) { | |
| if (typeof uniDiff === 'string') { | |
| uniDiff = parsePatch(uniDiff); | |
| } | |
| var currentIndex = 0; | |
| function processIndex() { | |
| var index = uniDiff[currentIndex++]; | |
| if (!index) { | |
| return options.complete(); | |
| } | |
| options.loadFile(index, function (err, data) { | |
| if (err) { | |
| return options.complete(err); | |
| } | |
| var updatedContent = applyPatch(data, index, options); | |
| options.patched(index, updatedContent, function (err) { | |
| if (err) { | |
| return options.complete(err); | |
| } | |
| processIndex(); | |
| }); | |
| }); | |
| } | |
| processIndex(); | |
| } | |
| function structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) { | |
| if (!options) { | |
| options = {}; | |
| } | |
| if (typeof options.context === 'undefined') { | |
| options.context = 4; | |
| } | |
| var diff = diffLines(oldStr, newStr, options); | |
| diff.push({ | |
| value: '', | |
| lines: [] | |
| }); // Append an empty value to make cleanup easier | |
| function contextLines(lines) { | |
| return lines.map(function (entry) { | |
| return ' ' + entry; | |
| }); | |
| } | |
| var hunks = []; | |
| var oldRangeStart = 0, | |
| newRangeStart = 0, | |
| curRange = [], | |
| oldLine = 1, | |
| newLine = 1; | |
| var _loop = function _loop(i) { | |
| var current = diff[i], | |
| lines = current.lines || current.value.replace(/\\n$/, '').split('\\n'); | |
| current.lines = lines; | |
| if (current.added || current.removed) { | |
| var _curRange; | |
| // If we have previous context, start with that | |
| if (!oldRangeStart) { | |
| var prev = diff[i - 1]; | |
| oldRangeStart = oldLine; | |
| newRangeStart = newLine; | |
| if (prev) { | |
| curRange = options.context > 0 ? contextLines(prev.lines.slice(-options.context)) : []; | |
| oldRangeStart -= curRange.length; | |
| newRangeStart -= curRange.length; | |
| } | |
| } // Output our changes | |
| (_curRange = curRange).push.apply(_curRange, _toConsumableArray(lines.map(function (entry) { | |
| return (current.added ? '+' : '-') + entry; | |
| }))); // Track the updated file position | |
| if (current.added) { | |
| newLine += lines.length; | |
| } else { | |
| oldLine += lines.length; | |
| } | |
| } else { | |
| // Identical context lines. Track line changes | |
| if (oldRangeStart) { | |
| // Close out any changes that have been output (or join overlapping) | |
| if (lines.length <= options.context * 2 && i < diff.length - 2) { | |
| var _curRange2; | |
| // Overlapping | |
| (_curRange2 = curRange).push.apply(_curRange2, _toConsumableArray(contextLines(lines))); | |
| } else { | |
| var _curRange3; | |
| // end the range and output | |
| var contextSize = Math.min(lines.length, options.context); | |
| (_curRange3 = curRange).push.apply(_curRange3, _toConsumableArray(contextLines(lines.slice(0, contextSize)))); | |
| var hunk = { | |
| oldStart: oldRangeStart, | |
| oldLines: oldLine - oldRangeStart + contextSize, | |
| newStart: newRangeStart, | |
| newLines: newLine - newRangeStart + contextSize, | |
| lines: curRange | |
| }; | |
| if (i >= diff.length - 2 && lines.length <= options.context) { | |
| // EOF is inside this hunk | |
| var oldEOFNewline = /\\n$/.test(oldStr); | |
| var newEOFNewline = /\\n$/.test(newStr); | |
| var noNlBeforeAdds = lines.length == 0 && curRange.length > hunk.oldLines; | |
| if (!oldEOFNewline && noNlBeforeAdds) { | |
| // special case: old has no eol and no trailing context; no-nl can end up before adds | |
| curRange.splice(hunk.oldLines, 0, '\\\\ No newline at end of file'); | |
| } | |
| if (!oldEOFNewline && !noNlBeforeAdds || !newEOFNewline) { | |
| curRange.push('\\\\ No newline at end of file'); | |
| } | |
| } | |
| hunks.push(hunk); | |
| oldRangeStart = 0; | |
| newRangeStart = 0; | |
| curRange = []; | |
| } | |
| } | |
| oldLine += lines.length; | |
| newLine += lines.length; | |
| } | |
| }; | |
| for (var i = 0; i < diff.length; i++) { | |
| _loop(i); | |
| } | |
| return { | |
| oldFileName: oldFileName, | |
| newFileName: newFileName, | |
| oldHeader: oldHeader, | |
| newHeader: newHeader, | |
| hunks: hunks | |
| }; | |
| } | |
| function createTwoFilesPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) { | |
| var diff = structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options); | |
| var ret = []; | |
| if (oldFileName == newFileName) { | |
| ret.push('Index: ' + oldFileName); | |
| } | |
| ret.push('==================================================================='); | |
| ret.push('--- ' + diff.oldFileName + (typeof diff.oldHeader === 'undefined' ? '' : '\\t' + diff.oldHeader)); | |
| ret.push('+++ ' + diff.newFileName + (typeof diff.newHeader === 'undefined' ? '' : '\\t' + diff.newHeader)); | |
| for (var i = 0; i < diff.hunks.length; i++) { | |
| var hunk = diff.hunks[i]; | |
| ret.push('@@ -' + hunk.oldStart + ',' + hunk.oldLines + ' +' + hunk.newStart + ',' + hunk.newLines + ' @@'); | |
| ret.push.apply(ret, hunk.lines); | |
| } | |
| return ret.join('\\n') + '\\n'; | |
| } | |
| function createPatch(fileName, oldStr, newStr, oldHeader, newHeader, options) { | |
| return createTwoFilesPatch(fileName, fileName, oldStr, newStr, oldHeader, newHeader, options); | |
| } | |
| function arrayEqual(a, b) { | |
| if (a.length !== b.length) { | |
| return false; | |
| } | |
| return arrayStartsWith(a, b); | |
| } | |
| function arrayStartsWith(array, start) { | |
| if (start.length > array.length) { | |
| return false; | |
| } | |
| for (var i = 0; i < start.length; i++) { | |
| if (start[i] !== array[i]) { | |
| return false; | |
| } | |
| } | |
| return true; | |
| } | |
| function calcLineCount(hunk) { | |
| var _calcOldNewLineCount = calcOldNewLineCount(hunk.lines), | |
| oldLines = _calcOldNewLineCount.oldLines, | |
| newLines = _calcOldNewLineCount.newLines; | |
| if (oldLines !== undefined) { | |
| hunk.oldLines = oldLines; | |
| } else { | |
| delete hunk.oldLines; | |
| } | |
| if (newLines !== undefined) { | |
| hunk.newLines = newLines; | |
| } else { | |
| delete hunk.newLines; | |
| } | |
| } | |
| function merge(mine, theirs, base) { | |
| mine = loadPatch(mine, base); | |
| theirs = loadPatch(theirs, base); | |
| var ret = {}; // For index we just let it pass through as it doesn't have any necessary meaning. | |
| // Leaving sanity checks on this to the API consumer that may know more about the | |
| // meaning in their own context. | |
| if (mine.index || theirs.index) { | |
| ret.index = mine.index || theirs.index; | |
| } | |
| if (mine.newFileName || theirs.newFileName) { | |
| if (!fileNameChanged(mine)) { | |
| // No header or no change in ours, use theirs (and ours if theirs does not exist) | |
| ret.oldFileName = theirs.oldFileName || mine.oldFileName; | |
| ret.newFileName = theirs.newFileName || mine.newFileName; | |
| ret.oldHeader = theirs.oldHeader || mine.oldHeader; | |
| ret.newHeader = theirs.newHeader || mine.newHeader; | |
| } else if (!fileNameChanged(theirs)) { | |
| // No header or no change in theirs, use ours | |
| ret.oldFileName = mine.oldFileName; | |
| ret.newFileName = mine.newFileName; | |
| ret.oldHeader = mine.oldHeader; | |
| ret.newHeader = mine.newHeader; | |
| } else { | |
| // Both changed... figure it out | |
| ret.oldFileName = selectField(ret, mine.oldFileName, theirs.oldFileName); | |
| ret.newFileName = selectField(ret, mine.newFileName, theirs.newFileName); | |
| ret.oldHeader = selectField(ret, mine.oldHeader, theirs.oldHeader); | |
| ret.newHeader = selectField(ret, mine.newHeader, theirs.newHeader); | |
| } | |
| } | |
| ret.hunks = []; | |
| var mineIndex = 0, | |
| theirsIndex = 0, | |
| mineOffset = 0, | |
| theirsOffset = 0; | |
| while (mineIndex < mine.hunks.length || theirsIndex < theirs.hunks.length) { | |
| var mineCurrent = mine.hunks[mineIndex] || { | |
| oldStart: Infinity | |
| }, | |
| theirsCurrent = theirs.hunks[theirsIndex] || { | |
| oldStart: Infinity | |
| }; | |
| if (hunkBefore(mineCurrent, theirsCurrent)) { | |
| // This patch does not overlap with any of the others, yay. | |
| ret.hunks.push(cloneHunk(mineCurrent, mineOffset)); | |
| mineIndex++; | |
| theirsOffset += mineCurrent.newLines - mineCurrent.oldLines; | |
| } else if (hunkBefore(theirsCurrent, mineCurrent)) { | |
| // This patch does not overlap with any of the others, yay. | |
| ret.hunks.push(cloneHunk(theirsCurrent, theirsOffset)); | |
| theirsIndex++; | |
| mineOffset += theirsCurrent.newLines - theirsCurrent.oldLines; | |
| } else { | |
| // Overlap, merge as best we can | |
| var mergedHunk = { | |
| oldStart: Math.min(mineCurrent.oldStart, theirsCurrent.oldStart), | |
| oldLines: 0, | |
| newStart: Math.min(mineCurrent.newStart + mineOffset, theirsCurrent.oldStart + theirsOffset), | |
| newLines: 0, | |
| lines: [] | |
| }; | |
| mergeLines(mergedHunk, mineCurrent.oldStart, mineCurrent.lines, theirsCurrent.oldStart, theirsCurrent.lines); | |
| theirsIndex++; | |
| mineIndex++; | |
| ret.hunks.push(mergedHunk); | |
| } | |
| } | |
| return ret; | |
| } | |
| function loadPatch(param, base) { | |
| if (typeof param === 'string') { | |
| if (/^@@/m.test(param) || /^Index:/m.test(param)) { | |
| return parsePatch(param)[0]; | |
| } | |
| if (!base) { | |
| throw new Error('Must provide a base reference or pass in a patch'); | |
| } | |
| return structuredPatch(undefined, undefined, base, param); | |
| } | |
| return param; | |
| } | |
| function fileNameChanged(patch) { | |
| return patch.newFileName && patch.newFileName !== patch.oldFileName; | |
| } | |
| function selectField(index, mine, theirs) { | |
| if (mine === theirs) { | |
| return mine; | |
| } else { | |
| index.conflict = true; | |
| return { | |
| mine: mine, | |
| theirs: theirs | |
| }; | |
| } | |
| } | |
| function hunkBefore(test, check) { | |
| return test.oldStart < check.oldStart && test.oldStart + test.oldLines < check.oldStart; | |
| } | |
| function cloneHunk(hunk, offset) { | |
| return { | |
| oldStart: hunk.oldStart, | |
| oldLines: hunk.oldLines, | |
| newStart: hunk.newStart + offset, | |
| newLines: hunk.newLines, | |
| lines: hunk.lines | |
| }; | |
| } | |
| function mergeLines(hunk, mineOffset, mineLines, theirOffset, theirLines) { | |
| // This will generally result in a conflicted hunk, but there are cases where the context | |
| // is the only overlap where we can successfully merge the content here. | |
| var mine = { | |
| offset: mineOffset, | |
| lines: mineLines, | |
| index: 0 | |
| }, | |
| their = { | |
| offset: theirOffset, | |
| lines: theirLines, | |
| index: 0 | |
| }; // Handle any leading content | |
| insertLeading(hunk, mine, their); | |
| insertLeading(hunk, their, mine); // Now in the overlap content. Scan through and select the best changes from each. | |
| while (mine.index < mine.lines.length && their.index < their.lines.length) { | |
| var mineCurrent = mine.lines[mine.index], | |
| theirCurrent = their.lines[their.index]; | |
| if ((mineCurrent[0] === '-' || mineCurrent[0] === '+') && (theirCurrent[0] === '-' || theirCurrent[0] === '+')) { | |
| // Both modified ... | |
| mutualChange(hunk, mine, their); | |
| } else if (mineCurrent[0] === '+' && theirCurrent[0] === ' ') { | |
| var _hunk$lines; | |
| // Mine inserted | |
| (_hunk$lines = hunk.lines).push.apply(_hunk$lines, _toConsumableArray(collectChange(mine))); | |
| } else if (theirCurrent[0] === '+' && mineCurrent[0] === ' ') { | |
| var _hunk$lines2; | |
| // Theirs inserted | |
| (_hunk$lines2 = hunk.lines).push.apply(_hunk$lines2, _toConsumableArray(collectChange(their))); | |
| } else if (mineCurrent[0] === '-' && theirCurrent[0] === ' ') { | |
| // Mine removed or edited | |
| removal(hunk, mine, their); | |
| } else if (theirCurrent[0] === '-' && mineCurrent[0] === ' ') { | |
| // Their removed or edited | |
| removal(hunk, their, mine, true); | |
| } else if (mineCurrent === theirCurrent) { | |
| // Context identity | |
| hunk.lines.push(mineCurrent); | |
| mine.index++; | |
| their.index++; | |
| } else { | |
| // Context mismatch | |
| conflict(hunk, collectChange(mine), collectChange(their)); | |
| } | |
| } // Now push anything that may be remaining | |
| insertTrailing(hunk, mine); | |
| insertTrailing(hunk, their); | |
| calcLineCount(hunk); | |
| } | |
| function mutualChange(hunk, mine, their) { | |
| var myChanges = collectChange(mine), | |
| theirChanges = collectChange(their); | |
| if (allRemoves(myChanges) && allRemoves(theirChanges)) { | |
| // Special case for remove changes that are supersets of one another | |
| if (arrayStartsWith(myChanges, theirChanges) && skipRemoveSuperset(their, myChanges, myChanges.length - theirChanges.length)) { | |
| var _hunk$lines3; | |
| (_hunk$lines3 = hunk.lines).push.apply(_hunk$lines3, _toConsumableArray(myChanges)); | |
| return; | |
| } else if (arrayStartsWith(theirChanges, myChanges) && skipRemoveSuperset(mine, theirChanges, theirChanges.length - myChanges.length)) { | |
| var _hunk$lines4; | |
| (_hunk$lines4 = hunk.lines).push.apply(_hunk$lines4, _toConsumableArray(theirChanges)); | |
| return; | |
| } | |
| } else if (arrayEqual(myChanges, theirChanges)) { | |
| var _hunk$lines5; | |
| (_hunk$lines5 = hunk.lines).push.apply(_hunk$lines5, _toConsumableArray(myChanges)); | |
| return; | |
| } | |
| conflict(hunk, myChanges, theirChanges); | |
| } | |
| function removal(hunk, mine, their, swap) { | |
| var myChanges = collectChange(mine), | |
| theirChanges = collectContext(their, myChanges); | |
| if (theirChanges.merged) { | |
| var _hunk$lines6; | |
| (_hunk$lines6 = hunk.lines).push.apply(_hunk$lines6, _toConsumableArray(theirChanges.merged)); | |
| } else { | |
| conflict(hunk, swap ? theirChanges : myChanges, swap ? myChanges : theirChanges); | |
| } | |
| } | |
| function conflict(hunk, mine, their) { | |
| hunk.conflict = true; | |
| hunk.lines.push({ | |
| conflict: true, | |
| mine: mine, | |
| theirs: their | |
| }); | |
| } | |
| function insertLeading(hunk, insert, their) { | |
| while (insert.offset < their.offset && insert.index < insert.lines.length) { | |
| var line = insert.lines[insert.index++]; | |
| hunk.lines.push(line); | |
| insert.offset++; | |
| } | |
| } | |
| function insertTrailing(hunk, insert) { | |
| while (insert.index < insert.lines.length) { | |
| var line = insert.lines[insert.index++]; | |
| hunk.lines.push(line); | |
| } | |
| } | |
| function collectChange(state) { | |
| var ret = [], | |
| operation = state.lines[state.index][0]; | |
| while (state.index < state.lines.length) { | |
| var line = state.lines[state.index]; // Group additions that are immediately after subtractions and treat them as one "atomic" modify change. | |
| if (operation === '-' && line[0] === '+') { | |
| operation = '+'; | |
| } | |
| if (operation === line[0]) { | |
| ret.push(line); | |
| state.index++; | |
| } else { | |
| break; | |
| } | |
| } | |
| return ret; | |
| } | |
| function collectContext(state, matchChanges) { | |
| var changes = [], | |
| merged = [], | |
| matchIndex = 0, | |
| contextChanges = false, | |
| conflicted = false; | |
| while (matchIndex < matchChanges.length && state.index < state.lines.length) { | |
| var change = state.lines[state.index], | |
| match = matchChanges[matchIndex]; // Once we've hit our add, then we are done | |
| if (match[0] === '+') { | |
| break; | |
| } | |
| contextChanges = contextChanges || change[0] !== ' '; | |
| merged.push(match); | |
| matchIndex++; // Consume any additions in the other block as a conflict to attempt | |
| // to pull in the remaining context after this | |
| if (change[0] === '+') { | |
| conflicted = true; | |
| while (change[0] === '+') { | |
| changes.push(change); | |
| change = state.lines[++state.index]; | |
| } | |
| } | |
| if (match.substr(1) === change.substr(1)) { | |
| changes.push(change); | |
| state.index++; | |
| } else { | |
| conflicted = true; | |
| } | |
| } | |
| if ((matchChanges[matchIndex] || '')[0] === '+' && contextChanges) { | |
| conflicted = true; | |
| } | |
| if (conflicted) { | |
| return changes; | |
| } | |
| while (matchIndex < matchChanges.length) { | |
| merged.push(matchChanges[matchIndex++]); | |
| } | |
| return { | |
| merged: merged, | |
| changes: changes | |
| }; | |
| } | |
| function allRemoves(changes) { | |
| return changes.reduce(function (prev, change) { | |
| return prev && change[0] === '-'; | |
| }, true); | |
| } | |
| function skipRemoveSuperset(state, removeChanges, delta) { | |
| for (var i = 0; i < delta; i++) { | |
| var changeContent = removeChanges[removeChanges.length - delta + i].substr(1); | |
| if (state.lines[state.index + i] !== ' ' + changeContent) { | |
| return false; | |
| } | |
| } | |
| state.index += delta; | |
| return true; | |
| } | |
| function calcOldNewLineCount(lines) { | |
| var oldLines = 0; | |
| var newLines = 0; | |
| lines.forEach(function (line) { | |
| if (typeof line !== 'string') { | |
| var myCount = calcOldNewLineCount(line.mine); | |
| var theirCount = calcOldNewLineCount(line.theirs); | |
| if (oldLines !== undefined) { | |
| if (myCount.oldLines === theirCount.oldLines) { | |
| oldLines += myCount.oldLines; | |
| } else { | |
| oldLines = undefined; | |
| } | |
| } | |
| if (newLines !== undefined) { | |
| if (myCount.newLines === theirCount.newLines) { | |
| newLines += myCount.newLines; | |
| } else { | |
| newLines = undefined; | |
| } | |
| } | |
| } else { | |
| if (newLines !== undefined && (line[0] === '+' || line[0] === ' ')) { | |
| newLines++; | |
| } | |
| if (oldLines !== undefined && (line[0] === '-' || line[0] === ' ')) { | |
| oldLines++; | |
| } | |
| } | |
| }); | |
| return { | |
| oldLines: oldLines, | |
| newLines: newLines | |
| }; | |
| } | |
| // See: http://code.google.com/p/google-diff-match-patch/wiki/API | |
| function convertChangesToDMP(changes) { | |
| var ret = [], | |
| change, | |
| operation; | |
| for (var i = 0; i < changes.length; i++) { | |
| change = changes[i]; | |
| if (change.added) { | |
| operation = 1; | |
| } else if (change.removed) { | |
| operation = -1; | |
| } else { | |
| operation = 0; | |
| } | |
| ret.push([operation, change.value]); | |
| } | |
| return ret; | |
| } | |
| function convertChangesToXML(changes) { | |
| var ret = []; | |
| for (var i = 0; i < changes.length; i++) { | |
| var change = changes[i]; | |
| if (change.added) { | |
| ret.push('<ins>'); | |
| } else if (change.removed) { | |
| ret.push('<del>'); | |
| } | |
| ret.push(escapeHTML(change.value)); | |
| if (change.added) { | |
| ret.push('</ins>'); | |
| } else if (change.removed) { | |
| ret.push('</del>'); | |
| } | |
| } | |
| return ret.join(''); | |
| } | |
| function escapeHTML(s) { | |
| var n = s; | |
| n = n.replace(/&/g, '&'); | |
| n = n.replace(/</g, '<'); | |
| n = n.replace(/>/g, '>'); | |
| n = n.replace(/"/g, '"'); | |
| return n; | |
| } | |
| /* See LICENSE file for terms of use */ | |
| exports.Diff = Diff; | |
| exports.diffChars = diffChars; | |
| exports.diffWords = diffWords; | |
| exports.diffWordsWithSpace = diffWordsWithSpace; | |
| exports.diffLines = diffLines; | |
| exports.diffTrimmedLines = diffTrimmedLines; | |
| exports.diffSentences = diffSentences; | |
| exports.diffCss = diffCss; | |
| exports.diffJson = diffJson; | |
| exports.diffArrays = diffArrays; | |
| exports.structuredPatch = structuredPatch; | |
| exports.createTwoFilesPatch = createTwoFilesPatch; | |
| exports.createPatch = createPatch; | |
| exports.applyPatch = applyPatch; | |
| exports.applyPatches = applyPatches; | |
| exports.parsePatch = parsePatch; | |
| exports.merge = merge; | |
| exports.convertChangesToDMP = convertChangesToDMP; | |
| exports.convertChangesToXML = convertChangesToXML; | |
| exports.canonicalize = canonicalize; | |
| Object.defineProperty(exports, '__esModule', { value: true }); | |
| })); | |
| //# sourceURL=webpack://LIB/./node_modules/diff/dist/diff.js?`)},"./node_modules/events/events.js":function(module,exports,__webpack_require__){eval(`// Copyright Joyent, Inc. and other Node contributors. | |
| // | |
| // Permission is hereby granted, free of charge, to any person obtaining a | |
| // copy of this software and associated documentation files (the | |
| // "Software"), to deal in the Software without restriction, including | |
| // without limitation the rights to use, copy, modify, merge, publish, | |
| // distribute, sublicense, and/or sell copies of the Software, and to permit | |
| // persons to whom the Software is furnished to do so, subject to the | |
| // following conditions: | |
| // | |
| // The above copyright notice and this permission notice shall be included | |
| // in all copies or substantial portions of the Software. | |
| // | |
| // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | |
| // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | |
| // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN | |
| // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, | |
| // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR | |
| // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE | |
| // USE OR OTHER DEALINGS IN THE SOFTWARE. | |
| var R = typeof Reflect === 'object' ? Reflect : null | |
| var ReflectApply = R && typeof R.apply === 'function' | |
| ? R.apply | |
| : function ReflectApply(target, receiver, args) { | |
| return Function.prototype.apply.call(target, receiver, args); | |
| } | |
| var ReflectOwnKeys | |
| if (R && typeof R.ownKeys === 'function') { | |
| ReflectOwnKeys = R.ownKeys | |
| } else if (Object.getOwnPropertySymbols) { | |
| ReflectOwnKeys = function ReflectOwnKeys(target) { | |
| return Object.getOwnPropertyNames(target) | |
| .concat(Object.getOwnPropertySymbols(target)); | |
| }; | |
| } else { | |
| ReflectOwnKeys = function ReflectOwnKeys(target) { | |
| return Object.getOwnPropertyNames(target); | |
| }; | |
| } | |
| function ProcessEmitWarning(warning) { | |
| if (console && console.warn) console.warn(warning); | |
| } | |
| var NumberIsNaN = Number.isNaN || function NumberIsNaN(value) { | |
| return value !== value; | |
| } | |
| function EventEmitter() { | |
| EventEmitter.init.call(this); | |
| } | |
| module.exports = EventEmitter; | |
| module.exports.once = once; | |
| // Backwards-compat with node 0.10.x | |
| EventEmitter.EventEmitter = EventEmitter; | |
| EventEmitter.prototype._events = undefined; | |
| EventEmitter.prototype._eventsCount = 0; | |
| EventEmitter.prototype._maxListeners = undefined; | |
| // By default EventEmitters will print a warning if more than 10 listeners are | |
| // added to it. This is a useful default which helps finding memory leaks. | |
| var defaultMaxListeners = 10; | |
| function checkListener(listener) { | |
| if (typeof listener !== 'function') { | |
| throw new TypeError('The "listener" argument must be of type Function. Received type ' + typeof listener); | |
| } | |
| } | |
| Object.defineProperty(EventEmitter, 'defaultMaxListeners', { | |
| enumerable: true, | |
| get: function() { | |
| return defaultMaxListeners; | |
| }, | |
| set: function(arg) { | |
| if (typeof arg !== 'number' || arg < 0 || NumberIsNaN(arg)) { | |
| throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received ' + arg + '.'); | |
| } | |
| defaultMaxListeners = arg; | |
| } | |
| }); | |
| EventEmitter.init = function() { | |
| if (this._events === undefined || | |
| this._events === Object.getPrototypeOf(this)._events) { | |
| this._events = Object.create(null); | |
| this._eventsCount = 0; | |
| } | |
| this._maxListeners = this._maxListeners || undefined; | |
| }; | |
| // Obviously not all Emitters should be limited to 10. This function allows | |
| // that to be increased. Set to zero for unlimited. | |
| EventEmitter.prototype.setMaxListeners = function setMaxListeners(n) { | |
| if (typeof n !== 'number' || n < 0 || NumberIsNaN(n)) { | |
| throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received ' + n + '.'); | |
| } | |
| this._maxListeners = n; | |
| return this; | |
| }; | |
| function _getMaxListeners(that) { | |
| if (that._maxListeners === undefined) | |
| return EventEmitter.defaultMaxListeners; | |
| return that._maxListeners; | |
| } | |
| EventEmitter.prototype.getMaxListeners = function getMaxListeners() { | |
| return _getMaxListeners(this); | |
| }; | |
| EventEmitter.prototype.emit = function emit(type) { | |
| var args = []; | |
| for (var i = 1; i < arguments.length; i++) args.push(arguments[i]); | |
| var doError = (type === 'error'); | |
| var events = this._events; | |
| if (events !== undefined) | |
| doError = (doError && events.error === undefined); | |
| else if (!doError) | |
| return false; | |
| // If there is no 'error' event listener then throw. | |
| if (doError) { | |
| var er; | |
| if (args.length > 0) | |
| er = args[0]; | |
| if (er instanceof Error) { | |
| // Note: The comments on the \`throw\` lines are intentional, they show | |
| // up in Node's output if this results in an unhandled exception. | |
| throw er; // Unhandled 'error' event | |
| } | |
| // At least give some kind of context to the user | |
| var err = new Error('Unhandled error.' + (er ? ' (' + er.message + ')' : '')); | |
| err.context = er; | |
| throw err; // Unhandled 'error' event | |
| } | |
| var handler = events[type]; | |
| if (handler === undefined) | |
| return false; | |
| if (typeof handler === 'function') { | |
| ReflectApply(handler, this, args); | |
| } else { | |
| var len = handler.length; | |
| var listeners = arrayClone(handler, len); | |
| for (var i = 0; i < len; ++i) | |
| ReflectApply(listeners[i], this, args); | |
| } | |
| return true; | |
| }; | |
| function _addListener(target, type, listener, prepend) { | |
| var m; | |
| var events; | |
| var existing; | |
| checkListener(listener); | |
| events = target._events; | |
| if (events === undefined) { | |
| events = target._events = Object.create(null); | |
| target._eventsCount = 0; | |
| } else { | |
| // To avoid recursion in the case that type === "newListener"! Before | |
| // adding it to the listeners, first emit "newListener". | |
| if (events.newListener !== undefined) { | |
| target.emit('newListener', type, | |
| listener.listener ? listener.listener : listener); | |
| // Re-assign \`events\` because a newListener handler could have caused the | |
| // this._events to be assigned to a new object | |
| events = target._events; | |
| } | |
| existing = events[type]; | |
| } | |
| if (existing === undefined) { | |
| // Optimize the case of one listener. Don't need the extra array object. | |
| existing = events[type] = listener; | |
| ++target._eventsCount; | |
| } else { | |
| if (typeof existing === 'function') { | |
| // Adding the second element, need to change to array. | |
| existing = events[type] = | |
| prepend ? [listener, existing] : [existing, listener]; | |
| // If we've already got an array, just append. | |
| } else if (prepend) { | |
| existing.unshift(listener); | |
| } else { | |
| existing.push(listener); | |
| } | |
| // Check for listener leak | |
| m = _getMaxListeners(target); | |
| if (m > 0 && existing.length > m && !existing.warned) { | |
| existing.warned = true; | |
| // No error code for this since it is a Warning | |
| // eslint-disable-next-line no-restricted-syntax | |
| var w = new Error('Possible EventEmitter memory leak detected. ' + | |
| existing.length + ' ' + String(type) + ' listeners ' + | |
| 'added. Use emitter.setMaxListeners() to ' + | |
| 'increase limit'); | |
| w.name = 'MaxListenersExceededWarning'; | |
| w.emitter = target; | |
| w.type = type; | |
| w.count = existing.length; | |
| ProcessEmitWarning(w); | |
| } | |
| } | |
| return target; | |
| } | |
| EventEmitter.prototype.addListener = function addListener(type, listener) { | |
| return _addListener(this, type, listener, false); | |
| }; | |
| EventEmitter.prototype.on = EventEmitter.prototype.addListener; | |
| EventEmitter.prototype.prependListener = | |
| function prependListener(type, listener) { | |
| return _addListener(this, type, listener, true); | |
| }; | |
| function onceWrapper() { | |
| if (!this.fired) { | |
| this.target.removeListener(this.type, this.wrapFn); | |
| this.fired = true; | |
| if (arguments.length === 0) | |
| return this.listener.call(this.target); | |
| return this.listener.apply(this.target, arguments); | |
| } | |
| } | |
| function _onceWrap(target, type, listener) { | |
| var state = { fired: false, wrapFn: undefined, target: target, type: type, listener: listener }; | |
| var wrapped = onceWrapper.bind(state); | |
| wrapped.listener = listener; | |
| state.wrapFn = wrapped; | |
| return wrapped; | |
| } | |
| EventEmitter.prototype.once = function once(type, listener) { | |
| checkListener(listener); | |
| this.on(type, _onceWrap(this, type, listener)); | |
| return this; | |
| }; | |
| EventEmitter.prototype.prependOnceListener = | |
| function prependOnceListener(type, listener) { | |
| checkListener(listener); | |
| this.prependListener(type, _onceWrap(this, type, listener)); | |
| return this; | |
| }; | |
| // Emits a 'removeListener' event if and only if the listener was removed. | |
| EventEmitter.prototype.removeListener = | |
| function removeListener(type, listener) { | |
| var list, events, position, i, originalListener; | |
| checkListener(listener); | |
| events = this._events; | |
| if (events === undefined) | |
| return this; | |
| list = events[type]; | |
| if (list === undefined) | |
| return this; | |
| if (list === listener || list.listener === listener) { | |
| if (--this._eventsCount === 0) | |
| this._events = Object.create(null); | |
| else { | |
| delete events[type]; | |
| if (events.removeListener) | |
| this.emit('removeListener', type, list.listener || listener); | |
| } | |
| } else if (typeof list !== 'function') { | |
| position = -1; | |
| for (i = list.length - 1; i >= 0; i--) { | |
| if (list[i] === listener || list[i].listener === listener) { | |
| originalListener = list[i].listener; | |
| position = i; | |
| break; | |
| } | |
| } | |
| if (position < 0) | |
| return this; | |
| if (position === 0) | |
| list.shift(); | |
| else { | |
| spliceOne(list, position); | |
| } | |
| if (list.length === 1) | |
| events[type] = list[0]; | |
| if (events.removeListener !== undefined) | |
| this.emit('removeListener', type, originalListener || listener); | |
| } | |
| return this; | |
| }; | |
| EventEmitter.prototype.off = EventEmitter.prototype.removeListener; | |
| EventEmitter.prototype.removeAllListeners = | |
| function removeAllListeners(type) { | |
| var listeners, events, i; | |
| events = this._events; | |
| if (events === undefined) | |
| return this; | |
| // not listening for removeListener, no need to emit | |
| if (events.removeListener === undefined) { | |
| if (arguments.length === 0) { | |
| this._events = Object.create(null); | |
| this._eventsCount = 0; | |
| } else if (events[type] !== undefined) { | |
| if (--this._eventsCount === 0) | |
| this._events = Object.create(null); | |
| else | |
| delete events[type]; | |
| } | |
| return this; | |
| } | |
| // emit removeListener for all listeners on all events | |
| if (arguments.length === 0) { | |
| var keys = Object.keys(events); | |
| var key; | |
| for (i = 0; i < keys.length; ++i) { | |
| key = keys[i]; | |
| if (key === 'removeListener') continue; | |
| this.removeAllListeners(key); | |
| } | |
| this.removeAllListeners('removeListener'); | |
| this._events = Object.create(null); | |
| this._eventsCount = 0; | |
| return this; | |
| } | |
| listeners = events[type]; | |
| if (typeof listeners === 'function') { | |
| this.removeListener(type, listeners); | |
| } else if (listeners !== undefined) { | |
| // LIFO order | |
| for (i = listeners.length - 1; i >= 0; i--) { | |
| this.removeListener(type, listeners[i]); | |
| } | |
| } | |
| return this; | |
| }; | |
| function _listeners(target, type, unwrap) { | |
| var events = target._events; | |
| if (events === undefined) | |
| return []; | |
| var evlistener = events[type]; | |
| if (evlistener === undefined) | |
| return []; | |
| if (typeof evlistener === 'function') | |
| return unwrap ? [evlistener.listener || evlistener] : [evlistener]; | |
| return unwrap ? | |
| unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length); | |
| } | |
| EventEmitter.prototype.listeners = function listeners(type) { | |
| return _listeners(this, type, true); | |
| }; | |
| EventEmitter.prototype.rawListeners = function rawListeners(type) { | |
| return _listeners(this, type, false); | |
| }; | |
| EventEmitter.listenerCount = function(emitter, type) { | |
| if (typeof emitter.listenerCount === 'function') { | |
| return emitter.listenerCount(type); | |
| } else { | |
| return listenerCount.call(emitter, type); | |
| } | |
| }; | |
| EventEmitter.prototype.listenerCount = listenerCount; | |
| function listenerCount(type) { | |
| var events = this._events; | |
| if (events !== undefined) { | |
| var evlistener = events[type]; | |
| if (typeof evlistener === 'function') { | |
| return 1; | |
| } else if (evlistener !== undefined) { | |
| return evlistener.length; | |
| } | |
| } | |
| return 0; | |
| } | |
| EventEmitter.prototype.eventNames = function eventNames() { | |
| return this._eventsCount > 0 ? ReflectOwnKeys(this._events) : []; | |
| }; | |
| function arrayClone(arr, n) { | |
| var copy = new Array(n); | |
| for (var i = 0; i < n; ++i) | |
| copy[i] = arr[i]; | |
| return copy; | |
| } | |
| function spliceOne(list, index) { | |
| for (; index + 1 < list.length; index++) | |
| list[index] = list[index + 1]; | |
| list.pop(); | |
| } | |
| function unwrapListeners(arr) { | |
| var ret = new Array(arr.length); | |
| for (var i = 0; i < ret.length; ++i) { | |
| ret[i] = arr[i].listener || arr[i]; | |
| } | |
| return ret; | |
| } | |
| function once(emitter, name) { | |
| return new Promise(function (resolve, reject) { | |
| function errorListener(err) { | |
| emitter.removeListener(name, resolver); | |
| reject(err); | |
| } | |
| function resolver() { | |
| if (typeof emitter.removeListener === 'function') { | |
| emitter.removeListener('error', errorListener); | |
| } | |
| resolve([].slice.call(arguments)); | |
| }; | |
| eventTargetAgnosticAddListener(emitter, name, resolver, { once: true }); | |
| if (name !== 'error') { | |
| addErrorHandlerIfEventEmitter(emitter, errorListener, { once: true }); | |
| } | |
| }); | |
| } | |
| function addErrorHandlerIfEventEmitter(emitter, handler, flags) { | |
| if (typeof emitter.on === 'function') { | |
| eventTargetAgnosticAddListener(emitter, 'error', handler, flags); | |
| } | |
| } | |
| function eventTargetAgnosticAddListener(emitter, name, listener, flags) { | |
| if (typeof emitter.on === 'function') { | |
| if (flags.once) { | |
| emitter.once(name, listener); | |
| } else { | |
| emitter.on(name, listener); | |
| } | |
| } else if (typeof emitter.addEventListener === 'function') { | |
| // EventTarget does not have \`error\` event semantics like Node | |
| // EventEmitters, we do not listen for \`error\` events here. | |
| emitter.addEventListener(name, function wrapListener(arg) { | |
| // IE does not have builtin \`{ once: true }\` support so we | |
| // have to do it manually. | |
| if (flags.once) { | |
| emitter.removeEventListener(name, wrapListener); | |
| } | |
| listener(arg); | |
| }); | |
| } else { | |
| throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type ' + typeof emitter); | |
| } | |
| } | |
| //# sourceURL=webpack://LIB/./node_modules/events/events.js?`)},"./node_modules/ieee754/index.js":function(module,exports){eval(`/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */ | |
| exports.read = function (buffer, offset, isLE, mLen, nBytes) { | |
| var e, m | |
| var eLen = (nBytes * 8) - mLen - 1 | |
| var eMax = (1 << eLen) - 1 | |
| var eBias = eMax >> 1 | |
| var nBits = -7 | |
| var i = isLE ? (nBytes - 1) : 0 | |
| var d = isLE ? -1 : 1 | |
| var s = buffer[offset + i] | |
| i += d | |
| e = s & ((1 << (-nBits)) - 1) | |
| s >>= (-nBits) | |
| nBits += eLen | |
| for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {} | |
| m = e & ((1 << (-nBits)) - 1) | |
| e >>= (-nBits) | |
| nBits += mLen | |
| for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {} | |
| if (e === 0) { | |
| e = 1 - eBias | |
| } else if (e === eMax) { | |
| return m ? NaN : ((s ? -1 : 1) * Infinity) | |
| } else { | |
| m = m + Math.pow(2, mLen) | |
| e = e - eBias | |
| } | |
| return (s ? -1 : 1) * m * Math.pow(2, e - mLen) | |
| } | |
| exports.write = function (buffer, value, offset, isLE, mLen, nBytes) { | |
| var e, m, c | |
| var eLen = (nBytes * 8) - mLen - 1 | |
| var eMax = (1 << eLen) - 1 | |
| var eBias = eMax >> 1 | |
| var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0) | |
| var i = isLE ? 0 : (nBytes - 1) | |
| var d = isLE ? 1 : -1 | |
| var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0 | |
| value = Math.abs(value) | |
| if (isNaN(value) || value === Infinity) { | |
| m = isNaN(value) ? 1 : 0 | |
| e = eMax | |
| } else { | |
| e = Math.floor(Math.log(value) / Math.LN2) | |
| if (value * (c = Math.pow(2, -e)) < 1) { | |
| e-- | |
| c *= 2 | |
| } | |
| if (e + eBias >= 1) { | |
| value += rt / c | |
| } else { | |
| value += rt * Math.pow(2, 1 - eBias) | |
| } | |
| if (value * c >= 2) { | |
| e++ | |
| c /= 2 | |
| } | |
| if (e + eBias >= eMax) { | |
| m = 0 | |
| e = eMax | |
| } else if (e + eBias >= 1) { | |
| m = ((value * c) - 1) * Math.pow(2, mLen) | |
| e = e + eBias | |
| } else { | |
| m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen) | |
| e = 0 | |
| } | |
| } | |
| for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {} | |
| e = (e << mLen) | m | |
| eLen += mLen | |
| for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {} | |
| buffer[offset + i - d] |= s * 128 | |
| } | |
| //# sourceURL=webpack://LIB/./node_modules/ieee754/index.js?`)},"./node_modules/isarray/index.js":function(module,exports){eval(`var toString = {}.toString; | |
| module.exports = Array.isArray || function (arr) { | |
| return toString.call(arr) == '[object Array]'; | |
| }; | |
| //# sourceURL=webpack://LIB/./node_modules/isarray/index.js?`)},"./node_modules/sha1/sha1.js":function(module,exports,__webpack_require__){eval(`/* WEBPACK VAR INJECTION */(function(Buffer) {(function() { | |
| var crypt = __webpack_require__(/*! crypt */ "./node_modules/crypt/crypt.js"), | |
| utf8 = __webpack_require__(/*! charenc */ "./node_modules/charenc/charenc.js").utf8, | |
| bin = __webpack_require__(/*! charenc */ "./node_modules/charenc/charenc.js").bin, | |
| // The core | |
| sha1 = function (message) { | |
| // Convert to byte array | |
| if (message.constructor == String) | |
| message = utf8.stringToBytes(message); | |
| else if (typeof Buffer !== 'undefined' && typeof Buffer.isBuffer == 'function' && Buffer.isBuffer(message)) | |
| message = Array.prototype.slice.call(message, 0); | |
| else if (!Array.isArray(message)) | |
| message = message.toString(); | |
| // otherwise assume byte array | |
| var m = crypt.bytesToWords(message), | |
| l = message.length * 8, | |
| w = [], | |
| H0 = 1732584193, | |
| H1 = -271733879, | |
| H2 = -1732584194, | |
| H3 = 271733878, | |
| H4 = -1009589776; | |
| // Padding | |
| m[l >> 5] |= 0x80 << (24 - l % 32); | |
| m[((l + 64 >>> 9) << 4) + 15] = l; | |
| for (var i = 0; i < m.length; i += 16) { | |
| var a = H0, | |
| b = H1, | |
| c = H2, | |
| d = H3, | |
| e = H4; | |
| for (var j = 0; j < 80; j++) { | |
| if (j < 16) | |
| w[j] = m[i + j]; | |
| else { | |
| var n = w[j - 3] ^ w[j - 8] ^ w[j - 14] ^ w[j - 16]; | |
| w[j] = (n << 1) | (n >>> 31); | |
| } | |
| var t = ((H0 << 5) | (H0 >>> 27)) + H4 + (w[j] >>> 0) + ( | |
| j < 20 ? (H1 & H2 | ~H1 & H3) + 1518500249 : | |
| j < 40 ? (H1 ^ H2 ^ H3) + 1859775393 : | |
| j < 60 ? (H1 & H2 | H1 & H3 | H2 & H3) - 1894007588 : | |
| (H1 ^ H2 ^ H3) - 899497514); | |
| H4 = H3; | |
| H3 = H2; | |
| H2 = (H1 << 30) | (H1 >>> 2); | |
| H1 = H0; | |
| H0 = t; | |
| } | |
| H0 += a; | |
| H1 += b; | |
| H2 += c; | |
| H3 += d; | |
| H4 += e; | |
| } | |
| return [H0, H1, H2, H3, H4]; | |
| }, | |
| // Public API | |
| api = function (message, options) { | |
| var digestbytes = crypt.wordsToBytes(sha1(message)); | |
| return options && options.asBytes ? digestbytes : | |
| options && options.asString ? bin.bytesToString(digestbytes) : | |
| crypt.bytesToHex(digestbytes); | |
| }; | |
| api._blocksize = 16; | |
| api._digestsize = 20; | |
| module.exports = api; | |
| })(); | |
| /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../buffer/index.js */ "./node_modules/buffer/index.js").Buffer)) | |
| //# sourceURL=webpack://LIB/./node_modules/sha1/sha1.js?`)},"./node_modules/tslib/tslib.es6.js":function(module,__webpack_exports__,__webpack_require__){eval(`__webpack_require__.r(__webpack_exports__); | |
| /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__extends", function() { return __extends; }); | |
| /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__assign", function() { return __assign; }); | |
| /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__rest", function() { return __rest; }); | |
| /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__decorate", function() { return __decorate; }); | |
| /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__param", function() { return __param; }); | |
| /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__metadata", function() { return __metadata; }); | |
| /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__awaiter", function() { return __awaiter; }); | |
| /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__generator", function() { return __generator; }); | |
| /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__createBinding", function() { return __createBinding; }); | |
| /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__exportStar", function() { return __exportStar; }); | |
| /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__values", function() { return __values; }); | |
| /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__read", function() { return __read; }); | |
| /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__spread", function() { return __spread; }); | |
| /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__spreadArrays", function() { return __spreadArrays; }); | |
| /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__await", function() { return __await; }); | |
| /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncGenerator", function() { return __asyncGenerator; }); | |
| /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncDelegator", function() { return __asyncDelegator; }); | |
| /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncValues", function() { return __asyncValues; }); | |
| /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__makeTemplateObject", function() { return __makeTemplateObject; }); | |
| /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importStar", function() { return __importStar; }); | |
| /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importDefault", function() { return __importDefault; }); | |
| /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__classPrivateFieldGet", function() { return __classPrivateFieldGet; }); | |
| /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__classPrivateFieldSet", function() { return __classPrivateFieldSet; }); | |
| /*! *****************************************************************************\r | |
| Copyright (c) Microsoft Corporation.\r | |
| \r | |
| Permission to use, copy, modify, and/or distribute this software for any\r | |
| purpose with or without fee is hereby granted.\r | |
| \r | |
| THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r | |
| REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r | |
| AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r | |
| INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r | |
| LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r | |
| OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r | |
| PERFORMANCE OF THIS SOFTWARE.\r | |
| ***************************************************************************** */\r | |
| /* global Reflect, Promise */\r | |
| \r | |
| var extendStatics = function(d, b) {\r | |
| extendStatics = Object.setPrototypeOf ||\r | |
| ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r | |
| function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\r | |
| return extendStatics(d, b);\r | |
| };\r | |
| \r | |
| function __extends(d, b) {\r | |
| extendStatics(d, b);\r | |
| function __() { this.constructor = d; }\r | |
| d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r | |
| }\r | |
| \r | |
| var __assign = function() {\r | |
| __assign = Object.assign || function __assign(t) {\r | |
| for (var s, i = 1, n = arguments.length; i < n; i++) {\r | |
| s = arguments[i];\r | |
| for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r | |
| }\r | |
| return t;\r | |
| }\r | |
| return __assign.apply(this, arguments);\r | |
| }\r | |
| \r | |
| function __rest(s, e) {\r | |
| var t = {};\r | |
| for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r | |
| t[p] = s[p];\r | |
| if (s != null && typeof Object.getOwnPropertySymbols === "function")\r | |
| for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r | |
| if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r | |
| t[p[i]] = s[p[i]];\r | |
| }\r | |
| return t;\r | |
| }\r | |
| \r | |
| function __decorate(decorators, target, key, desc) {\r | |
| var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r | |
| if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);\r | |
| else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r | |
| return c > 3 && r && Object.defineProperty(target, key, r), r;\r | |
| }\r | |
| \r | |
| function __param(paramIndex, decorator) {\r | |
| return function (target, key) { decorator(target, key, paramIndex); }\r | |
| }\r | |
| \r | |
| function __metadata(metadataKey, metadataValue) {\r | |
| if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);\r | |
| }\r | |
| \r | |
| function __awaiter(thisArg, _arguments, P, generator) {\r | |
| function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r | |
| return new (P || (P = Promise))(function (resolve, reject) {\r | |
| function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r | |
| function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }\r | |
| function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r | |
| step((generator = generator.apply(thisArg, _arguments || [])).next());\r | |
| });\r | |
| }\r | |
| \r | |
| function __generator(thisArg, body) {\r | |
| var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r | |
| return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;\r | |
| function verb(n) { return function (v) { return step([n, v]); }; }\r | |
| function step(op) {\r | |
| if (f) throw new TypeError("Generator is already executing.");\r | |
| while (_) try {\r | |
| if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r | |
| if (y = 0, t) op = [op[0] & 2, t.value];\r | |
| switch (op[0]) {\r | |
| case 0: case 1: t = op; break;\r | |
| case 4: _.label++; return { value: op[1], done: false };\r | |
| case 5: _.label++; y = op[1]; op = [0]; continue;\r | |
| case 7: op = _.ops.pop(); _.trys.pop(); continue;\r | |
| default:\r | |
| if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r | |
| if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r | |
| if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r | |
| if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r | |
| if (t[2]) _.ops.pop();\r | |
| _.trys.pop(); continue;\r | |
| }\r | |
| op = body.call(thisArg, _);\r | |
| } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r | |
| if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r | |
| }\r | |
| }\r | |
| \r | |
| function __createBinding(o, m, k, k2) {\r | |
| if (k2 === undefined) k2 = k;\r | |
| o[k2] = m[k];\r | |
| }\r | |
| \r | |
| function __exportStar(m, exports) {\r | |
| for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) exports[p] = m[p];\r | |
| }\r | |
| \r | |
| function __values(o) {\r | |
| var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;\r | |
| if (m) return m.call(o);\r | |
| if (o && typeof o.length === "number") return {\r | |
| next: function () {\r | |
| if (o && i >= o.length) o = void 0;\r | |
| return { value: o && o[i++], done: !o };\r | |
| }\r | |
| };\r | |
| throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");\r | |
| }\r | |
| \r | |
| function __read(o, n) {\r | |
| var m = typeof Symbol === "function" && o[Symbol.iterator];\r | |
| if (!m) return o;\r | |
| var i = m.call(o), r, ar = [], e;\r | |
| try {\r | |
| while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r | |
| }\r | |
| catch (error) { e = { error: error }; }\r | |
| finally {\r | |
| try {\r | |
| if (r && !r.done && (m = i["return"])) m.call(i);\r | |
| }\r | |
| finally { if (e) throw e.error; }\r | |
| }\r | |
| return ar;\r | |
| }\r | |
| \r | |
| function __spread() {\r | |
| for (var ar = [], i = 0; i < arguments.length; i++)\r | |
| ar = ar.concat(__read(arguments[i]));\r | |
| return ar;\r | |
| }\r | |
| \r | |
| function __spreadArrays() {\r | |
| for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r | |
| for (var r = Array(s), k = 0, i = 0; i < il; i++)\r | |
| for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r | |
| r[k] = a[j];\r | |
| return r;\r | |
| };\r | |
| \r | |
| function __await(v) {\r | |
| return this instanceof __await ? (this.v = v, this) : new __await(v);\r | |
| }\r | |
| \r | |
| function __asyncGenerator(thisArg, _arguments, generator) {\r | |
| if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");\r | |
| var g = generator.apply(thisArg, _arguments || []), i, q = [];\r | |
| return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;\r | |
| function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r | |
| function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r | |
| function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r | |
| function fulfill(value) { resume("next", value); }\r | |
| function reject(value) { resume("throw", value); }\r | |
| function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r | |
| }\r | |
| \r | |
| function __asyncDelegator(o) {\r | |
| var i, p;\r | |
| return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;\r | |
| function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }\r | |
| }\r | |
| \r | |
| function __asyncValues(o) {\r | |
| if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");\r | |
| var m = o[Symbol.asyncIterator], i;\r | |
| return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);\r | |
| function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r | |
| function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r | |
| }\r | |
| \r | |
| function __makeTemplateObject(cooked, raw) {\r | |
| if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }\r | |
| return cooked;\r | |
| };\r | |
| \r | |
| function __importStar(mod) {\r | |
| if (mod && mod.__esModule) return mod;\r | |
| var result = {};\r | |
| if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];\r | |
| result.default = mod;\r | |
| return result;\r | |
| }\r | |
| \r | |
| function __importDefault(mod) {\r | |
| return (mod && mod.__esModule) ? mod : { default: mod };\r | |
| }\r | |
| \r | |
| function __classPrivateFieldGet(receiver, privateMap) {\r | |
| if (!privateMap.has(receiver)) {\r | |
| throw new TypeError("attempted to get private field on non-instance");\r | |
| }\r | |
| return privateMap.get(receiver);\r | |
| }\r | |
| \r | |
| function __classPrivateFieldSet(receiver, privateMap, value) {\r | |
| if (!privateMap.has(receiver)) {\r | |
| throw new TypeError("attempted to set private field on non-instance");\r | |
| }\r | |
| privateMap.set(receiver, value);\r | |
| return value;\r | |
| }\r | |
| //# sourceURL=webpack://LIB/./node_modules/tslib/tslib.es6.js?`)},"./node_modules/webpack/buildin/global.js":function(module,exports){eval(`var g; | |
| // This works in non-strict mode | |
| g = (function() { | |
| return this; | |
| })(); | |
| try { | |
| // This works if eval is allowed (see CSP) | |
| g = g || new Function("return this")(); | |
| } catch (e) { | |
| // This works if the window reference is available | |
| if (typeof window === "object") g = window; | |
| } | |
| // g can still be undefined, but nothing to do about it... | |
| // We return undefined, instead of nothing here, so it's | |
| // easier to handle this case. if(!global) { ...} | |
| module.exports = g; | |
| //# sourceURL=webpack://LIB/(webpack)/buildin/global.js?`)}});LIB===void 0&&console.error("esm-webpack-plugin: nothing exported!");const _LIB$RemoteFile=LIB.RemoteFile,_sfc_main$2={props:{host:String,filePath:String,content:String,filePathReadOnly:Boolean},data(){return{remoteFile:new _LIB$RemoteFile,loading:!1}},created(){this.remoteFile.on("sync",({timestamp:t})=>{const e=this.remoteFile.content.replace(/\r\n/g,` | |
| `);this.$emit("update:content",e),this.$nextTick(()=>this.loading=!1),console.debug("remote file synchronized:",new Date(t))}),this.remoteFile.on("connected",()=>this.$emit("update:connected",!0)),this.remoteFile.on("disconnected",()=>{this.loading=!1,this.$emit("update:connected",!1)}),this.debouncedContentUpdate=useDebounceFn(t=>{this.remoteFile.connected&&t!==this.remoteFile.content&&(this.remoteFile.content=t)},1e3)},methods:{onLink(){this.remoteFile.connected?this.disconnect():this.connect()},connect(){this.loading=!0,this.remoteFile.connect(this.host,this.filePath)},disconnect(){this.remoteFile.close()}},watch:{content(t){this.debouncedContentUpdate(t)},loading(t){this.$emit("update:loading",t)}}},_hoisted_1$2=["disabled"],_hoisted_2$2=["value","readonly"];function _sfc_render$2(t,e,r,s,n,o){return openBlock(),createElementBlock("span",{class:normalizeClass({connected:n.remoteFile.connected})},[createBaseVNode("button",{class:normalizeClass(["link",{on:n.remoteFile.connected}]),onClick:e[0]||(e[0]=(...l)=>o.onLink&&o.onLink(...l)),disabled:!r.host||!r.filePath},"🔗",10,_hoisted_1$2),createBaseVNode("input",{class:"file-path",type:"text",value:r.filePath,readonly:r.filePathReadOnly,onInput:e[1]||(e[1]=l=>t.$emit("update:filePath",l.target.value))},null,40,_hoisted_2$2)],2)}const RemoteFile=_export_sfc(_sfc_main$2,[["render",_sfc_render$2]]),_sfc_main$1={name:"dir-browser",props:{homeURL:String,shown:Boolean,handlePattern:RegExp,autoHide:Boolean,compactFolders:Boolean},data(){return{href:this.homeURL,hover:!1}},created(){this.debouncedAutoHide=useDebounceFn(()=>{this.hover||this.hide()},1e3)},methods:{onFrameLoad(){this.href=this.$refs.frame.contentWindow.location.href},hide(){this.$emit("update:shown",!1)},reload(){this.$refs.frame.contentWindow.location.reload()}},watch:{href(){if(this.handlePattern&&this.handlePattern.test(this.href)){this.$refs.frame.contentWindow.history.back(),this.hide();const t=Math.max(this.href.indexOf(this.homeURL),0),e=decodeURI(this.href.substr(t+this.homeURL.length));this.$emit("pickFile",e)}else if(this.compactFolders){const t=this.$refs.frame.contentDocument.querySelectorAll("#files li"),e=this.$refs.frame.contentDocument.querySelectorAll("#files .folder");t.length===2&&e.length===1&&this.$refs.frame.contentDocument.querySelector("#files .folder").click()}},hover(t){!t&&this.autoHide&&this.debouncedAutoHide()}}},_hoisted_1$1=["src"],_hoisted_2$1={class:"controls"};function _sfc_render$1(t,e,r,s,n,o){return withDirectives((openBlock(),createElementBlock("div",{class:"dir-browser",onMouseenter:e[3]||(e[3]=l=>n.hover=!0),onMouseleave:e[4]||(e[4]=l=>n.hover=!1)},[createBaseVNode("iframe",{ref:"frame",src:r.homeURL,onLoad:e[0]||(e[0]=(...l)=>o.onFrameLoad&&o.onFrameLoad(...l))},null,40,_hoisted_1$1),createBaseVNode("div",_hoisted_2$1,[createBaseVNode("button",{onClick:e[1]||(e[1]=l=>t.$refs.frame.contentWindow.location.href=r.homeURL)},toDisplayString("🏠")),createBaseVNode("button",{onClick:e[2]||(e[2]=l=>t.$refs.frame.contentWindow.history.back())},"⇦")])],544)),[[vShow,r.shown]])}const DirBrowser=_export_sfc(_sfc_main$1,[["render",_sfc_render$1],["__scopeId","data-v-af726797"]]),QuitClearner={created(){this.quitCleaner=new Promise(t=>this.quitClear=t)},methods:{async appendCleaner(t){await Promise.race([this.quitCleaner,"pending"])!=="pending"?t():this.quitCleaner=this.quitCleaner.then(t)}},beforeUnmount(){this.quitClear()}},INIT_LILY=`\\version "2.20.0" | |
| %% additional definitions required by the score: | |
| fz = #(make-dynamic-script "fz") | |
| \\language "english" | |
| \\header { | |
| encodingsoftware = "Finale 2014 for Windows" | |
| arranger = \\markup \\column { \\line { "Op.25.No.9" } \\line { "Frédéric Chopin" } } | |
| encodingdate = "2018-02-08" | |
| subtitle = "Butterfly" | |
| title = "G-flat major Étude" | |
| } | |
| #(set-global-staff-size 24) | |
| \\paper { | |
| paper-width = 24.34\\cm | |
| paper-height = 22.36\\cm | |
| top-margin = 0.99\\cm | |
| bottom-margin = 1.67\\cm | |
| left-margin = 0.99\\cm | |
| right-margin = 0.89\\cm | |
| between-system-space = 2.65\\cm | |
| page-top-space = 1.79\\cm | |
| ragged-last = ##t | |
| } | |
| \\layout { | |
| \\context { | |
| \\Score | |
| autoBeaming = ##f | |
| } | |
| } | |
| PartPOneVoiceOne = \\relative bf' { | |
| \\clef "treble" \\key gf \\major \\time 2/4 \\stemUp bf8 ( s8 _\\markup { \\bold \\italic { leggiero } } df8 s8 | % 1 | |
| gf,8 s8 bf8 s8 | % 2 | |
| ef,8 s8 gf8 s8 | % 3 | |
| af8 s8 af8 s8 | % 4 | |
| bf'8 s8 df,8 s8 | % 5 | |
| gf8 s8 bf,8 s8 | % 6 | |
| ef8 s8 gf,8 s8 | % 7 | |
| af8 s8 gf4 | % 8 | |
| af8 s8 _\\< af8 s8 | % 9 | |
| \\barNumberCheck #10 ef'8 s8 e8 f8 -\\! | % 10 | |
| ef8 _\\> s8 af,8 s8 | % 11 | |
| bf8 s8 e,8 f8 -\\! | % 12 | |
| f'8 s8 af,8 _\\< s8 | % 13 | |
| df'8 s8 e,8 f8 | % 14 | |
| ef'8 s8 af,,8 _\\> s8 | % 15 | |
| c8 s8 df8 s8 -\\! | % 16 | |
| df8 _\\p s8 df8 s8 | % 17 | |
| cf8 s8 cf8 s8 | % 18 | |
| gf8 s8 af8 s8 | % 19 | |
| \\barNumberCheck #20 f8 s8 af8 df8 | % 20 | |
| \\ottava #1 df''8 s8 df8 _\\markup { \\bold \\italic { cresc . } } s8 | % 21 | |
| cf8 s8 cf8 s8 | % 22 | |
| gf8 s8 af,8 s8 | % 23 | |
| gf8 s8 \\ottava #0 eff8 s8 | % 24 | |
| bf8 s8 _\\markup { \\bold \\italic { marcato } } df8 s8 | % 25 | |
| gf,8 s8 bf8 s8 | % 26 | |
| ef,8 s8 gf8 s8 | % 27 | |
| af8 s8 af8 s8 | % 28 | |
| bf8 s8 df8 _\\markup { \\bold \\italic { cresc . } } s8 | % 29 | |
| \\barNumberCheck #30 cf8 s8 ef8 s8 | % 30 | |
| \\ottava #1 ef8 s8 gf8 s8 | % 31 | |
| af8 s8 bff8 s8 | % 32 | |
| bf8 _\\ff s8 ^\\markup { \\bold \\italic { appassionato } } bf8 s8 | % 33 | |
| af8 s8 gf8 s8 | % 34 | |
| ef8 s8 df8 s8 | % 35 | |
| cf8 s8 _\\markup { \\bold \\italic { riten . } } bff8 af8 | % 36 | |
| s4 af8 _\\p s8 | % 37 | |
| df8 s8 af8 s8 | % 38 | |
| df,8 s8 af'8 s8 _\\> | % 39 | |
| \\barNumberCheck #40 df8 s8 af8 -\\! s8 | % 40 | |
| s4 \\ottava #1 af''8 s8 _\\markup { \\bold \\italic { leggierissimo } } | % 41 | |
| df8 s8 af8 s8 | % 42 | |
| df,8 s8 af'8 s8 | % 43 | |
| \\ottava #1 df8 s8 af8 s8 | % 44 | |
| \\stemDown gf,16 ^1 [ gf'16 ^3 <ef cf'>16 ^. ^2 ^5 <df bf'>16 ) ^. ^1 ^4 ] bf16 ( ^1 [ gf'16 <ef cf'>16 ^. <df bf'>16 ) ^. ] | % 45 | |
| bf16 ( ^1 [ gf'16 _\\markup { \\bold \\italic { dimin . } } <ef cf'>16 ^. <df bf'>16 ^. ^1 ] bf16 ^1 [ gf'16 <ef cf'>16 ^. \\ottava #0 <df bf'>16 ^. ] | % 46 | |
| \\ottava #1 bf16 [ gf'16 <ef cf'>16 ^. <df bf'>16 ^. ] bf16 [ gf'16 <ef cf'>16 ^. <df bf'>16 ) ^. ] | % 47 | |
| bf16 ( [ gf'16 <ef cf'>16 ^. <df bf'>16 ^. ] bf16 [ gf'16 <ef cf'>16 ^. <df bf'>16 ^. ] | % 48 | |
| \\ottava #0 <bf gf'>8 ) ^. r8 r4 | % 49 | |
| \\barNumberCheck #50 r4 \\stemUp bf,,16 ( [ _\\markup { \\bold \\italic { poco rit . } } gf'16 _\\> <ef cf'>16 <df bf'>16 ^1 ^4 ] | % 50 | |
| <bf gf'>8 ) ^2 ^5 -\\! r8 r4 \\bar "|." | |
| } | |
| PartPOneVoiceThree = \\relative gf { | |
| \\clef "bass" \\key gf \\major \\time 2/4 \\stemDown gf8 ^. ^> [ <bf df gf>8 ^. ] f8 ^. ^> [ <af df af'>8 ^. ] | % 1 | |
| ef8 ^. ^> [ <gf bf ef>8 ^. ] df8 ^. ^> [ <f bf f'>8 ^. ] | % 2 | |
| cf8 ^. ^> [ <gf' cf>8 ^. ] bf,8 ^. ^> [ <df gf df'>8 ^. ] | % 3 | |
| c8 ^. ^> [ <gf' af ef'>8 ^. ] df8 ^. ^> [ <cf' df f>8 ^. ] | % 4 | |
| gf8 ^. ^> [ <bf df gf>8 ^. ] f8 ^. ^> [ <af df af'>8 ^. ] | % 5 | |
| ef8 ^. ^> [ <gf bf ef>8 ^. ] df8 ^. ^> [ <f bf f'>8 ^. ] | % 6 | |
| cf8 ^. ^> [ <gf' cf>8 ^. ] bf,8 ^. ^> [ <df gf df'>8 ^. ] | % 7 | |
| <c gf' ef'>8 ( \\arpeggio ^> [ \\arpeggio \\arpeggio \\sustainOn <df cf' f>8 \\arpeggio \\arpeggio \\arpeggio \\sustainOff <gf bf>8 ) ^> ] \\sustainOn r8 | % 8 | |
| df8 ^. [ \\sustainOff \\sustainOn <af' df f>8 ^. ] \\sustainOff c,8 ^. [ \\sustainOn <af' ef' gf>8 ^. ] \\sustainOff | % 9 | |
| af,8 ^. [ \\sustainOn <af' c gf'>8 ^. ] \\sustainOff df,8 ^. [ \\sustainOn <af' df f>8 ^. ] \\sustainOff | % 10 | |
| g,8 ^. [ \\sustainOn <e' bf' df>8 ^. ] \\sustainOff af,8 ^. [ \\sustainOn <f' af df>8 ^. ] \\sustainOff | % 11 | |
| af,8 ^. [ \\sustainOn <ef' gf af c>8 ^. ] \\sustainOff df8 ^. [ \\sustainOn <af' df>8 ^. ] \\sustainOff | % 12 | |
| df,8 ^. [ \\sustainOn <af' df>8 ^. ] c,8 ^. [ \\sustainOff \\sustainOn <af' ef'>8 ^. ] \\sustainOff | % 13 | |
| bf,8 ^. [ \\sustainOn <bf' df g>8 ^. ] af,8 ^. [ \\sustainOff \\sustainOn <af' df af'>8 ^. ] | % 14 | |
| <g, g'>8 ^. [ \\sustainOff \\sustainOn <df'' ef bf'>8 ^. ] af,8 ^. [ \\sustainOff \\sustainOn <f' af df>8 ^. ] \\sustainOff | % 15 | |
| af,,8 ^. [ \\sustainOn <ef'' gf c>8 ^. ] \\sustainOff df,8 ^. [ \\sustainOn <af'' df f>8 ^. ] \\sustainOff | % 16 | |
| df,8 ^. [ \\sustainOn <bf' g'>8 ^. ] \\sustainOff df,8 ^. [ \\sustainOn <cf' af'>8 ^. ] \\sustainOff | % 17 | |
| df,8 ^. [ \\sustainOn <af' f'>8 ^. ] \\sustainOff df,8 ^. [ \\sustainOn <bff' gf'>8 ^. ] \\sustainOff | % 18 | |
| df,,8 ^. [ \\sustainOn <ef' c'>8 ^. ] \\sustainOff df,8 ^. [ \\sustainOn <ef' c'>8 ^. ] \\sustainOff | % 19 | |
| \\barNumberCheck #20 df,8 ^. [ \\sustainOn <f' df'>8 ^. ] \\sustainOff df8 ^. [ \\sustainOn <af' f'>8 ^. ] \\sustainOff | % 20 | |
| df,8 ^. [ \\sustainOn <bf' g'>8 ^. ] \\sustainOff df,8 ^. [ \\sustainOn <cf' af'>8 ^. ] \\sustainOff | % 21 | |
| df,8 ^. [ \\sustainOn <af' f'>8 ^. ] \\sustainOff df,8 ^. [ \\sustainOn <bff' gf'>8 ^. ] \\sustainOff | % 22 | |
| df,,8 ^. [ \\sustainOn <bff'' c gf'>8 ^. ] \\sustainOff df,8 ^. [ \\sustainOn <af' c gf'>8 ^. ] \\sustainOff | % 23 | |
| df,8 ^. [ \\sustainOn <af' cf gf'>8 ^. ] \\sustainOff df,8 ^. ^> [ \\sustainOn <af' cf f>8 ^. ] \\sustainOff | % 24 | |
| <gf, gf'>8 ^. [ ^\\f \\sustainOn <bf' df gf>8 ^. ] \\sustainOff <f, f'>8 ^. [ \\sustainOn <af' df af'>8 ^. ] \\sustainOff | % 25 | |
| <ef, ef'>8 ^. [ \\sustainOn <gf' bf ef>8 ^. ] \\sustainOff <df, df'>8 ^. [ \\sustainOn <f' bf f'>8 ^. ] \\sustainOff | % 26 | |
| <cf, cf'>8 ^. [ \\sustainOn <ef' gf cf>8 ^. ] \\sustainOff <bf, bf'>8 ^. [ \\sustainOn <df' gf df'>8 ^. ] \\sustainOff | % 27 | |
| <c, c'>8 ^. [ \\sustainOn <gf'' af ef'>8 ^. ] \\sustainOff <df, df'>8 ^. [ \\sustainOn <af'' cf f>8 ^. ] \\sustainOff | % 28 | |
| <gf, gf'>8 ^. [ \\sustainOn <bf' df gf>8 ^. ] \\sustainOff <f, f'>8 ^. [ \\sustainOn <af' df af'>8 ^. ] \\sustainOff | % 29 | |
| \\barNumberCheck #30 <af, af'>8 ^. [ \\sustainOn <cf' ef af>8 ^. ] \\sustainOff <g, g'>8 ^. [ \\sustainOn <bf' ef bf'>8 ^. ] \\sustainOff | % 30 | |
| <cf, cf'>8 ^. [ \\sustainOn \\clef "treble" <ef' gf cf>8 ^. ] \\sustainOff \\clef "bass" <bf, bf'>8 ^. [ \\sustainOn \\clef "treble" <df' gf df'>8 ^. ] \\sustainOff | % 31 | |
| <c, c'>8 ^. [ \\sustainOn \\clef "treble" <gf'' ef'>8 ^. ] _\\fz r8 \\clef "bass" \\stemUp <c,,, c'>8 ( \\sustainOff | % 32 | |
| \\stemDown <df df'>8 ) ^. [ \\sustainOn <bf'' gf'>8 ^. ] \\sustainOff <d,, d'>8 ^. [ \\sustainOn <bf'' f'>8 ^. ] \\sustainOff | % 33 | |
| <ef,, ef'>8 ^. [ \\sustainOn <bf'' ef gf>8 ^. ] \\sustainOff <c,, c'>8 ^. [ \\sustainOn <bff'' ef gf>8 ^. ] \\sustainOff | % 34 | |
| <df,, df'>8 ^. [ \\sustainOn <af'' df gf>8 ^. ] \\sustainOff r4 | % 35 | |
| \\stemUp <df,,, df'>8 _. [ \\sustainOn \\stemDown <af''' cf f>8 _. ] r4 | % 36 | |
| s8 \\sustainOff _\\fz \\sustainOn \\stemUp df,4. ~ | % 37 | |
| \\stemDown <df gf bf>8 ^. [ gf,8 ^. ] <df' f cf'>8 ^. [ gf,8 ^. ] | % 38 | |
| <df' gf bf>8 ^. [ gf,8 ^. ] <df' f cf'>8 ^. [ gf,8 ^. ] | % 39 | |
| <df' gf bf>8 ^. [ gf,8 ^. ] <df' f cf'>8 ^. [ gf,8 ^. ] | % 40 | |
| <df' gf bf>8 ^. [ \\sustainOn gf,8 ^. ] <df' f cf'>8 ^. [ gf,8 ^. ] \\sustainOff | % 41 | |
| <df' gf bf>8 ^. [ \\sustainOn gf,8 ^. ] \\sustainOff <df' f cf'>8 ^. [ \\sustainOn gf,8 ^. ] \\sustainOff | % 42 | |
| <df' gf bf>8 ^. [ \\sustainOn gf,8 ^. ] \\sustainOff <df' f cf'>8 ^. [ \\sustainOn gf,8 ^. ] \\sustainOff | % 43 | |
| <df' gf bf>8 ^. [ \\sustainOn gf,8 ^. ] \\sustainOff <df' f cf'>8 ^. [ \\sustainOn gf,8 ^. ] \\sustainOff | % 44 | |
| <df' bf'>8 _. [ \\stemUp gf,,8 _. ^5 ] \\sustainOn \\stemDown df''8 ^. _5 [ <gf df'>8 ^. _3 _1 ] | % 45 | |
| \\stemUp <bf gf'>8 _. _5 _2 [ <df bf'>8 _. _4 _1 ] \\stemDown <gf df'>8 ^. _5 _2 [ <bf gf'>8 ^. _4 _1 ] | % 46 | |
| \\stemUp <gf df'>8 _5 _2 [ <df bf'>8 _4 _1 ] \\clef "bass" \\stemDown <gf, gf'>8 ^. [ <df df'>8 ^. ] | % 47 | |
| \\stemUp <gf, gf'>8 _. [ <df df'>8 _. ] <gf, gf'>8 _. [ <df df'>8 _. ] | % 48 | |
| <gf gf'>8 _. [ ^\\markup { \\bold \\italic { poco secco } } \\sustainOff <df df'>8 _. ] <gf gf'>8 _. [ <df df'>8 _. ] | % 49 | |
| <gf gf'>8 _. [ <ef df'>8 _. ] ^\\pp <gf gf'>8 _. [ \\sustainOn <df' df'>8 _. ] \\sustainOn | % 50 | |
| <gf gf'>8 _. \\sustainOn r8 r4 \\sustainOff \\bar "|." | |
| } | |
| PartPOneVoiceTwo = \\relative bf' { | |
| \\clef "treble" \\key gf \\major \\time 2/4 \\stemDown bf16 [ <gf' bf>16 ^2 ^3 <cf, cf'>16 ^. ^4 <c c'>16 ^. ^5 ] df16 [ <af' df>16 ^4 <ef ef'>16 ^. ^5 <df df'>16 ^. ^4 ] | % 1 | |
| gf,16 [ <ef' gf>16 ^2 ^3 <af, af'>16 ^. ^4 <a a'>16 ^. ^5 ] bf16 [ <f' bf>16 ^2 ^4 <cf cf'>16 ^. ^5 <bf bf'>16 ^. ^4 ] | % 2 | |
| ef,16 [ <cf' ef>16 ^4 <e, e'>16 ^. ^5 <f f'>16 ^. ^5 ] gf16 [ <df' gf>16 ^4 <f, f'>16 ^. ^5 <gf gf'>16 ^. ^4 ] | % 3 | |
| af16 [ <ef' af>16 ^4 <bf bf'>16 ^. ^5 <af af'>16 ^. ^4 ] af16 [ <f' af>16 ^3 <bf, bf'>16 ^. ^4 <cf cf'>16 ^. ^5 ] | % 4 | |
| gf'16 [ bf,16 <cf cf'>16 ^. <c c'>16 ^. ] df16 [ <af' df>16 <ef ef'>16 ^. <df df'>16 ^. ] | % 5 | |
| ef16 [ gf,16 <af af'>16 ^. <a a'>16 ^. ] bf16 [ <f' bf>16 <cf cf'>16 ^. <bf bf'>16 ^. ] | % 6 | |
| cf16 [ ef,16 <e e'>16 ^. <f f'>16 ^. ] gf16 [ <df' gf>16 <f, f'>16 ^. <gf gf'>16 ^. ] | % 7 | |
| af16 [ <gf' af>16 <bf, f' bf>16 <af af'>16 ] gf16 [ <df' gf>16 <f, f'>16 ^. <gf gf'>16 ^. ] | % 8 | |
| af16 [ <f' af>16 <bf, bf'>16 ^. <af af'>16 ^. ] af16 [ <gf' af>16 <c, c'>16 ^. <df df'>16 ^. ] | % 9 | |
| ef16 [ <af ef'>16 <d, d'>16 ^. <ef ef'>16 ^. ] e16 [ <af e'>16 f16 <af f'>16 ] | % 10 | |
| ef16 [ <bf' ef>16 ^5 <df, df'>16 ^. ^4 <bf bf'>16 ^. ^5 ] af16 [ <df af'>16 <g, g'>16 ^. <af af'>16 ^. ] | % 11 | |
| bf16 [ <c bf'>16 ^2 ^5 <af af'>16 ^. ^5 <gf gf'>16 ^. ^4 ] e16 [ <df' e>16 f,16 <df' f>16 ] | % 12 | |
| df16 [ f,16 <gf gf'>16 ^. <g g'>16 ^. ] af16 [ <ef' af>16 <bf bf'>16 ^. <c c'>16 ^. ] | % 13 | |
| g'16 [ df16 <ef ef'>16 ^. <e e'>16 ^. ] e16 [ <af e'>16 f16 <af f'>16 ] | % 14 | |
| bf16 [ -\\! ef,16 <df df'>16 ^. <bf bf'>16 ^. ] af16 [ <df af'>16 <g, g'>16 ^. <af af'>16 ^. ] | % 15 | |
| c16 [ <gf' c>16 <bf, bf'>16 ^. <af af'>16 ^. ] df16 [ <f df'>16 <c c'>16 ^. ^5 <df df'>16 ^. ^4 ] | % 16 | |
| df16 [ <bf' df>16 ^3 <ff ff'>16 ^. ^5 <ef ef'>16 ^. ] df16 [ <af' df>16 <cf, cf'>16 ^. <bf bf'>16 ^. ] | % 17 | |
| cf16 [ <f cf'>16 ^5 <eff eff'>16 ^. ^5 <df df'>16 ^. ^4 ] cf16 [ <gf' cf>16 <bff, bff'>16 ^. <af af'>16 ^. ] | % 18 | |
| gf16 [ <ef' gf>16 ^3 <bff bff'>16 ^. ^5 <af af'>16 ^. ^4 ] af16 [ <ef' af>16 <g, g'>16 ^. <gf gf'>16 ^. ] | % 19 | |
| f16 [ <df' f>16 ^2 ^5 <gf, gf'>16 ^. ^4 <g g'>16 ^. ^5 ] af16 [ <df af'>16 df16 <af' df>16 ] | % 20 | |
| bf'16 [ df,16 <ff ff'>16 ^. <ef ef'>16 ^. ] af16 [ df,16 <cf cf'>16 ^. <bf bf'>16 ^. ] | % 21 | |
| f'16 [ cf16 <eff eff'>16 ^. <df df'>16 ^. ] gf16 [ cf,16 <bff bff'>16 ^. <af af'>16 ^. ] | % 22 | |
| ef'16 [ gf,16 <bff bff'>16 ^. <af af'>16 ^. ] af16 [ <ef' af>16 <aff, aff'>16 ^. <gf gf'>16 ^. ] | % 23 | |
| gf16 [ <cf gf'>16 <f, f'>16 ^. <ef ef'>16 ^. ] eff16 [ <af eff'>16 <df, df'>16 ^. <cf cf'>16 ^. ] | % 24 | |
| bf16 [ <gf' bf>16 <cf, cf'>16 ^. <c c'>16 ^. ] df16 [ <af' df>16 <ef ef'>16 ^. <df df'>16 ^. ] | % 25 | |
| gf,16 [ <ef' gf>16 <af, af'>16 ^. <a a'>16 ^. ] bf16 [ <f' bf>16 <cf cf'>16 ^. <bf bf'>16 ^. ] | % 26 | |
| ef,16 [ <cf' ef>16 <e, e'>16 ^. <f f'>16 ^. ] gf16 [ <df' gf>16 <f, f'>16 ^. <gf gf'>16 ^. ] | % 27 | |
| af16 [ <gf' af>16 <bf, bf'>16 ^. <af af'>16 ^. ] af16 [ <f' af>16 <bf, bf'>16 ^. <cf cf'>16 ^. ] | % 28 | |
| bf16 [ <gf' bf>16 <cf, cf'>16 ^. <c c'>16 ^. ] df16 [ <af' df>16 <ef ef'>16 ^. <df df'>16 ^. ] | % 29 | |
| cf16 [ <af' cf>16 <df, df'>16 ^. <d d'>16 ^. ] ef16 [ <bf' ef>16 <ff ff'>16 ^. <ef ef'>16 ^. ] | % 30 | |
| ef16 [ <cf' ef>16 <e, e'>16 ^. <f f'>16 ^. ] gf16 [ <df' gf>16 <f, f'>16 ^. <gf gf'>16 ^. ] | % 31 | |
| af16 [ <ef' gf af>16 <g, g'>16 ^. <af af'>16 ^. ] bff16 [ <ef gf bff>16 <af, af'>16 ^. <bff bff'>16 ^. ] | % 32 | |
| bf16 [ <gf' bf>16 <cf, cf'>16 ^. <bf bf'>16 ^. ] bf16 [ <f' bf>16 <bff, bff'>16 ^. <af af'>16 ^. ] | % 33 | |
| af16 [ <ef' af>16 <aff, aff'>16 ^. <gf gf'>16 ^. ] gf16 [ <bff gf'>16 <f f'>16 ^. <ef ef'>16 ^. ] | % 34 | |
| \\ottava #0 ef16 [ <af ef'>16 <eff eff'>16 ^. <df df'>16 ^. ] df16 [ <af' df>16 <dff, dff'>16 ^. <cf cf'>16 ^. ] | % 35 | |
| cf16 _> [ <eff cf'>16 <bf bf'>16 ^. <bff bff'>16 ^. ] bff16 _> [ <c bff'>16 af16 _> <df af'>16 ~ ] | % 36 | |
| <gf, df' gf>4 af16 [ <df af'>16 <bf bf'>16 ^. <cf cf'>16 ^. ] | % 37 | |
| df16 [ <gf df'>16 <ef ef'>16 ^. <df df'>16 ^. ] af16 [ <df af'>16 <bf bf'>16 ^. <af af'>16 ^. ] | % 38 | |
| df,16 [ <bf' df>16 <f f'>16 ^. <gf gf'>16 ^. ] af16 [ <df af'>16 <bf bf'>16 ^. <cf cf'>16 ^. ] | % 39 | |
| df16 [ <gf df'>16 <ef ef'>16 ^. <df df'>16 ^. ] af16 [ <df af'>16 <bf bf'>16 ^. <af af'>16 ^. ] | % 40 | |
| <gf gf'>8 ^. b8\\rest df'16 [ af16 <bf bf'>16 ^. <cf cf'>16 ^. ] | % 41 | |
| gf'16 [ df16 <ef ef'>16 ^. <df df'>16 ^. ] df16 [ af16 <bf bf'>16 ^. <af af'>16 ^. ] | % 42 | |
| bf16 [ df,16 <f f'>16 ^. <gf gf'>16 ^. ] df'16 [ af16 <bf bf'>16 ^. \\ottava #0 <cf cf'>16 ^. ] | % 43 | |
| gf'16 [ df16 <ef ef'>16 ^. <df df'>16 ^. ] df16 [ af16 <bf bf'>16 ^. <af af'>16 ^. ] | % 44 | |
| s2 | % 45 | |
| s2 | % 46 | |
| s2 | % 47 | |
| s2 | % 48 | |
| s2 | % 49 | |
| s2 | % 50 | |
| s2 \\bar "|." | |
| } | |
| PartPOneVoiceFour = \\relative gf,, { | |
| \\clef "bass" \\key gf \\major \\time 2/4 s2 | % 1 | |
| s2 | % 2 | |
| s2 | % 3 | |
| s2 | % 4 | |
| s2 | % 5 | |
| s2 | % 6 | |
| s2 | % 7 | |
| s2 | % 8 | |
| s2 | % 9 | |
| s2 | % 10 | |
| s2 | % 11 | |
| s2 | % 12 | |
| s2 | % 13 | |
| s2 | % 14 | |
| s2 | % 15 | |
| s2 | % 16 | |
| s2 | % 17 | |
| s2 | % 18 | |
| s2 | % 19 | |
| s2 | % 20 | |
| s2 | % 21 | |
| s2 | % 22 | |
| s2 | % 23 | |
| s2 | % 24 | |
| s2 | % 25 | |
| s2 | % 26 | |
| s2 | % 27 | |
| s2 | % 28 | |
| s2 | % 29 | |
| s2 | % 30 | |
| s8 \\clef "treble" s8 \\clef "bass" s8 \\clef "treble" s8 | % 31 | |
| s8 \\clef "treble" s4 \\clef "bass" s8 | % 32 | |
| s2 | % 33 | |
| s2 | % 34 | |
| s2 | % 35 | |
| s2 | % 36 | |
| \\stemUp gf8 _. [ \\stemDown df''8 ^1 ^3 ] <f cf'>8 ^. _1 _2 [ \\sustainOff gf,8 ^. _5 ] | % 37 | |
| s2 | % 38 | |
| s2 | % 39 | |
| s2 | % 40 | |
| s2 | % 41 | |
| s2 | % 42 | |
| s2 | % 43 | |
| s2 | % 44 | |
| s2 | % 45 | |
| s2 | % 46 | |
| s4 \\clef "bass" s4 | % 47 | |
| s2 | % 48 | |
| s2 | % 49 | |
| s2 | % 50 | |
| s2 \\bar "|." | |
| } | |
| % The score definition | |
| \\score { | |
| << | |
| \\new PianoStaff << | |
| \\context Staff = "1" << | |
| \\mergeDifferentlyDottedOn | |
| \\mergeDifferentlyHeadedOn | |
| \\context Voice = "PartPOneVoiceOne" { | |
| \\voiceOne \\PartPOneVoiceOne | |
| } | |
| \\context Voice = "PartPOneVoiceTwo" { | |
| \\voiceTwo \\PartPOneVoiceTwo | |
| } | |
| >> | |
| \\context Staff = "2" << | |
| \\mergeDifferentlyDottedOn | |
| \\mergeDifferentlyHeadedOn | |
| \\context Voice = "PartPOneVoiceThree" { | |
| \\voiceOne \\PartPOneVoiceThree | |
| } | |
| \\context Voice = "PartPOneVoiceFour" { | |
| \\voiceTwo \\PartPOneVoiceFour | |
| } | |
| >> | |
| >> | |
| >> | |
| \\layout { | |
| } | |
| \\midi { | |
| \\tempo 4 = 120 | |
| \\context { | |
| \\Score | |
| midiChannelMapping = #'instrument | |
| } | |
| } | |
| }`,_sfc_main={name:"playground",mixins:[QuitClearner],components:{SourceEditor,SheetSimple,SheetLive,SheetSigns,Loading,StoreInput,BoolStoreInput,CheckButton,MidiRoll,NotationsMatcher,Dialog,RemoteFile,DirBrowser,Icon},data(){return{buildContainerSize:{width:100,height:100},sheetContainerSize:{width:100,height:100},dragHover:null,sourceDragHover:!1,lilySource:INIT_LILY,converting:!1,engraving:!1,svgDocuments:null,engraverLogs:null,engraverDirty:!1,autoEngrave:!0,tokenizeStaff:!0,sheetDocument:null,title:null,svgHashTable:null,midi:null,midiNotation:null,scheduler:null,pitchContextGroup:null,enabledChromatic:!1,chromaticMode:"symbols",midiPlayer:null,rollVisible:!1,matcherNotations:null,showNotationsMatcher:!1,enabledMidiAudio:!0,showCursor:!0,settingPanelVisible:!1,xml2lyOptions:{removeBreaks:!0,removeStaffGroup:!0,mergeContinuousGraces:!0,excludeChordTracksFromMIDI:!0,midiChannelMapping:!1},engraveWithLogs:!1,enabledFuzzyMatcher:!0,enabledSheetNotation:!1,lilyMarkups:{enabled:!0,staffSize:null,autoPaperSize:!0,pageCount:2,systemSpacing:-1,topMarkupSpacing:-1,raggedLast:!0},lilyParser:null,measuresParser:null,lilyDocumentDirty:!1,lilyTextSourceDirty:!1,bakingSheet:!1,bakingImages:null,enabledMusicFont:!1,hideBakingImages:!1,lilyMarkupMethods:Object.getOwnPropertyNames(LilyDocument.prototype),chosenLilyMarkupMethod:null,operating:!1,loadingLilyParser:!1,enabledPointer:!1,pointerData:null,sourceEditorEnabled:!1,showSourceDir:!1,sourceEditorHost:`ws://${location.host}`,sourceEditorFilePath:null,sourceEditorConnected:!1,sourceEditorLoading:!1,measureLayoutType:"ordinary",measureLayoutCode:null,measureLayoutCodeDirty:!1,measureLayoutCodeError:null,articulateMIDI:!1,highlightSymbol:null}},computed:{markupValueHash(){const{enabled:t,...e}=this.lilyMarkups;return JSON.stringify(e)},autoPageSize(){return{width:this.sheetContainerSize.width/this.lilyMarkups.pageCount-34,height:this.sheetContainerSize.height-38}},engraverLogStatus(){return this.engraverLogs?/error:/i.test(this.engraverLogs)?"error":/warning:/i.test(this.engraverLogs)?"warning":"info":null},sourceIsLoading(){return this.converting||this.sourceEditorLoading},pitchContextMarks(){return!this.pitchContextGroup||!this.scheduler?[]:this.pitchContextGroup.map(t=>t.items.map(e=>{const r=e.context,s=a=>({y:a,alter:r.alterOnNote(r.yToNote(a)),name:r.yToPitchName(a)}),{system:n,x:o}=this.scheduler.lookupPosition(e.tick),l=[[-2,-1,0,1,2].map(s),[-1.5,-.5,.5,1.5].map(s)];return{system:n,x:o,names:l}})).reduce((t,e,r)=>(e.forEach(({system:s,...n})=>{t[s]=t[s]||[],t[s][r]=t[s][r]||[],t[s][r].push(n)}),t),[])}},async created(){window.$main=this,f.WebAudio.empty()&&f.loadPlugin({soundfontUrl:"/soundfont/",api:"webaudio"}).then(()=>console.log("Soundfont loaded.")),load(__vitePreload(()=>import("./measureLayout-eqryu3En.js"),[],import.meta.url)).then(t=>{this.measuresParser=t,console.debug("measureLayout parser loaded.")}),this.loadingLilyParser=!0,this.lilyParser=await load(__vitePreload(()=>import("./lilypond-CRjqli1b.js"),[],import.meta.url)),this.loadingLilyParser=!1,console.debug("lily parser loaded."),this.updateLilyDocument()},async mounted(){const t=r=>{switch(r.code){case"F8":this.engrave(),r.preventDefault();break}};document.addEventListener("keydown",t),this.appendCleaner(()=>document.removeEventListener("keydown",t));const e=useResizeObserver(this.$refs.sheetContainer,r=>{const s=r[0],{width:n,height:o}=s.contentRect;this.buildContainerSize.width=this.$refs.buildContainer.clientWidth,this.buildContainerSize.height=this.$refs.buildContainer.clientHeight,this.sheetContainerSize.width=n,this.sheetContainerSize.height=o});this.appendCleaner(e),await this.$nextTick(),this.watchEngrave()},methods:{onDragOver(t){const e=t.dataTransfer.items[0];e&&(this.dragHover=e.type)},async onDropFile(t,{source:e}={}){if(this.dragHover=null,this.sourceDragHover=!1,this.sourceEditorConnected)if(window.confirm("Break the edidtor file connection and continue loading?"))this.$refs.remoteFile.disconnect();else return;const r=t.dataTransfer.files[0];if(r)switch(r.type){case"text/x-lilypond":case"text/lilypond-source":case"":this.lilySource=await r.readAs("Text"),this.engraverLogs=null,this.clearSheet(),await this.updateLilyDocument(),this.engrave();break;case"text/xml":this.converting=!0;try{const s=await r.readAs("Text");this.lilySource=await this.musicxml2ly(s),this.engraverLogs=null}catch(s){console.warn("musicxml2ly failed:",s)}this.converting=!1,this.clearSheet(),await this.updateLilyDocument(),this.lilySource&&this.engrave();break;case"audio/midi":case"audio/mid":if(e){this.converting=!0;try{this.lilySource=await this.midi2ly(r),this.engraverLogs=null}catch(s){console.warn("musicxml2ly failed:",s)}this.converting=!1,this.clearSheet(),await this.updateLilyDocument(),this.lilySource&&this.engrave()}else{const s=await r.readAs("ArrayBuffer");this.midi=ue.parseMidiData(s)}break;default:console.warn("unsupported file type:",r.type)}},onMidi(t,e){if(this.enabledMidiAudio)switch(t.subtype){case"noteOn":f.noteOn(t.channel,t.noteNumber,t.velocity,e);break;case"noteOff":f.noteOff(t.channel,t.noteNumber,e);break}},onCursorPageShift(t){console.log("onCursorPageShift:",t)},onPointerUpdate(t){this.pointerData=t},async onPointerClick(t,e){if(!e.ctrlKey&&Number.isFinite(t.tick)){const r=this.midiPlayer.isPlaying;r&&(this.midiPlayer.pause(),await animationDelay()),this.midiPlayer.progressTicks=t.tick,r&&this.midiPlayer.play()}},clearSheet(){this.title=null,this.sheetDocument=null,this.sheetNotation=null,this.svgHashTable=null,this.lilyNotation=null,this.midi=null,this.midiNotation=null,this.scheduler=null,this.pitchContextGroup=null,this.midiPlayer=null,this.matcherNotations=null,this.bakingImages=null},async musicxml2ly(t){const e=new FormData;e.append("xml",t),e.append("options",JSON.stringify({removeBreak:this.xml2lyOptions.removeBreaks,removePageBreak:this.xml2lyOptions.removeBreaks}));const r=await fetch("/musicxml2ly",{method:"POST",body:e});if(r.ok){const s=await r.text();return console.debug("musicxml2ly accomplished."),this.postProcessSource(s)}else{const s=await r.text();throw console.warn("musicxml2ly failed:",s),new Error(s)}},async midi2ly(t){const e=new FormData;e.append("midi",t),e.append("options",JSON.stringify({removeInstrumentName:!0,tupletReplace:!0}));const r=await fetch("/midi2ly",{method:"POST",body:e});if(!r.ok){console.warn("MIDI to ly failed:",await r.text());return}return r.text()},async engrave(){if(this.engraving){console.warn("already engraving, cancelled.");return}if(this.engraving=!0,await this.$nextTick(),await animationDelay(),await animationDelay(),this.tokenizeStaff)try{await this.updateLilyDocument(),this.lilyDocument&&this.lilyDocument.interpret({useCached:!1})}catch(r){console.warn("lilydocument parsing failed:",r)}const t=new FormData;t.append("source",this.lilySource),this.engraveWithLogs&&t.append("log",this.engraveWithLogs),this.tokenizeStaff&&t.append("tokenize",this.tokenizeStaff);const e=await fetch("/engrave",{method:"POST",body:t});if(!e.ok)this.engraverLogs=await e.text(),this.clearSheet(),this.svgDocuments=null;else{const r=await e.json();console.log("Engraving accomplished."),this.engraverLogs=r.logs,this.engraverLogger=r.logger,this.svgDocuments=r.svgs,this.tokenizeStaff?(this.sheetDocument=recoverJSON(r.doc,{StaffToken,SheetDocument}),this.svgHashTable=r.hashTable,this.sheetDocument.assignFlagsTrack(),this.articulateMIDI?this.midi=await this.engraveMIDI():this.midi=r.midi,this.enabledSheetNotation&&this.updateSheetNotation(),this.midi&&this.matchNotations(this.midi)):this.clearSheet(),this.engraving=!1}this.engraverDirty=!1,this.engraving=!1},async engraveScm(){const t=new FormData;t.append("source",this.lilySource);const e=await fetch("/engraveScm",{method:"POST",body:t});if(!e.ok){console.warn("engraveScm error:",await e.text());return}const r=await e.json();this.engraverLogs=r.logs;const n=(await __vitePreload(()=>import("./index-ygwAcZb2.js"),[],import.meta.url)).S(r.scm);console.log("SCM:",n)},async engraveMIDI({articulate:t=!0}={}){const e=new FormData;e.append("source",this.lilySource),t&&e.append("articulate","1");const r=await fetch("/engraveMIDI",{method:"POST",body:e});if(!r.ok){console.warn("engraveMIDI error:",await r.text());return}const s=await r.arrayBuffer();return ue.parseMidiData(s)},saveSource(){const t=new Blob([this.lilySource],{type:"text/x-lilypond"}),e=document.createElement("a");e.href=URL.createObjectURL(t);const r=prompt("Input your file name:",`${this.title||"lotus-editor"}.ly`);r&&(e.download=/\.\w+/.test(r)?r:r+".ly",e.click())},watchEngrave(){this.autoEngrave&&this.engraverDirty&&!this.engraving&&this.engrave()},togglePlayer(){this.midiPlayer&&(this.midiPlayer.isPlaying?this.midiPlayer.pause():this.midiPlayer.play())},async sliceSource(t,e){if(!this.midi)return null;const r=pe.sliceMidi(this.midi,t,e);console.log("partMidi:",r);const s=new Blob([ue.encodeMidiFile(r)],{type:"audio/midi"}),n=this.midi2ly(s);console.log("ly:",n)},updateSheetNotation(){if(this.sheetNotation=null,this.matcherNotations=null,this.sheetDocument){const t=new LogRecorder({enabled:!0});if(this.sheetNotation=parseNotationFromSheetDocument(this.sheetDocument,{logger:t}),this.lilyDocument){const e=this.lilyDocument.getLocationTickTable();assignTickByLocationTable(this.sheetNotation,e)}else console.warn("lilyDocument is null, assignTickByLocationTable skipped.");console.log("sheet notation parsed:",t.toJSON())}},async matchNotations(t){if(console.assert(t,"midi is null."),this.enabledSheetNotation){console.assert(this.sheetNotation,"sheetNotation is null.");const e=he.Notation.parseMidi(t);this.matcherNotations=await matchNotations(e,this.sheetNotation,{enableFuzzy:this.enabledFuzzyMatcher}),this.midiNotation=e,this.pitchContextGroup=PitchContextTable.createPitchContextGroup(this.sheetNotation.pitchContexts,this.midiNotation),this.matchedIds=new Set,this.midiNotation.notes.forEach(r=>r.ids&&r.ids.forEach(s=>this.matchedIds.add(s)))}else{this.lilyNotation=this.lilyDocument.interpret().getNotation(),this.matcherNotations=await matchWithExactMIDI(this.lilyNotation,t);const e=this.lilyNotation.getMeasureIndices(this.measureLayoutType);this.midiNotation=this.lilyNotation.toPerformingNotationWithEvents(e),this.pitchContextGroup=this.lilyNotation.getContextGroup(e),this.matchedIds=this.lilyNotation.idSet,this.scheduler=Scheduler.createFromNotation(this.lilyNotation.toPerformingNotation(e,{withRestTied:!0}),this.sheetDocument.getTokenMap())}this.sheetDocument.updateMatchedTokens(this.matchedIds),this.bakingSheet&&this.bakeSheet()},async exportScore(){console.assert(this.sheetDocument,"sheetDocument is null."),console.assert(this.pitchContextGroup,"pitchContextGroup is null."),console.assert(this.midiNotation,"midiNotation is null."),await this.updateLilyDocument();const t=this.lilyDocument.globalAttributes({readonly:!0}),e=this.lilyDocument.interpret().midiMusic,r={title:t.title&&t.title.toString(),composer:t.composer&&t.composer.toString(),pageSize:this.sheetDocument.pageSize,pageCount:this.sheetDocument.pages.length,staffSize:t.staffSize,trackInfos:e&&e.trackContextDicts},s={version:npmPackage.version+" -playground",meta:r,doc:this.sheetDocument,hashTable:this.bakingSheet?null:this.svgHashTable,lilyNotation:this.lilyNotation},n=new Blob([JSON.stringify(s)],{type:"application/json"}),{default:o}=await __vitePreload(async()=>{const{default:u}=await import("./jszip.min-C1swU7HS.js").then(c=>c.j);return{default:u}},__vite__mapDeps([0,1,2,3]),import.meta.url),l=new o;l.file("score.json",n),this.bakingSheet&&this.bakingImages&&await Promise.all(this.bakingImages.map(async(u,c)=>{const h=await(await fetch(u)).blob();l.file(`baking${c}.png`,h),console.log("img:",h)}));const a=await l.generateAsync({type:"blob",compression:"DEFLATE",compressionOptions:{level:5}});downloadUrl(URL.createObjectURL(a),`${this.title||""}.zip`)},async updateLilyDocument(){if((!this.lilyDocument||this.lilyDocumentDirty)&&this.lilyParser){const t=await this.lilyParser.parse(this.lilySource);this.lilyDocument=new LilyDocument(t);const e=this.lilyDocument.globalAttributes({readonly:!0}).title;this.title=e&&e.toString(),this.lilyDocumentDirty=!1}},updateLilyTextSource(){this.lilyTextSourceDirty&&(this.lilyTextSource=new TextSource(this.lilySource),this.lilyTextSourceDirty=!1)},markupLilyDocument(t){t.formalize();const e=t.globalAttributes();this.lilyMarkups.staffSize&&(e.staffSize.value=this.lilyMarkups.staffSize),this.lilyMarkups.autoPaperSize&&(e.paperWidth.value.set({number:this.autoPageSize.width/CM_TO_PX,unit:"\\cm"}),e.paperHeight.value.set({number:this.autoPageSize.height/CM_TO_PX,unit:"\\cm"})),this.lilyMarkups.systemSpacing>=0&&(e.systemSpacing.value=this.lilyMarkups.systemSpacing),this.lilyMarkups.topMarkupSpacing>=0&&(e.topMarkupSpacing.value=this.lilyMarkups.topMarkupSpacing),typeof this.lilyMarkups.raggedLast=="boolean"&&(e.raggedLast.value=this.lilyMarkups.raggedLast)},async markupSource(){await this.updateLilyDocument(),console.assert(this.lilyDocument,"lilyDocument is null."),this.markupLilyDocument(this.lilyDocument),this.lilySource=this.lilyDocument.toString(),await this.$nextTick(),this.engraverLogs=null},async postProcessSource(t){const e=new LilyDocument(await this.lilyParser.parse(t));return this.xml2lyOptions.removeStaffGroup&&e.removeStaffGroup(),this.xml2lyOptions.mergeContinuousGraces&&e.mergeContinuousGraces(),this.xml2lyOptions.excludeChordTracksFromMIDI&&e.excludeChordTracksFromMIDI(),this.xml2lyOptions.midiChannelMapping&&e.useMidiInstrumentChannelMapping(),e.toString()},removeTrillSpans(){return this.executeMarkup("removeTrillSpans")},async exportMarkupLily(){const t=new LilyDocument(await this.lilyParser.parse('\\version "2.20.0"'));this.markupLilyDocument(t);const e=new Blob([t.toString()]);return downloadUrl(URL.createObjectURL(e),"markup.ly")},async bakeSheet(){console.assert(this.svgDocuments,"svgDocuments is null."),console.assert(this.matchedIds,"matchedIds is null."),this.bakingImages=await bakeRawSvgs(this.svgDocuments,this.matchedIds,this.$refs.canvas)},async inspectLily(){await this.updateLilyDocument(),this.updateLilyTextSource(),console.log(this.lilyDocument)},showEngraverLog(){console.log(this.engraverLogs)},async executeMarkup(t){await this.updateLilyDocument(),this.lilyDocument||console.log("lilyDocument parsing failed."),this.lilyDocument[t]||console.warn("Markup function not found:",t,this.lilyDocument),this.lilyDocument[t](),this.lilySource=this.lilyDocument.toString()},async unfoldRepeats(){this.operating=!0;try{if(await this.updateLilyDocument(),!this.lilyDocument)throw new Error("lilyDocument is null.");this.lilyDocument.unfoldRepeats(),this.lilySource=this.lilyDocument.toString(),await this.engrave(),this.lilySource=replaceSourceToken(this.lilySource,"\\unfoldRepeats"),this.engraving=!0;const t=new FormData;t.append("source",this.lilySource),this.engraveWithLogs&&t.append("log",this.engraveWithLogs),t.append("tokenize",!0);const e=await fetch("/engrave",{method:"POST",body:t});if(e.ok){const r=await e.json();this.engraverLogs=r.logs,this.svgDocuments=r.svgs,this.sheetDocument=recoverJSON(r.doc,{StaffToken,SheetDocument}),this.svgHashTable=r.hashTable,this.sheetDocument.updateMatchedTokens(this.matchedIds),this.$refs.sheet.preparePlayer()}else{const r=await e.text();throw new Error(r)}}catch(t){console.warn("unfoldRepeats failed:",t)}this.engraverDirty=!1,this.engraving=!1,this.operating=!1},async redivideLilyDocument({reconstruct:t=!1}={}){await this.updateLilyDocument();const e=this.lilyDocument.interpret({useCached:!1});t?(e.layoutMusic.musicTracks.forEach(r=>r.redivide()),this.lilyDocument=e.toDocument(),this.lilySource=this.lilyDocument.toString()):(this.lilyDocument.root.forEachTopTerm(LilyTerms.Assignment,r=>{if(r.value&&typeof r.value=="object"&&r.value.isMusic){const s=r.key.toString(),n=e.layoutMusic.musicTracks.find(l=>l.contextDict.Voice===s);r.value.findFirst(LilyTerms.MusicBlock).redivide({measureHeads:n.measureHeads})}}),this.lilySource=this.lilyDocument.toString())},async sliceMeasures(t,e){await this.updateLilyDocument();const r=this.lilyDocument.interpret({useCached:!1});r.sliceMeasures(t,e),this.lilyDocument=r.toDocument(),this.lilySource=this.lilyDocument.toString()},async createPianoRhythm(t){await this.updateLilyDocument();const e=this.lilyDocument.interpret({useCached:!1});createPianoRhythm(e,t),this.lilyDocument=e.toDocument(),this.lilySource=this.lilyDocument.toString(),await this.$nextTick(),this.lilyDocumentDirty=!1},async testInterpreter({flatten:t=!1}={}){await this.updateLilyDocument();const e=this.lilyDocument.interpret({useCached:!1}),r=e.getNotation();t&&e.layoutMusic.musicTracks.forEach(n=>n.flatten({spreadRepeats:!0}));const s=e.toDocument();console.log("INTERPRETER:",e),console.log("DOC:",s),console.log("NOTATION:",r)},onSourceDirPick(t){this.sourceEditorFilePath=t,this.$nextTick(()=>{this.$refs.remoteFile&&this.$refs.remoteFile.connect()})},highlightSourcePosition(t){if(this.updateLilyTextSource(),t.length>=2){const e=this.$el.querySelector(".prism-editor__textarea");if(!e){console.warn(".prism-editor__textarea is not found.");return}const r=this.lilyTextSource.positionToChars([t[0],t[1]]),s=t.length>=3?this.lilyTextSource.positionToChars([t[0],t[2]]):r;e.setSelectionRange(r,s),e.focus();const n=this.$el.querySelector(".prism-editor-wrapper"),o={left:t[1]*9.7,right:((t[2]||t[1])+2)*9.7,top:(t[0]-1)*19,bottom:(t[0]+2)*19};n.scrollLeft=Math.max(o.right+50-n.clientWidth,n.scrollLeft),n.scrollLeft=Math.min(o.left,n.scrollLeft),n.scrollTop=Math.max(o.bottom-n.clientHeight,n.scrollTop),n.scrollTop=Math.min(o.top,n.scrollTop)}},onSheetLink(t,e){t.preventDefault();const r=e.match(/\d+/g);r&&this.highlightSourcePosition(r.map(Number))},onClickToken(t,e){if(e.ctrlKey&&t.href){const r=t.href.match(/\d+/g);r&&this.highlightSourcePosition(r.map(Number))}else console.log("token:",t)},onClickMatcherNote(t){if(console.log("matcher note:",{...t}),t.id){const e=t.id.match(/\d+/g);e&&this.highlightSourcePosition(e.map(Number))}},async updateMeasureLayoutCode(){await this.updateLilyDocument(),this.measureLayoutCode=this.lilyDocument.interpret().layoutMusic.measureLayoutCode,this.measureLayoutCodeDirty=!1},async validateMeasureLayoutCode(){if(this.measureLayoutCodeError=null,!!this.measureLayoutCode)try{await this.measuresParser.parse(this.measureLayoutCode)}catch(t){this.measureLayoutCodeError=t}},async applyUpdateMeasureLayoutCode(){if(this.measureLayoutCode)try{const t=await this.measuresParser.parse(this.measureLayoutCode),e=recoverJSON(t.data,measureLayout);await this.updateLilyDocument(),this.lilyDocument.interpret(),this.applyMeasureLayout(e),this.measureLayoutCodeDirty=!1}catch(t){this.measureLayoutCodeError=t,console.error(t)}},applyMeasureLayout(t){this.lilyDocument.root.sections.filter(r=>r instanceof LilyTerms.Assignment&&r.value instanceof LilyTerms.Relative&&r.value.measureLayout).map(r=>r.value.args).map(r=>MusicTrack.fromBlockAnchor(r[1],r[0])).forEach(r=>r.applyMeasureLayout(t)),this.lilySource=this.lilyDocument.toString()},async flattenTracks(){await this.updateLilyDocument(),this.lilyDocument.interpret(),this.lilyDocument.root.sections.filter(e=>e instanceof LilyTerms.Assignment&&e.value instanceof LilyTerms.Relative&&e.value.measureLayout).map(e=>e.value.args).map(e=>MusicTrack.fromBlockAnchor(e[1],e[0])).forEach(e=>e.flatten({spreadRepeats:!0})),this.lilySource=this.lilyDocument.toString()},async mergeSingleVoltaMLayout(){await this.updateLilyDocument();const e=this.lilyDocument.interpret().layoutMusic.mainTrack.block.measureLayout;let r=1;for(;r<e.seq.length-1&&!(!(e.seq[r-1]instanceof SingleMLayout)&&e.seq[r]instanceof SingleMLayout&&e.seq[r+1]instanceof VoltaMLayout);++r);if(r<e.seq.length-1){const[s]=e.seq.splice(r,1);return e.seq[r].body.unshift(s),this.applyMeasureLayout(e),!0}return!1},staffTopToken(t){return[].concat(...t.measures.map(r=>r.tokens)).reduce((r,s)=>!r||s.y<r.y?s:r,null)},staffBottomToken(t){return[].concat(...t.measures.map(r=>r.tokens)).reduce((r,s)=>!r||s.y>r.y?s:r,null)}},watch:{lilySource(){this.engraverDirty=!0,this.lilyDocumentDirty=!0,this.lilyTextSourceDirty=!0,this.engraverLogs=null,this.measureLayoutCode=null,this.measureLayoutCodeError=null,this.sourceEditorConnected||(this.sourceEditorFilePath=null)},markupValueHash(){this.lilyParser&&this.lilyMarkups.enabled&&this.markupSource()},engraverDirty(t){t&&this.autoEngrave&&mutexDelay("autoEngrave",5e3).then(e=>!e||this.watchEngrave())},autoEngrave:"watchEngrave",tokenizeStaff(t){t&&this.lilySource&&!this.sheetDocument&&(this.engraverDirty=!0)},bakingSheet(t){t?this.svgDocuments&&this.matchedIds&&this.bakeSheet():this.bakingImages=null}}},_hoisted_1=["data-hover-type"],_hoisted_2={key:0,class:"title"},_hoisted_3=["disabled"],_hoisted_4=["disabled"],_hoisted_5=["disabled"],_hoisted_6={key:0,class:"pointer-info"},_hoisted_7={key:0},_hoisted_8={key:0},_hoisted_9=["disabled"],_hoisted_10=["title"],_hoisted_11=["disabled"],_hoisted_12={class:"corner"},_hoisted_13=["title"],_hoisted_14=["data-chromatic"],_hoisted_15={class:"sheet-container",ref:"sheetContainer",style:{"--music-font-family":"Emmentaler-26","--music-font-size":"4px"}},_hoisted_16={key:0},_hoisted_17=["transform"],_hoisted_18={key:0,class:"locator"},_hoisted_19=["width"],_hoisted_20=["y1","x2","y2"],_hoisted_21=["x","width"],_hoisted_22=["x"],_hoisted_23={key:1,class:"pitch-context"},_hoisted_24=["transform"],_hoisted_25={transform:"translate(0.2, 0.5)"},_hoisted_26=["transform"],_hoisted_27={transform:"translate(1.6, 0.5)"},_hoisted_28=["transform"],_hoisted_29={key:0},_hoisted_30={key:0},_hoisted_31=["transform"],_hoisted_32=["y2"],_hoisted_33=["transform"],_hoisted_34=["y2"],_hoisted_35={key:0,class:"source-editor-controls"},_hoisted_36={class:"settings-panel"},_hoisted_37={class:"settings-header"},_hoisted_38={class:"settings-content"},_hoisted_39={id:"lily-markups"},_hoisted_40=["value"],_hoisted_41={class:"settings-section"},_hoisted_42={class:"settings-grid"},_hoisted_43=["disabled"],_hoisted_44=["disabled"],_hoisted_45=["disabled"],_hoisted_46={class:"settings-section"},_hoisted_47={class:"settings-grid"},_hoisted_48={class:"input-group"},_hoisted_49={class:"settings-section"},_hoisted_50={class:"settings-grid"},_hoisted_51={class:"full-width"},_hoisted_52={class:"input-group"},_hoisted_53=["disabled"],_hoisted_54={ref:"canvas"};function _sfc_render(t,e,r,s,n,o){const l=resolveComponent("StoreInput"),a=resolveComponent("Icon"),u=resolveComponent("BoolStoreInput"),c=resolveComponent("CheckButton"),h=resolveComponent("SourceEditor"),d=resolveComponent("Loading"),m=resolveComponent("MidiRoll"),p=resolveComponent("NotationsMatcher"),g=resolveComponent("SheetSimple"),y=resolveComponent("SheetSigns"),w=resolveComponent("SheetLive"),L=resolveComponent("RemoteFile"),B=resolveComponent("DirBrowser"),C=resolveComponent("Dialog");return openBlock(),createElementBlock("div",{class:normalizeClass(["playground",{"drag-hover":n.dragHover}]),"data-hover-type":n.dragHover,onDragover:e[76]||(e[76]=withModifiers((...i)=>o.onDragOver&&o.onDragOver(...i),["prevent"])),onDragleave:e[77]||(e[77]=i=>n.dragHover=null),onDrop:e[78]||(e[78]=withModifiers((...i)=>o.onDropFile&&o.onDropFile(...i),["prevent"]))},[createBaseVNode("header",{class:normalizeClass(["controls",{buzy:n.operating}])},[withDirectives(createVNode(l,{modelValue:n.lilySource,"onUpdate:modelValue":e[0]||(e[0]=i=>n.lilySource=i),sessionKey:"lotus-lilySource"},null,8,["modelValue"]),[[vShow,!1]]),createBaseVNode("fieldset",null,[n.title?(openBlock(),createElementBlock("span",_hoisted_2,toDisplayString(n.title),1)):createCommentVNode("",!0)]),createBaseVNode("fieldset",null,[createBaseVNode("button",{onClick:e[1]||(e[1]=(...i)=>o.saveSource&&o.saveSource(...i)),title:"save source"},[createVNode(a,{name:"floppy"})]),createBaseVNode("button",{onClick:e[2]||(e[2]=i=>n.settingPanelVisible=!0),title:"settings"},[createVNode(a,{name:"gear"})]),createBaseVNode("button",{class:normalizeClass({"hidden-but-hold-place":!n.lilyMarkups.enabled}),onClick:e[3]||(e[3]=(...i)=>o.markupSource&&o.markupSource(...i)),title:"markup lilypond source",disabled:n.loadingLilyParser},[createVNode(a,{name:"code"})],10,_hoisted_3)]),createBaseVNode("fieldset",null,[withDirectives(createVNode(u,{modelValue:n.autoEngrave,"onUpdate:modelValue":e[4]||(e[4]=i=>n.autoEngrave=i),sessionKey:"lotus-autoEngrave"},null,8,["modelValue"]),[[vShow,!1]]),createVNode(c,{icon:"refresh",modelValue:n.autoEngrave,"onUpdate:modelValue":e[5]||(e[5]=i=>n.autoEngrave=i),title:"auto engrave when dirty"},null,8,["modelValue"]),createBaseVNode("button",{onClick:e[6]||(e[6]=(...i)=>o.engrave&&o.engrave(...i)),class:normalizeClass({working:n.engraving}),style:{zoom:"160%"},title:"engrave (F8)"},[createBaseVNode("span",{class:normalizeClass(["dirty-badge",{dirty:n.engraverDirty}])},null,2),createVNode(a,{name:"music"})],2),createBaseVNode("button",{disabled:!n.sheetDocument,onClick:e[7]||(e[7]=(...i)=>o.exportScore&&o.exportScore(...i)),title:"export score package"},[createVNode(a,{name:"download"})],8,_hoisted_4)]),createBaseVNode("fieldset",null,[withDirectives(createVNode(u,{modelValue:n.tokenizeStaff,"onUpdate:modelValue":e[8]||(e[8]=i=>n.tokenizeStaff=i),sessionKey:"lotus-tokenizeStaff"},null,8,["modelValue"]),[[vShow,!1]]),withDirectives(createVNode(u,{modelValue:n.rollVisible,"onUpdate:modelValue":e[9]||(e[9]=i=>n.rollVisible=i),sessionKey:"lotus-rollVisible"},null,8,["modelValue"]),[[vShow,!1]]),withDirectives(createVNode(u,{modelValue:n.showNotationsMatcher,"onUpdate:modelValue":e[10]||(e[10]=i=>n.showNotationsMatcher=i),sessionKey:"lotus-showNotationsMatcher"},null,8,["modelValue"]),[[vShow,!1]]),withDirectives(createVNode(u,{modelValue:n.enabledMidiAudio,"onUpdate:modelValue":e[11]||(e[11]=i=>n.enabledMidiAudio=i),sessionKey:"lotus-enabledMidiAudio"},null,8,["modelValue"]),[[vShow,!1]]),withDirectives(createVNode(u,{modelValue:n.showCursor,"onUpdate:modelValue":e[12]||(e[12]=i=>n.showCursor=i),sessionKey:"lotus-playground.showCursor"},null,8,["modelValue"]),[[vShow,!1]]),withDirectives(createVNode(l,{modelValue:n.chromaticMode,"onUpdate:modelValue":e[13]||(e[13]=i=>n.chromaticMode=i),localKey:"lotus-playground.chromaticMode"},null,8,["modelValue"]),[[vShow,!1]]),createVNode(c,{icon:"piano",modelValue:n.tokenizeStaff,"onUpdate:modelValue":e[14]||(e[14]=i=>n.tokenizeStaff=i),title:"toggle live staff view"},null,8,["modelValue"]),createBaseVNode("fieldset",{class:normalizeClass({"hidden-but-hold-place":!n.tokenizeStaff})},[createVNode(c,{icon:"palette",modelValue:n.enabledChromatic,"onUpdate:modelValue":e[15]||(e[15]=i=>n.enabledChromatic=i),disabled:!n.sheetDocument,title:"enable chromatic mode"},null,8,["modelValue","disabled"]),withDirectives(createBaseVNode("select",{class:normalizeClass({"hidden-but-hold-place":!n.enabledChromatic}),"onUpdate:modelValue":e[16]||(e[16]=i=>n.chromaticMode=i),title:"chromatic mode type"},[...e[79]||(e[79]=[createBaseVNode("option",{value:"symbols"},"symbols",-1),createBaseVNode("option",{value:"pitch"},"pitch",-1),createBaseVNode("option",{value:"track"},"track",-1)])],2),[[vModelSelect,n.chromaticMode]]),createVNode(c,{icon:"sliders",modelValue:n.rollVisible,"onUpdate:modelValue":e[17]||(e[17]=i=>n.rollVisible=i),disabled:!n.midiPlayer,title:"toggle MIDI roll view"},null,8,["modelValue","disabled"]),createVNode(c,{icon:"git-branch",modelValue:n.showNotationsMatcher,"onUpdate:modelValue":e[18]||(e[18]=i=>n.showNotationsMatcher=i),disabled:!n.matcherNotations,title:"show notations matcher"},null,8,["modelValue","disabled"]),createVNode(c,{icon:"speaker",modelValue:n.enabledMidiAudio,"onUpdate:modelValue":e[19]||(e[19]=i=>n.enabledMidiAudio=i),title:"toggle MIDI audio playback"},null,8,["modelValue"]),createVNode(c,{icon:"playbar",modelValue:n.showCursor,"onUpdate:modelValue":e[20]||(e[20]=i=>n.showCursor=i),title:"toggle playback cursor"},null,8,["modelValue"]),createBaseVNode("button",{onClick:e[21]||(e[21]=(...i)=>o.togglePlayer&&o.togglePlayer(...i)),disabled:!n.midiPlayer,title:"play/pause MIDI"},[createVNode(a,{name:n.midiPlayer&&n.midiPlayer.isPlaying?"bars":"triangle-right"},null,8,["name"])],8,_hoisted_5)],2)]),createBaseVNode("fieldset",{class:normalizeClass({"hidden-but-hold-place":!n.tokenizeStaff})},[withDirectives(createVNode(u,{modelValue:n.bakingSheet,"onUpdate:modelValue":e[22]||(e[22]=i=>n.bakingSheet=i),sessionKey:"lotus-bakingSheet"},null,8,["modelValue"]),[[vShow,!1]]),createVNode(c,{icon:"type",modelValue:n.enabledMusicFont,"onUpdate:modelValue":e[23]||(e[23]=i=>n.enabledMusicFont=i),title:"enable music font rendering"},null,8,["modelValue"]),createVNode(c,{icon:"layers",modelValue:n.bakingSheet,"onUpdate:modelValue":e[24]||(e[24]=i=>n.bakingSheet=i),title:"enable sheet baking mode"},null,8,["modelValue"]),createVNode(c,{class:normalizeClass({"hidden-but-hold-place":!n.bakingSheet}),icon:"eye-off",modelValue:n.hideBakingImages,"onUpdate:modelValue":e[25]||(e[25]=i=>n.hideBakingImages=i),title:"hide baking background images"},null,8,["class","modelValue"])],2),createBaseVNode("fieldset",{class:normalizeClass({"hidden-but-hold-place":!n.tokenizeStaff})},[withDirectives(createVNode(u,{modelValue:n.enabledPointer,"onUpdate:modelValue":e[26]||(e[26]=i=>n.enabledPointer=i),sessionKey:"lotus-enabledPointer"},null,8,["modelValue"]),[[vShow,!1]]),createVNode(c,{icon:"cursor-arrow",modelValue:n.enabledPointer,"onUpdate:modelValue":e[27]||(e[27]=i=>n.enabledPointer=i),title:"enable pointer tracking"},null,8,["modelValue"]),n.enabledPointer?(openBlock(),createElementBlock("span",_hoisted_6,[n.pointerData?(openBlock(),createElementBlock("span",_hoisted_7,[createBaseVNode("span",null,[e[80]||(e[80]=createTextVNode("m: ",-1)),createBaseVNode("em",null,toDisplayString(n.pointerData.measureIndex),1)]),Number.isFinite(n.pointerData.tick)?(openBlock(),createElementBlock("span",_hoisted_8,[e[81]||(e[81]=createTextVNode("t: ",-1)),createBaseVNode("em",null,toDisplayString(Math.round(n.pointerData.tick)),1)])):createCommentVNode("",!0)])):createCommentVNode("",!0)])):createCommentVNode("",!0)],2),createBaseVNode("fieldset",null,[createBaseVNode("button",{onClick:e[28]||(e[28]=(...i)=>o.updateMeasureLayoutCode&&o.updateMeasureLayoutCode(...i)),title:"update measure layout code",disabled:n.loadingLilyParser},[createVNode(a,{name:"brackets"})],8,_hoisted_9),n.measureLayoutCode||n.measureLayoutCode===""?withDirectives((openBlock(),createElementBlock("input",{key:0,class:normalizeClass(["measure-layout-code",{error:n.measureLayoutCodeError,dirty:n.measureLayoutCodeDirty}]),type:"text","onUpdate:modelValue":e[29]||(e[29]=i=>n.measureLayoutCode=i),title:n.measureLayoutCodeError||"measure layout code",onInput:e[30]||(e[30]=(...i)=>o.validateMeasureLayoutCode&&o.validateMeasureLayoutCode(...i)),onChange:e[31]||(e[31]=i=>n.measureLayoutCodeDirty=!0)},null,42,_hoisted_10)),[[vModelText,n.measureLayoutCode]]):createCommentVNode("",!0),n.measureLayoutCodeDirty&&!n.measureLayoutCodeError?(openBlock(),createElementBlock("button",{key:1,class:"apply",disabled:n.loadingLilyParser,onClick:e[32]||(e[32]=(...i)=>o.applyUpdateMeasureLayoutCode&&o.applyUpdateMeasureLayoutCode(...i)),title:"apply measure layout changes"},"apply",8,_hoisted_11)):createCommentVNode("",!0)]),createBaseVNode("fieldset",null,[withDirectives(createBaseVNode("input",{class:"hightlight-symbol",type:"text","onUpdate:modelValue":e[33]||(e[33]=i=>n.highlightSymbol=i),title:"highlight symbol (case insensitive)"},null,512),[[vModelText,n.highlightSymbol]])])],2),createBaseVNode("main",null,[createBaseVNode("div",{class:normalizeClass(["source-container",{loading:o.sourceIsLoading,"drag-hover":n.sourceDragHover,connected:n.sourceEditorConnected}]),onDragover:e[37]||(e[37]=withModifiers(i=>n.sourceDragHover=!0,["prevent"])),onDragleave:e[38]||(e[38]=i=>n.sourceDragHover=null),onDrop:e[39]||(e[39]=withModifiers(i=>o.onDropFile(i,{source:!0}),["prevent","stop"])),onFocusin:e[40]||(e[40]=i=>n.showSourceDir=!1)},[createVNode(h,{ref:"sourceEditor",source:n.lilySource,"onUpdate:source":e[34]||(e[34]=i=>n.lilySource=i),disabled:o.sourceIsLoading},null,8,["source","disabled"]),createBaseVNode("span",_hoisted_12,[createBaseVNode("button",{class:"inspect",onClick:e[35]||(e[35]=(...i)=>o.inspectLily&&o.inspectLily(...i)),title:"inspect lily document"},[createVNode(a,{name:"book"})]),withDirectives(createBaseVNode("button",{class:normalizeClass(["log",o.engraverLogStatus]),title:n.engraverLogs,onClick:e[36]||(e[36]=(...i)=>o.showEngraverLog&&o.showEngraverLog(...i))},null,10,_hoisted_13),[[vShow,o.engraverLogStatus]]),withDirectives(createVNode(d,null,null,512),[[vShow,n.loadingLilyParser]])]),withDirectives(createVNode(d,null,null,512),[[vShow,o.sourceIsLoading]])],34),createBaseVNode("div",{class:normalizeClass(["build-container",{loading:n.engraving,dirty:n.engraverDirty,chromatic:n.enabledChromatic,inspecting:n.showNotationsMatcher}]),ref:"buildContainer","data-chromatic":n.chromaticMode},[n.tokenizeStaff&&n.midiPlayer?withDirectives((openBlock(),createBlock(m,{key:0,player:n.midiPlayer,timeScale:.016,height:120,width:n.buildContainerSize.width},null,8,["player","width"])),[[vShow,n.rollVisible]]):createCommentVNode("",!0),n.showNotationsMatcher&&n.matcherNotations?(openBlock(),createBlock(p,{key:1,criterion:n.matcherNotations&&n.matcherNotations.criterion,sample:n.matcherNotations&&n.matcherNotations.sample,path:n.matcherNotations&&n.matcherNotations.path,softIndexAsX:n.enabledSheetNotation,onClickCNote:o.onClickMatcherNote,onClickSNote:o.onClickMatcherNote},null,8,["criterion","sample","path","softIndexAsX","onClickCNote","onClickSNote"])):createCommentVNode("",!0),createBaseVNode("div",_hoisted_15,[n.svgDocuments&&!n.tokenizeStaff?(openBlock(),createBlock(g,{key:0,documents:n.svgDocuments,onLinkClick:o.onSheetLink},null,8,["documents","onLinkClick"])):createCommentVNode("",!0),n.svgHashTable?withDirectives((openBlock(),createBlock(y,{key:1,hashTable:n.svgHashTable,enabledFont:n.enabledMusicFont},null,8,["hashTable","enabledFont"])),[[vShow,!1]]):createCommentVNode("",!0),n.tokenizeStaff&&n.sheetDocument?(openBlock(),createBlock(w,{key:2,ref:"sheet",doc:n.sheetDocument,midiNotation:n.midiNotation,pitchContextGroup:n.pitchContextGroup,midiPlayer:n.midiPlayer,"onUpdate:midiPlayer":e[41]||(e[41]=i=>n.midiPlayer=i),showMark:!0,enablePointer:n.enabledPointer,showCursor:n.showCursor,bakingMode:n.bakingSheet,backgroundImages:n.hideBakingImages?null:n.bakingImages,scheduler:n.scheduler,"onUpdate:scheduler":e[42]||(e[42]=i=>n.scheduler=i),enabledFont:n.enabledMusicFont,highlightSymbol:n.highlightSymbol&&n.highlightSymbol.toUpperCase(),onMidi:o.onMidi,onCursorPageShift:o.onCursorPageShift,onPointerUpdate:o.onPointerUpdate,onPointerClick:o.onPointerClick,onClickToken:o.onClickToken},{system:withCtx(i=>[n.enabledChromatic?(openBlock(),createElementBlock("g",_hoisted_16,[(openBlock(!0),createElementBlock(Fragment,null,renderList(i.system.staves,(v,k)=>(openBlock(),createElementBlock("g",{class:"staff",key:k,transform:`translate(${v.x}, ${v.y})`},[n.chromaticMode==="symbols"?(openBlock(),createElementBlock("g",_hoisted_18,[createBaseVNode("rect",{class:"head",x:0,y:-2,width:v.headWidth,height:4},null,8,_hoisted_19),e[82]||(e[82]=createBaseVNode("circle",null,null,-1)),Number.isFinite(v.top)?(openBlock(),createElementBlock("line",{key:0,x1:0,y1:v.top,x2:i.system.width,y2:v.top},null,8,_hoisted_20)):createCommentVNode("",!0),(openBlock(!0),createElementBlock(Fragment,null,renderList(v.measures,(b,x)=>(openBlock(),createElementBlock("g",{class:normalizeClass(["measure",b.class]),key:x},[createBaseVNode("rect",{x:b.lineX,y:-2,width:b.noteRange.end-b.lineX,height:4},null,8,_hoisted_21),createBaseVNode("text",{x:b.headX},"'"+toDisplayString(b.index),9,_hoisted_22)],2))),128))])):createCommentVNode("",!0),n.chromaticMode==="pitch"&&o.pitchContextMarks[i.system.index]&&o.pitchContextMarks[i.system.index][k]?(openBlock(),createElementBlock("g",_hoisted_23,[(openBlock(!0),createElementBlock(Fragment,null,renderList(o.pitchContextMarks[i.system.index][k],(b,x)=>(openBlock(),createElementBlock("g",{key:x,transform:`translate(${b.x}, 0)`},[e[85]||(e[85]=createBaseVNode("line",{class:"base-line",x1:"0",x2:"0",y1:"-3",y2:"3"},null,-1)),createBaseVNode("g",_hoisted_25,[(openBlock(!0),createElementBlock(Fragment,null,renderList(b.names[0],(_,S)=>(openBlock(),createElementBlock("g",{key:S,class:normalizeClass(["pitch",{sharp:_.alter>0,flat:_.alter<0}]),transform:`translate(0, ${_.y})`},[e[83]||(e[83]=createBaseVNode("rect",{class:"bg"},null,-1)),createBaseVNode("text",null,toDisplayString(_.name),1)],10,_hoisted_26))),128))]),createBaseVNode("g",_hoisted_27,[(openBlock(!0),createElementBlock(Fragment,null,renderList(b.names[1],(_,S)=>(openBlock(),createElementBlock("g",{key:S,class:normalizeClass(["pitch",{sharp:_.alter>0,flat:_.alter<0}]),transform:`translate(0, ${_.y})`},[e[84]||(e[84]=createBaseVNode("rect",{class:"bg"},null,-1)),createBaseVNode("text",null,toDisplayString(_.name),1)],10,_hoisted_28))),128))])],8,_hoisted_24))),128))])):createCommentVNode("",!0)],8,_hoisted_17))),128))])):createCommentVNode("",!0)]),staff:withCtx(i=>[n.enabledChromatic&&n.chromaticMode==="symbols"?(openBlock(),createElementBlock("g",_hoisted_29,[o.staffTopToken(i.staff)?(openBlock(),createElementBlock("g",_hoisted_30,[createBaseVNode("g",{class:"staff-peak",transform:`translate(${o.staffTopToken(i.staff).x}, ${o.staffTopToken(i.staff).y})`},[e[86]||(e[86]=createBaseVNode("path",{d:"M-1.2,0 L1.2,0 M-0.9,0.6 L0,0 L0.9,0.6"},null,-1)),createBaseVNode("line",{x1:0,x2:0,y1:0,y2:-o.staffTopToken(i.staff).y},null,8,_hoisted_32),e[87]||(e[87]=createBaseVNode("circle",null,null,-1))],8,_hoisted_31),createBaseVNode("g",{class:"staff-peak",transform:`translate(${o.staffBottomToken(i.staff).x}, ${o.staffBottomToken(i.staff).y})`},[e[88]||(e[88]=createBaseVNode("path",{d:"M-1.2,0 L1.2,0 M-0.9,-0.6 L0,0 L0.9,-0.6"},null,-1)),createBaseVNode("line",{x1:0,x2:0,y1:0,y2:-o.staffBottomToken(i.staff).y},null,8,_hoisted_34),e[89]||(e[89]=createBaseVNode("circle",null,null,-1))],8,_hoisted_33)])):createCommentVNode("",!0)])):createCommentVNode("",!0)]),_:1},8,["doc","midiNotation","pitchContextGroup","midiPlayer","enablePointer","showCursor","bakingMode","backgroundImages","scheduler","enabledFont","highlightSymbol","onMidi","onCursorPageShift","onPointerUpdate","onPointerClick","onClickToken"])):createCommentVNode("",!0)],512),withDirectives(createVNode(d,null,null,512),[[vShow,n.engraving]])],10,_hoisted_14),n.sourceEditorEnabled?(openBlock(),createElementBlock("div",_hoisted_35,[createBaseVNode("button",{class:"folder",onClick:e[43]||(e[43]=i=>{n.showSourceDir=!n.showSourceDir,t.$refs.sourceDir.reload()}),title:"browse source files"},[createVNode(a,{name:"folder",size:24})]),withDirectives(createVNode(l,{modelValue:n.sourceEditorHost,"onUpdate:modelValue":e[44]||(e[44]=i=>n.sourceEditorHost=i),localKey:"lotus-sourceEditorHost"},null,8,["modelValue"]),[[vShow,!1]]),withDirectives(createVNode(l,{modelValue:n.sourceEditorFilePath,"onUpdate:modelValue":e[45]||(e[45]=i=>n.sourceEditorFilePath=i),sessionKey:"lotus-sourceEditorFilePath"},null,8,["modelValue"]),[[vShow,!1]]),withDirectives(createVNode(L,{ref:"remoteFile",host:n.sourceEditorHost,filePath:n.sourceEditorFilePath,filePathReadOnly:!0,content:n.lilySource,"onUpdate:content":e[46]||(e[46]=i=>n.lilySource=i),connected:n.sourceEditorConnected,"onUpdate:connected":e[47]||(e[47]=i=>n.sourceEditorConnected=i),loading:n.sourceEditorLoading,"onUpdate:loading":e[48]||(e[48]=i=>n.sourceEditorLoading=i)},null,8,["host","filePath","content","connected","loading"]),[[vShow,n.sourceEditorFilePath]]),createVNode(B,{ref:"sourceDir",homeURL:"/source-dir/",shown:n.showSourceDir,"onUpdate:shown":e[49]||(e[49]=i=>n.showSourceDir=i),handlePattern:/\.ly$/,compactFolders:!0,onPickFile:o.onSourceDirPick},null,8,["shown","onPickFile"])])):createCommentVNode("",!0)]),createVNode(C,{visible:n.settingPanelVisible,"onUpdate:visible":e[75]||(e[75]=i=>n.settingPanelVisible=i)},{default:withCtx(()=>[createBaseVNode("div",_hoisted_36,[createBaseVNode("header",_hoisted_37,[e[90]||(e[90]=createBaseVNode("h2",null,"Settings",-1)),createBaseVNode("button",{class:"close-btn",onClick:e[50]||(e[50]=withModifiers(i=>n.settingPanelVisible=!1,["stop"])),title:"close"},"×")]),createBaseVNode("div",_hoisted_38,[createBaseVNode("datalist",_hoisted_39,[(openBlock(!0),createElementBlock(Fragment,null,renderList(n.lilyMarkupMethods,(i,v)=>(openBlock(),createElementBlock("option",{key:v,value:i},null,8,_hoisted_40))),128))]),createBaseVNode("section",_hoisted_41,[e[99]||(e[99]=createBaseVNode("h3",null,"MusicXML to Lilypond",-1)),createBaseVNode("div",_hoisted_42,[createBaseVNode("label",null,[e[91]||(e[91]=createBaseVNode("span",null,"Remove Breaks",-1)),createVNode(u,{modelValue:n.xml2lyOptions.removeBreaks,"onUpdate:modelValue":e[51]||(e[51]=i=>n.xml2lyOptions.removeBreaks=i),localKey:"lotus-xml2lyOptions.removeBreaks"},null,8,["modelValue"])]),createBaseVNode("label",null,[e[92]||(e[92]=createBaseVNode("span",null,"Remove Staff Group",-1)),createVNode(u,{modelValue:n.xml2lyOptions.removeStaffGroup,"onUpdate:modelValue":e[52]||(e[52]=i=>n.xml2lyOptions.removeStaffGroup=i),localKey:"lotus-xml2lyOptions.removeStaffGroup"},null,8,["modelValue"])]),createBaseVNode("label",null,[e[93]||(e[93]=createBaseVNode("span",null,"Merge Continuous Graces",-1)),createVNode(u,{modelValue:n.xml2lyOptions.mergeContinuousGraces,"onUpdate:modelValue":e[53]||(e[53]=i=>n.xml2lyOptions.mergeContinuousGraces=i),localKey:"lotus-xml2lyOptions.mergeContinuousGraces"},null,8,["modelValue"])]),createBaseVNode("label",null,[e[94]||(e[94]=createBaseVNode("span",null,"Exclude Chord Tracks from MIDI",-1)),createVNode(u,{modelValue:n.xml2lyOptions.excludeChordTracksFromMIDI,"onUpdate:modelValue":e[54]||(e[54]=i=>n.xml2lyOptions.excludeChordTracksFromMIDI=i),localKey:"lotus-xml2lyOptions.excludeChordTracksFromMIDI"},null,8,["modelValue"])]),createBaseVNode("label",null,[e[95]||(e[95]=createBaseVNode("span",null,"Use MIDI Instrument as Channel Mapping",-1)),createVNode(u,{modelValue:n.xml2lyOptions.midiChannelMapping,"onUpdate:modelValue":e[55]||(e[55]=i=>n.xml2lyOptions.midiChannelMapping=i),localKey:"lotus-xml2lyOptions.midiChannelMapping"},null,8,["modelValue"])]),createBaseVNode("label",null,[e[96]||(e[96]=createBaseVNode("span",null,"Remove Trill Spans",-1)),createBaseVNode("button",{onClick:e[56]||(e[56]=(...i)=>o.removeTrillSpans&&o.removeTrillSpans(...i)),disabled:n.loadingLilyParser},"Remove",8,_hoisted_43)]),createBaseVNode("label",null,[e[97]||(e[97]=createBaseVNode("span",null,"Prune Stem Directions",-1)),createBaseVNode("button",{onClick:e[57]||(e[57]=i=>o.executeMarkup("pruneStemDirections")),disabled:n.loadingLilyParser},"Prune",8,_hoisted_44)]),createBaseVNode("label",null,[e[98]||(e[98]=createBaseVNode("span",null,"Redivide Measures",-1)),createBaseVNode("button",{onClick:e[58]||(e[58]=(...i)=>o.redivideLilyDocument&&o.redivideLilyDocument(...i)),disabled:n.loadingLilyParser},"Redivide",8,_hoisted_45)])])]),createBaseVNode("section",_hoisted_46,[e[106]||(e[106]=createBaseVNode("h3",null,"Engrave",-1)),createBaseVNode("div",_hoisted_47,[createBaseVNode("label",null,[e[100]||(e[100]=createBaseVNode("span",null,"Logger Recorder",-1)),createVNode(u,{modelValue:n.engraveWithLogs,"onUpdate:modelValue":e[59]||(e[59]=i=>n.engraveWithLogs=i),localKey:"lotus-engraveWithLogs"},null,8,["modelValue"])]),createBaseVNode("label",null,[e[101]||(e[101]=createBaseVNode("span",null,"Use Sheet Notation",-1)),createVNode(u,{modelValue:n.enabledSheetNotation,"onUpdate:modelValue":e[60]||(e[60]=i=>n.enabledSheetNotation=i),localKey:"lotus-enabledSheetNot"},null,8,["modelValue"])]),withDirectives(createBaseVNode("label",null,[e[102]||(e[102]=createBaseVNode("span",null,"Fuzzy Notation Matcher",-1)),createVNode(u,{modelValue:n.enabledFuzzyMatcher,"onUpdate:modelValue":e[61]||(e[61]=i=>n.enabledFuzzyMatcher=i),localKey:"lotus-enabledFuzzyMatcher"},null,8,["modelValue"])],512),[[vShow,n.enabledSheetNotation]]),createBaseVNode("label",null,[e[104]||(e[104]=createBaseVNode("span",null,"Measure Repeat Type",-1)),createBaseVNode("div",_hoisted_48,[withDirectives(createVNode(l,{modelValue:n.measureLayoutType,"onUpdate:modelValue":e[62]||(e[62]=i=>n.measureLayoutType=i),localKey:"lotus-measureLayoutType"},null,8,["modelValue"]),[[vShow,!1]]),withDirectives(createBaseVNode("select",{"onUpdate:modelValue":e[63]||(e[63]=i=>n.measureLayoutType=i)},[...e[103]||(e[103]=[createBaseVNode("option",{value:"ordinary"},"Ordinary",-1),createBaseVNode("option",{value:"full"},"Full",-1),createBaseVNode("option",{value:"conservative"},"Conservative",-1),createBaseVNode("option",{value:"once"},"Once",-1)])],512),[[vModelSelect,n.measureLayoutType]])])]),createBaseVNode("label",null,[e[105]||(e[105]=createBaseVNode("span",null,"Articulate MIDI",-1)),createVNode(u,{modelValue:n.articulateMIDI,"onUpdate:modelValue":e[64]||(e[64]=i=>n.articulateMIDI=i),localKey:"lotus-articulateMIDI"},null,8,["modelValue"])])])]),createBaseVNode("section",_hoisted_49,[e[116]||(e[116]=createBaseVNode("h3",null,"Lilypond Markups",-1)),createBaseVNode("div",_hoisted_50,[createBaseVNode("label",null,[e[107]||(e[107]=createBaseVNode("span",null,"Enabled",-1)),createVNode(u,{modelValue:n.lilyMarkups.enabled,"onUpdate:modelValue":e[65]||(e[65]=i=>n.lilyMarkups.enabled=i),localKey:"lotus-lilyMarkups.enabled"},null,8,["modelValue"])]),createBaseVNode("label",null,[e[108]||(e[108]=createBaseVNode("span",null,"Staff Size",-1)),createVNode(l,{type:"number",modelValue:n.lilyMarkups.staffSize,"onUpdate:modelValue":e[66]||(e[66]=i=>n.lilyMarkups.staffSize=i),modelModifiers:{number:!0},localKey:"lotus-lilyMarkups.staffSize"},null,8,["modelValue"])]),createBaseVNode("label",null,[e[109]||(e[109]=createBaseVNode("span",null,"Auto Paper Size",-1)),createVNode(u,{modelValue:n.lilyMarkups.autoPaperSize,"onUpdate:modelValue":e[67]||(e[67]=i=>n.lilyMarkups.autoPaperSize=i),localKey:"lotus-lilyMarkups.autoPaperSize"},null,8,["modelValue"])]),createBaseVNode("label",null,[e[110]||(e[110]=createBaseVNode("span",null,"Page Count",-1)),createVNode(l,{type:"number",modelValue:n.lilyMarkups.pageCount,"onUpdate:modelValue":e[68]||(e[68]=i=>n.lilyMarkups.pageCount=i),modelModifiers:{number:!0},localKey:"lotus-lilyMarkups.pageCount"},null,8,["modelValue"])]),createBaseVNode("label",null,[e[111]||(e[111]=createBaseVNode("span",null,"System-System Spacing",-1)),createVNode(l,{type:"number",modelValue:n.lilyMarkups.systemSpacing,"onUpdate:modelValue":e[69]||(e[69]=i=>n.lilyMarkups.systemSpacing=i),modelModifiers:{number:!0},localKey:"lotus-lilyMarkups.systemSpacing"},null,8,["modelValue"])]),createBaseVNode("label",null,[e[112]||(e[112]=createBaseVNode("span",null,"Top Markup Spacing",-1)),createVNode(l,{type:"number",modelValue:n.lilyMarkups.topMarkupSpacing,"onUpdate:modelValue":e[70]||(e[70]=i=>n.lilyMarkups.topMarkupSpacing=i),modelModifiers:{number:!0},localKey:"lotus-lilyMarkups.topMarkupSpacing"},null,8,["modelValue"])]),createBaseVNode("label",null,[e[113]||(e[113]=createBaseVNode("span",null,"Ragged Last",-1)),createVNode(u,{modelValue:n.lilyMarkups.raggedLast,"onUpdate:modelValue":e[71]||(e[71]=i=>n.lilyMarkups.raggedLast=i),localKey:"lotus-lilyMarkups.raggedLast"},null,8,["modelValue"])]),createBaseVNode("label",null,[e[114]||(e[114]=createBaseVNode("span",null,"Export a Markup File",-1)),createBaseVNode("button",{onClick:e[72]||(e[72]=(...i)=>o.exportMarkupLily&&o.exportMarkupLily(...i))},"Export .ly")]),createBaseVNode("label",_hoisted_51,[e[115]||(e[115]=createBaseVNode("span",null,"Execute Function",-1)),createBaseVNode("div",_hoisted_52,[withDirectives(createBaseVNode("input",{type:"text",list:"lily-markups","onUpdate:modelValue":e[73]||(e[73]=i=>n.chosenLilyMarkupMethod=i),placeholder:"Choose method..."},null,512),[[vModelText,n.chosenLilyMarkupMethod]]),createBaseVNode("button",{onClick:e[74]||(e[74]=i=>{o.executeMarkup(n.chosenLilyMarkupMethod),n.chosenLilyMarkupMethod=null}),disabled:!n.chosenLilyMarkupMethod},toDisplayString(n.chosenLilyMarkupMethod?"Call":"Done"),9,_hoisted_53)])])])])])])]),_:1},8,["visible"]),withDirectives(createBaseVNode("canvas",_hoisted_54,null,512),[[vShow,!1]])],42,_hoisted_1)}const playground=_export_sfc(_sfc_main,[["render",_sfc_render]]);export{playground as default}; | |