@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.
- package/dist/AlphaTabVitePluginOptions.cjs +38 -0
- package/dist/AlphaTabVitePluginOptions.d.ts +30 -0
- package/dist/AlphaTabVitePluginOptions.mjs +36 -0
- package/dist/alphaTab.vite.cjs +45 -0
- package/dist/alphaTab.vite.d.ts +1 -33
- package/dist/alphaTab.vite.mjs +2 -2328
- package/dist/alphaTabVitePlugin.cjs +57 -0
- package/dist/alphaTabVitePlugin.d.ts +5 -0
- package/dist/alphaTabVitePlugin.mjs +53 -0
- package/dist/bridge/asset.cjs +87 -0
- package/dist/bridge/asset.mjs +63 -0
- package/dist/bridge/build.cjs +242 -0
- package/dist/bridge/build.mjs +217 -0
- package/dist/bridge/config.cjs +38 -0
- package/dist/bridge/config.mjs +36 -0
- package/dist/bridge/constants.cjs +88 -0
- package/dist/bridge/constants.mjs +82 -0
- package/dist/bridge/fsUtils.cjs +60 -0
- package/dist/bridge/fsUtils.mjs +56 -0
- package/dist/bridge/index.cjs +69 -0
- package/dist/bridge/index.mjs +43 -0
- package/dist/bridge/optimizer.cjs +172 -0
- package/dist/bridge/optimizer.mjs +148 -0
- package/dist/bridge/plugins.cjs +51 -0
- package/dist/bridge/plugins.mjs +47 -0
- package/dist/bridge/resolve.cjs +75 -0
- package/dist/bridge/resolve.mjs +71 -0
- package/dist/bridge/typeUtils.cjs +38 -0
- package/dist/bridge/typeUtils.d.ts +3 -0
- package/dist/bridge/typeUtils.mjs +36 -0
- package/dist/bridge/utils.cjs +164 -0
- package/dist/bridge/utils.mjs +151 -0
- package/dist/bridge/worker.cjs +207 -0
- package/dist/bridge/worker.d.ts +10 -0
- package/dist/bridge/worker.mjs +180 -0
- package/dist/copyAssetsPlugin.cjs +168 -0
- package/dist/copyAssetsPlugin.d.ts +5 -0
- package/dist/copyAssetsPlugin.mjs +143 -0
- package/dist/importMetaPlugin.cjs +201 -0
- package/dist/importMetaPlugin.d.ts +5 -0
- package/dist/importMetaPlugin.mjs +197 -0
- package/dist/workerPlugin.cjs +224 -0
- package/dist/workerPlugin.d.ts +5 -0
- package/dist/workerPlugin.mjs +201 -0
- package/package.json +32 -19
- package/dist/alphaTab.vite.js +0 -2388
- package/dist/alphaTab.vite.min.mjs +0 -36
|
@@ -0,0 +1,36 @@
|
|
|
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
|
+
|
|
@@ -0,0 +1,164 @@
|
|
|
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 node_crypto = require('node:crypto');
|
|
43
|
+
|
|
44
|
+
// index.ts for more details on contents and license of this file
|
|
45
|
+
// https://github.com/vitejs/vite/blob/b7ddfae5f852c2948fab03e94751ce56f5f31ce0/packages/vite/src/node/utils.ts#L1302
|
|
46
|
+
/**
|
|
47
|
+
* @internal
|
|
48
|
+
*/
|
|
49
|
+
function evalValue(rawValue) {
|
|
50
|
+
const fn = new Function(`
|
|
51
|
+
var console, exports, global, module, process, require
|
|
52
|
+
return (\n${rawValue}\n)
|
|
53
|
+
`);
|
|
54
|
+
return fn();
|
|
55
|
+
}
|
|
56
|
+
// https://github.com/vitejs/vite/blob/b7ddfae5f852c2948fab03e94751ce56f5f31ce0/packages/vite/src/shared/utils.ts#L31-L34
|
|
57
|
+
const postfixRE = /[?#].*$/;
|
|
58
|
+
/**
|
|
59
|
+
* @internal
|
|
60
|
+
*/
|
|
61
|
+
function cleanUrl(url) {
|
|
62
|
+
return url.replace(postfixRE, '');
|
|
63
|
+
}
|
|
64
|
+
// https://github.com/vitejs/vite/blob/b7ddfae5f852c2948fab03e94751ce56f5f31ce0/packages/vite/src/node/utils.ts#L393
|
|
65
|
+
/**
|
|
66
|
+
* @internal
|
|
67
|
+
*/
|
|
68
|
+
function tryStatSync(file) {
|
|
69
|
+
try {
|
|
70
|
+
// The "throwIfNoEntry" is a performance optimization for cases where the file does not exist
|
|
71
|
+
return fs.statSync(file, { throwIfNoEntry: false });
|
|
72
|
+
}
|
|
73
|
+
catch {
|
|
74
|
+
// Ignore errors
|
|
75
|
+
}
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
// https://github.com/vitejs/vite/blob/b7ddfae5f852c2948fab03e94751ce56f5f31ce0/packages/vite/src/node/utils.ts#L1030
|
|
79
|
+
/**
|
|
80
|
+
* @internal
|
|
81
|
+
*/
|
|
82
|
+
function getHash(text, length = 8) {
|
|
83
|
+
const h = node_crypto.createHash('sha256').update(text).digest('hex').substring(0, length);
|
|
84
|
+
if (length <= 64) {
|
|
85
|
+
return h;
|
|
86
|
+
}
|
|
87
|
+
return h.padEnd(length, '_');
|
|
88
|
+
}
|
|
89
|
+
// https://github.com/vitejs/vite/blob/b7ddfae5f852c2948fab03e94751ce56f5f31ce0/packages/vite/src/shared/utils.ts#L40
|
|
90
|
+
/**
|
|
91
|
+
* @internal
|
|
92
|
+
*/
|
|
93
|
+
function withTrailingSlash(path) {
|
|
94
|
+
if (path[path.length - 1] !== '/') {
|
|
95
|
+
return `${path}/`;
|
|
96
|
+
}
|
|
97
|
+
return path;
|
|
98
|
+
}
|
|
99
|
+
// https://github.com/vitejs/vite/blob/b7ddfae5f852c2948fab03e94751ce56f5f31ce0/packages/vite/src/node/utils.ts#L1268
|
|
100
|
+
/**
|
|
101
|
+
* @internal
|
|
102
|
+
*/
|
|
103
|
+
function joinUrlSegments(a, b) {
|
|
104
|
+
if (!a || !b) {
|
|
105
|
+
return a || b || '';
|
|
106
|
+
}
|
|
107
|
+
if (a[a.length - 1] === '/') {
|
|
108
|
+
a = a.substring(0, a.length - 1);
|
|
109
|
+
}
|
|
110
|
+
if (b[0] !== '/') {
|
|
111
|
+
b = `/${b}`;
|
|
112
|
+
}
|
|
113
|
+
return a + b;
|
|
114
|
+
}
|
|
115
|
+
// https://github.com/vitejs/vite/blob/b7ddfae5f852c2948fab03e94751ce56f5f31ce0/packages/vite/src/node/utils.ts#L1281
|
|
116
|
+
/**
|
|
117
|
+
* @internal
|
|
118
|
+
*/
|
|
119
|
+
function removeLeadingSlash(str) {
|
|
120
|
+
return str[0] === '/' ? str.slice(1) : str;
|
|
121
|
+
}
|
|
122
|
+
// https://github.com/vitejs/vite/blob/b7ddfae5f852c2948fab03e94751ce56f5f31ce0/packages/vite/src/node/utils.ts#L319
|
|
123
|
+
/**
|
|
124
|
+
* @internal
|
|
125
|
+
*/
|
|
126
|
+
function injectQuery(builtUrl, query) {
|
|
127
|
+
const queryIndex = builtUrl.indexOf('?');
|
|
128
|
+
return builtUrl + (queryIndex === -1 ? '?' : '&') + query;
|
|
129
|
+
}
|
|
130
|
+
// https://github.com/vitejs/vite/blob/b7ddfae5f852c2948fab03e94751ce56f5f31ce0/packages/vite/src/node/utils.ts#L1435
|
|
131
|
+
/**
|
|
132
|
+
* @internal
|
|
133
|
+
*/
|
|
134
|
+
function partialEncodeURIPath(uri) {
|
|
135
|
+
if (uri.startsWith('data:')) {
|
|
136
|
+
return uri;
|
|
137
|
+
}
|
|
138
|
+
const filePath = cleanUrl(uri);
|
|
139
|
+
const postfix = filePath !== uri ? uri.slice(filePath.length) : '';
|
|
140
|
+
return filePath.replaceAll('%', '%25') + postfix;
|
|
141
|
+
}
|
|
142
|
+
// https://github.com/vitejs/vite/blob/b7ddfae5f852c2948fab03e94751ce56f5f31ce0/packages/vite/src/node/utils.ts#L1424
|
|
143
|
+
/**
|
|
144
|
+
* @internal
|
|
145
|
+
*/
|
|
146
|
+
function encodeURIPath(uri) {
|
|
147
|
+
if (uri.startsWith('data:')) {
|
|
148
|
+
return uri;
|
|
149
|
+
}
|
|
150
|
+
const filePath = cleanUrl(uri);
|
|
151
|
+
const postfix = filePath !== uri ? uri.slice(filePath.length) : '';
|
|
152
|
+
return encodeURI(filePath) + postfix;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
exports.cleanUrl = cleanUrl;
|
|
156
|
+
exports.encodeURIPath = encodeURIPath;
|
|
157
|
+
exports.evalValue = evalValue;
|
|
158
|
+
exports.getHash = getHash;
|
|
159
|
+
exports.injectQuery = injectQuery;
|
|
160
|
+
exports.joinUrlSegments = joinUrlSegments;
|
|
161
|
+
exports.partialEncodeURIPath = partialEncodeURIPath;
|
|
162
|
+
exports.removeLeadingSlash = removeLeadingSlash;
|
|
163
|
+
exports.tryStatSync = tryStatSync;
|
|
164
|
+
exports.withTrailingSlash = withTrailingSlash;
|
|
@@ -0,0 +1,151 @@
|
|
|
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 { 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,207 @@
|
|
|
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 bridge_utils = require('./utils.cjs');
|
|
42
|
+
const path = require('node:path');
|
|
43
|
+
const vite = require('vite');
|
|
44
|
+
const bridge_build = require('./build.cjs');
|
|
45
|
+
|
|
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
|
+
|
|
65
|
+
// index.ts for more details on contents and license of this file
|
|
66
|
+
/**
|
|
67
|
+
* @internal
|
|
68
|
+
*/
|
|
69
|
+
// biome-ignore lint/suspicious/noConstEnum: Exception where we use them
|
|
70
|
+
exports.AlphaTabWorkerTypes = void 0;
|
|
71
|
+
(function (AlphaTabWorkerTypes) {
|
|
72
|
+
AlphaTabWorkerTypes["WorkerClassic"] = "worker_classic";
|
|
73
|
+
AlphaTabWorkerTypes["WorkerModule"] = "worker_module";
|
|
74
|
+
AlphaTabWorkerTypes["AudioWorklet"] = "audio_worklet";
|
|
75
|
+
})(exports.AlphaTabWorkerTypes || (exports.AlphaTabWorkerTypes = {}));
|
|
76
|
+
/**
|
|
77
|
+
* @internal
|
|
78
|
+
*/
|
|
79
|
+
const workerCache = new WeakMap();
|
|
80
|
+
/**
|
|
81
|
+
* @internal
|
|
82
|
+
*/
|
|
83
|
+
const WORKER_FILE_ID = 'alphatab_worker';
|
|
84
|
+
/**
|
|
85
|
+
* @internal
|
|
86
|
+
*/
|
|
87
|
+
const WORKER_ASSET_ID = '__ALPHATAB_WORKER_ASSET__';
|
|
88
|
+
// https://github.com/vitejs/vite/blob/b7ddfae5f852c2948fab03e94751ce56f5f31ce0/packages/vite/src/node/plugins/worker.ts#L47
|
|
89
|
+
function saveEmitWorkerAsset(config, asset) {
|
|
90
|
+
const workerMap = workerCache.get(config.mainConfig || config);
|
|
91
|
+
workerMap.assets.set(asset.fileName, asset);
|
|
92
|
+
}
|
|
93
|
+
// https://github.com/vitejs/vite/blob/b7ddfae5f852c2948fab03e94751ce56f5f31ce0/packages/vite/src/node/plugins/worker.ts#L161
|
|
94
|
+
/**
|
|
95
|
+
* @internal
|
|
96
|
+
*/
|
|
97
|
+
async function workerFileToUrl(config, id) {
|
|
98
|
+
const workerMap = workerCache.get(config.mainConfig || config);
|
|
99
|
+
let fileName = workerMap.bundle.get(id);
|
|
100
|
+
if (!fileName) {
|
|
101
|
+
const outputChunk = await bundleWorkerEntry(config, id);
|
|
102
|
+
fileName = outputChunk.fileName;
|
|
103
|
+
saveEmitWorkerAsset(config, {
|
|
104
|
+
fileName,
|
|
105
|
+
source: outputChunk.code
|
|
106
|
+
});
|
|
107
|
+
workerMap.bundle.set(id, fileName);
|
|
108
|
+
}
|
|
109
|
+
return encodeWorkerAssetFileName(fileName, workerMap);
|
|
110
|
+
}
|
|
111
|
+
// https://github.com/vitejs/vite/blob/b7ddfae5f852c2948fab03e94751ce56f5f31ce0/packages/vite/src/node/plugins/worker.ts#L149
|
|
112
|
+
function encodeWorkerAssetFileName(fileName, workerCache) {
|
|
113
|
+
const { fileNameHash } = workerCache;
|
|
114
|
+
const hash = bridge_utils.getHash(fileName);
|
|
115
|
+
if (!fileNameHash.get(hash)) {
|
|
116
|
+
fileNameHash.set(hash, fileName);
|
|
117
|
+
}
|
|
118
|
+
return `${WORKER_ASSET_ID}${hash}__`;
|
|
119
|
+
}
|
|
120
|
+
// https://github.com/vitejs/vite/blob/b7ddfae5f852c2948fab03e94751ce56f5f31ce0/packages/vite/src/node/plugins/worker.ts#L55
|
|
121
|
+
async function bundleWorkerEntry(config, id) {
|
|
122
|
+
const input = bridge_utils.cleanUrl(id);
|
|
123
|
+
const bundleChain = config.bundleChain ?? [];
|
|
124
|
+
const newBundleChain = [...bundleChain, input];
|
|
125
|
+
if (bundleChain.includes(input)) {
|
|
126
|
+
throw new Error(`Circular worker imports detected. Vite does not support it. Import chain: ${newBundleChain.join(' -> ')}`);
|
|
127
|
+
}
|
|
128
|
+
// bundle the file as entry to support imports
|
|
129
|
+
const { rollup } = await import('rollup');
|
|
130
|
+
const { plugins, rollupOptions, format } = config.worker;
|
|
131
|
+
const workerConfig = await plugins(newBundleChain);
|
|
132
|
+
const workerEnvironment = new vite.BuildEnvironment('client', workerConfig); // TODO: should this be 'worker'?
|
|
133
|
+
await workerEnvironment.init();
|
|
134
|
+
const bundle = await rollup({
|
|
135
|
+
...rollupOptions,
|
|
136
|
+
input,
|
|
137
|
+
plugins: workerEnvironment.plugins.map(p => bridge_build.injectEnvironmentToHooks(workerEnvironment, p)),
|
|
138
|
+
preserveEntrySignatures: false
|
|
139
|
+
});
|
|
140
|
+
let chunk;
|
|
141
|
+
try {
|
|
142
|
+
const workerOutputConfig = config.worker.rollupOptions.output;
|
|
143
|
+
const workerConfig = workerOutputConfig
|
|
144
|
+
? Array.isArray(workerOutputConfig)
|
|
145
|
+
? workerOutputConfig[0] || {}
|
|
146
|
+
: workerOutputConfig
|
|
147
|
+
: {};
|
|
148
|
+
const { output: [outputChunk, ...outputChunks] } = await bundle.generate({
|
|
149
|
+
entryFileNames: path__namespace.posix.join(config.build.assetsDir, '[name]-[hash].js'),
|
|
150
|
+
chunkFileNames: path__namespace.posix.join(config.build.assetsDir, '[name]-[hash].js'),
|
|
151
|
+
assetFileNames: path__namespace.posix.join(config.build.assetsDir, '[name]-[hash].[ext]'),
|
|
152
|
+
...workerConfig,
|
|
153
|
+
format,
|
|
154
|
+
sourcemap: config.build.sourcemap
|
|
155
|
+
});
|
|
156
|
+
chunk = outputChunk;
|
|
157
|
+
for (const outputChunk of outputChunks) {
|
|
158
|
+
if (outputChunk.type === 'asset') {
|
|
159
|
+
saveEmitWorkerAsset(config, outputChunk);
|
|
160
|
+
}
|
|
161
|
+
else if (outputChunk.type === 'chunk') {
|
|
162
|
+
saveEmitWorkerAsset(config, {
|
|
163
|
+
fileName: outputChunk.fileName,
|
|
164
|
+
source: outputChunk.code
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
finally {
|
|
170
|
+
await bundle.close();
|
|
171
|
+
}
|
|
172
|
+
return emitSourcemapForWorkerEntry(config, chunk);
|
|
173
|
+
}
|
|
174
|
+
// https://github.com/vitejs/vite/blob/b7ddfae5f852c2948fab03e94751ce56f5f31ce0/packages/vite/src/node/plugins/worker.ts#L124
|
|
175
|
+
function emitSourcemapForWorkerEntry(config, chunk) {
|
|
176
|
+
const { map: sourcemap } = chunk;
|
|
177
|
+
if (sourcemap) {
|
|
178
|
+
if (config.build.sourcemap === 'hidden' || config.build.sourcemap === true) {
|
|
179
|
+
const data = sourcemap.toString();
|
|
180
|
+
const mapFileName = `${chunk.fileName}.map`;
|
|
181
|
+
saveEmitWorkerAsset(config, {
|
|
182
|
+
fileName: mapFileName,
|
|
183
|
+
source: data
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
return chunk;
|
|
188
|
+
}
|
|
189
|
+
// https://github.com/vitejs/vite/blob/b7ddfae5f852c2948fab03e94751ce56f5f31ce0/packages/vite/src/node/plugins/worker.ts#L458
|
|
190
|
+
/**
|
|
191
|
+
* @internal
|
|
192
|
+
*/
|
|
193
|
+
function isSameContent(a, b) {
|
|
194
|
+
if (typeof a === 'string') {
|
|
195
|
+
if (typeof b === 'string') {
|
|
196
|
+
return a === b;
|
|
197
|
+
}
|
|
198
|
+
return Buffer.from(a).equals(b);
|
|
199
|
+
}
|
|
200
|
+
return Buffer.from(b).equals(a);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
exports.WORKER_ASSET_ID = WORKER_ASSET_ID;
|
|
204
|
+
exports.WORKER_FILE_ID = WORKER_FILE_ID;
|
|
205
|
+
exports.isSameContent = isSameContent;
|
|
206
|
+
exports.workerCache = workerCache;
|
|
207
|
+
exports.workerFileToUrl = workerFileToUrl;
|