@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.
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 +15 -15
@@ -1,201 +1,156 @@
1
1
  /*!
2
- * alphaTab Vite Plugin v1.8.2 (, build 31)
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
- 'use strict';
38
-
39
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
40
-
41
- const path = require('node:path');
42
- const MagicString = require('magic-string');
43
- const bridge_asset = require('./bridge/asset.cjs');
44
- const bridge_utils = require('./bridge/utils.cjs');
45
- const bridge_optimizer = require('./bridge/optimizer.cjs');
46
- const bridge_resolve = require('./bridge/resolve.cjs');
47
- const bridge_worker = require('./bridge/worker.cjs');
48
-
49
- // This file contains a customized and adapted version of the Vite built-in workerImportMetaUrl plugin
50
- // https://github.com/vitejs/vite/blob/main/packages/vite/src/node/plugins/workerImportMetaUrl.ts
51
- // The main adaptions are:
52
- // - Custom syntax detection for workers and audio worklets
53
- // - Custom worker types and worker URLs to not overlap with the original plugin
54
- // With https://github.com/vitejs/vite/pull/16422 integrated this custom code should not be needed anymore
55
- // Original Sources Licensed under:
56
- // MIT License
57
- // Copyright (c) 2019-present, Yuxi (Evan) You and Vite contributors
58
- // Permission is hereby granted, free of charge, to any person obtaining a copy
59
- // of this software and associated documentation files (the "Software"), to deal
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
- for (const pattern of alphaTabWorkerPatterns) {
79
- let position = 0;
80
- for (const match of pattern) {
81
- position = code.indexOf(match, position);
82
- if (position === -1) {
83
- break;
84
- }
85
- }
86
- if (position !== -1) {
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
- if (match[1].includes('.addModule')) {
94
- return bridge_worker.AlphaTabWorkerTypes.AudioWorklet;
95
- }
96
- const endOfMatch = match.indices[0][1];
97
- const startOfOptions = code.indexOf('{', endOfMatch);
98
- if (startOfOptions === -1) {
99
- return bridge_worker.AlphaTabWorkerTypes.WorkerClassic;
100
- }
101
- const endOfOptions = code.indexOf('}', endOfMatch);
102
- if (endOfOptions === -1) {
103
- return bridge_worker.AlphaTabWorkerTypes.WorkerClassic;
104
- }
105
- const endOfWorkerCreate = code.indexOf(')', endOfMatch);
106
- if (startOfOptions > endOfWorkerCreate || endOfOptions > endOfWorkerCreate) {
107
- return bridge_worker.AlphaTabWorkerTypes.WorkerClassic;
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
- * @public
123
- */
90
+ * @public
91
+ */
124
92
  function importMetaUrlPlugin(options) {
125
- let resolvedConfig;
126
- let isBuild;
127
- let preserveSymlinks;
128
- const isWorkerActive = options.webWorkers !== false;
129
- const isWorkletActive = options.audioWorklets !== false;
130
- const isActive = isWorkerActive || isWorkletActive;
131
- return {
132
- name: 'vite-plugin-alphatab-url',
133
- enforce: 'pre',
134
- configResolved(config) {
135
- resolvedConfig = config;
136
- isBuild = config.command === 'build';
137
- preserveSymlinks = config.resolve.preserveSymlinks;
138
- },
139
- shouldTransformCachedModule({ code }) {
140
- if (isActive && isBuild && resolvedConfig.build.watch && includesAlphaTabWorker(code)) {
141
- return true;
142
- }
143
- return;
144
- },
145
- async transform(code, id, options) {
146
- if (!isActive || options?.ssr || !includesAlphaTabWorker(code)) {
147
- return;
148
- }
149
- let s;
150
- const alphaTabWorkerPattern = /\b(alphaTabWorker|alphaTabWorklet\.addModule)\s*\(\s*(new\s+[^ (]+alphaTabUrl\s*\(\s*('[^']+'|"[^"]+"|`[^`]+`)\s*,\s*import\.meta\.url\s*\))/dg;
151
- let match = alphaTabWorkerPattern.exec(code);
152
- while (match) {
153
- const workerType = getWorkerType(code, match);
154
- let typeActive = false;
155
- switch (workerType) {
156
- case bridge_worker.AlphaTabWorkerTypes.WorkerClassic:
157
- case bridge_worker.AlphaTabWorkerTypes.WorkerModule:
158
- typeActive = isWorkerActive;
159
- break;
160
- case bridge_worker.AlphaTabWorkerTypes.AudioWorklet:
161
- typeActive = isWorkletActive;
162
- break;
163
- }
164
- if (!typeActive) {
165
- match = alphaTabWorkerPattern.exec(code);
166
- continue;
167
- }
168
- s ??= new MagicString(code);
169
- const url = code.slice(match.indices[3][0] + 1, match.indices[3][1] - 1);
170
- let file = path.resolve(path.dirname(id), url);
171
- file =
172
- bridge_resolve.tryFsResolve(file, preserveSymlinks) ??
173
- bridge_optimizer.tryOptimizedDepResolve(resolvedConfig, options?.ssr === true, url, id, preserveSymlinks) ??
174
- file;
175
- let builtUrl;
176
- if (isBuild) {
177
- builtUrl = await bridge_worker.workerFileToUrl(resolvedConfig, file);
178
- }
179
- else {
180
- builtUrl = await bridge_asset.fileToUrl(bridge_utils.cleanUrl(file), resolvedConfig);
181
- builtUrl = bridge_utils.injectQuery(builtUrl, `${bridge_worker.WORKER_FILE_ID}&type=${workerType}`);
182
- }
183
- s.update(match.indices[3][0], match.indices[3][1],
184
- // add `'' +` to skip vite:asset-import-meta-url plugin
185
- `new URL('' + ${JSON.stringify(builtUrl)}, import.meta.url)`);
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;