@coderline/alphatab-vite 1.8.2 → 1.8.3
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/AlphaTabVitePluginOptions.cjs +34 -37
- package/dist/AlphaTabVitePluginOptions.mjs +34 -35
- package/dist/alphaTab.vite.cjs +37 -44
- package/dist/alphaTab.vite.mjs +36 -36
- package/dist/alphaTabVitePlugin.cjs +50 -54
- package/dist/alphaTabVitePlugin.mjs +49 -50
- package/dist/bridge/asset.cjs +50 -80
- package/dist/bridge/asset.mjs +47 -57
- package/dist/bridge/build.cjs +152 -214
- package/dist/bridge/build.mjs +149 -191
- package/dist/bridge/bundler.cjs +54 -0
- package/dist/bridge/bundler.mjs +52 -0
- package/dist/bridge/config.cjs +34 -37
- package/dist/bridge/config.mjs +34 -35
- package/dist/bridge/constants.cjs +73 -80
- package/dist/bridge/constants.mjs +72 -76
- package/dist/bridge/fsUtils.cjs +46 -55
- package/dist/bridge/fsUtils.mjs +43 -51
- package/dist/bridge/index.cjs +58 -68
- package/dist/bridge/index.mjs +42 -42
- package/dist/bridge/optimizer.cjs +112 -155
- package/dist/bridge/optimizer.mjs +108 -132
- package/dist/bridge/plugins.cjs +39 -45
- package/dist/bridge/plugins.mjs +38 -41
- package/dist/bridge/resolve.cjs +54 -66
- package/dist/bridge/resolve.mjs +53 -62
- package/dist/bridge/typeUtils.cjs +34 -37
- package/dist/bridge/typeUtils.mjs +34 -35
- package/dist/bridge/utils.cjs +87 -121
- package/dist/bridge/utils.mjs +84 -117
- package/dist/bridge/worker.cjs +179 -183
- package/dist/bridge/worker.mjs +175 -160
- package/dist/chunk.cjs +63 -0
- package/dist/copyAssetsPlugin.cjs +102 -163
- package/dist/copyAssetsPlugin.mjs +35 -141
- package/dist/copyAssetsPlugin2.mjs +108 -0
- package/dist/detectionGlobalPlugin.cjs +65 -68
- package/dist/detectionGlobalPlugin.mjs +62 -64
- package/dist/dist.cjs +6595 -0
- package/dist/dist.mjs +6589 -0
- package/dist/importMetaPlugin.cjs +147 -192
- package/dist/importMetaPlugin.mjs +143 -188
- package/dist/prompt-DewH0PjV.cjs +885 -0
- package/dist/prompt-DewH0PjV.mjs +882 -0
- package/dist/workerPlugin.cjs +145 -219
- package/dist/workerPlugin.mjs +141 -196
- package/package.json +15 -15
|
@@ -1,197 +1,152 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
import
|
|
38
|
-
import
|
|
39
|
-
import {
|
|
40
|
-
import {
|
|
41
|
-
import
|
|
42
|
-
import
|
|
43
|
-
import
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
// in the Software without restriction, including without limitation the rights
|
|
57
|
-
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
58
|
-
// copies of the Software, and to permit persons to whom the Software is
|
|
59
|
-
// furnished to do so, subject to the following conditions:
|
|
60
|
-
// The above copyright notice and this permission notice shall be included in all
|
|
61
|
-
// copies or substantial portions of the Software.
|
|
62
|
-
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
63
|
-
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
64
|
-
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
65
|
-
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
66
|
-
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
67
|
-
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
68
|
-
// SOFTWARE.
|
|
69
|
-
const alphaTabWorkerPatterns = [
|
|
70
|
-
['alphaTabWorker', 'new', 'alphaTabUrl', 'import.meta.url'],
|
|
71
|
-
['alphaTabWorklet.addModule', 'new', 'alphaTabUrl', 'import.meta.url']
|
|
72
|
-
];
|
|
2
|
+
* alphaTab Vite Plugin v1.8.3 (, build 32)
|
|
3
|
+
*
|
|
4
|
+
* Copyright © 2026, 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 Vite (https://github.com/vitejs/vite/), licensed under:
|
|
11
|
+
*
|
|
12
|
+
* MIT License
|
|
13
|
+
* Copyright (c) 2019-present, Yuxi (Evan) You and Vite contributors
|
|
14
|
+
*
|
|
15
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
16
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
17
|
+
* in the Software without restriction, including without limitation the rights
|
|
18
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
19
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
20
|
+
* furnished to do so, subject to the following conditions:
|
|
21
|
+
*
|
|
22
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
23
|
+
* copies or substantial portions of the Software.
|
|
24
|
+
*
|
|
25
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
26
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
27
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
28
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
29
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
30
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
31
|
+
* SOFTWARE.
|
|
32
|
+
*
|
|
33
|
+
* @preserve
|
|
34
|
+
* @license
|
|
35
|
+
*/
|
|
36
|
+
import { cleanUrl, evalValue, injectQuery } from "./bridge/utils.mjs";
|
|
37
|
+
import { fileToUrl } from "./bridge/asset.mjs";
|
|
38
|
+
import { tryFsResolve } from "./bridge/resolve.mjs";
|
|
39
|
+
import { tryOptimizedDepResolve } from "./bridge/optimizer.mjs";
|
|
40
|
+
import { AlphaTabWorkerTypes, WORKER_FILE_ID, workerFileToUrl } from "./bridge/worker.mjs";
|
|
41
|
+
import "./bridge/index.mjs";
|
|
42
|
+
import MagicString from "magic-string";
|
|
43
|
+
import path from "node:path";
|
|
44
|
+
//#region src/importMetaPlugin.ts
|
|
45
|
+
var alphaTabWorkerPatterns = [[
|
|
46
|
+
"alphaTabWorker",
|
|
47
|
+
"new",
|
|
48
|
+
"alphaTabUrl",
|
|
49
|
+
"import.meta.url"
|
|
50
|
+
], [
|
|
51
|
+
"alphaTabWorklet.addModule",
|
|
52
|
+
"new",
|
|
53
|
+
"alphaTabUrl",
|
|
54
|
+
"import.meta.url"
|
|
55
|
+
]];
|
|
73
56
|
function includesAlphaTabWorker(code) {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
return true;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
return false;
|
|
57
|
+
for (const pattern of alphaTabWorkerPatterns) {
|
|
58
|
+
let position = 0;
|
|
59
|
+
for (const match of pattern) {
|
|
60
|
+
position = code.indexOf(match, position);
|
|
61
|
+
if (position === -1) break;
|
|
62
|
+
}
|
|
63
|
+
if (position !== -1) return true;
|
|
64
|
+
}
|
|
65
|
+
return false;
|
|
87
66
|
}
|
|
88
67
|
function getWorkerType(code, match) {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
let workerOptions = code.slice(startOfOptions, endOfOptions + 1);
|
|
106
|
-
try {
|
|
107
|
-
workerOptions = evalValue(workerOptions);
|
|
108
|
-
}
|
|
109
|
-
catch {
|
|
110
|
-
return AlphaTabWorkerTypes.WorkerClassic;
|
|
111
|
-
}
|
|
112
|
-
if (typeof workerOptions === 'object' && workerOptions?.type === 'module') {
|
|
113
|
-
return AlphaTabWorkerTypes.WorkerModule;
|
|
114
|
-
}
|
|
115
|
-
return AlphaTabWorkerTypes.WorkerClassic;
|
|
68
|
+
if (match[1].includes(".addModule")) return AlphaTabWorkerTypes.AudioWorklet;
|
|
69
|
+
const endOfMatch = match.indices[0][1];
|
|
70
|
+
const startOfOptions = code.indexOf("{", endOfMatch);
|
|
71
|
+
if (startOfOptions === -1) return AlphaTabWorkerTypes.WorkerClassic;
|
|
72
|
+
const endOfOptions = code.indexOf("}", endOfMatch);
|
|
73
|
+
if (endOfOptions === -1) return AlphaTabWorkerTypes.WorkerClassic;
|
|
74
|
+
const endOfWorkerCreate = code.indexOf(")", endOfMatch);
|
|
75
|
+
if (startOfOptions > endOfWorkerCreate || endOfOptions > endOfWorkerCreate) return AlphaTabWorkerTypes.WorkerClassic;
|
|
76
|
+
let workerOptions = code.slice(startOfOptions, endOfOptions + 1);
|
|
77
|
+
try {
|
|
78
|
+
workerOptions = evalValue(workerOptions);
|
|
79
|
+
} catch {
|
|
80
|
+
return AlphaTabWorkerTypes.WorkerClassic;
|
|
81
|
+
}
|
|
82
|
+
if (typeof workerOptions === "object" && workerOptions?.type === "module") return AlphaTabWorkerTypes.WorkerModule;
|
|
83
|
+
return AlphaTabWorkerTypes.WorkerClassic;
|
|
116
84
|
}
|
|
117
85
|
/**
|
|
118
|
-
|
|
119
|
-
|
|
86
|
+
* @public
|
|
87
|
+
*/
|
|
120
88
|
function importMetaUrlPlugin(options) {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
match = alphaTabWorkerPattern.exec(code);
|
|
183
|
-
}
|
|
184
|
-
if (s) {
|
|
185
|
-
return {
|
|
186
|
-
code: s.toString(),
|
|
187
|
-
map: resolvedConfig.command === 'build' && resolvedConfig.build.sourcemap
|
|
188
|
-
? s.generateMap({ hires: 'boundary', source: id })
|
|
189
|
-
: null
|
|
190
|
-
};
|
|
191
|
-
}
|
|
192
|
-
return null;
|
|
193
|
-
}
|
|
194
|
-
};
|
|
89
|
+
let resolvedConfig;
|
|
90
|
+
let isBuild;
|
|
91
|
+
let preserveSymlinks;
|
|
92
|
+
const isWorkerActive = options.webWorkers !== false;
|
|
93
|
+
const isWorkletActive = options.audioWorklets !== false;
|
|
94
|
+
const isActive = isWorkerActive || isWorkletActive;
|
|
95
|
+
return {
|
|
96
|
+
name: "vite-plugin-alphatab-url",
|
|
97
|
+
enforce: "pre",
|
|
98
|
+
configResolved(config) {
|
|
99
|
+
resolvedConfig = config;
|
|
100
|
+
isBuild = config.command === "build";
|
|
101
|
+
preserveSymlinks = config.resolve.preserveSymlinks;
|
|
102
|
+
},
|
|
103
|
+
shouldTransformCachedModule({ code }) {
|
|
104
|
+
if (isActive && isBuild && resolvedConfig.build.watch && includesAlphaTabWorker(code)) return true;
|
|
105
|
+
},
|
|
106
|
+
async transform(code, id, options) {
|
|
107
|
+
if (!isActive || options?.ssr || !includesAlphaTabWorker(code)) return;
|
|
108
|
+
let s;
|
|
109
|
+
const alphaTabWorkerPattern = /\b(alphaTabWorker|[\w.]+\.addModule)\s*\(\s*(new\s+[^ (]+alphaTabUrl\s*\(\s*('[^']+'|"[^"]+"|`[^`]+`)\s*,\s*import\.meta\.url\s*\))/dg;
|
|
110
|
+
let match = alphaTabWorkerPattern.exec(code);
|
|
111
|
+
while (match) {
|
|
112
|
+
const workerType = getWorkerType(code, match);
|
|
113
|
+
let typeActive = false;
|
|
114
|
+
switch (workerType) {
|
|
115
|
+
case AlphaTabWorkerTypes.WorkerClassic:
|
|
116
|
+
case AlphaTabWorkerTypes.WorkerModule:
|
|
117
|
+
typeActive = isWorkerActive;
|
|
118
|
+
break;
|
|
119
|
+
case AlphaTabWorkerTypes.AudioWorklet:
|
|
120
|
+
typeActive = isWorkletActive;
|
|
121
|
+
break;
|
|
122
|
+
}
|
|
123
|
+
if (!typeActive) {
|
|
124
|
+
match = alphaTabWorkerPattern.exec(code);
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
s ??= new MagicString(code);
|
|
128
|
+
const url = code.slice(match.indices[3][0] + 1, match.indices[3][1] - 1);
|
|
129
|
+
let file = path.resolve(path.dirname(id), url);
|
|
130
|
+
file = tryFsResolve(file, preserveSymlinks) ?? tryOptimizedDepResolve(resolvedConfig, options?.ssr === true, url, id, preserveSymlinks) ?? file;
|
|
131
|
+
let builtUrl;
|
|
132
|
+
if (isBuild) builtUrl = await workerFileToUrl(resolvedConfig, file);
|
|
133
|
+
else {
|
|
134
|
+
builtUrl = await fileToUrl(cleanUrl(file), resolvedConfig);
|
|
135
|
+
builtUrl = injectQuery(builtUrl, `${WORKER_FILE_ID}&type=${workerType}`);
|
|
136
|
+
}
|
|
137
|
+
s.update(match.indices[3][0], match.indices[3][1], `new URL('' + ${JSON.stringify(builtUrl)}, import.meta.url)`);
|
|
138
|
+
match = alphaTabWorkerPattern.exec(code);
|
|
139
|
+
}
|
|
140
|
+
if (s) return {
|
|
141
|
+
code: s.toString(),
|
|
142
|
+
map: resolvedConfig.command === "build" && resolvedConfig.build.sourcemap ? s.generateMap({
|
|
143
|
+
hires: "boundary",
|
|
144
|
+
source: id
|
|
145
|
+
}) : null
|
|
146
|
+
};
|
|
147
|
+
return null;
|
|
148
|
+
}
|
|
149
|
+
};
|
|
195
150
|
}
|
|
196
|
-
|
|
151
|
+
//#endregion
|
|
197
152
|
export { importMetaUrlPlugin };
|