@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,224 +1,150 @@
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_utils = require('./bridge/utils.cjs');
44
- const bridge_build = require('./bridge/build.cjs');
45
- const bridge_constants = require('./bridge/constants.cjs');
46
- require('node:fs');
47
- require('vite');
48
- const bridge_worker = require('./bridge/worker.cjs');
49
-
50
- function _interopNamespaceDefault(e) {
51
- const n = Object.create(null, { [Symbol.toStringTag]: { value: 'Module' } });
52
- if (e) {
53
- for (const k in e) {
54
- if (k !== 'default') {
55
- const d = Object.getOwnPropertyDescriptor(e, k);
56
- Object.defineProperty(n, k, d.get ? d : {
57
- enumerable: true,
58
- get: () => e[k]
59
- });
60
- }
61
- }
62
- }
63
- n.default = e;
64
- return Object.freeze(n);
65
- }
66
-
67
- const path__namespace = /*#__PURE__*/_interopNamespaceDefault(path);
68
-
69
- // This file contains a customized and adapted version of the Vite built-in worker plugin
70
- // https://github.com/vitejs/vite/blob/main/packages/vite/src/node/plugins/worker.ts
71
- // This is more or less a 1:1 copy of the original worker plugin with following adaptions:
72
- // - Only handle syntax variants known to be used in alphaTab
73
- // - Use the alphaTab URL markers
74
- // - Some refactoring for better code understanding
75
- // With https://github.com/vitejs/vite/pull/16422 integrated this custom code might not be needed anymore
76
- // Some adjustment for audio worklet in vite might be needed to treat them as type "module" workers
77
- // Original Sources Licensed under:
78
- // MIT License
79
- // Copyright (c) 2019-present, Yuxi (Evan) You and Vite contributors
80
- // Permission is hereby granted, free of charge, to any person obtaining a copy
81
- // of this software and associated documentation files (the "Software"), to deal
82
- // in the Software without restriction, including without limitation the rights
83
- // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
84
- // copies of the Software, and to permit persons to whom the Software is
85
- // furnished to do so, subject to the following conditions:
86
- // The above copyright notice and this permission notice shall be included in all
87
- // copies or substantial portions of the Software.
88
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
89
- // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
90
- // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
91
- // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
92
- // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
93
- // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
94
- // SOFTWARE.
95
- const workerFileRE = new RegExp(`(?:\\?|&)${bridge_worker.WORKER_FILE_ID}&type=(\\w+)(?:&|$)`);
96
- const workerAssetUrlRE = new RegExp(`${bridge_worker.WORKER_ASSET_ID}([a-z\\d]{8})__`, 'g');
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_constants = require("./bridge/constants.cjs");
40
+ const require_bridge_build = require("./bridge/build.cjs");
41
+ const require_bridge_worker = require("./bridge/worker.cjs");
42
+ require("./bridge/index.cjs");
43
+ let magic_string = require("magic-string");
44
+ magic_string = require_chunk.__toESM(magic_string, 1);
45
+ let node_path = require("node:path");
46
+ node_path = require_chunk.__toESM(node_path, 1);
47
+ //#region src/workerPlugin.ts
48
+ var workerFileRE = new RegExp(`(?:\\?|&)${require_bridge_worker.WORKER_FILE_ID}&type=(\\w+)(?:&|$)`);
49
+ var workerAssetUrlRE = new RegExp(`${require_bridge_worker.WORKER_ASSET_ID}([a-z\\d]{8})__`, "g");
97
50
  /**
98
- * @public
99
- */
51
+ * @public
52
+ */
100
53
  function workerPlugin(options) {
101
- let resolvedConfig;
102
- let isBuild;
103
- let isWorker;
104
- const isWorkerActive = options.webWorkers !== false;
105
- const isWorkletActive = options.audioWorklets !== false;
106
- const isActive = isWorkerActive || isWorkletActive;
107
- return {
108
- name: 'vite-plugin-alphatab-worker',
109
- configResolved(config) {
110
- resolvedConfig = config;
111
- isBuild = config.command === 'build';
112
- isWorker = config.isWorker;
113
- },
114
- buildStart() {
115
- if (!isActive || isWorker) {
116
- return;
117
- }
118
- bridge_worker.workerCache.set(resolvedConfig, {
119
- assets: new Map(),
120
- bundle: new Map(),
121
- fileNameHash: new Map()
122
- });
123
- },
124
- load(id) {
125
- if (isActive && isBuild && id.includes(bridge_worker.WORKER_FILE_ID)) {
126
- return '';
127
- }
128
- return;
129
- },
130
- shouldTransformCachedModule({ id }) {
131
- if (isActive && isBuild && resolvedConfig.build.watch && id.includes(bridge_worker.WORKER_FILE_ID)) {
132
- return true;
133
- }
134
- return;
135
- },
136
- async transform(raw, id) {
137
- if (!isActive) {
138
- return;
139
- }
140
- const match = workerFileRE.exec(id);
141
- if (!match) {
142
- return;
143
- }
144
- // inject env to worker file, might be needed by imported scripts
145
- const envScriptPath = JSON.stringify(path__namespace.posix.join(resolvedConfig.base, bridge_constants.ENV_PUBLIC_PATH));
146
- const workerType = match[1];
147
- let injectEnv = '';
148
- switch (workerType) {
149
- case bridge_worker.AlphaTabWorkerTypes.WorkerClassic:
150
- injectEnv = `importScripts(${envScriptPath})\n`;
151
- break;
152
- case bridge_worker.AlphaTabWorkerTypes.WorkerModule:
153
- case bridge_worker.AlphaTabWorkerTypes.AudioWorklet:
154
- injectEnv = `import ${envScriptPath}\n`;
155
- break;
156
- }
157
- if (injectEnv) {
158
- const s = new MagicString(raw);
159
- s.prepend(injectEnv);
160
- return {
161
- code: s.toString(),
162
- map: s.generateMap({ hires: 'boundary' })
163
- };
164
- }
165
- return;
166
- },
167
- renderChunk(code, chunk, outputOptions) {
168
- // when building the worker URLs are replaced with some placeholders
169
- // here we replace those placeholders with the final file names respecting chunks
170
- let s;
171
- const result = () => {
172
- return (s && {
173
- code: s.toString(),
174
- map: resolvedConfig.build.sourcemap ? s.generateMap({ hires: 'boundary' }) : null
175
- });
176
- };
177
- workerAssetUrlRE.lastIndex = 0;
178
- if (workerAssetUrlRE.test(code)) {
179
- const toRelativeRuntime = bridge_build.createToImportMetaURLBasedRelativeRuntime(outputOptions.format, resolvedConfig.isWorker);
180
- s = new MagicString(code);
181
- workerAssetUrlRE.lastIndex = 0;
182
- // Replace "VITE_WORKER_ASSET__5aa0ddc0" using relative paths
183
- const workerMap = bridge_worker.workerCache.get(resolvedConfig.mainConfig || resolvedConfig);
184
- const { fileNameHash } = workerMap;
185
- let match = workerAssetUrlRE.exec(code);
186
- while (match) {
187
- const [full, hash] = match;
188
- const filename = fileNameHash.get(hash);
189
- const replacement = bridge_build.toOutputFilePathInJS(filename, 'asset', chunk.fileName, 'js', resolvedConfig, toRelativeRuntime);
190
- const replacementString = typeof replacement === 'string'
191
- ? JSON.stringify(bridge_utils.encodeURIPath(replacement)).slice(1, -1)
192
- : `"+${replacement.runtime}+"`;
193
- s.update(match.index, match.index + full.length, replacementString);
194
- match = workerAssetUrlRE.exec(code);
195
- }
196
- }
197
- return result();
198
- },
199
- generateBundle(_, bundle) {
200
- if (isWorker) {
201
- return;
202
- }
203
- const workerMap = bridge_worker.workerCache.get(resolvedConfig);
204
- for (const asset of workerMap.assets.values()) {
205
- const duplicateAsset = bundle[asset.fileName];
206
- if (duplicateAsset) {
207
- const content = duplicateAsset.type === 'asset' ? duplicateAsset.source : duplicateAsset.code;
208
- // don't emit if the file name and the content is same
209
- if (bridge_worker.isSameContent(content, asset.source)) {
210
- return;
211
- }
212
- }
213
- this.emitFile({
214
- type: 'asset',
215
- fileName: asset.fileName,
216
- source: asset.source
217
- });
218
- }
219
- workerMap.assets.clear();
220
- }
221
- };
54
+ let resolvedConfig;
55
+ let isBuild;
56
+ let isWorker;
57
+ const isWorkerActive = options.webWorkers !== false;
58
+ const isWorkletActive = options.audioWorklets !== false;
59
+ const isActive = isWorkerActive || isWorkletActive;
60
+ return {
61
+ name: "vite-plugin-alphatab-worker",
62
+ configResolved(config) {
63
+ resolvedConfig = config;
64
+ isBuild = config.command === "build";
65
+ isWorker = config.isWorker;
66
+ },
67
+ buildStart() {
68
+ if (!isActive || isWorker) return;
69
+ require_bridge_worker.workerCache.set(resolvedConfig, {
70
+ assets: /* @__PURE__ */ new Map(),
71
+ bundle: /* @__PURE__ */ new Map(),
72
+ fileNameHash: /* @__PURE__ */ new Map()
73
+ });
74
+ },
75
+ load(id) {
76
+ if (isActive && isBuild && id.includes("alphatab_worker")) return "";
77
+ },
78
+ shouldTransformCachedModule({ id }) {
79
+ if (isActive && isBuild && resolvedConfig.build.watch && id.includes("alphatab_worker")) return true;
80
+ },
81
+ async transform(raw, id) {
82
+ if (!isActive) return;
83
+ const match = workerFileRE.exec(id);
84
+ if (!match) return;
85
+ const envScriptPath = JSON.stringify(node_path.posix.join(resolvedConfig.base, require_bridge_constants.ENV_PUBLIC_PATH));
86
+ const workerType = match[1];
87
+ let injectEnv = "";
88
+ switch (workerType) {
89
+ case require_bridge_worker.AlphaTabWorkerTypes.WorkerClassic:
90
+ injectEnv = `importScripts(${envScriptPath})\n`;
91
+ break;
92
+ case require_bridge_worker.AlphaTabWorkerTypes.WorkerModule:
93
+ case require_bridge_worker.AlphaTabWorkerTypes.AudioWorklet:
94
+ injectEnv = `import ${envScriptPath}\n`;
95
+ break;
96
+ }
97
+ if (injectEnv) {
98
+ const s = new magic_string.default(raw);
99
+ s.prepend(injectEnv);
100
+ return {
101
+ code: s.toString(),
102
+ map: s.generateMap({ hires: "boundary" })
103
+ };
104
+ }
105
+ },
106
+ renderChunk(code, chunk, outputOptions) {
107
+ let s;
108
+ const result = () => {
109
+ return s && {
110
+ code: s.toString(),
111
+ map: resolvedConfig.build.sourcemap ? s.generateMap({ hires: "boundary" }) : null
112
+ };
113
+ };
114
+ workerAssetUrlRE.lastIndex = 0;
115
+ if (workerAssetUrlRE.test(code)) {
116
+ const toRelativeRuntime = require_bridge_build.createToImportMetaURLBasedRelativeRuntime(outputOptions.format, resolvedConfig.isWorker);
117
+ s = new magic_string.default(code);
118
+ workerAssetUrlRE.lastIndex = 0;
119
+ const { fileNameHash } = require_bridge_worker.workerCache.get(resolvedConfig.mainConfig || resolvedConfig);
120
+ let match = workerAssetUrlRE.exec(code);
121
+ while (match) {
122
+ const [full, hash] = match;
123
+ const replacement = require_bridge_build.toOutputFilePathInJS(fileNameHash.get(hash), "asset", chunk.fileName, "js", resolvedConfig, toRelativeRuntime);
124
+ const replacementString = typeof replacement === "string" ? JSON.stringify(require_bridge_utils.encodeURIPath(replacement)).slice(1, -1) : `"+${replacement.runtime}+"`;
125
+ s.update(match.index, match.index + full.length, replacementString);
126
+ match = workerAssetUrlRE.exec(code);
127
+ }
128
+ }
129
+ return result();
130
+ },
131
+ generateBundle(_, bundle) {
132
+ if (isWorker) return;
133
+ const workerMap = require_bridge_worker.workerCache.get(resolvedConfig);
134
+ for (const asset of workerMap.assets.values()) {
135
+ const duplicateAsset = bundle[asset.fileName];
136
+ if (duplicateAsset) {
137
+ if (require_bridge_worker.isSameContent(duplicateAsset.type === "asset" ? duplicateAsset.source : duplicateAsset.code, asset.source)) return;
138
+ }
139
+ this.emitFile({
140
+ type: "asset",
141
+ fileName: asset.fileName,
142
+ source: asset.source
143
+ });
144
+ }
145
+ workerMap.assets.clear();
146
+ }
147
+ };
222
148
  }
223
-
149
+ //#endregion
224
150
  exports.workerPlugin = workerPlugin;