@coderline/alphatab-vite 1.7.0-alpha.1575 → 1.7.0-alpha.1577
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/alphaTab.vite.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* alphaTab Vite Plugin v1.7.0-alpha.
|
|
2
|
+
* alphaTab Vite Plugin v1.7.0-alpha.1577 (develop, build 1577)
|
|
3
3
|
*
|
|
4
4
|
* Copyright © 2025, Daniel Kuschny and Contributors, All rights reserved.
|
|
5
5
|
*
|
|
@@ -1807,7 +1807,7 @@ function wrapEnvironmentHook(environment, hook) {
|
|
|
1807
1807
|
return handler;
|
|
1808
1808
|
}
|
|
1809
1809
|
function injectEnvironmentInContext(context, environment) {
|
|
1810
|
-
context.environment
|
|
1810
|
+
context.environment ??= environment;
|
|
1811
1811
|
return context;
|
|
1812
1812
|
}
|
|
1813
1813
|
function injectSsrFlag(options, environment) {
|
|
@@ -2171,9 +2171,7 @@ function importMetaUrlPlugin(options) {
|
|
|
2171
2171
|
return;
|
|
2172
2172
|
}
|
|
2173
2173
|
let s;
|
|
2174
|
-
const alphaTabWorkerPattern =
|
|
2175
|
-
// @ts-expect-error For the Vite plugin we expect newer node than for alphaTab itself (-> migrate to monorepo)
|
|
2176
|
-
/\b(alphaTabWorker|alphaTabWorklet\.addModule)\s*\(\s*(new\s+[^ (]+alphaTabUrl\s*\(\s*('[^']+'|"[^"]+"|`[^`]+`)\s*,\s*import\.meta\.url\s*\))/dg;
|
|
2174
|
+
const alphaTabWorkerPattern = /\b(alphaTabWorker|alphaTabWorklet\.addModule)\s*\(\s*(new\s+[^ (]+alphaTabUrl\s*\(\s*('[^']+'|"[^"]+"|`[^`]+`)\s*,\s*import\.meta\.url\s*\))/dg;
|
|
2177
2175
|
let match = alphaTabWorkerPattern.exec(code);
|
|
2178
2176
|
while (match) {
|
|
2179
2177
|
const workerType = getWorkerType(code, match);
|
|
@@ -2191,7 +2189,7 @@ function importMetaUrlPlugin(options) {
|
|
|
2191
2189
|
match = alphaTabWorkerPattern.exec(code);
|
|
2192
2190
|
continue;
|
|
2193
2191
|
}
|
|
2194
|
-
s
|
|
2192
|
+
s ??= new MagicString(code);
|
|
2195
2193
|
const url = code.slice(match.indices[3][0] + 1, match.indices[3][1] - 1);
|
|
2196
2194
|
let file = path.resolve(path.dirname(id), url);
|
|
2197
2195
|
file =
|
|
@@ -2378,7 +2376,7 @@ function workerPlugin(options) {
|
|
|
2378
2376
|
|
|
2379
2377
|
function alphaTab(options) {
|
|
2380
2378
|
const plugins = [];
|
|
2381
|
-
options
|
|
2379
|
+
options ??= {};
|
|
2382
2380
|
plugins.push(importMetaUrlPlugin(options));
|
|
2383
2381
|
plugins.push(workerPlugin(options));
|
|
2384
2382
|
plugins.push(copyAssetsPlugin(options));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* alphaTab Vite Plugin v1.7.0-alpha.
|
|
2
|
+
* alphaTab Vite Plugin v1.7.0-alpha.1577 (develop, build 1577)
|
|
3
3
|
*
|
|
4
4
|
* Copyright © 2025, Daniel Kuschny and Contributors, All rights reserved.
|
|
5
5
|
*
|
|
@@ -33,4 +33,4 @@
|
|
|
33
33
|
* @preserve
|
|
34
34
|
* @license
|
|
35
35
|
*/
|
|
36
|
-
import*as t from"node:fs";import*as e from"node:path";import n from"node:path";import*as r from"node:url";import{createHash as i}from"node:crypto";import{normalizePath as s,BuildEnvironment as o}from"vite";var a=",".charCodeAt(0),l=";".charCodeAt(0),h="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",u=new Uint8Array(64),c=new Uint8Array(128);for(let t=0;t<64;t++){const e=h.charCodeAt(t);u[t]=e,c[e]=t}function d(t,e,n){let r=e-n;r=r<0?-r<<1|1:r<<1;do{let e=31&r;r>>>=5,r>0&&(e|=32),t.write(u[e])}while(r>0);return e}var f="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 n=0;n<t.length;n++)e+=String.fromCharCode(t[n]);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+=f.decode(e),this.pos=0)}flush(){const{buffer:t,out:e,pos:n}=this;return n>0?e+f.decode(t.subarray(0,n)):e}};class g{constructor(t){this.bits=t instanceof g?t.bits.slice():[]}add(t){this.bits[t>>5]|=1<<(31&t)}has(t){return!!(this.bits[t>>5]&1<<(31&t))}}class m{constructor(t,e,n){this.start=t,this.end=e,this.original=n,this.intro="",this.outro="",this.content=n,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 m(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,n){return this.content=t,n||(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,n=this.original.slice(0,e),r=this.original.slice(e);this.original=n;const i=new m(t,this.end,r);return i.outro=this.outro,this.outro="",this.end=t,this.edited?(i.edit("",!1),this.content=""):this.content=n,i.next=this.next,i.next&&(i.next.previous=i),i.previous=this,this.next=i,i}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 b(){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 w=b();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 n=0,r=0,i=0,s=0;for(let o=0;o<t.length;o++){const h=t[o];if(o>0&&e.write(l),0===h.length)continue;let u=0;for(let t=0;t<h.length;t++){const o=h[t];t>0&&e.write(a),u=d(e,o[0],u),1!==o.length&&(n=d(e,o[1],n),r=d(e,o[2],r),i=d(e,o[3],i),4!==o.length&&(s=d(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,"+w(this.toString())}}function v(t,e){const n=t.split(/[/\\]/),r=e.split(/[/\\]/);for(n.pop();n[0]===r[0];)n.shift(),r.shift();if(n.length){let t=n.length;for(;t--;)n[t]=".."}return n.concat(r).join("/")}const x=Object.prototype.toString;function C(t){const e=t.split("\n"),n=[];for(let t=0,r=0;t<e.length;t++)n.push(r),r+=e[t].length+1;return function(t){let e=0,r=n.length;for(;e<r;){const i=e+r>>1;t<n[i]?r=i:e=i+1}const i=e-1;return{line:i,column:t-n[i]}}}const k=/\w/;class S{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,n,r){if(e.length){const i=e.length-1;let s=e.indexOf("\n",0),o=-1;for(;s>=0&&i>s;){const i=[this.generatedCodeColumn,t,n.line,n.column];r>=0&&i.push(r),this.rawSegments.push(i),this.generatedCodeLine+=1,this.raw[this.generatedCodeLine]=this.rawSegments=[],this.generatedCodeColumn=0,o=s,s=e.indexOf("\n",s+1)}const a=[this.generatedCodeColumn,t,n.line,n.column];r>=0&&a.push(r),this.rawSegments.push(a),this.advance(e.slice(o+1))}else this.pending&&(this.rawSegments.push(this.pending),this.advance(e));this.pending=null}addUneditedChunk(t,e,n,r,i){let s=e.start,o=!0,a=!1;for(;s<e.end;){if("\n"===n[s])r.line+=1,r.column=0,this.generatedCodeLine+=1,this.raw[this.generatedCodeLine]=this.rawSegments=[],this.generatedCodeColumn=0,o=!0,a=!1;else{if(this.hires||o||i.has(s)){const e=[this.generatedCodeColumn,t,r.line,r.column];"boundary"===this.hires?k.test(n[s])?a||(this.rawSegments.push(e),a=!0):(this.rawSegments.push(e),a=!1):this.rawSegments.push(e)}r.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 E="\n",_={insertLeft:!1,insertRight:!1,storeName:!1};class L{constructor(t,e={}){const n=new m(0,t.length,t);Object.defineProperties(this,{original:{writable:!0,value:t},outro:{writable:!0,value:""},intro:{writable:!0,value:""},firstChunk:{writable:!0,value:n},lastChunk:{writable:!0,value:n},lastSearchedChunk:{writable:!0,value:n},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 g},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]=n,this.byEnd[t.length]=n}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._split(t);const n=this.byEnd[t];return n?n.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._split(t);const n=this.byStart[t];return n?n.appendRight(e):this.outro+=e,this}clone(){const t=new L(this.original,{filename:this.filename,offset:this.offset});let e=this.firstChunk,n=t.firstChunk=t.lastSearchedChunk=e.clone();for(;e;){t.byStart[n.start]=n,t.byEnd[n.end]=n;const r=e.next,i=r&&r.clone();i&&(n.next=i,i.previous=n,n=i),e=r}return t.lastChunk=n,this.indentExclusionRanges&&(t.indentExclusionRanges=this.indentExclusionRanges.slice()),t.sourcemapLocations=new g(this.sourcemapLocations),t.intro=this.intro,t.outro=this.outro,t}generateDecodedMap(t){t=t||{};const e=Object.keys(this.storedNames),n=new S(t.hires),r=C(this.original);return this.intro&&n.advance(this.intro),this.firstChunk.eachNext(t=>{const i=r(t.start);t.intro.length&&n.advance(t.intro),t.edited?n.addEdit(0,t.content,i,t.storeName?e.indexOf(t.original):-1):n.addUneditedChunk(0,t,this.original,i,this.sourcemapLocations),t.outro.length&&n.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:n.raw,x_google_ignoreList:this.ignoreList?[0]:void 0}}generateMap(t){return new y(this.generateDecodedMap(t))}_ensureindentStr(){void 0===this.indentStr&&(this.indentStr=function(t){const e=t.split("\n"),n=e.filter(t=>/^\t+/.test(t)),r=e.filter(t=>/^ {2,}/.test(t));if(0===n.length&&0===r.length)return null;if(n.length>=r.length)return"\t";const i=r.reduce((t,e)=>{const n=/^ +/.exec(e)[0].length;return Math.min(n,t)},1/0);return new Array(i+1).join(" ")}(this.original))}_getRawIndentString(){return this._ensureindentStr(),this.indentStr}getIndentString(){return this._ensureindentStr(),null===this.indentStr?"\t":this.indentStr}indent(t,e){const n=/^[^\r\n]/gm;var r;if(r=t,"[object Object]"===x.call(r)&&(e=t,t=void 0),void 0===t&&(this._ensureindentStr(),t=this.indentStr||"\t"),""===t)return this;const i={};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)i[e]=!0})}let s=!1!==e.indentStart;const o=e=>s?`${t}${e}`:(s=!0,e);this.intro=this.intro.replace(n,o);let a=0,l=this.firstChunk;for(;l;){const e=l.end;if(l.edited)i[a]||(l.content=l.content.replace(n,o),l.content.length&&(s="\n"===l.content[l.content.length-1]));else for(a=l.start;a<e;){if(!i[a]){const e=this.original[a];"\n"===e?s=!0:"\r"!==e&&s&&(s=!1,a===l.start||(this._splitChunk(l,a),l=l.next),l.prependRight(t))}a+=1}a=l.end,l=l.next}return this.outro=this.outro.replace(n,o),this}insert(){throw new Error("magicString.insert(...) is deprecated. Use prependRight(...) or appendLeft(...)")}insertLeft(t,e){return _.insertLeft||(console.warn("magicString.insertLeft(...) is deprecated. Use magicString.appendLeft(...) instead"),_.insertLeft=!0),this.appendLeft(t,e)}insertRight(t,e){return _.insertRight||(console.warn("magicString.insertRight(...) is deprecated. Use magicString.prependRight(...) instead"),_.insertRight=!0),this.prependRight(t,e)}move(t,e,n){if(t+=this.offset,e+=this.offset,(n+=this.offset)>=t&&n<=e)throw new Error("Cannot move a selection inside itself");this._split(t),this._split(e),this._split(n);const r=this.byStart[t],i=this.byEnd[e],s=r.previous,o=i.next,a=this.byStart[n];if(!a&&i===this.lastChunk)return this;const l=a?a.previous:this.lastChunk;return s&&(s.next=o),o&&(o.previous=s),l&&(l.next=r),a&&(a.previous=i),r.previous||(this.firstChunk=i.next),i.next||(this.lastChunk=r.previous,this.lastChunk.next=null),r.previous=l,i.next=a||null,l||(this.firstChunk=r),a||(this.lastChunk=i),this}overwrite(t,e,n,r){return r=r||{},this.update(t,e,n,{...r,overwrite:!r.contentOnly})}update(t,e,n,r){if(t+=this.offset,e+=this.offset,"string"!=typeof n)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._split(t),this._split(e),!0===r&&(_.storeName||(console.warn("The final argument to magicString.overwrite(...) should be an options object. See https://github.com/rich-harris/magic-string"),_.storeName=!0),r={storeName:!0});const i=void 0!==r&&r.storeName,s=void 0!==r&&r.overwrite;if(i){const n=this.original.slice(t,e);Object.defineProperty(this.storedNames,n,{writable:!0,value:!0,enumerable:!0})}const o=this.byStart[t],a=this.byEnd[e];if(o){let t=o;for(;t!==a;){if(t.next!==this.byStart[t.end])throw new Error("Cannot overwrite across a split point");t=t.next,t.edit("",!1)}o.edit(n,i,!s)}else{const r=new m(t,e,"").edit(n,i);a.next=r,r.previous=a}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._split(t);const n=this.byEnd[t];return n?n.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._split(t);const n=this.byStart[t];return n?n.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._split(t),this._split(e);let n=this.byStart[t];for(;n;)n.intro="",n.outro="",n.edit(""),n=e>n.end?this.byStart[n.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._split(t),this._split(e);let n=this.byStart[t];for(;n;)n.reset(),n=e>n.end?this.byStart[n.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(E);if(-1!==t)return this.outro.substr(t+1);let e=this.outro,n=this.lastChunk;do{if(n.outro.length>0){if(t=n.outro.lastIndexOf(E),-1!==t)return n.outro.substr(t+1)+e;e=n.outro+e}if(n.content.length>0){if(t=n.content.lastIndexOf(E),-1!==t)return n.content.substr(t+1)+e;e=n.content+e}if(n.intro.length>0){if(t=n.intro.lastIndexOf(E),-1!==t)return n.intro.substr(t+1)+e;e=n.intro+e}}while(n=n.previous);return t=this.intro.lastIndexOf(E),-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 n="",r=this.firstChunk;for(;r&&(r.start>t||r.end<=t);){if(r.start<e&&r.end>=e)return n;r=r.next}if(r&&r.edited&&r.start!==t)throw new Error(`Cannot use replaced character ${t} as slice start anchor.`);const i=r;for(;r;){!r.intro||i===r&&r.start!==t||(n+=r.intro);const s=r.start<e&&r.end>=e;if(s&&r.edited&&r.end!==e)throw new Error(`Cannot use replaced character ${e} as slice end anchor.`);const o=i===r?t-r.start:0,a=s?r.content.length+e-r.end:r.content.length;if(n+=r.content.slice(o,a),!r.outro||s&&r.end!==e||(n+=r.outro),s)break;r=r.next}return n}snip(t,e){const n=this.clone();return n.remove(0,t),n.remove(e,n.original.length),n}_split(t){if(this.byStart[t]||this.byEnd[t])return;let e=this.lastSearchedChunk,n=e;const r=t>e.end;for(;e;){if(e.contains(t))return this._splitChunk(e,t);if(e=r?this.byStart[e.end]:this.byEnd[e.start],e===n)return;n=e}}_splitChunk(t,e){if(t.edited&&t.content.length){const n=C(this.original)(e);throw new Error(`Cannot split a chunk that has already been edited (${n.line}:${n.column} – "${t.original}")`)}const n=t.split(e);return this.byEnd[e]=t,this.byStart[e]=n,this.byEnd[n.end]=n,t===this.lastChunk&&(this.lastChunk=n),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 n=this.lastChunk;do{const t=n.end,r=n.trimEnd(e);if(n.end!==t&&(this.lastChunk===n&&(this.lastChunk=n.next),this.byEnd[n.end]=n,this.byStart[n.next.start]=n.next,this.byEnd[n.next.end]=n.next),r)return!0;n=n.previous}while(n);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 n=this.firstChunk;do{const t=n.end,r=n.trimStart(e);if(n.end!==t&&(n===this.lastChunk&&(this.lastChunk=n.next),this.byEnd[n.end]=n,this.byStart[n.next.start]=n.next,this.byEnd[n.next.end]=n.next),r)return!0;n=n.next}while(n);return!1}trimStart(t){return this.trimStartAborted(t),this}hasChanged(){return this.original!==this.toString()}_replaceRegexp(t,e){function n(t,n){return"string"==typeof e?e.replace(/\$(\$|&|\d+)/g,(e,n)=>{if("$"===n)return"$";if("&"===n)return t[0];return+n<t.length?t[+n]:`$${n}`}):e(...t,t.index,n,t.groups)}if(t.global){(function(t,e){let n;const r=[];for(;n=t.exec(e);)r.push(n);return r})(t,this.original).forEach(t=>{if(null!=t.index){const e=n(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=n(e,this.original);t!==e[0]&&this.overwrite(e.index,e.index+e[0].length,t)}}return this}_replaceString(t,e){const{original:n}=this,r=n.indexOf(t);return-1!==r&&this.overwrite(r,r+t.length,e),this}replace(t,e){return"string"==typeof t?this._replaceString(t,e):this._replaceRegexp(t,e)}_replaceAllString(t,e){const{original:n}=this,r=t.length;for(let i=n.indexOf(t);-1!==i;i=n.indexOf(t,i+r)){n.slice(i,i+r)!==e&&this.overwrite(i,i+r,e)}return this}replaceAll(t,e){if("string"==typeof t)return this._replaceAllString(t,e);if(!t.global)throw new TypeError("MagicString.prototype.replaceAll called with a non-global RegExp argument");return this._replaceRegexp(t,e)}}const $=/[?#].*$/;function R(t){return t.replace($,"")}function O(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 N(t,e){const n=t.indexOf("?");return t+(-1===n?"?":"&")+e}function j(t){if(t.startsWith("data:"))return t;const e=R(t),n=e!==t?t.slice(e.length):"";return e.replaceAll("%","%25")+n}function W(t){if(t.startsWith("data:"))return t;const e=R(t),n=e!==t?t.slice(e.length):"";return encodeURI(e)+n}async function T(t,n){let r;r=t.startsWith(function(t){return"/"!==t[t.length-1]?`${t}/`:t}(n.root))?`/${e.posix.relative(n.root,t)}`:e.posix.join("/@fs/",t);const i=O(n.server?.origin??"",n.base);return O(i,"/"===(s=r)[0]?s.slice(1):s);var s}const I="_metadata.json",A=["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 M(t){return"object"==typeof t?t.handler:t}const U=/[\n\r'\\\u2028\u2029]/,D=/([\n\r'\u2028\u2029])/g,F=/\\/g;function H(t){return U.test(t)?t.replace(F,"\\\\").replace(D,"\\$1"):t}const B=(t,e="URL")=>`new ${e}(${t}).href`,z=(t,e=!1)=>B(`'${H(j(t))}', ${e?"typeof document === 'undefined' ? location.href : ":""}document.currentScript && document.currentScript.src || document.baseURI`),P=t=>(t=>`require('u' + 'rl').pathToFileURL(${t}).href`)(`__dirname + '/${H(t)}'`),q={...{amd:t=>("."!==t[0]&&(t=`./${t}`),B(`require.toUrl('${H(t)}'), document.baseURI`)),cjs:t=>`(typeof document === 'undefined' ? ${P(t)} : ${z(t)})`,es:t=>B(`'${H(j(t))}', import.meta.url`),iife:t=>z(t),system:t=>B(`'${H(j(t))}', module.meta.url`),umd:t=>`(typeof document === 'undefined' && typeof location === 'undefined' ? ${P(t)} : ${z(t,!0)})`},"worker-iife":t=>B(`'${H(j(t))}', self.location.href`)};function J(t,e,n,r,i,s){const{renderBuiltUrl:o}=i.experimental;let a=""===i.base||"./"===i.base;if(o){const s=o(t,{hostId:n,hostType:r,type:e,ssr:!!i.build.ssr});if("object"==typeof s){if(s.runtime)return{runtime:s.runtime};"boolean"==typeof s.relative&&(a=s.relative)}else if(s)return s}return a&&!i.build.ssr?s(t,n):O(i.base,t)}function K(t,e){if(!e)return;const n=M(e),r=function(e,r,i){return n.call(X(this,t),e,r,Y(i,t))};return"handler"in e?{...e,handler:r}:r}function V(t,e){if(!e)return;const n=M(e),r=function(e,...r){return n.call(X(this,t),e,Y(r[0],t))};return"handler"in e?{...e,handler:r}:r}function G(t,e){if(!e)return;const n=M(e),r=function(e,r,...i){return n.call(X(this,t),e,r,Y(i[0],t))};return"handler"in e?{...e,handler:r}:r}function Q(t,e){if(!e)return;const n=M(e);if("function"!=typeof n)return e;const r=function(...e){return n.call(X(this,t),...e)};return"handler"in e?{...e,handler:r}:r}function X(t,e){return t.environment??(t.environment=e),t}function Y(t,e){return{...t??{},ssr:!e||"server"===e.config.consumer}}function Z(e,n){const r=function(e){try{return t.statSync(e,{throwIfNoEntry:!1})}catch{}}(e);return r?.isFile()?e:r?.isSymbolicLink()?n?e:t.realpathSync(e):void 0}function tt(t,e){const{file:n,postfix:r}=function(t){const e=R(t);return{file:e,postfix:t.slice(e.length)}}(t),i=function(t,e){if(t.includes("node_modules"))return Z(t,e);const n=Z(s(t));if(!n)return Z(t,e);return n}(n,e);if(i)return i+r}function et(n,r,i,o,a){const l=function(n,r){const i=r?rt:nt;let o=i.get(n);o||(o=function(n){const r=s(e.resolve(n.cacheDir,"deps")),i=function(t,n){const{hash:r,lockfileHash:i,configHash:o,browserHash:a,optimized:l,chunks:h}=JSON.parse(t,(t,r)=>"file"===t||"src"===t?s(e.resolve(n,r)):r);if(!h||Object.values(l).some(t=>!t.fileHash))return;const u={hash:r,lockfileHash:i,configHash:o,browserHash:a,optimized:{},discovered:{},chunks:{},depInfoList:[]};for(const t of Object.keys(l))it(u,"optimized",{...l[t],id:t,browserHash:a});for(const t of Object.keys(h))it(u,"chunks",{...h[t],id:t,browserHash:a,needsInterop:!1});return u}(t.readFileSync(e.join(r,I),"utf8"),r),o=()=>{throw new Error("not implemented")};return{async init(){},metadata:i,registerMissingImport:o,run:o,isOptimizedDepFile:t=>t.startsWith(r),isOptimizedDepUrl:o,getOptimizedDepId:o,close:o,options:{}}}(n),i.set(n,o));return o}(n,r);if(l?.isOptimizedDepFile(o)){const t=R(o),n=(h=l.metadata,u=t,h.depInfoList.find(t=>t.file===u)),r=n?.src;if(r){return tt(e.resolve(e.dirname(r),i),a)}}var h,u}const nt=new WeakMap,rt=new WeakMap;function it(t,e,n){return t[e][n.id]=n,t.depInfoList.push(n),n}var st;!function(t){t.WorkerClassic="worker_classic",t.WorkerModule="worker_module",t.AudioWorklet="audio_worklet"}(st||(st={}));const ot=new WeakMap,at="alphatab_worker",lt="__ALPHATAB_WORKER_ASSET__";function ht(t,e){ot.get(t.mainConfig||t).assets.set(e.fileName,e)}async function ut(t,n){const r=ot.get(t.mainConfig||t);let s=r.bundle.get(n);if(!s){const i=await async function(t,n){const r=R(n),i=t.bundleChain??[],s=[...i,r];if(i.includes(r))throw new Error(`Circular worker imports detected. Vite does not support it. Import chain: ${s.join(" -> ")}`);const{rollup:a}=await import("rollup"),{plugins:l,rollupOptions:h,format:u}=t.worker,c=await l(s),d=new o("client",c);await d.init();const f=await a({...h,input:r,plugins:d.plugins.map(t=>function(t,e){const{resolveId:n,load:r,transform:i}=e,s={...e};for(const e of Object.keys(s))switch(e){case"resolveId":s[e]=K(t,n);break;case"load":s[e]=V(t,r);break;case"transform":s[e]=G(t,i);break;default:A.includes(e)&&(s[e]=Q(t,s[e]))}return s}(d,t)),preserveEntrySignatures:!1});let p;try{const n=t.worker.rollupOptions.output,r=n?Array.isArray(n)?n[0]||{}:n:{},{output:[i,...s]}=await f.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]"),...r,format:u,sourcemap:t.build.sourcemap});p=i;for(const e of s)"asset"===e.type?ht(t,e):"chunk"===e.type&&ht(t,{fileName:e.fileName,source:e.code})}finally{await f.close()}return function(t,e){const{map:n}=e;if(n&&("hidden"===t.build.sourcemap||!0===t.build.sourcemap)){const r=n.toString();ht(t,{fileName:`${e.fileName}.map`,source:r})}return e}(t,p)}(t,n);s=i.fileName,ht(t,{fileName:s,source:i.code}),r.bundle.set(n,s)}return function(t,e){const{fileNameHash:n}=e,r=function(t,e=8){const n=i("sha256").update(t).digest("hex").substring(0,e);return e<=64?n:n.padEnd(e,"_")}(t);n.get(r)||n.set(r,t);return`${lt}${r}__`}(s,r)}function ct(t,e){return"string"==typeof t?"string"==typeof e?t===e:Buffer.from(t).equals(e):Buffer.from(e).equals(t)}const dt=[["alphaTabWorker","new","alphaTabUrl","import.meta.url"],["alphaTabWorklet.addModule","new","alphaTabUrl","import.meta.url"]];function ft(t){for(const e of dt){let n=0;for(const r of e)if(n=t.indexOf(r,n),-1===n)break;if(-1!==n)return!0}return!1}function pt(t,e){if(e[1].includes(".addModule"))return st.AudioWorklet;const n=e.indices[0][1],r=t.indexOf("{",n);if(-1===r)return st.WorkerClassic;const i=t.indexOf("}",n);if(-1===i)return st.WorkerClassic;const s=t.indexOf(")",n);if(r>s||i>s)return st.WorkerClassic;let o=t.slice(r,i+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 gt=new RegExp(`(?:\\?|&)${at}&type=(\\w+)(?:&|$)`),mt=new RegExp(`${lt}([a-z\\d]{8})__`,"g");function bt(t){let n,r,i;const s=!1!==t.webWorkers,o=!1!==t.audioWorklets,a=s||o;return{name:"vite-plugin-alphatab-worker",configResolved(t){n=t,r="build"===t.command,i=t.isWorker},buildStart(){a&&!i&&ot.set(n,{assets:new Map,bundle:new Map,fileNameHash:new Map})},load(t){if(a&&r&&t.includes(at))return""},shouldTransformCachedModule({id:t}){if(a&&r&&n.build.watch&&t.includes(at))return!0},async transform(t,r){if(!a)return;const i=gt.exec(r);if(!i)return;const s=JSON.stringify(e.posix.join(n.base,"/@vite/env"));let o="";switch(i[1]){case st.WorkerClassic:o=`importScripts(${s})\n`;break;case st.WorkerModule:case st.AudioWorklet:o=`import ${s}\n`}if(o){const e=new L(t);return e.prepend(o),{code:e.toString(),map:e.generateMap({hires:"boundary"})}}},renderChunk(t,r,i){let s;if(mt.lastIndex=0,mt.test(t)){const o=function(t,n){const r=q[n&&"iife"===t?"worker-iife":t];return(t,n)=>({runtime:r(e.posix.relative(e.dirname(n),t))})}(i.format,n.isWorker);s=new L(t),mt.lastIndex=0;const a=ot.get(n.mainConfig||n),{fileNameHash:l}=a;let h=mt.exec(t);for(;h;){const[e,i]=h,a=J(l.get(i),"asset",r.fileName,"js",n,o),u="string"==typeof a?JSON.stringify(W(a)).slice(1,-1):`"+${a.runtime}+"`;s.update(h.index,h.index+e.length,u),h=mt.exec(t)}}return s&&{code:s.toString(),map:n.build.sourcemap?s.generateMap({hires:"boundary"}):null}},generateBundle(t,e){if(i)return;const r=ot.get(n);for(const t of r.assets.values()){const n=e[t.fileName];if(n){if(ct("asset"===n.type?n.source:n.code,t.source))return}this.emitFile({type:"asset",fileName:t.fileName,source:t.source})}r.assets.clear()}}}function wt(i){const s=[];return i??(i={}),s.push(function(t){let e,r,i;const s=!1!==t.webWorkers,o=!1!==t.audioWorklets,a=s||o;return{name:"vite-plugin-alphatab-url",enforce:"pre",configResolved(t){e=t,r="build"===t.command,i=t.resolve.preserveSymlinks},shouldTransformCachedModule({code:t}){if(a&&r&&e.build.watch&&ft(t))return!0},async transform(t,l,h){if(!a||h?.ssr||!ft(t))return;let u;const c=/\b(alphaTabWorker|alphaTabWorklet\.addModule)\s*\(\s*(new\s+[^ (]+alphaTabUrl\s*\(\s*('[^']+'|"[^"]+"|`[^`]+`)\s*,\s*import\.meta\.url\s*\))/dg;let d=c.exec(t);for(;d;){const a=pt(t,d);let f=!1;switch(a){case st.WorkerClassic:case st.WorkerModule:f=s;break;case st.AudioWorklet:f=o}if(!f){d=c.exec(t);continue}u??(u=new L(t));const p=t.slice(d.indices[3][0]+1,d.indices[3][1]-1);let g,m=n.resolve(n.dirname(l),p);m=tt(m,i)??et(e,!0===h?.ssr,p,l,i)??m,r?g=await ut(e,m):(g=await T(R(m),e),g=N(g,`${at}&type=${a}`)),u.update(d.indices[3][0],d.indices[3][1],`new URL('' + ${JSON.stringify(g)}, import.meta.url)`),d=c.exec(t)}return u?{code:u.toString(),map:"build"===e.command&&e.build.sourcemap?u.generateMap({hires:"boundary",source:l}):null}:null}}}(i)),s.push(bt(i)),s.push(function(n){let i,s=!1;return{name:"vite-plugin-alphatab-copy",enforce:"pre",configResolved(t){i=t},buildEnd(){s=!1},async buildStart(){if(s)return;s=!0;let o,a=n.alphaTabSourceDir;if(!a)try{const t="string"==typeof import.meta.url;a=t?r.fileURLToPath(import.meta.resolve("@coderline/alphatab")):require.resolve("@coderline/alphatab"),a=e.resolve(a,"..")}catch{a=e.join(i.root,"node_modules/@coderline/alphatab/dist/")}if(a)try{await t.promises.access(e.join(a,"alphaTab.mjs"),t.constants.F_OK),o=!0}catch{o=!1}else o=!1;if(!o)return void i.logger.error("Could not find alphaTab, please ensure it is installed into node_modules or configure alphaTabSourceDir");const l=n.assetOutputDir??i.publicDir;async function h(n){const r=e.join(a,n),i=await t.promises.readdir(r,{withFileTypes:!0});await t.promises.mkdir(e.join(l,n),{recursive:!0}),await Promise.all(i.filter(t=>t.isFile()).map(async r=>{const i=e.join(r.parentPath??r.path,r.name);await t.promises.copyFile(i,e.join(l,n,r.name))}))}l&&await Promise.all([h("font"),h("soundfont")])}}}(i)),s}export{wt as alphaTab};
|
|
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};
|
package/dist/alphaTab.vite.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* alphaTab Vite Plugin v1.7.0-alpha.
|
|
2
|
+
* alphaTab Vite Plugin v1.7.0-alpha.1577 (develop, build 1577)
|
|
3
3
|
*
|
|
4
4
|
* Copyright © 2025, Daniel Kuschny and Contributors, All rights reserved.
|
|
5
5
|
*
|
|
@@ -1782,7 +1782,7 @@ function wrapEnvironmentHook(environment, hook) {
|
|
|
1782
1782
|
return handler;
|
|
1783
1783
|
}
|
|
1784
1784
|
function injectEnvironmentInContext(context, environment) {
|
|
1785
|
-
context.environment
|
|
1785
|
+
context.environment ??= environment;
|
|
1786
1786
|
return context;
|
|
1787
1787
|
}
|
|
1788
1788
|
function injectSsrFlag(options, environment) {
|
|
@@ -2146,9 +2146,7 @@ function importMetaUrlPlugin(options) {
|
|
|
2146
2146
|
return;
|
|
2147
2147
|
}
|
|
2148
2148
|
let s;
|
|
2149
|
-
const alphaTabWorkerPattern =
|
|
2150
|
-
// @ts-expect-error For the Vite plugin we expect newer node than for alphaTab itself (-> migrate to monorepo)
|
|
2151
|
-
/\b(alphaTabWorker|alphaTabWorklet\.addModule)\s*\(\s*(new\s+[^ (]+alphaTabUrl\s*\(\s*('[^']+'|"[^"]+"|`[^`]+`)\s*,\s*import\.meta\.url\s*\))/dg;
|
|
2149
|
+
const alphaTabWorkerPattern = /\b(alphaTabWorker|alphaTabWorklet\.addModule)\s*\(\s*(new\s+[^ (]+alphaTabUrl\s*\(\s*('[^']+'|"[^"]+"|`[^`]+`)\s*,\s*import\.meta\.url\s*\))/dg;
|
|
2152
2150
|
let match = alphaTabWorkerPattern.exec(code);
|
|
2153
2151
|
while (match) {
|
|
2154
2152
|
const workerType = getWorkerType(code, match);
|
|
@@ -2166,7 +2164,7 @@ function importMetaUrlPlugin(options) {
|
|
|
2166
2164
|
match = alphaTabWorkerPattern.exec(code);
|
|
2167
2165
|
continue;
|
|
2168
2166
|
}
|
|
2169
|
-
s
|
|
2167
|
+
s ??= new MagicString(code);
|
|
2170
2168
|
const url = code.slice(match.indices[3][0] + 1, match.indices[3][1] - 1);
|
|
2171
2169
|
let file = path__default.resolve(path__default.dirname(id), url);
|
|
2172
2170
|
file =
|
|
@@ -2353,7 +2351,7 @@ function workerPlugin(options) {
|
|
|
2353
2351
|
|
|
2354
2352
|
function alphaTab(options) {
|
|
2355
2353
|
const plugins = [];
|
|
2356
|
-
options
|
|
2354
|
+
options ??= {};
|
|
2357
2355
|
plugins.push(importMetaUrlPlugin(options));
|
|
2358
2356
|
plugins.push(workerPlugin(options));
|
|
2359
2357
|
plugins.push(copyAssetsPlugin(options));
|