@coderline/alphatab-vite 1.9.0-alpha.1785 → 1.9.0-alpha.1861
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/copyAssetsPlugin.cjs +102 -163
- package/dist/copyAssetsPlugin.mjs +103 -138
- package/dist/detectionGlobalPlugin.cjs +65 -68
- package/dist/detectionGlobalPlugin.mjs +62 -64
- package/dist/dist.cjs +6629 -0
- package/dist/dist.mjs +6623 -0
- package/dist/importMetaPlugin.cjs +147 -192
- package/dist/importMetaPlugin.mjs +143 -188
- package/dist/prompt-B1Yc1NPt.cjs +885 -0
- package/dist/prompt-B1Yc1NPt.mjs +882 -0
- package/dist/rolldown-runtime.cjs +63 -0
- package/dist/workerPlugin.cjs +145 -219
- package/dist/workerPlugin.mjs +141 -196
- package/package.json +15 -12
package/dist/bridge/worker.mjs
CHANGED
|
@@ -1,180 +1,195 @@
|
|
|
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
|
-
|
|
42
|
-
// index.ts for more details on contents and license of this file
|
|
2
|
+
* alphaTab Vite Plugin v1.9.0-alpha.1861 (develop, build 1861)
|
|
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
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
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
|
-
|
|
55
|
-
|
|
56
|
-
|
|
52
|
+
* @internal
|
|
53
|
+
*/
|
|
54
|
+
var workerCache = /* @__PURE__ */ new WeakMap();
|
|
57
55
|
/**
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
56
|
+
* @internal
|
|
57
|
+
*/
|
|
58
|
+
var WORKER_FILE_ID = "alphatab_worker";
|
|
61
59
|
/**
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
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
|
-
|
|
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
|
-
|
|
73
|
-
|
|
67
|
+
* @internal
|
|
68
|
+
*/
|
|
74
69
|
async function workerFileToUrl(config, id) {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
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
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
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
|
-
|
|
169
|
-
|
|
185
|
+
* @internal
|
|
186
|
+
*/
|
|
170
187
|
function isSameContent(a, b) {
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
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 };
|
|
@@ -1,168 +1,107 @@
|
|
|
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
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
46
|
-
function _interopNamespaceDefault(e) {
|
|
47
|
-
const n = Object.create(null, { [Symbol.toStringTag]: { value: 'Module' } });
|
|
48
|
-
if (e) {
|
|
49
|
-
for (const k in e) {
|
|
50
|
-
if (k !== 'default') {
|
|
51
|
-
const d = Object.getOwnPropertyDescriptor(e, k);
|
|
52
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
53
|
-
enumerable: true,
|
|
54
|
-
get: () => e[k]
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
n.default = e;
|
|
60
|
-
return Object.freeze(n);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
const path__namespace = /*#__PURE__*/_interopNamespaceDefault(path);
|
|
64
|
-
const url__namespace = /*#__PURE__*/_interopNamespaceDefault(url);
|
|
65
|
-
|
|
2
|
+
* alphaTab Vite Plugin v1.9.0-alpha.1861 (develop, build 1861)
|
|
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_rolldown_runtime = require("./rolldown-runtime.cjs");
|
|
38
|
+
let node_fs = require("node:fs");
|
|
39
|
+
node_fs = require_rolldown_runtime.__toESM(node_fs, 1);
|
|
40
|
+
let node_path = require("node:path");
|
|
41
|
+
node_path = require_rolldown_runtime.__toESM(node_path, 1);
|
|
42
|
+
let node_url = require("node:url");
|
|
43
|
+
node_url = require_rolldown_runtime.__toESM(node_url, 1);
|
|
44
|
+
//#region src/copyAssetsPlugin.ts
|
|
66
45
|
/**
|
|
67
|
-
|
|
68
|
-
|
|
46
|
+
* @public
|
|
47
|
+
*/
|
|
69
48
|
function copyAssetsPlugin(options) {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
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
|
-
if (alphaTabSourceDir) {
|
|
127
|
-
try {
|
|
128
|
-
await fs.promises.access(path__namespace.join(alphaTabSourceDir, 'alphaTab.mjs'), fs.constants.F_OK);
|
|
129
|
-
isValidAlphaTabSourceDir = true;
|
|
130
|
-
}
|
|
131
|
-
catch {
|
|
132
|
-
isValidAlphaTabSourceDir = false;
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
else {
|
|
136
|
-
isValidAlphaTabSourceDir = false;
|
|
137
|
-
}
|
|
138
|
-
if (!isValidAlphaTabSourceDir) {
|
|
139
|
-
resolvedConfig.logger.error('Could not find alphaTab, please ensure it is installed into node_modules or configure alphaTabSourceDir');
|
|
140
|
-
return;
|
|
141
|
-
}
|
|
142
|
-
const outputPath = (options.assetOutputDir ?? resolvedConfig.publicDir);
|
|
143
|
-
if (!outputPath) {
|
|
144
|
-
return;
|
|
145
|
-
}
|
|
146
|
-
async function copyFiles(subdir) {
|
|
147
|
-
const fullDir = path__namespace.join(alphaTabSourceDir, subdir);
|
|
148
|
-
const files = await fs.promises.readdir(fullDir, {
|
|
149
|
-
withFileTypes: true
|
|
150
|
-
});
|
|
151
|
-
await fs.promises.mkdir(path__namespace.join(outputPath, subdir), {
|
|
152
|
-
recursive: true
|
|
153
|
-
});
|
|
154
|
-
await Promise.all(files
|
|
155
|
-
.filter(f => f.isFile())
|
|
156
|
-
.map(async (file) => {
|
|
157
|
-
// node v20.12.0 has parentPath pointing to the path (not the file)
|
|
158
|
-
// see https://github.com/nodejs/node/pull/50976
|
|
159
|
-
const sourceFilename = path__namespace.join(file.parentPath ?? file.path, file.name);
|
|
160
|
-
await fs.promises.copyFile(sourceFilename, path__namespace.join(outputPath, subdir, file.name));
|
|
161
|
-
}));
|
|
162
|
-
}
|
|
163
|
-
await Promise.all([copyFiles('font'), copyFiles('soundfont')]);
|
|
164
|
-
}
|
|
165
|
-
};
|
|
49
|
+
let resolvedConfig;
|
|
50
|
+
let output = false;
|
|
51
|
+
return {
|
|
52
|
+
name: "vite-plugin-alphatab-copy",
|
|
53
|
+
enforce: "pre",
|
|
54
|
+
configResolved(config) {
|
|
55
|
+
resolvedConfig = config;
|
|
56
|
+
},
|
|
57
|
+
buildEnd() {
|
|
58
|
+
output = false;
|
|
59
|
+
},
|
|
60
|
+
async buildStart() {
|
|
61
|
+
if (output) return;
|
|
62
|
+
output = true;
|
|
63
|
+
let alphaTabSourceDir = options.alphaTabSourceDir;
|
|
64
|
+
if (!alphaTabSourceDir) try {
|
|
65
|
+
if (typeof {}.url === "string") alphaTabSourceDir = node_url.fileURLToPath({}.resolve("@coderline/alphatab"));
|
|
66
|
+
else alphaTabSourceDir = require.resolve("@coderline/alphatab");
|
|
67
|
+
alphaTabSourceDir = node_path.resolve(alphaTabSourceDir, "..");
|
|
68
|
+
while (alphaTabSourceDir) if (await node_fs.default.promises.access(node_path.join(alphaTabSourceDir, "package.json"), node_fs.default.constants.F_OK).then(() => true).catch(() => false)) {
|
|
69
|
+
alphaTabSourceDir = node_path.resolve(alphaTabSourceDir, "dist");
|
|
70
|
+
break;
|
|
71
|
+
} else {
|
|
72
|
+
const parent = node_path.resolve(alphaTabSourceDir, "..");
|
|
73
|
+
if (parent === alphaTabSourceDir) alphaTabSourceDir = void 0;
|
|
74
|
+
else alphaTabSourceDir = parent;
|
|
75
|
+
}
|
|
76
|
+
} catch {
|
|
77
|
+
alphaTabSourceDir = node_path.join(resolvedConfig.root, "node_modules/@coderline/alphatab/dist/");
|
|
78
|
+
}
|
|
79
|
+
let isValidAlphaTabSourceDir;
|
|
80
|
+
if (alphaTabSourceDir) try {
|
|
81
|
+
await node_fs.default.promises.access(node_path.join(alphaTabSourceDir, "alphaTab.mjs"), node_fs.default.constants.F_OK);
|
|
82
|
+
isValidAlphaTabSourceDir = true;
|
|
83
|
+
} catch {
|
|
84
|
+
isValidAlphaTabSourceDir = false;
|
|
85
|
+
}
|
|
86
|
+
else isValidAlphaTabSourceDir = false;
|
|
87
|
+
if (!isValidAlphaTabSourceDir) {
|
|
88
|
+
resolvedConfig.logger.error("Could not find alphaTab, please ensure it is installed into node_modules or configure alphaTabSourceDir");
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
const outputPath = options.assetOutputDir ?? resolvedConfig.publicDir;
|
|
92
|
+
if (!outputPath) return;
|
|
93
|
+
async function copyFiles(subdir) {
|
|
94
|
+
const fullDir = node_path.join(alphaTabSourceDir, subdir);
|
|
95
|
+
const files = await node_fs.default.promises.readdir(fullDir, { withFileTypes: true });
|
|
96
|
+
await node_fs.default.promises.mkdir(node_path.join(outputPath, subdir), { recursive: true });
|
|
97
|
+
await Promise.all(files.filter((f) => f.isFile()).map(async (file) => {
|
|
98
|
+
const sourceFilename = node_path.join(file.parentPath ?? file.path, file.name);
|
|
99
|
+
await node_fs.default.promises.copyFile(sourceFilename, node_path.join(outputPath, subdir, file.name));
|
|
100
|
+
}));
|
|
101
|
+
}
|
|
102
|
+
await Promise.all([copyFiles("font"), copyFiles("soundfont")]);
|
|
103
|
+
}
|
|
104
|
+
};
|
|
166
105
|
}
|
|
167
|
-
|
|
106
|
+
//#endregion
|
|
168
107
|
exports.copyAssetsPlugin = copyAssetsPlugin;
|