@coderline/alphatab-vite 1.7.0-alpha.1617 → 1.7.0-alpha.1625
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AlphaTabVitePluginOptions.d.ts +30 -0
- package/dist/AlphaTabVitePluginOptions.mjs +36 -0
- package/dist/alphaTab.vite.d.ts +1 -33
- package/dist/alphaTab.vite.mjs +2 -2326
- package/dist/alphaTabVitePlugin.d.ts +5 -0
- package/dist/alphaTabVitePlugin.mjs +53 -0
- package/dist/bridge/asset.mjs +63 -0
- package/dist/bridge/build.mjs +217 -0
- package/dist/bridge/config.mjs +36 -0
- package/dist/bridge/constants.mjs +82 -0
- package/dist/bridge/fsUtils.mjs +56 -0
- package/dist/bridge/index.mjs +43 -0
- package/dist/bridge/optimizer.mjs +148 -0
- package/dist/bridge/plugins.mjs +47 -0
- package/dist/bridge/resolve.mjs +71 -0
- package/dist/bridge/typeUtils.d.ts +3 -0
- package/dist/bridge/typeUtils.mjs +36 -0
- package/dist/bridge/utils.mjs +151 -0
- package/dist/bridge/worker.d.ts +10 -0
- package/dist/bridge/worker.mjs +180 -0
- package/dist/copyAssetsPlugin.d.ts +5 -0
- package/dist/copyAssetsPlugin.mjs +143 -0
- package/dist/importMetaPlugin.d.ts +5 -0
- package/dist/importMetaPlugin.mjs +197 -0
- package/dist/workerPlugin.d.ts +5 -0
- package/dist/workerPlugin.mjs +201 -0
- package/package.json +9 -5
- package/dist/alphaTab.vite.js +0 -2386
- package/dist/alphaTab.vite.min.mjs +0 -36
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* alphaTab Vite Plugin v1.7.0-alpha.1617 (develop, build 1617)
|
|
3
|
-
*
|
|
4
|
-
* Copyright © 2025, Daniel Kuschny and Contributors, All rights reserved.
|
|
5
|
-
*
|
|
6
|
-
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
7
|
-
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
8
|
-
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
9
|
-
*
|
|
10
|
-
* This library uses code from Vite (https://github.com/vitejs/vite/), licensed under:
|
|
11
|
-
*
|
|
12
|
-
* MIT License
|
|
13
|
-
* Copyright (c) 2019-present, Yuxi (Evan) You and Vite contributors
|
|
14
|
-
*
|
|
15
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
16
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
17
|
-
* in the Software without restriction, including without limitation the rights
|
|
18
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
19
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
20
|
-
* furnished to do so, subject to the following conditions:
|
|
21
|
-
*
|
|
22
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
23
|
-
* copies or substantial portions of the Software.
|
|
24
|
-
*
|
|
25
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
26
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
27
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
28
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
29
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
30
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
31
|
-
* SOFTWARE.
|
|
32
|
-
*
|
|
33
|
-
* @preserve
|
|
34
|
-
* @license
|
|
35
|
-
*/
|
|
36
|
-
import*as t from"node:fs";import*as e from"node:path";import r from"node:path";import*as i from"node:url";import{createHash as n}from"node:crypto";import{normalizePath as s,BuildEnvironment as o}from"vite";var h=",".charCodeAt(0),a=";".charCodeAt(0),u="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",c=new Uint8Array(64),f=new Uint8Array(128);for(let t=0;t<64;t++){const e=u.charCodeAt(t);c[t]=e,f[e]=t}function l(t,e,r){let i=e-r;i=i<0?-i<<1|1:i<<1;do{let e=31&i;i>>>=5,i>0&&(e|=32),t.write(c[e])}while(i>0);return e}var d="undefined"!=typeof TextDecoder?new TextDecoder:"undefined"!=typeof Buffer?{decode:t=>Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString()}:{decode(t){let e="";for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return e}},p=class{constructor(){this.pos=0,this.out="",this.buffer=new Uint8Array(16384)}write(t){const{buffer:e}=this;e[this.pos++]=t,16384===this.pos&&(this.out+=d.decode(e),this.pos=0)}flush(){const{buffer:t,out:e,pos:r}=this;return r>0?e+d.decode(t.subarray(0,r)):e}};class m{constructor(t){this.bits=t instanceof m?t.bits.slice():[]}add(t){this.bits[t>>5]|=1<<(31&t)}has(t){return!!(this.bits[t>>5]&1<<(31&t))}}class w{constructor(t,e,r){this.start=t,this.end=e,this.original=r,this.intro="",this.outro="",this.content=r,this.storeName=!1,this.edited=!1,this.previous=null,this.next=null}appendLeft(t){this.outro+=t}appendRight(t){this.intro=this.intro+t}clone(){const t=new w(this.start,this.end,this.original);return t.intro=this.intro,t.outro=this.outro,t.content=this.content,t.storeName=this.storeName,t.edited=this.edited,t}contains(t){return this.start<t&&t<this.end}eachNext(t){let e=this;for(;e;)t(e),e=e.next}eachPrevious(t){let e=this;for(;e;)t(e),e=e.previous}edit(t,e,r){return this.content=t,r||(this.intro="",this.outro=""),this.storeName=e,this.edited=!0,this}prependLeft(t){this.outro=t+this.outro}prependRight(t){this.intro=t+this.intro}reset(){this.intro="",this.outro="",this.edited&&(this.content=this.original,this.storeName=!1,this.edited=!1)}split(t){const e=t-this.start,r=this.original.slice(0,e),i=this.original.slice(e);this.original=r;const n=new w(t,this.end,i);return n.outro=this.outro,this.outro="",this.end=t,this.edited?(n.edit("",!1),this.content=""):this.content=r,n.next=this.next,n.next&&(n.next.previous=n),n.previous=this,this.next=n,n}toString(){return this.intro+this.content+this.outro}trimEnd(t){if(this.outro=this.outro.replace(t,""),this.outro.length)return!0;const e=this.content.replace(t,"");return e.length?(e!==this.content&&(this.split(this.start+e.length).edit("",void 0,!0),this.edited&&this.edit(e,this.storeName,!0)),!0):(this.edit("",void 0,!0),this.intro=this.intro.replace(t,""),!!this.intro.length||void 0)}trimStart(t){if(this.intro=this.intro.replace(t,""),this.intro.length)return!0;const e=this.content.replace(t,"");if(e.length){if(e!==this.content){const t=this.split(this.end-e.length);this.edited&&t.edit(e,this.storeName,!0),this.edit("",void 0,!0)}return!0}return this.edit("",void 0,!0),this.outro=this.outro.replace(t,""),!!this.outro.length||void 0}}function g(){return"undefined"!=typeof globalThis&&"function"==typeof globalThis.btoa?t=>globalThis.btoa(unescape(encodeURIComponent(t))):"function"==typeof Buffer?t=>Buffer.from(t,"utf-8").toString("base64"):()=>{throw new Error("Unsupported environment: `window.btoa` or `Buffer` should be supported.")}}const b=g();class y{constructor(t){this.version=3,this.file=t.file,this.sources=t.sources,this.sourcesContent=t.sourcesContent,this.names=t.names,this.mappings=function(t){const e=new p;let r=0,i=0,n=0,s=0;for(let o=0;o<t.length;o++){const u=t[o];if(o>0&&e.write(a),0===u.length)continue;let c=0;for(let t=0;t<u.length;t++){const o=u[t];t>0&&e.write(h),c=l(e,o[0],c),1!==o.length&&(r=l(e,o[1],r),i=l(e,o[2],i),n=l(e,o[3],n),4!==o.length&&(s=l(e,o[4],s)))}}return e.flush()}(t.mappings),void 0!==t.x_google_ignoreList&&(this.x_google_ignoreList=t.x_google_ignoreList),void 0!==t.debugId&&(this.debugId=t.debugId)}toString(){return JSON.stringify(this)}toUrl(){return"data:application/json;charset=utf-8;base64,"+b(this.toString())}}function v(t,e){const r=t.split(/[/\\]/),i=e.split(/[/\\]/);for(r.pop();r[0]===i[0];)r.shift(),i.shift();if(r.length){let t=r.length;for(;t--;)r[t]=".."}return r.concat(i).join("/")}const $=Object.prototype.toString;function E(t){const e=t.split("\n"),r=[];for(let t=0,i=0;t<e.length;t++)r.push(i),i+=e[t].length+1;return function(t){let e=0,i=r.length;for(;e<i;){const n=e+i>>1;t<r[n]?i=n:e=n+1}const n=e-1;return{line:n,column:t-r[n]}}}const S=/\w/;class k{constructor(t){this.hires=t,this.generatedCodeLine=0,this.generatedCodeColumn=0,this.raw=[],this.rawSegments=this.raw[this.generatedCodeLine]=[],this.pending=null}addEdit(t,e,r,i){if(e.length){const n=e.length-1;let s=e.indexOf("\n",0),o=-1;for(;s>=0&&n>s;){const n=[this.generatedCodeColumn,t,r.line,r.column];i>=0&&n.push(i),this.rawSegments.push(n),this.generatedCodeLine+=1,this.raw[this.generatedCodeLine]=this.rawSegments=[],this.generatedCodeColumn=0,o=s,s=e.indexOf("\n",s+1)}const h=[this.generatedCodeColumn,t,r.line,r.column];i>=0&&h.push(i),this.rawSegments.push(h),this.advance(e.slice(o+1))}else this.pending&&(this.rawSegments.push(this.pending),this.advance(e));this.pending=null}addUneditedChunk(t,e,r,i,n){let s=e.start,o=!0,h=!1;for(;s<e.end;){if("\n"===r[s])i.line+=1,i.column=0,this.generatedCodeLine+=1,this.raw[this.generatedCodeLine]=this.rawSegments=[],this.generatedCodeColumn=0,o=!0,h=!1;else{if(this.hires||o||n.has(s)){const e=[this.generatedCodeColumn,t,i.line,i.column];"boundary"===this.hires?S.test(r[s])?h||(this.rawSegments.push(e),h=!0):(this.rawSegments.push(e),h=!1):this.rawSegments.push(e)}i.column+=1,this.generatedCodeColumn+=1,o=!1}s+=1}this.pending=null}advance(t){if(!t)return;const e=t.split("\n");if(e.length>1){for(let t=0;t<e.length-1;t++)this.generatedCodeLine++,this.raw[this.generatedCodeLine]=this.rawSegments=[];this.generatedCodeColumn=0}this.generatedCodeColumn+=e[e.length-1].length}}const T="\n",R={insertLeft:!1,insertRight:!1,storeName:!1};class _{constructor(t,e={}){const r=new w(0,t.length,t);Object.defineProperties(this,{original:{writable:!0,value:t},outro:{writable:!0,value:""},intro:{writable:!0,value:""},firstChunk:{writable:!0,value:r},lastChunk:{writable:!0,value:r},lastSearchedChunk:{writable:!0,value:r},byStart:{writable:!0,value:{}},byEnd:{writable:!0,value:{}},filename:{writable:!0,value:e.filename},indentExclusionRanges:{writable:!0,value:e.indentExclusionRanges},sourcemapLocations:{writable:!0,value:new m},storedNames:{writable:!0,value:{}},indentStr:{writable:!0,value:void 0},ignoreList:{writable:!0,value:e.ignoreList},offset:{writable:!0,value:e.offset||0}}),this.byStart[0]=r,this.byEnd[t.length]=r}addSourcemapLocation(t){this.sourcemapLocations.add(t)}append(t){if("string"!=typeof t)throw new TypeError("outro content must be a string");return this.outro+=t,this}appendLeft(t,e){if(t+=this.offset,"string"!=typeof e)throw new TypeError("inserted content must be a string");this.t(t);const r=this.byEnd[t];return r?r.appendLeft(e):this.intro+=e,this}appendRight(t,e){if(t+=this.offset,"string"!=typeof e)throw new TypeError("inserted content must be a string");this.t(t);const r=this.byStart[t];return r?r.appendRight(e):this.outro+=e,this}clone(){const t=new _(this.original,{filename:this.filename,offset:this.offset});let e=this.firstChunk,r=t.firstChunk=t.lastSearchedChunk=e.clone();for(;e;){t.byStart[r.start]=r,t.byEnd[r.end]=r;const i=e.next,n=i&&i.clone();n&&(r.next=n,n.previous=r,r=n),e=i}return t.lastChunk=r,this.indentExclusionRanges&&(t.indentExclusionRanges=this.indentExclusionRanges.slice()),t.sourcemapLocations=new m(this.sourcemapLocations),t.intro=this.intro,t.outro=this.outro,t}generateDecodedMap(t){t=t||{};const e=Object.keys(this.storedNames),r=new k(t.hires),i=E(this.original);return this.intro&&r.advance(this.intro),this.firstChunk.eachNext(t=>{const n=i(t.start);t.intro.length&&r.advance(t.intro),t.edited?r.addEdit(0,t.content,n,t.storeName?e.indexOf(t.original):-1):r.addUneditedChunk(0,t,this.original,n,this.sourcemapLocations),t.outro.length&&r.advance(t.outro)}),{file:t.file?t.file.split(/[/\\]/).pop():void 0,sources:[t.source?v(t.file||"",t.source):t.file||""],sourcesContent:t.includeContent?[this.original]:void 0,names:e,mappings:r.raw,x_google_ignoreList:this.ignoreList?[0]:void 0}}generateMap(t){return new y(this.generateDecodedMap(t))}i(){void 0===this.indentStr&&(this.indentStr=function(t){const e=t.split("\n"),r=e.filter(t=>/^\t+/.test(t)),i=e.filter(t=>/^ {2,}/.test(t));if(0===r.length&&0===i.length)return null;if(r.length>=i.length)return"\t";const n=i.reduce((t,e)=>{const r=/^ +/.exec(e)[0].length;return Math.min(r,t)},1/0);return new Array(n+1).join(" ")}(this.original))}o(){return this.i(),this.indentStr}getIndentString(){return this.i(),null===this.indentStr?"\t":this.indentStr}indent(t,e){const r=/^[^\r\n]/gm;var i;if(i=t,"[object Object]"===$.call(i)&&(e=t,t=void 0),void 0===t&&(this.i(),t=this.indentStr||"\t"),""===t)return this;const n={};if((e=e||{}).exclude){("number"==typeof e.exclude[0]?[e.exclude]:e.exclude).forEach(t=>{for(let e=t[0];e<t[1];e+=1)n[e]=!0})}let s=!1!==e.indentStart;const o=e=>s?`${t}${e}`:(s=!0,e);this.intro=this.intro.replace(r,o);let h=0,a=this.firstChunk;for(;a;){const e=a.end;if(a.edited)n[h]||(a.content=a.content.replace(r,o),a.content.length&&(s="\n"===a.content[a.content.length-1]));else for(h=a.start;h<e;){if(!n[h]){const e=this.original[h];"\n"===e?s=!0:"\r"!==e&&s&&(s=!1,h===a.start||(this.h(a,h),a=a.next),a.prependRight(t))}h+=1}h=a.end,a=a.next}return this.outro=this.outro.replace(r,o),this}insert(){throw new Error("magicString.insert(...) is deprecated. Use prependRight(...) or appendLeft(...)")}insertLeft(t,e){return R.insertLeft||(console.warn("magicString.insertLeft(...) is deprecated. Use magicString.appendLeft(...) instead"),R.insertLeft=!0),this.appendLeft(t,e)}insertRight(t,e){return R.insertRight||(console.warn("magicString.insertRight(...) is deprecated. Use magicString.prependRight(...) instead"),R.insertRight=!0),this.prependRight(t,e)}move(t,e,r){if(t+=this.offset,e+=this.offset,(r+=this.offset)>=t&&r<=e)throw new Error("Cannot move a selection inside itself");this.t(t),this.t(e),this.t(r);const i=this.byStart[t],n=this.byEnd[e],s=i.previous,o=n.next,h=this.byStart[r];if(!h&&n===this.lastChunk)return this;const a=h?h.previous:this.lastChunk;return s&&(s.next=o),o&&(o.previous=s),a&&(a.next=i),h&&(h.previous=n),i.previous||(this.firstChunk=n.next),n.next||(this.lastChunk=i.previous,this.lastChunk.next=null),i.previous=a,n.next=h||null,a||(this.firstChunk=i),h||(this.lastChunk=n),this}overwrite(t,e,r,i){return i=i||{},this.update(t,e,r,{...i,overwrite:!i.contentOnly})}update(t,e,r,i){if(t+=this.offset,e+=this.offset,"string"!=typeof r)throw new TypeError("replacement content must be a string");if(0!==this.original.length){for(;t<0;)t+=this.original.length;for(;e<0;)e+=this.original.length}if(e>this.original.length)throw new Error("end is out of bounds");if(t===e)throw new Error("Cannot overwrite a zero-length range – use appendLeft or prependRight instead");this.t(t),this.t(e),!0===i&&(R.storeName||(console.warn("The final argument to magicString.overwrite(...) should be an options object. See https://github.com/rich-harris/magic-string"),R.storeName=!0),i={storeName:!0});const n=void 0!==i&&i.storeName,s=void 0!==i&&i.overwrite;if(n){const r=this.original.slice(t,e);Object.defineProperty(this.storedNames,r,{writable:!0,value:!0,enumerable:!0})}const o=this.byStart[t],h=this.byEnd[e];if(o){let t=o;for(;t!==h;){if(t.next!==this.byStart[t.end])throw new Error("Cannot overwrite across a split point");t=t.next,t.edit("",!1)}o.edit(r,n,!s)}else{const i=new w(t,e,"").edit(r,n);h.next=i,i.previous=h}return this}prepend(t){if("string"!=typeof t)throw new TypeError("outro content must be a string");return this.intro=t+this.intro,this}prependLeft(t,e){if(t+=this.offset,"string"!=typeof e)throw new TypeError("inserted content must be a string");this.t(t);const r=this.byEnd[t];return r?r.prependLeft(e):this.intro=e+this.intro,this}prependRight(t,e){if(t+=this.offset,"string"!=typeof e)throw new TypeError("inserted content must be a string");this.t(t);const r=this.byStart[t];return r?r.prependRight(e):this.outro=e+this.outro,this}remove(t,e){if(t+=this.offset,e+=this.offset,0!==this.original.length){for(;t<0;)t+=this.original.length;for(;e<0;)e+=this.original.length}if(t===e)return this;if(t<0||e>this.original.length)throw new Error("Character is out of bounds");if(t>e)throw new Error("end must be greater than start");this.t(t),this.t(e);let r=this.byStart[t];for(;r;)r.intro="",r.outro="",r.edit(""),r=e>r.end?this.byStart[r.end]:null;return this}reset(t,e){if(t+=this.offset,e+=this.offset,0!==this.original.length){for(;t<0;)t+=this.original.length;for(;e<0;)e+=this.original.length}if(t===e)return this;if(t<0||e>this.original.length)throw new Error("Character is out of bounds");if(t>e)throw new Error("end must be greater than start");this.t(t),this.t(e);let r=this.byStart[t];for(;r;)r.reset(),r=e>r.end?this.byStart[r.end]:null;return this}lastChar(){if(this.outro.length)return this.outro[this.outro.length-1];let t=this.lastChunk;do{if(t.outro.length)return t.outro[t.outro.length-1];if(t.content.length)return t.content[t.content.length-1];if(t.intro.length)return t.intro[t.intro.length-1]}while(t=t.previous);return this.intro.length?this.intro[this.intro.length-1]:""}lastLine(){let t=this.outro.lastIndexOf(T);if(-1!==t)return this.outro.substr(t+1);let e=this.outro,r=this.lastChunk;do{if(r.outro.length>0){if(t=r.outro.lastIndexOf(T),-1!==t)return r.outro.substr(t+1)+e;e=r.outro+e}if(r.content.length>0){if(t=r.content.lastIndexOf(T),-1!==t)return r.content.substr(t+1)+e;e=r.content+e}if(r.intro.length>0){if(t=r.intro.lastIndexOf(T),-1!==t)return r.intro.substr(t+1)+e;e=r.intro+e}}while(r=r.previous);return t=this.intro.lastIndexOf(T),-1!==t?this.intro.substr(t+1)+e:this.intro+e}slice(t=0,e=this.original.length-this.offset){if(t+=this.offset,e+=this.offset,0!==this.original.length){for(;t<0;)t+=this.original.length;for(;e<0;)e+=this.original.length}let r="",i=this.firstChunk;for(;i&&(i.start>t||i.end<=t);){if(i.start<e&&i.end>=e)return r;i=i.next}if(i&&i.edited&&i.start!==t)throw new Error(`Cannot use replaced character ${t} as slice start anchor.`);const n=i;for(;i;){!i.intro||n===i&&i.start!==t||(r+=i.intro);const s=i.start<e&&i.end>=e;if(s&&i.edited&&i.end!==e)throw new Error(`Cannot use replaced character ${e} as slice end anchor.`);const o=n===i?t-i.start:0,h=s?i.content.length+e-i.end:i.content.length;if(r+=i.content.slice(o,h),!i.outro||s&&i.end!==e||(r+=i.outro),s)break;i=i.next}return r}snip(t,e){const r=this.clone();return r.remove(0,t),r.remove(e,r.original.length),r}t(t){if(this.byStart[t]||this.byEnd[t])return;let e=this.lastSearchedChunk,r=e;const i=t>e.end;for(;e;){if(e.contains(t))return this.h(e,t);if(e=i?this.byStart[e.end]:this.byEnd[e.start],e===r)return;r=e}}h(t,e){if(t.edited&&t.content.length){const r=E(this.original)(e);throw new Error(`Cannot split a chunk that has already been edited (${r.line}:${r.column} – "${t.original}")`)}const r=t.split(e);return this.byEnd[e]=t,this.byStart[e]=r,this.byEnd[r.end]=r,t===this.lastChunk&&(this.lastChunk=r),this.lastSearchedChunk=t,!0}toString(){let t=this.intro,e=this.firstChunk;for(;e;)t+=e.toString(),e=e.next;return t+this.outro}isEmpty(){let t=this.firstChunk;do{if(t.intro.length&&t.intro.trim()||t.content.length&&t.content.trim()||t.outro.length&&t.outro.trim())return!1}while(t=t.next);return!0}length(){let t=this.firstChunk,e=0;do{e+=t.intro.length+t.content.length+t.outro.length}while(t=t.next);return e}trimLines(){return this.trim("[\\r\\n]")}trim(t){return this.trimStart(t).trimEnd(t)}trimEndAborted(t){const e=new RegExp((t||"\\s")+"+$");if(this.outro=this.outro.replace(e,""),this.outro.length)return!0;let r=this.lastChunk;do{const t=r.end,i=r.trimEnd(e);if(r.end!==t&&(this.lastChunk===r&&(this.lastChunk=r.next),this.byEnd[r.end]=r,this.byStart[r.next.start]=r.next,this.byEnd[r.next.end]=r.next),i)return!0;r=r.previous}while(r);return!1}trimEnd(t){return this.trimEndAborted(t),this}trimStartAborted(t){const e=new RegExp("^"+(t||"\\s")+"+");if(this.intro=this.intro.replace(e,""),this.intro.length)return!0;let r=this.firstChunk;do{const t=r.end,i=r.trimStart(e);if(r.end!==t&&(r===this.lastChunk&&(this.lastChunk=r.next),this.byEnd[r.end]=r,this.byStart[r.next.start]=r.next,this.byEnd[r.next.end]=r.next),i)return!0;r=r.next}while(r);return!1}trimStart(t){return this.trimStartAborted(t),this}hasChanged(){return this.original!==this.toString()}u(t,e){function r(t,r){return"string"==typeof e?e.replace(/\$(\$|&|\d+)/g,(e,r)=>{if("$"===r)return"$";if("&"===r)return t[0];return+r<t.length?t[+r]:`$${r}`}):e(...t,t.index,r,t.groups)}if(t.global){(function(t,e){let r;const i=[];for(;r=t.exec(e);)i.push(r);return i})(t,this.original).forEach(t=>{if(null!=t.index){const e=r(t,this.original);e!==t[0]&&this.overwrite(t.index,t.index+t[0].length,e)}})}else{const e=this.original.match(t);if(e&&null!=e.index){const t=r(e,this.original);t!==e[0]&&this.overwrite(e.index,e.index+e[0].length,t)}}return this}l(t,e){const{original:r}=this,i=r.indexOf(t);return-1!==i&&this.overwrite(i,i+t.length,e),this}replace(t,e){return"string"==typeof t?this.l(t,e):this.u(t,e)}p(t,e){const{original:r}=this,i=t.length;for(let n=r.indexOf(t);-1!==n;n=r.indexOf(t,n+i)){r.slice(n,n+i)!==e&&this.overwrite(n,n+i,e)}return this}replaceAll(t,e){if("string"==typeof t)return this.p(t,e);if(!t.global)throw new TypeError("MagicString.prototype.replaceAll called with a non-global RegExp argument");return this.u(t,e)}}const C=/[?#].*$/;function U(t){return t.replace(C,"")}function L(t,e){return t&&e?("/"===t[t.length-1]&&(t=t.substring(0,t.length-1)),"/"!==e[0]&&(e=`/${e}`),t+e):t||e||""}function j(t,e){const r=t.indexOf("?");return t+(-1===r?"?":"&")+e}function N(t){if(t.startsWith("data:"))return t;const e=U(t),r=e!==t?t.slice(e.length):"";return e.replaceAll("%","%25")+r}function O(t){if(t.startsWith("data:"))return t;const e=U(t),r=e!==t?t.slice(e.length):"";return encodeURI(e)+r}async function I(t,r){let i;i=t.startsWith(function(t){return"/"!==t[t.length-1]?`${t}/`:t}(r.root))?`/${e.posix.relative(r.root,t)}`:e.posix.join("/@fs/",t);const n=L(r.server?.origin??"",r.base);return L(n,"/"===(s=i)[0]?s.slice(1):s);var s}const M="_metadata.json",x=["options","buildStart","buildEnd","renderStart","renderError","renderChunk","writeBundle","generateBundle","banner","footer","augmentChunkHash","outputOptions","renderDynamicImport","resolveFileUrl","resolveImportMeta","intro","outro","closeBundle","closeWatcher","load","moduleParsed","watchChange","resolveDynamicImport","resolveId","shouldTransformCachedModule","transform","onLog"];function A(t){return"object"==typeof t?t.handler:t}const B=/[\n\r'\\\u2028\u2029]/,H=/([\n\r'\u2028\u2029])/g,D=/\\/g;function W(t){return B.test(t)?t.replace(D,"\\\\").replace(H,"\\$1"):t}const z=(t,e="URL")=>`new ${e}(${t}).href`,F=(t,e=!1)=>z(`'${W(N(t))}', ${e?"typeof document === 'undefined' ? location.href : ":""}document.currentScript && document.currentScript.src || document.baseURI`),J=t=>(t=>`require('u' + 'rl').pathToFileURL(${t}).href`)(`__dirname + '/${W(t)}'`),P={...{amd:t=>("."!==t[0]&&(t=`./${t}`),z(`require.toUrl('${W(t)}'), document.baseURI`)),cjs:t=>`(typeof document === 'undefined' ? ${J(t)} : ${F(t)})`,es:t=>z(`'${W(N(t))}', import.meta.url`),iife:t=>F(t),system:t=>z(`'${W(N(t))}', module.meta.url`),umd:t=>`(typeof document === 'undefined' && typeof location === 'undefined' ? ${J(t)} : ${F(t,!0)})`},"worker-iife":t=>z(`'${W(N(t))}', self.location.href`)};function q(t,e,r,i,n,s){const{renderBuiltUrl:o}=n.experimental;let h=""===n.base||"./"===n.base;if(o){const s=o(t,{hostId:r,hostType:i,type:e,ssr:!!n.build.ssr});if("object"==typeof s){if(s.runtime)return{runtime:s.runtime};"boolean"==typeof s.relative&&(h=s.relative)}else if(s)return s}return h&&!n.build.ssr?s(t,r):L(n.base,t)}function K(t,e){if(!e)return;const r=A(e),i=function(e,i,n){return r.call(X(this,t),e,i,Y(n,t))};return"handler"in e?{...e,handler:i}:i}function V(t,e){if(!e)return;const r=A(e),i=function(e,...i){return r.call(X(this,t),e,Y(i[0],t))};return"handler"in e?{...e,handler:i}:i}function G(t,e){if(!e)return;const r=A(e),i=function(e,i,...n){return r.call(X(this,t),e,i,Y(n[0],t))};return"handler"in e?{...e,handler:i}:i}function Q(t,e){if(!e)return;const r=A(e);if("function"!=typeof r)return e;const i=function(...e){return r.call(X(this,t),...e)};return"handler"in e?{...e,handler:i}:i}function X(t,e){return t.environment??=e,t}function Y(t,e){return{...t??{},ssr:!e||"server"===e.config.consumer}}function Z(e,r){const i=function(e){try{return t.statSync(e,{throwIfNoEntry:!1})}catch{}}(e);return i?.isFile()?e:i?.isSymbolicLink()?r?e:t.realpathSync(e):void 0}function tt(t,e){const{file:r,postfix:i}=function(t){const e=U(t);return{file:e,postfix:t.slice(e.length)}}(t),n=function(t,e){if(t.includes("node_modules"))return Z(t,e);const r=Z(s(t));if(!r)return Z(t,e);return r}(r,e);if(n)return n+i}function et(r,i,n,o,h){const a=function(r,i){const n=i?it:rt;let o=n.get(r);o||(o=function(r){const i=s(e.resolve(r.cacheDir,"deps")),n=function(t,r){const{hash:i,lockfileHash:n,configHash:o,browserHash:h,optimized:a,chunks:u}=JSON.parse(t,(t,i)=>"file"===t||"src"===t?s(e.resolve(r,i)):i);if(!u||Object.values(a).some(t=>!t.fileHash))return;const c={hash:i,lockfileHash:n,configHash:o,browserHash:h,optimized:{},discovered:{},chunks:{},depInfoList:[]};for(const t of Object.keys(a))nt(c,"optimized",{...a[t],id:t,browserHash:h});for(const t of Object.keys(u))nt(c,"chunks",{...u[t],id:t,browserHash:h,needsInterop:!1});return c}(t.readFileSync(e.join(i,M),"utf8"),i),o=()=>{throw new Error("not implemented")};return{async init(){},metadata:n,registerMissingImport:o,run:o,isOptimizedDepFile:t=>t.startsWith(i),isOptimizedDepUrl:o,getOptimizedDepId:o,close:o,options:{}}}(r),n.set(r,o));return o}(r,i);if(a?.isOptimizedDepFile(o)){const t=U(o),r=(u=a.metadata,c=t,u.depInfoList.find(t=>t.file===c)),i=r?.src;if(i){return tt(e.resolve(e.dirname(i),n),h)}}var u,c}const rt=new WeakMap,it=new WeakMap;function nt(t,e,r){return t[e][r.id]=r,t.depInfoList.push(r),r}var st;!function(t){t.WorkerClassic="worker_classic",t.WorkerModule="worker_module",t.AudioWorklet="audio_worklet"}(st||(st={}));const ot=new WeakMap,ht="alphatab_worker",at="__ALPHATAB_WORKER_ASSET__";function ut(t,e){ot.get(t.mainConfig||t).assets.set(e.fileName,e)}async function ct(t,r){const i=ot.get(t.mainConfig||t);let s=i.bundle.get(r);if(!s){const n=await async function(t,r){const i=U(r),n=t.bundleChain??[],s=[...n,i];if(n.includes(i))throw new Error(`Circular worker imports detected. Vite does not support it. Import chain: ${s.join(" -> ")}`);const{rollup:h}=await import("rollup"),{plugins:a,rollupOptions:u,format:c}=t.worker,f=await a(s),l=new o("client",f);await l.init();const d=await h({...u,input:i,plugins:l.plugins.map(t=>function(t,e){const{resolveId:r,load:i,transform:n}=e,s={...e};for(const e of Object.keys(s))switch(e){case"resolveId":s[e]=K(t,r);break;case"load":s[e]=V(t,i);break;case"transform":s[e]=G(t,n);break;default:x.includes(e)&&(s[e]=Q(t,s[e]))}return s}(l,t)),preserveEntrySignatures:!1});let p;try{const r=t.worker.rollupOptions.output,i=r?Array.isArray(r)?r[0]||{}:r:{},{output:[n,...s]}=await d.generate({entryFileNames:e.posix.join(t.build.assetsDir,"[name]-[hash].js"),chunkFileNames:e.posix.join(t.build.assetsDir,"[name]-[hash].js"),assetFileNames:e.posix.join(t.build.assetsDir,"[name]-[hash].[ext]"),...i,format:c,sourcemap:t.build.sourcemap});p=n;for(const e of s)"asset"===e.type?ut(t,e):"chunk"===e.type&&ut(t,{fileName:e.fileName,source:e.code})}finally{await d.close()}return function(t,e){const{map:r}=e;if(r&&("hidden"===t.build.sourcemap||!0===t.build.sourcemap)){const i=r.toString();ut(t,{fileName:`${e.fileName}.map`,source:i})}return e}(t,p)}(t,r);s=n.fileName,ut(t,{fileName:s,source:n.code}),i.bundle.set(r,s)}return function(t,e){const{fileNameHash:r}=e,i=function(t,e=8){const r=n("sha256").update(t).digest("hex").substring(0,e);return e<=64?r:r.padEnd(e,"_")}(t);r.get(i)||r.set(i,t);return`${at}${i}__`}(s,i)}function ft(t,e){return"string"==typeof t?"string"==typeof e?t===e:Buffer.from(t).equals(e):Buffer.from(e).equals(t)}const lt=[["alphaTabWorker","new","alphaTabUrl","import.meta.url"],["alphaTabWorklet.addModule","new","alphaTabUrl","import.meta.url"]];function dt(t){for(const e of lt){let r=0;for(const i of e)if(r=t.indexOf(i,r),-1===r)break;if(-1!==r)return!0}return!1}function pt(t,e){if(e[1].includes(".addModule"))return st.AudioWorklet;const r=e.indices[0][1],i=t.indexOf("{",r);if(-1===i)return st.WorkerClassic;const n=t.indexOf("}",r);if(-1===n)return st.WorkerClassic;const s=t.indexOf(")",r);if(i>s||n>s)return st.WorkerClassic;let o=t.slice(i,n+1);try{o=new Function(`\n var console, exports, global, module, process, require\n return (\n${o}\n)\n `)()}catch{return st.WorkerClassic}return"object"==typeof o&&"module"===o?.type?st.WorkerModule:st.WorkerClassic}const mt=new RegExp(`(?:\\?|&)${ht}&type=(\\w+)(?:&|$)`),wt=new RegExp(`${at}([a-z\\d]{8})__`,"g");function gt(t){let r,i,n;const s=!1!==t.webWorkers,o=!1!==t.audioWorklets,h=s||o;return{name:"vite-plugin-alphatab-worker",configResolved(t){r=t,i="build"===t.command,n=t.isWorker},buildStart(){h&&!n&&ot.set(r,{assets:new Map,bundle:new Map,fileNameHash:new Map})},load(t){if(h&&i&&t.includes(ht))return""},shouldTransformCachedModule({id:t}){if(h&&i&&r.build.watch&&t.includes(ht))return!0},async transform(t,i){if(!h)return;const n=mt.exec(i);if(!n)return;const s=JSON.stringify(e.posix.join(r.base,"/@vite/env"));let o="";switch(n[1]){case st.WorkerClassic:o=`importScripts(${s})\n`;break;case st.WorkerModule:case st.AudioWorklet:o=`import ${s}\n`}if(o){const e=new _(t);return e.prepend(o),{code:e.toString(),map:e.generateMap({hires:"boundary"})}}},renderChunk(t,i,n){let s;if(wt.lastIndex=0,wt.test(t)){const o=function(t,r){const i=P[r&&"iife"===t?"worker-iife":t];return(t,r)=>({runtime:i(e.posix.relative(e.dirname(r),t))})}(n.format,r.isWorker);s=new _(t),wt.lastIndex=0;const h=ot.get(r.mainConfig||r),{fileNameHash:a}=h;let u=wt.exec(t);for(;u;){const[e,n]=u,h=q(a.get(n),"asset",i.fileName,"js",r,o),c="string"==typeof h?JSON.stringify(O(h)).slice(1,-1):`"+${h.runtime}+"`;s.update(u.index,u.index+e.length,c),u=wt.exec(t)}}return s&&{code:s.toString(),map:r.build.sourcemap?s.generateMap({hires:"boundary"}):null}},generateBundle(t,e){if(n)return;const i=ot.get(r);for(const t of i.assets.values()){const r=e[t.fileName];if(r){if(ft("asset"===r.type?r.source:r.code,t.source))return}this.emitFile({type:"asset",fileName:t.fileName,source:t.source})}i.assets.clear()}}}function bt(n){const s=[];return n??={},s.push(function(t){let e,i,n;const s=!1!==t.webWorkers,o=!1!==t.audioWorklets,h=s||o;return{name:"vite-plugin-alphatab-url",enforce:"pre",configResolved(t){e=t,i="build"===t.command,n=t.resolve.preserveSymlinks},shouldTransformCachedModule({code:t}){if(h&&i&&e.build.watch&&dt(t))return!0},async transform(t,a,u){if(!h||u?.ssr||!dt(t))return;let c;const f=/\b(alphaTabWorker|alphaTabWorklet\.addModule)\s*\(\s*(new\s+[^ (]+alphaTabUrl\s*\(\s*('[^']+'|"[^"]+"|`[^`]+`)\s*,\s*import\.meta\.url\s*\))/dg;let l=f.exec(t);for(;l;){const h=pt(t,l);let d=!1;switch(h){case st.WorkerClassic:case st.WorkerModule:d=s;break;case st.AudioWorklet:d=o}if(!d){l=f.exec(t);continue}c??=new _(t);const p=t.slice(l.indices[3][0]+1,l.indices[3][1]-1);let m,w=r.resolve(r.dirname(a),p);w=tt(w,n)??et(e,!0===u?.ssr,p,a,n)??w,i?m=await ct(e,w):(m=await I(U(w),e),m=j(m,`${ht}&type=${h}`)),c.update(l.indices[3][0],l.indices[3][1],`new URL('' + ${JSON.stringify(m)}, import.meta.url)`),l=f.exec(t)}return c?{code:c.toString(),map:"build"===e.command&&e.build.sourcemap?c.generateMap({hires:"boundary",source:a}):null}:null}}}(n)),s.push(gt(n)),s.push(function(r){let n,s=!1;return{name:"vite-plugin-alphatab-copy",enforce:"pre",configResolved(t){n=t},buildEnd(){s=!1},async buildStart(){if(s)return;s=!0;let o,h=r.alphaTabSourceDir;if(!h)try{const t="string"==typeof import.meta.url;h=t?i.fileURLToPath(import.meta.resolve("@coderline/alphatab")):require.resolve("@coderline/alphatab"),h=e.resolve(h,"..")}catch{h=e.join(n.root,"node_modules/@coderline/alphatab/dist/")}if(h)try{await t.promises.access(e.join(h,"alphaTab.mjs"),t.constants.F_OK),o=!0}catch{o=!1}else o=!1;if(!o)return void n.logger.error("Could not find alphaTab, please ensure it is installed into node_modules or configure alphaTabSourceDir");const a=r.assetOutputDir??n.publicDir;async function u(r){const i=e.join(h,r),n=await t.promises.readdir(i,{withFileTypes:!0});await t.promises.mkdir(e.join(a,r),{recursive:!0}),await Promise.all(n.filter(t=>t.isFile()).map(async i=>{const n=e.join(i.parentPath??i.path,i.name);await t.promises.copyFile(n,e.join(a,r,i.name))}))}a&&await Promise.all([u("font"),u("soundfont")])}}}(n)),s}export{bt as alphaTab};
|