@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.
- 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 +17 -17
package/dist/workerPlugin.mjs
CHANGED
|
@@ -1,201 +1,146 @@
|
|
|
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
|
-
import
|
|
38
|
-
import
|
|
39
|
-
import {
|
|
40
|
-
import
|
|
41
|
-
import
|
|
42
|
-
import
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
// This file contains a customized and adapted version of the Vite built-in worker plugin
|
|
47
|
-
// https://github.com/vitejs/vite/blob/main/packages/vite/src/node/plugins/worker.ts
|
|
48
|
-
// This is more or less a 1:1 copy of the original worker plugin with following adaptions:
|
|
49
|
-
// - Only handle syntax variants known to be used in alphaTab
|
|
50
|
-
// - Use the alphaTab URL markers
|
|
51
|
-
// - Some refactoring for better code understanding
|
|
52
|
-
// With https://github.com/vitejs/vite/pull/16422 integrated this custom code might not be needed anymore
|
|
53
|
-
// Some adjustment for audio worklet in vite might be needed to treat them as type "module" workers
|
|
54
|
-
// Original Sources Licensed under:
|
|
55
|
-
// MIT License
|
|
56
|
-
// Copyright (c) 2019-present, Yuxi (Evan) You and Vite contributors
|
|
57
|
-
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
58
|
-
// of this software and associated documentation files (the "Software"), to deal
|
|
59
|
-
// in the Software without restriction, including without limitation the rights
|
|
60
|
-
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
61
|
-
// copies of the Software, and to permit persons to whom the Software is
|
|
62
|
-
// furnished to do so, subject to the following conditions:
|
|
63
|
-
// The above copyright notice and this permission notice shall be included in all
|
|
64
|
-
// copies or substantial portions of the Software.
|
|
65
|
-
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
66
|
-
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
67
|
-
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
68
|
-
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
69
|
-
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
70
|
-
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
71
|
-
// SOFTWARE.
|
|
72
|
-
const workerFileRE = new RegExp(`(?:\\?|&)${WORKER_FILE_ID}&type=(\\w+)(?:&|$)`);
|
|
73
|
-
const workerAssetUrlRE = new RegExp(`${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
|
+
import { encodeURIPath } from "./bridge/utils.mjs";
|
|
37
|
+
import { ENV_PUBLIC_PATH } from "./bridge/constants.mjs";
|
|
38
|
+
import { createToImportMetaURLBasedRelativeRuntime, toOutputFilePathInJS } from "./bridge/build.mjs";
|
|
39
|
+
import { AlphaTabWorkerTypes, WORKER_ASSET_ID, WORKER_FILE_ID, isSameContent, workerCache } from "./bridge/worker.mjs";
|
|
40
|
+
import "./bridge/index.mjs";
|
|
41
|
+
import MagicString from "magic-string";
|
|
42
|
+
import * as path$1 from "node:path";
|
|
43
|
+
//#region src/workerPlugin.ts
|
|
44
|
+
var workerFileRE = new RegExp(`(?:\\?|&)${WORKER_FILE_ID}&type=(\\w+)(?:&|$)`);
|
|
45
|
+
var workerAssetUrlRE = new RegExp(`${WORKER_ASSET_ID}([a-z\\d]{8})__`, "g");
|
|
74
46
|
/**
|
|
75
|
-
|
|
76
|
-
|
|
47
|
+
* @public
|
|
48
|
+
*/
|
|
77
49
|
function workerPlugin(options) {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
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
|
-
return result();
|
|
175
|
-
},
|
|
176
|
-
generateBundle(_, bundle) {
|
|
177
|
-
if (isWorker) {
|
|
178
|
-
return;
|
|
179
|
-
}
|
|
180
|
-
const workerMap = workerCache.get(resolvedConfig);
|
|
181
|
-
for (const asset of workerMap.assets.values()) {
|
|
182
|
-
const duplicateAsset = bundle[asset.fileName];
|
|
183
|
-
if (duplicateAsset) {
|
|
184
|
-
const content = duplicateAsset.type === 'asset' ? duplicateAsset.source : duplicateAsset.code;
|
|
185
|
-
// don't emit if the file name and the content is same
|
|
186
|
-
if (isSameContent(content, asset.source)) {
|
|
187
|
-
return;
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
this.emitFile({
|
|
191
|
-
type: 'asset',
|
|
192
|
-
fileName: asset.fileName,
|
|
193
|
-
source: asset.source
|
|
194
|
-
});
|
|
195
|
-
}
|
|
196
|
-
workerMap.assets.clear();
|
|
197
|
-
}
|
|
198
|
-
};
|
|
50
|
+
let resolvedConfig;
|
|
51
|
+
let isBuild;
|
|
52
|
+
let isWorker;
|
|
53
|
+
const isWorkerActive = options.webWorkers !== false;
|
|
54
|
+
const isWorkletActive = options.audioWorklets !== false;
|
|
55
|
+
const isActive = isWorkerActive || isWorkletActive;
|
|
56
|
+
return {
|
|
57
|
+
name: "vite-plugin-alphatab-worker",
|
|
58
|
+
configResolved(config) {
|
|
59
|
+
resolvedConfig = config;
|
|
60
|
+
isBuild = config.command === "build";
|
|
61
|
+
isWorker = config.isWorker;
|
|
62
|
+
},
|
|
63
|
+
buildStart() {
|
|
64
|
+
if (!isActive || isWorker) return;
|
|
65
|
+
workerCache.set(resolvedConfig, {
|
|
66
|
+
assets: /* @__PURE__ */ new Map(),
|
|
67
|
+
bundle: /* @__PURE__ */ new Map(),
|
|
68
|
+
fileNameHash: /* @__PURE__ */ new Map()
|
|
69
|
+
});
|
|
70
|
+
},
|
|
71
|
+
load(id) {
|
|
72
|
+
if (isActive && isBuild && id.includes("alphatab_worker")) return "";
|
|
73
|
+
},
|
|
74
|
+
shouldTransformCachedModule({ id }) {
|
|
75
|
+
if (isActive && isBuild && resolvedConfig.build.watch && id.includes("alphatab_worker")) return true;
|
|
76
|
+
},
|
|
77
|
+
async transform(raw, id) {
|
|
78
|
+
if (!isActive) return;
|
|
79
|
+
const match = workerFileRE.exec(id);
|
|
80
|
+
if (!match) return;
|
|
81
|
+
const envScriptPath = JSON.stringify(path$1.posix.join(resolvedConfig.base, ENV_PUBLIC_PATH));
|
|
82
|
+
const workerType = match[1];
|
|
83
|
+
let injectEnv = "";
|
|
84
|
+
switch (workerType) {
|
|
85
|
+
case AlphaTabWorkerTypes.WorkerClassic:
|
|
86
|
+
injectEnv = `importScripts(${envScriptPath})\n`;
|
|
87
|
+
break;
|
|
88
|
+
case AlphaTabWorkerTypes.WorkerModule:
|
|
89
|
+
case AlphaTabWorkerTypes.AudioWorklet:
|
|
90
|
+
injectEnv = `import ${envScriptPath}\n`;
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
if (injectEnv) {
|
|
94
|
+
const s = new MagicString(raw);
|
|
95
|
+
s.prepend(injectEnv);
|
|
96
|
+
return {
|
|
97
|
+
code: s.toString(),
|
|
98
|
+
map: s.generateMap({ hires: "boundary" })
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
renderChunk(code, chunk, outputOptions) {
|
|
103
|
+
let s;
|
|
104
|
+
const result = () => {
|
|
105
|
+
return s && {
|
|
106
|
+
code: s.toString(),
|
|
107
|
+
map: resolvedConfig.build.sourcemap ? s.generateMap({ hires: "boundary" }) : null
|
|
108
|
+
};
|
|
109
|
+
};
|
|
110
|
+
workerAssetUrlRE.lastIndex = 0;
|
|
111
|
+
if (workerAssetUrlRE.test(code)) {
|
|
112
|
+
const toRelativeRuntime = createToImportMetaURLBasedRelativeRuntime(outputOptions.format, resolvedConfig.isWorker);
|
|
113
|
+
s = new MagicString(code);
|
|
114
|
+
workerAssetUrlRE.lastIndex = 0;
|
|
115
|
+
const { fileNameHash } = workerCache.get(resolvedConfig.mainConfig || resolvedConfig);
|
|
116
|
+
let match = workerAssetUrlRE.exec(code);
|
|
117
|
+
while (match) {
|
|
118
|
+
const [full, hash] = match;
|
|
119
|
+
const replacement = toOutputFilePathInJS(fileNameHash.get(hash), "asset", chunk.fileName, "js", resolvedConfig, toRelativeRuntime);
|
|
120
|
+
const replacementString = typeof replacement === "string" ? JSON.stringify(encodeURIPath(replacement)).slice(1, -1) : `"+${replacement.runtime}+"`;
|
|
121
|
+
s.update(match.index, match.index + full.length, replacementString);
|
|
122
|
+
match = workerAssetUrlRE.exec(code);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
return result();
|
|
126
|
+
},
|
|
127
|
+
generateBundle(_, bundle) {
|
|
128
|
+
if (isWorker) return;
|
|
129
|
+
const workerMap = workerCache.get(resolvedConfig);
|
|
130
|
+
for (const asset of workerMap.assets.values()) {
|
|
131
|
+
const duplicateAsset = bundle[asset.fileName];
|
|
132
|
+
if (duplicateAsset) {
|
|
133
|
+
if (isSameContent(duplicateAsset.type === "asset" ? duplicateAsset.source : duplicateAsset.code, asset.source)) return;
|
|
134
|
+
}
|
|
135
|
+
this.emitFile({
|
|
136
|
+
type: "asset",
|
|
137
|
+
fileName: asset.fileName,
|
|
138
|
+
source: asset.source
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
workerMap.assets.clear();
|
|
142
|
+
}
|
|
143
|
+
};
|
|
199
144
|
}
|
|
200
|
-
|
|
145
|
+
//#endregion
|
|
201
146
|
export { workerPlugin };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coderline/alphatab-vite",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.3",
|
|
4
4
|
"description": "A plugin for Vite to bundle alphaTab into your webapps.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"guitar",
|
|
@@ -39,30 +39,30 @@
|
|
|
39
39
|
"lint": "biome lint",
|
|
40
40
|
"typecheck": "tsc --noEmit",
|
|
41
41
|
"build": "vite build",
|
|
42
|
-
"
|
|
42
|
+
"pretest": "node test/fixtures/install.mjs",
|
|
43
|
+
"test": "vitest run",
|
|
44
|
+
"test-web": "npm run test"
|
|
43
45
|
},
|
|
44
46
|
"dependencies": {
|
|
45
|
-
"magic-string": "^0.30.21"
|
|
46
|
-
|
|
47
|
+
"magic-string": "^0.30.21"
|
|
48
|
+
},
|
|
49
|
+
"peerDependencies": {
|
|
50
|
+
"vite": "^7 || ^8"
|
|
47
51
|
},
|
|
48
52
|
"engines": {
|
|
49
53
|
"node": ">=20.19.0"
|
|
50
54
|
},
|
|
51
55
|
"devDependencies": {
|
|
52
|
-
"@biomejs/biome": "^2.
|
|
53
|
-
"@microsoft/api-extractor": "^7.
|
|
54
|
-
"@types/
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"chai": "^6.2.2",
|
|
59
|
-
"mocha": "^11.7.5",
|
|
60
|
-
"rimraf": "^6.1.2",
|
|
61
|
-
"rollup-plugin-node-externals": "^8.1.2",
|
|
62
|
-
"terser": "^5.44.1",
|
|
56
|
+
"@biomejs/biome": "^2.4.15",
|
|
57
|
+
"@microsoft/api-extractor": "^7.57.7",
|
|
58
|
+
"@types/node": "^25.9.1",
|
|
59
|
+
"rimraf": "^6.1.3",
|
|
60
|
+
"rollup-plugin-node-externals": "^9.0.1",
|
|
61
|
+
"terser": "^5.47.1",
|
|
63
62
|
"tslib": "^2.8.1",
|
|
64
|
-
"tsx": "^4.
|
|
65
|
-
"typescript": "^
|
|
63
|
+
"tsx": "^4.22.3",
|
|
64
|
+
"typescript": "^6.0.3",
|
|
65
|
+
"vitest": "^4.1.7"
|
|
66
66
|
},
|
|
67
67
|
"files": [
|
|
68
68
|
"/dist/**",
|