@coderline/alphatab-webpack 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.
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type * as webpackTypes from 'webpack';
|
|
2
2
|
|
|
3
3
|
export declare class AlphaTabWebPackPlugin {
|
|
4
|
-
_webPackWithAlphaTab
|
|
4
|
+
private _webPackWithAlphaTab;
|
|
5
5
|
options: AlphaTabWebPackPluginOptions;
|
|
6
6
|
constructor(options?: AlphaTabWebPackPluginOptions);
|
|
7
7
|
apply(compiler: webpackTypes.Compiler): void;
|
package/dist/alphaTab.webpack.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* alphaTab WebPack Plugin v1.7.0-alpha.
|
|
2
|
+
* alphaTab WebPack Plugin v1.7.0-alpha.1577 (develop, build 1577)
|
|
3
3
|
*
|
|
4
4
|
* Copyright © 2025, Daniel Kuschny and Contributors, All rights reserved.
|
|
5
5
|
*
|
|
@@ -118,6 +118,7 @@ function isWorkerRuntime(runtime) {
|
|
|
118
118
|
|
|
119
119
|
function injectWorkerRuntimeModule(webPackWithAlphaTab) {
|
|
120
120
|
class AlphaTabWorkerRuntimeModule extends webPackWithAlphaTab.webpack.RuntimeModule {
|
|
121
|
+
static Key = 'AlphaTabWorkerRuntime';
|
|
121
122
|
constructor() {
|
|
122
123
|
super('alphaTab audio worker chunk loading', webPackWithAlphaTab.webpack.RuntimeModule.STAGE_BASIC);
|
|
123
124
|
}
|
|
@@ -162,7 +163,6 @@ function injectWorkerRuntimeModule(webPackWithAlphaTab) {
|
|
|
162
163
|
]);
|
|
163
164
|
}
|
|
164
165
|
}
|
|
165
|
-
AlphaTabWorkerRuntimeModule.Key = 'AlphaTabWorkerRuntime';
|
|
166
166
|
webPackWithAlphaTab.alphaTab.registerWebWorkerRuntimeModule = (pluginName, compilation) => {
|
|
167
167
|
compilation.hooks.runtimeRequirementInTree
|
|
168
168
|
.for(AlphaTabWorkerRuntimeModule.Key)
|
|
@@ -316,6 +316,8 @@ function configureWebWorker(webPackWithAlphaTab, pluginName, options, compiler,
|
|
|
316
316
|
|
|
317
317
|
function injectWebWorkerDependency(webPackWithAlphaTab) {
|
|
318
318
|
class AlphaTabWebWorkerDependency extends webPackWithAlphaTab.webpack.dependencies.ModuleDependency {
|
|
319
|
+
publicPath;
|
|
320
|
+
_hashUpdate;
|
|
319
321
|
constructor(request, range, publicPath) {
|
|
320
322
|
super(request);
|
|
321
323
|
this.range = range;
|
|
@@ -374,6 +376,7 @@ function injectWebWorkerDependency(webPackWithAlphaTab) {
|
|
|
374
376
|
|
|
375
377
|
function injectWorkletRuntimeModule(webPackWithAlphaTab) {
|
|
376
378
|
class AlphaTabWorkletStartRuntimeModule extends webPackWithAlphaTab.webpack.RuntimeModule {
|
|
379
|
+
static RuntimeGlobalWorkletGetStartupChunks = '__webpack_require__.wsc';
|
|
377
380
|
constructor() {
|
|
378
381
|
super('alphaTab audio worklet chunk lookup', webPackWithAlphaTab.webpack.RuntimeModule.STAGE_BASIC);
|
|
379
382
|
}
|
|
@@ -407,7 +410,6 @@ function injectWorkletRuntimeModule(webPackWithAlphaTab) {
|
|
|
407
410
|
]);
|
|
408
411
|
}
|
|
409
412
|
}
|
|
410
|
-
AlphaTabWorkletStartRuntimeModule.RuntimeGlobalWorkletGetStartupChunks = '__webpack_require__.wsc';
|
|
411
413
|
webPackWithAlphaTab.alphaTab.RuntimeGlobalWorkletGetStartupChunks =
|
|
412
414
|
AlphaTabWorkletStartRuntimeModule.RuntimeGlobalWorkletGetStartupChunks;
|
|
413
415
|
webPackWithAlphaTab.alphaTab.registerWorkletRuntimeModule = (pluginName, compilation) => {
|
|
@@ -425,6 +427,8 @@ function injectWorkletDependency(webPackWithAlphaTab) {
|
|
|
425
427
|
* to install chunks which have been added to the worklet via addModule before the bootstrap script starts.
|
|
426
428
|
*/
|
|
427
429
|
class AlphaTabWorkletDependency extends webPackWithAlphaTab.webpack.dependencies.ModuleDependency {
|
|
430
|
+
publicPath;
|
|
431
|
+
_hashUpdate;
|
|
428
432
|
constructor(url, range, publicPath) {
|
|
429
433
|
super(url);
|
|
430
434
|
this.range = range;
|
|
@@ -602,6 +606,8 @@ const makeCacheableWithContext = (fn) => {
|
|
|
602
606
|
};
|
|
603
607
|
const contextify = makeCacheableWithContext(_contextify);
|
|
604
608
|
class AlphaTabWebPackPlugin {
|
|
609
|
+
_webPackWithAlphaTab;
|
|
610
|
+
options;
|
|
605
611
|
constructor(options) {
|
|
606
612
|
this.options = options ?? {};
|
|
607
613
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* alphaTab WebPack Plugin v1.7.0-alpha.
|
|
2
|
+
* alphaTab WebPack 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 e from"node:fs";import*as t from"node:path";import*as a from"node:url";function n(e,t,a){e.webpack.util.serialization.register(t,a,null,{serialize(e,t){e.serialize(t)},deserialize(e){if("function"==typeof t.deserialize)return t.deserialize(e);const a=new t;return a.deserialize(e),a}})}function i(e,t,a){e.hooks.parser.for("javascript/auto").tap(t,a),e.hooks.parser.for("javascript/esm").tap(t,a)}function o(e,t){if("NewExpression"!==t.type||2!==t.arguments.length)return;const a=t,[n,i]=a.arguments,o=e.evaluateExpression(a.callee);if(!o.isIdentifier()||!o.identifier.includes("alphaTabUrl"))return;return[e.evaluateExpression(n),[n.range[0],i.range[1]]]}const r="atworker_";function s(e,t,a,n){const i=n.get(e.state)||0;n.set(e.state,i+1);const o=`${a(e.state.module.identifier())}|${i}`,s=t.compiler.webpack.util.createHash(t.outputOptions.hashFunction);s.update(o);const l=s.digest(t.outputOptions.hashDigest).slice(0,t.outputOptions.hashDigestLength);return r+l}function l(e){return"string"==typeof e&&e.startsWith(r)}const p=Symbol("alphatab worklet specifier tag"),c=new WeakMap;function u(e,t,a,n,r,l,u){if(!1===a.audioWorklets)return;e.alphaTab.registerWorkletDependency(r,l);i(l,t,a=>{const i="alphaTabWorklet";a.hooks.preDeclarator.tap(t,e=>{if("Identifier"===e.id.type&&e.id.name===i)return a.tagVariable(e.id.name,p),!0}),a.hooks.pattern.for(i).tap(t,e=>(a.tagVariable(e.name,p),!0)),a.hooks.callMemberChain.for(p).tap(t,(t,i)=>{if("addModule"===i.join("."))return((t,a)=>{const[i]=a.arguments,l=o(t,i);if(!l)return;const[p]=l;if(!p.isString())return;const d=s(t,r,u,c),h=new e.webpack.AsyncDependenciesBlock({entryOptions:{chunkLoading:!1,wasmLoading:!1,runtime:d,library:{type:"at-worklet"}}});h.loc=a.loc;const b=e.alphaTab.createWorkletDependency(p.string,[a.range[0],a.range[1]],n.options.output.workerPublicPath);return b.loc=a.loc,h.addDependency(b),t.state.module.addBlock(h),!0})(a,t)})})}const d=new WeakMap;function h(e,t,a,n,r,l,p){if(!1===a.audioWorklets)return;e.alphaTab.registerWebWorkerDependency(r,l),new e.webpack.javascript.EnableChunkLoadingPlugin("import-scripts").apply(n);i(l,t,a=>{a.hooks.new.for("alphaTab.Environment.alphaTabWorker").tap(t,t=>((t,a)=>{const[i,l]=a.arguments,c=o(t,i);if(!c)return;const[u,h]=c;if(!u.isString())return;const b=s(t,r,p,d),k=new e.webpack.AsyncDependenciesBlock({entryOptions:{chunkLoading:"import-scripts",wasmLoading:!1,runtime:b,library:{type:"at-worker"}}});k.loc=a.loc;const m=e.alphaTab.createWebWorkerDependency(u.string,h,n.options.output.workerPublicPath);m.loc=a.loc,k.addDependency(m),t.state.module.addBlock(k);const w=new e.webpack.dependencies.ConstDependency(`{ type: ${r.options.output.module?'"module"':"undefined"} }`,l.range);return w.loc=a.loc,t.state.module.addPresentationalDependency(w),t.walkExpression(a.callee),t.walkExpression(i.callee),!0})(a,t))})}const b=/^[a-zA-Z]:[\\/]/,k=/\\/g,m=e=>""===e?"./.":".."===e?"../.":e.startsWith("../")?e:`./${e}`,w=(e=>{const t=new WeakMap,a=(a,n,i)=>{if(!i)return e(a,n);let o,r=t.get(i);void 0===r&&(r=new Map,t.set(i,r));let s=r.get(a);if(void 0===s?(s=new Map,r.set(a,s)):o=s.get(n),void 0!==o)return o;const l=e(a,n);return s.set(n,l),l};return a.bindContextCache=(a,n)=>{let i;if(n){let e=t.get(n);void 0===e&&(e=new Map,t.set(n,e)),i=e.get(a),void 0===i&&(i=new Map,e.set(a,i))}else i=new Map;return t=>{const n=i.get(t);if(void 0!==n)return n;const o=e(a,t);return i.set(t,o),o}},a})((e,a)=>a.split("!").map(a=>((e,a)=>{if("/"===a[0]){if(a.length>1&&"/"===a[a.length-1])return a;const n=a.indexOf("?");let i=-1===n?a:a.slice(0,n);return i=m(t.posix.relative(e,i)),-1===n?i:i+a.slice(n)}if(b.test(a)){const n=a.indexOf("?");let i=-1===n?a:a.slice(0,n);return i=t.win32.relative(e,i),b.test(i)||(i=m(i.replace(k,"/"))),-1===n?i:i+a.slice(n)}return a})(e,a)).join("!"));class g{constructor(e){this.options=e??{}}apply(e){const t={webpack:e.webpack,alphaTab:{}};"alphaTab"in e.webpack.util.serialization.register?t.alphaTab=e.webpack.util.serialization.register.alphaTab:(e.webpack.util.serialization.register.alphaTab=t.alphaTab,function(e){class t extends e.webpack.dependencies.ModuleDependency{constructor(e,t,a){super(e),this.range=t,this.publicPath=a}getReferencedExports(){return e.webpack.Dependency.NO_EXPORTS_REFERENCED}get type(){return"alphaTabWorker"}get category(){return"worker"}updateHash(e){void 0===this._hashUpdate&&(this._hashUpdate=JSON.stringify(this.publicPath)),e.update(this._hashUpdate)}serialize(e){const{write:t}=e;t(this.publicPath),super.serialize(e)}deserialize(e){const{read:t}=e;this.publicPath=t(),super.deserialize(e)}}t.Template=class extends e.webpack.dependencies.ModuleDependency.Template{apply(t,a,n){const{chunkGraph:i,moduleGraph:o,runtimeRequirements:r}=n,s=t,l=o.getParentBlock(t),p=i.getBlockChunkGroup(l).getEntrypointChunk(),c=s.publicPath?`"${s.publicPath}"`:e.webpack.RuntimeGlobals.publicPath;r.add(e.webpack.RuntimeGlobals.publicPath),r.add(e.webpack.RuntimeGlobals.baseURI),r.add(e.webpack.RuntimeGlobals.getChunkScriptFilename),a.replace(s.range[0],s.range[1]-1,`/* worker import */ ${c} + ${e.webpack.RuntimeGlobals.getChunkScriptFilename}(${JSON.stringify(p.id)}), ${e.webpack.RuntimeGlobals.baseURI}`)}},n(e,t,"AlphaTabWebWorkerDependency"),e.alphaTab.createWebWorkerDependency=(e,a,n)=>new t(e,a,n),e.alphaTab.registerWebWorkerDependency=(e,a)=>{e.dependencyFactories.set(t,a),e.dependencyTemplates.set(t,new t.Template)}}(t),function(e){class t extends e.webpack.RuntimeModule{constructor(){super("alphaTab audio worker chunk loading",e.webpack.RuntimeModule.STAGE_BASIC)}generate(){const t=this.compilation,a=t.runtimeTemplate,n=a.globalObject,i=`${n}[${JSON.stringify(t.outputOptions.chunkLoadingGlobal)}]`,o=new Set(this.chunk.ids);for(const t of this.chunk.getAllInitialChunks())if(!e.webpack.javascript.JavascriptModulesPlugin.chunkHasJs(t,this.chunkGraph))for(const e of t.ids)o.add(e);return e.webpack.Template.asString([`if ( ! ('AudioWorkletGlobalScope' in ${n}) ) { return; }`,"const installedChunks = {",e.webpack.Template.indent(Array.from(o,e=>`${JSON.stringify(e)}: 1`).join(",\n")),"};","// importScripts chunk loading",`const installChunk = ${a.basicFunction("data",[a.destructureArray(["chunkIds","moreModules","runtime"],"data"),"for(const moduleId in moreModules) {",e.webpack.Template.indent([`if(${e.webpack.RuntimeGlobals.hasOwnProperty}(moreModules, moduleId)) {`,e.webpack.Template.indent(`${e.webpack.RuntimeGlobals.moduleFactories}[moduleId] = moreModules[moduleId];`),"}"]),"}",`if(runtime) runtime(${e.webpack.RuntimeGlobals.require});`,"while(chunkIds.length)",e.webpack.Template.indent("installedChunks[chunkIds.pop()] = 1;"),"parentChunkLoadingFunction(data);"])};`,`const chunkLoadingGlobal = ${i} = ${i} || [];`,"const parentChunkLoadingFunction = chunkLoadingGlobal.push.bind(chunkLoadingGlobal);","chunkLoadingGlobal.forEach(installChunk);","chunkLoadingGlobal.push = installChunk;"])}}t.Key="AlphaTabWorkerRuntime",e.alphaTab.registerWebWorkerRuntimeModule=(a,n)=>{n.hooks.runtimeRequirementInTree.for(t.Key).tap(a,e=>{n.addRuntimeModule(e,new t)}),n.hooks.additionalChunkRuntimeRequirements.tap(a,(t,a)=>{l(t.runtime)&&(a.add(e.webpack.RuntimeGlobals.moduleFactories),a.add(e.alphaTab.WebWorkerRuntimeModuleKey))})},e.alphaTab.WebWorkerRuntimeModuleKey=t.Key}(t),function(e){class t extends e.webpack.dependencies.ModuleDependency{constructor(e,t,a){super(e),this.range=t,this.publicPath=a}get type(){return"alphaTabWorklet"}get category(){return"worker"}updateHash(e){void 0===this._hashUpdate&&(this._hashUpdate=JSON.stringify(this.publicPath)),e.update(this._hashUpdate)}serialize(e){const{write:t}=e;t(this.publicPath),super.serialize(e)}deserialize(e){const{read:t}=e;this.publicPath=t(),super.deserialize(e)}}t.Template=class extends e.webpack.dependencies.ModuleDependency.Template{apply(t,a,n){const{chunkGraph:i,moduleGraph:o,runtimeRequirements:r}=n,s=t,l=o.getParentBlock(t),p=i.getBlockChunkGroup(l),c=s.publicPath?JSON.stringify(s.publicPath):e.webpack.RuntimeGlobals.publicPath,u=p.getEntrypointChunk(),d=`\n globalThis.self = globalThis.self || globalThis;\n globalThis.location = \${JSON.stringify(${e.webpack.RuntimeGlobals.baseURI})};\n globalThis.importScripts = (url) => { throw new Error("importScripts not available, dynamic loading of chunks not supported in this context", url) };\n `;i.addChunkRuntimeRequirements(u,new Set([e.webpack.RuntimeGlobals.moduleFactories,e.alphaTab.WebWorkerRuntimeModuleKey])),r.add(e.alphaTab.RuntimeGlobalWorkletGetStartupChunks),a.replace(s.range[0],s.range[1]-1,e.webpack.Template.asString(["(/* worklet bootstrap */ async function(__webpack_worklet__) {",e.webpack.Template.indent([`await __webpack_worklet__.addModule(URL.createObjectURL(new Blob([\`${d}\`], { type: "application/javascript; charset=utf-8" })));`,`for (const fileName of ${e.alphaTab.RuntimeGlobalWorkletGetStartupChunks}(${JSON.stringify(u.id)})) {`,e.webpack.Template.indent([`await __webpack_worklet__.addModule(new URL(${c} + fileName, ${e.webpack.RuntimeGlobals.baseURI}));`]),"}"]),"})(alphaTabWorklet)"]))}},n(e,t,"AlphaTabWorkletDependency"),e.alphaTab.registerWorkletDependency=(e,a)=>{e.dependencyFactories.set(t,a),e.dependencyTemplates.set(t,new t.Template)},e.alphaTab.createWorkletDependency=(e,a,n)=>new t(e,a,n)}(t),function(e){class t extends e.webpack.RuntimeModule{constructor(){super("alphaTab audio worklet chunk lookup",e.webpack.RuntimeModule.STAGE_BASIC)}generate(){const a=this.compilation,n=new Map,i=a.chunks;for(const t of i)if(l(t.runtime)){const i=Array.from(t.getAllReferencedChunks()).map(t=>(a.hooks.contentHash.call(t),a.getPath(e.webpack.javascript.JavascriptModulesPlugin.getChunkFilenameTemplate(t,a.outputOptions),{chunk:t,contentHashType:"javascript"})));n.set(String(t.id),i)}return e.webpack.Template.asString([`${t.RuntimeGlobalWorkletGetStartupChunks} = (() => {`,e.webpack.Template.indent(["const lookup = new Map(",e.webpack.Template.indent(JSON.stringify(Array.from(n.entries()))),");","return (chunkId) => lookup.get(String(chunkId)) ?? [];"]),"})();"])}}t.RuntimeGlobalWorkletGetStartupChunks="__webpack_require__.wsc",e.alphaTab.RuntimeGlobalWorkletGetStartupChunks=t.RuntimeGlobalWorkletGetStartupChunks,e.alphaTab.registerWorkletRuntimeModule=(e,a)=>{a.hooks.runtimeRequirementInTree.for(t.RuntimeGlobalWorkletGetStartupChunks).tap(e,e=>{a.addRuntimeModule(e,new t)})}}(t)),this._webPackWithAlphaTab=t,this.configureSoundFont(e),this.configure(e)}configureSoundFont(e){!1!==this.options.assetOutputDir&&(e.options.module.rules.push({test:/\.sf2/,type:"asset/resource"}),e.options.module.rules.push({test:/\.sf3/,type:"asset/resource"}))}configure(e){const t=this.constructor.name,a=w.bindContextCache(e.context,e.root);e.hooks.thisCompilation.tap(t,(n,{normalModuleFactory:i})=>{this._webPackWithAlphaTab.alphaTab.registerWebWorkerRuntimeModule(t,n),this._webPackWithAlphaTab.alphaTab.registerWorkletRuntimeModule(t,n),u(this._webPackWithAlphaTab,t,this.options,e,n,i,a),h(this._webPackWithAlphaTab,t,this.options,e,n,i,a),this.configureAssetCopy(this._webPackWithAlphaTab,t,e,n)})}configureAssetCopy(n,i,o,r){if(!1===this.options.assetOutputDir)return;const s=this.options;r.hooks.processAssets.tapAsync({name:i,stage:this._webPackWithAlphaTab.webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONAL},async(i,l)=>{let p,c=s.alphaTabSourceDir;if(!c)try{const e="string"==typeof import.meta.url;c=e?a.fileURLToPath(import.meta.resolve("@coderline/alphatab")):require.resolve("@coderline/alphatab"),c=t.resolve(c,"..")}catch{c=r.getPath("node_modules/@coderline/alphatab/dist/")}if(c)try{await e.promises.access(t.join(c,"alphaTab.mjs"),e.constants.F_OK),p=!0}catch{p=!1}else p=!1;if(!p)return void r.errors.push(new this._webPackWithAlphaTab.webpack.WebpackError("Could not find alphaTab, please ensure it is installed into node_modules or configure alphaTabSourceDir"));const u=s.assetOutputDir??o.options.output.path;async function d(a){const i=t.join(c,a);r.contextDependencies.add(t.normalize(i));const o=await e.promises.readdir(i,{withFileTypes:!0});await e.promises.mkdir(t.join(u,a),{recursive:!0}),await Promise.all(o.filter(e=>e.isFile()).map(async i=>{const o=t.join(i.parentPath??i.path,i.name);await e.promises.copyFile(o,t.join(u,a,i.name));const s=`${a}/${i.name}`,l=r.getAsset(s),p=await e.promises.readFile(o),c=new n.webpack.sources.RawSource(p);l?r.updateAsset(s,c,{copied:!0,sourceFilename:o}):r.emitAsset(s,c,{copied:!0,sourceFilename:o})}))}u?(await Promise.all([d("font"),d("soundfont")]),l()):r.errors.push(new this._webPackWithAlphaTab.webpack.WebpackError("Need output.path configured in application to store asset files."))})}}export{g 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.
|
|
2
|
+
* alphaTab WebPack Plugin v1.7.0-alpha.1577 (develop, build 1577)
|
|
3
3
|
*
|
|
4
4
|
* Copyright © 2025, Daniel Kuschny and Contributors, All rights reserved.
|
|
5
5
|
*
|
|
@@ -92,6 +92,7 @@ function isWorkerRuntime(runtime) {
|
|
|
92
92
|
|
|
93
93
|
function injectWorkerRuntimeModule(webPackWithAlphaTab) {
|
|
94
94
|
class AlphaTabWorkerRuntimeModule extends webPackWithAlphaTab.webpack.RuntimeModule {
|
|
95
|
+
static Key = 'AlphaTabWorkerRuntime';
|
|
95
96
|
constructor() {
|
|
96
97
|
super('alphaTab audio worker chunk loading', webPackWithAlphaTab.webpack.RuntimeModule.STAGE_BASIC);
|
|
97
98
|
}
|
|
@@ -136,7 +137,6 @@ function injectWorkerRuntimeModule(webPackWithAlphaTab) {
|
|
|
136
137
|
]);
|
|
137
138
|
}
|
|
138
139
|
}
|
|
139
|
-
AlphaTabWorkerRuntimeModule.Key = 'AlphaTabWorkerRuntime';
|
|
140
140
|
webPackWithAlphaTab.alphaTab.registerWebWorkerRuntimeModule = (pluginName, compilation) => {
|
|
141
141
|
compilation.hooks.runtimeRequirementInTree
|
|
142
142
|
.for(AlphaTabWorkerRuntimeModule.Key)
|
|
@@ -290,6 +290,8 @@ function configureWebWorker(webPackWithAlphaTab, pluginName, options, compiler,
|
|
|
290
290
|
|
|
291
291
|
function injectWebWorkerDependency(webPackWithAlphaTab) {
|
|
292
292
|
class AlphaTabWebWorkerDependency extends webPackWithAlphaTab.webpack.dependencies.ModuleDependency {
|
|
293
|
+
publicPath;
|
|
294
|
+
_hashUpdate;
|
|
293
295
|
constructor(request, range, publicPath) {
|
|
294
296
|
super(request);
|
|
295
297
|
this.range = range;
|
|
@@ -348,6 +350,7 @@ function injectWebWorkerDependency(webPackWithAlphaTab) {
|
|
|
348
350
|
|
|
349
351
|
function injectWorkletRuntimeModule(webPackWithAlphaTab) {
|
|
350
352
|
class AlphaTabWorkletStartRuntimeModule extends webPackWithAlphaTab.webpack.RuntimeModule {
|
|
353
|
+
static RuntimeGlobalWorkletGetStartupChunks = '__webpack_require__.wsc';
|
|
351
354
|
constructor() {
|
|
352
355
|
super('alphaTab audio worklet chunk lookup', webPackWithAlphaTab.webpack.RuntimeModule.STAGE_BASIC);
|
|
353
356
|
}
|
|
@@ -381,7 +384,6 @@ function injectWorkletRuntimeModule(webPackWithAlphaTab) {
|
|
|
381
384
|
]);
|
|
382
385
|
}
|
|
383
386
|
}
|
|
384
|
-
AlphaTabWorkletStartRuntimeModule.RuntimeGlobalWorkletGetStartupChunks = '__webpack_require__.wsc';
|
|
385
387
|
webPackWithAlphaTab.alphaTab.RuntimeGlobalWorkletGetStartupChunks =
|
|
386
388
|
AlphaTabWorkletStartRuntimeModule.RuntimeGlobalWorkletGetStartupChunks;
|
|
387
389
|
webPackWithAlphaTab.alphaTab.registerWorkletRuntimeModule = (pluginName, compilation) => {
|
|
@@ -399,6 +401,8 @@ function injectWorkletDependency(webPackWithAlphaTab) {
|
|
|
399
401
|
* to install chunks which have been added to the worklet via addModule before the bootstrap script starts.
|
|
400
402
|
*/
|
|
401
403
|
class AlphaTabWorkletDependency extends webPackWithAlphaTab.webpack.dependencies.ModuleDependency {
|
|
404
|
+
publicPath;
|
|
405
|
+
_hashUpdate;
|
|
402
406
|
constructor(url, range, publicPath) {
|
|
403
407
|
super(url);
|
|
404
408
|
this.range = range;
|
|
@@ -576,6 +580,8 @@ const makeCacheableWithContext = (fn) => {
|
|
|
576
580
|
};
|
|
577
581
|
const contextify = makeCacheableWithContext(_contextify);
|
|
578
582
|
class AlphaTabWebPackPlugin {
|
|
583
|
+
_webPackWithAlphaTab;
|
|
584
|
+
options;
|
|
579
585
|
constructor(options) {
|
|
580
586
|
this.options = options ?? {};
|
|
581
587
|
}
|