@coderline/alphatab-vite 1.8.1 → 1.8.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AlphaTabVitePluginOptions.cjs +34 -37
- package/dist/AlphaTabVitePluginOptions.mjs +34 -35
- package/dist/alphaTab.vite.cjs +37 -44
- package/dist/alphaTab.vite.mjs +36 -36
- package/dist/alphaTabVitePlugin.cjs +50 -54
- package/dist/alphaTabVitePlugin.mjs +49 -50
- package/dist/bridge/asset.cjs +50 -80
- package/dist/bridge/asset.mjs +47 -57
- package/dist/bridge/build.cjs +152 -214
- package/dist/bridge/build.mjs +149 -191
- package/dist/bridge/bundler.cjs +54 -0
- package/dist/bridge/bundler.mjs +52 -0
- package/dist/bridge/config.cjs +34 -37
- package/dist/bridge/config.mjs +34 -35
- package/dist/bridge/constants.cjs +73 -80
- package/dist/bridge/constants.mjs +72 -76
- package/dist/bridge/fsUtils.cjs +46 -55
- package/dist/bridge/fsUtils.mjs +43 -51
- package/dist/bridge/index.cjs +58 -68
- package/dist/bridge/index.mjs +42 -42
- package/dist/bridge/optimizer.cjs +112 -155
- package/dist/bridge/optimizer.mjs +108 -132
- package/dist/bridge/plugins.cjs +39 -45
- package/dist/bridge/plugins.mjs +38 -41
- package/dist/bridge/resolve.cjs +54 -66
- package/dist/bridge/resolve.mjs +53 -62
- package/dist/bridge/typeUtils.cjs +34 -37
- package/dist/bridge/typeUtils.mjs +34 -35
- package/dist/bridge/utils.cjs +87 -121
- package/dist/bridge/utils.mjs +84 -117
- package/dist/bridge/worker.cjs +179 -183
- package/dist/bridge/worker.mjs +175 -160
- package/dist/chunk.cjs +63 -0
- package/dist/copyAssetsPlugin.cjs +102 -163
- package/dist/copyAssetsPlugin.mjs +35 -141
- package/dist/copyAssetsPlugin2.mjs +108 -0
- package/dist/detectionGlobalPlugin.cjs +65 -68
- package/dist/detectionGlobalPlugin.mjs +62 -64
- package/dist/dist.cjs +6595 -0
- package/dist/dist.mjs +6589 -0
- package/dist/importMetaPlugin.cjs +147 -192
- package/dist/importMetaPlugin.mjs +143 -188
- package/dist/prompt-DewH0PjV.cjs +885 -0
- package/dist/prompt-DewH0PjV.mjs +882 -0
- package/dist/workerPlugin.cjs +145 -219
- package/dist/workerPlugin.mjs +141 -196
- package/package.json +17 -17
package/dist/bridge/utils.mjs
CHANGED
|
@@ -1,151 +1,118 @@
|
|
|
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
|
-
|
|
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
|
|
2
|
+
* alphaTab Vite Plugin v1.8.3 (, build 32)
|
|
3
|
+
*
|
|
4
|
+
* Copyright © 2026, Daniel Kuschny and Contributors, All rights reserved.
|
|
5
|
+
*
|
|
6
|
+
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
7
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
8
|
+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
9
|
+
*
|
|
10
|
+
* This library uses code from Vite (https://github.com/vitejs/vite/), licensed under:
|
|
11
|
+
*
|
|
12
|
+
* MIT License
|
|
13
|
+
* Copyright (c) 2019-present, Yuxi (Evan) You and Vite contributors
|
|
14
|
+
*
|
|
15
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
16
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
17
|
+
* in the Software without restriction, including without limitation the rights
|
|
18
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
19
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
20
|
+
* furnished to do so, subject to the following conditions:
|
|
21
|
+
*
|
|
22
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
23
|
+
* copies or substantial portions of the Software.
|
|
24
|
+
*
|
|
25
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
26
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
27
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
28
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
29
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
30
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
31
|
+
* SOFTWARE.
|
|
32
|
+
*
|
|
33
|
+
* @preserve
|
|
34
|
+
* @license
|
|
35
|
+
*/
|
|
36
|
+
import fs from "node:fs";
|
|
37
|
+
import { createHash } from "node:crypto";
|
|
38
|
+
//#region src/bridge/utils.ts
|
|
42
39
|
/**
|
|
43
|
-
|
|
44
|
-
|
|
40
|
+
* @internal
|
|
41
|
+
*/
|
|
45
42
|
function evalValue(rawValue) {
|
|
46
|
-
|
|
43
|
+
return new Function(`
|
|
47
44
|
var console, exports, global, module, process, require
|
|
48
45
|
return (\n${rawValue}\n)
|
|
49
|
-
`);
|
|
50
|
-
return fn();
|
|
46
|
+
`)();
|
|
51
47
|
}
|
|
52
|
-
|
|
53
|
-
const postfixRE = /[?#].*$/;
|
|
48
|
+
var postfixRE = /[?#].*$/;
|
|
54
49
|
/**
|
|
55
|
-
|
|
56
|
-
|
|
50
|
+
* @internal
|
|
51
|
+
*/
|
|
57
52
|
function cleanUrl(url) {
|
|
58
|
-
|
|
53
|
+
return url.replace(postfixRE, "");
|
|
59
54
|
}
|
|
60
|
-
// https://github.com/vitejs/vite/blob/b7ddfae5f852c2948fab03e94751ce56f5f31ce0/packages/vite/src/node/utils.ts#L393
|
|
61
55
|
/**
|
|
62
|
-
|
|
63
|
-
|
|
56
|
+
* @internal
|
|
57
|
+
*/
|
|
64
58
|
function tryStatSync(file) {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
catch {
|
|
70
|
-
// Ignore errors
|
|
71
|
-
}
|
|
72
|
-
return;
|
|
59
|
+
try {
|
|
60
|
+
return fs.statSync(file, { throwIfNoEntry: false });
|
|
61
|
+
} catch {}
|
|
73
62
|
}
|
|
74
|
-
// https://github.com/vitejs/vite/blob/b7ddfae5f852c2948fab03e94751ce56f5f31ce0/packages/vite/src/node/utils.ts#L1030
|
|
75
63
|
/**
|
|
76
|
-
|
|
77
|
-
|
|
64
|
+
* @internal
|
|
65
|
+
*/
|
|
78
66
|
function getHash(text, length = 8) {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}
|
|
83
|
-
return h.padEnd(length, '_');
|
|
67
|
+
const h = createHash("sha256").update(text).digest("hex").substring(0, length);
|
|
68
|
+
if (length <= 64) return h;
|
|
69
|
+
return h.padEnd(length, "_");
|
|
84
70
|
}
|
|
85
|
-
// https://github.com/vitejs/vite/blob/b7ddfae5f852c2948fab03e94751ce56f5f31ce0/packages/vite/src/shared/utils.ts#L40
|
|
86
71
|
/**
|
|
87
|
-
|
|
88
|
-
|
|
72
|
+
* @internal
|
|
73
|
+
*/
|
|
89
74
|
function withTrailingSlash(path) {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
}
|
|
93
|
-
return path;
|
|
75
|
+
if (path[path.length - 1] !== "/") return `${path}/`;
|
|
76
|
+
return path;
|
|
94
77
|
}
|
|
95
|
-
// https://github.com/vitejs/vite/blob/b7ddfae5f852c2948fab03e94751ce56f5f31ce0/packages/vite/src/node/utils.ts#L1268
|
|
96
78
|
/**
|
|
97
|
-
|
|
98
|
-
|
|
79
|
+
* @internal
|
|
80
|
+
*/
|
|
99
81
|
function joinUrlSegments(a, b) {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
a = a.substring(0, a.length - 1);
|
|
105
|
-
}
|
|
106
|
-
if (b[0] !== '/') {
|
|
107
|
-
b = `/${b}`;
|
|
108
|
-
}
|
|
109
|
-
return a + b;
|
|
82
|
+
if (!a || !b) return a || b || "";
|
|
83
|
+
if (a[a.length - 1] === "/") a = a.substring(0, a.length - 1);
|
|
84
|
+
if (b[0] !== "/") b = `/${b}`;
|
|
85
|
+
return a + b;
|
|
110
86
|
}
|
|
111
|
-
// https://github.com/vitejs/vite/blob/b7ddfae5f852c2948fab03e94751ce56f5f31ce0/packages/vite/src/node/utils.ts#L1281
|
|
112
87
|
/**
|
|
113
|
-
|
|
114
|
-
|
|
88
|
+
* @internal
|
|
89
|
+
*/
|
|
115
90
|
function removeLeadingSlash(str) {
|
|
116
|
-
|
|
91
|
+
return str[0] === "/" ? str.slice(1) : str;
|
|
117
92
|
}
|
|
118
|
-
// https://github.com/vitejs/vite/blob/b7ddfae5f852c2948fab03e94751ce56f5f31ce0/packages/vite/src/node/utils.ts#L319
|
|
119
93
|
/**
|
|
120
|
-
|
|
121
|
-
|
|
94
|
+
* @internal
|
|
95
|
+
*/
|
|
122
96
|
function injectQuery(builtUrl, query) {
|
|
123
|
-
|
|
124
|
-
return builtUrl + (queryIndex === -1 ? '?' : '&') + query;
|
|
97
|
+
return builtUrl + (builtUrl.indexOf("?") === -1 ? "?" : "&") + query;
|
|
125
98
|
}
|
|
126
|
-
// https://github.com/vitejs/vite/blob/b7ddfae5f852c2948fab03e94751ce56f5f31ce0/packages/vite/src/node/utils.ts#L1435
|
|
127
99
|
/**
|
|
128
|
-
|
|
129
|
-
|
|
100
|
+
* @internal
|
|
101
|
+
*/
|
|
130
102
|
function partialEncodeURIPath(uri) {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
const postfix = filePath !== uri ? uri.slice(filePath.length) : '';
|
|
136
|
-
return filePath.replaceAll('%', '%25') + postfix;
|
|
103
|
+
if (uri.startsWith("data:")) return uri;
|
|
104
|
+
const filePath = cleanUrl(uri);
|
|
105
|
+
const postfix = filePath !== uri ? uri.slice(filePath.length) : "";
|
|
106
|
+
return filePath.replaceAll("%", "%25") + postfix;
|
|
137
107
|
}
|
|
138
|
-
// https://github.com/vitejs/vite/blob/b7ddfae5f852c2948fab03e94751ce56f5f31ce0/packages/vite/src/node/utils.ts#L1424
|
|
139
108
|
/**
|
|
140
|
-
|
|
141
|
-
|
|
109
|
+
* @internal
|
|
110
|
+
*/
|
|
142
111
|
function encodeURIPath(uri) {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
const postfix = filePath !== uri ? uri.slice(filePath.length) : '';
|
|
148
|
-
return encodeURI(filePath) + postfix;
|
|
112
|
+
if (uri.startsWith("data:")) return uri;
|
|
113
|
+
const filePath = cleanUrl(uri);
|
|
114
|
+
const postfix = filePath !== uri ? uri.slice(filePath.length) : "";
|
|
115
|
+
return encodeURI(filePath) + postfix;
|
|
149
116
|
}
|
|
150
|
-
|
|
117
|
+
//#endregion
|
|
151
118
|
export { cleanUrl, encodeURIPath, evalValue, getHash, injectQuery, joinUrlSegments, partialEncodeURIPath, removeLeadingSlash, tryStatSync, withTrailingSlash };
|
package/dist/bridge/worker.cjs
CHANGED
|
@@ -1,205 +1,201 @@
|
|
|
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
|
-
|
|
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
|
|
2
|
+
* alphaTab Vite Plugin v1.8.3 (, build 32)
|
|
3
|
+
*
|
|
4
|
+
* Copyright © 2026, Daniel Kuschny and Contributors, All rights reserved.
|
|
5
|
+
*
|
|
6
|
+
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
7
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
8
|
+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
9
|
+
*
|
|
10
|
+
* This library uses code from Vite (https://github.com/vitejs/vite/), licensed under:
|
|
11
|
+
*
|
|
12
|
+
* MIT License
|
|
13
|
+
* Copyright (c) 2019-present, Yuxi (Evan) You and Vite contributors
|
|
14
|
+
*
|
|
15
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
16
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
17
|
+
* in the Software without restriction, including without limitation the rights
|
|
18
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
19
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
20
|
+
* furnished to do so, subject to the following conditions:
|
|
21
|
+
*
|
|
22
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
23
|
+
* copies or substantial portions of the Software.
|
|
24
|
+
*
|
|
25
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
26
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
27
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
28
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
29
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
30
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
31
|
+
* SOFTWARE.
|
|
32
|
+
*
|
|
33
|
+
* @preserve
|
|
34
|
+
* @license
|
|
35
|
+
*/
|
|
36
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
37
|
+
const require_chunk = require("../chunk.cjs");
|
|
38
|
+
const require_bridge_utils = require("./utils.cjs");
|
|
39
|
+
const require_bridge_build = require("./build.cjs");
|
|
40
|
+
const require_bridge_bundler = require("./bundler.cjs");
|
|
41
|
+
let node_path = require("node:path");
|
|
42
|
+
node_path = require_chunk.__toESM(node_path, 1);
|
|
43
|
+
let vite = require("vite");
|
|
44
|
+
//#region src/bridge/worker.ts
|
|
66
45
|
/**
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
})(exports.AlphaTabWorkerTypes || (exports.AlphaTabWorkerTypes = {}));
|
|
46
|
+
* @internal
|
|
47
|
+
*/
|
|
48
|
+
var AlphaTabWorkerTypes = /* @__PURE__ */ function(AlphaTabWorkerTypes) {
|
|
49
|
+
AlphaTabWorkerTypes["WorkerClassic"] = "worker_classic";
|
|
50
|
+
AlphaTabWorkerTypes["WorkerModule"] = "worker_module";
|
|
51
|
+
AlphaTabWorkerTypes["AudioWorklet"] = "audio_worklet";
|
|
52
|
+
return AlphaTabWorkerTypes;
|
|
53
|
+
}({});
|
|
76
54
|
/**
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
55
|
+
* @internal
|
|
56
|
+
*/
|
|
57
|
+
var workerCache = /* @__PURE__ */ new WeakMap();
|
|
80
58
|
/**
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
59
|
+
* @internal
|
|
60
|
+
*/
|
|
61
|
+
var WORKER_FILE_ID = "alphatab_worker";
|
|
84
62
|
/**
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
// https://github.com/vitejs/vite/blob/b7ddfae5f852c2948fab03e94751ce56f5f31ce0/packages/vite/src/node/plugins/worker.ts#L47
|
|
63
|
+
* @internal
|
|
64
|
+
*/
|
|
65
|
+
var WORKER_ASSET_ID = "__ALPHATAB_WORKER_ASSET__";
|
|
89
66
|
function saveEmitWorkerAsset(config, asset) {
|
|
90
|
-
|
|
91
|
-
workerMap.assets.set(asset.fileName, asset);
|
|
67
|
+
workerCache.get(config.mainConfig || config).assets.set(asset.fileName, asset);
|
|
92
68
|
}
|
|
93
|
-
// https://github.com/vitejs/vite/blob/b7ddfae5f852c2948fab03e94751ce56f5f31ce0/packages/vite/src/node/plugins/worker.ts#L161
|
|
94
69
|
/**
|
|
95
|
-
|
|
96
|
-
|
|
70
|
+
* @internal
|
|
71
|
+
*/
|
|
97
72
|
async function workerFileToUrl(config, id) {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
73
|
+
const workerMap = workerCache.get(config.mainConfig || config);
|
|
74
|
+
let fileName = workerMap.bundle.get(id);
|
|
75
|
+
if (!fileName) {
|
|
76
|
+
const outputChunk = await bundleWorkerEntry(config, id);
|
|
77
|
+
fileName = outputChunk.fileName;
|
|
78
|
+
saveEmitWorkerAsset(config, {
|
|
79
|
+
fileName,
|
|
80
|
+
source: outputChunk.code
|
|
81
|
+
});
|
|
82
|
+
workerMap.bundle.set(id, fileName);
|
|
83
|
+
}
|
|
84
|
+
return encodeWorkerAssetFileName(fileName, workerMap);
|
|
110
85
|
}
|
|
111
|
-
// https://github.com/vitejs/vite/blob/b7ddfae5f852c2948fab03e94751ce56f5f31ce0/packages/vite/src/node/plugins/worker.ts#L149
|
|
112
86
|
function encodeWorkerAssetFileName(fileName, workerCache) {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
}
|
|
118
|
-
return `${WORKER_ASSET_ID}${hash}__`;
|
|
87
|
+
const { fileNameHash } = workerCache;
|
|
88
|
+
const hash = require_bridge_utils.getHash(fileName);
|
|
89
|
+
if (!fileNameHash.get(hash)) fileNameHash.set(hash, fileName);
|
|
90
|
+
return `${WORKER_ASSET_ID}${hash}__`;
|
|
119
91
|
}
|
|
120
|
-
// https://github.com/vitejs/vite/blob/b7ddfae5f852c2948fab03e94751ce56f5f31ce0/packages/vite/src/node/plugins/worker.ts#L55
|
|
121
92
|
async function bundleWorkerEntry(config, id) {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
93
|
+
const input = require_bridge_utils.cleanUrl(id);
|
|
94
|
+
const bundleChain = config.bundleChain ?? [];
|
|
95
|
+
const newBundleChain = [...bundleChain, input];
|
|
96
|
+
if (bundleChain.includes(input)) throw new Error(`Circular worker imports detected. Vite does not support it. Import chain: ${newBundleChain.join(" -> ")}`);
|
|
97
|
+
const { plugins, format } = config.worker;
|
|
98
|
+
const workerOptionsCarrier = config.worker;
|
|
99
|
+
const workerBundlerOptions = workerOptionsCarrier.rolldownOptions ?? workerOptionsCarrier.rollupOptions;
|
|
100
|
+
const workerEnvironment = new vite.BuildEnvironment("client", await plugins(newBundleChain));
|
|
101
|
+
await workerEnvironment.init();
|
|
102
|
+
const wrappedPlugins = workerEnvironment.plugins.map((p) => require_bridge_build.injectEnvironmentToHooks(workerEnvironment, p));
|
|
103
|
+
const workerOutputConfig = workerBundlerOptions.output;
|
|
104
|
+
const outputConfig = workerOutputConfig ? Array.isArray(workerOutputConfig) ? workerOutputConfig[0] || {} : workerOutputConfig : {};
|
|
105
|
+
const generateOptions = {
|
|
106
|
+
entryFileNames: node_path.posix.join(config.build.assetsDir, "[name]-[hash].js"),
|
|
107
|
+
chunkFileNames: node_path.posix.join(config.build.assetsDir, "[name]-[hash].js"),
|
|
108
|
+
assetFileNames: node_path.posix.join(config.build.assetsDir, "[name]-[hash].[ext]"),
|
|
109
|
+
...outputConfig,
|
|
110
|
+
format,
|
|
111
|
+
sourcemap: config.build.sourcemap
|
|
112
|
+
};
|
|
113
|
+
let chunk;
|
|
114
|
+
if (require_bridge_bundler.detectBundler(config) === require_bridge_bundler.BundlerKind.Rolldown) chunk = await bundleWorkerEntryRolldown(config, input, workerBundlerOptions, wrappedPlugins, generateOptions, workerEnvironment);
|
|
115
|
+
else chunk = await bundleWorkerEntryRollup(config, input, workerBundlerOptions, wrappedPlugins, generateOptions);
|
|
116
|
+
return emitSourcemapForWorkerEntry(config, chunk);
|
|
117
|
+
}
|
|
118
|
+
async function bundleWorkerEntryRollup(config, input, bundlerOptions, plugins, generateOptions) {
|
|
119
|
+
const { rollup } = await import("rollup");
|
|
120
|
+
const bundle = await rollup({
|
|
121
|
+
...bundlerOptions,
|
|
122
|
+
input,
|
|
123
|
+
plugins,
|
|
124
|
+
preserveEntrySignatures: false
|
|
125
|
+
});
|
|
126
|
+
try {
|
|
127
|
+
const { output } = await bundle.generate(generateOptions);
|
|
128
|
+
const [outputChunk, ...rest] = output;
|
|
129
|
+
for (const o of rest) if (o.type === "asset") saveEmitWorkerAsset(config, o);
|
|
130
|
+
else saveEmitWorkerAsset(config, {
|
|
131
|
+
fileName: o.fileName,
|
|
132
|
+
source: o.code
|
|
133
|
+
});
|
|
134
|
+
return outputChunk;
|
|
135
|
+
} finally {
|
|
136
|
+
await bundle.close();
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
async function bundleWorkerEntryRolldown(config, input, bundlerOptions, plugins, generateOptions, workerEnvironment) {
|
|
140
|
+
const { rolldown } = await Promise.resolve().then(() => require("../dist.cjs"));
|
|
141
|
+
const workerBuildTarget = workerEnvironment.config.build.target;
|
|
142
|
+
const bundle = await rolldown({
|
|
143
|
+
...bundlerOptions,
|
|
144
|
+
input,
|
|
145
|
+
plugins,
|
|
146
|
+
transform: {
|
|
147
|
+
target: workerBuildTarget === false ? void 0 : workerBuildTarget,
|
|
148
|
+
...bundlerOptions.transform,
|
|
149
|
+
define: {
|
|
150
|
+
...bundlerOptions.transform?.define,
|
|
151
|
+
"process.env.NODE_ENV": "process.env.NODE_ENV"
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
moduleTypes: {
|
|
155
|
+
".css": "js",
|
|
156
|
+
...bundlerOptions.moduleTypes
|
|
157
|
+
},
|
|
158
|
+
preserveEntrySignatures: false,
|
|
159
|
+
experimental: {
|
|
160
|
+
...bundlerOptions.experimental,
|
|
161
|
+
viteMode: true
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
try {
|
|
165
|
+
const { output } = await bundle.generate(generateOptions);
|
|
166
|
+
const [outputChunk, ...rest] = output;
|
|
167
|
+
for (const o of rest) if (o.type === "asset") saveEmitWorkerAsset(config, o);
|
|
168
|
+
else saveEmitWorkerAsset(config, {
|
|
169
|
+
fileName: o.fileName,
|
|
170
|
+
source: o.code
|
|
171
|
+
});
|
|
172
|
+
return outputChunk;
|
|
173
|
+
} finally {
|
|
174
|
+
await bundle.close();
|
|
175
|
+
}
|
|
173
176
|
}
|
|
174
|
-
// https://github.com/vitejs/vite/blob/b7ddfae5f852c2948fab03e94751ce56f5f31ce0/packages/vite/src/node/plugins/worker.ts#L124
|
|
175
177
|
function emitSourcemapForWorkerEntry(config, chunk) {
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
});
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
return chunk;
|
|
178
|
+
const sourcemap = chunk.map;
|
|
179
|
+
if (sourcemap) {
|
|
180
|
+
if (config.build.sourcemap === "hidden" || config.build.sourcemap === true) saveEmitWorkerAsset(config, {
|
|
181
|
+
fileName: `${chunk.fileName}.map`,
|
|
182
|
+
source: sourcemap.toString()
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
return chunk;
|
|
188
186
|
}
|
|
189
|
-
// https://github.com/vitejs/vite/blob/b7ddfae5f852c2948fab03e94751ce56f5f31ce0/packages/vite/src/node/plugins/worker.ts#L458
|
|
190
187
|
/**
|
|
191
|
-
|
|
192
|
-
|
|
188
|
+
* @internal
|
|
189
|
+
*/
|
|
193
190
|
function isSameContent(a, b) {
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
}
|
|
200
|
-
return Buffer.from(b).equals(a);
|
|
191
|
+
if (typeof a === "string") {
|
|
192
|
+
if (typeof b === "string") return a === b;
|
|
193
|
+
return Buffer.from(a).equals(b);
|
|
194
|
+
}
|
|
195
|
+
return Buffer.from(b).equals(a);
|
|
201
196
|
}
|
|
202
|
-
|
|
197
|
+
//#endregion
|
|
198
|
+
exports.AlphaTabWorkerTypes = AlphaTabWorkerTypes;
|
|
203
199
|
exports.WORKER_ASSET_ID = WORKER_ASSET_ID;
|
|
204
200
|
exports.WORKER_FILE_ID = WORKER_FILE_ID;
|
|
205
201
|
exports.isSameContent = isSameContent;
|