@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.
Files changed (47) hide show
  1. package/dist/AlphaTabVitePluginOptions.cjs +34 -37
  2. package/dist/AlphaTabVitePluginOptions.mjs +34 -35
  3. package/dist/alphaTab.vite.cjs +37 -44
  4. package/dist/alphaTab.vite.mjs +36 -36
  5. package/dist/alphaTabVitePlugin.cjs +50 -54
  6. package/dist/alphaTabVitePlugin.mjs +49 -50
  7. package/dist/bridge/asset.cjs +50 -80
  8. package/dist/bridge/asset.mjs +47 -57
  9. package/dist/bridge/build.cjs +152 -214
  10. package/dist/bridge/build.mjs +149 -191
  11. package/dist/bridge/bundler.cjs +54 -0
  12. package/dist/bridge/bundler.mjs +52 -0
  13. package/dist/bridge/config.cjs +34 -37
  14. package/dist/bridge/config.mjs +34 -35
  15. package/dist/bridge/constants.cjs +73 -80
  16. package/dist/bridge/constants.mjs +72 -76
  17. package/dist/bridge/fsUtils.cjs +46 -55
  18. package/dist/bridge/fsUtils.mjs +43 -51
  19. package/dist/bridge/index.cjs +58 -68
  20. package/dist/bridge/index.mjs +42 -42
  21. package/dist/bridge/optimizer.cjs +112 -155
  22. package/dist/bridge/optimizer.mjs +108 -132
  23. package/dist/bridge/plugins.cjs +39 -45
  24. package/dist/bridge/plugins.mjs +38 -41
  25. package/dist/bridge/resolve.cjs +54 -66
  26. package/dist/bridge/resolve.mjs +53 -62
  27. package/dist/bridge/typeUtils.cjs +34 -37
  28. package/dist/bridge/typeUtils.mjs +34 -35
  29. package/dist/bridge/utils.cjs +87 -121
  30. package/dist/bridge/utils.mjs +84 -117
  31. package/dist/bridge/worker.cjs +179 -183
  32. package/dist/bridge/worker.mjs +175 -160
  33. package/dist/chunk.cjs +63 -0
  34. package/dist/copyAssetsPlugin.cjs +102 -163
  35. package/dist/copyAssetsPlugin.mjs +35 -141
  36. package/dist/copyAssetsPlugin2.mjs +108 -0
  37. package/dist/detectionGlobalPlugin.cjs +65 -68
  38. package/dist/detectionGlobalPlugin.mjs +62 -64
  39. package/dist/dist.cjs +6595 -0
  40. package/dist/dist.mjs +6589 -0
  41. package/dist/importMetaPlugin.cjs +147 -192
  42. package/dist/importMetaPlugin.mjs +143 -188
  43. package/dist/prompt-DewH0PjV.cjs +885 -0
  44. package/dist/prompt-DewH0PjV.mjs +882 -0
  45. package/dist/workerPlugin.cjs +145 -219
  46. package/dist/workerPlugin.mjs +141 -196
  47. package/package.json +17 -17
@@ -1,87 +1,57 @@
1
1
  /*!
2
- * alphaTab Vite Plugin v1.8.1 (, build 30)
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
-
37
- 'use strict';
38
-
39
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
40
-
41
- const path = require('node:path');
42
- const bridge_utils = require('./utils.cjs');
43
-
44
- function _interopNamespaceDefault(e) {
45
- const n = Object.create(null, { [Symbol.toStringTag]: { value: 'Module' } });
46
- if (e) {
47
- for (const k in e) {
48
- if (k !== 'default') {
49
- const d = Object.getOwnPropertyDescriptor(e, k);
50
- Object.defineProperty(n, k, d.get ? d : {
51
- enumerable: true,
52
- get: () => e[k]
53
- });
54
- }
55
- }
56
- }
57
- n.default = e;
58
- return Object.freeze(n);
59
- }
60
-
61
- const path__namespace = /*#__PURE__*/_interopNamespaceDefault(path);
62
-
63
- // 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
+ let node_path = require("node:path");
40
+ node_path = require_chunk.__toESM(node_path, 1);
41
+ //#region src/bridge/asset.ts
64
42
  /**
65
- * @internal
66
- */
67
- const FS_PREFIX = '/@fs/';
43
+ * @internal
44
+ */
45
+ var FS_PREFIX = "/@fs/";
68
46
  /**
69
- * @internal
70
- */
47
+ * @internal
48
+ */
71
49
  async function fileToUrl(id, config) {
72
- let rtn;
73
- if (id.startsWith(bridge_utils.withTrailingSlash(config.root))) {
74
- // in project root, infer short public path
75
- rtn = `/${path__namespace.posix.relative(config.root, id)}`;
76
- }
77
- else {
78
- // outside of project root, use absolute fs path
79
- // (this is special handled by the serve static middleware
80
- rtn = path__namespace.posix.join(FS_PREFIX, id);
81
- }
82
- const base = bridge_utils.joinUrlSegments(config.server?.origin ?? '', config.base);
83
- return bridge_utils.joinUrlSegments(base, bridge_utils.removeLeadingSlash(rtn));
50
+ let rtn;
51
+ if (id.startsWith(require_bridge_utils.withTrailingSlash(config.root))) rtn = `/${node_path.posix.relative(config.root, id)}`;
52
+ else rtn = node_path.posix.join(FS_PREFIX, id);
53
+ return require_bridge_utils.joinUrlSegments(require_bridge_utils.joinUrlSegments(config.server?.origin ?? "", config.base), require_bridge_utils.removeLeadingSlash(rtn));
84
54
  }
85
-
55
+ //#endregion
86
56
  exports.FS_PREFIX = FS_PREFIX;
87
57
  exports.fileToUrl = fileToUrl;
@@ -1,63 +1,53 @@
1
1
  /*!
2
- * alphaTab Vite Plugin v1.8.1 (, build 30)
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
-
37
- import * as path from 'node:path';
38
- import { withTrailingSlash, joinUrlSegments, removeLeadingSlash } from './utils.mjs';
39
-
40
- // 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
+ import { joinUrlSegments, removeLeadingSlash, withTrailingSlash } from "./utils.mjs";
37
+ import * as path$1 from "node:path";
38
+ //#region src/bridge/asset.ts
41
39
  /**
42
- * @internal
43
- */
44
- const FS_PREFIX = '/@fs/';
40
+ * @internal
41
+ */
42
+ var FS_PREFIX = "/@fs/";
45
43
  /**
46
- * @internal
47
- */
44
+ * @internal
45
+ */
48
46
  async function fileToUrl(id, config) {
49
- let rtn;
50
- if (id.startsWith(withTrailingSlash(config.root))) {
51
- // in project root, infer short public path
52
- rtn = `/${path.posix.relative(config.root, id)}`;
53
- }
54
- else {
55
- // outside of project root, use absolute fs path
56
- // (this is special handled by the serve static middleware
57
- rtn = path.posix.join(FS_PREFIX, id);
58
- }
59
- const base = joinUrlSegments(config.server?.origin ?? '', config.base);
60
- return joinUrlSegments(base, removeLeadingSlash(rtn));
47
+ let rtn;
48
+ if (id.startsWith(withTrailingSlash(config.root))) rtn = `/${path$1.posix.relative(config.root, id)}`;
49
+ else rtn = path$1.posix.join(FS_PREFIX, id);
50
+ return joinUrlSegments(joinUrlSegments(config.server?.origin ?? "", config.base), removeLeadingSlash(rtn));
61
51
  }
62
-
52
+ //#endregion
63
53
  export { FS_PREFIX, fileToUrl };
@@ -1,242 +1,180 @@
1
1
  /*!
2
- * alphaTab Vite Plugin v1.8.1 (, build 30)
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
-
37
- 'use strict';
38
-
39
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
40
-
41
- const path = require('node:path');
42
- const bridge_constants = require('./constants.cjs');
43
- const bridge_plugins = require('./plugins.cjs');
44
- const bridge_utils = require('./utils.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
- const needsEscapeRegEx = /[\n\r'\\\u2028\u2029]/;
67
- const quoteNewlineRegEx = /([\n\r'\u2028\u2029])/g;
68
- const backSlashRegEx = /\\/g;
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_constants = require("./constants.cjs");
40
+ const require_bridge_plugins = require("./plugins.cjs");
41
+ let node_path = require("node:path");
42
+ node_path = require_chunk.__toESM(node_path, 1);
43
+ //#region src/bridge/build.ts
44
+ var needsEscapeRegEx = /[\n\r'\\\u2028\u2029]/;
45
+ var quoteNewlineRegEx = /([\n\r'\u2028\u2029])/g;
46
+ var backSlashRegEx = /\\/g;
69
47
  function escapeId(id) {
70
- if (!needsEscapeRegEx.test(id)) {
71
- return id;
72
- }
73
- return id.replace(backSlashRegEx, '\\\\').replace(quoteNewlineRegEx, '\\$1');
48
+ if (!needsEscapeRegEx.test(id)) return id;
49
+ return id.replace(backSlashRegEx, "\\\\").replace(quoteNewlineRegEx, "\\$1");
74
50
  }
75
- const getResolveUrl = (path, URL = 'URL') => `new ${URL}(${path}).href`;
76
- const getRelativeUrlFromDocument = (relativePath, umd = false) => getResolveUrl(`'${escapeId(bridge_utils.partialEncodeURIPath(relativePath))}', ${umd ? `typeof document === 'undefined' ? location.href : ` : ''}document.currentScript && document.currentScript.src || document.baseURI`);
77
- const getFileUrlFromFullPath = (path) => `require('u' + 'rl').pathToFileURL(${path}).href`;
78
- const getFileUrlFromRelativePath = (path) => getFileUrlFromFullPath(`__dirname + '/${escapeId(path)}'`);
79
- const relativeUrlMechanisms = {
80
- amd: relativePath => {
81
- if (relativePath[0] !== '.') {
82
- relativePath = `./${relativePath}`;
83
- }
84
- return getResolveUrl(`require.toUrl('${escapeId(relativePath)}'), document.baseURI`);
85
- },
86
- cjs: relativePath => `(typeof document === 'undefined' ? ${getFileUrlFromRelativePath(relativePath)} : ${getRelativeUrlFromDocument(relativePath)})`,
87
- es: relativePath => getResolveUrl(`'${escapeId(bridge_utils.partialEncodeURIPath(relativePath))}', import.meta.url`),
88
- iife: relativePath => getRelativeUrlFromDocument(relativePath),
89
- // NOTE: make sure rollup generate `module` params
90
- system: relativePath => getResolveUrl(`'${escapeId(bridge_utils.partialEncodeURIPath(relativePath))}', module.meta.url`),
91
- umd: relativePath => `(typeof document === 'undefined' && typeof location === 'undefined' ? ${getFileUrlFromRelativePath(relativePath)} : ${getRelativeUrlFromDocument(relativePath, true)})`
92
- };
93
- const customRelativeUrlMechanisms = {
94
- ...relativeUrlMechanisms,
95
- 'worker-iife': relativePath => getResolveUrl(`'${escapeId(bridge_utils.partialEncodeURIPath(relativePath))}', self.location.href`)
51
+ var getResolveUrl = (path, URL = "URL") => `new ${URL}(${path}).href`;
52
+ var getRelativeUrlFromDocument = (relativePath, umd = false) => getResolveUrl(`'${escapeId(require_bridge_utils.partialEncodeURIPath(relativePath))}', ${umd ? `typeof document === 'undefined' ? location.href : ` : ""}document.currentScript && document.currentScript.src || document.baseURI`);
53
+ var getFileUrlFromFullPath = (path) => `require('u' + 'rl').pathToFileURL(${path}).href`;
54
+ var getFileUrlFromRelativePath = (path) => getFileUrlFromFullPath(`__dirname + '/${escapeId(path)}'`);
55
+ var customRelativeUrlMechanisms = {
56
+ amd: (relativePath) => {
57
+ if (relativePath[0] !== ".") relativePath = `./${relativePath}`;
58
+ return getResolveUrl(`require.toUrl('${escapeId(relativePath)}'), document.baseURI`);
59
+ },
60
+ cjs: (relativePath) => `(typeof document === 'undefined' ? ${getFileUrlFromRelativePath(relativePath)} : ${getRelativeUrlFromDocument(relativePath)})`,
61
+ es: (relativePath) => getResolveUrl(`'${escapeId(require_bridge_utils.partialEncodeURIPath(relativePath))}', import.meta.url`),
62
+ iife: (relativePath) => getRelativeUrlFromDocument(relativePath),
63
+ system: (relativePath) => getResolveUrl(`'${escapeId(require_bridge_utils.partialEncodeURIPath(relativePath))}', module.meta.url`),
64
+ umd: (relativePath) => `(typeof document === 'undefined' && typeof location === 'undefined' ? ${getFileUrlFromRelativePath(relativePath)} : ${getRelativeUrlFromDocument(relativePath, true)})`,
65
+ "worker-iife": (relativePath) => getResolveUrl(`'${escapeId(require_bridge_utils.partialEncodeURIPath(relativePath))}', self.location.href`)
96
66
  };
97
67
  /**
98
- * @internal
99
- */
68
+ * @internal
69
+ */
100
70
  function createToImportMetaURLBasedRelativeRuntime(format, isWorker) {
101
- const formatLong = isWorker && format === 'iife' ? 'worker-iife' : format;
102
- const toRelativePath = customRelativeUrlMechanisms[formatLong];
103
- return (filename, importer) => ({
104
- runtime: toRelativePath(path__namespace.posix.relative(path__namespace.dirname(importer), filename))
105
- });
71
+ const toRelativePath = customRelativeUrlMechanisms[isWorker && format === "iife" ? "worker-iife" : format];
72
+ return (filename, importer) => ({ runtime: toRelativePath(node_path.posix.relative(node_path.dirname(importer), filename)) });
106
73
  }
107
74
  /**
108
- * @internal
109
- */
75
+ * @internal
76
+ */
110
77
  function toOutputFilePathInJS(filename, type, hostId, hostType, config, toRelative) {
111
- const { renderBuiltUrl } = config.experimental;
112
- let relative = config.base === '' || config.base === './';
113
- if (renderBuiltUrl) {
114
- const result = renderBuiltUrl(filename, {
115
- hostId,
116
- hostType,
117
- type,
118
- ssr: !!config.build.ssr
119
- });
120
- if (typeof result === 'object') {
121
- if (result.runtime) {
122
- return { runtime: result.runtime };
123
- }
124
- if (typeof result.relative === 'boolean') {
125
- relative = result.relative;
126
- }
127
- }
128
- else if (result) {
129
- return result;
130
- }
131
- }
132
- if (relative && !config.build.ssr) {
133
- return toRelative(filename, hostId);
134
- }
135
- return bridge_utils.joinUrlSegments(config.base, filename);
78
+ const { renderBuiltUrl } = config.experimental;
79
+ let relative = config.base === "" || config.base === "./";
80
+ if (renderBuiltUrl) {
81
+ const result = renderBuiltUrl(filename, {
82
+ hostId,
83
+ hostType,
84
+ type,
85
+ ssr: !!config.build.ssr
86
+ });
87
+ if (typeof result === "object") {
88
+ if (result.runtime) return { runtime: result.runtime };
89
+ if (typeof result.relative === "boolean") relative = result.relative;
90
+ } else if (result) return result;
91
+ }
92
+ if (relative && !config.build.ssr) return toRelative(filename, hostId);
93
+ return require_bridge_utils.joinUrlSegments(config.base, filename);
136
94
  }
137
- // https://github.com/vitejs/vite/blob/v6.1.1/packages/vite/src/node/build.ts#L1131
138
95
  /**
139
- * @internal
140
- */
96
+ * @internal
97
+ */
141
98
  function injectEnvironmentToHooks(environment, plugin) {
142
- const { resolveId, load, transform } = plugin;
143
- const clone = { ...plugin };
144
- for (const hook of Object.keys(clone)) {
145
- switch (hook) {
146
- case 'resolveId':
147
- clone[hook] = wrapEnvironmentResolveId(environment, resolveId);
148
- break;
149
- case 'load':
150
- clone[hook] = wrapEnvironmentLoad(environment, load);
151
- break;
152
- case 'transform':
153
- clone[hook] = wrapEnvironmentTransform(environment, transform);
154
- break;
155
- default:
156
- if (bridge_constants.ROLLUP_HOOKS.includes(hook)) {
157
- clone[hook] = wrapEnvironmentHook(environment, clone[hook]);
158
- }
159
- break;
160
- }
161
- }
162
- return clone;
99
+ const { resolveId, load, transform } = plugin;
100
+ const clone = { ...plugin };
101
+ for (const hook of Object.keys(clone)) switch (hook) {
102
+ case "resolveId":
103
+ clone[hook] = wrapEnvironmentResolveId(environment, resolveId);
104
+ break;
105
+ case "load":
106
+ clone[hook] = wrapEnvironmentLoad(environment, load);
107
+ break;
108
+ case "transform":
109
+ clone[hook] = wrapEnvironmentTransform(environment, transform);
110
+ break;
111
+ default:
112
+ if (require_bridge_constants.ROLLUP_HOOKS.includes(hook)) clone[hook] = wrapEnvironmentHook(environment, clone[hook]);
113
+ break;
114
+ }
115
+ return clone;
163
116
  }
164
117
  function wrapEnvironmentResolveId(environment, hook) {
165
- if (!hook) {
166
- return;
167
- }
168
- const fn = bridge_plugins.getHookHandler(hook);
169
- const handler = function (id, importer, options) {
170
- return fn.call(injectEnvironmentInContext(this, environment), id, importer, injectSsrFlag(options, environment));
171
- };
172
- if ('handler' in hook) {
173
- return {
174
- ...hook,
175
- handler
176
- };
177
- }
178
- return handler;
118
+ if (!hook) return;
119
+ const fn = require_bridge_plugins.getHookHandler(hook);
120
+ const handler = function(id, importer, options) {
121
+ return fn.call(injectEnvironmentInContext(this, environment), id, importer, injectSsrFlag(options, environment));
122
+ };
123
+ if ("handler" in hook) return {
124
+ ...hook,
125
+ handler
126
+ };
127
+ return handler;
179
128
  }
180
129
  function wrapEnvironmentLoad(environment, hook) {
181
- if (!hook) {
182
- return;
183
- }
184
- const fn = bridge_plugins.getHookHandler(hook);
185
- const handler = function (id, ...args) {
186
- return fn.call(injectEnvironmentInContext(this, environment), id, injectSsrFlag(args[0], environment));
187
- };
188
- if ('handler' in hook) {
189
- return {
190
- ...hook,
191
- handler
192
- };
193
- }
194
- return handler;
130
+ if (!hook) return;
131
+ const fn = require_bridge_plugins.getHookHandler(hook);
132
+ const handler = function(id, ...args) {
133
+ return fn.call(injectEnvironmentInContext(this, environment), id, injectSsrFlag(args[0], environment));
134
+ };
135
+ if ("handler" in hook) return {
136
+ ...hook,
137
+ handler
138
+ };
139
+ return handler;
195
140
  }
196
141
  function wrapEnvironmentTransform(environment, hook) {
197
- if (!hook) {
198
- return;
199
- }
200
- const fn = bridge_plugins.getHookHandler(hook);
201
- const handler = function (code, importer, ...args) {
202
- return fn.call(injectEnvironmentInContext(this, environment), code, importer, injectSsrFlag(args[0], environment));
203
- };
204
- if ('handler' in hook) {
205
- return {
206
- ...hook,
207
- handler
208
- };
209
- }
210
- return handler;
142
+ if (!hook) return;
143
+ const fn = require_bridge_plugins.getHookHandler(hook);
144
+ const handler = function(code, importer, ...args) {
145
+ return fn.call(injectEnvironmentInContext(this, environment), code, importer, injectSsrFlag(args[0], environment));
146
+ };
147
+ if ("handler" in hook) return {
148
+ ...hook,
149
+ handler
150
+ };
151
+ return handler;
211
152
  }
212
153
  function wrapEnvironmentHook(environment, hook) {
213
- if (!hook) {
214
- return;
215
- }
216
- const fn = bridge_plugins.getHookHandler(hook);
217
- if (typeof fn !== 'function') {
218
- return hook;
219
- }
220
- const handler = function (...args) {
221
- return fn.call(injectEnvironmentInContext(this, environment), ...args);
222
- };
223
- if ('handler' in hook) {
224
- return {
225
- ...hook,
226
- handler
227
- };
228
- }
229
- return handler;
154
+ if (!hook) return;
155
+ const fn = require_bridge_plugins.getHookHandler(hook);
156
+ if (typeof fn !== "function") return hook;
157
+ const handler = function(...args) {
158
+ return fn.call(injectEnvironmentInContext(this, environment), ...args);
159
+ };
160
+ if ("handler" in hook) return {
161
+ ...hook,
162
+ handler
163
+ };
164
+ return handler;
230
165
  }
231
166
  function injectEnvironmentInContext(context, environment) {
232
- context.environment ??= environment;
233
- return context;
167
+ context.environment ??= environment;
168
+ return context;
234
169
  }
235
170
  function injectSsrFlag(options, environment) {
236
- const ssr = environment ? environment.config.consumer === 'server' : true;
237
- return { ...(options ?? {}), ssr };
171
+ const ssr = environment ? environment.config.consumer === "server" : true;
172
+ return {
173
+ ...options ?? {},
174
+ ssr
175
+ };
238
176
  }
239
-
177
+ //#endregion
240
178
  exports.createToImportMetaURLBasedRelativeRuntime = createToImportMetaURLBasedRelativeRuntime;
241
179
  exports.injectEnvironmentToHooks = injectEnvironmentToHooks;
242
180
  exports.toOutputFilePathInJS = toOutputFilePathInJS;