@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
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* alphaTab WebPack Plugin v1.7.0-alpha.1626 (develop, build 1626)
|
|
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
|
+
|
|
37
|
+
import { makeDependencySerializable } from './Utils.mjs';
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* @internal
|
|
41
|
+
*/
|
|
42
|
+
function injectWebWorkerDependency(webPackWithAlphaTab) {
|
|
43
|
+
class AlphaTabWebWorkerDependency extends webPackWithAlphaTab.webpack.dependencies.ModuleDependency {
|
|
44
|
+
publicPath;
|
|
45
|
+
_hashUpdate;
|
|
46
|
+
constructor(request, range, publicPath) {
|
|
47
|
+
super(request);
|
|
48
|
+
this.range = range;
|
|
49
|
+
this.publicPath = publicPath;
|
|
50
|
+
}
|
|
51
|
+
getReferencedExports() {
|
|
52
|
+
return webPackWithAlphaTab.webpack.Dependency.NO_EXPORTS_REFERENCED;
|
|
53
|
+
}
|
|
54
|
+
get type() {
|
|
55
|
+
return 'alphaTabWorker';
|
|
56
|
+
}
|
|
57
|
+
get category() {
|
|
58
|
+
return 'worker';
|
|
59
|
+
}
|
|
60
|
+
updateHash(hash) {
|
|
61
|
+
if (this._hashUpdate === undefined) {
|
|
62
|
+
this._hashUpdate = JSON.stringify(this.publicPath);
|
|
63
|
+
}
|
|
64
|
+
hash.update(this._hashUpdate);
|
|
65
|
+
}
|
|
66
|
+
serialize(context) {
|
|
67
|
+
const { write } = context;
|
|
68
|
+
write(this.publicPath);
|
|
69
|
+
super.serialize(context);
|
|
70
|
+
}
|
|
71
|
+
deserialize(context) {
|
|
72
|
+
const { read } = context;
|
|
73
|
+
this.publicPath = read();
|
|
74
|
+
super.deserialize(context);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
AlphaTabWebWorkerDependency.Template = class WorkerDependencyTemplate extends (webPackWithAlphaTab.webpack.dependencies.ModuleDependency.Template) {
|
|
78
|
+
apply(dependency, source, templateContext) {
|
|
79
|
+
const { chunkGraph, moduleGraph, runtimeRequirements } = templateContext;
|
|
80
|
+
const dep = dependency;
|
|
81
|
+
const block = moduleGraph.getParentBlock(dependency);
|
|
82
|
+
const entrypoint = chunkGraph.getBlockChunkGroup(block);
|
|
83
|
+
const chunk = entrypoint.getEntrypointChunk();
|
|
84
|
+
// We use the workerPublicPath option if provided, else we fallback to the RuntimeGlobal publicPath
|
|
85
|
+
const workerImportBaseUrl = dep.publicPath
|
|
86
|
+
? `"${dep.publicPath}"`
|
|
87
|
+
: webPackWithAlphaTab.webpack.RuntimeGlobals.publicPath;
|
|
88
|
+
runtimeRequirements.add(webPackWithAlphaTab.webpack.RuntimeGlobals.publicPath);
|
|
89
|
+
runtimeRequirements.add(webPackWithAlphaTab.webpack.RuntimeGlobals.baseURI);
|
|
90
|
+
runtimeRequirements.add(webPackWithAlphaTab.webpack.RuntimeGlobals.getChunkScriptFilename);
|
|
91
|
+
source.replace(dep.range[0], dep.range[1] - 1, `/* worker import */ ${workerImportBaseUrl} + ${webPackWithAlphaTab.webpack.RuntimeGlobals.getChunkScriptFilename}(${JSON.stringify(chunk.id)}), ${webPackWithAlphaTab.webpack.RuntimeGlobals.baseURI}`);
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
makeDependencySerializable(webPackWithAlphaTab, AlphaTabWebWorkerDependency, 'AlphaTabWebWorkerDependency');
|
|
95
|
+
webPackWithAlphaTab.alphaTab.createWebWorkerDependency = (request, range, publicPath) => new AlphaTabWebWorkerDependency(request, range, publicPath);
|
|
96
|
+
webPackWithAlphaTab.alphaTab.registerWebWorkerDependency = (compilation, normalModuleFactory) => {
|
|
97
|
+
compilation.dependencyFactories.set(AlphaTabWebWorkerDependency, normalModuleFactory);
|
|
98
|
+
compilation.dependencyTemplates.set(AlphaTabWebWorkerDependency, new AlphaTabWebWorkerDependency.Template());
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export { injectWebWorkerDependency };
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* alphaTab WebPack Plugin v1.7.0-alpha.1626 (develop, build 1626)
|
|
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
|
+
|
|
37
|
+
import { isWorkerRuntime } from './Utils.mjs';
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* @internal
|
|
41
|
+
*/
|
|
42
|
+
function injectWorkerRuntimeModule(webPackWithAlphaTab) {
|
|
43
|
+
class AlphaTabWorkerRuntimeModule extends webPackWithAlphaTab.webpack.RuntimeModule {
|
|
44
|
+
static Key = 'AlphaTabWorkerRuntime';
|
|
45
|
+
constructor() {
|
|
46
|
+
super('alphaTab audio worker chunk loading', webPackWithAlphaTab.webpack.RuntimeModule.STAGE_BASIC);
|
|
47
|
+
}
|
|
48
|
+
generate() {
|
|
49
|
+
const compilation = this.compilation;
|
|
50
|
+
const runtimeTemplate = compilation.runtimeTemplate;
|
|
51
|
+
const globalObject = runtimeTemplate.globalObject;
|
|
52
|
+
const chunkLoadingGlobalExpr = `${globalObject}[${JSON.stringify(compilation.outputOptions.chunkLoadingGlobal)}]`;
|
|
53
|
+
const initialChunkIds = new Set(this.chunk.ids);
|
|
54
|
+
for (const c of this.chunk.getAllInitialChunks()) {
|
|
55
|
+
if (webPackWithAlphaTab.webpack.javascript.JavascriptModulesPlugin.chunkHasJs(c, this.chunkGraph)) {
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
for (const id of c.ids) {
|
|
59
|
+
initialChunkIds.add(id);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return webPackWithAlphaTab.webpack.Template.asString([
|
|
63
|
+
`if ( ! ('AudioWorkletGlobalScope' in ${globalObject}) ) { return; }`,
|
|
64
|
+
'const installedChunks = {',
|
|
65
|
+
webPackWithAlphaTab.webpack.Template.indent(Array.from(initialChunkIds, id => `${JSON.stringify(id)}: 1`).join(',\n')),
|
|
66
|
+
'};',
|
|
67
|
+
'// importScripts chunk loading',
|
|
68
|
+
`const installChunk = ${runtimeTemplate.basicFunction('data', [
|
|
69
|
+
runtimeTemplate.destructureArray(['chunkIds', 'moreModules', 'runtime'], 'data'),
|
|
70
|
+
'for(const moduleId in moreModules) {',
|
|
71
|
+
webPackWithAlphaTab.webpack.Template.indent([
|
|
72
|
+
`if(${webPackWithAlphaTab.webpack.RuntimeGlobals.hasOwnProperty}(moreModules, moduleId)) {`,
|
|
73
|
+
webPackWithAlphaTab.webpack.Template.indent(`${webPackWithAlphaTab.webpack.RuntimeGlobals.moduleFactories}[moduleId] = moreModules[moduleId];`),
|
|
74
|
+
'}'
|
|
75
|
+
]),
|
|
76
|
+
'}',
|
|
77
|
+
`if(runtime) runtime(${webPackWithAlphaTab.webpack.RuntimeGlobals.require});`,
|
|
78
|
+
'while(chunkIds.length)',
|
|
79
|
+
webPackWithAlphaTab.webpack.Template.indent('installedChunks[chunkIds.pop()] = 1;'),
|
|
80
|
+
'parentChunkLoadingFunction(data);'
|
|
81
|
+
])};`,
|
|
82
|
+
`const chunkLoadingGlobal = ${chunkLoadingGlobalExpr} = ${chunkLoadingGlobalExpr} || [];`,
|
|
83
|
+
'const parentChunkLoadingFunction = chunkLoadingGlobal.push.bind(chunkLoadingGlobal);',
|
|
84
|
+
'chunkLoadingGlobal.forEach(installChunk);',
|
|
85
|
+
'chunkLoadingGlobal.push = installChunk;'
|
|
86
|
+
]);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
webPackWithAlphaTab.alphaTab.registerWebWorkerRuntimeModule = (pluginName, compilation) => {
|
|
90
|
+
compilation.hooks.runtimeRequirementInTree
|
|
91
|
+
.for(AlphaTabWorkerRuntimeModule.Key)
|
|
92
|
+
.tap(pluginName, (chunk) => {
|
|
93
|
+
compilation.addRuntimeModule(chunk, new AlphaTabWorkerRuntimeModule());
|
|
94
|
+
});
|
|
95
|
+
compilation.hooks.additionalChunkRuntimeRequirements.tap(pluginName, (chunk, runtimeRequirements) => {
|
|
96
|
+
if (isWorkerRuntime(chunk.runtime)) {
|
|
97
|
+
runtimeRequirements.add(webPackWithAlphaTab.webpack.RuntimeGlobals.moduleFactories);
|
|
98
|
+
runtimeRequirements.add(webPackWithAlphaTab.alphaTab.WebWorkerRuntimeModuleKey);
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
};
|
|
102
|
+
webPackWithAlphaTab.alphaTab.WebWorkerRuntimeModuleKey = AlphaTabWorkerRuntimeModule.Key;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export { injectWorkerRuntimeModule };
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* alphaTab WebPack Plugin v1.7.0-alpha.1626 (develop, build 1626)
|
|
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
|
+
|
|
37
|
+
import { makeDependencySerializable } from './Utils.mjs';
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* @internal
|
|
41
|
+
*/
|
|
42
|
+
function injectWorkletDependency(webPackWithAlphaTab) {
|
|
43
|
+
/**
|
|
44
|
+
* This module dependency injects the relevant code into a worklet bootstrap script
|
|
45
|
+
* to install chunks which have been added to the worklet via addModule before the bootstrap script starts.
|
|
46
|
+
*/
|
|
47
|
+
class AlphaTabWorkletDependency extends webPackWithAlphaTab.webpack.dependencies.ModuleDependency {
|
|
48
|
+
publicPath;
|
|
49
|
+
_hashUpdate;
|
|
50
|
+
constructor(url, range, publicPath) {
|
|
51
|
+
super(url);
|
|
52
|
+
this.range = range;
|
|
53
|
+
this.publicPath = publicPath;
|
|
54
|
+
}
|
|
55
|
+
get type() {
|
|
56
|
+
return 'alphaTabWorklet';
|
|
57
|
+
}
|
|
58
|
+
get category() {
|
|
59
|
+
return 'worker';
|
|
60
|
+
}
|
|
61
|
+
updateHash(hash) {
|
|
62
|
+
if (this._hashUpdate === undefined) {
|
|
63
|
+
this._hashUpdate = JSON.stringify(this.publicPath);
|
|
64
|
+
}
|
|
65
|
+
hash.update(this._hashUpdate);
|
|
66
|
+
}
|
|
67
|
+
serialize(context) {
|
|
68
|
+
const { write } = context;
|
|
69
|
+
write(this.publicPath);
|
|
70
|
+
super.serialize(context);
|
|
71
|
+
}
|
|
72
|
+
deserialize(context) {
|
|
73
|
+
const { read } = context;
|
|
74
|
+
this.publicPath = read();
|
|
75
|
+
super.deserialize(context);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
AlphaTabWorkletDependency.Template = class AlphaTabWorkletDependencyTemplate extends (webPackWithAlphaTab.webpack.dependencies.ModuleDependency.Template) {
|
|
79
|
+
apply(dependency, source, templateContext) {
|
|
80
|
+
const { chunkGraph, moduleGraph, runtimeRequirements } = templateContext;
|
|
81
|
+
const dep = dependency;
|
|
82
|
+
const block = moduleGraph.getParentBlock(dependency);
|
|
83
|
+
const entrypoint = chunkGraph.getBlockChunkGroup(block);
|
|
84
|
+
const workletImportBaseUrl = dep.publicPath
|
|
85
|
+
? JSON.stringify(dep.publicPath)
|
|
86
|
+
: webPackWithAlphaTab.webpack.RuntimeGlobals.publicPath;
|
|
87
|
+
const chunk = entrypoint.getEntrypointChunk();
|
|
88
|
+
// worklet global scope has no 'self', need to inject it for compatibility with chunks
|
|
89
|
+
// some plugins like the auto public path need to right location. we pass this on from the main runtime
|
|
90
|
+
// some plugins rely on importScripts to be defined.
|
|
91
|
+
const workletInlineBootstrap = `
|
|
92
|
+
globalThis.self = globalThis.self || globalThis;
|
|
93
|
+
globalThis.location = \${JSON.stringify(${webPackWithAlphaTab.webpack.RuntimeGlobals.baseURI})};
|
|
94
|
+
globalThis.importScripts = (url) => { throw new Error("importScripts not available, dynamic loading of chunks not supported in this context", url) };
|
|
95
|
+
`;
|
|
96
|
+
chunkGraph.addChunkRuntimeRequirements(chunk, new Set([
|
|
97
|
+
webPackWithAlphaTab.webpack.RuntimeGlobals.moduleFactories,
|
|
98
|
+
webPackWithAlphaTab.alphaTab.WebWorkerRuntimeModuleKey
|
|
99
|
+
]));
|
|
100
|
+
runtimeRequirements.add(webPackWithAlphaTab.alphaTab.RuntimeGlobalWorkletGetStartupChunks);
|
|
101
|
+
source.replace(dep.range[0], dep.range[1] - 1, webPackWithAlphaTab.webpack.Template.asString([
|
|
102
|
+
'(/* worklet bootstrap */ async function(__webpack_worklet__) {',
|
|
103
|
+
webPackWithAlphaTab.webpack.Template.indent([
|
|
104
|
+
`await __webpack_worklet__.addModule(URL.createObjectURL(new Blob([\`${workletInlineBootstrap}\`], { type: "application/javascript; charset=utf-8" })));`,
|
|
105
|
+
`for (const fileName of ${webPackWithAlphaTab.alphaTab.RuntimeGlobalWorkletGetStartupChunks}(${JSON.stringify(chunk.id)})) {`,
|
|
106
|
+
webPackWithAlphaTab.webpack.Template.indent([
|
|
107
|
+
`await __webpack_worklet__.addModule(new URL(${workletImportBaseUrl} + fileName, ${webPackWithAlphaTab.webpack.RuntimeGlobals.baseURI}));`
|
|
108
|
+
]),
|
|
109
|
+
'}'
|
|
110
|
+
]),
|
|
111
|
+
'})(alphaTabWorklet)'
|
|
112
|
+
]));
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
makeDependencySerializable(webPackWithAlphaTab, AlphaTabWorkletDependency, 'AlphaTabWorkletDependency');
|
|
116
|
+
webPackWithAlphaTab.alphaTab.registerWorkletDependency = (compilation, normalModuleFactory) => {
|
|
117
|
+
compilation.dependencyFactories.set(AlphaTabWorkletDependency, normalModuleFactory);
|
|
118
|
+
compilation.dependencyTemplates.set(AlphaTabWorkletDependency, new AlphaTabWorkletDependency.Template());
|
|
119
|
+
};
|
|
120
|
+
webPackWithAlphaTab.alphaTab.createWorkletDependency = (request, range, publicPath) => new AlphaTabWorkletDependency(request, range, publicPath);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export { injectWorkletDependency };
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* alphaTab WebPack Plugin v1.7.0-alpha.1626 (develop, build 1626)
|
|
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
|
+
|
|
37
|
+
import { isWorkerRuntime } from './Utils.mjs';
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* @internal
|
|
41
|
+
*/
|
|
42
|
+
function injectWorkletRuntimeModule(webPackWithAlphaTab) {
|
|
43
|
+
class AlphaTabWorkletStartRuntimeModule extends webPackWithAlphaTab.webpack.RuntimeModule {
|
|
44
|
+
static RuntimeGlobalWorkletGetStartupChunks = '__webpack_require__.wsc';
|
|
45
|
+
constructor() {
|
|
46
|
+
super('alphaTab audio worklet chunk lookup', webPackWithAlphaTab.webpack.RuntimeModule.STAGE_BASIC);
|
|
47
|
+
}
|
|
48
|
+
generate() {
|
|
49
|
+
const compilation = this.compilation;
|
|
50
|
+
const workletChunkLookup = new Map();
|
|
51
|
+
const allChunks = compilation.chunks;
|
|
52
|
+
for (const chunk of allChunks) {
|
|
53
|
+
const isWorkletEntry = isWorkerRuntime(chunk.runtime);
|
|
54
|
+
if (isWorkletEntry) {
|
|
55
|
+
const workletChunks = Array.from(chunk.getAllReferencedChunks()).map(c => {
|
|
56
|
+
// force content chunk to be created
|
|
57
|
+
compilation.hooks.contentHash.call(c);
|
|
58
|
+
return compilation.getPath(webPackWithAlphaTab.webpack.javascript.JavascriptModulesPlugin.getChunkFilenameTemplate(c, compilation.outputOptions), {
|
|
59
|
+
chunk: c,
|
|
60
|
+
contentHashType: 'javascript'
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
workletChunkLookup.set(String(chunk.id), workletChunks);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return webPackWithAlphaTab.webpack.Template.asString([
|
|
67
|
+
`${AlphaTabWorkletStartRuntimeModule.RuntimeGlobalWorkletGetStartupChunks} = (() => {`,
|
|
68
|
+
webPackWithAlphaTab.webpack.Template.indent([
|
|
69
|
+
'const lookup = new Map(',
|
|
70
|
+
webPackWithAlphaTab.webpack.Template.indent(JSON.stringify(Array.from(workletChunkLookup.entries()))),
|
|
71
|
+
');',
|
|
72
|
+
'return (chunkId) => lookup.get(String(chunkId)) ?? [];'
|
|
73
|
+
]),
|
|
74
|
+
'})();'
|
|
75
|
+
]);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
webPackWithAlphaTab.alphaTab.RuntimeGlobalWorkletGetStartupChunks =
|
|
79
|
+
AlphaTabWorkletStartRuntimeModule.RuntimeGlobalWorkletGetStartupChunks;
|
|
80
|
+
webPackWithAlphaTab.alphaTab.registerWorkletRuntimeModule = (pluginName, compilation) => {
|
|
81
|
+
compilation.hooks.runtimeRequirementInTree
|
|
82
|
+
.for(AlphaTabWorkletStartRuntimeModule.RuntimeGlobalWorkletGetStartupChunks)
|
|
83
|
+
.tap(pluginName, (chunk) => {
|
|
84
|
+
compilation.addRuntimeModule(chunk, new AlphaTabWorkletStartRuntimeModule());
|
|
85
|
+
});
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export { injectWorkletRuntimeModule };
|
package/dist/Utils.d.ts
ADDED
package/dist/Utils.mjs
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* alphaTab WebPack Plugin v1.7.0-alpha.1626 (develop, build 1626)
|
|
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
|
+
|
|
37
|
+
const JAVASCRIPT_MODULE_TYPE_AUTO = 'javascript/auto';
|
|
38
|
+
const JAVASCRIPT_MODULE_TYPE_ESM = 'javascript/esm';
|
|
39
|
+
/**
|
|
40
|
+
* @internal
|
|
41
|
+
*/
|
|
42
|
+
function makeDependencySerializable(webPackWithAlphaTab, dependency, key) {
|
|
43
|
+
webPackWithAlphaTab.webpack.util.serialization.register(dependency, key, null, {
|
|
44
|
+
serialize(obj, context) {
|
|
45
|
+
obj.serialize(context);
|
|
46
|
+
},
|
|
47
|
+
deserialize(context) {
|
|
48
|
+
if (typeof dependency.deserialize === 'function') {
|
|
49
|
+
return dependency.deserialize(context);
|
|
50
|
+
}
|
|
51
|
+
const obj = new dependency();
|
|
52
|
+
obj.deserialize(context);
|
|
53
|
+
return obj;
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* @internal
|
|
59
|
+
*/
|
|
60
|
+
function tapJavaScript(normalModuleFactory, pluginName, parserPlugin) {
|
|
61
|
+
normalModuleFactory.hooks.parser.for(JAVASCRIPT_MODULE_TYPE_AUTO).tap(pluginName, parserPlugin);
|
|
62
|
+
normalModuleFactory.hooks.parser.for(JAVASCRIPT_MODULE_TYPE_ESM).tap(pluginName, parserPlugin);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* @internal
|
|
66
|
+
*/
|
|
67
|
+
function parseModuleUrl(parser, expr) {
|
|
68
|
+
if (expr.type !== 'NewExpression' || expr.arguments.length !== 2) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
const newExpr = expr;
|
|
72
|
+
const [arg1, arg2] = newExpr.arguments;
|
|
73
|
+
const callee = parser.evaluateExpression(newExpr.callee);
|
|
74
|
+
if (!callee.isIdentifier() || !callee.identifier.includes('alphaTabUrl')) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
const arg1Value = parser.evaluateExpression(arg1);
|
|
78
|
+
return [arg1Value, [arg1.range[0], arg2.range[1]]];
|
|
79
|
+
}
|
|
80
|
+
const ALPHATAB_WORKER_RUNTIME_PREFIX = 'atworker_';
|
|
81
|
+
/**
|
|
82
|
+
* @internal
|
|
83
|
+
*/
|
|
84
|
+
function getWorkerRuntime(parser, compilation, cachedContextify, workerIndexMap) {
|
|
85
|
+
const i = workerIndexMap.get(parser.state) || 0;
|
|
86
|
+
workerIndexMap.set(parser.state, i + 1);
|
|
87
|
+
const name = `${cachedContextify(parser.state.module.identifier())}|${i}`;
|
|
88
|
+
const hash = compilation.compiler.webpack.util.createHash(compilation.outputOptions.hashFunction);
|
|
89
|
+
hash.update(name);
|
|
90
|
+
const digest = hash.digest(compilation.outputOptions.hashDigest);
|
|
91
|
+
const runtime = digest.slice(0, compilation.outputOptions.hashDigestLength);
|
|
92
|
+
return ALPHATAB_WORKER_RUNTIME_PREFIX + runtime;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* @internal
|
|
96
|
+
*/
|
|
97
|
+
function isWorkerRuntime(runtime) {
|
|
98
|
+
if (typeof runtime !== 'string') {
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
return runtime.startsWith(ALPHATAB_WORKER_RUNTIME_PREFIX);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export { getWorkerRuntime, isWorkerRuntime, makeDependencySerializable, parseModuleUrl, tapJavaScript };
|
|
@@ -1,57 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export declare class AlphaTabWebPackPlugin {
|
|
4
|
-
private _webPackWithAlphaTab;
|
|
5
|
-
options: AlphaTabWebPackPluginOptions;
|
|
6
|
-
constructor(options?: AlphaTabWebPackPluginOptions);
|
|
7
|
-
apply(compiler: webpackTypes.Compiler): void;
|
|
8
|
-
configureSoundFont(compiler: webpackTypes.Compiler): void;
|
|
9
|
-
configure(compiler: webpackTypes.Compiler): void;
|
|
10
|
-
configureAssetCopy(webPackWithAlphaTab: webPackWithAlphaTab, pluginName: string, compiler: webpackTypes.Compiler, compilation: webpackTypes.Compilation): void;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
declare interface AlphaTabWebPackPluginOptions {
|
|
14
|
-
/**
|
|
15
|
-
* The location where alphaTab can be found.
|
|
16
|
-
* (default: node_modules/@coderline/alphatab/dist)
|
|
17
|
-
*/
|
|
18
|
-
alphaTabSourceDir?: string;
|
|
19
|
-
/**
|
|
20
|
-
* The location where assets of alphaTab should be placed.
|
|
21
|
-
* Set it to false to disable the copying of assets like fonts.
|
|
22
|
-
* (default: compiler.options.output.path)
|
|
23
|
-
*/
|
|
24
|
-
assetOutputDir?: string | false;
|
|
25
|
-
/**
|
|
26
|
-
* Whether alphaTab should configure the audio worklet support in WebPack.
|
|
27
|
-
* This might break support for audio playback unless audio worklet support is added
|
|
28
|
-
* through other means to WebPack.
|
|
29
|
-
* (default: true)
|
|
30
|
-
*/
|
|
31
|
-
audioWorklets?: boolean;
|
|
32
|
-
/**
|
|
33
|
-
* Whether alphaTab should configure the web worklet support in WebPack.
|
|
34
|
-
* This might break support for audio playback and background unless audio worklet support is added
|
|
35
|
-
* through other means to WebPack.
|
|
36
|
-
* (default: true)
|
|
37
|
-
*/
|
|
38
|
-
webWorkers?: boolean;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
declare type NormalModuleFactory = webpackTypes.Compilation['params']['normalModuleFactory'];
|
|
42
|
-
|
|
43
|
-
declare type webPackWithAlphaTab = {
|
|
44
|
-
webpack: webpackTypes.Compiler['webpack'];
|
|
45
|
-
alphaTab: {
|
|
46
|
-
registerWebWorkerRuntimeModule(pluginName: string, compilation: webpackTypes.Compilation): void;
|
|
47
|
-
WebWorkerRuntimeModuleKey: string;
|
|
48
|
-
createWebWorkerDependency(request: string, range: [number, number], publicPath: string | undefined): webpackTypes.dependencies.ModuleDependency;
|
|
49
|
-
registerWebWorkerDependency(compilation: webpackTypes.Compilation, normalModuleFactory: NormalModuleFactory): void;
|
|
50
|
-
registerWorkletRuntimeModule(pluginName: string, compilation: webpackTypes.Compilation): void;
|
|
51
|
-
RuntimeGlobalWorkletGetStartupChunks: string;
|
|
52
|
-
createWorkletDependency(request: string, range: [number, number], publicPath: string | undefined): webpackTypes.dependencies.ModuleDependency;
|
|
53
|
-
registerWorkletDependency(compilation: webpackTypes.Compilation, normalModuleFactory: NormalModuleFactory): void;
|
|
54
|
-
};
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
export { }
|
|
1
|
+
export { AlphaTabWebPackPlugin } from "./AlphaTabWebPackPlugin";
|