@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,201 +1,156 @@
|
|
|
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
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
const
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
// in the Software without restriction, including without limitation the rights
|
|
61
|
-
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
62
|
-
// copies of the Software, and to permit persons to whom the Software is
|
|
63
|
-
// furnished to do so, subject to the following conditions:
|
|
64
|
-
// The above copyright notice and this permission notice shall be included in all
|
|
65
|
-
// copies or substantial portions of the Software.
|
|
66
|
-
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
67
|
-
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
68
|
-
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
69
|
-
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
70
|
-
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
71
|
-
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
72
|
-
// SOFTWARE.
|
|
73
|
-
const alphaTabWorkerPatterns = [
|
|
74
|
-
['alphaTabWorker', 'new', 'alphaTabUrl', 'import.meta.url'],
|
|
75
|
-
['alphaTabWorklet.addModule', 'new', 'alphaTabUrl', 'import.meta.url']
|
|
76
|
-
];
|
|
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
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
37
|
+
const require_chunk = require("./chunk.cjs");
|
|
38
|
+
const require_bridge_utils = require("./bridge/utils.cjs");
|
|
39
|
+
const require_bridge_asset = require("./bridge/asset.cjs");
|
|
40
|
+
const require_bridge_resolve = require("./bridge/resolve.cjs");
|
|
41
|
+
const require_bridge_optimizer = require("./bridge/optimizer.cjs");
|
|
42
|
+
const require_bridge_worker = require("./bridge/worker.cjs");
|
|
43
|
+
require("./bridge/index.cjs");
|
|
44
|
+
let magic_string = require("magic-string");
|
|
45
|
+
magic_string = require_chunk.__toESM(magic_string, 1);
|
|
46
|
+
let node_path = require("node:path");
|
|
47
|
+
node_path = require_chunk.__toESM(node_path, 1);
|
|
48
|
+
//#region src/importMetaPlugin.ts
|
|
49
|
+
var alphaTabWorkerPatterns = [[
|
|
50
|
+
"alphaTabWorker",
|
|
51
|
+
"new",
|
|
52
|
+
"alphaTabUrl",
|
|
53
|
+
"import.meta.url"
|
|
54
|
+
], [
|
|
55
|
+
"alphaTabWorklet.addModule",
|
|
56
|
+
"new",
|
|
57
|
+
"alphaTabUrl",
|
|
58
|
+
"import.meta.url"
|
|
59
|
+
]];
|
|
77
60
|
function includesAlphaTabWorker(code) {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
return true;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
return false;
|
|
61
|
+
for (const pattern of alphaTabWorkerPatterns) {
|
|
62
|
+
let position = 0;
|
|
63
|
+
for (const match of pattern) {
|
|
64
|
+
position = code.indexOf(match, position);
|
|
65
|
+
if (position === -1) break;
|
|
66
|
+
}
|
|
67
|
+
if (position !== -1) return true;
|
|
68
|
+
}
|
|
69
|
+
return false;
|
|
91
70
|
}
|
|
92
71
|
function getWorkerType(code, match) {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
let workerOptions = code.slice(startOfOptions, endOfOptions + 1);
|
|
110
|
-
try {
|
|
111
|
-
workerOptions = bridge_utils.evalValue(workerOptions);
|
|
112
|
-
}
|
|
113
|
-
catch {
|
|
114
|
-
return bridge_worker.AlphaTabWorkerTypes.WorkerClassic;
|
|
115
|
-
}
|
|
116
|
-
if (typeof workerOptions === 'object' && workerOptions?.type === 'module') {
|
|
117
|
-
return bridge_worker.AlphaTabWorkerTypes.WorkerModule;
|
|
118
|
-
}
|
|
119
|
-
return bridge_worker.AlphaTabWorkerTypes.WorkerClassic;
|
|
72
|
+
if (match[1].includes(".addModule")) return require_bridge_worker.AlphaTabWorkerTypes.AudioWorklet;
|
|
73
|
+
const endOfMatch = match.indices[0][1];
|
|
74
|
+
const startOfOptions = code.indexOf("{", endOfMatch);
|
|
75
|
+
if (startOfOptions === -1) return require_bridge_worker.AlphaTabWorkerTypes.WorkerClassic;
|
|
76
|
+
const endOfOptions = code.indexOf("}", endOfMatch);
|
|
77
|
+
if (endOfOptions === -1) return require_bridge_worker.AlphaTabWorkerTypes.WorkerClassic;
|
|
78
|
+
const endOfWorkerCreate = code.indexOf(")", endOfMatch);
|
|
79
|
+
if (startOfOptions > endOfWorkerCreate || endOfOptions > endOfWorkerCreate) return require_bridge_worker.AlphaTabWorkerTypes.WorkerClassic;
|
|
80
|
+
let workerOptions = code.slice(startOfOptions, endOfOptions + 1);
|
|
81
|
+
try {
|
|
82
|
+
workerOptions = require_bridge_utils.evalValue(workerOptions);
|
|
83
|
+
} catch {
|
|
84
|
+
return require_bridge_worker.AlphaTabWorkerTypes.WorkerClassic;
|
|
85
|
+
}
|
|
86
|
+
if (typeof workerOptions === "object" && workerOptions?.type === "module") return require_bridge_worker.AlphaTabWorkerTypes.WorkerModule;
|
|
87
|
+
return require_bridge_worker.AlphaTabWorkerTypes.WorkerClassic;
|
|
120
88
|
}
|
|
121
89
|
/**
|
|
122
|
-
|
|
123
|
-
|
|
90
|
+
* @public
|
|
91
|
+
*/
|
|
124
92
|
function importMetaUrlPlugin(options) {
|
|
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
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
match = alphaTabWorkerPattern.exec(code);
|
|
187
|
-
}
|
|
188
|
-
if (s) {
|
|
189
|
-
return {
|
|
190
|
-
code: s.toString(),
|
|
191
|
-
map: resolvedConfig.command === 'build' && resolvedConfig.build.sourcemap
|
|
192
|
-
? s.generateMap({ hires: 'boundary', source: id })
|
|
193
|
-
: null
|
|
194
|
-
};
|
|
195
|
-
}
|
|
196
|
-
return null;
|
|
197
|
-
}
|
|
198
|
-
};
|
|
93
|
+
let resolvedConfig;
|
|
94
|
+
let isBuild;
|
|
95
|
+
let preserveSymlinks;
|
|
96
|
+
const isWorkerActive = options.webWorkers !== false;
|
|
97
|
+
const isWorkletActive = options.audioWorklets !== false;
|
|
98
|
+
const isActive = isWorkerActive || isWorkletActive;
|
|
99
|
+
return {
|
|
100
|
+
name: "vite-plugin-alphatab-url",
|
|
101
|
+
enforce: "pre",
|
|
102
|
+
configResolved(config) {
|
|
103
|
+
resolvedConfig = config;
|
|
104
|
+
isBuild = config.command === "build";
|
|
105
|
+
preserveSymlinks = config.resolve.preserveSymlinks;
|
|
106
|
+
},
|
|
107
|
+
shouldTransformCachedModule({ code }) {
|
|
108
|
+
if (isActive && isBuild && resolvedConfig.build.watch && includesAlphaTabWorker(code)) return true;
|
|
109
|
+
},
|
|
110
|
+
async transform(code, id, options) {
|
|
111
|
+
if (!isActive || options?.ssr || !includesAlphaTabWorker(code)) return;
|
|
112
|
+
let s;
|
|
113
|
+
const alphaTabWorkerPattern = /\b(alphaTabWorker|[\w.]+\.addModule)\s*\(\s*(new\s+[^ (]+alphaTabUrl\s*\(\s*('[^']+'|"[^"]+"|`[^`]+`)\s*,\s*import\.meta\.url\s*\))/dg;
|
|
114
|
+
let match = alphaTabWorkerPattern.exec(code);
|
|
115
|
+
while (match) {
|
|
116
|
+
const workerType = getWorkerType(code, match);
|
|
117
|
+
let typeActive = false;
|
|
118
|
+
switch (workerType) {
|
|
119
|
+
case require_bridge_worker.AlphaTabWorkerTypes.WorkerClassic:
|
|
120
|
+
case require_bridge_worker.AlphaTabWorkerTypes.WorkerModule:
|
|
121
|
+
typeActive = isWorkerActive;
|
|
122
|
+
break;
|
|
123
|
+
case require_bridge_worker.AlphaTabWorkerTypes.AudioWorklet:
|
|
124
|
+
typeActive = isWorkletActive;
|
|
125
|
+
break;
|
|
126
|
+
}
|
|
127
|
+
if (!typeActive) {
|
|
128
|
+
match = alphaTabWorkerPattern.exec(code);
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
s ??= new magic_string.default(code);
|
|
132
|
+
const url = code.slice(match.indices[3][0] + 1, match.indices[3][1] - 1);
|
|
133
|
+
let file = node_path.default.resolve(node_path.default.dirname(id), url);
|
|
134
|
+
file = require_bridge_resolve.tryFsResolve(file, preserveSymlinks) ?? require_bridge_optimizer.tryOptimizedDepResolve(resolvedConfig, options?.ssr === true, url, id, preserveSymlinks) ?? file;
|
|
135
|
+
let builtUrl;
|
|
136
|
+
if (isBuild) builtUrl = await require_bridge_worker.workerFileToUrl(resolvedConfig, file);
|
|
137
|
+
else {
|
|
138
|
+
builtUrl = await require_bridge_asset.fileToUrl(require_bridge_utils.cleanUrl(file), resolvedConfig);
|
|
139
|
+
builtUrl = require_bridge_utils.injectQuery(builtUrl, `${require_bridge_worker.WORKER_FILE_ID}&type=${workerType}`);
|
|
140
|
+
}
|
|
141
|
+
s.update(match.indices[3][0], match.indices[3][1], `new URL('' + ${JSON.stringify(builtUrl)}, import.meta.url)`);
|
|
142
|
+
match = alphaTabWorkerPattern.exec(code);
|
|
143
|
+
}
|
|
144
|
+
if (s) return {
|
|
145
|
+
code: s.toString(),
|
|
146
|
+
map: resolvedConfig.command === "build" && resolvedConfig.build.sourcemap ? s.generateMap({
|
|
147
|
+
hires: "boundary",
|
|
148
|
+
source: id
|
|
149
|
+
}) : null
|
|
150
|
+
};
|
|
151
|
+
return null;
|
|
152
|
+
}
|
|
153
|
+
};
|
|
199
154
|
}
|
|
200
|
-
|
|
155
|
+
//#endregion
|
|
201
156
|
exports.importMetaUrlPlugin = importMetaUrlPlugin;
|