@coderline/alphatab-vite 1.7.0 → 1.8.0-alpha.1632

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 +38 -0
  2. package/dist/AlphaTabVitePluginOptions.d.ts +30 -0
  3. package/dist/AlphaTabVitePluginOptions.mjs +36 -0
  4. package/dist/alphaTab.vite.cjs +45 -0
  5. package/dist/alphaTab.vite.d.ts +1 -33
  6. package/dist/alphaTab.vite.mjs +2 -2328
  7. package/dist/alphaTabVitePlugin.cjs +57 -0
  8. package/dist/alphaTabVitePlugin.d.ts +5 -0
  9. package/dist/alphaTabVitePlugin.mjs +53 -0
  10. package/dist/bridge/asset.cjs +87 -0
  11. package/dist/bridge/asset.mjs +63 -0
  12. package/dist/bridge/build.cjs +242 -0
  13. package/dist/bridge/build.mjs +217 -0
  14. package/dist/bridge/config.cjs +38 -0
  15. package/dist/bridge/config.mjs +36 -0
  16. package/dist/bridge/constants.cjs +88 -0
  17. package/dist/bridge/constants.mjs +82 -0
  18. package/dist/bridge/fsUtils.cjs +60 -0
  19. package/dist/bridge/fsUtils.mjs +56 -0
  20. package/dist/bridge/index.cjs +69 -0
  21. package/dist/bridge/index.mjs +43 -0
  22. package/dist/bridge/optimizer.cjs +172 -0
  23. package/dist/bridge/optimizer.mjs +148 -0
  24. package/dist/bridge/plugins.cjs +51 -0
  25. package/dist/bridge/plugins.mjs +47 -0
  26. package/dist/bridge/resolve.cjs +75 -0
  27. package/dist/bridge/resolve.mjs +71 -0
  28. package/dist/bridge/typeUtils.cjs +38 -0
  29. package/dist/bridge/typeUtils.d.ts +3 -0
  30. package/dist/bridge/typeUtils.mjs +36 -0
  31. package/dist/bridge/utils.cjs +164 -0
  32. package/dist/bridge/utils.mjs +151 -0
  33. package/dist/bridge/worker.cjs +207 -0
  34. package/dist/bridge/worker.d.ts +10 -0
  35. package/dist/bridge/worker.mjs +180 -0
  36. package/dist/copyAssetsPlugin.cjs +168 -0
  37. package/dist/copyAssetsPlugin.d.ts +5 -0
  38. package/dist/copyAssetsPlugin.mjs +143 -0
  39. package/dist/importMetaPlugin.cjs +201 -0
  40. package/dist/importMetaPlugin.d.ts +5 -0
  41. package/dist/importMetaPlugin.mjs +197 -0
  42. package/dist/workerPlugin.cjs +224 -0
  43. package/dist/workerPlugin.d.ts +5 -0
  44. package/dist/workerPlugin.mjs +201 -0
  45. package/package.json +32 -19
  46. package/dist/alphaTab.vite.js +0 -2388
  47. package/dist/alphaTab.vite.min.mjs +0 -36
@@ -0,0 +1,180 @@
1
+ /*!
2
+ * alphaTab Vite Plugin v1.8.0-alpha.1632 (develop, build 1632)
3
+ *
4
+ * Copyright © 2025, 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
43
+ /**
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 = {}));
53
+ /**
54
+ * @internal
55
+ */
56
+ const workerCache = new WeakMap();
57
+ /**
58
+ * @internal
59
+ */
60
+ const WORKER_FILE_ID = 'alphatab_worker';
61
+ /**
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
66
+ function saveEmitWorkerAsset(config, asset) {
67
+ const workerMap = workerCache.get(config.mainConfig || config);
68
+ workerMap.assets.set(asset.fileName, asset);
69
+ }
70
+ // https://github.com/vitejs/vite/blob/b7ddfae5f852c2948fab03e94751ce56f5f31ce0/packages/vite/src/node/plugins/worker.ts#L161
71
+ /**
72
+ * @internal
73
+ */
74
+ 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);
87
+ }
88
+ // https://github.com/vitejs/vite/blob/b7ddfae5f852c2948fab03e94751ce56f5f31ce0/packages/vite/src/node/plugins/worker.ts#L149
89
+ 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}__`;
96
+ }
97
+ // https://github.com/vitejs/vite/blob/b7ddfae5f852c2948fab03e94751ce56f5f31ce0/packages/vite/src/node/plugins/worker.ts#L55
98
+ 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);
150
+ }
151
+ // https://github.com/vitejs/vite/blob/b7ddfae5f852c2948fab03e94751ce56f5f31ce0/packages/vite/src/node/plugins/worker.ts#L124
152
+ 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;
165
+ }
166
+ // https://github.com/vitejs/vite/blob/b7ddfae5f852c2948fab03e94751ce56f5f31ce0/packages/vite/src/node/plugins/worker.ts#L458
167
+ /**
168
+ * @internal
169
+ */
170
+ 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);
178
+ }
179
+
180
+ export { AlphaTabWorkerTypes, WORKER_ASSET_ID, WORKER_FILE_ID, isSameContent, workerCache, workerFileToUrl };
@@ -0,0 +1,168 @@
1
+ /*!
2
+ * alphaTab Vite Plugin v1.8.0-alpha.1632 (develop, build 1632)
3
+ *
4
+ * Copyright © 2025, 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 fs = require('node:fs');
42
+ const path = require('node:path');
43
+ const url = require('node:url');
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
+
66
+ /**
67
+ * @public
68
+ */
69
+ function copyAssetsPlugin(options) {
70
+ let resolvedConfig;
71
+ let output = false;
72
+ return {
73
+ name: 'vite-plugin-alphatab-copy',
74
+ enforce: 'pre',
75
+ configResolved(config) {
76
+ resolvedConfig = config;
77
+ },
78
+ buildEnd() {
79
+ // reset for watch mode
80
+ output = false;
81
+ },
82
+ async buildStart() {
83
+ // run copy only once even if multiple bundles are generated
84
+ if (output) {
85
+ return;
86
+ }
87
+ output = true;
88
+ let alphaTabSourceDir = options.alphaTabSourceDir;
89
+ if (!alphaTabSourceDir) {
90
+ try {
91
+ const isEsm = typeof (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('copyAssetsPlugin.cjs', document.baseURI).href)) === 'string';
92
+ if (isEsm) {
93
+ alphaTabSourceDir = url__namespace.fileURLToPath(undefined('@coderline/alphatab'));
94
+ }
95
+ else {
96
+ alphaTabSourceDir = require.resolve('@coderline/alphatab');
97
+ }
98
+ alphaTabSourceDir = path__namespace.resolve(alphaTabSourceDir, '..');
99
+ // walk up to package.json
100
+ while (alphaTabSourceDir) {
101
+ if (await fs.promises
102
+ .access(path__namespace.join(alphaTabSourceDir, 'package.json'), fs.constants.F_OK)
103
+ .then(() => true)
104
+ .catch(() => false)) {
105
+ // found package directory
106
+ alphaTabSourceDir = path__namespace.resolve(alphaTabSourceDir, 'dist');
107
+ break;
108
+ }
109
+ else {
110
+ // reached root
111
+ const parent = path__namespace.resolve(alphaTabSourceDir, '..');
112
+ if (parent === alphaTabSourceDir) {
113
+ alphaTabSourceDir = undefined;
114
+ }
115
+ else {
116
+ alphaTabSourceDir = parent;
117
+ }
118
+ }
119
+ }
120
+ }
121
+ catch {
122
+ alphaTabSourceDir = path__namespace.join(resolvedConfig.root, 'node_modules/@coderline/alphatab/dist/');
123
+ }
124
+ }
125
+ let isValidAlphaTabSourceDir;
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
+ };
166
+ }
167
+
168
+ exports.copyAssetsPlugin = copyAssetsPlugin;
@@ -0,0 +1,5 @@
1
+ import type { AlphaTabVitePluginOptions } from './AlphaTabVitePluginOptions';
2
+ /**
3
+ * @public
4
+ */
5
+ export declare function copyAssetsPlugin(options: AlphaTabVitePluginOptions): Plugin;
@@ -0,0 +1,143 @@
1
+ /*!
2
+ * alphaTab Vite Plugin v1.8.0-alpha.1632 (develop, build 1632)
3
+ *
4
+ * Copyright © 2025, 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 fs from 'node:fs';
38
+ import * as path from 'node:path';
39
+ import * as url from 'node:url';
40
+
41
+ /**
42
+ * @public
43
+ */
44
+ function copyAssetsPlugin(options) {
45
+ let resolvedConfig;
46
+ let output = false;
47
+ return {
48
+ name: 'vite-plugin-alphatab-copy',
49
+ enforce: 'pre',
50
+ configResolved(config) {
51
+ resolvedConfig = config;
52
+ },
53
+ buildEnd() {
54
+ // reset for watch mode
55
+ output = false;
56
+ },
57
+ async buildStart() {
58
+ // run copy only once even if multiple bundles are generated
59
+ if (output) {
60
+ return;
61
+ }
62
+ output = true;
63
+ let alphaTabSourceDir = options.alphaTabSourceDir;
64
+ if (!alphaTabSourceDir) {
65
+ try {
66
+ const isEsm = typeof import.meta.url === 'string';
67
+ if (isEsm) {
68
+ alphaTabSourceDir = url.fileURLToPath(import.meta.resolve('@coderline/alphatab'));
69
+ }
70
+ else {
71
+ alphaTabSourceDir = require.resolve('@coderline/alphatab');
72
+ }
73
+ alphaTabSourceDir = path.resolve(alphaTabSourceDir, '..');
74
+ // walk up to package.json
75
+ while (alphaTabSourceDir) {
76
+ if (await fs.promises
77
+ .access(path.join(alphaTabSourceDir, 'package.json'), fs.constants.F_OK)
78
+ .then(() => true)
79
+ .catch(() => false)) {
80
+ // found package directory
81
+ alphaTabSourceDir = path.resolve(alphaTabSourceDir, 'dist');
82
+ break;
83
+ }
84
+ else {
85
+ // reached root
86
+ const parent = path.resolve(alphaTabSourceDir, '..');
87
+ if (parent === alphaTabSourceDir) {
88
+ alphaTabSourceDir = undefined;
89
+ }
90
+ else {
91
+ alphaTabSourceDir = parent;
92
+ }
93
+ }
94
+ }
95
+ }
96
+ catch {
97
+ alphaTabSourceDir = path.join(resolvedConfig.root, 'node_modules/@coderline/alphatab/dist/');
98
+ }
99
+ }
100
+ let isValidAlphaTabSourceDir;
101
+ if (alphaTabSourceDir) {
102
+ try {
103
+ await fs.promises.access(path.join(alphaTabSourceDir, 'alphaTab.mjs'), fs.constants.F_OK);
104
+ isValidAlphaTabSourceDir = true;
105
+ }
106
+ catch {
107
+ isValidAlphaTabSourceDir = false;
108
+ }
109
+ }
110
+ else {
111
+ isValidAlphaTabSourceDir = false;
112
+ }
113
+ if (!isValidAlphaTabSourceDir) {
114
+ resolvedConfig.logger.error('Could not find alphaTab, please ensure it is installed into node_modules or configure alphaTabSourceDir');
115
+ return;
116
+ }
117
+ const outputPath = (options.assetOutputDir ?? resolvedConfig.publicDir);
118
+ if (!outputPath) {
119
+ return;
120
+ }
121
+ async function copyFiles(subdir) {
122
+ const fullDir = path.join(alphaTabSourceDir, subdir);
123
+ const files = await fs.promises.readdir(fullDir, {
124
+ withFileTypes: true
125
+ });
126
+ await fs.promises.mkdir(path.join(outputPath, subdir), {
127
+ recursive: true
128
+ });
129
+ await Promise.all(files
130
+ .filter(f => f.isFile())
131
+ .map(async (file) => {
132
+ // node v20.12.0 has parentPath pointing to the path (not the file)
133
+ // see https://github.com/nodejs/node/pull/50976
134
+ const sourceFilename = path.join(file.parentPath ?? file.path, file.name);
135
+ await fs.promises.copyFile(sourceFilename, path.join(outputPath, subdir, file.name));
136
+ }));
137
+ }
138
+ await Promise.all([copyFiles('font'), copyFiles('soundfont')]);
139
+ }
140
+ };
141
+ }
142
+
143
+ export { copyAssetsPlugin };