@coderline/alphatab-webpack 1.7.0-alpha.1617 → 1.7.0-alpha.1626
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/AlphaTabAudioWorklet.mjs +114 -0
- package/dist/AlphaTabWebPackPlugin.d.ts +10 -0
- package/dist/AlphaTabWebPackPlugin.mjs +311 -0
- package/dist/AlphaTabWebPackPluginOptions.d.ts +30 -0
- package/dist/AlphaTabWebPackPluginOptions.mjs +36 -0
- package/dist/AlphaTabWebWorker.mjs +101 -0
- package/dist/AlphaTabWebWorkerDependency.mjs +102 -0
- package/dist/AlphaTabWorkerRuntimeModule.mjs +105 -0
- package/dist/AlphaTabWorkletDependency.mjs +123 -0
- package/dist/AlphaTabWorkletStartRuntimeModule.mjs +89 -0
- package/dist/Utils.d.ts +6 -0
- package/dist/Utils.mjs +104 -0
- package/dist/alphaTab.webpack.d.ts +1 -57
- package/dist/alphaTab.webpack.mjs +2 -684
- package/package.json +11 -8
- package/dist/alphaTab.webpack.js +0 -745
- package/dist/alphaTab.webpack.min.mjs +0 -36
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* alphaTab WebPack Plugin v1.7.0-alpha.1617 (develop, build 1617)
|
|
3
|
-
*
|
|
4
|
-
* Copyright © 2025, Daniel Kuschny and Contributors, All rights reserved.
|
|
5
|
-
*
|
|
6
|
-
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
7
|
-
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
8
|
-
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
9
|
-
*
|
|
10
|
-
* This library uses code from WebPack (https://github.com/webpack/webpack/), licensed under:
|
|
11
|
-
*
|
|
12
|
-
* Copyright JS Foundation and other contributors
|
|
13
|
-
*
|
|
14
|
-
* Permission is hereby granted, free of charge, to any person obtaining
|
|
15
|
-
* a copy of this software and associated documentation files (the
|
|
16
|
-
* 'Software'), to deal in the Software without restriction, including
|
|
17
|
-
* without limitation the rights to use, copy, modify, merge, publish,
|
|
18
|
-
* distribute, sublicense, and/or sell copies of the Software, and to
|
|
19
|
-
* permit persons to whom the Software is furnished to do so, subject to
|
|
20
|
-
* the following conditions:
|
|
21
|
-
*
|
|
22
|
-
* The above copyright notice and this permission notice shall be
|
|
23
|
-
* included in all copies or substantial portions of the Software.
|
|
24
|
-
*
|
|
25
|
-
* THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
26
|
-
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
27
|
-
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
28
|
-
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
29
|
-
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
30
|
-
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
31
|
-
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
32
|
-
*
|
|
33
|
-
* @preserve
|
|
34
|
-
* @license
|
|
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};
|