muon-ui 0.1.0 → 0.2.0
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/{build-CCuZpajl.cjs → build-BxDRaTmF.cjs} +83 -26
- package/dist/{build-CCuZpajl.cjs.map → build-BxDRaTmF.cjs.map} +1 -1
- package/dist/cli.cjs +12 -10
- package/dist/cli.cjs.map +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.mjs +2 -2
- package/dist/native/linux64/muon-bootstrap +0 -0
- package/dist/native/linux64/muon-prepare +0 -0
- package/dist/native/linuxarm/muon-bootstrap +0 -0
- package/dist/native/linuxarm/muon-prepare +0 -0
- package/dist/native/linuxarm64/muon-bootstrap +0 -0
- package/dist/native/linuxarm64/muon-prepare +0 -0
- package/dist/native/windows32/muon-bootstrap.exe +0 -0
- package/dist/native/windows32/muon-prepare.exe +0 -0
- package/dist/native/windows64/muon-bootstrap.exe +0 -0
- package/dist/native/windows64/muon-prepare.exe +0 -0
- package/dist/runtime/{linuxarm64/THIRD_PARTY_NOTICES.md → linux64/LICENSE_muon} +59 -16
- package/dist/runtime/linux64/muon-core +0 -0
- package/dist/runtime/{windows32/THIRD_PARTY_NOTICES.md → linuxarm/LICENSE_muon} +59 -16
- package/dist/runtime/linuxarm/muon-core +0 -0
- package/dist/runtime/{linux64/THIRD_PARTY_NOTICES.md → linuxarm64/LICENSE_muon} +59 -16
- package/dist/runtime/linuxarm64/muon-core +0 -0
- package/dist/runtime/{linuxarm/THIRD_PARTY_NOTICES.md → windows32/LICENSE_muon} +59 -16
- package/dist/runtime/windows32/libcardio.dll +0 -0
- package/dist/runtime/windows32/libmuon-ui.dll +0 -0
- package/dist/runtime/windows32/muon-core.exe +0 -0
- package/dist/runtime/windows64/LICENSE_muon +266 -0
- package/dist/runtime/windows64/libcardio.dll +0 -0
- package/dist/runtime/windows64/libmuon-ui.dll +0 -0
- package/dist/runtime/windows64/muon-core.exe +0 -0
- package/dist/vite.cjs +59 -18
- package/dist/vite.cjs.map +1 -1
- package/dist/vite.mjs +135 -47
- package/dist/vite.mjs.map +1 -1
- package/package.json +8 -8
- package/dist/runtime/windows64/THIRD_PARTY_NOTICES.md +0 -223
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
# muon license
|
|
2
|
+
|
|
3
|
+
## muon
|
|
4
|
+
|
|
5
|
+
Source: https://github.com/kekyo/muon-ui/
|
|
6
|
+
|
|
7
|
+
Copyright (c) Kouji Matsui (@kekyo@mi.kekyo.net)
|
|
8
|
+
|
|
9
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
10
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
11
|
+
in the Software without restriction, including without limitation the rights
|
|
12
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
13
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
14
|
+
furnished to do so, subject to the following conditions:
|
|
15
|
+
|
|
16
|
+
The above copyright notice and this permission notice shall be included in all
|
|
17
|
+
copies or substantial portions of the Software.
|
|
18
|
+
|
|
19
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
20
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
21
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
22
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
23
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
24
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
25
|
+
SOFTWARE.
|
|
26
|
+
|
|
27
|
+
## Chromium Embedded Framework (CEF)
|
|
28
|
+
|
|
29
|
+
Source: https://github.com/chromiumembedded/cef/
|
|
30
|
+
|
|
31
|
+
Copyright (c) 2008-2020 Marshall A. Greenblatt. Portions Copyright (c)
|
|
32
|
+
2006-2009 Google Inc. All rights reserved.
|
|
33
|
+
|
|
34
|
+
Redistribution and use in source and binary forms, with or without
|
|
35
|
+
modification, are permitted provided that the following conditions are
|
|
36
|
+
met:
|
|
37
|
+
|
|
38
|
+
* Redistributions of source code must retain the above copyright
|
|
39
|
+
notice, this list of conditions and the following disclaimer.
|
|
40
|
+
* Redistributions in binary form must reproduce the above
|
|
41
|
+
copyright notice, this list of conditions and the following disclaimer
|
|
42
|
+
in the documentation and/or other materials provided with the
|
|
43
|
+
distribution.
|
|
44
|
+
* Neither the name of Google Inc. nor the name Chromium Embedded
|
|
45
|
+
Framework nor the names of its contributors may be used to endorse
|
|
46
|
+
or promote products derived from this software without specific prior
|
|
47
|
+
written permission.
|
|
48
|
+
|
|
49
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
50
|
+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
51
|
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
52
|
+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
53
|
+
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
54
|
+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
55
|
+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
56
|
+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
57
|
+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
58
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
59
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
60
|
+
|
|
61
|
+
## libffi 3.4.6
|
|
62
|
+
|
|
63
|
+
Source: https://github.com/libffi/libffi/releases/tag/v3.4.6
|
|
64
|
+
|
|
65
|
+
libffi - Copyright (c) 1996-2024 Anthony Green, Red Hat, Inc and others.
|
|
66
|
+
See source files for details.
|
|
67
|
+
|
|
68
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
69
|
+
a copy of this software and associated documentation files (the
|
|
70
|
+
``Software''), to deal in the Software without restriction, including
|
|
71
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
72
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
73
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
74
|
+
the following conditions:
|
|
75
|
+
|
|
76
|
+
The above copyright notice and this permission notice shall be
|
|
77
|
+
included in all copies or substantial portions of the Software.
|
|
78
|
+
|
|
79
|
+
THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
|
|
80
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
81
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
82
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
83
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
84
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
85
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
86
|
+
|
|
87
|
+
## yyjson 0.12.0
|
|
88
|
+
|
|
89
|
+
Source: https://github.com/ibireme/yyjson/tree/0.12.0
|
|
90
|
+
|
|
91
|
+
Copyright (c) 2020 YaoYuan <ibireme@gmail.com>
|
|
92
|
+
|
|
93
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
94
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
95
|
+
in the Software without restriction, including without limitation the rights
|
|
96
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
97
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
98
|
+
furnished to do so, subject to the following conditions:
|
|
99
|
+
|
|
100
|
+
The above copyright notice and this permission notice shall be included in all
|
|
101
|
+
copies or substantial portions of the Software.
|
|
102
|
+
|
|
103
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
104
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
105
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
106
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
107
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
108
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
109
|
+
SOFTWARE.
|
|
110
|
+
|
|
111
|
+
## NetBSD SHA1
|
|
112
|
+
|
|
113
|
+
Source:
|
|
114
|
+
https://github.com/NetBSD/src/tree/trunk/common/lib/libc/hash/sha1
|
|
115
|
+
|
|
116
|
+
SHA-1 in C
|
|
117
|
+
By Steve Reid <steve@edmweb.com>
|
|
118
|
+
100% Public Domain
|
|
119
|
+
|
|
120
|
+
## libarchive 3.8.7
|
|
121
|
+
|
|
122
|
+
Source: https://github.com/libarchive/libarchive/releases/tag/v3.8.7
|
|
123
|
+
|
|
124
|
+
The libarchive distribution as a whole is Copyright by Tim Kientzle
|
|
125
|
+
and is subject to the copyright notice reproduced below.
|
|
126
|
+
|
|
127
|
+
Copyright (c) 2003-2018 <author(s)>
|
|
128
|
+
All rights reserved.
|
|
129
|
+
|
|
130
|
+
Redistribution and use in source and binary forms, with or without
|
|
131
|
+
modification, are permitted provided that the following conditions
|
|
132
|
+
are met:
|
|
133
|
+
1. Redistributions of source code must retain the above copyright
|
|
134
|
+
notice, this list of conditions and the following disclaimer
|
|
135
|
+
in this position and unchanged.
|
|
136
|
+
2. Redistributions in binary form must reproduce the above copyright
|
|
137
|
+
notice, this list of conditions and the following disclaimer in the
|
|
138
|
+
documentation and/or other materials provided with the distribution.
|
|
139
|
+
|
|
140
|
+
THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
|
141
|
+
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
142
|
+
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
143
|
+
IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
144
|
+
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
145
|
+
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
146
|
+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
147
|
+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
148
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
149
|
+
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
150
|
+
|
|
151
|
+
## bzip2/libbzip2 1.0.8
|
|
152
|
+
|
|
153
|
+
Source: https://sourceware.org/pub/bzip2/bzip2-1.0.8.tar.gz
|
|
154
|
+
|
|
155
|
+
License: bzip2/libbzip2 license
|
|
156
|
+
|
|
157
|
+
This program, "bzip2", the associated library "libbzip2", and all
|
|
158
|
+
documentation, are copyright (C) 1996-2019 Julian R Seward. All
|
|
159
|
+
rights reserved.
|
|
160
|
+
|
|
161
|
+
Redistribution and use in source and binary forms, with or without
|
|
162
|
+
modification, are permitted provided that the following conditions
|
|
163
|
+
are met:
|
|
164
|
+
|
|
165
|
+
1. Redistributions of source code must retain the above copyright
|
|
166
|
+
notice, this list of conditions and the following disclaimer.
|
|
167
|
+
|
|
168
|
+
2. The origin of this software must not be misrepresented; you must
|
|
169
|
+
not claim that you wrote the original software. If you use this
|
|
170
|
+
software in a product, an acknowledgment in the product
|
|
171
|
+
documentation would be appreciated but is not required.
|
|
172
|
+
|
|
173
|
+
3. Altered source versions must be plainly marked as such, and must
|
|
174
|
+
not be misrepresented as being the original software.
|
|
175
|
+
|
|
176
|
+
4. The name of the author may not be used to endorse or promote
|
|
177
|
+
products derived from this software without specific prior written
|
|
178
|
+
permission.
|
|
179
|
+
|
|
180
|
+
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
|
181
|
+
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
182
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
183
|
+
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
|
184
|
+
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
185
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
|
186
|
+
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
187
|
+
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
|
188
|
+
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
189
|
+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
190
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
191
|
+
|
|
192
|
+
Julian Seward, jseward@acm.org
|
|
193
|
+
bzip2/libbzip2 version 1.0.8 of 13 July 2019
|
|
194
|
+
|
|
195
|
+
## miniz 3.1.1
|
|
196
|
+
|
|
197
|
+
Source: https://github.com/richgel999/miniz/tree/3.1.1
|
|
198
|
+
|
|
199
|
+
Copyright 2013-2014 RAD Game Tools and Valve Software
|
|
200
|
+
Copyright 2010-2014 Rich Geldreich and Tenacious Software LLC
|
|
201
|
+
|
|
202
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
203
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
204
|
+
in the Software without restriction, including without limitation the rights
|
|
205
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
206
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
207
|
+
furnished to do so, subject to the following conditions:
|
|
208
|
+
|
|
209
|
+
The above copyright notice and this permission notice shall be included in all
|
|
210
|
+
copies or substantial portions of the Software.
|
|
211
|
+
|
|
212
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
213
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
214
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
215
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
216
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
217
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
218
|
+
SOFTWARE.
|
|
219
|
+
|
|
220
|
+
## cardio
|
|
221
|
+
|
|
222
|
+
Source: https://github.com/kekyo/cardio/
|
|
223
|
+
|
|
224
|
+
Copyright (c) Kouji Matsui (@kekyo@mi.kekyo.net)
|
|
225
|
+
|
|
226
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
227
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
228
|
+
in the Software without restriction, including without limitation the rights
|
|
229
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
230
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
231
|
+
furnished to do so, subject to the following conditions:
|
|
232
|
+
|
|
233
|
+
The above copyright notice and this permission notice shall be included in all
|
|
234
|
+
copies or substantial portions of the Software.
|
|
235
|
+
|
|
236
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
237
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
238
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
239
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
240
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
241
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
242
|
+
SOFTWARE.
|
|
243
|
+
|
|
244
|
+
## tra-ffic
|
|
245
|
+
|
|
246
|
+
Source: https://github.com/kekyo/tra-ffic/
|
|
247
|
+
|
|
248
|
+
Copyright (c) Kouji Matsui (@kekyo@mi.kekyo.net)
|
|
249
|
+
|
|
250
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
251
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
252
|
+
in the Software without restriction, including without limitation the rights
|
|
253
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
254
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
255
|
+
furnished to do so, subject to the following conditions:
|
|
256
|
+
|
|
257
|
+
The above copyright notice and this permission notice shall be included in all
|
|
258
|
+
copies or substantial portions of the Software.
|
|
259
|
+
|
|
260
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
261
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
262
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
263
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
264
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
265
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
266
|
+
SOFTWARE.
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/dist/vite.cjs
CHANGED
|
@@ -1,25 +1,31 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* name: muon-ui
|
|
3
|
-
* version: 0.
|
|
3
|
+
* version: 0.2.0
|
|
4
4
|
* description: A multi-platform GUI application framework that uses CEF as its backend
|
|
5
5
|
* author: Kouji Matsui (@kekyo@mi.kekyo.net)
|
|
6
6
|
* license: MIT
|
|
7
7
|
* repository.url: https://github.com/kekyo/muon-ui.git
|
|
8
|
-
* git.commit.hash:
|
|
8
|
+
* git.commit.hash: 6251ff88aafa8ae873657f39aed1ebba2fa329a4
|
|
9
9
|
*/
|
|
10
|
-
const require_build = require("./build-
|
|
10
|
+
const require_build = require("./build-BxDRaTmF.cjs");
|
|
11
11
|
let node_fs = require("node:fs");
|
|
12
12
|
let node_fs_promises = require("node:fs/promises");
|
|
13
13
|
let node_url = require("node:url");
|
|
14
14
|
let node_path = require("node:path");
|
|
15
15
|
let node_os = require("node:os");
|
|
16
16
|
//#region src/vite-internals.ts
|
|
17
|
+
var import_dist = require_build.require_dist();
|
|
17
18
|
var getServerOpenValue = (server) => {
|
|
18
19
|
const open = server.config.server.open;
|
|
19
20
|
return open === true || typeof open === "string" ? open : false;
|
|
20
21
|
};
|
|
21
22
|
var resolveFromRoot = (root, path) => (0, node_path.isAbsolute)(path) ? path : (0, node_path.resolve)(root, path);
|
|
22
23
|
var moduleDirectory = typeof __dirname === "string" ? __dirname : (0, node_path.dirname)((0, node_url.fileURLToPath)({}.url));
|
|
24
|
+
var defaultProjectConfigFileNames = [
|
|
25
|
+
"muon.json5",
|
|
26
|
+
"muon.jsonc",
|
|
27
|
+
"muon.json"
|
|
28
|
+
];
|
|
23
29
|
/**
|
|
24
30
|
* Resolves the muon-core runtime directory used by the Vite plugin.
|
|
25
31
|
*
|
|
@@ -31,16 +37,21 @@ var getMuonExecutablePath = (runtimePath, platform) => (0, node_path.join)(runti
|
|
|
31
37
|
var getLaunchScriptFileName = (platform) => platform === "win32" ? "open-muon.cmd" : "open-muon.sh";
|
|
32
38
|
var quotePosix = (value) => `'${value.replaceAll("'", "'\\''")}'`;
|
|
33
39
|
var getPlatformDirectoryName = (path, platform) => platform === "win32" ? node_path.win32.dirname(path) : (0, node_path.dirname)(path);
|
|
40
|
+
var getOptionalPosixValue = (value) => value === void 0 ? "''" : quotePosix(value);
|
|
34
41
|
var createPosixMuonLaunchScript = ({ muonExecutablePath, projectConfigPath, overrideConfigPath }) => `#!/usr/bin/env bash
|
|
35
42
|
set -euo pipefail
|
|
36
43
|
MUON_EXECUTABLE=${quotePosix(muonExecutablePath)}
|
|
37
44
|
MUON_EXECUTABLE_DIRECTORY=${quotePosix(getPlatformDirectoryName(muonExecutablePath, "linux"))}
|
|
38
|
-
MUON_PROJECT_CONFIG=${
|
|
45
|
+
MUON_PROJECT_CONFIG=${getOptionalPosixValue(projectConfigPath)}
|
|
39
46
|
MUON_OVERRIDE_CONFIG=${quotePosix(overrideConfigPath)}
|
|
40
47
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
48
|
+
MUON_CONFIG_ARGS=()
|
|
49
|
+
if [[ -n "$MUON_PROJECT_CONFIG" ]]; then
|
|
50
|
+
if [[ ! -f "$MUON_PROJECT_CONFIG" ]]; then
|
|
51
|
+
echo "Muon startup failed: project config does not exist: $MUON_PROJECT_CONFIG" >&2
|
|
52
|
+
exit 1
|
|
53
|
+
fi
|
|
54
|
+
MUON_CONFIG_ARGS+=("-c" "$MUON_PROJECT_CONFIG")
|
|
44
55
|
fi
|
|
45
56
|
|
|
46
57
|
if [[ ! -x "$MUON_EXECUTABLE" ]]; then
|
|
@@ -52,23 +63,20 @@ if [[ ! -f "$MUON_OVERRIDE_CONFIG" ]]; then
|
|
|
52
63
|
echo "Muon startup failed: generated override config does not exist: $MUON_OVERRIDE_CONFIG" >&2
|
|
53
64
|
exit 1
|
|
54
65
|
fi
|
|
66
|
+
MUON_CONFIG_ARGS+=("-c" "$MUON_OVERRIDE_CONFIG")
|
|
55
67
|
|
|
56
68
|
cd "$MUON_EXECUTABLE_DIRECTORY"
|
|
57
|
-
exec "$MUON_EXECUTABLE"
|
|
69
|
+
exec "$MUON_EXECUTABLE" "\${MUON_CONFIG_ARGS[@]}"
|
|
58
70
|
`;
|
|
59
71
|
var escapeWindowsCmdValue = (value) => value.replaceAll("%", "%%").replaceAll("\r", "").replaceAll("\n", "");
|
|
72
|
+
var getOptionalWindowsCmdValue = (value) => value === void 0 ? "" : escapeWindowsCmdValue(value);
|
|
60
73
|
var createWindowsMuonLaunchScript = ({ muonExecutablePath, projectConfigPath, overrideConfigPath }) => `@echo off
|
|
61
74
|
setlocal
|
|
62
75
|
set "MUON_EXECUTABLE=${escapeWindowsCmdValue(muonExecutablePath)}"
|
|
63
76
|
set "MUON_EXECUTABLE_DIRECTORY=${escapeWindowsCmdValue(getPlatformDirectoryName(muonExecutablePath, "win32"))}"
|
|
64
|
-
set "MUON_PROJECT_CONFIG=${
|
|
77
|
+
set "MUON_PROJECT_CONFIG=${getOptionalWindowsCmdValue(projectConfigPath)}"
|
|
65
78
|
set "MUON_OVERRIDE_CONFIG=${escapeWindowsCmdValue(overrideConfigPath)}"
|
|
66
79
|
|
|
67
|
-
if not exist "%MUON_PROJECT_CONFIG%" (
|
|
68
|
-
echo Muon startup failed: project config does not exist: %MUON_PROJECT_CONFIG% 1>&2
|
|
69
|
-
exit /b 1
|
|
70
|
-
)
|
|
71
|
-
|
|
72
80
|
if not exist "%MUON_EXECUTABLE%" (
|
|
73
81
|
echo Muon startup failed: executable does not exist: %MUON_EXECUTABLE% 1>&2
|
|
74
82
|
exit /b 1
|
|
@@ -80,7 +88,16 @@ if not exist "%MUON_OVERRIDE_CONFIG%" (
|
|
|
80
88
|
)
|
|
81
89
|
|
|
82
90
|
pushd "%MUON_EXECUTABLE_DIRECTORY%"
|
|
83
|
-
|
|
91
|
+
if defined MUON_PROJECT_CONFIG (
|
|
92
|
+
if not exist "%MUON_PROJECT_CONFIG%" (
|
|
93
|
+
echo Muon startup failed: project config does not exist: %MUON_PROJECT_CONFIG% 1>&2
|
|
94
|
+
popd
|
|
95
|
+
exit /b 1
|
|
96
|
+
)
|
|
97
|
+
"%MUON_EXECUTABLE%" -c "%MUON_PROJECT_CONFIG%" -c "%MUON_OVERRIDE_CONFIG%"
|
|
98
|
+
) else (
|
|
99
|
+
"%MUON_EXECUTABLE%" -c "%MUON_OVERRIDE_CONFIG%"
|
|
100
|
+
)
|
|
84
101
|
set "MUON_EXIT_CODE=%ERRORLEVEL%"
|
|
85
102
|
popd
|
|
86
103
|
exit /b %MUON_EXIT_CODE%
|
|
@@ -116,16 +133,40 @@ var writeMuonOverrideConfig = (server, openValue, overrideConfigPath) => {
|
|
|
116
133
|
}
|
|
117
134
|
(0, node_fs.writeFileSync)(overrideConfigPath, `${JSON.stringify(createMuonOverrideConfig(startUrl), null, 2)}\n`);
|
|
118
135
|
};
|
|
119
|
-
var createRuntimePaths = async (server, stagePath, platform) => {
|
|
136
|
+
var createRuntimePaths = async (server, stagePath, platform, projectConfigPath) => {
|
|
120
137
|
const temporaryDirectory = await (0, node_fs_promises.mkdtemp)((0, node_path.join)((0, node_os.tmpdir)(), "muon-vite-"));
|
|
121
138
|
return {
|
|
122
139
|
temporaryDirectory,
|
|
123
140
|
launchScriptPath: (0, node_path.join)(temporaryDirectory, getLaunchScriptFileName(platform)),
|
|
124
141
|
overrideConfigPath: (0, node_path.join)(temporaryDirectory, "muon.vite.json"),
|
|
125
|
-
projectConfigPath
|
|
142
|
+
projectConfigPath,
|
|
126
143
|
muonExecutablePath: getMuonExecutablePath(stagePath, platform)
|
|
127
144
|
};
|
|
128
145
|
};
|
|
146
|
+
var fileExists = async (path) => {
|
|
147
|
+
try {
|
|
148
|
+
await (0, node_fs_promises.access)(path, node_fs.constants.F_OK);
|
|
149
|
+
return true;
|
|
150
|
+
} catch {
|
|
151
|
+
return false;
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
var isJsonObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
155
|
+
var getErrorMessage = (error) => error instanceof Error ? error.message : String(error);
|
|
156
|
+
var resolveProjectConfigPath = async (server) => {
|
|
157
|
+
for (const fileName of defaultProjectConfigFileNames) {
|
|
158
|
+
const candidatePath = (0, node_path.join)(server.config.root, fileName);
|
|
159
|
+
if (!await fileExists(candidatePath)) continue;
|
|
160
|
+
try {
|
|
161
|
+
if (!isJsonObject((0, import_dist.parse)(await (0, node_fs_promises.readFile)(candidatePath, "utf8")))) throw new Error("muon config root must be an object");
|
|
162
|
+
return candidatePath;
|
|
163
|
+
} catch (error) {
|
|
164
|
+
server.config.logger.warn(`Muon project config will be ignored because it could not be read or parsed: ${candidatePath}: ${getErrorMessage(error)}`);
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
server.config.logger.warn(`Muon project config was not found in ${server.config.root}; launching with generated Vite config only.`);
|
|
169
|
+
};
|
|
129
170
|
var writeLaunchScript = async (paths, platform) => {
|
|
130
171
|
await (0, node_fs_promises.writeFile)(paths.launchScriptPath, createMuonLaunchScript({
|
|
131
172
|
muonExecutablePath: paths.muonExecutablePath,
|
|
@@ -156,7 +197,7 @@ var startMuonViteBrowserBridge = async ({ server, pluginOptions, platform, archi
|
|
|
156
197
|
cwd: server.config.root
|
|
157
198
|
});
|
|
158
199
|
if (preparedRuntime.stagePath === void 0) throw new Error("muon-prepare did not return a staged runtime path.");
|
|
159
|
-
const paths = await createRuntimePaths(server, preparedRuntime.stagePath, platform);
|
|
200
|
+
const paths = await createRuntimePaths(server, preparedRuntime.stagePath, platform, await resolveProjectConfigPath(server));
|
|
160
201
|
await writeLaunchScript(paths, platform);
|
|
161
202
|
const previousBrowser = environment.BROWSER;
|
|
162
203
|
environment.BROWSER = paths.launchScriptPath;
|
package/dist/vite.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite.cjs","names":[],"sources":["../src/vite-internals.ts","../src/vite.ts"],"sourcesContent":["// muon - Multi-platform GUI application framework that uses CEF as its backend\n// Copyright (c) Kouji Matsui. (@kekyo@mi.kekyo.net)\n// Under MIT.\n// https://github.com/kekyo/muon\n\nimport { chmod, mkdtemp, rm, writeFile } from \"node:fs/promises\";\nimport { writeFileSync } from \"node:fs\";\nimport { tmpdir } from \"node:os\";\nimport { dirname, isAbsolute, join, resolve, win32 } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\nimport type { ViteDevServer } from \"vite\";\n\nimport { getDefaultMuonPrepareTarget, runMuonPrepare } from \"./prepare.js\";\nimport type { MuonVitePluginOptions } from \"./vite.js\";\n\nexport interface MuonLaunchScriptOptions {\n muonExecutablePath: string;\n projectConfigPath: string;\n overrideConfigPath: string;\n platform: NodeJS.Platform;\n}\n\ninterface MuonViteSessionOptions {\n server: ViteDevServer;\n pluginOptions: MuonVitePluginOptions;\n platform: NodeJS.Platform;\n architecture: NodeJS.Architecture;\n environment: NodeJS.ProcessEnv;\n}\n\ninterface MuonRuntimePaths {\n temporaryDirectory: string;\n launchScriptPath: string;\n overrideConfigPath: string;\n projectConfigPath: string;\n muonExecutablePath: string;\n}\n\ninterface MuonOverrideConfig {\n browser: {\n startPage: string;\n plugin: {\n allow: string[];\n };\n };\n network: {\n allow: string[];\n };\n}\n\n/**\n * Options for resolving a Muon runtime directory used by the Vite plugin.\n */\nexport interface MuonRuntimePathOptions {\n /**\n * Vite project root used to resolve explicit relative paths.\n */\n root: string;\n\n /**\n * Muon runtime target such as linux64, linuxarm, linuxarm64, windows32, or windows64.\n */\n target: string;\n\n /**\n * Explicit custom muon-core runtime path.\n */\n muonPath: string | undefined;\n\n /**\n * Directory containing the packaged Muon JavaScript files.\n *\n * @remarks This is injectable for tests. Production code uses the module directory.\n */\n packageDirectory?: string;\n}\n\nconst getServerOpenValue = (\n server: ViteDevServer,\n): boolean | string | false => {\n const open = server.config.server.open;\n return open === true || typeof open === \"string\" ? open : false;\n};\n\nconst resolveFromRoot = (root: string, path: string): string =>\n isAbsolute(path) ? path : resolve(root, path);\n\nconst moduleDirectory =\n typeof __dirname === \"string\"\n ? __dirname\n : dirname(fileURLToPath(import.meta.url));\n\n/**\n * Resolves the muon-core runtime directory used by the Vite plugin.\n *\n * @param options Runtime path resolution inputs.\n * @returns Absolute or package-relative runtime directory path.\n */\nexport const resolveMuonRuntimePath = ({\n root,\n target,\n muonPath,\n packageDirectory = moduleDirectory,\n}: MuonRuntimePathOptions): string =>\n muonPath === undefined\n ? join(packageDirectory, \"runtime\", target)\n : resolveFromRoot(root, muonPath);\n\nexport const getMuonExecutablePath = (\n runtimePath: string,\n platform: NodeJS.Platform,\n): string =>\n join(runtimePath, platform === \"win32\" ? \"muon-core.exe\" : \"muon-core\");\n\nconst getLaunchScriptFileName = (platform: NodeJS.Platform): string =>\n platform === \"win32\" ? \"open-muon.cmd\" : \"open-muon.sh\";\n\nconst quotePosix = (value: string): string =>\n `'${value.replaceAll(\"'\", \"'\\\\''\")}'`;\n\nconst getPlatformDirectoryName = (\n path: string,\n platform: NodeJS.Platform,\n): string => (platform === \"win32\" ? win32.dirname(path) : dirname(path));\n\nconst createPosixMuonLaunchScript = ({\n muonExecutablePath,\n projectConfigPath,\n overrideConfigPath,\n}: MuonLaunchScriptOptions): string => `#!/usr/bin/env bash\nset -euo pipefail\nMUON_EXECUTABLE=${quotePosix(muonExecutablePath)}\nMUON_EXECUTABLE_DIRECTORY=${quotePosix(getPlatformDirectoryName(muonExecutablePath, \"linux\"))}\nMUON_PROJECT_CONFIG=${quotePosix(projectConfigPath)}\nMUON_OVERRIDE_CONFIG=${quotePosix(overrideConfigPath)}\n\nif [[ ! -f \"$MUON_PROJECT_CONFIG\" ]]; then\n echo \"Muon startup failed: project config does not exist: $MUON_PROJECT_CONFIG\" >&2\n exit 1\nfi\n\nif [[ ! -x \"$MUON_EXECUTABLE\" ]]; then\n echo \"Muon startup failed: executable does not exist or is not executable: $MUON_EXECUTABLE\" >&2\n exit 1\nfi\n\nif [[ ! -f \"$MUON_OVERRIDE_CONFIG\" ]]; then\n echo \"Muon startup failed: generated override config does not exist: $MUON_OVERRIDE_CONFIG\" >&2\n exit 1\nfi\n\ncd \"$MUON_EXECUTABLE_DIRECTORY\"\nexec \"$MUON_EXECUTABLE\" -c \"$MUON_PROJECT_CONFIG\" -c \"$MUON_OVERRIDE_CONFIG\"\n`;\n\nconst escapeWindowsCmdValue = (value: string): string =>\n value.replaceAll(\"%\", \"%%\").replaceAll(\"\\r\", \"\").replaceAll(\"\\n\", \"\");\n\nconst createWindowsMuonLaunchScript = ({\n muonExecutablePath,\n projectConfigPath,\n overrideConfigPath,\n}: MuonLaunchScriptOptions): string => `@echo off\nsetlocal\nset \"MUON_EXECUTABLE=${escapeWindowsCmdValue(muonExecutablePath)}\"\nset \"MUON_EXECUTABLE_DIRECTORY=${escapeWindowsCmdValue(getPlatformDirectoryName(muonExecutablePath, \"win32\"))}\"\nset \"MUON_PROJECT_CONFIG=${escapeWindowsCmdValue(projectConfigPath)}\"\nset \"MUON_OVERRIDE_CONFIG=${escapeWindowsCmdValue(overrideConfigPath)}\"\n\nif not exist \"%MUON_PROJECT_CONFIG%\" (\n echo Muon startup failed: project config does not exist: %MUON_PROJECT_CONFIG% 1>&2\n exit /b 1\n)\n\nif not exist \"%MUON_EXECUTABLE%\" (\n echo Muon startup failed: executable does not exist: %MUON_EXECUTABLE% 1>&2\n exit /b 1\n)\n\nif not exist \"%MUON_OVERRIDE_CONFIG%\" (\n echo Muon startup failed: generated override config does not exist: %MUON_OVERRIDE_CONFIG% 1>&2\n exit /b 1\n)\n\npushd \"%MUON_EXECUTABLE_DIRECTORY%\"\n\"%MUON_EXECUTABLE%\" -c \"%MUON_PROJECT_CONFIG%\" -c \"%MUON_OVERRIDE_CONFIG%\"\nset \"MUON_EXIT_CODE=%ERRORLEVEL%\"\npopd\nexit /b %MUON_EXIT_CODE%\n`;\n\nexport const createMuonLaunchScript = (\n options: MuonLaunchScriptOptions,\n): string =>\n options.platform === \"win32\"\n ? createWindowsMuonLaunchScript(options)\n : createPosixMuonLaunchScript(options);\n\nconst getBaseUrl = (server: ViteDevServer): string | undefined =>\n server.resolvedUrls?.local[0] ?? server.resolvedUrls?.network[0];\n\nconst getStartUrl = (\n server: ViteDevServer,\n openValue: boolean | string,\n): string | undefined => {\n const baseUrl = getBaseUrl(server);\n if (baseUrl === undefined) {\n return undefined;\n }\n return typeof openValue === \"string\"\n ? new URL(openValue, baseUrl).href\n : baseUrl;\n};\n\nconst getWebSocketOrigin = (startUrl: string): string => {\n const url = new URL(startUrl);\n if (url.protocol === \"https:\") {\n url.protocol = \"wss:\";\n } else if (url.protocol === \"http:\") {\n url.protocol = \"ws:\";\n }\n return url.origin;\n};\n\nconst createMuonOverrideConfig = (startUrl: string): MuonOverrideConfig => {\n const origin = new URL(startUrl).origin;\n return {\n browser: {\n startPage: startUrl,\n plugin: {\n allow: [`${origin}/**`],\n },\n },\n network: {\n allow: [`${origin}/**`, `${getWebSocketOrigin(startUrl)}/**`],\n },\n };\n};\n\nconst writeMuonOverrideConfig = (\n server: ViteDevServer,\n openValue: boolean | string,\n overrideConfigPath: string,\n): void => {\n const startUrl = getStartUrl(server, openValue);\n if (startUrl === undefined) {\n server.config.logger.warn(\"Muon Vite plugin could not resolve a Vite URL.\");\n return;\n }\n writeFileSync(\n overrideConfigPath,\n `${JSON.stringify(createMuonOverrideConfig(startUrl), null, 2)}\\n`,\n );\n};\n\nconst createRuntimePaths = async (\n server: ViteDevServer,\n stagePath: string,\n platform: NodeJS.Platform,\n): Promise<MuonRuntimePaths> => {\n const temporaryDirectory = await mkdtemp(join(tmpdir(), \"muon-vite-\"));\n return {\n temporaryDirectory,\n launchScriptPath: join(\n temporaryDirectory,\n getLaunchScriptFileName(platform),\n ),\n overrideConfigPath: join(temporaryDirectory, \"muon.vite.json\"),\n projectConfigPath: join(server.config.root, \"muon.json\"),\n muonExecutablePath: getMuonExecutablePath(stagePath, platform),\n };\n};\n\nconst writeLaunchScript = async (\n paths: MuonRuntimePaths,\n platform: NodeJS.Platform,\n): Promise<void> => {\n await writeFile(\n paths.launchScriptPath,\n createMuonLaunchScript({\n muonExecutablePath: paths.muonExecutablePath,\n projectConfigPath: paths.projectConfigPath,\n overrideConfigPath: paths.overrideConfigPath,\n platform,\n }),\n );\n if (platform !== \"win32\") {\n await chmod(paths.launchScriptPath, 0o700);\n }\n};\n\nexport const startMuonViteBrowserBridge = async ({\n server,\n pluginOptions,\n platform,\n architecture,\n environment,\n}: MuonViteSessionOptions): Promise<void> => {\n const openValue = getServerOpenValue(server);\n if (openValue === false || server.httpServer === null) {\n return;\n }\n\n const target = getDefaultMuonPrepareTarget(platform, architecture);\n const muonPath = resolveMuonRuntimePath({\n root: server.config.root,\n target,\n muonPath: pluginOptions.muonPath,\n });\n const cefPath =\n pluginOptions.cefPath === undefined\n ? undefined\n : resolveFromRoot(server.config.root, pluginOptions.cefPath);\n const stagePath =\n pluginOptions.stagePath === undefined\n ? resolve(server.config.root, \".muon\", target)\n : resolveFromRoot(server.config.root, pluginOptions.stagePath);\n const preparedRuntime = await runMuonPrepare({\n muonPath,\n cefPath,\n stageDir: stagePath,\n target,\n cacheDir: environment.MUON_CACHE_DIR,\n force: false,\n quiet: false,\n prepareExecutablePath: undefined,\n environment,\n cwd: server.config.root,\n });\n if (preparedRuntime.stagePath === undefined) {\n throw new Error(\"muon-prepare did not return a staged runtime path.\");\n }\n const paths = await createRuntimePaths(\n server,\n preparedRuntime.stagePath,\n platform,\n );\n await writeLaunchScript(paths, platform);\n const previousBrowser = environment.BROWSER;\n environment.BROWSER = paths.launchScriptPath;\n\n let cleanupPromise: Promise<void> | undefined = undefined;\n const cleanup = async (): Promise<void> => {\n if (cleanupPromise !== undefined) {\n return cleanupPromise;\n }\n cleanupPromise = (async () => {\n if (previousBrowser === undefined) {\n delete environment.BROWSER;\n } else {\n environment.BROWSER = previousBrowser;\n }\n await rm(paths.temporaryDirectory, { recursive: true, force: true });\n })();\n return cleanupPromise;\n };\n\n const originalClose = server.close.bind(server);\n server.close = async (): Promise<void> => {\n try {\n await originalClose();\n } finally {\n await cleanup();\n }\n };\n server.httpServer.once(\"close\", () => {\n void cleanup();\n });\n server.httpServer.once(\"listening\", () => {\n writeMuonOverrideConfig(server, openValue, paths.overrideConfigPath);\n });\n};\n","// muon - Multi-platform GUI application framework that uses CEF as its backend\n// Copyright (c) Kouji Matsui. (@kekyo@mi.kekyo.net)\n// Under MIT.\n// https://github.com/kekyo/muon\n\nimport type { Plugin } from \"vite\";\nimport type { ResolvedConfig } from \"vite\";\nimport { isAbsolute, resolve } from \"node:path\";\n\nimport { buildMuonApp, type MuonBuildOptions } from \"./build.js\";\nimport { startMuonViteBrowserBridge } from \"./vite-internals.js\";\n\n/**\n * Options for generating Muon app distributions after Vite build.\n */\nexport interface MuonViteBuildOptions {\n /**\n * Target aliases or internal target names to build.\n */\n targets?: readonly string[];\n\n /**\n * Build every supported target from the installed package.\n */\n allTargets?: boolean;\n\n /**\n * File name used for the app launcher.\n *\n * @remarks The .exe suffix is added automatically for Windows targets.\n */\n appName?: string;\n\n /**\n * Parent directory that receives dist-linux-amd64/ style outputs.\n */\n outputRoot?: string;\n\n /**\n * Muon config path to embed.\n */\n configPath?: string;\n\n /**\n * Directory containing package runtime/ and native/ folders.\n *\n * @remarks This defaults to the installed muon package dist directory.\n */\n packageDirectory?: string;\n\n /**\n * Asset salt override for deterministic tests.\n *\n * @remarks Production builds should omit this option.\n */\n assetSalt?: Uint8Array;\n}\n\n/**\n * Options for the Muon Vite development plugin.\n */\nexport interface MuonVitePluginOptions {\n /**\n * Directory containing muon-core runtime files such as muon-core and plugins.\n *\n * @remarks Relative paths are resolved from the Vite project root. When omitted,\n * the packaged runtime at dist/runtime/<target> is used.\n */\n muonPath?: string;\n\n /**\n * Directory containing CEF files, or a CEF archive root with Release/Resources.\n *\n * @remarks Relative paths are resolved from the Vite project root. When omitted,\n * muon-prepare downloads and caches the tested CEF artifact from muonPath.\n */\n cefPath?: string;\n\n /**\n * Runtime staging directory used for development startup.\n *\n * @remarks Relative paths are resolved from the Vite project root. Defaults to\n * .muon/<target>.\n */\n stagePath?: string;\n\n /**\n * Build app distributions from Vite output.\n *\n * @remarks Defaults to true during Vite build. Set false to disable the build\n * hook while keeping the development bridge enabled.\n */\n build?: boolean | MuonViteBuildOptions;\n}\n\n/**\n * Creates a Vite plugin that launches Muon through Vite's server.open flow.\n *\n * @param options Muon runtime location used for development startup.\n * @returns Vite plugin instance.\n */\nconst muon = (options: MuonVitePluginOptions = {}): Plugin => {\n let resolvedConfig: ResolvedConfig | undefined = undefined;\n\n return {\n name: \"muon\",\n configResolved: (config) => {\n resolvedConfig = config;\n },\n configureServer: async (server) => {\n await startMuonViteBrowserBridge({\n server,\n pluginOptions: options,\n platform: process.platform,\n architecture: process.arch,\n environment: process.env,\n });\n },\n closeBundle: async () => {\n if (resolvedConfig === undefined || resolvedConfig.command !== \"build\") {\n return;\n }\n if (options.build === false) {\n return;\n }\n\n const buildOptions =\n typeof options.build === \"object\" ? options.build : {};\n await buildMuonApp(createMuonBuildOptions(resolvedConfig, buildOptions));\n },\n };\n};\n\nconst createMuonBuildOptions = (\n config: ResolvedConfig,\n buildOptions: MuonViteBuildOptions,\n): MuonBuildOptions => {\n const outDir = isAbsolute(config.build.outDir)\n ? config.build.outDir\n : resolve(config.root, config.build.outDir);\n const options: MuonBuildOptions = {\n root: config.root,\n assetSourcePath: outDir,\n assetPrefix: \"main\",\n };\n\n if (buildOptions.allTargets !== undefined) {\n options.allTargets = buildOptions.allTargets;\n }\n if (buildOptions.targets !== undefined) {\n options.targets = buildOptions.targets;\n }\n if (buildOptions.appName !== undefined) {\n options.appName = buildOptions.appName;\n }\n if (buildOptions.outputRoot !== undefined) {\n options.outputRoot = buildOptions.outputRoot;\n }\n if (buildOptions.configPath !== undefined) {\n options.configPath = buildOptions.configPath;\n }\n if (buildOptions.packageDirectory !== undefined) {\n options.packageDirectory = buildOptions.packageDirectory;\n }\n if (buildOptions.assetSalt !== undefined) {\n options.assetSalt = buildOptions.assetSalt;\n }\n\n return options;\n};\n\nexport default muon;\n"],"mappings":";;;;;;;;;;;;;;;;AA8EA,IAAM,sBACJ,WAC6B;CAC7B,MAAM,OAAO,OAAO,OAAO,OAAO;CAClC,OAAO,SAAS,QAAQ,OAAO,SAAS,WAAW,OAAO;AAC5D;AAEA,IAAM,mBAAmB,MAAc,UAAA,GAAA,UAAA,YAC1B,IAAI,IAAI,QAAA,GAAA,UAAA,SAAe,MAAM,IAAI;AAE9C,IAAM,kBACJ,OAAO,cAAc,WACjB,aAAA,GAAA,UAAA,UAAA,GAAA,SAAA,eAAA,CAAA,EACkC,GAAG,CAAC;;;;;;;AAQ5C,IAAa,0BAA0B,EACrC,MACA,QACA,UACA,mBAAmB,sBAEnB,aAAa,KAAA,KAAA,GAAA,UAAA,MACJ,kBAAkB,WAAW,MAAM,IACxC,gBAAgB,MAAM,QAAQ;AAEp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,cAAc,KAAA,GAC7B,QAAQ,YAAY,aAAa;CAGnC,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"vite.cjs","names":[],"sources":["../src/vite-internals.ts","../src/vite.ts"],"sourcesContent":["// muon - Multi-platform GUI application framework that uses CEF as its backend\n// Copyright (c) Kouji Matsui. (@kekyo@mi.kekyo.net)\n// Under MIT.\n// https://github.com/kekyo/muon\n\nimport { constants, writeFileSync } from \"node:fs\";\nimport {\n access,\n chmod,\n mkdtemp,\n readFile,\n rm,\n writeFile,\n} from \"node:fs/promises\";\nimport { tmpdir } from \"node:os\";\nimport { dirname, isAbsolute, join, resolve, win32 } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\nimport { parse } from \"json5\";\nimport type { ViteDevServer } from \"vite\";\n\nimport { getDefaultMuonPrepareTarget, runMuonPrepare } from \"./prepare.js\";\nimport type { MuonVitePluginOptions } from \"./vite.js\";\n\nexport interface MuonLaunchScriptOptions {\n muonExecutablePath: string;\n projectConfigPath: string | undefined;\n overrideConfigPath: string;\n platform: NodeJS.Platform;\n}\n\ninterface MuonViteSessionOptions {\n server: ViteDevServer;\n pluginOptions: MuonVitePluginOptions;\n platform: NodeJS.Platform;\n architecture: NodeJS.Architecture;\n environment: NodeJS.ProcessEnv;\n}\n\ninterface MuonRuntimePaths {\n temporaryDirectory: string;\n launchScriptPath: string;\n overrideConfigPath: string;\n projectConfigPath: string | undefined;\n muonExecutablePath: string;\n}\n\ninterface MuonOverrideConfig {\n browser: {\n startPage: string;\n plugin: {\n allow: string[];\n };\n };\n network: {\n allow: string[];\n };\n}\n\n/**\n * Options for resolving a Muon runtime directory used by the Vite plugin.\n */\nexport interface MuonRuntimePathOptions {\n /**\n * Vite project root used to resolve explicit relative paths.\n */\n root: string;\n\n /**\n * Muon runtime target such as linux64, linuxarm, linuxarm64, windows32, or windows64.\n */\n target: string;\n\n /**\n * Explicit custom muon-core runtime path.\n */\n muonPath: string | undefined;\n\n /**\n * Directory containing the packaged Muon JavaScript files.\n *\n * @remarks This is injectable for tests. Production code uses the module directory.\n */\n packageDirectory?: string;\n}\n\nconst getServerOpenValue = (\n server: ViteDevServer,\n): boolean | string | false => {\n const open = server.config.server.open;\n return open === true || typeof open === \"string\" ? open : false;\n};\n\nconst resolveFromRoot = (root: string, path: string): string =>\n isAbsolute(path) ? path : resolve(root, path);\n\nconst moduleDirectory =\n typeof __dirname === \"string\"\n ? __dirname\n : dirname(fileURLToPath(import.meta.url));\nconst defaultProjectConfigFileNames = [\"muon.json5\", \"muon.jsonc\", \"muon.json\"];\n\n/**\n * Resolves the muon-core runtime directory used by the Vite plugin.\n *\n * @param options Runtime path resolution inputs.\n * @returns Absolute or package-relative runtime directory path.\n */\nexport const resolveMuonRuntimePath = ({\n root,\n target,\n muonPath,\n packageDirectory = moduleDirectory,\n}: MuonRuntimePathOptions): string =>\n muonPath === undefined\n ? join(packageDirectory, \"runtime\", target)\n : resolveFromRoot(root, muonPath);\n\nexport const getMuonExecutablePath = (\n runtimePath: string,\n platform: NodeJS.Platform,\n): string =>\n join(runtimePath, platform === \"win32\" ? \"muon-core.exe\" : \"muon-core\");\n\nconst getLaunchScriptFileName = (platform: NodeJS.Platform): string =>\n platform === \"win32\" ? \"open-muon.cmd\" : \"open-muon.sh\";\n\nconst quotePosix = (value: string): string =>\n `'${value.replaceAll(\"'\", \"'\\\\''\")}'`;\n\nconst getPlatformDirectoryName = (\n path: string,\n platform: NodeJS.Platform,\n): string => (platform === \"win32\" ? win32.dirname(path) : dirname(path));\n\nconst getOptionalPosixValue = (value: string | undefined): string =>\n value === undefined ? \"''\" : quotePosix(value);\n\nconst createPosixMuonLaunchScript = ({\n muonExecutablePath,\n projectConfigPath,\n overrideConfigPath,\n}: MuonLaunchScriptOptions): string => `#!/usr/bin/env bash\nset -euo pipefail\nMUON_EXECUTABLE=${quotePosix(muonExecutablePath)}\nMUON_EXECUTABLE_DIRECTORY=${quotePosix(getPlatformDirectoryName(muonExecutablePath, \"linux\"))}\nMUON_PROJECT_CONFIG=${getOptionalPosixValue(projectConfigPath)}\nMUON_OVERRIDE_CONFIG=${quotePosix(overrideConfigPath)}\n\nMUON_CONFIG_ARGS=()\nif [[ -n \"$MUON_PROJECT_CONFIG\" ]]; then\n if [[ ! -f \"$MUON_PROJECT_CONFIG\" ]]; then\n echo \"Muon startup failed: project config does not exist: $MUON_PROJECT_CONFIG\" >&2\n exit 1\n fi\n MUON_CONFIG_ARGS+=(\"-c\" \"$MUON_PROJECT_CONFIG\")\nfi\n\nif [[ ! -x \"$MUON_EXECUTABLE\" ]]; then\n echo \"Muon startup failed: executable does not exist or is not executable: $MUON_EXECUTABLE\" >&2\n exit 1\nfi\n\nif [[ ! -f \"$MUON_OVERRIDE_CONFIG\" ]]; then\n echo \"Muon startup failed: generated override config does not exist: $MUON_OVERRIDE_CONFIG\" >&2\n exit 1\nfi\nMUON_CONFIG_ARGS+=(\"-c\" \"$MUON_OVERRIDE_CONFIG\")\n\ncd \"$MUON_EXECUTABLE_DIRECTORY\"\nexec \"$MUON_EXECUTABLE\" \"\\${MUON_CONFIG_ARGS[@]}\"\n`;\n\nconst escapeWindowsCmdValue = (value: string): string =>\n value.replaceAll(\"%\", \"%%\").replaceAll(\"\\r\", \"\").replaceAll(\"\\n\", \"\");\n\nconst getOptionalWindowsCmdValue = (value: string | undefined): string =>\n value === undefined ? \"\" : escapeWindowsCmdValue(value);\n\nconst createWindowsMuonLaunchScript = ({\n muonExecutablePath,\n projectConfigPath,\n overrideConfigPath,\n}: MuonLaunchScriptOptions): string => `@echo off\nsetlocal\nset \"MUON_EXECUTABLE=${escapeWindowsCmdValue(muonExecutablePath)}\"\nset \"MUON_EXECUTABLE_DIRECTORY=${escapeWindowsCmdValue(getPlatformDirectoryName(muonExecutablePath, \"win32\"))}\"\nset \"MUON_PROJECT_CONFIG=${getOptionalWindowsCmdValue(projectConfigPath)}\"\nset \"MUON_OVERRIDE_CONFIG=${escapeWindowsCmdValue(overrideConfigPath)}\"\n\nif not exist \"%MUON_EXECUTABLE%\" (\n echo Muon startup failed: executable does not exist: %MUON_EXECUTABLE% 1>&2\n exit /b 1\n)\n\nif not exist \"%MUON_OVERRIDE_CONFIG%\" (\n echo Muon startup failed: generated override config does not exist: %MUON_OVERRIDE_CONFIG% 1>&2\n exit /b 1\n)\n\npushd \"%MUON_EXECUTABLE_DIRECTORY%\"\nif defined MUON_PROJECT_CONFIG (\n if not exist \"%MUON_PROJECT_CONFIG%\" (\n echo Muon startup failed: project config does not exist: %MUON_PROJECT_CONFIG% 1>&2\n popd\n exit /b 1\n )\n \"%MUON_EXECUTABLE%\" -c \"%MUON_PROJECT_CONFIG%\" -c \"%MUON_OVERRIDE_CONFIG%\"\n) else (\n \"%MUON_EXECUTABLE%\" -c \"%MUON_OVERRIDE_CONFIG%\"\n)\nset \"MUON_EXIT_CODE=%ERRORLEVEL%\"\npopd\nexit /b %MUON_EXIT_CODE%\n`;\n\nexport const createMuonLaunchScript = (\n options: MuonLaunchScriptOptions,\n): string =>\n options.platform === \"win32\"\n ? createWindowsMuonLaunchScript(options)\n : createPosixMuonLaunchScript(options);\n\nconst getBaseUrl = (server: ViteDevServer): string | undefined =>\n server.resolvedUrls?.local[0] ?? server.resolvedUrls?.network[0];\n\nconst getStartUrl = (\n server: ViteDevServer,\n openValue: boolean | string,\n): string | undefined => {\n const baseUrl = getBaseUrl(server);\n if (baseUrl === undefined) {\n return undefined;\n }\n return typeof openValue === \"string\"\n ? new URL(openValue, baseUrl).href\n : baseUrl;\n};\n\nconst getWebSocketOrigin = (startUrl: string): string => {\n const url = new URL(startUrl);\n if (url.protocol === \"https:\") {\n url.protocol = \"wss:\";\n } else if (url.protocol === \"http:\") {\n url.protocol = \"ws:\";\n }\n return url.origin;\n};\n\nconst createMuonOverrideConfig = (startUrl: string): MuonOverrideConfig => {\n const origin = new URL(startUrl).origin;\n return {\n browser: {\n startPage: startUrl,\n plugin: {\n allow: [`${origin}/**`],\n },\n },\n network: {\n allow: [`${origin}/**`, `${getWebSocketOrigin(startUrl)}/**`],\n },\n };\n};\n\nconst writeMuonOverrideConfig = (\n server: ViteDevServer,\n openValue: boolean | string,\n overrideConfigPath: string,\n): void => {\n const startUrl = getStartUrl(server, openValue);\n if (startUrl === undefined) {\n server.config.logger.warn(\"Muon Vite plugin could not resolve a Vite URL.\");\n return;\n }\n writeFileSync(\n overrideConfigPath,\n `${JSON.stringify(createMuonOverrideConfig(startUrl), null, 2)}\\n`,\n );\n};\n\nconst createRuntimePaths = async (\n server: ViteDevServer,\n stagePath: string,\n platform: NodeJS.Platform,\n projectConfigPath: string | undefined,\n): Promise<MuonRuntimePaths> => {\n const temporaryDirectory = await mkdtemp(join(tmpdir(), \"muon-vite-\"));\n return {\n temporaryDirectory,\n launchScriptPath: join(\n temporaryDirectory,\n getLaunchScriptFileName(platform),\n ),\n overrideConfigPath: join(temporaryDirectory, \"muon.vite.json\"),\n projectConfigPath,\n muonExecutablePath: getMuonExecutablePath(stagePath, platform),\n };\n};\n\nconst fileExists = async (path: string): Promise<boolean> => {\n try {\n await access(path, constants.F_OK);\n return true;\n } catch {\n return false;\n }\n};\n\nconst isJsonObject = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null && !Array.isArray(value);\n\nconst getErrorMessage = (error: unknown): string =>\n error instanceof Error ? error.message : String(error);\n\nconst resolveProjectConfigPath = async (\n server: ViteDevServer,\n): Promise<string | undefined> => {\n for (const fileName of defaultProjectConfigFileNames) {\n const candidatePath = join(server.config.root, fileName);\n if (!(await fileExists(candidatePath))) {\n continue;\n }\n\n try {\n const parsed = parse(await readFile(candidatePath, \"utf8\"));\n if (!isJsonObject(parsed)) {\n throw new Error(\"muon config root must be an object\");\n }\n return candidatePath;\n } catch (error) {\n server.config.logger.warn(\n `Muon project config will be ignored because it could not be read or parsed: ${candidatePath}: ${getErrorMessage(error)}`,\n );\n return undefined;\n }\n }\n\n server.config.logger.warn(\n `Muon project config was not found in ${server.config.root}; launching with generated Vite config only.`,\n );\n return undefined;\n};\n\nconst writeLaunchScript = async (\n paths: MuonRuntimePaths,\n platform: NodeJS.Platform,\n): Promise<void> => {\n await writeFile(\n paths.launchScriptPath,\n createMuonLaunchScript({\n muonExecutablePath: paths.muonExecutablePath,\n projectConfigPath: paths.projectConfigPath,\n overrideConfigPath: paths.overrideConfigPath,\n platform,\n }),\n );\n if (platform !== \"win32\") {\n await chmod(paths.launchScriptPath, 0o700);\n }\n};\n\nexport const startMuonViteBrowserBridge = async ({\n server,\n pluginOptions,\n platform,\n architecture,\n environment,\n}: MuonViteSessionOptions): Promise<void> => {\n const openValue = getServerOpenValue(server);\n if (openValue === false || server.httpServer === null) {\n return;\n }\n\n const target = getDefaultMuonPrepareTarget(platform, architecture);\n const muonPath = resolveMuonRuntimePath({\n root: server.config.root,\n target,\n muonPath: pluginOptions.muonPath,\n });\n const cefPath =\n pluginOptions.cefPath === undefined\n ? undefined\n : resolveFromRoot(server.config.root, pluginOptions.cefPath);\n const stagePath =\n pluginOptions.stagePath === undefined\n ? resolve(server.config.root, \".muon\", target)\n : resolveFromRoot(server.config.root, pluginOptions.stagePath);\n const preparedRuntime = await runMuonPrepare({\n muonPath,\n cefPath,\n stageDir: stagePath,\n target,\n cacheDir: environment.MUON_CACHE_DIR,\n force: false,\n quiet: false,\n prepareExecutablePath: undefined,\n environment,\n cwd: server.config.root,\n });\n if (preparedRuntime.stagePath === undefined) {\n throw new Error(\"muon-prepare did not return a staged runtime path.\");\n }\n const paths = await createRuntimePaths(\n server,\n preparedRuntime.stagePath,\n platform,\n await resolveProjectConfigPath(server),\n );\n await writeLaunchScript(paths, platform);\n const previousBrowser = environment.BROWSER;\n environment.BROWSER = paths.launchScriptPath;\n\n let cleanupPromise: Promise<void> | undefined = undefined;\n const cleanup = async (): Promise<void> => {\n if (cleanupPromise !== undefined) {\n return cleanupPromise;\n }\n cleanupPromise = (async () => {\n if (previousBrowser === undefined) {\n delete environment.BROWSER;\n } else {\n environment.BROWSER = previousBrowser;\n }\n await rm(paths.temporaryDirectory, { recursive: true, force: true });\n })();\n return cleanupPromise;\n };\n\n const originalClose = server.close.bind(server);\n server.close = async (): Promise<void> => {\n try {\n await originalClose();\n } finally {\n await cleanup();\n }\n };\n server.httpServer.once(\"close\", () => {\n void cleanup();\n });\n server.httpServer.once(\"listening\", () => {\n writeMuonOverrideConfig(server, openValue, paths.overrideConfigPath);\n });\n};\n","// muon - Multi-platform GUI application framework that uses CEF as its backend\n// Copyright (c) Kouji Matsui. (@kekyo@mi.kekyo.net)\n// Under MIT.\n// https://github.com/kekyo/muon\n\nimport type { Plugin } from \"vite\";\nimport type { ResolvedConfig } from \"vite\";\nimport { isAbsolute, resolve } from \"node:path\";\n\nimport { buildMuonApp, type MuonBuildOptions } from \"./build.js\";\nimport { startMuonViteBrowserBridge } from \"./vite-internals.js\";\n\n/**\n * Options for generating Muon app distributions after Vite build.\n */\nexport interface MuonViteBuildOptions {\n /**\n * Target aliases or internal target names to build.\n */\n targets?: readonly string[];\n\n /**\n * Build every supported target from the installed package.\n */\n allTargets?: boolean;\n\n /**\n * File name used for the app launcher.\n *\n * @remarks The .exe suffix is added automatically for Windows targets.\n */\n appName?: string;\n\n /**\n * Parent directory that receives dist-linux-amd64/ style outputs.\n */\n outputRoot?: string;\n\n /**\n * Muon config path to embed.\n */\n configPath?: string;\n\n /**\n * Directory containing package runtime/ and native/ folders.\n *\n * @remarks This defaults to the installed muon package dist directory.\n */\n packageDirectory?: string;\n\n /**\n * Asset salt override for deterministic tests.\n *\n * @remarks Production builds should omit this option.\n */\n assetSalt?: Uint8Array;\n}\n\n/**\n * Options for the Muon Vite development plugin.\n */\nexport interface MuonVitePluginOptions {\n /**\n * Directory containing muon-core runtime files such as muon-core and plugins.\n *\n * @remarks Relative paths are resolved from the Vite project root. When omitted,\n * the packaged runtime at dist/runtime/<target> is used.\n */\n muonPath?: string;\n\n /**\n * Directory containing CEF files, or a CEF archive root with Release/Resources.\n *\n * @remarks Relative paths are resolved from the Vite project root. When omitted,\n * muon-prepare downloads and caches the tested CEF artifact from muonPath.\n */\n cefPath?: string;\n\n /**\n * Runtime staging directory used for development startup.\n *\n * @remarks Relative paths are resolved from the Vite project root. Defaults to\n * .muon/<target>.\n */\n stagePath?: string;\n\n /**\n * Build app distributions from Vite output.\n *\n * @remarks Defaults to true during Vite build. Set false to disable the build\n * hook while keeping the development bridge enabled.\n */\n build?: boolean | MuonViteBuildOptions;\n}\n\n/**\n * Creates a Vite plugin that launches Muon through Vite's server.open flow.\n *\n * @param options Muon runtime location used for development startup.\n * @returns Vite plugin instance.\n */\nconst muon = (options: MuonVitePluginOptions = {}): Plugin => {\n let resolvedConfig: ResolvedConfig | undefined = undefined;\n\n return {\n name: \"muon\",\n configResolved: (config) => {\n resolvedConfig = config;\n },\n configureServer: async (server) => {\n await startMuonViteBrowserBridge({\n server,\n pluginOptions: options,\n platform: process.platform,\n architecture: process.arch,\n environment: process.env,\n });\n },\n closeBundle: async () => {\n if (resolvedConfig === undefined || resolvedConfig.command !== \"build\") {\n return;\n }\n if (options.build === false) {\n return;\n }\n\n const buildOptions =\n typeof options.build === \"object\" ? options.build : {};\n await buildMuonApp(createMuonBuildOptions(resolvedConfig, buildOptions));\n },\n };\n};\n\nconst createMuonBuildOptions = (\n config: ResolvedConfig,\n buildOptions: MuonViteBuildOptions,\n): MuonBuildOptions => {\n const outDir = isAbsolute(config.build.outDir)\n ? config.build.outDir\n : resolve(config.root, config.build.outDir);\n const options: MuonBuildOptions = {\n root: config.root,\n assetSourcePath: outDir,\n assetPrefix: \"main\",\n };\n\n if (buildOptions.allTargets !== undefined) {\n options.allTargets = buildOptions.allTargets;\n }\n if (buildOptions.targets !== undefined) {\n options.targets = buildOptions.targets;\n }\n if (buildOptions.appName !== undefined) {\n options.appName = buildOptions.appName;\n }\n if (buildOptions.outputRoot !== undefined) {\n options.outputRoot = buildOptions.outputRoot;\n }\n if (buildOptions.configPath !== undefined) {\n options.configPath = buildOptions.configPath;\n }\n if (buildOptions.packageDirectory !== undefined) {\n options.packageDirectory = buildOptions.packageDirectory;\n }\n if (buildOptions.assetSalt !== undefined) {\n options.assetSalt = buildOptions.assetSalt;\n }\n\n return options;\n};\n\nexport default muon;\n"],"mappings":";;;;;;;;;;;;;;;;;AAsFA,IAAM,sBACJ,WAC6B;CAC7B,MAAM,OAAO,OAAO,OAAO,OAAO;CAClC,OAAO,SAAS,QAAQ,OAAO,SAAS,WAAW,OAAO;AAC5D;AAEA,IAAM,mBAAmB,MAAc,UAAA,GAAA,UAAA,YAC1B,IAAI,IAAI,QAAA,GAAA,UAAA,SAAe,MAAM,IAAI;AAE9C,IAAM,kBACJ,OAAO,cAAc,WACjB,aAAA,GAAA,UAAA,UAAA,GAAA,SAAA,eAAA,CAAA,EACkC,GAAG,CAAC;AAC5C,IAAM,gCAAgC;CAAC;CAAc;CAAc;AAAW;;;;;;;AAQ9E,IAAa,0BAA0B,EACrC,MACA,QACA,UACA,mBAAmB,sBAEnB,aAAa,KAAA,KAAA,GAAA,UAAA,MACJ,kBAAkB,WAAW,MAAM,IACxC,gBAAgB,MAAM,QAAQ;AAEpC,IAAa,yBACX,aACA,cAAA,GAAA,UAAA,MAEK,aAAa,aAAa,UAAU,kBAAkB,WAAW;AAExE,IAAM,2BAA2B,aAC/B,aAAa,UAAU,kBAAkB;AAE3C,IAAM,cAAc,UAClB,IAAI,MAAM,WAAW,KAAK,OAAO,EAAE;AAErC,IAAM,4BACJ,MACA,aACY,aAAa,UAAU,UAAA,MAAM,QAAQ,IAAI,KAAA,GAAA,UAAA,SAAY,IAAI;AAEvE,IAAM,yBAAyB,UAC7B,UAAU,KAAA,IAAY,OAAO,WAAW,KAAK;AAE/C,IAAM,+BAA+B,EACnC,oBACA,mBACA,yBACqC;;kBAErB,WAAW,kBAAkB,EAAE;4BACrB,WAAW,yBAAyB,oBAAoB,OAAO,CAAC,EAAE;sBACxE,sBAAsB,iBAAiB,EAAE;uBACxC,WAAW,kBAAkB,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;AA0Bt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