@coderline/alphatab-vite 1.8.1 → 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.
Files changed (47) hide show
  1. package/dist/AlphaTabVitePluginOptions.cjs +34 -37
  2. package/dist/AlphaTabVitePluginOptions.mjs +34 -35
  3. package/dist/alphaTab.vite.cjs +37 -44
  4. package/dist/alphaTab.vite.mjs +36 -36
  5. package/dist/alphaTabVitePlugin.cjs +50 -54
  6. package/dist/alphaTabVitePlugin.mjs +49 -50
  7. package/dist/bridge/asset.cjs +50 -80
  8. package/dist/bridge/asset.mjs +47 -57
  9. package/dist/bridge/build.cjs +152 -214
  10. package/dist/bridge/build.mjs +149 -191
  11. package/dist/bridge/bundler.cjs +54 -0
  12. package/dist/bridge/bundler.mjs +52 -0
  13. package/dist/bridge/config.cjs +34 -37
  14. package/dist/bridge/config.mjs +34 -35
  15. package/dist/bridge/constants.cjs +73 -80
  16. package/dist/bridge/constants.mjs +72 -76
  17. package/dist/bridge/fsUtils.cjs +46 -55
  18. package/dist/bridge/fsUtils.mjs +43 -51
  19. package/dist/bridge/index.cjs +58 -68
  20. package/dist/bridge/index.mjs +42 -42
  21. package/dist/bridge/optimizer.cjs +112 -155
  22. package/dist/bridge/optimizer.mjs +108 -132
  23. package/dist/bridge/plugins.cjs +39 -45
  24. package/dist/bridge/plugins.mjs +38 -41
  25. package/dist/bridge/resolve.cjs +54 -66
  26. package/dist/bridge/resolve.mjs +53 -62
  27. package/dist/bridge/typeUtils.cjs +34 -37
  28. package/dist/bridge/typeUtils.mjs +34 -35
  29. package/dist/bridge/utils.cjs +87 -121
  30. package/dist/bridge/utils.mjs +84 -117
  31. package/dist/bridge/worker.cjs +179 -183
  32. package/dist/bridge/worker.mjs +175 -160
  33. package/dist/chunk.cjs +63 -0
  34. package/dist/copyAssetsPlugin.cjs +102 -163
  35. package/dist/copyAssetsPlugin.mjs +35 -141
  36. package/dist/copyAssetsPlugin2.mjs +108 -0
  37. package/dist/detectionGlobalPlugin.cjs +65 -68
  38. package/dist/detectionGlobalPlugin.mjs +62 -64
  39. package/dist/dist.cjs +6595 -0
  40. package/dist/dist.mjs +6589 -0
  41. package/dist/importMetaPlugin.cjs +147 -192
  42. package/dist/importMetaPlugin.mjs +143 -188
  43. package/dist/prompt-DewH0PjV.cjs +885 -0
  44. package/dist/prompt-DewH0PjV.mjs +882 -0
  45. package/dist/workerPlugin.cjs +145 -219
  46. package/dist/workerPlugin.mjs +141 -196
  47. package/package.json +17 -17
@@ -1,197 +1,152 @@
1
1
  /*!
2
- * alphaTab Vite Plugin v1.8.1 (, build 30)
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
-
37
- import path__default from 'node:path';
38
- import MagicString from 'magic-string';
39
- import { fileToUrl } from './bridge/asset.mjs';
40
- import { cleanUrl, injectQuery, evalValue } from './bridge/utils.mjs';
41
- import { tryOptimizedDepResolve } from './bridge/optimizer.mjs';
42
- import { tryFsResolve } from './bridge/resolve.mjs';
43
- import { AlphaTabWorkerTypes, workerFileToUrl, WORKER_FILE_ID } from './bridge/worker.mjs';
44
-
45
- // This file contains a customized and adapted version of the Vite built-in workerImportMetaUrl plugin
46
- // https://github.com/vitejs/vite/blob/main/packages/vite/src/node/plugins/workerImportMetaUrl.ts
47
- // The main adaptions are:
48
- // - Custom syntax detection for workers and audio worklets
49
- // - Custom worker types and worker URLs to not overlap with the original plugin
50
- // With https://github.com/vitejs/vite/pull/16422 integrated this custom code should not be needed anymore
51
- // Original Sources Licensed under:
52
- // MIT License
53
- // Copyright (c) 2019-present, Yuxi (Evan) You and Vite contributors
54
- // Permission is hereby granted, free of charge, to any person obtaining a copy
55
- // of this software and associated documentation files (the "Software"), to deal
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
- for (const pattern of alphaTabWorkerPatterns) {
75
- let position = 0;
76
- for (const match of pattern) {
77
- position = code.indexOf(match, position);
78
- if (position === -1) {
79
- break;
80
- }
81
- }
82
- if (position !== -1) {
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
- if (match[1].includes('.addModule')) {
90
- return AlphaTabWorkerTypes.AudioWorklet;
91
- }
92
- const endOfMatch = match.indices[0][1];
93
- const startOfOptions = code.indexOf('{', endOfMatch);
94
- if (startOfOptions === -1) {
95
- return AlphaTabWorkerTypes.WorkerClassic;
96
- }
97
- const endOfOptions = code.indexOf('}', endOfMatch);
98
- if (endOfOptions === -1) {
99
- return AlphaTabWorkerTypes.WorkerClassic;
100
- }
101
- const endOfWorkerCreate = code.indexOf(')', endOfMatch);
102
- if (startOfOptions > endOfWorkerCreate || endOfOptions > endOfWorkerCreate) {
103
- return AlphaTabWorkerTypes.WorkerClassic;
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
- * @public
119
- */
86
+ * @public
87
+ */
120
88
  function importMetaUrlPlugin(options) {
121
- let resolvedConfig;
122
- let isBuild;
123
- let preserveSymlinks;
124
- const isWorkerActive = options.webWorkers !== false;
125
- const isWorkletActive = options.audioWorklets !== false;
126
- const isActive = isWorkerActive || isWorkletActive;
127
- return {
128
- name: 'vite-plugin-alphatab-url',
129
- enforce: 'pre',
130
- configResolved(config) {
131
- resolvedConfig = config;
132
- isBuild = config.command === 'build';
133
- preserveSymlinks = config.resolve.preserveSymlinks;
134
- },
135
- shouldTransformCachedModule({ code }) {
136
- if (isActive && isBuild && resolvedConfig.build.watch && includesAlphaTabWorker(code)) {
137
- return true;
138
- }
139
- return;
140
- },
141
- async transform(code, id, options) {
142
- if (!isActive || options?.ssr || !includesAlphaTabWorker(code)) {
143
- return;
144
- }
145
- let s;
146
- const alphaTabWorkerPattern = /\b(alphaTabWorker|alphaTabWorklet\.addModule)\s*\(\s*(new\s+[^ (]+alphaTabUrl\s*\(\s*('[^']+'|"[^"]+"|`[^`]+`)\s*,\s*import\.meta\.url\s*\))/dg;
147
- let match = alphaTabWorkerPattern.exec(code);
148
- while (match) {
149
- const workerType = getWorkerType(code, match);
150
- let typeActive = false;
151
- switch (workerType) {
152
- case AlphaTabWorkerTypes.WorkerClassic:
153
- case AlphaTabWorkerTypes.WorkerModule:
154
- typeActive = isWorkerActive;
155
- break;
156
- case AlphaTabWorkerTypes.AudioWorklet:
157
- typeActive = isWorkletActive;
158
- break;
159
- }
160
- if (!typeActive) {
161
- match = alphaTabWorkerPattern.exec(code);
162
- continue;
163
- }
164
- s ??= new MagicString(code);
165
- const url = code.slice(match.indices[3][0] + 1, match.indices[3][1] - 1);
166
- let file = path__default.resolve(path__default.dirname(id), url);
167
- file =
168
- tryFsResolve(file, preserveSymlinks) ??
169
- tryOptimizedDepResolve(resolvedConfig, options?.ssr === true, url, id, preserveSymlinks) ??
170
- file;
171
- let builtUrl;
172
- if (isBuild) {
173
- builtUrl = await workerFileToUrl(resolvedConfig, file);
174
- }
175
- else {
176
- builtUrl = await fileToUrl(cleanUrl(file), resolvedConfig);
177
- builtUrl = injectQuery(builtUrl, `${WORKER_FILE_ID}&type=${workerType}`);
178
- }
179
- s.update(match.indices[3][0], match.indices[3][1],
180
- // add `'' +` to skip vite:asset-import-meta-url plugin
181
- `new URL('' + ${JSON.stringify(builtUrl)}, import.meta.url)`);
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 };