muon-ui 0.1.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/LICENSE +21 -0
- package/README.md +84 -0
- package/dist/build-CCuZpajl.cjs +2083 -0
- package/dist/build-CCuZpajl.cjs.map +1 -0
- package/dist/cli.cjs +122 -0
- package/dist/cli.cjs.map +1 -0
- package/dist/index.cjs +9 -0
- package/dist/index.mjs +9 -0
- 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/linux64/THIRD_PARTY_NOTICES.md +223 -0
- package/dist/runtime/linux64/libcardio.so +0 -0
- package/dist/runtime/linux64/libmuon-ui.so +0 -0
- package/dist/runtime/linux64/muon-core +0 -0
- package/dist/runtime/linuxarm/THIRD_PARTY_NOTICES.md +223 -0
- package/dist/runtime/linuxarm/libcardio.so +0 -0
- package/dist/runtime/linuxarm/libmuon-ui.so +0 -0
- package/dist/runtime/linuxarm/muon-core +0 -0
- package/dist/runtime/linuxarm64/THIRD_PARTY_NOTICES.md +223 -0
- package/dist/runtime/linuxarm64/libcardio.so +0 -0
- package/dist/runtime/linuxarm64/libmuon-ui.so +0 -0
- package/dist/runtime/linuxarm64/muon-core +0 -0
- package/dist/runtime/windows32/THIRD_PARTY_NOTICES.md +223 -0
- 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/THIRD_PARTY_NOTICES.md +223 -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 +242 -0
- package/dist/vite.cjs.map +1 -0
- package/dist/vite.mjs +2251 -0
- package/dist/vite.mjs.map +1 -0
- package/images/muon-120.png +0 -0
- package/images/vscode.png +0 -0
- package/muon.d.ts +1039 -0
- package/package.json +91 -0
- package/vite.d.ts +98 -0
package/dist/vite.mjs
ADDED
|
@@ -0,0 +1,2251 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* name: muon-ui
|
|
3
|
+
* version: 0.1.0
|
|
4
|
+
* description: A multi-platform GUI application framework that uses CEF as its backend
|
|
5
|
+
* author: Kouji Matsui (@kekyo@mi.kekyo.net)
|
|
6
|
+
* license: MIT
|
|
7
|
+
* repository.url: https://github.com/kekyo/muon-ui.git
|
|
8
|
+
* git.commit.hash: 35f9658786642562593735d3b589c1d7ab270ecf
|
|
9
|
+
*/
|
|
10
|
+
import { basename, dirname, isAbsolute, join, relative, resolve, sep, win32 } from "node:path";
|
|
11
|
+
import { constants, writeFileSync } from "node:fs";
|
|
12
|
+
import { access, chmod, copyFile, cp, mkdir, mkdtemp, readFile, readdir, rm, stat, writeFile } from "node:fs/promises";
|
|
13
|
+
import { createHash, randomBytes } from "node:crypto";
|
|
14
|
+
import { tmpdir } from "node:os";
|
|
15
|
+
import { fileURLToPath } from "node:url";
|
|
16
|
+
import __screwUpDefaultImportModule0 from "adm-zip";
|
|
17
|
+
import { spawn } from "node:child_process";
|
|
18
|
+
//#region \0rolldown/runtime.js
|
|
19
|
+
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
|
|
20
|
+
//#endregion
|
|
21
|
+
//#region src/embed-config.ts
|
|
22
|
+
var import_dist = (/* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
23
|
+
(function(global, factory) {
|
|
24
|
+
typeof exports === "object" && typeof module !== "undefined" ? module.exports = factory() : typeof define === "function" && define.amd ? define(factory) : global.JSON5 = factory();
|
|
25
|
+
})(exports, (function() {
|
|
26
|
+
"use strict";
|
|
27
|
+
function createCommonjsModule(fn, module$1) {
|
|
28
|
+
return module$1 = { exports: {} }, fn(module$1, module$1.exports), module$1.exports;
|
|
29
|
+
}
|
|
30
|
+
var _global = createCommonjsModule(function(module$2) {
|
|
31
|
+
var global = module$2.exports = typeof window != "undefined" && window.Math == Math ? window : typeof self != "undefined" && self.Math == Math ? self : Function("return this")();
|
|
32
|
+
if (typeof __g == "number") __g = global;
|
|
33
|
+
});
|
|
34
|
+
var _core = createCommonjsModule(function(module$3) {
|
|
35
|
+
var core = module$3.exports = { version: "2.6.5" };
|
|
36
|
+
if (typeof __e == "number") __e = core;
|
|
37
|
+
});
|
|
38
|
+
_core.version;
|
|
39
|
+
var _isObject = function(it) {
|
|
40
|
+
return typeof it === "object" ? it !== null : typeof it === "function";
|
|
41
|
+
};
|
|
42
|
+
var _anObject = function(it) {
|
|
43
|
+
if (!_isObject(it)) throw TypeError(it + " is not an object!");
|
|
44
|
+
return it;
|
|
45
|
+
};
|
|
46
|
+
var _fails = function(exec) {
|
|
47
|
+
try {
|
|
48
|
+
return !!exec();
|
|
49
|
+
} catch (e) {
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
var _descriptors = !_fails(function() {
|
|
54
|
+
return Object.defineProperty({}, "a", { get: function() {
|
|
55
|
+
return 7;
|
|
56
|
+
} }).a != 7;
|
|
57
|
+
});
|
|
58
|
+
var document = _global.document;
|
|
59
|
+
var is = _isObject(document) && _isObject(document.createElement);
|
|
60
|
+
var _domCreate = function(it) {
|
|
61
|
+
return is ? document.createElement(it) : {};
|
|
62
|
+
};
|
|
63
|
+
var _ie8DomDefine = !_descriptors && !_fails(function() {
|
|
64
|
+
return Object.defineProperty(_domCreate("div"), "a", { get: function() {
|
|
65
|
+
return 7;
|
|
66
|
+
} }).a != 7;
|
|
67
|
+
});
|
|
68
|
+
var _toPrimitive = function(it, S) {
|
|
69
|
+
if (!_isObject(it)) return it;
|
|
70
|
+
var fn, val;
|
|
71
|
+
if (S && typeof (fn = it.toString) == "function" && !_isObject(val = fn.call(it))) return val;
|
|
72
|
+
if (typeof (fn = it.valueOf) == "function" && !_isObject(val = fn.call(it))) return val;
|
|
73
|
+
if (!S && typeof (fn = it.toString) == "function" && !_isObject(val = fn.call(it))) return val;
|
|
74
|
+
throw TypeError("Can't convert object to primitive value");
|
|
75
|
+
};
|
|
76
|
+
var dP = Object.defineProperty;
|
|
77
|
+
var _objectDp = { f: _descriptors ? Object.defineProperty : function defineProperty(O, P, Attributes) {
|
|
78
|
+
_anObject(O);
|
|
79
|
+
P = _toPrimitive(P, true);
|
|
80
|
+
_anObject(Attributes);
|
|
81
|
+
if (_ie8DomDefine) try {
|
|
82
|
+
return dP(O, P, Attributes);
|
|
83
|
+
} catch (e) {}
|
|
84
|
+
if ("get" in Attributes || "set" in Attributes) throw TypeError("Accessors not supported!");
|
|
85
|
+
if ("value" in Attributes) O[P] = Attributes.value;
|
|
86
|
+
return O;
|
|
87
|
+
} };
|
|
88
|
+
var _propertyDesc = function(bitmap, value) {
|
|
89
|
+
return {
|
|
90
|
+
enumerable: !(bitmap & 1),
|
|
91
|
+
configurable: !(bitmap & 2),
|
|
92
|
+
writable: !(bitmap & 4),
|
|
93
|
+
value
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
var _hide = _descriptors ? function(object, key, value) {
|
|
97
|
+
return _objectDp.f(object, key, _propertyDesc(1, value));
|
|
98
|
+
} : function(object, key, value) {
|
|
99
|
+
object[key] = value;
|
|
100
|
+
return object;
|
|
101
|
+
};
|
|
102
|
+
var hasOwnProperty = {}.hasOwnProperty;
|
|
103
|
+
var _has = function(it, key) {
|
|
104
|
+
return hasOwnProperty.call(it, key);
|
|
105
|
+
};
|
|
106
|
+
var id = 0;
|
|
107
|
+
var px = Math.random();
|
|
108
|
+
var _uid = function(key) {
|
|
109
|
+
return "Symbol(".concat(key === void 0 ? "" : key, ")_", (++id + px).toString(36));
|
|
110
|
+
};
|
|
111
|
+
var _library = false;
|
|
112
|
+
var _functionToString = createCommonjsModule(function(module$4) {
|
|
113
|
+
var SHARED = "__core-js_shared__";
|
|
114
|
+
var store = _global[SHARED] || (_global[SHARED] = {});
|
|
115
|
+
(module$4.exports = function(key, value) {
|
|
116
|
+
return store[key] || (store[key] = value !== void 0 ? value : {});
|
|
117
|
+
})("versions", []).push({
|
|
118
|
+
version: _core.version,
|
|
119
|
+
mode: _library ? "pure" : "global",
|
|
120
|
+
copyright: "© 2019 Denis Pushkarev (zloirock.ru)"
|
|
121
|
+
});
|
|
122
|
+
})("native-function-to-string", Function.toString);
|
|
123
|
+
var _redefine = createCommonjsModule(function(module$5) {
|
|
124
|
+
var SRC = _uid("src");
|
|
125
|
+
var TO_STRING = "toString";
|
|
126
|
+
var TPL = ("" + _functionToString).split(TO_STRING);
|
|
127
|
+
_core.inspectSource = function(it) {
|
|
128
|
+
return _functionToString.call(it);
|
|
129
|
+
};
|
|
130
|
+
(module$5.exports = function(O, key, val, safe) {
|
|
131
|
+
var isFunction = typeof val == "function";
|
|
132
|
+
if (isFunction) _has(val, "name") || _hide(val, "name", key);
|
|
133
|
+
if (O[key] === val) return;
|
|
134
|
+
if (isFunction) _has(val, SRC) || _hide(val, SRC, O[key] ? "" + O[key] : TPL.join(String(key)));
|
|
135
|
+
if (O === _global) O[key] = val;
|
|
136
|
+
else if (!safe) {
|
|
137
|
+
delete O[key];
|
|
138
|
+
_hide(O, key, val);
|
|
139
|
+
} else if (O[key]) O[key] = val;
|
|
140
|
+
else _hide(O, key, val);
|
|
141
|
+
})(Function.prototype, TO_STRING, function toString() {
|
|
142
|
+
return typeof this == "function" && this[SRC] || _functionToString.call(this);
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
var _aFunction = function(it) {
|
|
146
|
+
if (typeof it != "function") throw TypeError(it + " is not a function!");
|
|
147
|
+
return it;
|
|
148
|
+
};
|
|
149
|
+
var _ctx = function(fn, that, length) {
|
|
150
|
+
_aFunction(fn);
|
|
151
|
+
if (that === void 0) return fn;
|
|
152
|
+
switch (length) {
|
|
153
|
+
case 1: return function(a) {
|
|
154
|
+
return fn.call(that, a);
|
|
155
|
+
};
|
|
156
|
+
case 2: return function(a, b) {
|
|
157
|
+
return fn.call(that, a, b);
|
|
158
|
+
};
|
|
159
|
+
case 3: return function(a, b, c) {
|
|
160
|
+
return fn.call(that, a, b, c);
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
return function() {
|
|
164
|
+
return fn.apply(that, arguments);
|
|
165
|
+
};
|
|
166
|
+
};
|
|
167
|
+
var PROTOTYPE = "prototype";
|
|
168
|
+
var $export = function(type, name, source) {
|
|
169
|
+
var IS_FORCED = type & $export.F;
|
|
170
|
+
var IS_GLOBAL = type & $export.G;
|
|
171
|
+
var IS_STATIC = type & $export.S;
|
|
172
|
+
var IS_PROTO = type & $export.P;
|
|
173
|
+
var IS_BIND = type & $export.B;
|
|
174
|
+
var target = IS_GLOBAL ? _global : IS_STATIC ? _global[name] || (_global[name] = {}) : (_global[name] || {})[PROTOTYPE];
|
|
175
|
+
var exports$1 = IS_GLOBAL ? _core : _core[name] || (_core[name] = {});
|
|
176
|
+
var expProto = exports$1[PROTOTYPE] || (exports$1[PROTOTYPE] = {});
|
|
177
|
+
var key, own, out, exp;
|
|
178
|
+
if (IS_GLOBAL) source = name;
|
|
179
|
+
for (key in source) {
|
|
180
|
+
own = !IS_FORCED && target && target[key] !== void 0;
|
|
181
|
+
out = (own ? target : source)[key];
|
|
182
|
+
exp = IS_BIND && own ? _ctx(out, _global) : IS_PROTO && typeof out == "function" ? _ctx(Function.call, out) : out;
|
|
183
|
+
if (target) _redefine(target, key, out, type & $export.U);
|
|
184
|
+
if (exports$1[key] != out) _hide(exports$1, key, exp);
|
|
185
|
+
if (IS_PROTO && expProto[key] != out) expProto[key] = out;
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
_global.core = _core;
|
|
189
|
+
$export.F = 1;
|
|
190
|
+
$export.G = 2;
|
|
191
|
+
$export.S = 4;
|
|
192
|
+
$export.P = 8;
|
|
193
|
+
$export.B = 16;
|
|
194
|
+
$export.W = 32;
|
|
195
|
+
$export.U = 64;
|
|
196
|
+
$export.R = 128;
|
|
197
|
+
var _export = $export;
|
|
198
|
+
var ceil = Math.ceil;
|
|
199
|
+
var floor = Math.floor;
|
|
200
|
+
var _toInteger = function(it) {
|
|
201
|
+
return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it);
|
|
202
|
+
};
|
|
203
|
+
var _defined = function(it) {
|
|
204
|
+
if (it == void 0) throw TypeError("Can't call method on " + it);
|
|
205
|
+
return it;
|
|
206
|
+
};
|
|
207
|
+
var _stringAt = function(TO_STRING) {
|
|
208
|
+
return function(that, pos) {
|
|
209
|
+
var s = String(_defined(that));
|
|
210
|
+
var i = _toInteger(pos);
|
|
211
|
+
var l = s.length;
|
|
212
|
+
var a, b;
|
|
213
|
+
if (i < 0 || i >= l) return TO_STRING ? "" : void 0;
|
|
214
|
+
a = s.charCodeAt(i);
|
|
215
|
+
return a < 55296 || a > 56319 || i + 1 === l || (b = s.charCodeAt(i + 1)) < 56320 || b > 57343 ? TO_STRING ? s.charAt(i) : a : TO_STRING ? s.slice(i, i + 2) : (a - 55296 << 10) + (b - 56320) + 65536;
|
|
216
|
+
};
|
|
217
|
+
};
|
|
218
|
+
var $at = _stringAt(false);
|
|
219
|
+
_export(_export.P, "String", { codePointAt: function codePointAt(pos) {
|
|
220
|
+
return $at(this, pos);
|
|
221
|
+
} });
|
|
222
|
+
_core.String.codePointAt;
|
|
223
|
+
var max = Math.max;
|
|
224
|
+
var min = Math.min;
|
|
225
|
+
var _toAbsoluteIndex = function(index, length) {
|
|
226
|
+
index = _toInteger(index);
|
|
227
|
+
return index < 0 ? max(index + length, 0) : min(index, length);
|
|
228
|
+
};
|
|
229
|
+
var fromCharCode = String.fromCharCode;
|
|
230
|
+
var $fromCodePoint = String.fromCodePoint;
|
|
231
|
+
_export(_export.S + _export.F * (!!$fromCodePoint && $fromCodePoint.length != 1), "String", { fromCodePoint: function fromCodePoint(x) {
|
|
232
|
+
var arguments$1 = arguments;
|
|
233
|
+
var res = [];
|
|
234
|
+
var aLen = arguments.length;
|
|
235
|
+
var i = 0;
|
|
236
|
+
var code;
|
|
237
|
+
while (aLen > i) {
|
|
238
|
+
code = +arguments$1[i++];
|
|
239
|
+
if (_toAbsoluteIndex(code, 1114111) !== code) throw RangeError(code + " is not a valid code point");
|
|
240
|
+
res.push(code < 65536 ? fromCharCode(code) : fromCharCode(((code -= 65536) >> 10) + 55296, code % 1024 + 56320));
|
|
241
|
+
}
|
|
242
|
+
return res.join("");
|
|
243
|
+
} });
|
|
244
|
+
_core.String.fromCodePoint;
|
|
245
|
+
var unicode = {
|
|
246
|
+
Space_Separator: /[\u1680\u2000-\u200A\u202F\u205F\u3000]/,
|
|
247
|
+
ID_Start: /[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDF00-\uDF19]|\uD806[\uDCA0-\uDCDF\uDCFF\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE83\uDE86-\uDE89\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]/,
|
|
248
|
+
ID_Continue: /[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u08D4-\u08E1\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u09FC\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9-\u0AFF\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C60-\u0C63\u0C66-\u0C6F\u0C80-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D00-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D54-\u0D57\u0D5F-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19D9\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C88\u1CD0-\u1CD2\u1CD4-\u1CF9\u1D00-\u1DF9\u1DFB-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u2E2F\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099\u309A\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE38-\uDE3A\uDE3F\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE6\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC00-\uDC46\uDC66-\uDC6F\uDC7F-\uDCBA\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDCA-\uDDCC\uDDD0-\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE37\uDE3E\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF00-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3C-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF50\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC00-\uDC4A\uDC50-\uDC59\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDDD8-\uDDDD\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB7\uDEC0-\uDEC9\uDF00-\uDF19\uDF1D-\uDF2B\uDF30-\uDF39]|\uD806[\uDCA0-\uDCE9\uDCFF\uDE00-\uDE3E\uDE47\uDE50-\uDE83\uDE86-\uDE99\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC36\uDC38-\uDC40\uDC50-\uDC59\uDC72-\uDC8F\uDC92-\uDCA7\uDCA9-\uDCB6\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD47\uDD50-\uDD59]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50-\uDF7E\uDF8F-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6\uDD00-\uDD4A\uDD50-\uDD59]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uDB40[\uDD00-\uDDEF]/
|
|
249
|
+
};
|
|
250
|
+
var util = {
|
|
251
|
+
isSpaceSeparator: function isSpaceSeparator(c) {
|
|
252
|
+
return typeof c === "string" && unicode.Space_Separator.test(c);
|
|
253
|
+
},
|
|
254
|
+
isIdStartChar: function isIdStartChar(c) {
|
|
255
|
+
return typeof c === "string" && (c >= "a" && c <= "z" || c >= "A" && c <= "Z" || c === "$" || c === "_" || unicode.ID_Start.test(c));
|
|
256
|
+
},
|
|
257
|
+
isIdContinueChar: function isIdContinueChar(c) {
|
|
258
|
+
return typeof c === "string" && (c >= "a" && c <= "z" || c >= "A" && c <= "Z" || c >= "0" && c <= "9" || c === "$" || c === "_" || c === "" || c === "" || unicode.ID_Continue.test(c));
|
|
259
|
+
},
|
|
260
|
+
isDigit: function isDigit(c) {
|
|
261
|
+
return typeof c === "string" && /[0-9]/.test(c);
|
|
262
|
+
},
|
|
263
|
+
isHexDigit: function isHexDigit(c) {
|
|
264
|
+
return typeof c === "string" && /[0-9A-Fa-f]/.test(c);
|
|
265
|
+
}
|
|
266
|
+
};
|
|
267
|
+
var source;
|
|
268
|
+
var parseState;
|
|
269
|
+
var stack;
|
|
270
|
+
var pos;
|
|
271
|
+
var line;
|
|
272
|
+
var column;
|
|
273
|
+
var token;
|
|
274
|
+
var key;
|
|
275
|
+
var root;
|
|
276
|
+
var parse = function parse(text, reviver) {
|
|
277
|
+
source = String(text);
|
|
278
|
+
parseState = "start";
|
|
279
|
+
stack = [];
|
|
280
|
+
pos = 0;
|
|
281
|
+
line = 1;
|
|
282
|
+
column = 0;
|
|
283
|
+
token = void 0;
|
|
284
|
+
key = void 0;
|
|
285
|
+
root = void 0;
|
|
286
|
+
do {
|
|
287
|
+
token = lex();
|
|
288
|
+
parseStates[parseState]();
|
|
289
|
+
} while (token.type !== "eof");
|
|
290
|
+
if (typeof reviver === "function") return internalize({ "": root }, "", reviver);
|
|
291
|
+
return root;
|
|
292
|
+
};
|
|
293
|
+
function internalize(holder, name, reviver) {
|
|
294
|
+
var value = holder[name];
|
|
295
|
+
if (value != null && typeof value === "object") if (Array.isArray(value)) for (var i = 0; i < value.length; i++) {
|
|
296
|
+
var key = String(i);
|
|
297
|
+
var replacement = internalize(value, key, reviver);
|
|
298
|
+
if (replacement === void 0) delete value[key];
|
|
299
|
+
else Object.defineProperty(value, key, {
|
|
300
|
+
value: replacement,
|
|
301
|
+
writable: true,
|
|
302
|
+
enumerable: true,
|
|
303
|
+
configurable: true
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
else for (var key$1 in value) {
|
|
307
|
+
var replacement$1 = internalize(value, key$1, reviver);
|
|
308
|
+
if (replacement$1 === void 0) delete value[key$1];
|
|
309
|
+
else Object.defineProperty(value, key$1, {
|
|
310
|
+
value: replacement$1,
|
|
311
|
+
writable: true,
|
|
312
|
+
enumerable: true,
|
|
313
|
+
configurable: true
|
|
314
|
+
});
|
|
315
|
+
}
|
|
316
|
+
return reviver.call(holder, name, value);
|
|
317
|
+
}
|
|
318
|
+
var lexState;
|
|
319
|
+
var buffer;
|
|
320
|
+
var doubleQuote;
|
|
321
|
+
var sign;
|
|
322
|
+
var c;
|
|
323
|
+
function lex() {
|
|
324
|
+
lexState = "default";
|
|
325
|
+
buffer = "";
|
|
326
|
+
doubleQuote = false;
|
|
327
|
+
sign = 1;
|
|
328
|
+
for (;;) {
|
|
329
|
+
c = peek();
|
|
330
|
+
var token = lexStates[lexState]();
|
|
331
|
+
if (token) return token;
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
function peek() {
|
|
335
|
+
if (source[pos]) return String.fromCodePoint(source.codePointAt(pos));
|
|
336
|
+
}
|
|
337
|
+
function read() {
|
|
338
|
+
var c = peek();
|
|
339
|
+
if (c === "\n") {
|
|
340
|
+
line++;
|
|
341
|
+
column = 0;
|
|
342
|
+
} else if (c) column += c.length;
|
|
343
|
+
else column++;
|
|
344
|
+
if (c) pos += c.length;
|
|
345
|
+
return c;
|
|
346
|
+
}
|
|
347
|
+
var lexStates = {
|
|
348
|
+
default: function default$1() {
|
|
349
|
+
switch (c) {
|
|
350
|
+
case " ":
|
|
351
|
+
case "\v":
|
|
352
|
+
case "\f":
|
|
353
|
+
case " ":
|
|
354
|
+
case "\xA0":
|
|
355
|
+
case "":
|
|
356
|
+
case "\n":
|
|
357
|
+
case "\r":
|
|
358
|
+
case "\u2028":
|
|
359
|
+
case "\u2029":
|
|
360
|
+
read();
|
|
361
|
+
return;
|
|
362
|
+
case "/":
|
|
363
|
+
read();
|
|
364
|
+
lexState = "comment";
|
|
365
|
+
return;
|
|
366
|
+
case void 0:
|
|
367
|
+
read();
|
|
368
|
+
return newToken("eof");
|
|
369
|
+
}
|
|
370
|
+
if (util.isSpaceSeparator(c)) {
|
|
371
|
+
read();
|
|
372
|
+
return;
|
|
373
|
+
}
|
|
374
|
+
return lexStates[parseState]();
|
|
375
|
+
},
|
|
376
|
+
comment: function comment() {
|
|
377
|
+
switch (c) {
|
|
378
|
+
case "*":
|
|
379
|
+
read();
|
|
380
|
+
lexState = "multiLineComment";
|
|
381
|
+
return;
|
|
382
|
+
case "/":
|
|
383
|
+
read();
|
|
384
|
+
lexState = "singleLineComment";
|
|
385
|
+
return;
|
|
386
|
+
}
|
|
387
|
+
throw invalidChar(read());
|
|
388
|
+
},
|
|
389
|
+
multiLineComment: function multiLineComment() {
|
|
390
|
+
switch (c) {
|
|
391
|
+
case "*":
|
|
392
|
+
read();
|
|
393
|
+
lexState = "multiLineCommentAsterisk";
|
|
394
|
+
return;
|
|
395
|
+
case void 0: throw invalidChar(read());
|
|
396
|
+
}
|
|
397
|
+
read();
|
|
398
|
+
},
|
|
399
|
+
multiLineCommentAsterisk: function multiLineCommentAsterisk() {
|
|
400
|
+
switch (c) {
|
|
401
|
+
case "*":
|
|
402
|
+
read();
|
|
403
|
+
return;
|
|
404
|
+
case "/":
|
|
405
|
+
read();
|
|
406
|
+
lexState = "default";
|
|
407
|
+
return;
|
|
408
|
+
case void 0: throw invalidChar(read());
|
|
409
|
+
}
|
|
410
|
+
read();
|
|
411
|
+
lexState = "multiLineComment";
|
|
412
|
+
},
|
|
413
|
+
singleLineComment: function singleLineComment() {
|
|
414
|
+
switch (c) {
|
|
415
|
+
case "\n":
|
|
416
|
+
case "\r":
|
|
417
|
+
case "\u2028":
|
|
418
|
+
case "\u2029":
|
|
419
|
+
read();
|
|
420
|
+
lexState = "default";
|
|
421
|
+
return;
|
|
422
|
+
case void 0:
|
|
423
|
+
read();
|
|
424
|
+
return newToken("eof");
|
|
425
|
+
}
|
|
426
|
+
read();
|
|
427
|
+
},
|
|
428
|
+
value: function value() {
|
|
429
|
+
switch (c) {
|
|
430
|
+
case "{":
|
|
431
|
+
case "[": return newToken("punctuator", read());
|
|
432
|
+
case "n":
|
|
433
|
+
read();
|
|
434
|
+
literal("ull");
|
|
435
|
+
return newToken("null", null);
|
|
436
|
+
case "t":
|
|
437
|
+
read();
|
|
438
|
+
literal("rue");
|
|
439
|
+
return newToken("boolean", true);
|
|
440
|
+
case "f":
|
|
441
|
+
read();
|
|
442
|
+
literal("alse");
|
|
443
|
+
return newToken("boolean", false);
|
|
444
|
+
case "-":
|
|
445
|
+
case "+":
|
|
446
|
+
if (read() === "-") sign = -1;
|
|
447
|
+
lexState = "sign";
|
|
448
|
+
return;
|
|
449
|
+
case ".":
|
|
450
|
+
buffer = read();
|
|
451
|
+
lexState = "decimalPointLeading";
|
|
452
|
+
return;
|
|
453
|
+
case "0":
|
|
454
|
+
buffer = read();
|
|
455
|
+
lexState = "zero";
|
|
456
|
+
return;
|
|
457
|
+
case "1":
|
|
458
|
+
case "2":
|
|
459
|
+
case "3":
|
|
460
|
+
case "4":
|
|
461
|
+
case "5":
|
|
462
|
+
case "6":
|
|
463
|
+
case "7":
|
|
464
|
+
case "8":
|
|
465
|
+
case "9":
|
|
466
|
+
buffer = read();
|
|
467
|
+
lexState = "decimalInteger";
|
|
468
|
+
return;
|
|
469
|
+
case "I":
|
|
470
|
+
read();
|
|
471
|
+
literal("nfinity");
|
|
472
|
+
return newToken("numeric", Infinity);
|
|
473
|
+
case "N":
|
|
474
|
+
read();
|
|
475
|
+
literal("aN");
|
|
476
|
+
return newToken("numeric", NaN);
|
|
477
|
+
case "\"":
|
|
478
|
+
case "'":
|
|
479
|
+
doubleQuote = read() === "\"";
|
|
480
|
+
buffer = "";
|
|
481
|
+
lexState = "string";
|
|
482
|
+
return;
|
|
483
|
+
}
|
|
484
|
+
throw invalidChar(read());
|
|
485
|
+
},
|
|
486
|
+
identifierNameStartEscape: function identifierNameStartEscape() {
|
|
487
|
+
if (c !== "u") throw invalidChar(read());
|
|
488
|
+
read();
|
|
489
|
+
var u = unicodeEscape();
|
|
490
|
+
switch (u) {
|
|
491
|
+
case "$":
|
|
492
|
+
case "_": break;
|
|
493
|
+
default:
|
|
494
|
+
if (!util.isIdStartChar(u)) throw invalidIdentifier();
|
|
495
|
+
break;
|
|
496
|
+
}
|
|
497
|
+
buffer += u;
|
|
498
|
+
lexState = "identifierName";
|
|
499
|
+
},
|
|
500
|
+
identifierName: function identifierName() {
|
|
501
|
+
switch (c) {
|
|
502
|
+
case "$":
|
|
503
|
+
case "_":
|
|
504
|
+
case "":
|
|
505
|
+
case "":
|
|
506
|
+
buffer += read();
|
|
507
|
+
return;
|
|
508
|
+
case "\\":
|
|
509
|
+
read();
|
|
510
|
+
lexState = "identifierNameEscape";
|
|
511
|
+
return;
|
|
512
|
+
}
|
|
513
|
+
if (util.isIdContinueChar(c)) {
|
|
514
|
+
buffer += read();
|
|
515
|
+
return;
|
|
516
|
+
}
|
|
517
|
+
return newToken("identifier", buffer);
|
|
518
|
+
},
|
|
519
|
+
identifierNameEscape: function identifierNameEscape() {
|
|
520
|
+
if (c !== "u") throw invalidChar(read());
|
|
521
|
+
read();
|
|
522
|
+
var u = unicodeEscape();
|
|
523
|
+
switch (u) {
|
|
524
|
+
case "$":
|
|
525
|
+
case "_":
|
|
526
|
+
case "":
|
|
527
|
+
case "": break;
|
|
528
|
+
default:
|
|
529
|
+
if (!util.isIdContinueChar(u)) throw invalidIdentifier();
|
|
530
|
+
break;
|
|
531
|
+
}
|
|
532
|
+
buffer += u;
|
|
533
|
+
lexState = "identifierName";
|
|
534
|
+
},
|
|
535
|
+
sign: function sign$1() {
|
|
536
|
+
switch (c) {
|
|
537
|
+
case ".":
|
|
538
|
+
buffer = read();
|
|
539
|
+
lexState = "decimalPointLeading";
|
|
540
|
+
return;
|
|
541
|
+
case "0":
|
|
542
|
+
buffer = read();
|
|
543
|
+
lexState = "zero";
|
|
544
|
+
return;
|
|
545
|
+
case "1":
|
|
546
|
+
case "2":
|
|
547
|
+
case "3":
|
|
548
|
+
case "4":
|
|
549
|
+
case "5":
|
|
550
|
+
case "6":
|
|
551
|
+
case "7":
|
|
552
|
+
case "8":
|
|
553
|
+
case "9":
|
|
554
|
+
buffer = read();
|
|
555
|
+
lexState = "decimalInteger";
|
|
556
|
+
return;
|
|
557
|
+
case "I":
|
|
558
|
+
read();
|
|
559
|
+
literal("nfinity");
|
|
560
|
+
return newToken("numeric", sign * Infinity);
|
|
561
|
+
case "N":
|
|
562
|
+
read();
|
|
563
|
+
literal("aN");
|
|
564
|
+
return newToken("numeric", NaN);
|
|
565
|
+
}
|
|
566
|
+
throw invalidChar(read());
|
|
567
|
+
},
|
|
568
|
+
zero: function zero() {
|
|
569
|
+
switch (c) {
|
|
570
|
+
case ".":
|
|
571
|
+
buffer += read();
|
|
572
|
+
lexState = "decimalPoint";
|
|
573
|
+
return;
|
|
574
|
+
case "e":
|
|
575
|
+
case "E":
|
|
576
|
+
buffer += read();
|
|
577
|
+
lexState = "decimalExponent";
|
|
578
|
+
return;
|
|
579
|
+
case "x":
|
|
580
|
+
case "X":
|
|
581
|
+
buffer += read();
|
|
582
|
+
lexState = "hexadecimal";
|
|
583
|
+
return;
|
|
584
|
+
}
|
|
585
|
+
return newToken("numeric", sign * 0);
|
|
586
|
+
},
|
|
587
|
+
decimalInteger: function decimalInteger() {
|
|
588
|
+
switch (c) {
|
|
589
|
+
case ".":
|
|
590
|
+
buffer += read();
|
|
591
|
+
lexState = "decimalPoint";
|
|
592
|
+
return;
|
|
593
|
+
case "e":
|
|
594
|
+
case "E":
|
|
595
|
+
buffer += read();
|
|
596
|
+
lexState = "decimalExponent";
|
|
597
|
+
return;
|
|
598
|
+
}
|
|
599
|
+
if (util.isDigit(c)) {
|
|
600
|
+
buffer += read();
|
|
601
|
+
return;
|
|
602
|
+
}
|
|
603
|
+
return newToken("numeric", sign * Number(buffer));
|
|
604
|
+
},
|
|
605
|
+
decimalPointLeading: function decimalPointLeading() {
|
|
606
|
+
if (util.isDigit(c)) {
|
|
607
|
+
buffer += read();
|
|
608
|
+
lexState = "decimalFraction";
|
|
609
|
+
return;
|
|
610
|
+
}
|
|
611
|
+
throw invalidChar(read());
|
|
612
|
+
},
|
|
613
|
+
decimalPoint: function decimalPoint() {
|
|
614
|
+
switch (c) {
|
|
615
|
+
case "e":
|
|
616
|
+
case "E":
|
|
617
|
+
buffer += read();
|
|
618
|
+
lexState = "decimalExponent";
|
|
619
|
+
return;
|
|
620
|
+
}
|
|
621
|
+
if (util.isDigit(c)) {
|
|
622
|
+
buffer += read();
|
|
623
|
+
lexState = "decimalFraction";
|
|
624
|
+
return;
|
|
625
|
+
}
|
|
626
|
+
return newToken("numeric", sign * Number(buffer));
|
|
627
|
+
},
|
|
628
|
+
decimalFraction: function decimalFraction() {
|
|
629
|
+
switch (c) {
|
|
630
|
+
case "e":
|
|
631
|
+
case "E":
|
|
632
|
+
buffer += read();
|
|
633
|
+
lexState = "decimalExponent";
|
|
634
|
+
return;
|
|
635
|
+
}
|
|
636
|
+
if (util.isDigit(c)) {
|
|
637
|
+
buffer += read();
|
|
638
|
+
return;
|
|
639
|
+
}
|
|
640
|
+
return newToken("numeric", sign * Number(buffer));
|
|
641
|
+
},
|
|
642
|
+
decimalExponent: function decimalExponent() {
|
|
643
|
+
switch (c) {
|
|
644
|
+
case "+":
|
|
645
|
+
case "-":
|
|
646
|
+
buffer += read();
|
|
647
|
+
lexState = "decimalExponentSign";
|
|
648
|
+
return;
|
|
649
|
+
}
|
|
650
|
+
if (util.isDigit(c)) {
|
|
651
|
+
buffer += read();
|
|
652
|
+
lexState = "decimalExponentInteger";
|
|
653
|
+
return;
|
|
654
|
+
}
|
|
655
|
+
throw invalidChar(read());
|
|
656
|
+
},
|
|
657
|
+
decimalExponentSign: function decimalExponentSign() {
|
|
658
|
+
if (util.isDigit(c)) {
|
|
659
|
+
buffer += read();
|
|
660
|
+
lexState = "decimalExponentInteger";
|
|
661
|
+
return;
|
|
662
|
+
}
|
|
663
|
+
throw invalidChar(read());
|
|
664
|
+
},
|
|
665
|
+
decimalExponentInteger: function decimalExponentInteger() {
|
|
666
|
+
if (util.isDigit(c)) {
|
|
667
|
+
buffer += read();
|
|
668
|
+
return;
|
|
669
|
+
}
|
|
670
|
+
return newToken("numeric", sign * Number(buffer));
|
|
671
|
+
},
|
|
672
|
+
hexadecimal: function hexadecimal() {
|
|
673
|
+
if (util.isHexDigit(c)) {
|
|
674
|
+
buffer += read();
|
|
675
|
+
lexState = "hexadecimalInteger";
|
|
676
|
+
return;
|
|
677
|
+
}
|
|
678
|
+
throw invalidChar(read());
|
|
679
|
+
},
|
|
680
|
+
hexadecimalInteger: function hexadecimalInteger() {
|
|
681
|
+
if (util.isHexDigit(c)) {
|
|
682
|
+
buffer += read();
|
|
683
|
+
return;
|
|
684
|
+
}
|
|
685
|
+
return newToken("numeric", sign * Number(buffer));
|
|
686
|
+
},
|
|
687
|
+
string: function string() {
|
|
688
|
+
switch (c) {
|
|
689
|
+
case "\\":
|
|
690
|
+
read();
|
|
691
|
+
buffer += escape();
|
|
692
|
+
return;
|
|
693
|
+
case "\"":
|
|
694
|
+
if (doubleQuote) {
|
|
695
|
+
read();
|
|
696
|
+
return newToken("string", buffer);
|
|
697
|
+
}
|
|
698
|
+
buffer += read();
|
|
699
|
+
return;
|
|
700
|
+
case "'":
|
|
701
|
+
if (!doubleQuote) {
|
|
702
|
+
read();
|
|
703
|
+
return newToken("string", buffer);
|
|
704
|
+
}
|
|
705
|
+
buffer += read();
|
|
706
|
+
return;
|
|
707
|
+
case "\n":
|
|
708
|
+
case "\r": throw invalidChar(read());
|
|
709
|
+
case "\u2028":
|
|
710
|
+
case "\u2029":
|
|
711
|
+
separatorChar(c);
|
|
712
|
+
break;
|
|
713
|
+
case void 0: throw invalidChar(read());
|
|
714
|
+
}
|
|
715
|
+
buffer += read();
|
|
716
|
+
},
|
|
717
|
+
start: function start() {
|
|
718
|
+
switch (c) {
|
|
719
|
+
case "{":
|
|
720
|
+
case "[": return newToken("punctuator", read());
|
|
721
|
+
}
|
|
722
|
+
lexState = "value";
|
|
723
|
+
},
|
|
724
|
+
beforePropertyName: function beforePropertyName() {
|
|
725
|
+
switch (c) {
|
|
726
|
+
case "$":
|
|
727
|
+
case "_":
|
|
728
|
+
buffer = read();
|
|
729
|
+
lexState = "identifierName";
|
|
730
|
+
return;
|
|
731
|
+
case "\\":
|
|
732
|
+
read();
|
|
733
|
+
lexState = "identifierNameStartEscape";
|
|
734
|
+
return;
|
|
735
|
+
case "}": return newToken("punctuator", read());
|
|
736
|
+
case "\"":
|
|
737
|
+
case "'":
|
|
738
|
+
doubleQuote = read() === "\"";
|
|
739
|
+
lexState = "string";
|
|
740
|
+
return;
|
|
741
|
+
}
|
|
742
|
+
if (util.isIdStartChar(c)) {
|
|
743
|
+
buffer += read();
|
|
744
|
+
lexState = "identifierName";
|
|
745
|
+
return;
|
|
746
|
+
}
|
|
747
|
+
throw invalidChar(read());
|
|
748
|
+
},
|
|
749
|
+
afterPropertyName: function afterPropertyName() {
|
|
750
|
+
if (c === ":") return newToken("punctuator", read());
|
|
751
|
+
throw invalidChar(read());
|
|
752
|
+
},
|
|
753
|
+
beforePropertyValue: function beforePropertyValue() {
|
|
754
|
+
lexState = "value";
|
|
755
|
+
},
|
|
756
|
+
afterPropertyValue: function afterPropertyValue() {
|
|
757
|
+
switch (c) {
|
|
758
|
+
case ",":
|
|
759
|
+
case "}": return newToken("punctuator", read());
|
|
760
|
+
}
|
|
761
|
+
throw invalidChar(read());
|
|
762
|
+
},
|
|
763
|
+
beforeArrayValue: function beforeArrayValue() {
|
|
764
|
+
if (c === "]") return newToken("punctuator", read());
|
|
765
|
+
lexState = "value";
|
|
766
|
+
},
|
|
767
|
+
afterArrayValue: function afterArrayValue() {
|
|
768
|
+
switch (c) {
|
|
769
|
+
case ",":
|
|
770
|
+
case "]": return newToken("punctuator", read());
|
|
771
|
+
}
|
|
772
|
+
throw invalidChar(read());
|
|
773
|
+
},
|
|
774
|
+
end: function end() {
|
|
775
|
+
throw invalidChar(read());
|
|
776
|
+
}
|
|
777
|
+
};
|
|
778
|
+
function newToken(type, value) {
|
|
779
|
+
return {
|
|
780
|
+
type,
|
|
781
|
+
value,
|
|
782
|
+
line,
|
|
783
|
+
column
|
|
784
|
+
};
|
|
785
|
+
}
|
|
786
|
+
function literal(s) {
|
|
787
|
+
for (var i = 0, list = s; i < list.length; i += 1) {
|
|
788
|
+
var c = list[i];
|
|
789
|
+
if (peek() !== c) throw invalidChar(read());
|
|
790
|
+
read();
|
|
791
|
+
}
|
|
792
|
+
}
|
|
793
|
+
function escape() {
|
|
794
|
+
switch (peek()) {
|
|
795
|
+
case "b":
|
|
796
|
+
read();
|
|
797
|
+
return "\b";
|
|
798
|
+
case "f":
|
|
799
|
+
read();
|
|
800
|
+
return "\f";
|
|
801
|
+
case "n":
|
|
802
|
+
read();
|
|
803
|
+
return "\n";
|
|
804
|
+
case "r":
|
|
805
|
+
read();
|
|
806
|
+
return "\r";
|
|
807
|
+
case "t":
|
|
808
|
+
read();
|
|
809
|
+
return " ";
|
|
810
|
+
case "v":
|
|
811
|
+
read();
|
|
812
|
+
return "\v";
|
|
813
|
+
case "0":
|
|
814
|
+
read();
|
|
815
|
+
if (util.isDigit(peek())) throw invalidChar(read());
|
|
816
|
+
return "\0";
|
|
817
|
+
case "x":
|
|
818
|
+
read();
|
|
819
|
+
return hexEscape();
|
|
820
|
+
case "u":
|
|
821
|
+
read();
|
|
822
|
+
return unicodeEscape();
|
|
823
|
+
case "\n":
|
|
824
|
+
case "\u2028":
|
|
825
|
+
case "\u2029":
|
|
826
|
+
read();
|
|
827
|
+
return "";
|
|
828
|
+
case "\r":
|
|
829
|
+
read();
|
|
830
|
+
if (peek() === "\n") read();
|
|
831
|
+
return "";
|
|
832
|
+
case "1":
|
|
833
|
+
case "2":
|
|
834
|
+
case "3":
|
|
835
|
+
case "4":
|
|
836
|
+
case "5":
|
|
837
|
+
case "6":
|
|
838
|
+
case "7":
|
|
839
|
+
case "8":
|
|
840
|
+
case "9": throw invalidChar(read());
|
|
841
|
+
case void 0: throw invalidChar(read());
|
|
842
|
+
}
|
|
843
|
+
return read();
|
|
844
|
+
}
|
|
845
|
+
function hexEscape() {
|
|
846
|
+
var buffer = "";
|
|
847
|
+
var c = peek();
|
|
848
|
+
if (!util.isHexDigit(c)) throw invalidChar(read());
|
|
849
|
+
buffer += read();
|
|
850
|
+
c = peek();
|
|
851
|
+
if (!util.isHexDigit(c)) throw invalidChar(read());
|
|
852
|
+
buffer += read();
|
|
853
|
+
return String.fromCodePoint(parseInt(buffer, 16));
|
|
854
|
+
}
|
|
855
|
+
function unicodeEscape() {
|
|
856
|
+
var buffer = "";
|
|
857
|
+
var count = 4;
|
|
858
|
+
while (count-- > 0) {
|
|
859
|
+
var c = peek();
|
|
860
|
+
if (!util.isHexDigit(c)) throw invalidChar(read());
|
|
861
|
+
buffer += read();
|
|
862
|
+
}
|
|
863
|
+
return String.fromCodePoint(parseInt(buffer, 16));
|
|
864
|
+
}
|
|
865
|
+
var parseStates = {
|
|
866
|
+
start: function start() {
|
|
867
|
+
if (token.type === "eof") throw invalidEOF();
|
|
868
|
+
push();
|
|
869
|
+
},
|
|
870
|
+
beforePropertyName: function beforePropertyName() {
|
|
871
|
+
switch (token.type) {
|
|
872
|
+
case "identifier":
|
|
873
|
+
case "string":
|
|
874
|
+
key = token.value;
|
|
875
|
+
parseState = "afterPropertyName";
|
|
876
|
+
return;
|
|
877
|
+
case "punctuator":
|
|
878
|
+
pop();
|
|
879
|
+
return;
|
|
880
|
+
case "eof": throw invalidEOF();
|
|
881
|
+
}
|
|
882
|
+
},
|
|
883
|
+
afterPropertyName: function afterPropertyName() {
|
|
884
|
+
if (token.type === "eof") throw invalidEOF();
|
|
885
|
+
parseState = "beforePropertyValue";
|
|
886
|
+
},
|
|
887
|
+
beforePropertyValue: function beforePropertyValue() {
|
|
888
|
+
if (token.type === "eof") throw invalidEOF();
|
|
889
|
+
push();
|
|
890
|
+
},
|
|
891
|
+
beforeArrayValue: function beforeArrayValue() {
|
|
892
|
+
if (token.type === "eof") throw invalidEOF();
|
|
893
|
+
if (token.type === "punctuator" && token.value === "]") {
|
|
894
|
+
pop();
|
|
895
|
+
return;
|
|
896
|
+
}
|
|
897
|
+
push();
|
|
898
|
+
},
|
|
899
|
+
afterPropertyValue: function afterPropertyValue() {
|
|
900
|
+
if (token.type === "eof") throw invalidEOF();
|
|
901
|
+
switch (token.value) {
|
|
902
|
+
case ",":
|
|
903
|
+
parseState = "beforePropertyName";
|
|
904
|
+
return;
|
|
905
|
+
case "}": pop();
|
|
906
|
+
}
|
|
907
|
+
},
|
|
908
|
+
afterArrayValue: function afterArrayValue() {
|
|
909
|
+
if (token.type === "eof") throw invalidEOF();
|
|
910
|
+
switch (token.value) {
|
|
911
|
+
case ",":
|
|
912
|
+
parseState = "beforeArrayValue";
|
|
913
|
+
return;
|
|
914
|
+
case "]": pop();
|
|
915
|
+
}
|
|
916
|
+
},
|
|
917
|
+
end: function end() {}
|
|
918
|
+
};
|
|
919
|
+
function push() {
|
|
920
|
+
var value;
|
|
921
|
+
switch (token.type) {
|
|
922
|
+
case "punctuator":
|
|
923
|
+
switch (token.value) {
|
|
924
|
+
case "{":
|
|
925
|
+
value = {};
|
|
926
|
+
break;
|
|
927
|
+
case "[":
|
|
928
|
+
value = [];
|
|
929
|
+
break;
|
|
930
|
+
}
|
|
931
|
+
break;
|
|
932
|
+
case "null":
|
|
933
|
+
case "boolean":
|
|
934
|
+
case "numeric":
|
|
935
|
+
case "string":
|
|
936
|
+
value = token.value;
|
|
937
|
+
break;
|
|
938
|
+
}
|
|
939
|
+
if (root === void 0) root = value;
|
|
940
|
+
else {
|
|
941
|
+
var parent = stack[stack.length - 1];
|
|
942
|
+
if (Array.isArray(parent)) parent.push(value);
|
|
943
|
+
else Object.defineProperty(parent, key, {
|
|
944
|
+
value,
|
|
945
|
+
writable: true,
|
|
946
|
+
enumerable: true,
|
|
947
|
+
configurable: true
|
|
948
|
+
});
|
|
949
|
+
}
|
|
950
|
+
if (value !== null && typeof value === "object") {
|
|
951
|
+
stack.push(value);
|
|
952
|
+
if (Array.isArray(value)) parseState = "beforeArrayValue";
|
|
953
|
+
else parseState = "beforePropertyName";
|
|
954
|
+
} else {
|
|
955
|
+
var current = stack[stack.length - 1];
|
|
956
|
+
if (current == null) parseState = "end";
|
|
957
|
+
else if (Array.isArray(current)) parseState = "afterArrayValue";
|
|
958
|
+
else parseState = "afterPropertyValue";
|
|
959
|
+
}
|
|
960
|
+
}
|
|
961
|
+
function pop() {
|
|
962
|
+
stack.pop();
|
|
963
|
+
var current = stack[stack.length - 1];
|
|
964
|
+
if (current == null) parseState = "end";
|
|
965
|
+
else if (Array.isArray(current)) parseState = "afterArrayValue";
|
|
966
|
+
else parseState = "afterPropertyValue";
|
|
967
|
+
}
|
|
968
|
+
function invalidChar(c) {
|
|
969
|
+
if (c === void 0) return syntaxError("JSON5: invalid end of input at " + line + ":" + column);
|
|
970
|
+
return syntaxError("JSON5: invalid character '" + formatChar(c) + "' at " + line + ":" + column);
|
|
971
|
+
}
|
|
972
|
+
function invalidEOF() {
|
|
973
|
+
return syntaxError("JSON5: invalid end of input at " + line + ":" + column);
|
|
974
|
+
}
|
|
975
|
+
function invalidIdentifier() {
|
|
976
|
+
column -= 5;
|
|
977
|
+
return syntaxError("JSON5: invalid identifier character at " + line + ":" + column);
|
|
978
|
+
}
|
|
979
|
+
function separatorChar(c) {
|
|
980
|
+
console.warn("JSON5: '" + formatChar(c) + "' in strings is not valid ECMAScript; consider escaping");
|
|
981
|
+
}
|
|
982
|
+
function formatChar(c) {
|
|
983
|
+
var replacements = {
|
|
984
|
+
"'": "\\'",
|
|
985
|
+
"\"": "\\\"",
|
|
986
|
+
"\\": "\\\\",
|
|
987
|
+
"\b": "\\b",
|
|
988
|
+
"\f": "\\f",
|
|
989
|
+
"\n": "\\n",
|
|
990
|
+
"\r": "\\r",
|
|
991
|
+
" ": "\\t",
|
|
992
|
+
"\v": "\\v",
|
|
993
|
+
"\0": "\\0",
|
|
994
|
+
"\u2028": "\\u2028",
|
|
995
|
+
"\u2029": "\\u2029"
|
|
996
|
+
};
|
|
997
|
+
if (replacements[c]) return replacements[c];
|
|
998
|
+
if (c < " ") {
|
|
999
|
+
var hexString = c.charCodeAt(0).toString(16);
|
|
1000
|
+
return "\\x" + ("00" + hexString).substring(hexString.length);
|
|
1001
|
+
}
|
|
1002
|
+
return c;
|
|
1003
|
+
}
|
|
1004
|
+
function syntaxError(message) {
|
|
1005
|
+
var err = new SyntaxError(message);
|
|
1006
|
+
err.lineNumber = line;
|
|
1007
|
+
err.columnNumber = column;
|
|
1008
|
+
return err;
|
|
1009
|
+
}
|
|
1010
|
+
return {
|
|
1011
|
+
parse,
|
|
1012
|
+
stringify: function stringify(value, replacer, space) {
|
|
1013
|
+
var stack = [];
|
|
1014
|
+
var indent = "";
|
|
1015
|
+
var propertyList;
|
|
1016
|
+
var replacerFunc;
|
|
1017
|
+
var gap = "";
|
|
1018
|
+
var quote;
|
|
1019
|
+
if (replacer != null && typeof replacer === "object" && !Array.isArray(replacer)) {
|
|
1020
|
+
space = replacer.space;
|
|
1021
|
+
quote = replacer.quote;
|
|
1022
|
+
replacer = replacer.replacer;
|
|
1023
|
+
}
|
|
1024
|
+
if (typeof replacer === "function") replacerFunc = replacer;
|
|
1025
|
+
else if (Array.isArray(replacer)) {
|
|
1026
|
+
propertyList = [];
|
|
1027
|
+
for (var i = 0, list = replacer; i < list.length; i += 1) {
|
|
1028
|
+
var v = list[i];
|
|
1029
|
+
var item = void 0;
|
|
1030
|
+
if (typeof v === "string") item = v;
|
|
1031
|
+
else if (typeof v === "number" || v instanceof String || v instanceof Number) item = String(v);
|
|
1032
|
+
if (item !== void 0 && propertyList.indexOf(item) < 0) propertyList.push(item);
|
|
1033
|
+
}
|
|
1034
|
+
}
|
|
1035
|
+
if (space instanceof Number) space = Number(space);
|
|
1036
|
+
else if (space instanceof String) space = String(space);
|
|
1037
|
+
if (typeof space === "number") {
|
|
1038
|
+
if (space > 0) {
|
|
1039
|
+
space = Math.min(10, Math.floor(space));
|
|
1040
|
+
gap = " ".substr(0, space);
|
|
1041
|
+
}
|
|
1042
|
+
} else if (typeof space === "string") gap = space.substr(0, 10);
|
|
1043
|
+
return serializeProperty("", { "": value });
|
|
1044
|
+
function serializeProperty(key, holder) {
|
|
1045
|
+
var value = holder[key];
|
|
1046
|
+
if (value != null) {
|
|
1047
|
+
if (typeof value.toJSON5 === "function") value = value.toJSON5(key);
|
|
1048
|
+
else if (typeof value.toJSON === "function") value = value.toJSON(key);
|
|
1049
|
+
}
|
|
1050
|
+
if (replacerFunc) value = replacerFunc.call(holder, key, value);
|
|
1051
|
+
if (value instanceof Number) value = Number(value);
|
|
1052
|
+
else if (value instanceof String) value = String(value);
|
|
1053
|
+
else if (value instanceof Boolean) value = value.valueOf();
|
|
1054
|
+
switch (value) {
|
|
1055
|
+
case null: return "null";
|
|
1056
|
+
case true: return "true";
|
|
1057
|
+
case false: return "false";
|
|
1058
|
+
}
|
|
1059
|
+
if (typeof value === "string") return quoteString(value, false);
|
|
1060
|
+
if (typeof value === "number") return String(value);
|
|
1061
|
+
if (typeof value === "object") return Array.isArray(value) ? serializeArray(value) : serializeObject(value);
|
|
1062
|
+
}
|
|
1063
|
+
function quoteString(value) {
|
|
1064
|
+
var quotes = {
|
|
1065
|
+
"'": .1,
|
|
1066
|
+
"\"": .2
|
|
1067
|
+
};
|
|
1068
|
+
var replacements = {
|
|
1069
|
+
"'": "\\'",
|
|
1070
|
+
"\"": "\\\"",
|
|
1071
|
+
"\\": "\\\\",
|
|
1072
|
+
"\b": "\\b",
|
|
1073
|
+
"\f": "\\f",
|
|
1074
|
+
"\n": "\\n",
|
|
1075
|
+
"\r": "\\r",
|
|
1076
|
+
" ": "\\t",
|
|
1077
|
+
"\v": "\\v",
|
|
1078
|
+
"\0": "\\0",
|
|
1079
|
+
"\u2028": "\\u2028",
|
|
1080
|
+
"\u2029": "\\u2029"
|
|
1081
|
+
};
|
|
1082
|
+
var product = "";
|
|
1083
|
+
for (var i = 0; i < value.length; i++) {
|
|
1084
|
+
var c = value[i];
|
|
1085
|
+
switch (c) {
|
|
1086
|
+
case "'":
|
|
1087
|
+
case "\"":
|
|
1088
|
+
quotes[c]++;
|
|
1089
|
+
product += c;
|
|
1090
|
+
continue;
|
|
1091
|
+
case "\0": if (util.isDigit(value[i + 1])) {
|
|
1092
|
+
product += "\\x00";
|
|
1093
|
+
continue;
|
|
1094
|
+
}
|
|
1095
|
+
}
|
|
1096
|
+
if (replacements[c]) {
|
|
1097
|
+
product += replacements[c];
|
|
1098
|
+
continue;
|
|
1099
|
+
}
|
|
1100
|
+
if (c < " ") {
|
|
1101
|
+
var hexString = c.charCodeAt(0).toString(16);
|
|
1102
|
+
product += "\\x" + ("00" + hexString).substring(hexString.length);
|
|
1103
|
+
continue;
|
|
1104
|
+
}
|
|
1105
|
+
product += c;
|
|
1106
|
+
}
|
|
1107
|
+
var quoteChar = quote || Object.keys(quotes).reduce(function(a, b) {
|
|
1108
|
+
return quotes[a] < quotes[b] ? a : b;
|
|
1109
|
+
});
|
|
1110
|
+
product = product.replace(new RegExp(quoteChar, "g"), replacements[quoteChar]);
|
|
1111
|
+
return quoteChar + product + quoteChar;
|
|
1112
|
+
}
|
|
1113
|
+
function serializeObject(value) {
|
|
1114
|
+
if (stack.indexOf(value) >= 0) throw TypeError("Converting circular structure to JSON5");
|
|
1115
|
+
stack.push(value);
|
|
1116
|
+
var stepback = indent;
|
|
1117
|
+
indent = indent + gap;
|
|
1118
|
+
var keys = propertyList || Object.keys(value);
|
|
1119
|
+
var partial = [];
|
|
1120
|
+
for (var i = 0, list = keys; i < list.length; i += 1) {
|
|
1121
|
+
var key = list[i];
|
|
1122
|
+
var propertyString = serializeProperty(key, value);
|
|
1123
|
+
if (propertyString !== void 0) {
|
|
1124
|
+
var member = serializeKey(key) + ":";
|
|
1125
|
+
if (gap !== "") member += " ";
|
|
1126
|
+
member += propertyString;
|
|
1127
|
+
partial.push(member);
|
|
1128
|
+
}
|
|
1129
|
+
}
|
|
1130
|
+
var final;
|
|
1131
|
+
if (partial.length === 0) final = "{}";
|
|
1132
|
+
else {
|
|
1133
|
+
var properties;
|
|
1134
|
+
if (gap === "") {
|
|
1135
|
+
properties = partial.join(",");
|
|
1136
|
+
final = "{" + properties + "}";
|
|
1137
|
+
} else {
|
|
1138
|
+
var separator = ",\n" + indent;
|
|
1139
|
+
properties = partial.join(separator);
|
|
1140
|
+
final = "{\n" + indent + properties + ",\n" + stepback + "}";
|
|
1141
|
+
}
|
|
1142
|
+
}
|
|
1143
|
+
stack.pop();
|
|
1144
|
+
indent = stepback;
|
|
1145
|
+
return final;
|
|
1146
|
+
}
|
|
1147
|
+
function serializeKey(key) {
|
|
1148
|
+
if (key.length === 0) return quoteString(key, true);
|
|
1149
|
+
var firstChar = String.fromCodePoint(key.codePointAt(0));
|
|
1150
|
+
if (!util.isIdStartChar(firstChar)) return quoteString(key, true);
|
|
1151
|
+
for (var i = firstChar.length; i < key.length; i++) if (!util.isIdContinueChar(String.fromCodePoint(key.codePointAt(i)))) return quoteString(key, true);
|
|
1152
|
+
return key;
|
|
1153
|
+
}
|
|
1154
|
+
function serializeArray(value) {
|
|
1155
|
+
if (stack.indexOf(value) >= 0) throw TypeError("Converting circular structure to JSON5");
|
|
1156
|
+
stack.push(value);
|
|
1157
|
+
var stepback = indent;
|
|
1158
|
+
indent = indent + gap;
|
|
1159
|
+
var partial = [];
|
|
1160
|
+
for (var i = 0; i < value.length; i++) {
|
|
1161
|
+
var propertyString = serializeProperty(String(i), value);
|
|
1162
|
+
partial.push(propertyString !== void 0 ? propertyString : "null");
|
|
1163
|
+
}
|
|
1164
|
+
var final;
|
|
1165
|
+
if (partial.length === 0) final = "[]";
|
|
1166
|
+
else if (gap === "") final = "[" + partial.join(",") + "]";
|
|
1167
|
+
else {
|
|
1168
|
+
var separator = ",\n" + indent;
|
|
1169
|
+
var properties$1 = partial.join(separator);
|
|
1170
|
+
final = "[\n" + indent + properties$1 + ",\n" + stepback + "]";
|
|
1171
|
+
}
|
|
1172
|
+
stack.pop();
|
|
1173
|
+
indent = stepback;
|
|
1174
|
+
return final;
|
|
1175
|
+
}
|
|
1176
|
+
}
|
|
1177
|
+
};
|
|
1178
|
+
}));
|
|
1179
|
+
})))();
|
|
1180
|
+
/**
|
|
1181
|
+
* Fixed byte size reserved in muon-core for an embedded muon.json payload.
|
|
1182
|
+
*/
|
|
1183
|
+
var muonEmbeddedConfigSlotSize = 64 * 1024;
|
|
1184
|
+
/**
|
|
1185
|
+
* Fixed byte sequence used to locate an unembedded config slot.
|
|
1186
|
+
*/
|
|
1187
|
+
var muonEmbeddedConfigEmptySlotMarker = Buffer.from([
|
|
1188
|
+
109,
|
|
1189
|
+
117,
|
|
1190
|
+
111,
|
|
1191
|
+
110,
|
|
1192
|
+
45,
|
|
1193
|
+
99,
|
|
1194
|
+
111,
|
|
1195
|
+
114,
|
|
1196
|
+
101,
|
|
1197
|
+
58,
|
|
1198
|
+
101,
|
|
1199
|
+
109,
|
|
1200
|
+
98,
|
|
1201
|
+
101,
|
|
1202
|
+
100,
|
|
1203
|
+
45,
|
|
1204
|
+
99,
|
|
1205
|
+
111,
|
|
1206
|
+
110,
|
|
1207
|
+
102,
|
|
1208
|
+
105,
|
|
1209
|
+
103,
|
|
1210
|
+
58,
|
|
1211
|
+
115,
|
|
1212
|
+
108,
|
|
1213
|
+
111,
|
|
1214
|
+
116,
|
|
1215
|
+
58,
|
|
1216
|
+
118,
|
|
1217
|
+
49,
|
|
1218
|
+
0,
|
|
1219
|
+
93
|
|
1220
|
+
]);
|
|
1221
|
+
var muonEmbeddedConfigPayloadCapacity = muonEmbeddedConfigSlotSize;
|
|
1222
|
+
var muonBootstrapEmbeddedConfigSlotSize = 64 * 1024;
|
|
1223
|
+
var muonBootstrapEmbeddedConfigEmptySlotMarker = Buffer.from([
|
|
1224
|
+
109,
|
|
1225
|
+
117,
|
|
1226
|
+
111,
|
|
1227
|
+
110,
|
|
1228
|
+
45,
|
|
1229
|
+
98,
|
|
1230
|
+
111,
|
|
1231
|
+
111,
|
|
1232
|
+
116,
|
|
1233
|
+
115,
|
|
1234
|
+
116,
|
|
1235
|
+
114,
|
|
1236
|
+
97,
|
|
1237
|
+
112,
|
|
1238
|
+
58,
|
|
1239
|
+
101,
|
|
1240
|
+
109,
|
|
1241
|
+
98,
|
|
1242
|
+
101,
|
|
1243
|
+
100,
|
|
1244
|
+
45,
|
|
1245
|
+
99,
|
|
1246
|
+
111,
|
|
1247
|
+
110,
|
|
1248
|
+
102,
|
|
1249
|
+
105,
|
|
1250
|
+
103,
|
|
1251
|
+
58,
|
|
1252
|
+
118,
|
|
1253
|
+
49,
|
|
1254
|
+
0,
|
|
1255
|
+
93
|
|
1256
|
+
]);
|
|
1257
|
+
var muonBootstrapEmbeddedConfigPayloadCapacity = muonBootstrapEmbeddedConfigSlotSize;
|
|
1258
|
+
var tlvNullTag = 0;
|
|
1259
|
+
var tlvFalseTag = 1;
|
|
1260
|
+
var tlvTrueTag = 2;
|
|
1261
|
+
var tlvUintTag = 3;
|
|
1262
|
+
var tlvStringTag = 4;
|
|
1263
|
+
var tlvBinaryTag = 5;
|
|
1264
|
+
var tlvArrayTag = 6;
|
|
1265
|
+
var tlvObjectTag = 7;
|
|
1266
|
+
var getEmbeddedConfigEmptySlotByte = (index) => {
|
|
1267
|
+
if (index < muonEmbeddedConfigEmptySlotMarker.length) return muonEmbeddedConfigEmptySlotMarker[index] ?? 0;
|
|
1268
|
+
return (165 ^ Math.imul(index, 37) ^ Math.imul(index >>> 8, 109) ^ Math.imul(index >>> 16, 59) ^ Math.imul(index, 2654435761) >>> 24) & 255;
|
|
1269
|
+
};
|
|
1270
|
+
var createEmptySlot = () => {
|
|
1271
|
+
const slot = Buffer.allocUnsafe(muonEmbeddedConfigSlotSize);
|
|
1272
|
+
for (let index = 0; index < slot.length; index += 1) slot[index] = getEmbeddedConfigEmptySlotByte(index);
|
|
1273
|
+
return slot;
|
|
1274
|
+
};
|
|
1275
|
+
var encodeVarUint = (value) => {
|
|
1276
|
+
const bytes = [];
|
|
1277
|
+
let remaining = value;
|
|
1278
|
+
do {
|
|
1279
|
+
let byte = Number(remaining & 127n);
|
|
1280
|
+
remaining >>= 7n;
|
|
1281
|
+
if (remaining !== 0n) byte |= 128;
|
|
1282
|
+
bytes.push(byte);
|
|
1283
|
+
} while (remaining !== 0n);
|
|
1284
|
+
return Buffer.from(bytes);
|
|
1285
|
+
};
|
|
1286
|
+
var encodeRawString = (value) => {
|
|
1287
|
+
const bytes = Buffer.from(value, "utf8");
|
|
1288
|
+
return Buffer.concat([encodeVarUint(BigInt(bytes.length)), bytes]);
|
|
1289
|
+
};
|
|
1290
|
+
var encodeTaggedBytes = (tag, bytes) => Buffer.concat([
|
|
1291
|
+
Buffer.from([tag]),
|
|
1292
|
+
encodeVarUint(BigInt(bytes.length)),
|
|
1293
|
+
Buffer.from(bytes)
|
|
1294
|
+
]);
|
|
1295
|
+
var isJsonObject$1 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1296
|
+
var isPath = (path, first, second) => path.length === 2 && path[0] === first && path[1] === second;
|
|
1297
|
+
var isHexString = (value) => value.length % 2 === 0 && /^[0-9a-fA-F]*$/.test(value);
|
|
1298
|
+
var decodeHexString = (value) => {
|
|
1299
|
+
const bytes = Buffer.alloc(value.length / 2);
|
|
1300
|
+
for (let index = 0; index < value.length; index += 2) bytes[index / 2] = Number.parseInt(value.slice(index, index + 2), 16);
|
|
1301
|
+
return bytes;
|
|
1302
|
+
};
|
|
1303
|
+
var encodeKnownBinaryString = (path, value) => {
|
|
1304
|
+
if (isPath(path, "asset", "signature")) return value.length === 40 && isHexString(value) ? decodeHexString(value) : void 0;
|
|
1305
|
+
if (isPath(path, "asset", "salt")) return isHexString(value) ? decodeHexString(value) : void 0;
|
|
1306
|
+
if (isPath(path, "browser", "backgroundColor")) {
|
|
1307
|
+
const hex = value.startsWith("#") ? value.slice(1) : value;
|
|
1308
|
+
return hex.length === 6 && isHexString(hex) ? decodeHexString(hex) : void 0;
|
|
1309
|
+
}
|
|
1310
|
+
};
|
|
1311
|
+
var encodeTlvValue = (value, path) => {
|
|
1312
|
+
if (value === null) return Buffer.from([tlvNullTag]);
|
|
1313
|
+
if (typeof value === "boolean") return Buffer.from([value ? tlvTrueTag : tlvFalseTag]);
|
|
1314
|
+
if (typeof value === "number") {
|
|
1315
|
+
if (!Number.isSafeInteger(value) || value < 0) throw new Error("muon embedded config supports only unsigned integers.");
|
|
1316
|
+
return Buffer.concat([Buffer.from([tlvUintTag]), encodeVarUint(BigInt(value))]);
|
|
1317
|
+
}
|
|
1318
|
+
if (typeof value === "string") {
|
|
1319
|
+
const binaryValue = encodeKnownBinaryString(path, value);
|
|
1320
|
+
if (binaryValue !== void 0) return encodeTaggedBytes(tlvBinaryTag, binaryValue);
|
|
1321
|
+
return encodeTaggedBytes(tlvStringTag, Buffer.from(value, "utf8"));
|
|
1322
|
+
}
|
|
1323
|
+
if (Array.isArray(value)) return Buffer.concat([
|
|
1324
|
+
Buffer.from([tlvArrayTag]),
|
|
1325
|
+
encodeVarUint(BigInt(value.length)),
|
|
1326
|
+
...value.map((entry) => encodeTlvValue(entry, path))
|
|
1327
|
+
]);
|
|
1328
|
+
if (isJsonObject$1(value)) {
|
|
1329
|
+
const entries = Object.entries(value);
|
|
1330
|
+
return Buffer.concat([
|
|
1331
|
+
Buffer.from([tlvObjectTag]),
|
|
1332
|
+
encodeVarUint(BigInt(entries.length)),
|
|
1333
|
+
...entries.flatMap(([key, entry]) => [encodeRawString(key), encodeTlvValue(entry, [...path, key])])
|
|
1334
|
+
]);
|
|
1335
|
+
}
|
|
1336
|
+
throw new Error("muon embedded config contains an unsupported value.");
|
|
1337
|
+
};
|
|
1338
|
+
/**
|
|
1339
|
+
* Encodes a parsed muon config object as the embedded TLV payload.
|
|
1340
|
+
*
|
|
1341
|
+
* @param config Parsed muon config value.
|
|
1342
|
+
* @returns Encoded TLV payload bytes.
|
|
1343
|
+
*/
|
|
1344
|
+
var encodeMuonConfigTlv = (config) => encodeTlvValue(config, []);
|
|
1345
|
+
/**
|
|
1346
|
+
* Creates an empty or payload-filled fixed embedded config slot.
|
|
1347
|
+
*
|
|
1348
|
+
* @param payload Optional encoded TLV payload bytes.
|
|
1349
|
+
* @returns Fixed-size slot image.
|
|
1350
|
+
*/
|
|
1351
|
+
var createMuonEmbeddedConfigSlot = (payload = void 0) => {
|
|
1352
|
+
if (payload !== void 0 && payload.length > muonEmbeddedConfigPayloadCapacity) throw new Error(`Encoded muon config exceeds the embedded slot capacity: ${payload.length} > ${muonEmbeddedConfigPayloadCapacity}`);
|
|
1353
|
+
const slot = createEmptySlot();
|
|
1354
|
+
if (payload === void 0) return slot;
|
|
1355
|
+
Buffer.from(payload).copy(slot, 0);
|
|
1356
|
+
return slot;
|
|
1357
|
+
};
|
|
1358
|
+
/**
|
|
1359
|
+
* Creates an empty or payload-filled fixed muon-bootstrap embedded config slot.
|
|
1360
|
+
*
|
|
1361
|
+
* @param payload Optional encoded TLV payload bytes.
|
|
1362
|
+
* @returns Fixed-size slot image.
|
|
1363
|
+
*/
|
|
1364
|
+
var createMuonBootstrapEmbeddedConfigSlot = (payload = void 0) => {
|
|
1365
|
+
if (payload !== void 0 && payload.length > muonBootstrapEmbeddedConfigPayloadCapacity) throw new Error(`Encoded muon config exceeds the embedded bootstrap slot capacity: ${payload.length} > ${muonBootstrapEmbeddedConfigPayloadCapacity}`);
|
|
1366
|
+
const slot = Buffer.alloc(muonBootstrapEmbeddedConfigSlotSize, 0);
|
|
1367
|
+
muonBootstrapEmbeddedConfigEmptySlotMarker.copy(slot, 0);
|
|
1368
|
+
if (payload === void 0) return slot;
|
|
1369
|
+
Buffer.from(payload).copy(slot, 0);
|
|
1370
|
+
return slot;
|
|
1371
|
+
};
|
|
1372
|
+
var isEmptySlotAt = (content, offset) => {
|
|
1373
|
+
for (let index = 0; index < muonEmbeddedConfigSlotSize; index += 1) if (content[offset + index] !== getEmbeddedConfigEmptySlotByte(index)) return false;
|
|
1374
|
+
return true;
|
|
1375
|
+
};
|
|
1376
|
+
var inspectUnembeddedSlotAt = (content, offset) => {
|
|
1377
|
+
if (offset < 0 || offset + 65536 > content.length) return;
|
|
1378
|
+
if (isEmptySlotAt(content, offset)) return {
|
|
1379
|
+
state: "empty",
|
|
1380
|
+
offset,
|
|
1381
|
+
payload: Buffer.alloc(0),
|
|
1382
|
+
payloadSize: 0
|
|
1383
|
+
};
|
|
1384
|
+
};
|
|
1385
|
+
var collectSlotCandidates = (content) => {
|
|
1386
|
+
const candidates = /* @__PURE__ */ new Map();
|
|
1387
|
+
for (let offset = content.indexOf(muonEmbeddedConfigEmptySlotMarker); offset >= 0; offset = content.indexOf(muonEmbeddedConfigEmptySlotMarker, offset + 1)) {
|
|
1388
|
+
const slot = inspectUnembeddedSlotAt(content, offset);
|
|
1389
|
+
if (slot !== void 0) candidates.set(slot.offset, slot);
|
|
1390
|
+
}
|
|
1391
|
+
return [...candidates.values()].sort((left, right) => left.offset - right.offset);
|
|
1392
|
+
};
|
|
1393
|
+
var isEmptyBootstrapSlotAt = (content, offset) => {
|
|
1394
|
+
if (offset < 0 || offset + muonBootstrapEmbeddedConfigSlotSize > content.length) return false;
|
|
1395
|
+
if (!content.subarray(offset, offset + muonBootstrapEmbeddedConfigEmptySlotMarker.length).equals(muonBootstrapEmbeddedConfigEmptySlotMarker)) return false;
|
|
1396
|
+
for (let index = muonBootstrapEmbeddedConfigEmptySlotMarker.length; index < muonBootstrapEmbeddedConfigSlotSize; index += 1) if (content[offset + index] !== 0) return false;
|
|
1397
|
+
return true;
|
|
1398
|
+
};
|
|
1399
|
+
var inspectUnembeddedBootstrapSlotAt = (content, offset) => {
|
|
1400
|
+
if (!isEmptyBootstrapSlotAt(content, offset)) return;
|
|
1401
|
+
return {
|
|
1402
|
+
state: "empty",
|
|
1403
|
+
offset,
|
|
1404
|
+
payload: Buffer.alloc(0),
|
|
1405
|
+
payloadSize: 0
|
|
1406
|
+
};
|
|
1407
|
+
};
|
|
1408
|
+
var collectBootstrapSlotCandidates = (content) => {
|
|
1409
|
+
const candidates = /* @__PURE__ */ new Map();
|
|
1410
|
+
for (let offset = content.indexOf(muonBootstrapEmbeddedConfigEmptySlotMarker); offset >= 0; offset = content.indexOf(muonBootstrapEmbeddedConfigEmptySlotMarker, offset + 1)) {
|
|
1411
|
+
const slot = inspectUnembeddedBootstrapSlotAt(content, offset);
|
|
1412
|
+
if (slot !== void 0) candidates.set(slot.offset, slot);
|
|
1413
|
+
}
|
|
1414
|
+
return [...candidates.values()].sort((left, right) => left.offset - right.offset);
|
|
1415
|
+
};
|
|
1416
|
+
/**
|
|
1417
|
+
* Finds the fixed unembedded config slot in a muon-core executable image.
|
|
1418
|
+
*
|
|
1419
|
+
* @param content muon-core executable bytes.
|
|
1420
|
+
* @returns The single detected unembedded config slot.
|
|
1421
|
+
*/
|
|
1422
|
+
var findMuonEmbeddedConfigSlot = (content) => {
|
|
1423
|
+
const candidates = collectSlotCandidates(Buffer.isBuffer(content) ? content : Buffer.from(content));
|
|
1424
|
+
if (candidates.length !== 1) throw new Error(`Expected exactly one unembedded muon config slot, found ${candidates.length}.`);
|
|
1425
|
+
const [candidate] = candidates;
|
|
1426
|
+
if (candidate === void 0) throw new Error("Embedded muon config slot was not found.");
|
|
1427
|
+
return candidate;
|
|
1428
|
+
};
|
|
1429
|
+
/**
|
|
1430
|
+
* Finds the fixed unembedded config slot in a muon-bootstrap executable image.
|
|
1431
|
+
*
|
|
1432
|
+
* @param content muon-bootstrap executable bytes.
|
|
1433
|
+
* @returns The single detected unembedded bootstrap config slot.
|
|
1434
|
+
*/
|
|
1435
|
+
var findMuonBootstrapEmbeddedConfigSlot = (content) => {
|
|
1436
|
+
const candidates = collectBootstrapSlotCandidates(Buffer.isBuffer(content) ? content : Buffer.from(content));
|
|
1437
|
+
if (candidates.length !== 1) throw new Error(`Expected exactly one unembedded muon-bootstrap config slot, found ${candidates.length}.`);
|
|
1438
|
+
const [candidate] = candidates;
|
|
1439
|
+
if (candidate === void 0) throw new Error("Embedded muon-bootstrap config slot was not found.");
|
|
1440
|
+
return candidate;
|
|
1441
|
+
};
|
|
1442
|
+
var fileExists$1 = async (path) => {
|
|
1443
|
+
try {
|
|
1444
|
+
return (await stat(path)).isFile();
|
|
1445
|
+
} catch {
|
|
1446
|
+
return false;
|
|
1447
|
+
}
|
|
1448
|
+
};
|
|
1449
|
+
var resolveMuonConfigInputPath = async (configPath) => {
|
|
1450
|
+
if (basename(configPath) === "muon.json") {
|
|
1451
|
+
const directory = dirname(configPath);
|
|
1452
|
+
for (const fileName of [
|
|
1453
|
+
"muon.json5",
|
|
1454
|
+
"muon.jsonc",
|
|
1455
|
+
"muon.json"
|
|
1456
|
+
]) {
|
|
1457
|
+
const candidate = join(directory, fileName);
|
|
1458
|
+
if (await fileExists$1(candidate)) return candidate;
|
|
1459
|
+
}
|
|
1460
|
+
}
|
|
1461
|
+
if (!await fileExists$1(configPath)) throw new Error(`muon config does not exist: ${configPath}`);
|
|
1462
|
+
return configPath;
|
|
1463
|
+
};
|
|
1464
|
+
var readMuonConfigInput = async (configPath) => {
|
|
1465
|
+
return (0, import_dist.parse)(await readFile(await resolveMuonConfigInputPath(configPath), "utf8"));
|
|
1466
|
+
};
|
|
1467
|
+
var isSignedPeExecutable = (content) => {
|
|
1468
|
+
if (content.length < 64 || content[0] !== 77 || content[1] !== 90) return false;
|
|
1469
|
+
const peOffset = content.readUInt32LE(60);
|
|
1470
|
+
if (peOffset + 24 >= content.length || content.toString("ascii", peOffset, peOffset + 4) !== "PE\0\0") return false;
|
|
1471
|
+
const optionalHeaderOffset = peOffset + 24;
|
|
1472
|
+
const optionalHeaderEnd = optionalHeaderOffset + content.readUInt16LE(peOffset + 20);
|
|
1473
|
+
if (optionalHeaderEnd > content.length) return false;
|
|
1474
|
+
const certificateEntryOffset = (content.readUInt16LE(optionalHeaderOffset) === 523 ? optionalHeaderOffset + 112 : optionalHeaderOffset + 96) + 32;
|
|
1475
|
+
if (certificateEntryOffset + 8 > optionalHeaderEnd) return false;
|
|
1476
|
+
return content.readUInt32LE(certificateEntryOffset + 4) !== 0;
|
|
1477
|
+
};
|
|
1478
|
+
/**
|
|
1479
|
+
* Embeds a muon config into a single muon-core executable.
|
|
1480
|
+
*
|
|
1481
|
+
* @param options Core executable embedding options.
|
|
1482
|
+
* @returns Embedding result metadata.
|
|
1483
|
+
*/
|
|
1484
|
+
var embedMuonConfigInCoreFile = async ({ corePath, configPath, outputPath }) => {
|
|
1485
|
+
const payload = encodeMuonConfigTlv(await readMuonConfigInput(configPath));
|
|
1486
|
+
const embeddedSlot = createMuonEmbeddedConfigSlot(payload);
|
|
1487
|
+
const coreContent = await readFile(corePath);
|
|
1488
|
+
if (isSignedPeExecutable(coreContent)) throw new Error("Cannot embed muon config into a signed PE executable.");
|
|
1489
|
+
const slot = findMuonEmbeddedConfigSlot(coreContent);
|
|
1490
|
+
const patchedContent = Buffer.from(coreContent);
|
|
1491
|
+
embeddedSlot.copy(patchedContent, slot.offset);
|
|
1492
|
+
const resolvedOutputPath = outputPath ?? corePath;
|
|
1493
|
+
await writeFile(resolvedOutputPath, patchedContent);
|
|
1494
|
+
return {
|
|
1495
|
+
corePath,
|
|
1496
|
+
outputPath: resolvedOutputPath,
|
|
1497
|
+
slotOffset: slot.offset,
|
|
1498
|
+
payloadSize: payload.length,
|
|
1499
|
+
replaced: false
|
|
1500
|
+
};
|
|
1501
|
+
};
|
|
1502
|
+
/**
|
|
1503
|
+
* Embeds a muon config into a single muon-bootstrap executable.
|
|
1504
|
+
*
|
|
1505
|
+
* @param options Bootstrap executable embedding options.
|
|
1506
|
+
* @returns Embedding result metadata.
|
|
1507
|
+
*/
|
|
1508
|
+
var embedMuonConfigInBootstrapFile = async ({ bootstrapPath, configPath, outputPath }) => {
|
|
1509
|
+
const payload = encodeMuonConfigTlv(await readMuonConfigInput(configPath));
|
|
1510
|
+
const embeddedSlot = createMuonBootstrapEmbeddedConfigSlot(payload);
|
|
1511
|
+
const bootstrapContent = await readFile(bootstrapPath);
|
|
1512
|
+
if (isSignedPeExecutable(bootstrapContent)) throw new Error("Cannot embed muon config into a signed muon-bootstrap PE executable.");
|
|
1513
|
+
const slot = findMuonBootstrapEmbeddedConfigSlot(bootstrapContent);
|
|
1514
|
+
const patchedContent = Buffer.from(bootstrapContent);
|
|
1515
|
+
embeddedSlot.copy(patchedContent, slot.offset);
|
|
1516
|
+
const resolvedOutputPath = outputPath ?? bootstrapPath;
|
|
1517
|
+
await writeFile(resolvedOutputPath, patchedContent);
|
|
1518
|
+
return {
|
|
1519
|
+
corePath: bootstrapPath,
|
|
1520
|
+
outputPath: resolvedOutputPath,
|
|
1521
|
+
slotOffset: slot.offset,
|
|
1522
|
+
payloadSize: payload.length,
|
|
1523
|
+
replaced: false
|
|
1524
|
+
};
|
|
1525
|
+
};
|
|
1526
|
+
var resolveRuntimeCorePath = async (runtimePath) => {
|
|
1527
|
+
const candidates = [join(runtimePath, "muon-core"), join(runtimePath, "muon-core.exe")];
|
|
1528
|
+
const existing = [];
|
|
1529
|
+
for (const candidate of candidates) try {
|
|
1530
|
+
await access(candidate);
|
|
1531
|
+
existing.push(candidate);
|
|
1532
|
+
} catch {}
|
|
1533
|
+
if (existing.length !== 1) throw new Error(`Expected exactly one muon-core executable in runtime path, found ${existing.length}.`);
|
|
1534
|
+
const [corePath] = existing;
|
|
1535
|
+
if (corePath === void 0) throw new Error("muon-core executable was not found.");
|
|
1536
|
+
return corePath;
|
|
1537
|
+
};
|
|
1538
|
+
/**
|
|
1539
|
+
* Embeds a muon config into a runtime directory containing muon-core.
|
|
1540
|
+
*
|
|
1541
|
+
* @param options Runtime directory embedding options.
|
|
1542
|
+
* @returns Embedding result metadata.
|
|
1543
|
+
*/
|
|
1544
|
+
var embedMuonConfigInRuntime = async ({ runtimePath, configPath, outputRuntimePath }) => {
|
|
1545
|
+
const targetRuntimePath = outputRuntimePath ?? runtimePath;
|
|
1546
|
+
if (outputRuntimePath !== void 0) await cp(runtimePath, outputRuntimePath, {
|
|
1547
|
+
recursive: true,
|
|
1548
|
+
force: true
|
|
1549
|
+
});
|
|
1550
|
+
return embedMuonConfigInCoreFile({
|
|
1551
|
+
corePath: await resolveRuntimeCorePath(targetRuntimePath),
|
|
1552
|
+
configPath,
|
|
1553
|
+
outputPath: void 0
|
|
1554
|
+
});
|
|
1555
|
+
};
|
|
1556
|
+
//#endregion
|
|
1557
|
+
//#region src/prepare.ts
|
|
1558
|
+
/**
|
|
1559
|
+
* Returns the default Muon prepare target for a Node platform and architecture.
|
|
1560
|
+
*
|
|
1561
|
+
* @param platform Node platform.
|
|
1562
|
+
* @param architecture Node architecture.
|
|
1563
|
+
* @returns Muon prepare target name.
|
|
1564
|
+
*/
|
|
1565
|
+
var getDefaultMuonPrepareTarget = (platform, architecture) => {
|
|
1566
|
+
if (platform === "win32") {
|
|
1567
|
+
if (architecture === "ia32") return "windows32";
|
|
1568
|
+
if (architecture === "x64") return "windows64";
|
|
1569
|
+
}
|
|
1570
|
+
if (platform === "linux") {
|
|
1571
|
+
if (architecture === "x64") return "linux64";
|
|
1572
|
+
if (architecture === "arm") return "linuxarm";
|
|
1573
|
+
if (architecture === "arm64") return "linuxarm64";
|
|
1574
|
+
}
|
|
1575
|
+
throw new Error(`Unsupported Muon prepare target: platform=${platform}, arch=${architecture}`);
|
|
1576
|
+
};
|
|
1577
|
+
var getPrepareExecutableName = (platform) => platform === "win32" ? "muon-prepare.exe" : "muon-prepare";
|
|
1578
|
+
var moduleDirectory$2 = typeof __dirname === "string" ? __dirname : dirname(fileURLToPath(import.meta.url));
|
|
1579
|
+
var canExecute = async (path) => {
|
|
1580
|
+
try {
|
|
1581
|
+
await access(path, constants.X_OK);
|
|
1582
|
+
return true;
|
|
1583
|
+
} catch {
|
|
1584
|
+
return false;
|
|
1585
|
+
}
|
|
1586
|
+
};
|
|
1587
|
+
var resolveMuonPrepareExecutable = async (options) => {
|
|
1588
|
+
const explicit = options.prepareExecutablePath ?? options.environment.MUON_PREPARE_PATH;
|
|
1589
|
+
if (explicit !== void 0 && explicit !== "") return explicit;
|
|
1590
|
+
const executableName = getPrepareExecutableName(process.platform);
|
|
1591
|
+
const target = getDefaultMuonPrepareTarget(process.platform, process.arch);
|
|
1592
|
+
const candidates = [join(moduleDirectory$2, "native", target, executableName), join(moduleDirectory$2, "..", "dist", "native", target, executableName)];
|
|
1593
|
+
for (const candidate of candidates) if (await canExecute(candidate)) return candidate;
|
|
1594
|
+
return candidates[0] ?? executableName;
|
|
1595
|
+
};
|
|
1596
|
+
var createMuonPrepareArguments = (options) => {
|
|
1597
|
+
const args = [
|
|
1598
|
+
"runtime",
|
|
1599
|
+
"--muon-path",
|
|
1600
|
+
options.muonPath,
|
|
1601
|
+
"--json"
|
|
1602
|
+
];
|
|
1603
|
+
if (options.cefPath !== void 0) args.push("--cef-path", options.cefPath);
|
|
1604
|
+
if (options.stageDir !== void 0) args.push("--stage-dir", options.stageDir);
|
|
1605
|
+
if (options.target !== void 0) args.push("--target", options.target);
|
|
1606
|
+
if (options.cacheDir !== void 0) args.push("--cache-dir", options.cacheDir);
|
|
1607
|
+
if (options.force) args.push("--force");
|
|
1608
|
+
if (options.quiet) args.push("--quiet");
|
|
1609
|
+
return args;
|
|
1610
|
+
};
|
|
1611
|
+
/**
|
|
1612
|
+
* Invokes the native muon-prepare executable and returns the prepared runtime.
|
|
1613
|
+
*
|
|
1614
|
+
* @param options Native prepare invocation options.
|
|
1615
|
+
* @returns Prepared runtime location.
|
|
1616
|
+
*/
|
|
1617
|
+
var runMuonPrepare = async (options) => {
|
|
1618
|
+
const child = spawn(await resolveMuonPrepareExecutable(options), createMuonPrepareArguments(options), {
|
|
1619
|
+
cwd: options.cwd,
|
|
1620
|
+
env: options.environment,
|
|
1621
|
+
stdio: [
|
|
1622
|
+
"ignore",
|
|
1623
|
+
"pipe",
|
|
1624
|
+
"pipe"
|
|
1625
|
+
]
|
|
1626
|
+
});
|
|
1627
|
+
let stdout = "";
|
|
1628
|
+
let stderr = "";
|
|
1629
|
+
child.stdout.setEncoding("utf8");
|
|
1630
|
+
child.stderr.setEncoding("utf8");
|
|
1631
|
+
child.stdout.on("data", (chunk) => {
|
|
1632
|
+
stdout += chunk;
|
|
1633
|
+
});
|
|
1634
|
+
child.stderr.on("data", (chunk) => {
|
|
1635
|
+
stderr += chunk;
|
|
1636
|
+
if (!options.quiet) process.stderr.write(chunk);
|
|
1637
|
+
});
|
|
1638
|
+
const exitCode = await new Promise((resolvePromise, reject) => {
|
|
1639
|
+
child.on("error", reject);
|
|
1640
|
+
child.on("close", (code) => {
|
|
1641
|
+
resolvePromise(code ?? 1);
|
|
1642
|
+
});
|
|
1643
|
+
});
|
|
1644
|
+
if (exitCode !== 0) throw new Error(`muon-prepare failed with exit code ${exitCode}.\n${stderr.trim()}`);
|
|
1645
|
+
const result = JSON.parse(stdout);
|
|
1646
|
+
if (result.stagePath !== void 0 && typeof result.stagePath !== "string" || typeof result.muonPath !== "string" || typeof result.cefPath !== "string" || typeof result.cacheHit !== "boolean") throw new Error(`muon-prepare returned invalid JSON: ${stdout}`);
|
|
1647
|
+
return {
|
|
1648
|
+
...result.stagePath === void 0 ? {} : { stagePath: result.stagePath },
|
|
1649
|
+
muonPath: result.muonPath,
|
|
1650
|
+
cefPath: result.cefPath,
|
|
1651
|
+
cacheHit: result.cacheHit
|
|
1652
|
+
};
|
|
1653
|
+
};
|
|
1654
|
+
//#endregion
|
|
1655
|
+
//#region src/build.ts
|
|
1656
|
+
var AdmZip = __resolveDefaultExport(__screwUpDefaultImportModule0, false);
|
|
1657
|
+
globalThis.__screwUpIsInCJS_f9d0012cc677 = false;
|
|
1658
|
+
function __resolveDefaultExport(module, isESM) {
|
|
1659
|
+
const __isInCJS = typeof globalThis !== "undefined" && globalThis.__screwUpIsInCJS_f9d0012cc677 === true;
|
|
1660
|
+
const maybe = module;
|
|
1661
|
+
const hasDefault = !!(maybe && typeof maybe === "object" && "default" in maybe);
|
|
1662
|
+
const unwrapNamespaceDefault = (value) => {
|
|
1663
|
+
if (!value || typeof value !== "object") return value;
|
|
1664
|
+
const inner = value;
|
|
1665
|
+
if ((inner.__esModule === true || typeof Symbol !== "undefined" && inner[Symbol.toStringTag] === "Module") && "default" in inner) return inner.default;
|
|
1666
|
+
return value;
|
|
1667
|
+
};
|
|
1668
|
+
const resolvedDefault = hasDefault ? unwrapNamespaceDefault(maybe.default) : void 0;
|
|
1669
|
+
if (__isInCJS) return hasDefault ? resolvedDefault ?? module : module;
|
|
1670
|
+
if (isESM) {
|
|
1671
|
+
if (hasDefault) return resolvedDefault;
|
|
1672
|
+
throw new Error("Default export not found.");
|
|
1673
|
+
}
|
|
1674
|
+
return hasDefault ? resolvedDefault ?? module : module;
|
|
1675
|
+
}
|
|
1676
|
+
var allTargets = [
|
|
1677
|
+
"linux64",
|
|
1678
|
+
"linuxarm",
|
|
1679
|
+
"linuxarm64",
|
|
1680
|
+
"windows32",
|
|
1681
|
+
"windows64"
|
|
1682
|
+
];
|
|
1683
|
+
var targetAliases = {
|
|
1684
|
+
linux64: "linux64",
|
|
1685
|
+
"linux-amd64": "linux64",
|
|
1686
|
+
"linux-x64": "linux64",
|
|
1687
|
+
amd64: "linux64",
|
|
1688
|
+
x64: "linux64",
|
|
1689
|
+
linuxarm: "linuxarm",
|
|
1690
|
+
"linux-arm": "linuxarm",
|
|
1691
|
+
"linux-armv7l": "linuxarm",
|
|
1692
|
+
arm: "linuxarm",
|
|
1693
|
+
armv7l: "linuxarm",
|
|
1694
|
+
linuxarm64: "linuxarm64",
|
|
1695
|
+
"linux-arm64": "linuxarm64",
|
|
1696
|
+
"linux-aarch64": "linuxarm64",
|
|
1697
|
+
arm64: "linuxarm64",
|
|
1698
|
+
aarch64: "linuxarm64",
|
|
1699
|
+
windows32: "windows32",
|
|
1700
|
+
"windows-i686": "windows32",
|
|
1701
|
+
"windows-ia32": "windows32",
|
|
1702
|
+
win32: "windows32",
|
|
1703
|
+
i686: "windows32",
|
|
1704
|
+
ia32: "windows32",
|
|
1705
|
+
windows64: "windows64",
|
|
1706
|
+
"windows-amd64": "windows64",
|
|
1707
|
+
"windows-x64": "windows64",
|
|
1708
|
+
win64: "windows64"
|
|
1709
|
+
};
|
|
1710
|
+
var targetDescriptors = {
|
|
1711
|
+
linux64: {
|
|
1712
|
+
distributionDirectoryName: "dist-linux-amd64",
|
|
1713
|
+
runtimeExecutableName: "muon-core",
|
|
1714
|
+
bootstrapExecutableName: "muon-bootstrap",
|
|
1715
|
+
launcherExtension: "",
|
|
1716
|
+
runtimeFiles: [
|
|
1717
|
+
"muon-core",
|
|
1718
|
+
"libmuon-ui.so",
|
|
1719
|
+
"libcardio.so"
|
|
1720
|
+
]
|
|
1721
|
+
},
|
|
1722
|
+
linuxarm: {
|
|
1723
|
+
distributionDirectoryName: "dist-linux-armv7l",
|
|
1724
|
+
runtimeExecutableName: "muon-core",
|
|
1725
|
+
bootstrapExecutableName: "muon-bootstrap",
|
|
1726
|
+
launcherExtension: "",
|
|
1727
|
+
runtimeFiles: [
|
|
1728
|
+
"muon-core",
|
|
1729
|
+
"libmuon-ui.so",
|
|
1730
|
+
"libcardio.so"
|
|
1731
|
+
]
|
|
1732
|
+
},
|
|
1733
|
+
linuxarm64: {
|
|
1734
|
+
distributionDirectoryName: "dist-linux-arm64",
|
|
1735
|
+
runtimeExecutableName: "muon-core",
|
|
1736
|
+
bootstrapExecutableName: "muon-bootstrap",
|
|
1737
|
+
launcherExtension: "",
|
|
1738
|
+
runtimeFiles: [
|
|
1739
|
+
"muon-core",
|
|
1740
|
+
"libmuon-ui.so",
|
|
1741
|
+
"libcardio.so"
|
|
1742
|
+
]
|
|
1743
|
+
},
|
|
1744
|
+
windows32: {
|
|
1745
|
+
distributionDirectoryName: "dist-windows-i686",
|
|
1746
|
+
runtimeExecutableName: "muon-core.exe",
|
|
1747
|
+
bootstrapExecutableName: "muon-bootstrap.exe",
|
|
1748
|
+
launcherExtension: ".exe",
|
|
1749
|
+
runtimeFiles: [
|
|
1750
|
+
"muon-core.exe",
|
|
1751
|
+
"libmuon-ui.dll",
|
|
1752
|
+
"libcardio.dll"
|
|
1753
|
+
]
|
|
1754
|
+
},
|
|
1755
|
+
windows64: {
|
|
1756
|
+
distributionDirectoryName: "dist-windows-amd64",
|
|
1757
|
+
runtimeExecutableName: "muon-core.exe",
|
|
1758
|
+
bootstrapExecutableName: "muon-bootstrap.exe",
|
|
1759
|
+
launcherExtension: ".exe",
|
|
1760
|
+
runtimeFiles: [
|
|
1761
|
+
"muon-core.exe",
|
|
1762
|
+
"libmuon-ui.dll",
|
|
1763
|
+
"libcardio.dll"
|
|
1764
|
+
]
|
|
1765
|
+
}
|
|
1766
|
+
};
|
|
1767
|
+
var defaultConfigFileNames = [
|
|
1768
|
+
"muon.json5",
|
|
1769
|
+
"muon.jsonc",
|
|
1770
|
+
"muon.json"
|
|
1771
|
+
];
|
|
1772
|
+
var appConfigFromPath = "./assets.zip";
|
|
1773
|
+
var defaultAppName = "muon-app";
|
|
1774
|
+
var directoryMode = 493;
|
|
1775
|
+
var executableMode = 493;
|
|
1776
|
+
var assetSaltByteLength = 16;
|
|
1777
|
+
var moduleDirectory$1 = typeof __dirname === "string" ? __dirname : dirname(fileURLToPath(import.meta.url));
|
|
1778
|
+
/**
|
|
1779
|
+
* Returns the host target used by muon build when no explicit target is passed.
|
|
1780
|
+
*/
|
|
1781
|
+
var getDefaultMuonBuildTarget = () => {
|
|
1782
|
+
return normalizeMuonBuildTarget(getDefaultMuonPrepareTarget(process.platform, process.arch));
|
|
1783
|
+
};
|
|
1784
|
+
/**
|
|
1785
|
+
* Normalizes a user-facing target alias into the npm package target name.
|
|
1786
|
+
*/
|
|
1787
|
+
var normalizeMuonBuildTarget = (target) => {
|
|
1788
|
+
const normalized = target.trim().toLowerCase();
|
|
1789
|
+
if (normalized === "linux-i686" || normalized === "linux-ia32") throw new Error("Linux i686 is not supported by muon build.");
|
|
1790
|
+
const resolvedTarget = targetAliases[normalized];
|
|
1791
|
+
if (resolvedTarget === void 0) throw new Error(`Unsupported muon build target: ${target}`);
|
|
1792
|
+
return resolvedTarget;
|
|
1793
|
+
};
|
|
1794
|
+
/**
|
|
1795
|
+
* Builds CEF-free Muon app distribution directories for one or more targets.
|
|
1796
|
+
*/
|
|
1797
|
+
var buildMuonApp = async (options = {}) => {
|
|
1798
|
+
const root = resolve(options.root ?? process.cwd());
|
|
1799
|
+
const packageDirectory = resolvePackageDirectory(options.packageDirectory);
|
|
1800
|
+
const targets = resolveBuildTargets(options);
|
|
1801
|
+
const outputRoot = resolve(root, options.outputRoot ?? ".");
|
|
1802
|
+
const appName = await resolveAppName(root, options.appName);
|
|
1803
|
+
const assetInput = resolveAssetInput(root, options.assetSourcePath, options.assetPrefix);
|
|
1804
|
+
const sourceConfig = await readBuildConfig(root, options.configPath);
|
|
1805
|
+
const salt = Buffer.from(options.assetSalt ?? randomBytes(assetSaltByteLength));
|
|
1806
|
+
const results = [];
|
|
1807
|
+
for (const target of targets) {
|
|
1808
|
+
const result = await buildMuonTarget({
|
|
1809
|
+
packageDirectory,
|
|
1810
|
+
outputRoot,
|
|
1811
|
+
appName,
|
|
1812
|
+
target,
|
|
1813
|
+
assetInput,
|
|
1814
|
+
sourceConfig,
|
|
1815
|
+
salt
|
|
1816
|
+
});
|
|
1817
|
+
results.push(result);
|
|
1818
|
+
}
|
|
1819
|
+
return {
|
|
1820
|
+
root,
|
|
1821
|
+
appName,
|
|
1822
|
+
targets: results
|
|
1823
|
+
};
|
|
1824
|
+
};
|
|
1825
|
+
var resolvePackageDirectory = (packageDirectory) => {
|
|
1826
|
+
if (packageDirectory !== void 0) return resolve(packageDirectory);
|
|
1827
|
+
return moduleDirectory$1;
|
|
1828
|
+
};
|
|
1829
|
+
var resolveBuildTargets = (options) => {
|
|
1830
|
+
if (options.allTargets === true) return [...allTargets];
|
|
1831
|
+
if (options.targets !== void 0 && options.targets.length > 0) return [...new Set(options.targets.map((target) => normalizeMuonBuildTarget(target)))];
|
|
1832
|
+
return [getDefaultMuonBuildTarget()];
|
|
1833
|
+
};
|
|
1834
|
+
var resolveAssetInput = (root, assetSourcePath, assetPrefix) => {
|
|
1835
|
+
return {
|
|
1836
|
+
sourcePath: resolve(root, assetSourcePath ?? "assets"),
|
|
1837
|
+
prefix: normalizeZipPrefix(assetPrefix ?? "")
|
|
1838
|
+
};
|
|
1839
|
+
};
|
|
1840
|
+
var normalizeZipPrefix = (prefix) => {
|
|
1841
|
+
const normalized = prefix.replaceAll("\\", "/").split("/").filter((part) => part.length > 0).join("/");
|
|
1842
|
+
return normalized.length > 0 ? `${normalized}/` : "";
|
|
1843
|
+
};
|
|
1844
|
+
var resolveAppName = async (root, appName) => {
|
|
1845
|
+
if (appName !== void 0) return sanitizeAppName(appName);
|
|
1846
|
+
const packageJson = await readJsonObjectFile(join(root, "package.json"));
|
|
1847
|
+
const packageName = typeof packageJson.name === "string" ? packageJson.name : defaultAppName;
|
|
1848
|
+
return sanitizeAppName(packageName.startsWith("@") ? packageName.slice(packageName.indexOf("/") + 1) : packageName);
|
|
1849
|
+
};
|
|
1850
|
+
var sanitizeAppName = (name) => {
|
|
1851
|
+
const sanitized = name.trim().toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/^[.-]+/g, "").replace(/[.-]+$/g, "");
|
|
1852
|
+
return sanitized.length > 0 ? sanitized : defaultAppName;
|
|
1853
|
+
};
|
|
1854
|
+
var readBuildConfig = async (root, configPath) => {
|
|
1855
|
+
const resolvedConfigPath = await resolveConfigPath(root, configPath);
|
|
1856
|
+
if (resolvedConfigPath === void 0) return {};
|
|
1857
|
+
return readJsonObjectFile(resolvedConfigPath);
|
|
1858
|
+
};
|
|
1859
|
+
var resolveConfigPath = async (root, configPath) => {
|
|
1860
|
+
if (configPath !== void 0) {
|
|
1861
|
+
const resolvedPath = resolve(root, configPath);
|
|
1862
|
+
if (await fileExists(resolvedPath)) return resolvedPath;
|
|
1863
|
+
throw new Error(`Muon config file does not exist: ${resolvedPath}`);
|
|
1864
|
+
}
|
|
1865
|
+
for (const fileName of defaultConfigFileNames) {
|
|
1866
|
+
const candidatePath = join(root, fileName);
|
|
1867
|
+
if (await fileExists(candidatePath)) return candidatePath;
|
|
1868
|
+
}
|
|
1869
|
+
};
|
|
1870
|
+
var readJsonObjectFile = async (filePath) => {
|
|
1871
|
+
const parsed = (0, import_dist.parse)(await readFile(filePath, "utf8"));
|
|
1872
|
+
if (!isJsonObject(parsed)) throw new Error(`Expected JSON object in ${filePath}`);
|
|
1873
|
+
return parsed;
|
|
1874
|
+
};
|
|
1875
|
+
var buildMuonTarget = async (input) => {
|
|
1876
|
+
const descriptor = targetDescriptors[input.target];
|
|
1877
|
+
const sourceRuntimePath = join(input.packageDirectory, "runtime", input.target);
|
|
1878
|
+
const sourceBootstrapPath = join(input.packageDirectory, "native", input.target, descriptor.bootstrapExecutableName);
|
|
1879
|
+
const outputPath = join(input.outputRoot, descriptor.distributionDirectoryName);
|
|
1880
|
+
const launcherPath = join(outputPath, getLauncherFileName(input.appName, descriptor));
|
|
1881
|
+
const assetZipPath = join(outputPath, "assets.zip");
|
|
1882
|
+
await verifyTargetInputs({
|
|
1883
|
+
sourceRuntimePath,
|
|
1884
|
+
sourceBootstrapPath,
|
|
1885
|
+
descriptor,
|
|
1886
|
+
target: input.target
|
|
1887
|
+
});
|
|
1888
|
+
await rm(outputPath, {
|
|
1889
|
+
recursive: true,
|
|
1890
|
+
force: true
|
|
1891
|
+
});
|
|
1892
|
+
await mkdir(outputPath, {
|
|
1893
|
+
recursive: true,
|
|
1894
|
+
mode: directoryMode
|
|
1895
|
+
});
|
|
1896
|
+
await copyRuntimeFiles(sourceRuntimePath, outputPath, descriptor);
|
|
1897
|
+
await chmod(join(outputPath, descriptor.runtimeExecutableName), executableMode);
|
|
1898
|
+
await copyFile(sourceBootstrapPath, launcherPath);
|
|
1899
|
+
await chmod(launcherPath, executableMode);
|
|
1900
|
+
const asset = await writeAssetArchive(input.assetInput, assetZipPath, input.salt);
|
|
1901
|
+
const embeddedConfig = createEmbeddedConfig(input.sourceConfig, asset);
|
|
1902
|
+
await withTemporaryConfig(embeddedConfig, async (configPath) => {
|
|
1903
|
+
await embedMuonConfigInRuntime({
|
|
1904
|
+
runtimePath: outputPath,
|
|
1905
|
+
configPath,
|
|
1906
|
+
outputRuntimePath: void 0
|
|
1907
|
+
});
|
|
1908
|
+
await embedMuonConfigInBootstrapFile({
|
|
1909
|
+
bootstrapPath: launcherPath,
|
|
1910
|
+
configPath,
|
|
1911
|
+
outputPath: void 0
|
|
1912
|
+
});
|
|
1913
|
+
});
|
|
1914
|
+
return {
|
|
1915
|
+
target: input.target,
|
|
1916
|
+
distributionDirectoryName: descriptor.distributionDirectoryName,
|
|
1917
|
+
outputPath,
|
|
1918
|
+
launcherPath,
|
|
1919
|
+
asset,
|
|
1920
|
+
embeddedConfig
|
|
1921
|
+
};
|
|
1922
|
+
};
|
|
1923
|
+
var verifyTargetInputs = async (input) => {
|
|
1924
|
+
await assertDirectory(input.sourceRuntimePath, `Muon runtime for ${input.target}`);
|
|
1925
|
+
await assertFile(input.sourceBootstrapPath, `Muon bootstrap for ${input.target}`);
|
|
1926
|
+
for (const fileName of input.descriptor.runtimeFiles) await assertFile(join(input.sourceRuntimePath, fileName), `Muon runtime file ${fileName} for ${input.target}`);
|
|
1927
|
+
await assertFile(join(input.sourceRuntimePath, "THIRD_PARTY_NOTICES.md"), `Muon third-party notices for ${input.target}`);
|
|
1928
|
+
};
|
|
1929
|
+
var getLauncherFileName = (appName, descriptor) => {
|
|
1930
|
+
if (descriptor.launcherExtension.length > 0 && !appName.endsWith(descriptor.launcherExtension)) return `${appName}${descriptor.launcherExtension}`;
|
|
1931
|
+
return appName;
|
|
1932
|
+
};
|
|
1933
|
+
var copyRuntimeFiles = async (sourceRuntimePath, outputPath, descriptor) => {
|
|
1934
|
+
for (const fileName of descriptor.runtimeFiles) await copyFile(join(sourceRuntimePath, fileName), join(outputPath, fileName));
|
|
1935
|
+
await copyFile(join(sourceRuntimePath, "THIRD_PARTY_NOTICES.md"), join(outputPath, "THIRD_PARTY_NOTICES.md"));
|
|
1936
|
+
};
|
|
1937
|
+
var writeAssetArchive = async (input, outputPath, salt) => {
|
|
1938
|
+
await assertDirectory(input.sourcePath, "Muon asset source");
|
|
1939
|
+
const entries = await collectZipEntries(input.sourcePath, input.prefix);
|
|
1940
|
+
if (entries.length === 0) throw new Error(`Muon asset source has no files: ${input.sourcePath}`);
|
|
1941
|
+
const archive = createZipArchive(entries);
|
|
1942
|
+
await writeFile(outputPath, archive);
|
|
1943
|
+
return {
|
|
1944
|
+
path: outputPath,
|
|
1945
|
+
signature: createHash("sha1").update(archive).update(salt).digest("hex"),
|
|
1946
|
+
salt: salt.toString("hex"),
|
|
1947
|
+
entryCount: entries.length
|
|
1948
|
+
};
|
|
1949
|
+
};
|
|
1950
|
+
var collectZipEntries = async (sourcePath, prefix) => {
|
|
1951
|
+
const entries = [];
|
|
1952
|
+
const walk = async (directoryPath) => {
|
|
1953
|
+
const dirents = await readdir(directoryPath, { withFileTypes: true });
|
|
1954
|
+
dirents.sort((a, b) => a.name.localeCompare(b.name));
|
|
1955
|
+
for (const dirent of dirents) {
|
|
1956
|
+
const childPath = join(directoryPath, dirent.name);
|
|
1957
|
+
if (dirent.isDirectory()) await walk(childPath);
|
|
1958
|
+
else if (dirent.isFile()) {
|
|
1959
|
+
const name = `${prefix}${relative(sourcePath, childPath).split(sep).join("/")}`;
|
|
1960
|
+
assertSafeZipEntryName(name);
|
|
1961
|
+
entries.push({
|
|
1962
|
+
name,
|
|
1963
|
+
data: await readFile(childPath)
|
|
1964
|
+
});
|
|
1965
|
+
}
|
|
1966
|
+
}
|
|
1967
|
+
};
|
|
1968
|
+
await walk(sourcePath);
|
|
1969
|
+
return entries;
|
|
1970
|
+
};
|
|
1971
|
+
var assertSafeZipEntryName = (name) => {
|
|
1972
|
+
if (name.length === 0 || name.startsWith("/") || name.includes("..") || name.includes("\\")) throw new Error(`Unsafe ZIP entry name: ${name}`);
|
|
1973
|
+
};
|
|
1974
|
+
var createZipArchive = (entries) => {
|
|
1975
|
+
const zip = new AdmZip();
|
|
1976
|
+
for (const entry of entries) zip.addFile(entry.name, entry.data);
|
|
1977
|
+
return zip.toBuffer();
|
|
1978
|
+
};
|
|
1979
|
+
var createEmbeddedConfig = (sourceConfig, asset) => {
|
|
1980
|
+
const sourceAsset = sourceConfig.asset;
|
|
1981
|
+
if (sourceAsset !== void 0 && !isJsonObject(sourceAsset)) throw new Error("muon.json asset must be an object when present.");
|
|
1982
|
+
return {
|
|
1983
|
+
...sourceConfig,
|
|
1984
|
+
asset: {
|
|
1985
|
+
...sourceAsset ?? {},
|
|
1986
|
+
from: appConfigFromPath,
|
|
1987
|
+
signature: asset.signature,
|
|
1988
|
+
salt: asset.salt
|
|
1989
|
+
}
|
|
1990
|
+
};
|
|
1991
|
+
};
|
|
1992
|
+
var withTemporaryConfig = async (config, callback) => {
|
|
1993
|
+
const tempDirectory = await mkdtemp(join(tmpdir(), "muon-build-config-"));
|
|
1994
|
+
const configPath = join(tempDirectory, "muon.json");
|
|
1995
|
+
try {
|
|
1996
|
+
await writeFile(configPath, `${JSON.stringify(config, void 0, 2)}\n`);
|
|
1997
|
+
await callback(configPath);
|
|
1998
|
+
} finally {
|
|
1999
|
+
await rm(tempDirectory, {
|
|
2000
|
+
recursive: true,
|
|
2001
|
+
force: true
|
|
2002
|
+
});
|
|
2003
|
+
}
|
|
2004
|
+
};
|
|
2005
|
+
var assertDirectory = async (path, label) => {
|
|
2006
|
+
const stats = await stat(path).catch(() => void 0);
|
|
2007
|
+
if (stats === void 0 || !stats.isDirectory()) throw new Error(`${label} directory does not exist: ${path}`);
|
|
2008
|
+
};
|
|
2009
|
+
var assertFile = async (path, label) => {
|
|
2010
|
+
const stats = await stat(path).catch(() => void 0);
|
|
2011
|
+
if (stats === void 0 || !stats.isFile()) throw new Error(`${label} file does not exist: ${path}`);
|
|
2012
|
+
};
|
|
2013
|
+
var fileExists = async (path) => {
|
|
2014
|
+
try {
|
|
2015
|
+
await access(path, constants.F_OK);
|
|
2016
|
+
return true;
|
|
2017
|
+
} catch {
|
|
2018
|
+
return false;
|
|
2019
|
+
}
|
|
2020
|
+
};
|
|
2021
|
+
var isJsonObject = (value) => {
|
|
2022
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
2023
|
+
};
|
|
2024
|
+
//#endregion
|
|
2025
|
+
//#region src/vite-internals.ts
|
|
2026
|
+
var getServerOpenValue = (server) => {
|
|
2027
|
+
const open = server.config.server.open;
|
|
2028
|
+
return open === true || typeof open === "string" ? open : false;
|
|
2029
|
+
};
|
|
2030
|
+
var resolveFromRoot = (root, path) => isAbsolute(path) ? path : resolve(root, path);
|
|
2031
|
+
var moduleDirectory = typeof __dirname === "string" ? __dirname : dirname(fileURLToPath(import.meta.url));
|
|
2032
|
+
/**
|
|
2033
|
+
* Resolves the muon-core runtime directory used by the Vite plugin.
|
|
2034
|
+
*
|
|
2035
|
+
* @param options Runtime path resolution inputs.
|
|
2036
|
+
* @returns Absolute or package-relative runtime directory path.
|
|
2037
|
+
*/
|
|
2038
|
+
var resolveMuonRuntimePath = ({ root, target, muonPath, packageDirectory = moduleDirectory }) => muonPath === void 0 ? join(packageDirectory, "runtime", target) : resolveFromRoot(root, muonPath);
|
|
2039
|
+
var getMuonExecutablePath = (runtimePath, platform) => join(runtimePath, platform === "win32" ? "muon-core.exe" : "muon-core");
|
|
2040
|
+
var getLaunchScriptFileName = (platform) => platform === "win32" ? "open-muon.cmd" : "open-muon.sh";
|
|
2041
|
+
var quotePosix = (value) => `'${value.replaceAll("'", "'\\''")}'`;
|
|
2042
|
+
var getPlatformDirectoryName = (path, platform) => platform === "win32" ? win32.dirname(path) : dirname(path);
|
|
2043
|
+
var createPosixMuonLaunchScript = ({ muonExecutablePath, projectConfigPath, overrideConfigPath }) => `#!/usr/bin/env bash
|
|
2044
|
+
set -euo pipefail
|
|
2045
|
+
MUON_EXECUTABLE=${quotePosix(muonExecutablePath)}
|
|
2046
|
+
MUON_EXECUTABLE_DIRECTORY=${quotePosix(getPlatformDirectoryName(muonExecutablePath, "linux"))}
|
|
2047
|
+
MUON_PROJECT_CONFIG=${quotePosix(projectConfigPath)}
|
|
2048
|
+
MUON_OVERRIDE_CONFIG=${quotePosix(overrideConfigPath)}
|
|
2049
|
+
|
|
2050
|
+
if [[ ! -f "$MUON_PROJECT_CONFIG" ]]; then
|
|
2051
|
+
echo "Muon startup failed: project config does not exist: $MUON_PROJECT_CONFIG" >&2
|
|
2052
|
+
exit 1
|
|
2053
|
+
fi
|
|
2054
|
+
|
|
2055
|
+
if [[ ! -x "$MUON_EXECUTABLE" ]]; then
|
|
2056
|
+
echo "Muon startup failed: executable does not exist or is not executable: $MUON_EXECUTABLE" >&2
|
|
2057
|
+
exit 1
|
|
2058
|
+
fi
|
|
2059
|
+
|
|
2060
|
+
if [[ ! -f "$MUON_OVERRIDE_CONFIG" ]]; then
|
|
2061
|
+
echo "Muon startup failed: generated override config does not exist: $MUON_OVERRIDE_CONFIG" >&2
|
|
2062
|
+
exit 1
|
|
2063
|
+
fi
|
|
2064
|
+
|
|
2065
|
+
cd "$MUON_EXECUTABLE_DIRECTORY"
|
|
2066
|
+
exec "$MUON_EXECUTABLE" -c "$MUON_PROJECT_CONFIG" -c "$MUON_OVERRIDE_CONFIG"
|
|
2067
|
+
`;
|
|
2068
|
+
var escapeWindowsCmdValue = (value) => value.replaceAll("%", "%%").replaceAll("\r", "").replaceAll("\n", "");
|
|
2069
|
+
var createWindowsMuonLaunchScript = ({ muonExecutablePath, projectConfigPath, overrideConfigPath }) => `@echo off
|
|
2070
|
+
setlocal
|
|
2071
|
+
set "MUON_EXECUTABLE=${escapeWindowsCmdValue(muonExecutablePath)}"
|
|
2072
|
+
set "MUON_EXECUTABLE_DIRECTORY=${escapeWindowsCmdValue(getPlatformDirectoryName(muonExecutablePath, "win32"))}"
|
|
2073
|
+
set "MUON_PROJECT_CONFIG=${escapeWindowsCmdValue(projectConfigPath)}"
|
|
2074
|
+
set "MUON_OVERRIDE_CONFIG=${escapeWindowsCmdValue(overrideConfigPath)}"
|
|
2075
|
+
|
|
2076
|
+
if not exist "%MUON_PROJECT_CONFIG%" (
|
|
2077
|
+
echo Muon startup failed: project config does not exist: %MUON_PROJECT_CONFIG% 1>&2
|
|
2078
|
+
exit /b 1
|
|
2079
|
+
)
|
|
2080
|
+
|
|
2081
|
+
if not exist "%MUON_EXECUTABLE%" (
|
|
2082
|
+
echo Muon startup failed: executable does not exist: %MUON_EXECUTABLE% 1>&2
|
|
2083
|
+
exit /b 1
|
|
2084
|
+
)
|
|
2085
|
+
|
|
2086
|
+
if not exist "%MUON_OVERRIDE_CONFIG%" (
|
|
2087
|
+
echo Muon startup failed: generated override config does not exist: %MUON_OVERRIDE_CONFIG% 1>&2
|
|
2088
|
+
exit /b 1
|
|
2089
|
+
)
|
|
2090
|
+
|
|
2091
|
+
pushd "%MUON_EXECUTABLE_DIRECTORY%"
|
|
2092
|
+
"%MUON_EXECUTABLE%" -c "%MUON_PROJECT_CONFIG%" -c "%MUON_OVERRIDE_CONFIG%"
|
|
2093
|
+
set "MUON_EXIT_CODE=%ERRORLEVEL%"
|
|
2094
|
+
popd
|
|
2095
|
+
exit /b %MUON_EXIT_CODE%
|
|
2096
|
+
`;
|
|
2097
|
+
var createMuonLaunchScript = (options) => options.platform === "win32" ? createWindowsMuonLaunchScript(options) : createPosixMuonLaunchScript(options);
|
|
2098
|
+
var getBaseUrl = (server) => server.resolvedUrls?.local[0] ?? server.resolvedUrls?.network[0];
|
|
2099
|
+
var getStartUrl = (server, openValue) => {
|
|
2100
|
+
const baseUrl = getBaseUrl(server);
|
|
2101
|
+
if (baseUrl === void 0) return;
|
|
2102
|
+
return typeof openValue === "string" ? new URL(openValue, baseUrl).href : baseUrl;
|
|
2103
|
+
};
|
|
2104
|
+
var getWebSocketOrigin = (startUrl) => {
|
|
2105
|
+
const url = new URL(startUrl);
|
|
2106
|
+
if (url.protocol === "https:") url.protocol = "wss:";
|
|
2107
|
+
else if (url.protocol === "http:") url.protocol = "ws:";
|
|
2108
|
+
return url.origin;
|
|
2109
|
+
};
|
|
2110
|
+
var createMuonOverrideConfig = (startUrl) => {
|
|
2111
|
+
const origin = new URL(startUrl).origin;
|
|
2112
|
+
return {
|
|
2113
|
+
browser: {
|
|
2114
|
+
startPage: startUrl,
|
|
2115
|
+
plugin: { allow: [`${origin}/**`] }
|
|
2116
|
+
},
|
|
2117
|
+
network: { allow: [`${origin}/**`, `${getWebSocketOrigin(startUrl)}/**`] }
|
|
2118
|
+
};
|
|
2119
|
+
};
|
|
2120
|
+
var writeMuonOverrideConfig = (server, openValue, overrideConfigPath) => {
|
|
2121
|
+
const startUrl = getStartUrl(server, openValue);
|
|
2122
|
+
if (startUrl === void 0) {
|
|
2123
|
+
server.config.logger.warn("Muon Vite plugin could not resolve a Vite URL.");
|
|
2124
|
+
return;
|
|
2125
|
+
}
|
|
2126
|
+
writeFileSync(overrideConfigPath, `${JSON.stringify(createMuonOverrideConfig(startUrl), null, 2)}\n`);
|
|
2127
|
+
};
|
|
2128
|
+
var createRuntimePaths = async (server, stagePath, platform) => {
|
|
2129
|
+
const temporaryDirectory = await mkdtemp(join(tmpdir(), "muon-vite-"));
|
|
2130
|
+
return {
|
|
2131
|
+
temporaryDirectory,
|
|
2132
|
+
launchScriptPath: join(temporaryDirectory, getLaunchScriptFileName(platform)),
|
|
2133
|
+
overrideConfigPath: join(temporaryDirectory, "muon.vite.json"),
|
|
2134
|
+
projectConfigPath: join(server.config.root, "muon.json"),
|
|
2135
|
+
muonExecutablePath: getMuonExecutablePath(stagePath, platform)
|
|
2136
|
+
};
|
|
2137
|
+
};
|
|
2138
|
+
var writeLaunchScript = async (paths, platform) => {
|
|
2139
|
+
await writeFile(paths.launchScriptPath, createMuonLaunchScript({
|
|
2140
|
+
muonExecutablePath: paths.muonExecutablePath,
|
|
2141
|
+
projectConfigPath: paths.projectConfigPath,
|
|
2142
|
+
overrideConfigPath: paths.overrideConfigPath,
|
|
2143
|
+
platform
|
|
2144
|
+
}));
|
|
2145
|
+
if (platform !== "win32") await chmod(paths.launchScriptPath, 448);
|
|
2146
|
+
};
|
|
2147
|
+
var startMuonViteBrowserBridge = async ({ server, pluginOptions, platform, architecture, environment }) => {
|
|
2148
|
+
const openValue = getServerOpenValue(server);
|
|
2149
|
+
if (openValue === false || server.httpServer === null) return;
|
|
2150
|
+
const target = getDefaultMuonPrepareTarget(platform, architecture);
|
|
2151
|
+
const preparedRuntime = await runMuonPrepare({
|
|
2152
|
+
muonPath: resolveMuonRuntimePath({
|
|
2153
|
+
root: server.config.root,
|
|
2154
|
+
target,
|
|
2155
|
+
muonPath: pluginOptions.muonPath
|
|
2156
|
+
}),
|
|
2157
|
+
cefPath: pluginOptions.cefPath === void 0 ? void 0 : resolveFromRoot(server.config.root, pluginOptions.cefPath),
|
|
2158
|
+
stageDir: pluginOptions.stagePath === void 0 ? resolve(server.config.root, ".muon", target) : resolveFromRoot(server.config.root, pluginOptions.stagePath),
|
|
2159
|
+
target,
|
|
2160
|
+
cacheDir: environment.MUON_CACHE_DIR,
|
|
2161
|
+
force: false,
|
|
2162
|
+
quiet: false,
|
|
2163
|
+
prepareExecutablePath: void 0,
|
|
2164
|
+
environment,
|
|
2165
|
+
cwd: server.config.root
|
|
2166
|
+
});
|
|
2167
|
+
if (preparedRuntime.stagePath === void 0) throw new Error("muon-prepare did not return a staged runtime path.");
|
|
2168
|
+
const paths = await createRuntimePaths(server, preparedRuntime.stagePath, platform);
|
|
2169
|
+
await writeLaunchScript(paths, platform);
|
|
2170
|
+
const previousBrowser = environment.BROWSER;
|
|
2171
|
+
environment.BROWSER = paths.launchScriptPath;
|
|
2172
|
+
let cleanupPromise = void 0;
|
|
2173
|
+
const cleanup = async () => {
|
|
2174
|
+
if (cleanupPromise !== void 0) return cleanupPromise;
|
|
2175
|
+
cleanupPromise = (async () => {
|
|
2176
|
+
if (previousBrowser === void 0) delete environment.BROWSER;
|
|
2177
|
+
else environment.BROWSER = previousBrowser;
|
|
2178
|
+
await rm(paths.temporaryDirectory, {
|
|
2179
|
+
recursive: true,
|
|
2180
|
+
force: true
|
|
2181
|
+
});
|
|
2182
|
+
})();
|
|
2183
|
+
return cleanupPromise;
|
|
2184
|
+
};
|
|
2185
|
+
const originalClose = server.close.bind(server);
|
|
2186
|
+
server.close = async () => {
|
|
2187
|
+
try {
|
|
2188
|
+
await originalClose();
|
|
2189
|
+
} finally {
|
|
2190
|
+
await cleanup();
|
|
2191
|
+
}
|
|
2192
|
+
};
|
|
2193
|
+
server.httpServer.once("close", () => {
|
|
2194
|
+
cleanup();
|
|
2195
|
+
});
|
|
2196
|
+
server.httpServer.once("listening", () => {
|
|
2197
|
+
writeMuonOverrideConfig(server, openValue, paths.overrideConfigPath);
|
|
2198
|
+
});
|
|
2199
|
+
};
|
|
2200
|
+
//#endregion
|
|
2201
|
+
//#region src/vite.ts
|
|
2202
|
+
/**
|
|
2203
|
+
* Creates a Vite plugin that launches Muon through Vite's server.open flow.
|
|
2204
|
+
*
|
|
2205
|
+
* @param options Muon runtime location used for development startup.
|
|
2206
|
+
* @returns Vite plugin instance.
|
|
2207
|
+
*/
|
|
2208
|
+
var muon = (options = {}) => {
|
|
2209
|
+
let resolvedConfig = void 0;
|
|
2210
|
+
return {
|
|
2211
|
+
name: "muon",
|
|
2212
|
+
configResolved: (config) => {
|
|
2213
|
+
resolvedConfig = config;
|
|
2214
|
+
},
|
|
2215
|
+
configureServer: async (server) => {
|
|
2216
|
+
await startMuonViteBrowserBridge({
|
|
2217
|
+
server,
|
|
2218
|
+
pluginOptions: options,
|
|
2219
|
+
platform: process.platform,
|
|
2220
|
+
architecture: process.arch,
|
|
2221
|
+
environment: process.env
|
|
2222
|
+
});
|
|
2223
|
+
},
|
|
2224
|
+
closeBundle: async () => {
|
|
2225
|
+
if (resolvedConfig === void 0 || resolvedConfig.command !== "build") return;
|
|
2226
|
+
if (options.build === false) return;
|
|
2227
|
+
const buildOptions = typeof options.build === "object" ? options.build : {};
|
|
2228
|
+
await buildMuonApp(createMuonBuildOptions(resolvedConfig, buildOptions));
|
|
2229
|
+
}
|
|
2230
|
+
};
|
|
2231
|
+
};
|
|
2232
|
+
var createMuonBuildOptions = (config, buildOptions) => {
|
|
2233
|
+
const outDir = isAbsolute(config.build.outDir) ? config.build.outDir : resolve(config.root, config.build.outDir);
|
|
2234
|
+
const options = {
|
|
2235
|
+
root: config.root,
|
|
2236
|
+
assetSourcePath: outDir,
|
|
2237
|
+
assetPrefix: "main"
|
|
2238
|
+
};
|
|
2239
|
+
if (buildOptions.allTargets !== void 0) options.allTargets = buildOptions.allTargets;
|
|
2240
|
+
if (buildOptions.targets !== void 0) options.targets = buildOptions.targets;
|
|
2241
|
+
if (buildOptions.appName !== void 0) options.appName = buildOptions.appName;
|
|
2242
|
+
if (buildOptions.outputRoot !== void 0) options.outputRoot = buildOptions.outputRoot;
|
|
2243
|
+
if (buildOptions.configPath !== void 0) options.configPath = buildOptions.configPath;
|
|
2244
|
+
if (buildOptions.packageDirectory !== void 0) options.packageDirectory = buildOptions.packageDirectory;
|
|
2245
|
+
if (buildOptions.assetSalt !== void 0) options.assetSalt = buildOptions.assetSalt;
|
|
2246
|
+
return options;
|
|
2247
|
+
};
|
|
2248
|
+
//#endregion
|
|
2249
|
+
export { muon as default };
|
|
2250
|
+
|
|
2251
|
+
//# sourceMappingURL=vite.mjs.map
|