Skip to content

Commit dae73e2

Browse files
authored
Release 1.3.1 (#1542)
2 parents 48fd9ac + f5eb128 commit dae73e2

11 files changed

+714
-495
lines changed

package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,9 @@
9797
"webpack-cli": "^5.1.4"
9898
},
9999
"files": [
100-
"/dist/alphaTab*",
100+
"/dist/alphaTab*.js",
101+
"/dist/alphaTab*.mjs",
102+
"/dist/alphaTab*.ts",
101103
"/dist/font/Bravura.*",
102104
"/dist/font/Bravura*.txt",
103105
"/dist/font/*.txt",

rollup.config.webpack.ts

-10
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,6 @@ export default function webpack(isWatch: boolean, bundlePlugins: Plugin[]): Roll
4949
],
5050
external: [
5151
'webpack',
52-
'webpack/lib/ModuleTypeConstants',
53-
'webpack/lib/util/makeSerializable',
54-
'webpack/lib/util/identifier',
55-
'webpack/lib/javascript/EnableChunkLoadingPlugin',
56-
'webpack/lib/dependencies/WorkerDependency',
5752
'fs',
5853
'path'
5954
],
@@ -75,11 +70,6 @@ export default function webpack(isWatch: boolean, bundlePlugins: Plugin[]): Roll
7570
],
7671
external: [
7772
'webpack',
78-
'webpack/lib/ModuleTypeConstants',
79-
'webpack/lib/util/makeSerializable',
80-
'webpack/lib/util/identifier',
81-
'webpack/lib/javascript/EnableChunkLoadingPlugin',
82-
'webpack/lib/dependencies/WorkerDependency',
8373
'fs',
8474
'path'
8575
],

src/webpack/AlphaTabAudioWorklet.ts

+27-30
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,37 @@
11
/**@target web */
2-
import webpack from 'webpack'
32

4-
import { type VariableDeclarator, type Identifier, type Expression, type CallExpression } from 'estree'
3+
import { type VariableDeclarator, type Identifier, type Expression, type CallExpression } from 'estree';
54
import { AlphaTabWebPackPluginOptions } from './AlphaTabWebPackPluginOptions';
6-
import { AlphaTabWorkletDependency } from './AlphaTabWorkletDependency';
7-
import { getWorkerRuntime, parseModuleUrl, tapJavaScript } from './Utils';
5+
import { getWorkerRuntime, parseModuleUrl, tapJavaScript, webPackWithAlphaTab, webpackTypes } from './Utils';
86

9-
const AlphaTabWorkletSpecifierTag = Symbol("alphatab worklet specifier tag");
10-
const workletIndexMap = new WeakMap<webpack.ParserState, number>();
7+
const AlphaTabWorkletSpecifierTag = Symbol('alphatab worklet specifier tag');
8+
const workletIndexMap = new WeakMap<webpackTypes.ParserState, number>();
119

1210
/**
1311
* Configures the Audio Worklet aspects within webpack.
1412
* The counterpart which this plugin detects sits in alphaTab.main.ts
15-
* @param pluginName
16-
* @param options
17-
* @param compiler
18-
* @param compilation
19-
* @param normalModuleFactory
20-
* @param cachedContextify
21-
* @returns
13+
* @param pluginName
14+
* @param options
15+
* @param compiler
16+
* @param compilation
17+
* @param normalModuleFactory
18+
* @param cachedContextify
19+
* @returns
2220
*/
23-
export function configureAudioWorklet(pluginName: string,
21+
export function configureAudioWorklet(
22+
webPackWithAlphaTab: webPackWithAlphaTab,
23+
pluginName: string,
2424
options: AlphaTabWebPackPluginOptions,
25-
compiler: webpack.Compiler, compilation: webpack.Compilation, normalModuleFactory: any, cachedContextify: (s: string) => string) {
25+
compiler: webpackTypes.Compiler,
26+
compilation: webpackTypes.Compilation,
27+
normalModuleFactory: any,
28+
cachedContextify: (s: string) => string
29+
) {
2630
if (options.audioWorklets === false) {
2731
return;
2832
}
2933

30-
compilation.dependencyFactories.set(
31-
AlphaTabWorkletDependency,
32-
normalModuleFactory
33-
);
34-
compilation.dependencyTemplates.set(
35-
AlphaTabWorkletDependency,
36-
new AlphaTabWorkletDependency.Template()
37-
);
34+
webPackWithAlphaTab.alphaTab.registerWorkletDependency(compilation, normalModuleFactory);
3835

3936
const handleAlphaTabWorklet = (parser: any, expr: CallExpression) => {
4037
const [arg1] = expr.arguments;
@@ -49,7 +46,7 @@ export function configureAudioWorklet(pluginName: string,
4946
}
5047

5148
const runtime = getWorkerRuntime(parser, compilation, cachedContextify, workletIndexMap);
52-
const block = new webpack.AsyncDependenciesBlock({
49+
const block = new webPackWithAlphaTab.webpack.AsyncDependenciesBlock({
5350
entryOptions: {
5451
chunkLoading: false,
5552
wasmLoading: false,
@@ -59,10 +56,10 @@ export function configureAudioWorklet(pluginName: string,
5956

6057
block.loc = expr.loc;
6158

62-
const workletBootstrap = new AlphaTabWorkletDependency(
59+
const workletBootstrap = webPackWithAlphaTab.alphaTab.createWorkletDependency(
6360
url.string,
6461
[expr.range![0], expr.range![1]],
65-
compiler.options.output.workerPublicPath,
62+
compiler.options.output.workerPublicPath
6663
);
6764
workletBootstrap.loc = expr.loc!;
6865
block.addDependency(workletBootstrap);
@@ -72,11 +69,11 @@ export function configureAudioWorklet(pluginName: string,
7269
};
7370

7471
const parserPlugin = (parser: any) => {
75-
const pattern = "alphaTabWorklet";
76-
const itemMembers = "addModule";
72+
const pattern = 'alphaTabWorklet';
73+
const itemMembers = 'addModule';
7774

7875
parser.hooks.preDeclarator.tap(pluginName, (decl: VariableDeclarator) => {
79-
if (decl.id.type === "Identifier" && decl.id.name === pattern) {
76+
if (decl.id.type === 'Identifier' && decl.id.name === pattern) {
8077
parser.tagVariable(decl.id.name, AlphaTabWorkletSpecifierTag);
8178
return true;
8279
}
@@ -90,7 +87,7 @@ export function configureAudioWorklet(pluginName: string,
9087
parser.hooks.callMemberChain
9188
.for(AlphaTabWorkletSpecifierTag)
9289
.tap(pluginName, (expression: CallExpression, members: string[]) => {
93-
if (itemMembers !== members.join(".")) {
90+
if (itemMembers !== members.join('.')) {
9491
return;
9592
}
9693
return handleAlphaTabWorklet(parser, expression);

0 commit comments

Comments
 (0)