@coderline/alphatab-webpack 1.7.0-alpha.1577 → 1.7.0-alpha.1584

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.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * alphaTab WebPack Plugin v1.7.0-alpha.1577 (develop, build 1577)
2
+ * alphaTab WebPack Plugin v1.7.0-alpha.1584 (develop, build 1584)
3
3
  *
4
4
  * Copyright © 2025, Daniel Kuschny and Contributors, All rights reserved.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * alphaTab WebPack Plugin v1.7.0-alpha.1577 (develop, build 1577)
2
+ * alphaTab WebPack Plugin v1.7.0-alpha.1584 (develop, build 1584)
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*as n from"node:url";function o(t,e,n){t.webpack.util.serialization.register(e,n,null,{serialize(t,e){t.serialize(e)},deserialize(t){if("function"==typeof e.deserialize)return e.deserialize(t);const n=new e;return n.deserialize(t),n}})}function r(t,e,n){t.hooks.parser.for("javascript/auto").tap(e,n),t.hooks.parser.for("javascript/esm").tap(e,n)}function a(t,e){if("NewExpression"!==e.type||2!==e.arguments.length)return;const n=e,[o,r]=n.arguments,a=t.evaluateExpression(n.callee);if(!a.isIdentifier()||!a.identifier.includes("alphaTabUrl"))return;return[t.evaluateExpression(o),[o.range[0],r.range[1]]]}const i="atworker_";function s(t,e,n,o){const r=o.get(t.state)||0;o.set(t.state,r+1);const a=`${n(t.state.module.identifier())}|${r}`,s=e.compiler.webpack.util.createHash(e.outputOptions.hashFunction);s.update(a);const c=s.digest(e.outputOptions.hashDigest).slice(0,e.outputOptions.hashDigestLength);return i+c}function c(t){return"string"==typeof t&&t.startsWith(i)}const u=Symbol("alphatab worklet specifier tag"),l=new WeakMap;function p(t,e,n,o,i,c,p){if(!1===n.audioWorklets)return;t.alphaTab.registerWorkletDependency(i,c);r(c,e,n=>{const r="alphaTabWorklet";n.hooks.preDeclarator.tap(e,t=>{if("Identifier"===t.id.type&&t.id.name===r)return n.tagVariable(t.id.name,u),!0}),n.hooks.pattern.for(r).tap(e,t=>(n.tagVariable(t.name,u),!0)),n.hooks.callMemberChain.for(u).tap(e,(e,r)=>{if("addModule"===r.join("."))return((e,n)=>{const[r]=n.arguments,c=a(e,r);if(!c)return;const[u]=c;if(!u.isString())return;const h=s(e,i,p,l),d=new t.webpack.AsyncDependenciesBlock({entryOptions:{chunkLoading:!1,wasmLoading:!1,runtime:h,library:{type:"at-worklet"}}});d.loc=n.loc;const f=t.alphaTab.createWorkletDependency(u.string,[n.range[0],n.range[1]],o.options.output.workerPublicPath);return f.loc=n.loc,d.addDependency(f),e.state.module.addBlock(d),!0})(n,e)})})}const h=new WeakMap;function d(t,e,n,o,i,c,u){if(!1===n.audioWorklets)return;t.alphaTab.registerWebWorkerDependency(i,c),new t.webpack.javascript.EnableChunkLoadingPlugin("import-scripts").apply(o);r(c,e,n=>{n.hooks.new.for("alphaTab.Environment.alphaTabWorker").tap(e,e=>((e,n)=>{const[r,c]=n.arguments,l=a(e,r);if(!l)return;const[p,d]=l;if(!p.isString())return;const f=s(e,i,u,h),w=new t.webpack.AsyncDependenciesBlock({entryOptions:{chunkLoading:"import-scripts",wasmLoading:!1,runtime:f,library:{type:"at-worker"}}});w.loc=n.loc;const k=t.alphaTab.createWebWorkerDependency(p.string,d,o.options.output.workerPublicPath);k.loc=n.loc,w.addDependency(k),e.state.module.addBlock(w);const m=new t.webpack.dependencies.ConstDependency(`{ type: ${i.options.output.module?'"module"':"undefined"} }`,c.range);return m.loc=n.loc,e.state.module.addPresentationalDependency(m),e.walkExpression(n.callee),e.walkExpression(r.callee),!0})(n,e))})}const f=/^[a-zA-Z]:[\\/]/,w=/\\/g,k=t=>""===t?"./.":".."===t?"../.":t.startsWith("../")?t:`./${t}`,m=(t=>{const e=new WeakMap,n=(n,o,r)=>{if(!r)return t(n,o);let a,i=e.get(r);void 0===i&&(i=new Map,e.set(r,i));let s=i.get(n);if(void 0===s?(s=new Map,i.set(n,s)):a=s.get(o),void 0!==a)return a;const c=t(n,o);return s.set(o,c),c};return n.bindContextCache=(n,o)=>{let r;if(o){let t=e.get(o);void 0===t&&(t=new Map,e.set(o,t)),r=t.get(n),void 0===r&&(r=new Map,t.set(n,r))}else r=new Map;return e=>{const o=r.get(e);if(void 0!==o)return o;const a=t(n,e);return r.set(e,a),a}},n})((t,n)=>n.split("!").map(n=>((t,n)=>{if("/"===n[0]){if(n.length>1&&"/"===n[n.length-1])return n;const o=n.indexOf("?");let r=-1===o?n:n.slice(0,o);return r=k(e.posix.relative(t,r)),-1===o?r:r+n.slice(o)}if(f.test(n)){const o=n.indexOf("?");let r=-1===o?n:n.slice(0,o);return r=e.win32.relative(t,r),f.test(r)||(r=k(r.replace(w,"/"))),-1===o?r:r+n.slice(o)}return n})(t,n)).join("!"));class b{t;options;constructor(t){this.options=t??{}}apply(t){const e={webpack:t.webpack,alphaTab:{}};"alphaTab"in t.webpack.util.serialization.register?e.alphaTab=t.webpack.util.serialization.register.alphaTab:(t.webpack.util.serialization.register.alphaTab=e.alphaTab,function(t){class e extends t.webpack.dependencies.ModuleDependency{publicPath;o;constructor(t,e,n){super(t),this.range=e,this.publicPath=n}getReferencedExports(){return t.webpack.Dependency.NO_EXPORTS_REFERENCED}get type(){return"alphaTabWorker"}get category(){return"worker"}updateHash(t){void 0===this.o&&(this.o=JSON.stringify(this.publicPath)),t.update(this.o)}serialize(t){const{write:e}=t;e(this.publicPath),super.serialize(t)}deserialize(t){const{read:e}=t;this.publicPath=e(),super.deserialize(t)}}e.Template=class extends t.webpack.dependencies.ModuleDependency.Template{apply(e,n,o){const{chunkGraph:r,moduleGraph:a,runtimeRequirements:i}=o,s=e,c=a.getParentBlock(e),u=r.getBlockChunkGroup(c).getEntrypointChunk(),l=s.publicPath?`"${s.publicPath}"`:t.webpack.RuntimeGlobals.publicPath;i.add(t.webpack.RuntimeGlobals.publicPath),i.add(t.webpack.RuntimeGlobals.baseURI),i.add(t.webpack.RuntimeGlobals.getChunkScriptFilename),n.replace(s.range[0],s.range[1]-1,`/* worker import */ ${l} + ${t.webpack.RuntimeGlobals.getChunkScriptFilename}(${JSON.stringify(u.id)}), ${t.webpack.RuntimeGlobals.baseURI}`)}},o(t,e,"AlphaTabWebWorkerDependency"),t.alphaTab.createWebWorkerDependency=(t,n,o)=>new e(t,n,o),t.alphaTab.registerWebWorkerDependency=(t,n)=>{t.dependencyFactories.set(e,n),t.dependencyTemplates.set(e,new e.Template)}}(e),function(t){class e extends t.webpack.RuntimeModule{static Key="AlphaTabWorkerRuntime";constructor(){super("alphaTab audio worker chunk loading",t.webpack.RuntimeModule.STAGE_BASIC)}generate(){const e=this.compilation,n=e.runtimeTemplate,o=n.globalObject,r=`${o}[${JSON.stringify(e.outputOptions.chunkLoadingGlobal)}]`,a=new Set(this.chunk.ids);for(const e of this.chunk.getAllInitialChunks())if(!t.webpack.javascript.JavascriptModulesPlugin.chunkHasJs(e,this.chunkGraph))for(const t of e.ids)a.add(t);return t.webpack.Template.asString([`if ( ! ('AudioWorkletGlobalScope' in ${o}) ) { return; }`,"const installedChunks = {",t.webpack.Template.indent(Array.from(a,t=>`${JSON.stringify(t)}: 1`).join(",\n")),"};","// importScripts chunk loading",`const installChunk = ${n.basicFunction("data",[n.destructureArray(["chunkIds","moreModules","runtime"],"data"),"for(const moduleId in moreModules) {",t.webpack.Template.indent([`if(${t.webpack.RuntimeGlobals.hasOwnProperty}(moreModules, moduleId)) {`,t.webpack.Template.indent(`${t.webpack.RuntimeGlobals.moduleFactories}[moduleId] = moreModules[moduleId];`),"}"]),"}",`if(runtime) runtime(${t.webpack.RuntimeGlobals.require});`,"while(chunkIds.length)",t.webpack.Template.indent("installedChunks[chunkIds.pop()] = 1;"),"parentChunkLoadingFunction(data);"])};`,`const chunkLoadingGlobal = ${r} = ${r} || [];`,"const parentChunkLoadingFunction = chunkLoadingGlobal.push.bind(chunkLoadingGlobal);","chunkLoadingGlobal.forEach(installChunk);","chunkLoadingGlobal.push = installChunk;"])}}t.alphaTab.registerWebWorkerRuntimeModule=(n,o)=>{o.hooks.runtimeRequirementInTree.for(e.Key).tap(n,t=>{o.addRuntimeModule(t,new e)}),o.hooks.additionalChunkRuntimeRequirements.tap(n,(e,n)=>{c(e.runtime)&&(n.add(t.webpack.RuntimeGlobals.moduleFactories),n.add(t.alphaTab.WebWorkerRuntimeModuleKey))})},t.alphaTab.WebWorkerRuntimeModuleKey=e.Key}(e),function(t){class e extends t.webpack.dependencies.ModuleDependency{publicPath;o;constructor(t,e,n){super(t),this.range=e,this.publicPath=n}get type(){return"alphaTabWorklet"}get category(){return"worker"}updateHash(t){void 0===this.o&&(this.o=JSON.stringify(this.publicPath)),t.update(this.o)}serialize(t){const{write:e}=t;e(this.publicPath),super.serialize(t)}deserialize(t){const{read:e}=t;this.publicPath=e(),super.deserialize(t)}}e.Template=class extends t.webpack.dependencies.ModuleDependency.Template{apply(e,n,o){const{chunkGraph:r,moduleGraph:a,runtimeRequirements:i}=o,s=e,c=a.getParentBlock(e),u=r.getBlockChunkGroup(c),l=s.publicPath?JSON.stringify(s.publicPath):t.webpack.RuntimeGlobals.publicPath,p=u.getEntrypointChunk(),h=`\n globalThis.self = globalThis.self || globalThis;\n globalThis.location = \${JSON.stringify(${t.webpack.RuntimeGlobals.baseURI})};\n globalThis.importScripts = (url) => { throw new Error("importScripts not available, dynamic loading of chunks not supported in this context", url) };\n `;r.addChunkRuntimeRequirements(p,new Set([t.webpack.RuntimeGlobals.moduleFactories,t.alphaTab.WebWorkerRuntimeModuleKey])),i.add(t.alphaTab.RuntimeGlobalWorkletGetStartupChunks),n.replace(s.range[0],s.range[1]-1,t.webpack.Template.asString(["(/* worklet bootstrap */ async function(__webpack_worklet__) {",t.webpack.Template.indent([`await __webpack_worklet__.addModule(URL.createObjectURL(new Blob([\`${h}\`], { type: "application/javascript; charset=utf-8" })));`,`for (const fileName of ${t.alphaTab.RuntimeGlobalWorkletGetStartupChunks}(${JSON.stringify(p.id)})) {`,t.webpack.Template.indent([`await __webpack_worklet__.addModule(new URL(${l} + fileName, ${t.webpack.RuntimeGlobals.baseURI}));`]),"}"]),"})(alphaTabWorklet)"]))}},o(t,e,"AlphaTabWorkletDependency"),t.alphaTab.registerWorkletDependency=(t,n)=>{t.dependencyFactories.set(e,n),t.dependencyTemplates.set(e,new e.Template)},t.alphaTab.createWorkletDependency=(t,n,o)=>new e(t,n,o)}(e),function(t){class e extends t.webpack.RuntimeModule{static RuntimeGlobalWorkletGetStartupChunks="__webpack_require__.wsc";constructor(){super("alphaTab audio worklet chunk lookup",t.webpack.RuntimeModule.STAGE_BASIC)}generate(){const n=this.compilation,o=new Map,r=n.chunks;for(const e of r)if(c(e.runtime)){const r=Array.from(e.getAllReferencedChunks()).map(e=>(n.hooks.contentHash.call(e),n.getPath(t.webpack.javascript.JavascriptModulesPlugin.getChunkFilenameTemplate(e,n.outputOptions),{chunk:e,contentHashType:"javascript"})));o.set(String(e.id),r)}return t.webpack.Template.asString([`${e.RuntimeGlobalWorkletGetStartupChunks} = (() => {`,t.webpack.Template.indent(["const lookup = new Map(",t.webpack.Template.indent(JSON.stringify(Array.from(o.entries()))),");","return (chunkId) => lookup.get(String(chunkId)) ?? [];"]),"})();"])}}t.alphaTab.RuntimeGlobalWorkletGetStartupChunks=e.RuntimeGlobalWorkletGetStartupChunks,t.alphaTab.registerWorkletRuntimeModule=(t,n)=>{n.hooks.runtimeRequirementInTree.for(e.RuntimeGlobalWorkletGetStartupChunks).tap(t,t=>{n.addRuntimeModule(t,new e)})}}(e)),this.t=e,this.configureSoundFont(t),this.configure(t)}configureSoundFont(t){!1!==this.options.assetOutputDir&&(t.options.module.rules.push({test:/\.sf2/,type:"asset/resource"}),t.options.module.rules.push({test:/\.sf3/,type:"asset/resource"}))}configure(t){const e=this.constructor.name,n=m.bindContextCache(t.context,t.root);t.hooks.thisCompilation.tap(e,(o,{normalModuleFactory:r})=>{this.t.alphaTab.registerWebWorkerRuntimeModule(e,o),this.t.alphaTab.registerWorkletRuntimeModule(e,o),p(this.t,e,this.options,t,o,r,n),d(this.t,e,this.options,t,o,r,n),this.configureAssetCopy(this.t,e,t,o)})}configureAssetCopy(o,r,a,i){if(!1===this.options.assetOutputDir)return;const s=this.options;i.hooks.processAssets.tapAsync({name:r,stage:this.t.webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONAL},async(r,c)=>{let u,l=s.alphaTabSourceDir;if(!l)try{const t="string"==typeof import.meta.url;l=t?n.fileURLToPath(import.meta.resolve("@coderline/alphatab")):require.resolve("@coderline/alphatab"),l=e.resolve(l,"..")}catch{l=i.getPath("node_modules/@coderline/alphatab/dist/")}if(l)try{await t.promises.access(e.join(l,"alphaTab.mjs"),t.constants.F_OK),u=!0}catch{u=!1}else u=!1;if(!u)return void i.errors.push(new this.t.webpack.WebpackError("Could not find alphaTab, please ensure it is installed into node_modules or configure alphaTabSourceDir"));const p=s.assetOutputDir??a.options.output.path;async function h(n){const r=e.join(l,n);i.contextDependencies.add(e.normalize(r));const a=await t.promises.readdir(r,{withFileTypes:!0});await t.promises.mkdir(e.join(p,n),{recursive:!0}),await Promise.all(a.filter(t=>t.isFile()).map(async r=>{const a=e.join(r.parentPath??r.path,r.name);await t.promises.copyFile(a,e.join(p,n,r.name));const s=`${n}/${r.name}`,c=i.getAsset(s),u=await t.promises.readFile(a),l=new o.webpack.sources.RawSource(u);c?i.updateAsset(s,l,{copied:!0,sourceFilename:a}):i.emitAsset(s,l,{copied:!0,sourceFilename:a})}))}p?(await Promise.all([h("font"),h("soundfont")]),c()):i.errors.push(new this.t.webpack.WebpackError("Need output.path configured in application to store asset files."))})}}export{b as AlphaTabWebPackPlugin};
36
+ import*as t from"node:fs";import*as e from"node:path";import*as n from"node:url";function o(t,e,n){t.webpack.util.serialization.register(e,n,null,{serialize(t,e){t.serialize(e)},deserialize(t){if("function"==typeof e.deserialize)return e.deserialize(t);const n=new e;return n.deserialize(t),n}})}function r(t,e,n){t.hooks.parser.for("javascript/auto").tap(e,n),t.hooks.parser.for("javascript/esm").tap(e,n)}function a(t,e){if("NewExpression"!==e.type||2!==e.arguments.length)return;const n=e,[o,r]=n.arguments,a=t.evaluateExpression(n.callee);if(!a.isIdentifier()||!a.identifier.includes("alphaTabUrl"))return;return[t.evaluateExpression(o),[o.range[0],r.range[1]]]}const i="atworker_";function s(t,e,n,o){const r=o.get(t.state)||0;o.set(t.state,r+1);const a=`${n(t.state.module.identifier())}|${r}`,s=e.compiler.webpack.util.createHash(e.outputOptions.hashFunction);s.update(a);const c=s.digest(e.outputOptions.hashDigest).slice(0,e.outputOptions.hashDigestLength);return i+c}function c(t){return"string"==typeof t&&t.startsWith(i)}const u=Symbol("alphatab worklet specifier tag"),l=new WeakMap;function p(t,e,n,o,i,c,p){if(!1===n.audioWorklets)return;t.alphaTab.registerWorkletDependency(i,c);r(c,e,n=>{const r="alphaTabWorklet";n.hooks.preDeclarator.tap(e,t=>{if("Identifier"===t.id.type&&t.id.name===r)return n.tagVariable(t.id.name,u),!0}),n.hooks.pattern.for(r).tap(e,t=>(n.tagVariable(t.name,u),!0)),n.hooks.callMemberChain.for(u).tap(e,(e,r)=>{if("addModule"===r.join("."))return((e,n)=>{const[r]=n.arguments,c=a(e,r);if(!c)return;const[u]=c;if(!u.isString())return;const h=s(e,i,p,l),d=new t.webpack.AsyncDependenciesBlock({entryOptions:{chunkLoading:!1,wasmLoading:!1,runtime:h,library:{type:"at-worklet"}}});d.loc=n.loc;const f=t.alphaTab.createWorkletDependency(u.string,[n.range[0],n.range[1]],o.options.output.workerPublicPath);return f.loc=n.loc,d.addDependency(f),e.state.module.addBlock(d),!0})(n,e)})})}const h=new WeakMap;function d(t,e,n,o,i,c,u){if(!1===n.audioWorklets)return;t.alphaTab.registerWebWorkerDependency(i,c),new t.webpack.javascript.EnableChunkLoadingPlugin("import-scripts").apply(o);r(c,e,n=>{n.hooks.new.for("alphaTab.Environment.alphaTabWorker").tap(e,e=>((e,n)=>{const[r,c]=n.arguments,l=a(e,r);if(!l)return;const[p,d]=l;if(!p.isString())return;const f=s(e,i,u,h),w=new t.webpack.AsyncDependenciesBlock({entryOptions:{chunkLoading:"import-scripts",wasmLoading:!1,runtime:f,library:{type:"at-worker"}}});w.loc=n.loc;const k=t.alphaTab.createWebWorkerDependency(p.string,d,o.options.output.workerPublicPath);k.loc=n.loc,w.addDependency(k),e.state.module.addBlock(w);const m=new t.webpack.dependencies.ConstDependency(`{ type: ${i.options.output.module?'"module"':"undefined"} }`,c.range);return m.loc=n.loc,e.state.module.addPresentationalDependency(m),e.walkExpression(n.callee),e.walkExpression(r.callee),!0})(n,e))})}const f=/^[a-zA-Z]:[\\/]/,w=/\\/g,k=t=>""===t?"./.":".."===t?"../.":t.startsWith("../")?t:`./${t}`,m=(t=>{const e=new WeakMap,n=(n,o,r)=>{if(!r)return t(n,o);let a,i=e.get(r);void 0===i&&(i=new Map,e.set(r,i));let s=i.get(n);if(void 0===s?(s=new Map,i.set(n,s)):a=s.get(o),void 0!==a)return a;const c=t(n,o);return s.set(o,c),c};return n.bindContextCache=(n,o)=>{let r;if(o){let t=e.get(o);void 0===t&&(t=new Map,e.set(o,t)),r=t.get(n),void 0===r&&(r=new Map,t.set(n,r))}else r=new Map;return e=>{const o=r.get(e);if(void 0!==o)return o;const a=t(n,e);return r.set(e,a),a}},n})((t,n)=>n.split("!").map(n=>((t,n)=>{if("/"===n[0]){if(n.length>1&&"/"===n[n.length-1])return n;const o=n.indexOf("?");let r=-1===o?n:n.slice(0,o);return r=k(e.posix.relative(t,r)),-1===o?r:r+n.slice(o)}if(f.test(n)){const o=n.indexOf("?");let r=-1===o?n:n.slice(0,o);return r=e.win32.relative(t,r),f.test(r)||(r=k(r.replace(w,"/"))),-1===o?r:r+n.slice(o)}return n})(t,n)).join("!"));class b{t;options;constructor(t){this.options=t??{}}apply(t){const e={webpack:t.webpack,alphaTab:{}};"alphaTab"in t.webpack.util.serialization.register?e.alphaTab=t.webpack.util.serialization.register.alphaTab:(t.webpack.util.serialization.register.alphaTab=e.alphaTab,function(t){class e extends t.webpack.dependencies.ModuleDependency{publicPath;o;constructor(t,e,n){super(t),this.range=e,this.publicPath=n}getReferencedExports(){return t.webpack.Dependency.NO_EXPORTS_REFERENCED}get type(){return"alphaTabWorker"}get category(){return"worker"}updateHash(t){void 0===this.o&&(this.o=JSON.stringify(this.publicPath)),t.update(this.o)}serialize(t){const{write:e}=t;e(this.publicPath),super.serialize(t)}deserialize(t){const{read:e}=t;this.publicPath=e(),super.deserialize(t)}}e.Template=class extends t.webpack.dependencies.ModuleDependency.Template{apply(e,n,o){const{chunkGraph:r,moduleGraph:a,runtimeRequirements:i}=o,s=e,c=a.getParentBlock(e),u=r.getBlockChunkGroup(c).getEntrypointChunk(),l=s.publicPath?`"${s.publicPath}"`:t.webpack.RuntimeGlobals.publicPath;i.add(t.webpack.RuntimeGlobals.publicPath),i.add(t.webpack.RuntimeGlobals.baseURI),i.add(t.webpack.RuntimeGlobals.getChunkScriptFilename),n.replace(s.range[0],s.range[1]-1,`/* worker import */ ${l} + ${t.webpack.RuntimeGlobals.getChunkScriptFilename}(${JSON.stringify(u.id)}), ${t.webpack.RuntimeGlobals.baseURI}`)}},o(t,e,"AlphaTabWebWorkerDependency"),t.alphaTab.createWebWorkerDependency=(t,n,o)=>new e(t,n,o),t.alphaTab.registerWebWorkerDependency=(t,n)=>{t.dependencyFactories.set(e,n),t.dependencyTemplates.set(e,new e.Template)}}(e),function(t){class e extends t.webpack.RuntimeModule{static Key="AlphaTabWorkerRuntime";constructor(){super("alphaTab audio worker chunk loading",t.webpack.RuntimeModule.STAGE_BASIC)}generate(){const e=this.compilation,n=e.runtimeTemplate,o=n.globalObject,r=`${o}[${JSON.stringify(e.outputOptions.chunkLoadingGlobal)}]`,a=new Set(this.chunk.ids);for(const e of this.chunk.getAllInitialChunks())if(!t.webpack.javascript.JavascriptModulesPlugin.chunkHasJs(e,this.chunkGraph))for(const t of e.ids)a.add(t);return t.webpack.Template.asString([`if ( ! ('AudioWorkletGlobalScope' in ${o}) ) { return; }`,"const installedChunks = {",t.webpack.Template.indent(Array.from(a,t=>`${JSON.stringify(t)}: 1`).join(",\n")),"};","// importScripts chunk loading",`const installChunk = ${n.basicFunction("data",[n.destructureArray(["chunkIds","moreModules","runtime"],"data"),"for(const moduleId in moreModules) {",t.webpack.Template.indent([`if(${t.webpack.RuntimeGlobals.hasOwnProperty}(moreModules, moduleId)) {`,t.webpack.Template.indent(`${t.webpack.RuntimeGlobals.moduleFactories}[moduleId] = moreModules[moduleId];`),"}"]),"}",`if(runtime) runtime(${t.webpack.RuntimeGlobals.require});`,"while(chunkIds.length)",t.webpack.Template.indent("installedChunks[chunkIds.pop()] = 1;"),"parentChunkLoadingFunction(data);"])};`,`const chunkLoadingGlobal = ${r} = ${r} || [];`,"const parentChunkLoadingFunction = chunkLoadingGlobal.push.bind(chunkLoadingGlobal);","chunkLoadingGlobal.forEach(installChunk);","chunkLoadingGlobal.push = installChunk;"])}}t.alphaTab.registerWebWorkerRuntimeModule=(n,o)=>{o.hooks.runtimeRequirementInTree.for(e.Key).tap(n,t=>{o.addRuntimeModule(t,new e)}),o.hooks.additionalChunkRuntimeRequirements.tap(n,(e,n)=>{c(e.runtime)&&(n.add(t.webpack.RuntimeGlobals.moduleFactories),n.add(t.alphaTab.WebWorkerRuntimeModuleKey))})},t.alphaTab.WebWorkerRuntimeModuleKey=e.Key}(e),function(t){class e extends t.webpack.dependencies.ModuleDependency{publicPath;o;constructor(t,e,n){super(t),this.range=e,this.publicPath=n}get type(){return"alphaTabWorklet"}get category(){return"worker"}updateHash(t){void 0===this.o&&(this.o=JSON.stringify(this.publicPath)),t.update(this.o)}serialize(t){const{write:e}=t;e(this.publicPath),super.serialize(t)}deserialize(t){const{read:e}=t;this.publicPath=e(),super.deserialize(t)}}e.Template=class extends t.webpack.dependencies.ModuleDependency.Template{apply(e,n,o){const{chunkGraph:r,moduleGraph:a,runtimeRequirements:i}=o,s=e,c=a.getParentBlock(e),u=r.getBlockChunkGroup(c),l=s.publicPath?JSON.stringify(s.publicPath):t.webpack.RuntimeGlobals.publicPath,p=u.getEntrypointChunk(),h=`\n globalThis.self = globalThis.self || globalThis;\n globalThis.location = \${JSON.stringify(${t.webpack.RuntimeGlobals.baseURI})};\n globalThis.importScripts = (url) => { throw new Error("importScripts not available, dynamic loading of chunks not supported in this context", url) };\n `;r.addChunkRuntimeRequirements(p,new Set([t.webpack.RuntimeGlobals.moduleFactories,t.alphaTab.WebWorkerRuntimeModuleKey])),i.add(t.alphaTab.RuntimeGlobalWorkletGetStartupChunks),n.replace(s.range[0],s.range[1]-1,t.webpack.Template.asString(["(/* worklet bootstrap */ async function(__webpack_worklet__) {",t.webpack.Template.indent([`await __webpack_worklet__.addModule(URL.createObjectURL(new Blob([\`${h}\`], { type: "application/javascript; charset=utf-8" })));`,`for (const fileName of ${t.alphaTab.RuntimeGlobalWorkletGetStartupChunks}(${JSON.stringify(p.id)})) {`,t.webpack.Template.indent([`await __webpack_worklet__.addModule(new URL(${l} + fileName, ${t.webpack.RuntimeGlobals.baseURI}));`]),"}"]),"})(alphaTabWorklet)"]))}},o(t,e,"AlphaTabWorkletDependency"),t.alphaTab.registerWorkletDependency=(t,n)=>{t.dependencyFactories.set(e,n),t.dependencyTemplates.set(e,new e.Template)},t.alphaTab.createWorkletDependency=(t,n,o)=>new e(t,n,o)}(e),function(t){class e extends t.webpack.RuntimeModule{static RuntimeGlobalWorkletGetStartupChunks="__webpack_require__.wsc";constructor(){super("alphaTab audio worklet chunk lookup",t.webpack.RuntimeModule.STAGE_BASIC)}generate(){const n=this.compilation,o=new Map,r=n.chunks;for(const e of r)if(c(e.runtime)){const r=Array.from(e.getAllReferencedChunks()).map(e=>(n.hooks.contentHash.call(e),n.getPath(t.webpack.javascript.JavascriptModulesPlugin.getChunkFilenameTemplate(e,n.outputOptions),{chunk:e,contentHashType:"javascript"})));o.set(String(e.id),r)}return t.webpack.Template.asString([`${e.RuntimeGlobalWorkletGetStartupChunks} = (() => {`,t.webpack.Template.indent(["const lookup = new Map(",t.webpack.Template.indent(JSON.stringify(Array.from(o.entries()))),");","return (chunkId) => lookup.get(String(chunkId)) ?? [];"]),"})();"])}}t.alphaTab.RuntimeGlobalWorkletGetStartupChunks=e.RuntimeGlobalWorkletGetStartupChunks,t.alphaTab.registerWorkletRuntimeModule=(t,n)=>{n.hooks.runtimeRequirementInTree.for(e.RuntimeGlobalWorkletGetStartupChunks).tap(t,t=>{n.addRuntimeModule(t,new e)})}}(e)),this.t=e,this.configureSoundFont(t),this.configure(t)}configureSoundFont(t){!1!==this.options.assetOutputDir&&(t.options.module.rules.push({test:/\.sf2/,type:"asset/resource"}),t.options.module.rules.push({test:/\.sf3/,type:"asset/resource"}))}configure(t){const e=this.constructor.name,n=m.bindContextCache(t.context,t.root);t.hooks.thisCompilation.tap(e,(o,{normalModuleFactory:r})=>{this.t.alphaTab.registerWebWorkerRuntimeModule(e,o),this.t.alphaTab.registerWorkletRuntimeModule(e,o),p(this.t,e,this.options,t,o,r,n),d(this.t,e,this.options,t,o,r,n),this.configureAssetCopy(this.t,e,t,o)})}configureAssetCopy(o,r,a,i){if(!1===this.options.assetOutputDir)return;const s=this.options;i.hooks.processAssets.tapAsync({name:r,stage:this.t.webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONAL},async(r,c)=>{let u,l=s.alphaTabSourceDir;if(!l)try{const t="string"==typeof import.meta.url;l=t?n.fileURLToPath(import.meta.resolve("@coderline/alphatab")):require.resolve("@coderline/alphatab"),l=e.resolve(l,"..")}catch{l=i.getPath("node_modules/@coderline/alphatab/dist/")}if(l)try{await t.promises.access(e.join(l,"alphaTab.mjs"),t.constants.F_OK),u=!0}catch{u=!1}else u=!1;if(!u)return void i.errors.push(new this.t.webpack.WebpackError("Could not find alphaTab, please ensure it is installed into node_modules or configure alphaTabSourceDir"));const p=s.assetOutputDir??a.options.output.path;async function h(n){const r=e.join(l,n);i.contextDependencies.add(e.normalize(r));const a=await t.promises.readdir(r,{withFileTypes:!0});await t.promises.mkdir(e.join(p,n),{recursive:!0}),await Promise.all(a.filter(t=>t.isFile()).map(async r=>{const a=e.join(r.parentPath??r.path,r.name);await t.promises.copyFile(a,e.join(p,n,r.name));const s=`${n}/${r.name}`,c=i.getAsset(s),u=await t.promises.readFile(a),l=new o.webpack.sources.RawSource(u);c?i.updateAsset(s,l,{copied:!0,sourceFilename:a}):i.emitAsset(s,l,{copied:!0,sourceFilename:a})}))}p?(await Promise.all([h("font"),h("soundfont")]),c()):i.errors.push(new this.t.webpack.WebpackError("Need output.path configured in application to store asset files."))})}}export{b as AlphaTabWebPackPlugin};
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * alphaTab WebPack Plugin v1.7.0-alpha.1577 (develop, build 1577)
2
+ * alphaTab WebPack Plugin v1.7.0-alpha.1584 (develop, build 1584)
3
3
  *
4
4
  * Copyright © 2025, Daniel Kuschny and Contributors, All rights reserved.
5
5
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coderline/alphatab-webpack",
3
- "version": "1.7.0-alpha.1577",
3
+ "version": "1.7.0-alpha.1584",
4
4
  "description": "A plugin for WebPack to bundle alphaTab into your webapps.",
5
5
  "keywords": [
6
6
  "guitar",
@@ -36,11 +36,11 @@
36
36
  "webpack": "^5.101.3"
37
37
  },
38
38
  "devDependencies": {
39
- "@biomejs/biome": "^2.2.5",
39
+ "@biomejs/biome": "^2.2.6",
40
40
  "@microsoft/api-extractor": "^7.53.1",
41
41
  "@types/chai": "^5.2.2",
42
42
  "@types/mocha": "^10.0.10",
43
- "@types/node": "^24.7.2",
43
+ "@types/node": "^24.8.1",
44
44
  "assert": "^2.1.0",
45
45
  "chai": "^6.2.0",
46
46
  "html-webpack-plugin": "^5.6.4",