@coderline/alphatab-vite 1.7.0-alpha.1617 → 1.7.0-alpha.1625

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.
@@ -0,0 +1,148 @@
1
+ /*!
2
+ * alphaTab Vite Plugin v1.7.0-alpha.1625 (develop, build 1625)
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 { normalizePath } from 'vite';
40
+ import { METADATA_FILENAME } from './constants.mjs';
41
+ import { tryFsResolve } from './resolve.mjs';
42
+ import { cleanUrl } from './utils.mjs';
43
+
44
+ // index.ts for more details on contents and license of this file
45
+ // https://github.com/Danielku15/vite/blob/88b7def341f12d07d7d4f83cbe3dc73cc8c6b7be/packages/vite/src/node/optimizer/index.ts#L1356
46
+ /**
47
+ * @internal
48
+ */
49
+ function tryOptimizedDepResolve(config, ssr, url, depId, preserveSymlinks) {
50
+ const optimizer = getDepsOptimizer(config, ssr);
51
+ if (optimizer?.isOptimizedDepFile(depId)) {
52
+ const depFile = cleanUrl(depId);
53
+ const info = optimizedDepInfoFromFile(optimizer.metadata, depFile);
54
+ const depSrc = info?.src;
55
+ if (depSrc) {
56
+ const resolvedFile = path.resolve(path.dirname(depSrc), url);
57
+ return tryFsResolve(resolvedFile, preserveSymlinks);
58
+ }
59
+ }
60
+ return undefined;
61
+ }
62
+ // https://github.com/Danielku15/vite/blob/88b7def341f12d07d7d4f83cbe3dc73cc8c6b7be/packages/vite/src/node/optimizer/optimizer.ts#L32-L40
63
+ const depsOptimizerMap = new WeakMap();
64
+ const devSsrDepsOptimizerMap = new WeakMap();
65
+ function getDepsOptimizer(config, ssr) {
66
+ const map = ssr ? devSsrDepsOptimizerMap : depsOptimizerMap;
67
+ let optimizer = map.get(config);
68
+ if (!optimizer) {
69
+ optimizer = createDepsOptimizer(config);
70
+ map.set(config, optimizer);
71
+ }
72
+ return optimizer;
73
+ }
74
+ // https://github.com/vitejs/vite/blob/b7ddfae5f852c2948fab03e94751ce56f5f31ce0/packages/vite/src/node/optimizer/optimizer.ts#L79
75
+ function createDepsOptimizer(config) {
76
+ const depsCacheDirPrefix = normalizePath(path.resolve(config.cacheDir, 'deps'));
77
+ const metadata = parseDepsOptimizerMetadata(fs.readFileSync(path.join(depsCacheDirPrefix, METADATA_FILENAME), 'utf8'), depsCacheDirPrefix);
78
+ const notImplemented = () => {
79
+ throw new Error('not implemented');
80
+ };
81
+ const depsOptimizer = {
82
+ async init() { },
83
+ metadata,
84
+ registerMissingImport: notImplemented,
85
+ run: notImplemented,
86
+ // https://github.com/vitejs/vite/blob/b7ddfae5f852c2948fab03e94751ce56f5f31ce0/packages/vite/src/node/optimizer/index.ts#L916
87
+ isOptimizedDepFile: id => id.startsWith(depsCacheDirPrefix),
88
+ isOptimizedDepUrl: notImplemented,
89
+ getOptimizedDepId: notImplemented,
90
+ close: notImplemented,
91
+ options: {}
92
+ };
93
+ return depsOptimizer;
94
+ }
95
+ // https://github.com/vitejs/vite/blob/b7ddfae5f852c2948fab03e94751ce56f5f31ce0/packages/vite/src/node/optimizer/index.ts#L944
96
+ function parseDepsOptimizerMetadata(jsonMetadata, depsCacheDir) {
97
+ const { hash, lockfileHash, configHash, browserHash, optimized, chunks } = JSON.parse(jsonMetadata, (key, value) => {
98
+ if (key === 'file' || key === 'src') {
99
+ return normalizePath(path.resolve(depsCacheDir, value));
100
+ }
101
+ return value;
102
+ });
103
+ if (!chunks || Object.values(optimized).some(depInfo => !depInfo.fileHash)) {
104
+ // outdated _metadata.json version, ignore
105
+ return;
106
+ }
107
+ const metadata = {
108
+ hash,
109
+ lockfileHash,
110
+ configHash,
111
+ browserHash,
112
+ optimized: {},
113
+ discovered: {},
114
+ chunks: {},
115
+ depInfoList: []
116
+ };
117
+ for (const id of Object.keys(optimized)) {
118
+ addOptimizedDepInfo(metadata, 'optimized', {
119
+ ...optimized[id],
120
+ id,
121
+ browserHash
122
+ });
123
+ }
124
+ for (const id of Object.keys(chunks)) {
125
+ addOptimizedDepInfo(metadata, 'chunks', {
126
+ ...chunks[id],
127
+ id,
128
+ browserHash,
129
+ needsInterop: false
130
+ });
131
+ }
132
+ return metadata;
133
+ }
134
+ // https://github.com/vitejs/vite/blob/b7ddfae5f852c2948fab03e94751ce56f5f31ce0/packages/vite/src/node/optimizer/index.ts#L322
135
+ function addOptimizedDepInfo(metadata, type, depInfo) {
136
+ metadata[type][depInfo.id] = depInfo;
137
+ metadata.depInfoList.push(depInfo);
138
+ return depInfo;
139
+ }
140
+ // https://github.com/vitejs/vite/blob/b7ddfae5f852c2948fab03e94751ce56f5f31ce0/packages/vite/src/node/optimizer/index.ts#L1248
141
+ /**
142
+ * @internal
143
+ */
144
+ function optimizedDepInfoFromFile(metadata, file) {
145
+ return metadata.depInfoList.find(depInfo => depInfo.file === file);
146
+ }
147
+
148
+ export { optimizedDepInfoFromFile, tryOptimizedDepResolve };
@@ -0,0 +1,47 @@
1
+ /*!
2
+ * alphaTab Vite Plugin v1.7.0-alpha.1625 (develop, build 1625)
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
+ // index.ts for more details on contents and license of this file
38
+ // https://github.com/vitejs/vite/blob/v6.1.1/packages/vite/src/node/plugins/index.ts#L161
39
+ /**
40
+ * @internal
41
+ */
42
+ // biome-ignore lint/complexity/noBannedTypes: Function type needed here
43
+ function getHookHandler(hook) {
44
+ return (typeof hook === 'object' ? hook.handler : hook);
45
+ }
46
+
47
+ export { getHookHandler };
@@ -0,0 +1,71 @@
1
+ /*!
2
+ * alphaTab Vite Plugin v1.7.0-alpha.1625 (develop, build 1625)
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 { normalizePath } from 'vite';
38
+ import { tryResolveRealFile } from './fsUtils.mjs';
39
+ import { cleanUrl } from './utils.mjs';
40
+
41
+ // index.ts for more details on contents and license of this file
42
+ // https://github.com/vitejs/vite/blob/b7ddfae5f852c2948fab03e94751ce56f5f31ce0/packages/vite/src/node/plugins/resolve.ts#L534
43
+ function splitFileAndPostfix(path) {
44
+ const file = cleanUrl(path);
45
+ return { file, postfix: path.slice(file.length) };
46
+ }
47
+ // https://github.com/vitejs/vite/blob/b7ddfae5f852c2948fab03e94751ce56f5f31ce0/packages/vite/src/node/plugins/resolve.ts#L566-L574
48
+ /**
49
+ * @internal
50
+ */
51
+ function tryFsResolve(fsPath, preserveSymlinks) {
52
+ const { file, postfix } = splitFileAndPostfix(fsPath);
53
+ const res = tryCleanFsResolve(file, preserveSymlinks);
54
+ if (res) {
55
+ return res + postfix;
56
+ }
57
+ return;
58
+ }
59
+ // https://github.com/vitejs/vite/blob/b7ddfae5f852c2948fab03e94751ce56f5f31ce0/packages/vite/src/node/plugins/resolve.ts#L580
60
+ function tryCleanFsResolve(file, preserveSymlinks) {
61
+ if (file.includes('node_modules')) {
62
+ return tryResolveRealFile(file, preserveSymlinks);
63
+ }
64
+ const normalizedResolved = tryResolveRealFile(normalizePath(file));
65
+ if (!normalizedResolved) {
66
+ return tryResolveRealFile(file, preserveSymlinks);
67
+ }
68
+ return normalizedResolved;
69
+ }
70
+
71
+ export { tryFsResolve };
@@ -0,0 +1,3 @@
1
+ import type { ObjectHook, MinimalPluginContext as RollupMinimalPluginContext, Plugin as RollupPlugin } from 'rollup';
2
+ type RollupPluginHooksContext = GetHookContextMap<RollupPlugin>;
3
+ export {};
@@ -0,0 +1,36 @@
1
+ /*!
2
+ * alphaTab Vite Plugin v1.7.0-alpha.1625 (develop, build 1625)
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
+
@@ -0,0 +1,151 @@
1
+ /*!
2
+ * alphaTab Vite Plugin v1.7.0-alpha.1625 (develop, build 1625)
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 { createHash } from 'node:crypto';
39
+
40
+ // index.ts for more details on contents and license of this file
41
+ // https://github.com/vitejs/vite/blob/b7ddfae5f852c2948fab03e94751ce56f5f31ce0/packages/vite/src/node/utils.ts#L1302
42
+ /**
43
+ * @internal
44
+ */
45
+ function evalValue(rawValue) {
46
+ const fn = new Function(`
47
+ var console, exports, global, module, process, require
48
+ return (\n${rawValue}\n)
49
+ `);
50
+ return fn();
51
+ }
52
+ // https://github.com/vitejs/vite/blob/b7ddfae5f852c2948fab03e94751ce56f5f31ce0/packages/vite/src/shared/utils.ts#L31-L34
53
+ const postfixRE = /[?#].*$/;
54
+ /**
55
+ * @internal
56
+ */
57
+ function cleanUrl(url) {
58
+ return url.replace(postfixRE, '');
59
+ }
60
+ // https://github.com/vitejs/vite/blob/b7ddfae5f852c2948fab03e94751ce56f5f31ce0/packages/vite/src/node/utils.ts#L393
61
+ /**
62
+ * @internal
63
+ */
64
+ function tryStatSync(file) {
65
+ try {
66
+ // The "throwIfNoEntry" is a performance optimization for cases where the file does not exist
67
+ return fs.statSync(file, { throwIfNoEntry: false });
68
+ }
69
+ catch {
70
+ // Ignore errors
71
+ }
72
+ return;
73
+ }
74
+ // https://github.com/vitejs/vite/blob/b7ddfae5f852c2948fab03e94751ce56f5f31ce0/packages/vite/src/node/utils.ts#L1030
75
+ /**
76
+ * @internal
77
+ */
78
+ function getHash(text, length = 8) {
79
+ const h = createHash('sha256').update(text).digest('hex').substring(0, length);
80
+ if (length <= 64) {
81
+ return h;
82
+ }
83
+ return h.padEnd(length, '_');
84
+ }
85
+ // https://github.com/vitejs/vite/blob/b7ddfae5f852c2948fab03e94751ce56f5f31ce0/packages/vite/src/shared/utils.ts#L40
86
+ /**
87
+ * @internal
88
+ */
89
+ function withTrailingSlash(path) {
90
+ if (path[path.length - 1] !== '/') {
91
+ return `${path}/`;
92
+ }
93
+ return path;
94
+ }
95
+ // https://github.com/vitejs/vite/blob/b7ddfae5f852c2948fab03e94751ce56f5f31ce0/packages/vite/src/node/utils.ts#L1268
96
+ /**
97
+ * @internal
98
+ */
99
+ function joinUrlSegments(a, b) {
100
+ if (!a || !b) {
101
+ return a || b || '';
102
+ }
103
+ if (a[a.length - 1] === '/') {
104
+ a = a.substring(0, a.length - 1);
105
+ }
106
+ if (b[0] !== '/') {
107
+ b = `/${b}`;
108
+ }
109
+ return a + b;
110
+ }
111
+ // https://github.com/vitejs/vite/blob/b7ddfae5f852c2948fab03e94751ce56f5f31ce0/packages/vite/src/node/utils.ts#L1281
112
+ /**
113
+ * @internal
114
+ */
115
+ function removeLeadingSlash(str) {
116
+ return str[0] === '/' ? str.slice(1) : str;
117
+ }
118
+ // https://github.com/vitejs/vite/blob/b7ddfae5f852c2948fab03e94751ce56f5f31ce0/packages/vite/src/node/utils.ts#L319
119
+ /**
120
+ * @internal
121
+ */
122
+ function injectQuery(builtUrl, query) {
123
+ const queryIndex = builtUrl.indexOf('?');
124
+ return builtUrl + (queryIndex === -1 ? '?' : '&') + query;
125
+ }
126
+ // https://github.com/vitejs/vite/blob/b7ddfae5f852c2948fab03e94751ce56f5f31ce0/packages/vite/src/node/utils.ts#L1435
127
+ /**
128
+ * @internal
129
+ */
130
+ function partialEncodeURIPath(uri) {
131
+ if (uri.startsWith('data:')) {
132
+ return uri;
133
+ }
134
+ const filePath = cleanUrl(uri);
135
+ const postfix = filePath !== uri ? uri.slice(filePath.length) : '';
136
+ return filePath.replaceAll('%', '%25') + postfix;
137
+ }
138
+ // https://github.com/vitejs/vite/blob/b7ddfae5f852c2948fab03e94751ce56f5f31ce0/packages/vite/src/node/utils.ts#L1424
139
+ /**
140
+ * @internal
141
+ */
142
+ function encodeURIPath(uri) {
143
+ if (uri.startsWith('data:')) {
144
+ return uri;
145
+ }
146
+ const filePath = cleanUrl(uri);
147
+ const postfix = filePath !== uri ? uri.slice(filePath.length) : '';
148
+ return encodeURI(filePath) + postfix;
149
+ }
150
+
151
+ export { cleanUrl, encodeURIPath, evalValue, getHash, injectQuery, joinUrlSegments, partialEncodeURIPath, removeLeadingSlash, tryStatSync, withTrailingSlash };
@@ -0,0 +1,10 @@
1
+ type WorkerBundleAsset = {
2
+ fileName: string;
3
+ source: string | Uint8Array;
4
+ };
5
+ interface WorkerCache {
6
+ assets: Map<string, WorkerBundleAsset>;
7
+ bundle: Map<string, string>;
8
+ fileNameHash: Map<string, string>;
9
+ }
10
+ export {};
@@ -0,0 +1,180 @@
1
+ /*!
2
+ * alphaTab Vite Plugin v1.7.0-alpha.1625 (develop, build 1625)
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,5 @@
1
+ import type { AlphaTabVitePluginOptions } from './AlphaTabVitePluginOptions';
2
+ /**
3
+ * @public
4
+ */
5
+ export declare function copyAssetsPlugin(options: AlphaTabVitePluginOptions): Plugin;