@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,180 +1,195 @@
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 { cleanUrl, getHash } from './utils.mjs';
38
- import * as path from 'node:path';
39
- import { BuildEnvironment } from 'vite';
40
- import { injectEnvironmentToHooks } from './build.mjs';
41
-
42
- // index.ts for more details on contents and license of this file
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, getHash } from "./utils.mjs";
37
+ import { injectEnvironmentToHooks } from "./build.mjs";
38
+ import { BundlerKind, detectBundler } from "./bundler.mjs";
39
+ import * as path$1 from "node:path";
40
+ import { BuildEnvironment } from "vite";
41
+ //#region src/bridge/worker.ts
43
42
  /**
44
- * @internal
45
- */
46
- // biome-ignore lint/suspicious/noConstEnum: Exception where we use them
47
- var AlphaTabWorkerTypes;
48
- (function (AlphaTabWorkerTypes) {
49
- AlphaTabWorkerTypes["WorkerClassic"] = "worker_classic";
50
- AlphaTabWorkerTypes["WorkerModule"] = "worker_module";
51
- AlphaTabWorkerTypes["AudioWorklet"] = "audio_worklet";
52
- })(AlphaTabWorkerTypes || (AlphaTabWorkerTypes = {}));
43
+ * @internal
44
+ */
45
+ var AlphaTabWorkerTypes = /* @__PURE__ */ function(AlphaTabWorkerTypes) {
46
+ AlphaTabWorkerTypes["WorkerClassic"] = "worker_classic";
47
+ AlphaTabWorkerTypes["WorkerModule"] = "worker_module";
48
+ AlphaTabWorkerTypes["AudioWorklet"] = "audio_worklet";
49
+ return AlphaTabWorkerTypes;
50
+ }({});
53
51
  /**
54
- * @internal
55
- */
56
- const workerCache = new WeakMap();
52
+ * @internal
53
+ */
54
+ var workerCache = /* @__PURE__ */ new WeakMap();
57
55
  /**
58
- * @internal
59
- */
60
- const WORKER_FILE_ID = 'alphatab_worker';
56
+ * @internal
57
+ */
58
+ var WORKER_FILE_ID = "alphatab_worker";
61
59
  /**
62
- * @internal
63
- */
64
- const WORKER_ASSET_ID = '__ALPHATAB_WORKER_ASSET__';
65
- // https://github.com/vitejs/vite/blob/b7ddfae5f852c2948fab03e94751ce56f5f31ce0/packages/vite/src/node/plugins/worker.ts#L47
60
+ * @internal
61
+ */
62
+ var WORKER_ASSET_ID = "__ALPHATAB_WORKER_ASSET__";
66
63
  function saveEmitWorkerAsset(config, asset) {
67
- const workerMap = workerCache.get(config.mainConfig || config);
68
- workerMap.assets.set(asset.fileName, asset);
64
+ workerCache.get(config.mainConfig || config).assets.set(asset.fileName, asset);
69
65
  }
70
- // https://github.com/vitejs/vite/blob/b7ddfae5f852c2948fab03e94751ce56f5f31ce0/packages/vite/src/node/plugins/worker.ts#L161
71
66
  /**
72
- * @internal
73
- */
67
+ * @internal
68
+ */
74
69
  async function workerFileToUrl(config, id) {
75
- const workerMap = workerCache.get(config.mainConfig || config);
76
- let fileName = workerMap.bundle.get(id);
77
- if (!fileName) {
78
- const outputChunk = await bundleWorkerEntry(config, id);
79
- fileName = outputChunk.fileName;
80
- saveEmitWorkerAsset(config, {
81
- fileName,
82
- source: outputChunk.code
83
- });
84
- workerMap.bundle.set(id, fileName);
85
- }
86
- return encodeWorkerAssetFileName(fileName, workerMap);
70
+ const workerMap = workerCache.get(config.mainConfig || config);
71
+ let fileName = workerMap.bundle.get(id);
72
+ if (!fileName) {
73
+ const outputChunk = await bundleWorkerEntry(config, id);
74
+ fileName = outputChunk.fileName;
75
+ saveEmitWorkerAsset(config, {
76
+ fileName,
77
+ source: outputChunk.code
78
+ });
79
+ workerMap.bundle.set(id, fileName);
80
+ }
81
+ return encodeWorkerAssetFileName(fileName, workerMap);
87
82
  }
88
- // https://github.com/vitejs/vite/blob/b7ddfae5f852c2948fab03e94751ce56f5f31ce0/packages/vite/src/node/plugins/worker.ts#L149
89
83
  function encodeWorkerAssetFileName(fileName, workerCache) {
90
- const { fileNameHash } = workerCache;
91
- const hash = getHash(fileName);
92
- if (!fileNameHash.get(hash)) {
93
- fileNameHash.set(hash, fileName);
94
- }
95
- return `${WORKER_ASSET_ID}${hash}__`;
84
+ const { fileNameHash } = workerCache;
85
+ const hash = getHash(fileName);
86
+ if (!fileNameHash.get(hash)) fileNameHash.set(hash, fileName);
87
+ return `${WORKER_ASSET_ID}${hash}__`;
96
88
  }
97
- // https://github.com/vitejs/vite/blob/b7ddfae5f852c2948fab03e94751ce56f5f31ce0/packages/vite/src/node/plugins/worker.ts#L55
98
89
  async function bundleWorkerEntry(config, id) {
99
- const input = cleanUrl(id);
100
- const bundleChain = config.bundleChain ?? [];
101
- const newBundleChain = [...bundleChain, input];
102
- if (bundleChain.includes(input)) {
103
- throw new Error(`Circular worker imports detected. Vite does not support it. Import chain: ${newBundleChain.join(' -> ')}`);
104
- }
105
- // bundle the file as entry to support imports
106
- const { rollup } = await import('rollup');
107
- const { plugins, rollupOptions, format } = config.worker;
108
- const workerConfig = await plugins(newBundleChain);
109
- const workerEnvironment = new BuildEnvironment('client', workerConfig); // TODO: should this be 'worker'?
110
- await workerEnvironment.init();
111
- const bundle = await rollup({
112
- ...rollupOptions,
113
- input,
114
- plugins: workerEnvironment.plugins.map(p => injectEnvironmentToHooks(workerEnvironment, p)),
115
- preserveEntrySignatures: false
116
- });
117
- let chunk;
118
- try {
119
- const workerOutputConfig = config.worker.rollupOptions.output;
120
- const workerConfig = workerOutputConfig
121
- ? Array.isArray(workerOutputConfig)
122
- ? workerOutputConfig[0] || {}
123
- : workerOutputConfig
124
- : {};
125
- const { output: [outputChunk, ...outputChunks] } = await bundle.generate({
126
- entryFileNames: path.posix.join(config.build.assetsDir, '[name]-[hash].js'),
127
- chunkFileNames: path.posix.join(config.build.assetsDir, '[name]-[hash].js'),
128
- assetFileNames: path.posix.join(config.build.assetsDir, '[name]-[hash].[ext]'),
129
- ...workerConfig,
130
- format,
131
- sourcemap: config.build.sourcemap
132
- });
133
- chunk = outputChunk;
134
- for (const outputChunk of outputChunks) {
135
- if (outputChunk.type === 'asset') {
136
- saveEmitWorkerAsset(config, outputChunk);
137
- }
138
- else if (outputChunk.type === 'chunk') {
139
- saveEmitWorkerAsset(config, {
140
- fileName: outputChunk.fileName,
141
- source: outputChunk.code
142
- });
143
- }
144
- }
145
- }
146
- finally {
147
- await bundle.close();
148
- }
149
- return emitSourcemapForWorkerEntry(config, chunk);
90
+ const input = cleanUrl(id);
91
+ const bundleChain = config.bundleChain ?? [];
92
+ const newBundleChain = [...bundleChain, input];
93
+ if (bundleChain.includes(input)) throw new Error(`Circular worker imports detected. Vite does not support it. Import chain: ${newBundleChain.join(" -> ")}`);
94
+ const { plugins, format } = config.worker;
95
+ const workerOptionsCarrier = config.worker;
96
+ const workerBundlerOptions = workerOptionsCarrier.rolldownOptions ?? workerOptionsCarrier.rollupOptions;
97
+ const workerEnvironment = new BuildEnvironment("client", await plugins(newBundleChain));
98
+ await workerEnvironment.init();
99
+ const wrappedPlugins = workerEnvironment.plugins.map((p) => injectEnvironmentToHooks(workerEnvironment, p));
100
+ const workerOutputConfig = workerBundlerOptions.output;
101
+ const outputConfig = workerOutputConfig ? Array.isArray(workerOutputConfig) ? workerOutputConfig[0] || {} : workerOutputConfig : {};
102
+ const generateOptions = {
103
+ entryFileNames: path$1.posix.join(config.build.assetsDir, "[name]-[hash].js"),
104
+ chunkFileNames: path$1.posix.join(config.build.assetsDir, "[name]-[hash].js"),
105
+ assetFileNames: path$1.posix.join(config.build.assetsDir, "[name]-[hash].[ext]"),
106
+ ...outputConfig,
107
+ format,
108
+ sourcemap: config.build.sourcemap
109
+ };
110
+ let chunk;
111
+ if (detectBundler(config) === BundlerKind.Rolldown) chunk = await bundleWorkerEntryRolldown(config, input, workerBundlerOptions, wrappedPlugins, generateOptions, workerEnvironment);
112
+ else chunk = await bundleWorkerEntryRollup(config, input, workerBundlerOptions, wrappedPlugins, generateOptions);
113
+ return emitSourcemapForWorkerEntry(config, chunk);
114
+ }
115
+ async function bundleWorkerEntryRollup(config, input, bundlerOptions, plugins, generateOptions) {
116
+ const { rollup } = await import("rollup");
117
+ const bundle = await rollup({
118
+ ...bundlerOptions,
119
+ input,
120
+ plugins,
121
+ preserveEntrySignatures: false
122
+ });
123
+ try {
124
+ const { output } = await bundle.generate(generateOptions);
125
+ const [outputChunk, ...rest] = output;
126
+ for (const o of rest) if (o.type === "asset") saveEmitWorkerAsset(config, o);
127
+ else saveEmitWorkerAsset(config, {
128
+ fileName: o.fileName,
129
+ source: o.code
130
+ });
131
+ return outputChunk;
132
+ } finally {
133
+ await bundle.close();
134
+ }
135
+ }
136
+ async function bundleWorkerEntryRolldown(config, input, bundlerOptions, plugins, generateOptions, workerEnvironment) {
137
+ const { rolldown } = await import("../dist.mjs");
138
+ const workerBuildTarget = workerEnvironment.config.build.target;
139
+ const bundle = await rolldown({
140
+ ...bundlerOptions,
141
+ input,
142
+ plugins,
143
+ transform: {
144
+ target: workerBuildTarget === false ? void 0 : workerBuildTarget,
145
+ ...bundlerOptions.transform,
146
+ define: {
147
+ ...bundlerOptions.transform?.define,
148
+ "process.env.NODE_ENV": "process.env.NODE_ENV"
149
+ }
150
+ },
151
+ moduleTypes: {
152
+ ".css": "js",
153
+ ...bundlerOptions.moduleTypes
154
+ },
155
+ preserveEntrySignatures: false,
156
+ experimental: {
157
+ ...bundlerOptions.experimental,
158
+ viteMode: true
159
+ }
160
+ });
161
+ try {
162
+ const { output } = await bundle.generate(generateOptions);
163
+ const [outputChunk, ...rest] = output;
164
+ for (const o of rest) if (o.type === "asset") saveEmitWorkerAsset(config, o);
165
+ else saveEmitWorkerAsset(config, {
166
+ fileName: o.fileName,
167
+ source: o.code
168
+ });
169
+ return outputChunk;
170
+ } finally {
171
+ await bundle.close();
172
+ }
150
173
  }
151
- // https://github.com/vitejs/vite/blob/b7ddfae5f852c2948fab03e94751ce56f5f31ce0/packages/vite/src/node/plugins/worker.ts#L124
152
174
  function emitSourcemapForWorkerEntry(config, chunk) {
153
- const { map: sourcemap } = chunk;
154
- if (sourcemap) {
155
- if (config.build.sourcemap === 'hidden' || config.build.sourcemap === true) {
156
- const data = sourcemap.toString();
157
- const mapFileName = `${chunk.fileName}.map`;
158
- saveEmitWorkerAsset(config, {
159
- fileName: mapFileName,
160
- source: data
161
- });
162
- }
163
- }
164
- return chunk;
175
+ const sourcemap = chunk.map;
176
+ if (sourcemap) {
177
+ if (config.build.sourcemap === "hidden" || config.build.sourcemap === true) saveEmitWorkerAsset(config, {
178
+ fileName: `${chunk.fileName}.map`,
179
+ source: sourcemap.toString()
180
+ });
181
+ }
182
+ return chunk;
165
183
  }
166
- // https://github.com/vitejs/vite/blob/b7ddfae5f852c2948fab03e94751ce56f5f31ce0/packages/vite/src/node/plugins/worker.ts#L458
167
184
  /**
168
- * @internal
169
- */
185
+ * @internal
186
+ */
170
187
  function isSameContent(a, b) {
171
- if (typeof a === 'string') {
172
- if (typeof b === 'string') {
173
- return a === b;
174
- }
175
- return Buffer.from(a).equals(b);
176
- }
177
- return Buffer.from(b).equals(a);
188
+ if (typeof a === "string") {
189
+ if (typeof b === "string") return a === b;
190
+ return Buffer.from(a).equals(b);
191
+ }
192
+ return Buffer.from(b).equals(a);
178
193
  }
179
-
194
+ //#endregion
180
195
  export { AlphaTabWorkerTypes, WORKER_ASSET_ID, WORKER_FILE_ID, isSameContent, workerCache, workerFileToUrl };
package/dist/chunk.cjs ADDED
@@ -0,0 +1,63 @@
1
+ /*!
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
+ //#region \0rolldown/runtime.js
37
+ var __create = Object.create;
38
+ var __defProp = Object.defineProperty;
39
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
40
+ var __getOwnPropNames = Object.getOwnPropertyNames;
41
+ var __getProtoOf = Object.getPrototypeOf;
42
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
43
+ var __copyProps = (to, from, except, desc) => {
44
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
45
+ key = keys[i];
46
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
47
+ get: ((k) => from[k]).bind(null, key),
48
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
49
+ });
50
+ }
51
+ return to;
52
+ };
53
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
54
+ value: mod,
55
+ enumerable: true
56
+ }) : target, mod));
57
+ //#endregion
58
+ Object.defineProperty(exports, "__toESM", {
59
+ enumerable: true,
60
+ get: function() {
61
+ return __toESM;
62
+ }
63
+ });