@dbx-app/plugin-cli 0.1.0 → 0.1.1
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/README.md +5 -0
- package/bin/dbx-plugin.js +5 -0
- package/dev-runtime/runtime.mjs +3260 -0
- package/dev-runtime/ui/index.html +120 -0
- package/package.json +11 -10
|
@@ -0,0 +1,3260 @@
|
|
|
1
|
+
import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
9
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
|
|
28
|
+
// ../../plugins/sdk/dev-host/node_modules/semver/internal/constants.js
|
|
29
|
+
var require_constants = __commonJS({
|
|
30
|
+
"../../plugins/sdk/dev-host/node_modules/semver/internal/constants.js"(exports, module) {
|
|
31
|
+
"use strict";
|
|
32
|
+
var SEMVER_SPEC_VERSION = "2.0.0";
|
|
33
|
+
var MAX_LENGTH = 256;
|
|
34
|
+
var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || /* istanbul ignore next */
|
|
35
|
+
9007199254740991;
|
|
36
|
+
var MAX_SAFE_COMPONENT_LENGTH = 16;
|
|
37
|
+
var MAX_SAFE_BUILD_LENGTH = MAX_LENGTH - 6;
|
|
38
|
+
var RELEASE_TYPES = [
|
|
39
|
+
"major",
|
|
40
|
+
"premajor",
|
|
41
|
+
"minor",
|
|
42
|
+
"preminor",
|
|
43
|
+
"patch",
|
|
44
|
+
"prepatch",
|
|
45
|
+
"prerelease"
|
|
46
|
+
];
|
|
47
|
+
module.exports = {
|
|
48
|
+
MAX_LENGTH,
|
|
49
|
+
MAX_SAFE_COMPONENT_LENGTH,
|
|
50
|
+
MAX_SAFE_BUILD_LENGTH,
|
|
51
|
+
MAX_SAFE_INTEGER,
|
|
52
|
+
RELEASE_TYPES,
|
|
53
|
+
SEMVER_SPEC_VERSION,
|
|
54
|
+
FLAG_INCLUDE_PRERELEASE: 1,
|
|
55
|
+
FLAG_LOOSE: 2
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
// ../../plugins/sdk/dev-host/node_modules/semver/internal/debug.js
|
|
61
|
+
var require_debug = __commonJS({
|
|
62
|
+
"../../plugins/sdk/dev-host/node_modules/semver/internal/debug.js"(exports, module) {
|
|
63
|
+
"use strict";
|
|
64
|
+
var debug = typeof process === "object" && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG) ? (...args) => console.error("SEMVER", ...args) : () => {
|
|
65
|
+
};
|
|
66
|
+
module.exports = debug;
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
// ../../plugins/sdk/dev-host/node_modules/semver/internal/re.js
|
|
71
|
+
var require_re = __commonJS({
|
|
72
|
+
"../../plugins/sdk/dev-host/node_modules/semver/internal/re.js"(exports, module) {
|
|
73
|
+
"use strict";
|
|
74
|
+
var {
|
|
75
|
+
MAX_SAFE_COMPONENT_LENGTH,
|
|
76
|
+
MAX_SAFE_BUILD_LENGTH,
|
|
77
|
+
MAX_LENGTH
|
|
78
|
+
} = require_constants();
|
|
79
|
+
var debug = require_debug();
|
|
80
|
+
exports = module.exports = {};
|
|
81
|
+
var re = exports.re = [];
|
|
82
|
+
var safeRe = exports.safeRe = [];
|
|
83
|
+
var src = exports.src = [];
|
|
84
|
+
var safeSrc = exports.safeSrc = [];
|
|
85
|
+
var t = exports.t = {};
|
|
86
|
+
var R = 0;
|
|
87
|
+
var LETTERDASHNUMBER = "[a-zA-Z0-9-]";
|
|
88
|
+
var safeRegexReplacements = [
|
|
89
|
+
["\\s", 1],
|
|
90
|
+
["\\d", MAX_LENGTH],
|
|
91
|
+
[LETTERDASHNUMBER, MAX_SAFE_BUILD_LENGTH]
|
|
92
|
+
];
|
|
93
|
+
var makeSafeRegex = (value) => {
|
|
94
|
+
for (const [token, max] of safeRegexReplacements) {
|
|
95
|
+
value = value.split(`${token}*`).join(`${token}{0,${max}}`).split(`${token}+`).join(`${token}{1,${max}}`);
|
|
96
|
+
}
|
|
97
|
+
return value;
|
|
98
|
+
};
|
|
99
|
+
var createToken = (name, value, isGlobal) => {
|
|
100
|
+
const safe = makeSafeRegex(value);
|
|
101
|
+
const index = R++;
|
|
102
|
+
debug(name, index, value);
|
|
103
|
+
t[name] = index;
|
|
104
|
+
src[index] = value;
|
|
105
|
+
safeSrc[index] = safe;
|
|
106
|
+
re[index] = new RegExp(value, isGlobal ? "g" : void 0);
|
|
107
|
+
safeRe[index] = new RegExp(safe, isGlobal ? "g" : void 0);
|
|
108
|
+
};
|
|
109
|
+
createToken("NUMERICIDENTIFIER", "0|[1-9]\\d*");
|
|
110
|
+
createToken("NUMERICIDENTIFIERLOOSE", "\\d+");
|
|
111
|
+
createToken("NONNUMERICIDENTIFIER", `\\d*[a-zA-Z-]${LETTERDASHNUMBER}*`);
|
|
112
|
+
createToken("MAINVERSION", `(${src[t.NUMERICIDENTIFIER]})\\.(${src[t.NUMERICIDENTIFIER]})\\.(${src[t.NUMERICIDENTIFIER]})`);
|
|
113
|
+
createToken("MAINVERSIONLOOSE", `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.(${src[t.NUMERICIDENTIFIERLOOSE]})\\.(${src[t.NUMERICIDENTIFIERLOOSE]})`);
|
|
114
|
+
createToken("PRERELEASEIDENTIFIER", `(?:${src[t.NONNUMERICIDENTIFIER]}|${src[t.NUMERICIDENTIFIER]})`);
|
|
115
|
+
createToken("PRERELEASEIDENTIFIERLOOSE", `(?:${src[t.NONNUMERICIDENTIFIER]}|${src[t.NUMERICIDENTIFIERLOOSE]})`);
|
|
116
|
+
createToken("PRERELEASE", `(?:-(${src[t.PRERELEASEIDENTIFIER]}(?:\\.${src[t.PRERELEASEIDENTIFIER]})*))`);
|
|
117
|
+
createToken("PRERELEASELOOSE", `(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${src[t.PRERELEASEIDENTIFIERLOOSE]})*))`);
|
|
118
|
+
createToken("BUILDIDENTIFIER", `${LETTERDASHNUMBER}+`);
|
|
119
|
+
createToken("BUILD", `(?:\\+(${src[t.BUILDIDENTIFIER]}(?:\\.${src[t.BUILDIDENTIFIER]})*))`);
|
|
120
|
+
createToken("FULLPLAIN", `v?${src[t.MAINVERSION]}${src[t.PRERELEASE]}?${src[t.BUILD]}?`);
|
|
121
|
+
createToken("FULL", `^${src[t.FULLPLAIN]}$`);
|
|
122
|
+
createToken("LOOSEPLAIN", `[v=\\s]*${src[t.MAINVERSIONLOOSE]}${src[t.PRERELEASELOOSE]}?${src[t.BUILD]}?`);
|
|
123
|
+
createToken("LOOSE", `^${src[t.LOOSEPLAIN]}$`);
|
|
124
|
+
createToken("GTLT", "((?:<|>)?=?)");
|
|
125
|
+
createToken("XRANGEIDENTIFIERLOOSE", `${src[t.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);
|
|
126
|
+
createToken("XRANGEIDENTIFIER", `${src[t.NUMERICIDENTIFIER]}|x|X|\\*`);
|
|
127
|
+
createToken("XRANGEPLAIN", `[v=\\s]*(${src[t.XRANGEIDENTIFIER]})(?:\\.(${src[t.XRANGEIDENTIFIER]})(?:\\.(${src[t.XRANGEIDENTIFIER]})(?:${src[t.PRERELEASE]})?${src[t.BUILD]}?)?)?`);
|
|
128
|
+
createToken("XRANGEPLAINLOOSE", `[v=\\s]*(${src[t.XRANGEIDENTIFIERLOOSE]})(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})(?:${src[t.PRERELEASELOOSE]})?${src[t.BUILD]}?)?)?`);
|
|
129
|
+
createToken("XRANGE", `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAIN]}$`);
|
|
130
|
+
createToken("XRANGELOOSE", `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAINLOOSE]}$`);
|
|
131
|
+
createToken("COERCEPLAIN", `${"(^|[^\\d])(\\d{1,"}${MAX_SAFE_COMPONENT_LENGTH}})(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?`);
|
|
132
|
+
createToken("COERCE", `${src[t.COERCEPLAIN]}(?:$|[^\\d])`);
|
|
133
|
+
createToken("COERCEFULL", src[t.COERCEPLAIN] + `(?:${src[t.PRERELEASE]})?(?:${src[t.BUILD]})?(?:$|[^\\d])`);
|
|
134
|
+
createToken("COERCERTL", src[t.COERCE], true);
|
|
135
|
+
createToken("COERCERTLFULL", src[t.COERCEFULL], true);
|
|
136
|
+
createToken("LONETILDE", "(?:~>?)");
|
|
137
|
+
createToken("TILDETRIM", `(\\s*)${src[t.LONETILDE]}\\s+`, true);
|
|
138
|
+
exports.tildeTrimReplace = "$1~";
|
|
139
|
+
createToken("TILDE", `^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`);
|
|
140
|
+
createToken("TILDELOOSE", `^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`);
|
|
141
|
+
createToken("LONECARET", "(?:\\^)");
|
|
142
|
+
createToken("CARETTRIM", `(\\s*)${src[t.LONECARET]}\\s+`, true);
|
|
143
|
+
exports.caretTrimReplace = "$1^";
|
|
144
|
+
createToken("CARET", `^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`);
|
|
145
|
+
createToken("CARETLOOSE", `^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`);
|
|
146
|
+
createToken("COMPARATORLOOSE", `^${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]})$|^$`);
|
|
147
|
+
createToken("COMPARATOR", `^${src[t.GTLT]}\\s*(${src[t.FULLPLAIN]})$|^$`);
|
|
148
|
+
createToken("COMPARATORTRIM", `(\\s*)${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]}|${src[t.XRANGEPLAIN]})`, true);
|
|
149
|
+
exports.comparatorTrimReplace = "$1$2$3";
|
|
150
|
+
createToken("HYPHENRANGE", `^\\s*(${src[t.XRANGEPLAIN]})\\s+-\\s+(${src[t.XRANGEPLAIN]})\\s*$`);
|
|
151
|
+
createToken("HYPHENRANGELOOSE", `^\\s*(${src[t.XRANGEPLAINLOOSE]})\\s+-\\s+(${src[t.XRANGEPLAINLOOSE]})\\s*$`);
|
|
152
|
+
createToken("STAR", "(<|>)?=?\\s*\\*");
|
|
153
|
+
createToken("GTE0", "^\\s*>=\\s*0\\.0\\.0\\s*$");
|
|
154
|
+
createToken("GTE0PRE", "^\\s*>=\\s*0\\.0\\.0-0\\s*$");
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
// ../../plugins/sdk/dev-host/node_modules/semver/internal/parse-options.js
|
|
159
|
+
var require_parse_options = __commonJS({
|
|
160
|
+
"../../plugins/sdk/dev-host/node_modules/semver/internal/parse-options.js"(exports, module) {
|
|
161
|
+
"use strict";
|
|
162
|
+
var looseOption = Object.freeze({ loose: true });
|
|
163
|
+
var emptyOpts = Object.freeze({});
|
|
164
|
+
var parseOptions = (options) => {
|
|
165
|
+
if (!options) {
|
|
166
|
+
return emptyOpts;
|
|
167
|
+
}
|
|
168
|
+
if (typeof options !== "object") {
|
|
169
|
+
return looseOption;
|
|
170
|
+
}
|
|
171
|
+
return options;
|
|
172
|
+
};
|
|
173
|
+
module.exports = parseOptions;
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
// ../../plugins/sdk/dev-host/node_modules/semver/internal/identifiers.js
|
|
178
|
+
var require_identifiers = __commonJS({
|
|
179
|
+
"../../plugins/sdk/dev-host/node_modules/semver/internal/identifiers.js"(exports, module) {
|
|
180
|
+
"use strict";
|
|
181
|
+
var numeric = /^[0-9]+$/;
|
|
182
|
+
var compareIdentifiers = (a, b) => {
|
|
183
|
+
if (typeof a === "number" && typeof b === "number") {
|
|
184
|
+
return a === b ? 0 : a < b ? -1 : 1;
|
|
185
|
+
}
|
|
186
|
+
const anum = numeric.test(a);
|
|
187
|
+
const bnum = numeric.test(b);
|
|
188
|
+
if (anum && bnum) {
|
|
189
|
+
a = +a;
|
|
190
|
+
b = +b;
|
|
191
|
+
}
|
|
192
|
+
return a === b ? 0 : anum && !bnum ? -1 : bnum && !anum ? 1 : a < b ? -1 : 1;
|
|
193
|
+
};
|
|
194
|
+
var rcompareIdentifiers = (a, b) => compareIdentifiers(b, a);
|
|
195
|
+
module.exports = {
|
|
196
|
+
compareIdentifiers,
|
|
197
|
+
rcompareIdentifiers
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
// ../../plugins/sdk/dev-host/node_modules/semver/classes/semver.js
|
|
203
|
+
var require_semver = __commonJS({
|
|
204
|
+
"../../plugins/sdk/dev-host/node_modules/semver/classes/semver.js"(exports, module) {
|
|
205
|
+
"use strict";
|
|
206
|
+
var debug = require_debug();
|
|
207
|
+
var { MAX_LENGTH, MAX_SAFE_INTEGER } = require_constants();
|
|
208
|
+
var { safeRe: re, t } = require_re();
|
|
209
|
+
var parseOptions = require_parse_options();
|
|
210
|
+
var { compareIdentifiers } = require_identifiers();
|
|
211
|
+
var isPrereleaseIdentifier = (prerelease, identifier) => {
|
|
212
|
+
const identifiers = identifier.split(".");
|
|
213
|
+
if (identifiers.length > prerelease.length) {
|
|
214
|
+
return false;
|
|
215
|
+
}
|
|
216
|
+
for (let i = 0; i < identifiers.length; i++) {
|
|
217
|
+
if (compareIdentifiers(prerelease[i], identifiers[i]) !== 0) {
|
|
218
|
+
return false;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
return true;
|
|
222
|
+
};
|
|
223
|
+
var SemVer = class _SemVer {
|
|
224
|
+
constructor(version, options) {
|
|
225
|
+
options = parseOptions(options);
|
|
226
|
+
if (version instanceof _SemVer) {
|
|
227
|
+
if (version.loose === !!options.loose && version.includePrerelease === !!options.includePrerelease) {
|
|
228
|
+
return version;
|
|
229
|
+
} else {
|
|
230
|
+
version = version.version;
|
|
231
|
+
}
|
|
232
|
+
} else if (typeof version !== "string") {
|
|
233
|
+
throw new TypeError(`Invalid version. Must be a string. Got type "${typeof version}".`);
|
|
234
|
+
}
|
|
235
|
+
if (version.length > MAX_LENGTH) {
|
|
236
|
+
throw new TypeError(
|
|
237
|
+
`version is longer than ${MAX_LENGTH} characters`
|
|
238
|
+
);
|
|
239
|
+
}
|
|
240
|
+
debug("SemVer", version, options);
|
|
241
|
+
this.options = options;
|
|
242
|
+
this.loose = !!options.loose;
|
|
243
|
+
this.includePrerelease = !!options.includePrerelease;
|
|
244
|
+
const m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]);
|
|
245
|
+
if (!m) {
|
|
246
|
+
throw new TypeError(`Invalid Version: ${version}`);
|
|
247
|
+
}
|
|
248
|
+
this.raw = version;
|
|
249
|
+
this.major = +m[1];
|
|
250
|
+
this.minor = +m[2];
|
|
251
|
+
this.patch = +m[3];
|
|
252
|
+
if (this.major > MAX_SAFE_INTEGER || this.major < 0) {
|
|
253
|
+
throw new TypeError("Invalid major version");
|
|
254
|
+
}
|
|
255
|
+
if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) {
|
|
256
|
+
throw new TypeError("Invalid minor version");
|
|
257
|
+
}
|
|
258
|
+
if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) {
|
|
259
|
+
throw new TypeError("Invalid patch version");
|
|
260
|
+
}
|
|
261
|
+
if (!m[4]) {
|
|
262
|
+
this.prerelease = [];
|
|
263
|
+
} else {
|
|
264
|
+
this.prerelease = m[4].split(".").map((id) => {
|
|
265
|
+
if (/^[0-9]+$/.test(id)) {
|
|
266
|
+
const num = +id;
|
|
267
|
+
if (num >= 0 && num < MAX_SAFE_INTEGER) {
|
|
268
|
+
return num;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
return id;
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
this.build = m[5] ? m[5].split(".") : [];
|
|
275
|
+
this.format();
|
|
276
|
+
}
|
|
277
|
+
format() {
|
|
278
|
+
this.version = `${this.major}.${this.minor}.${this.patch}`;
|
|
279
|
+
if (this.prerelease.length) {
|
|
280
|
+
this.version += `-${this.prerelease.join(".")}`;
|
|
281
|
+
}
|
|
282
|
+
return this.version;
|
|
283
|
+
}
|
|
284
|
+
toString() {
|
|
285
|
+
return this.version;
|
|
286
|
+
}
|
|
287
|
+
compare(other) {
|
|
288
|
+
debug("SemVer.compare", this.version, this.options, other);
|
|
289
|
+
if (!(other instanceof _SemVer)) {
|
|
290
|
+
if (typeof other === "string" && other === this.version) {
|
|
291
|
+
return 0;
|
|
292
|
+
}
|
|
293
|
+
other = new _SemVer(other, this.options);
|
|
294
|
+
}
|
|
295
|
+
if (other.version === this.version) {
|
|
296
|
+
return 0;
|
|
297
|
+
}
|
|
298
|
+
return this.compareMain(other) || this.comparePre(other);
|
|
299
|
+
}
|
|
300
|
+
compareMain(other) {
|
|
301
|
+
if (!(other instanceof _SemVer)) {
|
|
302
|
+
other = new _SemVer(other, this.options);
|
|
303
|
+
}
|
|
304
|
+
if (this.major < other.major) {
|
|
305
|
+
return -1;
|
|
306
|
+
}
|
|
307
|
+
if (this.major > other.major) {
|
|
308
|
+
return 1;
|
|
309
|
+
}
|
|
310
|
+
if (this.minor < other.minor) {
|
|
311
|
+
return -1;
|
|
312
|
+
}
|
|
313
|
+
if (this.minor > other.minor) {
|
|
314
|
+
return 1;
|
|
315
|
+
}
|
|
316
|
+
if (this.patch < other.patch) {
|
|
317
|
+
return -1;
|
|
318
|
+
}
|
|
319
|
+
if (this.patch > other.patch) {
|
|
320
|
+
return 1;
|
|
321
|
+
}
|
|
322
|
+
return 0;
|
|
323
|
+
}
|
|
324
|
+
comparePre(other) {
|
|
325
|
+
if (!(other instanceof _SemVer)) {
|
|
326
|
+
other = new _SemVer(other, this.options);
|
|
327
|
+
}
|
|
328
|
+
if (this.prerelease.length && !other.prerelease.length) {
|
|
329
|
+
return -1;
|
|
330
|
+
} else if (!this.prerelease.length && other.prerelease.length) {
|
|
331
|
+
return 1;
|
|
332
|
+
} else if (!this.prerelease.length && !other.prerelease.length) {
|
|
333
|
+
return 0;
|
|
334
|
+
}
|
|
335
|
+
let i = 0;
|
|
336
|
+
do {
|
|
337
|
+
const a = this.prerelease[i];
|
|
338
|
+
const b = other.prerelease[i];
|
|
339
|
+
debug("prerelease compare", i, a, b);
|
|
340
|
+
if (a === void 0 && b === void 0) {
|
|
341
|
+
return 0;
|
|
342
|
+
} else if (b === void 0) {
|
|
343
|
+
return 1;
|
|
344
|
+
} else if (a === void 0) {
|
|
345
|
+
return -1;
|
|
346
|
+
} else if (a === b) {
|
|
347
|
+
continue;
|
|
348
|
+
} else {
|
|
349
|
+
return compareIdentifiers(a, b);
|
|
350
|
+
}
|
|
351
|
+
} while (++i);
|
|
352
|
+
}
|
|
353
|
+
compareBuild(other) {
|
|
354
|
+
if (!(other instanceof _SemVer)) {
|
|
355
|
+
other = new _SemVer(other, this.options);
|
|
356
|
+
}
|
|
357
|
+
let i = 0;
|
|
358
|
+
do {
|
|
359
|
+
const a = this.build[i];
|
|
360
|
+
const b = other.build[i];
|
|
361
|
+
debug("build compare", i, a, b);
|
|
362
|
+
if (a === void 0 && b === void 0) {
|
|
363
|
+
return 0;
|
|
364
|
+
} else if (b === void 0) {
|
|
365
|
+
return 1;
|
|
366
|
+
} else if (a === void 0) {
|
|
367
|
+
return -1;
|
|
368
|
+
} else if (a === b) {
|
|
369
|
+
continue;
|
|
370
|
+
} else {
|
|
371
|
+
return compareIdentifiers(a, b);
|
|
372
|
+
}
|
|
373
|
+
} while (++i);
|
|
374
|
+
}
|
|
375
|
+
// preminor will bump the version up to the next minor release, and immediately
|
|
376
|
+
// down to pre-release. premajor and prepatch work the same way.
|
|
377
|
+
inc(release, identifier, identifierBase) {
|
|
378
|
+
if (release.startsWith("pre")) {
|
|
379
|
+
if (!identifier && identifierBase === false) {
|
|
380
|
+
throw new Error("invalid increment argument: identifier is empty");
|
|
381
|
+
}
|
|
382
|
+
if (identifier) {
|
|
383
|
+
const match = `-${identifier}`.match(this.options.loose ? re[t.PRERELEASELOOSE] : re[t.PRERELEASE]);
|
|
384
|
+
if (!match || match[1] !== identifier) {
|
|
385
|
+
throw new Error(`invalid identifier: ${identifier}`);
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
switch (release) {
|
|
390
|
+
case "premajor":
|
|
391
|
+
this.prerelease.length = 0;
|
|
392
|
+
this.patch = 0;
|
|
393
|
+
this.minor = 0;
|
|
394
|
+
this.major++;
|
|
395
|
+
this.inc("pre", identifier, identifierBase);
|
|
396
|
+
break;
|
|
397
|
+
case "preminor":
|
|
398
|
+
this.prerelease.length = 0;
|
|
399
|
+
this.patch = 0;
|
|
400
|
+
this.minor++;
|
|
401
|
+
this.inc("pre", identifier, identifierBase);
|
|
402
|
+
break;
|
|
403
|
+
case "prepatch":
|
|
404
|
+
this.prerelease.length = 0;
|
|
405
|
+
this.inc("patch", identifier, identifierBase);
|
|
406
|
+
this.inc("pre", identifier, identifierBase);
|
|
407
|
+
break;
|
|
408
|
+
// If the input is a non-prerelease version, this acts the same as
|
|
409
|
+
// prepatch.
|
|
410
|
+
case "prerelease":
|
|
411
|
+
if (this.prerelease.length === 0) {
|
|
412
|
+
this.inc("patch", identifier, identifierBase);
|
|
413
|
+
}
|
|
414
|
+
this.inc("pre", identifier, identifierBase);
|
|
415
|
+
break;
|
|
416
|
+
case "release":
|
|
417
|
+
if (this.prerelease.length === 0) {
|
|
418
|
+
throw new Error(`version ${this.raw} is not a prerelease`);
|
|
419
|
+
}
|
|
420
|
+
this.prerelease.length = 0;
|
|
421
|
+
break;
|
|
422
|
+
case "major":
|
|
423
|
+
if (this.minor !== 0 || this.patch !== 0 || this.prerelease.length === 0) {
|
|
424
|
+
this.major++;
|
|
425
|
+
}
|
|
426
|
+
this.minor = 0;
|
|
427
|
+
this.patch = 0;
|
|
428
|
+
this.prerelease = [];
|
|
429
|
+
break;
|
|
430
|
+
case "minor":
|
|
431
|
+
if (this.patch !== 0 || this.prerelease.length === 0) {
|
|
432
|
+
this.minor++;
|
|
433
|
+
}
|
|
434
|
+
this.patch = 0;
|
|
435
|
+
this.prerelease = [];
|
|
436
|
+
break;
|
|
437
|
+
case "patch":
|
|
438
|
+
if (this.prerelease.length === 0) {
|
|
439
|
+
this.patch++;
|
|
440
|
+
}
|
|
441
|
+
this.prerelease = [];
|
|
442
|
+
break;
|
|
443
|
+
// This probably shouldn't be used publicly.
|
|
444
|
+
// 1.0.0 'pre' would become 1.0.0-0 which is the wrong direction.
|
|
445
|
+
case "pre": {
|
|
446
|
+
const base = Number(identifierBase) ? 1 : 0;
|
|
447
|
+
if (this.prerelease.length === 0) {
|
|
448
|
+
this.prerelease = [base];
|
|
449
|
+
} else {
|
|
450
|
+
let i = this.prerelease.length;
|
|
451
|
+
while (--i >= 0) {
|
|
452
|
+
if (typeof this.prerelease[i] === "number") {
|
|
453
|
+
this.prerelease[i]++;
|
|
454
|
+
i = -2;
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
if (i === -1) {
|
|
458
|
+
if (identifier === this.prerelease.join(".") && identifierBase === false) {
|
|
459
|
+
throw new Error("invalid increment argument: identifier already exists");
|
|
460
|
+
}
|
|
461
|
+
this.prerelease.push(base);
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
if (identifier) {
|
|
465
|
+
let prerelease = [identifier, base];
|
|
466
|
+
if (identifierBase === false) {
|
|
467
|
+
prerelease = [identifier];
|
|
468
|
+
}
|
|
469
|
+
if (isPrereleaseIdentifier(this.prerelease, identifier)) {
|
|
470
|
+
const prereleaseBase = this.prerelease[identifier.split(".").length];
|
|
471
|
+
if (isNaN(prereleaseBase)) {
|
|
472
|
+
this.prerelease = prerelease;
|
|
473
|
+
}
|
|
474
|
+
} else {
|
|
475
|
+
this.prerelease = prerelease;
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
break;
|
|
479
|
+
}
|
|
480
|
+
default:
|
|
481
|
+
throw new Error(`invalid increment argument: ${release}`);
|
|
482
|
+
}
|
|
483
|
+
this.raw = this.format();
|
|
484
|
+
if (this.build.length) {
|
|
485
|
+
this.raw += `+${this.build.join(".")}`;
|
|
486
|
+
}
|
|
487
|
+
return this;
|
|
488
|
+
}
|
|
489
|
+
};
|
|
490
|
+
module.exports = SemVer;
|
|
491
|
+
}
|
|
492
|
+
});
|
|
493
|
+
|
|
494
|
+
// ../../plugins/sdk/dev-host/node_modules/semver/functions/parse.js
|
|
495
|
+
var require_parse = __commonJS({
|
|
496
|
+
"../../plugins/sdk/dev-host/node_modules/semver/functions/parse.js"(exports, module) {
|
|
497
|
+
"use strict";
|
|
498
|
+
var SemVer = require_semver();
|
|
499
|
+
var parse = (version, options, throwErrors = false) => {
|
|
500
|
+
if (version instanceof SemVer) {
|
|
501
|
+
return version;
|
|
502
|
+
}
|
|
503
|
+
try {
|
|
504
|
+
return new SemVer(version, options);
|
|
505
|
+
} catch (er) {
|
|
506
|
+
if (!throwErrors) {
|
|
507
|
+
return null;
|
|
508
|
+
}
|
|
509
|
+
throw er;
|
|
510
|
+
}
|
|
511
|
+
};
|
|
512
|
+
module.exports = parse;
|
|
513
|
+
}
|
|
514
|
+
});
|
|
515
|
+
|
|
516
|
+
// ../../plugins/sdk/dev-host/node_modules/semver/functions/valid.js
|
|
517
|
+
var require_valid = __commonJS({
|
|
518
|
+
"../../plugins/sdk/dev-host/node_modules/semver/functions/valid.js"(exports, module) {
|
|
519
|
+
"use strict";
|
|
520
|
+
var parse = require_parse();
|
|
521
|
+
var valid = (version, options) => {
|
|
522
|
+
const v = parse(version, options);
|
|
523
|
+
return v ? v.version : null;
|
|
524
|
+
};
|
|
525
|
+
module.exports = valid;
|
|
526
|
+
}
|
|
527
|
+
});
|
|
528
|
+
|
|
529
|
+
// ../../plugins/sdk/dev-host/node_modules/semver/functions/clean.js
|
|
530
|
+
var require_clean = __commonJS({
|
|
531
|
+
"../../plugins/sdk/dev-host/node_modules/semver/functions/clean.js"(exports, module) {
|
|
532
|
+
"use strict";
|
|
533
|
+
var parse = require_parse();
|
|
534
|
+
var clean = (version, options) => {
|
|
535
|
+
const s = parse(version.trim().replace(/^[=v]+/, ""), options);
|
|
536
|
+
return s ? s.version : null;
|
|
537
|
+
};
|
|
538
|
+
module.exports = clean;
|
|
539
|
+
}
|
|
540
|
+
});
|
|
541
|
+
|
|
542
|
+
// ../../plugins/sdk/dev-host/node_modules/semver/functions/inc.js
|
|
543
|
+
var require_inc = __commonJS({
|
|
544
|
+
"../../plugins/sdk/dev-host/node_modules/semver/functions/inc.js"(exports, module) {
|
|
545
|
+
"use strict";
|
|
546
|
+
var SemVer = require_semver();
|
|
547
|
+
var inc = (version, release, options, identifier, identifierBase) => {
|
|
548
|
+
if (typeof options === "string") {
|
|
549
|
+
identifierBase = identifier;
|
|
550
|
+
identifier = options;
|
|
551
|
+
options = void 0;
|
|
552
|
+
}
|
|
553
|
+
try {
|
|
554
|
+
return new SemVer(
|
|
555
|
+
version instanceof SemVer ? version.version : version,
|
|
556
|
+
options
|
|
557
|
+
).inc(release, identifier, identifierBase).version;
|
|
558
|
+
} catch (er) {
|
|
559
|
+
return null;
|
|
560
|
+
}
|
|
561
|
+
};
|
|
562
|
+
module.exports = inc;
|
|
563
|
+
}
|
|
564
|
+
});
|
|
565
|
+
|
|
566
|
+
// ../../plugins/sdk/dev-host/node_modules/semver/functions/diff.js
|
|
567
|
+
var require_diff = __commonJS({
|
|
568
|
+
"../../plugins/sdk/dev-host/node_modules/semver/functions/diff.js"(exports, module) {
|
|
569
|
+
"use strict";
|
|
570
|
+
var parse = require_parse();
|
|
571
|
+
var diff = (version1, version2) => {
|
|
572
|
+
const v1 = parse(version1, null, true);
|
|
573
|
+
const v2 = parse(version2, null, true);
|
|
574
|
+
const comparison = v1.compare(v2);
|
|
575
|
+
if (comparison === 0) {
|
|
576
|
+
return null;
|
|
577
|
+
}
|
|
578
|
+
const v1Higher = comparison > 0;
|
|
579
|
+
const highVersion = v1Higher ? v1 : v2;
|
|
580
|
+
const lowVersion = v1Higher ? v2 : v1;
|
|
581
|
+
const highHasPre = !!highVersion.prerelease.length;
|
|
582
|
+
const lowHasPre = !!lowVersion.prerelease.length;
|
|
583
|
+
if (lowHasPre && !highHasPre) {
|
|
584
|
+
if (!lowVersion.patch && !lowVersion.minor) {
|
|
585
|
+
return "major";
|
|
586
|
+
}
|
|
587
|
+
if (lowVersion.compareMain(highVersion) === 0) {
|
|
588
|
+
if (lowVersion.minor && !lowVersion.patch) {
|
|
589
|
+
return "minor";
|
|
590
|
+
}
|
|
591
|
+
return "patch";
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
const prefix = highHasPre ? "pre" : "";
|
|
595
|
+
if (v1.major !== v2.major) {
|
|
596
|
+
return prefix + "major";
|
|
597
|
+
}
|
|
598
|
+
if (v1.minor !== v2.minor) {
|
|
599
|
+
return prefix + "minor";
|
|
600
|
+
}
|
|
601
|
+
if (v1.patch !== v2.patch) {
|
|
602
|
+
return prefix + "patch";
|
|
603
|
+
}
|
|
604
|
+
return "prerelease";
|
|
605
|
+
};
|
|
606
|
+
module.exports = diff;
|
|
607
|
+
}
|
|
608
|
+
});
|
|
609
|
+
|
|
610
|
+
// ../../plugins/sdk/dev-host/node_modules/semver/functions/major.js
|
|
611
|
+
var require_major = __commonJS({
|
|
612
|
+
"../../plugins/sdk/dev-host/node_modules/semver/functions/major.js"(exports, module) {
|
|
613
|
+
"use strict";
|
|
614
|
+
var SemVer = require_semver();
|
|
615
|
+
var major = (a, loose) => new SemVer(a, loose).major;
|
|
616
|
+
module.exports = major;
|
|
617
|
+
}
|
|
618
|
+
});
|
|
619
|
+
|
|
620
|
+
// ../../plugins/sdk/dev-host/node_modules/semver/functions/minor.js
|
|
621
|
+
var require_minor = __commonJS({
|
|
622
|
+
"../../plugins/sdk/dev-host/node_modules/semver/functions/minor.js"(exports, module) {
|
|
623
|
+
"use strict";
|
|
624
|
+
var SemVer = require_semver();
|
|
625
|
+
var minor = (a, loose) => new SemVer(a, loose).minor;
|
|
626
|
+
module.exports = minor;
|
|
627
|
+
}
|
|
628
|
+
});
|
|
629
|
+
|
|
630
|
+
// ../../plugins/sdk/dev-host/node_modules/semver/functions/patch.js
|
|
631
|
+
var require_patch = __commonJS({
|
|
632
|
+
"../../plugins/sdk/dev-host/node_modules/semver/functions/patch.js"(exports, module) {
|
|
633
|
+
"use strict";
|
|
634
|
+
var SemVer = require_semver();
|
|
635
|
+
var patch = (a, loose) => new SemVer(a, loose).patch;
|
|
636
|
+
module.exports = patch;
|
|
637
|
+
}
|
|
638
|
+
});
|
|
639
|
+
|
|
640
|
+
// ../../plugins/sdk/dev-host/node_modules/semver/functions/prerelease.js
|
|
641
|
+
var require_prerelease = __commonJS({
|
|
642
|
+
"../../plugins/sdk/dev-host/node_modules/semver/functions/prerelease.js"(exports, module) {
|
|
643
|
+
"use strict";
|
|
644
|
+
var parse = require_parse();
|
|
645
|
+
var prerelease = (version, options) => {
|
|
646
|
+
const parsed = parse(version, options);
|
|
647
|
+
return parsed && parsed.prerelease.length ? parsed.prerelease : null;
|
|
648
|
+
};
|
|
649
|
+
module.exports = prerelease;
|
|
650
|
+
}
|
|
651
|
+
});
|
|
652
|
+
|
|
653
|
+
// ../../plugins/sdk/dev-host/node_modules/semver/functions/compare.js
|
|
654
|
+
var require_compare = __commonJS({
|
|
655
|
+
"../../plugins/sdk/dev-host/node_modules/semver/functions/compare.js"(exports, module) {
|
|
656
|
+
"use strict";
|
|
657
|
+
var SemVer = require_semver();
|
|
658
|
+
var compare = (a, b, loose) => new SemVer(a, loose).compare(new SemVer(b, loose));
|
|
659
|
+
module.exports = compare;
|
|
660
|
+
}
|
|
661
|
+
});
|
|
662
|
+
|
|
663
|
+
// ../../plugins/sdk/dev-host/node_modules/semver/functions/rcompare.js
|
|
664
|
+
var require_rcompare = __commonJS({
|
|
665
|
+
"../../plugins/sdk/dev-host/node_modules/semver/functions/rcompare.js"(exports, module) {
|
|
666
|
+
"use strict";
|
|
667
|
+
var compare = require_compare();
|
|
668
|
+
var rcompare = (a, b, loose) => compare(b, a, loose);
|
|
669
|
+
module.exports = rcompare;
|
|
670
|
+
}
|
|
671
|
+
});
|
|
672
|
+
|
|
673
|
+
// ../../plugins/sdk/dev-host/node_modules/semver/functions/compare-loose.js
|
|
674
|
+
var require_compare_loose = __commonJS({
|
|
675
|
+
"../../plugins/sdk/dev-host/node_modules/semver/functions/compare-loose.js"(exports, module) {
|
|
676
|
+
"use strict";
|
|
677
|
+
var compare = require_compare();
|
|
678
|
+
var compareLoose = (a, b) => compare(a, b, true);
|
|
679
|
+
module.exports = compareLoose;
|
|
680
|
+
}
|
|
681
|
+
});
|
|
682
|
+
|
|
683
|
+
// ../../plugins/sdk/dev-host/node_modules/semver/functions/compare-build.js
|
|
684
|
+
var require_compare_build = __commonJS({
|
|
685
|
+
"../../plugins/sdk/dev-host/node_modules/semver/functions/compare-build.js"(exports, module) {
|
|
686
|
+
"use strict";
|
|
687
|
+
var SemVer = require_semver();
|
|
688
|
+
var compareBuild = (a, b, loose) => {
|
|
689
|
+
const versionA = new SemVer(a, loose);
|
|
690
|
+
const versionB = new SemVer(b, loose);
|
|
691
|
+
return versionA.compare(versionB) || versionA.compareBuild(versionB);
|
|
692
|
+
};
|
|
693
|
+
module.exports = compareBuild;
|
|
694
|
+
}
|
|
695
|
+
});
|
|
696
|
+
|
|
697
|
+
// ../../plugins/sdk/dev-host/node_modules/semver/functions/sort.js
|
|
698
|
+
var require_sort = __commonJS({
|
|
699
|
+
"../../plugins/sdk/dev-host/node_modules/semver/functions/sort.js"(exports, module) {
|
|
700
|
+
"use strict";
|
|
701
|
+
var compareBuild = require_compare_build();
|
|
702
|
+
var sort = (list, loose) => list.sort((a, b) => compareBuild(a, b, loose));
|
|
703
|
+
module.exports = sort;
|
|
704
|
+
}
|
|
705
|
+
});
|
|
706
|
+
|
|
707
|
+
// ../../plugins/sdk/dev-host/node_modules/semver/functions/rsort.js
|
|
708
|
+
var require_rsort = __commonJS({
|
|
709
|
+
"../../plugins/sdk/dev-host/node_modules/semver/functions/rsort.js"(exports, module) {
|
|
710
|
+
"use strict";
|
|
711
|
+
var compareBuild = require_compare_build();
|
|
712
|
+
var rsort = (list, loose) => list.sort((a, b) => compareBuild(b, a, loose));
|
|
713
|
+
module.exports = rsort;
|
|
714
|
+
}
|
|
715
|
+
});
|
|
716
|
+
|
|
717
|
+
// ../../plugins/sdk/dev-host/node_modules/semver/functions/gt.js
|
|
718
|
+
var require_gt = __commonJS({
|
|
719
|
+
"../../plugins/sdk/dev-host/node_modules/semver/functions/gt.js"(exports, module) {
|
|
720
|
+
"use strict";
|
|
721
|
+
var compare = require_compare();
|
|
722
|
+
var gt = (a, b, loose) => compare(a, b, loose) > 0;
|
|
723
|
+
module.exports = gt;
|
|
724
|
+
}
|
|
725
|
+
});
|
|
726
|
+
|
|
727
|
+
// ../../plugins/sdk/dev-host/node_modules/semver/functions/lt.js
|
|
728
|
+
var require_lt = __commonJS({
|
|
729
|
+
"../../plugins/sdk/dev-host/node_modules/semver/functions/lt.js"(exports, module) {
|
|
730
|
+
"use strict";
|
|
731
|
+
var compare = require_compare();
|
|
732
|
+
var lt = (a, b, loose) => compare(a, b, loose) < 0;
|
|
733
|
+
module.exports = lt;
|
|
734
|
+
}
|
|
735
|
+
});
|
|
736
|
+
|
|
737
|
+
// ../../plugins/sdk/dev-host/node_modules/semver/functions/eq.js
|
|
738
|
+
var require_eq = __commonJS({
|
|
739
|
+
"../../plugins/sdk/dev-host/node_modules/semver/functions/eq.js"(exports, module) {
|
|
740
|
+
"use strict";
|
|
741
|
+
var compare = require_compare();
|
|
742
|
+
var eq = (a, b, loose) => compare(a, b, loose) === 0;
|
|
743
|
+
module.exports = eq;
|
|
744
|
+
}
|
|
745
|
+
});
|
|
746
|
+
|
|
747
|
+
// ../../plugins/sdk/dev-host/node_modules/semver/functions/neq.js
|
|
748
|
+
var require_neq = __commonJS({
|
|
749
|
+
"../../plugins/sdk/dev-host/node_modules/semver/functions/neq.js"(exports, module) {
|
|
750
|
+
"use strict";
|
|
751
|
+
var compare = require_compare();
|
|
752
|
+
var neq = (a, b, loose) => compare(a, b, loose) !== 0;
|
|
753
|
+
module.exports = neq;
|
|
754
|
+
}
|
|
755
|
+
});
|
|
756
|
+
|
|
757
|
+
// ../../plugins/sdk/dev-host/node_modules/semver/functions/gte.js
|
|
758
|
+
var require_gte = __commonJS({
|
|
759
|
+
"../../plugins/sdk/dev-host/node_modules/semver/functions/gte.js"(exports, module) {
|
|
760
|
+
"use strict";
|
|
761
|
+
var compare = require_compare();
|
|
762
|
+
var gte = (a, b, loose) => compare(a, b, loose) >= 0;
|
|
763
|
+
module.exports = gte;
|
|
764
|
+
}
|
|
765
|
+
});
|
|
766
|
+
|
|
767
|
+
// ../../plugins/sdk/dev-host/node_modules/semver/functions/lte.js
|
|
768
|
+
var require_lte = __commonJS({
|
|
769
|
+
"../../plugins/sdk/dev-host/node_modules/semver/functions/lte.js"(exports, module) {
|
|
770
|
+
"use strict";
|
|
771
|
+
var compare = require_compare();
|
|
772
|
+
var lte = (a, b, loose) => compare(a, b, loose) <= 0;
|
|
773
|
+
module.exports = lte;
|
|
774
|
+
}
|
|
775
|
+
});
|
|
776
|
+
|
|
777
|
+
// ../../plugins/sdk/dev-host/node_modules/semver/functions/cmp.js
|
|
778
|
+
var require_cmp = __commonJS({
|
|
779
|
+
"../../plugins/sdk/dev-host/node_modules/semver/functions/cmp.js"(exports, module) {
|
|
780
|
+
"use strict";
|
|
781
|
+
var eq = require_eq();
|
|
782
|
+
var neq = require_neq();
|
|
783
|
+
var gt = require_gt();
|
|
784
|
+
var gte = require_gte();
|
|
785
|
+
var lt = require_lt();
|
|
786
|
+
var lte = require_lte();
|
|
787
|
+
var cmp = (a, op, b, loose) => {
|
|
788
|
+
switch (op) {
|
|
789
|
+
case "===":
|
|
790
|
+
if (typeof a === "object") {
|
|
791
|
+
a = a.version;
|
|
792
|
+
}
|
|
793
|
+
if (typeof b === "object") {
|
|
794
|
+
b = b.version;
|
|
795
|
+
}
|
|
796
|
+
return a === b;
|
|
797
|
+
case "!==":
|
|
798
|
+
if (typeof a === "object") {
|
|
799
|
+
a = a.version;
|
|
800
|
+
}
|
|
801
|
+
if (typeof b === "object") {
|
|
802
|
+
b = b.version;
|
|
803
|
+
}
|
|
804
|
+
return a !== b;
|
|
805
|
+
case "":
|
|
806
|
+
case "=":
|
|
807
|
+
case "==":
|
|
808
|
+
return eq(a, b, loose);
|
|
809
|
+
case "!=":
|
|
810
|
+
return neq(a, b, loose);
|
|
811
|
+
case ">":
|
|
812
|
+
return gt(a, b, loose);
|
|
813
|
+
case ">=":
|
|
814
|
+
return gte(a, b, loose);
|
|
815
|
+
case "<":
|
|
816
|
+
return lt(a, b, loose);
|
|
817
|
+
case "<=":
|
|
818
|
+
return lte(a, b, loose);
|
|
819
|
+
default:
|
|
820
|
+
throw new TypeError(`Invalid operator: ${op}`);
|
|
821
|
+
}
|
|
822
|
+
};
|
|
823
|
+
module.exports = cmp;
|
|
824
|
+
}
|
|
825
|
+
});
|
|
826
|
+
|
|
827
|
+
// ../../plugins/sdk/dev-host/node_modules/semver/functions/coerce.js
|
|
828
|
+
var require_coerce = __commonJS({
|
|
829
|
+
"../../plugins/sdk/dev-host/node_modules/semver/functions/coerce.js"(exports, module) {
|
|
830
|
+
"use strict";
|
|
831
|
+
var SemVer = require_semver();
|
|
832
|
+
var parse = require_parse();
|
|
833
|
+
var { safeRe: re, t } = require_re();
|
|
834
|
+
var coerce = (version, options) => {
|
|
835
|
+
if (version instanceof SemVer) {
|
|
836
|
+
return version;
|
|
837
|
+
}
|
|
838
|
+
if (typeof version === "number") {
|
|
839
|
+
version = String(version);
|
|
840
|
+
}
|
|
841
|
+
if (typeof version !== "string") {
|
|
842
|
+
return null;
|
|
843
|
+
}
|
|
844
|
+
options = options || {};
|
|
845
|
+
let match = null;
|
|
846
|
+
if (!options.rtl) {
|
|
847
|
+
match = version.match(options.includePrerelease ? re[t.COERCEFULL] : re[t.COERCE]);
|
|
848
|
+
} else {
|
|
849
|
+
const coerceRtlRegex = options.includePrerelease ? re[t.COERCERTLFULL] : re[t.COERCERTL];
|
|
850
|
+
let next;
|
|
851
|
+
while ((next = coerceRtlRegex.exec(version)) && (!match || match.index + match[0].length !== version.length)) {
|
|
852
|
+
if (!match || next.index + next[0].length !== match.index + match[0].length) {
|
|
853
|
+
match = next;
|
|
854
|
+
}
|
|
855
|
+
coerceRtlRegex.lastIndex = next.index + next[1].length + next[2].length;
|
|
856
|
+
}
|
|
857
|
+
coerceRtlRegex.lastIndex = -1;
|
|
858
|
+
}
|
|
859
|
+
if (match === null) {
|
|
860
|
+
return null;
|
|
861
|
+
}
|
|
862
|
+
const major = match[2];
|
|
863
|
+
const minor = match[3] || "0";
|
|
864
|
+
const patch = match[4] || "0";
|
|
865
|
+
const prerelease = options.includePrerelease && match[5] ? `-${match[5]}` : "";
|
|
866
|
+
const build = options.includePrerelease && match[6] ? `+${match[6]}` : "";
|
|
867
|
+
return parse(`${major}.${minor}.${patch}${prerelease}${build}`, options);
|
|
868
|
+
};
|
|
869
|
+
module.exports = coerce;
|
|
870
|
+
}
|
|
871
|
+
});
|
|
872
|
+
|
|
873
|
+
// ../../plugins/sdk/dev-host/node_modules/semver/functions/truncate.js
|
|
874
|
+
var require_truncate = __commonJS({
|
|
875
|
+
"../../plugins/sdk/dev-host/node_modules/semver/functions/truncate.js"(exports, module) {
|
|
876
|
+
"use strict";
|
|
877
|
+
var parse = require_parse();
|
|
878
|
+
var constants = require_constants();
|
|
879
|
+
var SemVer = require_semver();
|
|
880
|
+
var truncate = (version, truncation, options) => {
|
|
881
|
+
if (!constants.RELEASE_TYPES.includes(truncation)) {
|
|
882
|
+
return null;
|
|
883
|
+
}
|
|
884
|
+
const clonedVersion = cloneInputVersion(version, options);
|
|
885
|
+
return clonedVersion && doTruncation(clonedVersion, truncation);
|
|
886
|
+
};
|
|
887
|
+
var cloneInputVersion = (version, options) => {
|
|
888
|
+
const versionStringToParse = version instanceof SemVer ? version.version : version;
|
|
889
|
+
return parse(versionStringToParse, options);
|
|
890
|
+
};
|
|
891
|
+
var doTruncation = (version, truncation) => {
|
|
892
|
+
if (isPrerelease(truncation)) {
|
|
893
|
+
return version.version;
|
|
894
|
+
}
|
|
895
|
+
version.prerelease = [];
|
|
896
|
+
switch (truncation) {
|
|
897
|
+
case "major":
|
|
898
|
+
version.minor = 0;
|
|
899
|
+
version.patch = 0;
|
|
900
|
+
break;
|
|
901
|
+
case "minor":
|
|
902
|
+
version.patch = 0;
|
|
903
|
+
break;
|
|
904
|
+
}
|
|
905
|
+
return version.format();
|
|
906
|
+
};
|
|
907
|
+
var isPrerelease = (type) => {
|
|
908
|
+
return type.startsWith("pre");
|
|
909
|
+
};
|
|
910
|
+
module.exports = truncate;
|
|
911
|
+
}
|
|
912
|
+
});
|
|
913
|
+
|
|
914
|
+
// ../../plugins/sdk/dev-host/node_modules/semver/internal/lrucache.js
|
|
915
|
+
var require_lrucache = __commonJS({
|
|
916
|
+
"../../plugins/sdk/dev-host/node_modules/semver/internal/lrucache.js"(exports, module) {
|
|
917
|
+
"use strict";
|
|
918
|
+
var LRUCache = class {
|
|
919
|
+
constructor() {
|
|
920
|
+
this.max = 1e3;
|
|
921
|
+
this.map = /* @__PURE__ */ new Map();
|
|
922
|
+
}
|
|
923
|
+
get(key) {
|
|
924
|
+
const value = this.map.get(key);
|
|
925
|
+
if (value === void 0) {
|
|
926
|
+
return void 0;
|
|
927
|
+
} else {
|
|
928
|
+
this.map.delete(key);
|
|
929
|
+
this.map.set(key, value);
|
|
930
|
+
return value;
|
|
931
|
+
}
|
|
932
|
+
}
|
|
933
|
+
delete(key) {
|
|
934
|
+
return this.map.delete(key);
|
|
935
|
+
}
|
|
936
|
+
set(key, value) {
|
|
937
|
+
const deleted = this.delete(key);
|
|
938
|
+
if (!deleted && value !== void 0) {
|
|
939
|
+
if (this.map.size >= this.max) {
|
|
940
|
+
const firstKey = this.map.keys().next().value;
|
|
941
|
+
this.delete(firstKey);
|
|
942
|
+
}
|
|
943
|
+
this.map.set(key, value);
|
|
944
|
+
}
|
|
945
|
+
return this;
|
|
946
|
+
}
|
|
947
|
+
};
|
|
948
|
+
module.exports = LRUCache;
|
|
949
|
+
}
|
|
950
|
+
});
|
|
951
|
+
|
|
952
|
+
// ../../plugins/sdk/dev-host/node_modules/semver/classes/range.js
|
|
953
|
+
var require_range = __commonJS({
|
|
954
|
+
"../../plugins/sdk/dev-host/node_modules/semver/classes/range.js"(exports, module) {
|
|
955
|
+
"use strict";
|
|
956
|
+
var SPACE_CHARACTERS = /\s+/g;
|
|
957
|
+
var Range = class _Range {
|
|
958
|
+
constructor(range, options) {
|
|
959
|
+
options = parseOptions(options);
|
|
960
|
+
if (range instanceof _Range) {
|
|
961
|
+
if (range.loose === !!options.loose && range.includePrerelease === !!options.includePrerelease) {
|
|
962
|
+
return range;
|
|
963
|
+
} else {
|
|
964
|
+
return new _Range(range.raw, options);
|
|
965
|
+
}
|
|
966
|
+
}
|
|
967
|
+
if (range instanceof Comparator) {
|
|
968
|
+
this.raw = range.value;
|
|
969
|
+
this.set = [[range]];
|
|
970
|
+
this.formatted = void 0;
|
|
971
|
+
return this;
|
|
972
|
+
}
|
|
973
|
+
this.options = options;
|
|
974
|
+
this.loose = !!options.loose;
|
|
975
|
+
this.includePrerelease = !!options.includePrerelease;
|
|
976
|
+
this.raw = range.trim().replace(SPACE_CHARACTERS, " ");
|
|
977
|
+
this.set = this.raw.split("||").map((r) => this.parseRange(r.trim())).filter((c) => c.length);
|
|
978
|
+
if (!this.set.length) {
|
|
979
|
+
throw new TypeError(`Invalid SemVer Range: ${this.raw}`);
|
|
980
|
+
}
|
|
981
|
+
if (this.set.length > 1) {
|
|
982
|
+
const first = this.set[0];
|
|
983
|
+
this.set = this.set.filter((c) => !isNullSet(c[0]));
|
|
984
|
+
if (this.set.length === 0) {
|
|
985
|
+
this.set = [first];
|
|
986
|
+
} else if (this.set.length > 1) {
|
|
987
|
+
for (const c of this.set) {
|
|
988
|
+
if (c.length === 1 && isAny(c[0])) {
|
|
989
|
+
this.set = [c];
|
|
990
|
+
break;
|
|
991
|
+
}
|
|
992
|
+
}
|
|
993
|
+
}
|
|
994
|
+
}
|
|
995
|
+
this.formatted = void 0;
|
|
996
|
+
}
|
|
997
|
+
get range() {
|
|
998
|
+
if (this.formatted === void 0) {
|
|
999
|
+
this.formatted = "";
|
|
1000
|
+
for (let i = 0; i < this.set.length; i++) {
|
|
1001
|
+
if (i > 0) {
|
|
1002
|
+
this.formatted += "||";
|
|
1003
|
+
}
|
|
1004
|
+
const comps = this.set[i];
|
|
1005
|
+
for (let k = 0; k < comps.length; k++) {
|
|
1006
|
+
if (k > 0) {
|
|
1007
|
+
this.formatted += " ";
|
|
1008
|
+
}
|
|
1009
|
+
this.formatted += comps[k].toString().trim();
|
|
1010
|
+
}
|
|
1011
|
+
}
|
|
1012
|
+
}
|
|
1013
|
+
return this.formatted;
|
|
1014
|
+
}
|
|
1015
|
+
format() {
|
|
1016
|
+
return this.range;
|
|
1017
|
+
}
|
|
1018
|
+
toString() {
|
|
1019
|
+
return this.range;
|
|
1020
|
+
}
|
|
1021
|
+
parseRange(range) {
|
|
1022
|
+
range = range.replace(BUILDSTRIPRE, "");
|
|
1023
|
+
const memoOpts = (this.options.includePrerelease && FLAG_INCLUDE_PRERELEASE) | (this.options.loose && FLAG_LOOSE);
|
|
1024
|
+
const memoKey = memoOpts + ":" + range;
|
|
1025
|
+
const cached = cache.get(memoKey);
|
|
1026
|
+
if (cached) {
|
|
1027
|
+
return cached;
|
|
1028
|
+
}
|
|
1029
|
+
const loose = this.options.loose;
|
|
1030
|
+
const hr = loose ? re[t.HYPHENRANGELOOSE] : re[t.HYPHENRANGE];
|
|
1031
|
+
range = range.replace(hr, hyphenReplace(this.options.includePrerelease));
|
|
1032
|
+
debug("hyphen replace", range);
|
|
1033
|
+
range = range.replace(re[t.COMPARATORTRIM], comparatorTrimReplace);
|
|
1034
|
+
debug("comparator trim", range);
|
|
1035
|
+
range = range.replace(re[t.TILDETRIM], tildeTrimReplace);
|
|
1036
|
+
debug("tilde trim", range);
|
|
1037
|
+
range = range.replace(re[t.CARETTRIM], caretTrimReplace);
|
|
1038
|
+
debug("caret trim", range);
|
|
1039
|
+
let rangeList = range.split(" ").map((comp) => parseComparator(comp, this.options)).join(" ").split(/\s+/).map((comp) => replaceGTE0(comp, this.options));
|
|
1040
|
+
if (loose) {
|
|
1041
|
+
rangeList = rangeList.filter((comp) => {
|
|
1042
|
+
debug("loose invalid filter", comp, this.options);
|
|
1043
|
+
return !!comp.match(re[t.COMPARATORLOOSE]);
|
|
1044
|
+
});
|
|
1045
|
+
}
|
|
1046
|
+
debug("range list", rangeList);
|
|
1047
|
+
const rangeMap = /* @__PURE__ */ new Map();
|
|
1048
|
+
const comparators = rangeList.map((comp) => new Comparator(comp, this.options));
|
|
1049
|
+
for (const comp of comparators) {
|
|
1050
|
+
if (isNullSet(comp)) {
|
|
1051
|
+
return [comp];
|
|
1052
|
+
}
|
|
1053
|
+
rangeMap.set(comp.value, comp);
|
|
1054
|
+
}
|
|
1055
|
+
if (rangeMap.size > 1 && rangeMap.has("")) {
|
|
1056
|
+
rangeMap.delete("");
|
|
1057
|
+
}
|
|
1058
|
+
const result = [...rangeMap.values()];
|
|
1059
|
+
cache.set(memoKey, result);
|
|
1060
|
+
return result;
|
|
1061
|
+
}
|
|
1062
|
+
intersects(range, options) {
|
|
1063
|
+
if (!(range instanceof _Range)) {
|
|
1064
|
+
throw new TypeError("a Range is required");
|
|
1065
|
+
}
|
|
1066
|
+
return this.set.some((thisComparators) => {
|
|
1067
|
+
return isSatisfiable(thisComparators, options) && range.set.some((rangeComparators) => {
|
|
1068
|
+
return isSatisfiable(rangeComparators, options) && thisComparators.every((thisComparator) => {
|
|
1069
|
+
return rangeComparators.every((rangeComparator) => {
|
|
1070
|
+
return thisComparator.intersects(rangeComparator, options);
|
|
1071
|
+
});
|
|
1072
|
+
});
|
|
1073
|
+
});
|
|
1074
|
+
});
|
|
1075
|
+
}
|
|
1076
|
+
// if ANY of the sets match ALL of its comparators, then pass
|
|
1077
|
+
test(version) {
|
|
1078
|
+
if (!version) {
|
|
1079
|
+
return false;
|
|
1080
|
+
}
|
|
1081
|
+
if (typeof version === "string") {
|
|
1082
|
+
try {
|
|
1083
|
+
version = new SemVer(version, this.options);
|
|
1084
|
+
} catch (er) {
|
|
1085
|
+
return false;
|
|
1086
|
+
}
|
|
1087
|
+
}
|
|
1088
|
+
for (let i = 0; i < this.set.length; i++) {
|
|
1089
|
+
if (testSet(this.set[i], version, this.options)) {
|
|
1090
|
+
return true;
|
|
1091
|
+
}
|
|
1092
|
+
}
|
|
1093
|
+
return false;
|
|
1094
|
+
}
|
|
1095
|
+
};
|
|
1096
|
+
module.exports = Range;
|
|
1097
|
+
var LRU = require_lrucache();
|
|
1098
|
+
var cache = new LRU();
|
|
1099
|
+
var parseOptions = require_parse_options();
|
|
1100
|
+
var Comparator = require_comparator();
|
|
1101
|
+
var debug = require_debug();
|
|
1102
|
+
var SemVer = require_semver();
|
|
1103
|
+
var {
|
|
1104
|
+
safeRe: re,
|
|
1105
|
+
src,
|
|
1106
|
+
t,
|
|
1107
|
+
comparatorTrimReplace,
|
|
1108
|
+
tildeTrimReplace,
|
|
1109
|
+
caretTrimReplace
|
|
1110
|
+
} = require_re();
|
|
1111
|
+
var { FLAG_INCLUDE_PRERELEASE, FLAG_LOOSE } = require_constants();
|
|
1112
|
+
var BUILDSTRIPRE = new RegExp(src[t.BUILD], "g");
|
|
1113
|
+
var isNullSet = (c) => c.value === "<0.0.0-0";
|
|
1114
|
+
var isAny = (c) => c.value === "";
|
|
1115
|
+
var isSatisfiable = (comparators, options) => {
|
|
1116
|
+
let result = true;
|
|
1117
|
+
const remainingComparators = comparators.slice();
|
|
1118
|
+
let testComparator = remainingComparators.pop();
|
|
1119
|
+
while (result && remainingComparators.length) {
|
|
1120
|
+
result = remainingComparators.every((otherComparator) => {
|
|
1121
|
+
return testComparator.intersects(otherComparator, options);
|
|
1122
|
+
});
|
|
1123
|
+
testComparator = remainingComparators.pop();
|
|
1124
|
+
}
|
|
1125
|
+
return result;
|
|
1126
|
+
};
|
|
1127
|
+
var parseComparator = (comp, options) => {
|
|
1128
|
+
comp = comp.replace(re[t.BUILD], "");
|
|
1129
|
+
debug("comp", comp, options);
|
|
1130
|
+
comp = replaceCarets(comp, options);
|
|
1131
|
+
debug("caret", comp);
|
|
1132
|
+
comp = replaceTildes(comp, options);
|
|
1133
|
+
debug("tildes", comp);
|
|
1134
|
+
comp = replaceXRanges(comp, options);
|
|
1135
|
+
debug("xrange", comp);
|
|
1136
|
+
comp = replaceStars(comp, options);
|
|
1137
|
+
debug("stars", comp);
|
|
1138
|
+
return comp;
|
|
1139
|
+
};
|
|
1140
|
+
var isX = (id) => !id || id.toLowerCase() === "x" || id === "*";
|
|
1141
|
+
var invalidXRangeOrder = (M, m, p) => isX(M) && !isX(m) || isX(m) && p && !isX(p);
|
|
1142
|
+
var replaceTildes = (comp, options) => {
|
|
1143
|
+
return comp.trim().split(/\s+/).map((c) => replaceTilde(c, options)).join(" ");
|
|
1144
|
+
};
|
|
1145
|
+
var replaceTilde = (comp, options) => {
|
|
1146
|
+
const r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE];
|
|
1147
|
+
const z = options.includePrerelease ? "-0" : "";
|
|
1148
|
+
return comp.replace(r, (_, M, m, p, pr) => {
|
|
1149
|
+
debug("tilde", comp, _, M, m, p, pr);
|
|
1150
|
+
let ret;
|
|
1151
|
+
if (isX(M)) {
|
|
1152
|
+
ret = "";
|
|
1153
|
+
} else if (isX(m)) {
|
|
1154
|
+
ret = `>=${M}.0.0${z} <${+M + 1}.0.0-0`;
|
|
1155
|
+
} else if (isX(p)) {
|
|
1156
|
+
ret = `>=${M}.${m}.0${z} <${M}.${+m + 1}.0-0`;
|
|
1157
|
+
} else if (pr) {
|
|
1158
|
+
debug("replaceTilde pr", pr);
|
|
1159
|
+
ret = `>=${M}.${m}.${p}-${pr} <${M}.${+m + 1}.0-0`;
|
|
1160
|
+
} else {
|
|
1161
|
+
ret = `>=${M}.${m}.${p} <${M}.${+m + 1}.0-0`;
|
|
1162
|
+
}
|
|
1163
|
+
debug("tilde return", ret);
|
|
1164
|
+
return ret;
|
|
1165
|
+
});
|
|
1166
|
+
};
|
|
1167
|
+
var replaceCarets = (comp, options) => {
|
|
1168
|
+
return comp.trim().split(/\s+/).map((c) => replaceCaret(c, options)).join(" ");
|
|
1169
|
+
};
|
|
1170
|
+
var replaceCaret = (comp, options) => {
|
|
1171
|
+
debug("caret", comp, options);
|
|
1172
|
+
const r = options.loose ? re[t.CARETLOOSE] : re[t.CARET];
|
|
1173
|
+
const z = options.includePrerelease ? "-0" : "";
|
|
1174
|
+
return comp.replace(r, (_, M, m, p, pr) => {
|
|
1175
|
+
debug("caret", comp, _, M, m, p, pr);
|
|
1176
|
+
let ret;
|
|
1177
|
+
if (isX(M)) {
|
|
1178
|
+
ret = "";
|
|
1179
|
+
} else if (isX(m)) {
|
|
1180
|
+
ret = `>=${M}.0.0${z} <${+M + 1}.0.0-0`;
|
|
1181
|
+
} else if (isX(p)) {
|
|
1182
|
+
if (M === "0") {
|
|
1183
|
+
ret = `>=${M}.${m}.0${z} <${M}.${+m + 1}.0-0`;
|
|
1184
|
+
} else {
|
|
1185
|
+
ret = `>=${M}.${m}.0${z} <${+M + 1}.0.0-0`;
|
|
1186
|
+
}
|
|
1187
|
+
} else if (pr) {
|
|
1188
|
+
debug("replaceCaret pr", pr);
|
|
1189
|
+
if (M === "0") {
|
|
1190
|
+
if (m === "0") {
|
|
1191
|
+
ret = `>=${M}.${m}.${p}-${pr} <${M}.${m}.${+p + 1}-0`;
|
|
1192
|
+
} else {
|
|
1193
|
+
ret = `>=${M}.${m}.${p}-${pr} <${M}.${+m + 1}.0-0`;
|
|
1194
|
+
}
|
|
1195
|
+
} else {
|
|
1196
|
+
ret = `>=${M}.${m}.${p}-${pr} <${+M + 1}.0.0-0`;
|
|
1197
|
+
}
|
|
1198
|
+
} else {
|
|
1199
|
+
debug("no pr");
|
|
1200
|
+
if (M === "0") {
|
|
1201
|
+
if (m === "0") {
|
|
1202
|
+
ret = `>=${M}.${m}.${p} <${M}.${m}.${+p + 1}-0`;
|
|
1203
|
+
} else {
|
|
1204
|
+
ret = `>=${M}.${m}.${p} <${M}.${+m + 1}.0-0`;
|
|
1205
|
+
}
|
|
1206
|
+
} else {
|
|
1207
|
+
ret = `>=${M}.${m}.${p} <${+M + 1}.0.0-0`;
|
|
1208
|
+
}
|
|
1209
|
+
}
|
|
1210
|
+
debug("caret return", ret);
|
|
1211
|
+
return ret;
|
|
1212
|
+
});
|
|
1213
|
+
};
|
|
1214
|
+
var replaceXRanges = (comp, options) => {
|
|
1215
|
+
debug("replaceXRanges", comp, options);
|
|
1216
|
+
return comp.split(/\s+/).map((c) => replaceXRange(c, options)).join(" ");
|
|
1217
|
+
};
|
|
1218
|
+
var replaceXRange = (comp, options) => {
|
|
1219
|
+
comp = comp.trim();
|
|
1220
|
+
const r = options.loose ? re[t.XRANGELOOSE] : re[t.XRANGE];
|
|
1221
|
+
return comp.replace(r, (ret, gtlt, M, m, p, pr) => {
|
|
1222
|
+
debug("xRange", comp, ret, gtlt, M, m, p, pr);
|
|
1223
|
+
if (invalidXRangeOrder(M, m, p)) {
|
|
1224
|
+
return comp;
|
|
1225
|
+
}
|
|
1226
|
+
const xM = isX(M);
|
|
1227
|
+
const xm = xM || isX(m);
|
|
1228
|
+
const xp = xm || isX(p);
|
|
1229
|
+
const anyX = xp;
|
|
1230
|
+
if (gtlt === "=" && anyX) {
|
|
1231
|
+
gtlt = "";
|
|
1232
|
+
}
|
|
1233
|
+
pr = options.includePrerelease ? "-0" : "";
|
|
1234
|
+
if (xM) {
|
|
1235
|
+
if (gtlt === ">" || gtlt === "<") {
|
|
1236
|
+
ret = "<0.0.0-0";
|
|
1237
|
+
} else {
|
|
1238
|
+
ret = "*";
|
|
1239
|
+
}
|
|
1240
|
+
} else if (gtlt && anyX) {
|
|
1241
|
+
if (xm) {
|
|
1242
|
+
m = 0;
|
|
1243
|
+
}
|
|
1244
|
+
p = 0;
|
|
1245
|
+
if (gtlt === ">") {
|
|
1246
|
+
gtlt = ">=";
|
|
1247
|
+
if (xm) {
|
|
1248
|
+
M = +M + 1;
|
|
1249
|
+
m = 0;
|
|
1250
|
+
p = 0;
|
|
1251
|
+
} else {
|
|
1252
|
+
m = +m + 1;
|
|
1253
|
+
p = 0;
|
|
1254
|
+
}
|
|
1255
|
+
} else if (gtlt === "<=") {
|
|
1256
|
+
gtlt = "<";
|
|
1257
|
+
if (xm) {
|
|
1258
|
+
M = +M + 1;
|
|
1259
|
+
} else {
|
|
1260
|
+
m = +m + 1;
|
|
1261
|
+
}
|
|
1262
|
+
}
|
|
1263
|
+
if (gtlt === "<") {
|
|
1264
|
+
pr = "-0";
|
|
1265
|
+
}
|
|
1266
|
+
ret = `${gtlt + M}.${m}.${p}${pr}`;
|
|
1267
|
+
} else if (xm) {
|
|
1268
|
+
ret = `>=${M}.0.0${pr} <${+M + 1}.0.0-0`;
|
|
1269
|
+
} else if (xp) {
|
|
1270
|
+
ret = `>=${M}.${m}.0${pr} <${M}.${+m + 1}.0-0`;
|
|
1271
|
+
}
|
|
1272
|
+
debug("xRange return", ret);
|
|
1273
|
+
return ret;
|
|
1274
|
+
});
|
|
1275
|
+
};
|
|
1276
|
+
var replaceStars = (comp, options) => {
|
|
1277
|
+
debug("replaceStars", comp, options);
|
|
1278
|
+
return comp.trim().replace(re[t.STAR], "");
|
|
1279
|
+
};
|
|
1280
|
+
var replaceGTE0 = (comp, options) => {
|
|
1281
|
+
debug("replaceGTE0", comp, options);
|
|
1282
|
+
return comp.trim().replace(re[options.includePrerelease ? t.GTE0PRE : t.GTE0], "");
|
|
1283
|
+
};
|
|
1284
|
+
var hyphenReplace = (incPr) => ($0, from, fM, fm, fp, fpr, fb, to, tM, tm, tp, tpr) => {
|
|
1285
|
+
if (isX(fM)) {
|
|
1286
|
+
from = "";
|
|
1287
|
+
} else if (isX(fm)) {
|
|
1288
|
+
from = `>=${fM}.0.0${incPr ? "-0" : ""}`;
|
|
1289
|
+
} else if (isX(fp)) {
|
|
1290
|
+
from = `>=${fM}.${fm}.0${incPr ? "-0" : ""}`;
|
|
1291
|
+
} else if (fpr) {
|
|
1292
|
+
from = `>=${from}`;
|
|
1293
|
+
} else {
|
|
1294
|
+
from = `>=${from}${incPr ? "-0" : ""}`;
|
|
1295
|
+
}
|
|
1296
|
+
if (isX(tM)) {
|
|
1297
|
+
to = "";
|
|
1298
|
+
} else if (isX(tm)) {
|
|
1299
|
+
to = `<${+tM + 1}.0.0-0`;
|
|
1300
|
+
} else if (isX(tp)) {
|
|
1301
|
+
to = `<${tM}.${+tm + 1}.0-0`;
|
|
1302
|
+
} else if (tpr) {
|
|
1303
|
+
to = `<=${tM}.${tm}.${tp}-${tpr}`;
|
|
1304
|
+
} else if (incPr) {
|
|
1305
|
+
to = `<${tM}.${tm}.${+tp + 1}-0`;
|
|
1306
|
+
} else {
|
|
1307
|
+
to = `<=${to}`;
|
|
1308
|
+
}
|
|
1309
|
+
return `${from} ${to}`.trim();
|
|
1310
|
+
};
|
|
1311
|
+
var testSet = (set, version, options) => {
|
|
1312
|
+
for (let i = 0; i < set.length; i++) {
|
|
1313
|
+
if (!set[i].test(version)) {
|
|
1314
|
+
return false;
|
|
1315
|
+
}
|
|
1316
|
+
}
|
|
1317
|
+
if (version.prerelease.length && !options.includePrerelease) {
|
|
1318
|
+
for (let i = 0; i < set.length; i++) {
|
|
1319
|
+
debug(set[i].semver);
|
|
1320
|
+
if (set[i].semver === Comparator.ANY) {
|
|
1321
|
+
continue;
|
|
1322
|
+
}
|
|
1323
|
+
if (set[i].semver.prerelease.length > 0) {
|
|
1324
|
+
const allowed = set[i].semver;
|
|
1325
|
+
if (allowed.major === version.major && allowed.minor === version.minor && allowed.patch === version.patch) {
|
|
1326
|
+
return true;
|
|
1327
|
+
}
|
|
1328
|
+
}
|
|
1329
|
+
}
|
|
1330
|
+
return false;
|
|
1331
|
+
}
|
|
1332
|
+
return true;
|
|
1333
|
+
};
|
|
1334
|
+
}
|
|
1335
|
+
});
|
|
1336
|
+
|
|
1337
|
+
// ../../plugins/sdk/dev-host/node_modules/semver/classes/comparator.js
|
|
1338
|
+
var require_comparator = __commonJS({
|
|
1339
|
+
"../../plugins/sdk/dev-host/node_modules/semver/classes/comparator.js"(exports, module) {
|
|
1340
|
+
"use strict";
|
|
1341
|
+
var ANY = Symbol("SemVer ANY");
|
|
1342
|
+
var Comparator = class _Comparator {
|
|
1343
|
+
static get ANY() {
|
|
1344
|
+
return ANY;
|
|
1345
|
+
}
|
|
1346
|
+
constructor(comp, options) {
|
|
1347
|
+
options = parseOptions(options);
|
|
1348
|
+
if (comp instanceof _Comparator) {
|
|
1349
|
+
if (comp.loose === !!options.loose) {
|
|
1350
|
+
return comp;
|
|
1351
|
+
} else {
|
|
1352
|
+
comp = comp.value;
|
|
1353
|
+
}
|
|
1354
|
+
}
|
|
1355
|
+
comp = comp.trim().split(/\s+/).join(" ");
|
|
1356
|
+
debug("comparator", comp, options);
|
|
1357
|
+
this.options = options;
|
|
1358
|
+
this.loose = !!options.loose;
|
|
1359
|
+
this.parse(comp);
|
|
1360
|
+
if (this.semver === ANY) {
|
|
1361
|
+
this.value = "";
|
|
1362
|
+
} else {
|
|
1363
|
+
this.value = this.operator + this.semver.version;
|
|
1364
|
+
}
|
|
1365
|
+
debug("comp", this);
|
|
1366
|
+
}
|
|
1367
|
+
parse(comp) {
|
|
1368
|
+
const r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR];
|
|
1369
|
+
const m = comp.match(r);
|
|
1370
|
+
if (!m) {
|
|
1371
|
+
throw new TypeError(`Invalid comparator: ${comp}`);
|
|
1372
|
+
}
|
|
1373
|
+
this.operator = m[1] !== void 0 ? m[1] : "";
|
|
1374
|
+
if (this.operator === "=") {
|
|
1375
|
+
this.operator = "";
|
|
1376
|
+
}
|
|
1377
|
+
if (!m[2]) {
|
|
1378
|
+
this.semver = ANY;
|
|
1379
|
+
} else {
|
|
1380
|
+
this.semver = new SemVer(m[2], this.options.loose);
|
|
1381
|
+
}
|
|
1382
|
+
}
|
|
1383
|
+
toString() {
|
|
1384
|
+
return this.value;
|
|
1385
|
+
}
|
|
1386
|
+
test(version) {
|
|
1387
|
+
debug("Comparator.test", version, this.options.loose);
|
|
1388
|
+
if (this.semver === ANY || version === ANY) {
|
|
1389
|
+
return true;
|
|
1390
|
+
}
|
|
1391
|
+
if (typeof version === "string") {
|
|
1392
|
+
try {
|
|
1393
|
+
version = new SemVer(version, this.options);
|
|
1394
|
+
} catch (er) {
|
|
1395
|
+
return false;
|
|
1396
|
+
}
|
|
1397
|
+
}
|
|
1398
|
+
return cmp(version, this.operator, this.semver, this.options);
|
|
1399
|
+
}
|
|
1400
|
+
intersects(comp, options) {
|
|
1401
|
+
if (!(comp instanceof _Comparator)) {
|
|
1402
|
+
throw new TypeError("a Comparator is required");
|
|
1403
|
+
}
|
|
1404
|
+
if (this.operator === "") {
|
|
1405
|
+
if (this.value === "") {
|
|
1406
|
+
return true;
|
|
1407
|
+
}
|
|
1408
|
+
return new Range(comp.value, options).test(this.value);
|
|
1409
|
+
} else if (comp.operator === "") {
|
|
1410
|
+
if (comp.value === "") {
|
|
1411
|
+
return true;
|
|
1412
|
+
}
|
|
1413
|
+
return new Range(this.value, options).test(comp.semver);
|
|
1414
|
+
}
|
|
1415
|
+
options = parseOptions(options);
|
|
1416
|
+
if (options.includePrerelease && (this.value === "<0.0.0-0" || comp.value === "<0.0.0-0")) {
|
|
1417
|
+
return false;
|
|
1418
|
+
}
|
|
1419
|
+
if (!options.includePrerelease && (this.value.startsWith("<0.0.0") || comp.value.startsWith("<0.0.0"))) {
|
|
1420
|
+
return false;
|
|
1421
|
+
}
|
|
1422
|
+
if (this.operator.startsWith(">") && comp.operator.startsWith(">")) {
|
|
1423
|
+
return true;
|
|
1424
|
+
}
|
|
1425
|
+
if (this.operator.startsWith("<") && comp.operator.startsWith("<")) {
|
|
1426
|
+
return true;
|
|
1427
|
+
}
|
|
1428
|
+
if (this.semver.version === comp.semver.version && this.operator.includes("=") && comp.operator.includes("=")) {
|
|
1429
|
+
return true;
|
|
1430
|
+
}
|
|
1431
|
+
if (cmp(this.semver, "<", comp.semver, options) && this.operator.startsWith(">") && comp.operator.startsWith("<")) {
|
|
1432
|
+
return true;
|
|
1433
|
+
}
|
|
1434
|
+
if (cmp(this.semver, ">", comp.semver, options) && this.operator.startsWith("<") && comp.operator.startsWith(">")) {
|
|
1435
|
+
return true;
|
|
1436
|
+
}
|
|
1437
|
+
return false;
|
|
1438
|
+
}
|
|
1439
|
+
};
|
|
1440
|
+
module.exports = Comparator;
|
|
1441
|
+
var parseOptions = require_parse_options();
|
|
1442
|
+
var { safeRe: re, t } = require_re();
|
|
1443
|
+
var cmp = require_cmp();
|
|
1444
|
+
var debug = require_debug();
|
|
1445
|
+
var SemVer = require_semver();
|
|
1446
|
+
var Range = require_range();
|
|
1447
|
+
}
|
|
1448
|
+
});
|
|
1449
|
+
|
|
1450
|
+
// ../../plugins/sdk/dev-host/node_modules/semver/functions/satisfies.js
|
|
1451
|
+
var require_satisfies = __commonJS({
|
|
1452
|
+
"../../plugins/sdk/dev-host/node_modules/semver/functions/satisfies.js"(exports, module) {
|
|
1453
|
+
"use strict";
|
|
1454
|
+
var Range = require_range();
|
|
1455
|
+
var satisfies = (version, range, options) => {
|
|
1456
|
+
try {
|
|
1457
|
+
range = new Range(range, options);
|
|
1458
|
+
} catch (er) {
|
|
1459
|
+
return false;
|
|
1460
|
+
}
|
|
1461
|
+
return range.test(version);
|
|
1462
|
+
};
|
|
1463
|
+
module.exports = satisfies;
|
|
1464
|
+
}
|
|
1465
|
+
});
|
|
1466
|
+
|
|
1467
|
+
// ../../plugins/sdk/dev-host/node_modules/semver/ranges/to-comparators.js
|
|
1468
|
+
var require_to_comparators = __commonJS({
|
|
1469
|
+
"../../plugins/sdk/dev-host/node_modules/semver/ranges/to-comparators.js"(exports, module) {
|
|
1470
|
+
"use strict";
|
|
1471
|
+
var Range = require_range();
|
|
1472
|
+
var toComparators = (range, options) => new Range(range, options).set.map((comp) => comp.map((c) => c.value).join(" ").trim().split(" "));
|
|
1473
|
+
module.exports = toComparators;
|
|
1474
|
+
}
|
|
1475
|
+
});
|
|
1476
|
+
|
|
1477
|
+
// ../../plugins/sdk/dev-host/node_modules/semver/ranges/max-satisfying.js
|
|
1478
|
+
var require_max_satisfying = __commonJS({
|
|
1479
|
+
"../../plugins/sdk/dev-host/node_modules/semver/ranges/max-satisfying.js"(exports, module) {
|
|
1480
|
+
"use strict";
|
|
1481
|
+
var SemVer = require_semver();
|
|
1482
|
+
var Range = require_range();
|
|
1483
|
+
var maxSatisfying = (versions, range, options) => {
|
|
1484
|
+
let max = null;
|
|
1485
|
+
let maxSV = null;
|
|
1486
|
+
let rangeObj = null;
|
|
1487
|
+
try {
|
|
1488
|
+
rangeObj = new Range(range, options);
|
|
1489
|
+
} catch (er) {
|
|
1490
|
+
return null;
|
|
1491
|
+
}
|
|
1492
|
+
versions.forEach((v) => {
|
|
1493
|
+
if (rangeObj.test(v)) {
|
|
1494
|
+
if (!max || maxSV.compare(v) === -1) {
|
|
1495
|
+
max = v;
|
|
1496
|
+
maxSV = new SemVer(max, options);
|
|
1497
|
+
}
|
|
1498
|
+
}
|
|
1499
|
+
});
|
|
1500
|
+
return max;
|
|
1501
|
+
};
|
|
1502
|
+
module.exports = maxSatisfying;
|
|
1503
|
+
}
|
|
1504
|
+
});
|
|
1505
|
+
|
|
1506
|
+
// ../../plugins/sdk/dev-host/node_modules/semver/ranges/min-satisfying.js
|
|
1507
|
+
var require_min_satisfying = __commonJS({
|
|
1508
|
+
"../../plugins/sdk/dev-host/node_modules/semver/ranges/min-satisfying.js"(exports, module) {
|
|
1509
|
+
"use strict";
|
|
1510
|
+
var SemVer = require_semver();
|
|
1511
|
+
var Range = require_range();
|
|
1512
|
+
var minSatisfying = (versions, range, options) => {
|
|
1513
|
+
let min = null;
|
|
1514
|
+
let minSV = null;
|
|
1515
|
+
let rangeObj = null;
|
|
1516
|
+
try {
|
|
1517
|
+
rangeObj = new Range(range, options);
|
|
1518
|
+
} catch (er) {
|
|
1519
|
+
return null;
|
|
1520
|
+
}
|
|
1521
|
+
versions.forEach((v) => {
|
|
1522
|
+
if (rangeObj.test(v)) {
|
|
1523
|
+
if (!min || minSV.compare(v) === 1) {
|
|
1524
|
+
min = v;
|
|
1525
|
+
minSV = new SemVer(min, options);
|
|
1526
|
+
}
|
|
1527
|
+
}
|
|
1528
|
+
});
|
|
1529
|
+
return min;
|
|
1530
|
+
};
|
|
1531
|
+
module.exports = minSatisfying;
|
|
1532
|
+
}
|
|
1533
|
+
});
|
|
1534
|
+
|
|
1535
|
+
// ../../plugins/sdk/dev-host/node_modules/semver/ranges/min-version.js
|
|
1536
|
+
var require_min_version = __commonJS({
|
|
1537
|
+
"../../plugins/sdk/dev-host/node_modules/semver/ranges/min-version.js"(exports, module) {
|
|
1538
|
+
"use strict";
|
|
1539
|
+
var SemVer = require_semver();
|
|
1540
|
+
var Range = require_range();
|
|
1541
|
+
var gt = require_gt();
|
|
1542
|
+
var minVersion = (range, loose) => {
|
|
1543
|
+
range = new Range(range, loose);
|
|
1544
|
+
let minver = new SemVer("0.0.0");
|
|
1545
|
+
if (range.test(minver)) {
|
|
1546
|
+
return minver;
|
|
1547
|
+
}
|
|
1548
|
+
minver = new SemVer("0.0.0-0");
|
|
1549
|
+
if (range.test(minver)) {
|
|
1550
|
+
return minver;
|
|
1551
|
+
}
|
|
1552
|
+
minver = null;
|
|
1553
|
+
for (let i = 0; i < range.set.length; ++i) {
|
|
1554
|
+
const comparators = range.set[i];
|
|
1555
|
+
let setMin = null;
|
|
1556
|
+
comparators.forEach((comparator) => {
|
|
1557
|
+
const compver = new SemVer(comparator.semver.version);
|
|
1558
|
+
switch (comparator.operator) {
|
|
1559
|
+
case ">":
|
|
1560
|
+
if (compver.prerelease.length === 0) {
|
|
1561
|
+
compver.patch++;
|
|
1562
|
+
} else {
|
|
1563
|
+
compver.prerelease.push(0);
|
|
1564
|
+
}
|
|
1565
|
+
compver.raw = compver.format();
|
|
1566
|
+
/* fallthrough */
|
|
1567
|
+
case "":
|
|
1568
|
+
case ">=":
|
|
1569
|
+
if (!setMin || gt(compver, setMin)) {
|
|
1570
|
+
setMin = compver;
|
|
1571
|
+
}
|
|
1572
|
+
break;
|
|
1573
|
+
case "<":
|
|
1574
|
+
case "<=":
|
|
1575
|
+
break;
|
|
1576
|
+
/* istanbul ignore next */
|
|
1577
|
+
default:
|
|
1578
|
+
throw new Error(`Unexpected operation: ${comparator.operator}`);
|
|
1579
|
+
}
|
|
1580
|
+
});
|
|
1581
|
+
if (setMin && (!minver || gt(minver, setMin))) {
|
|
1582
|
+
minver = setMin;
|
|
1583
|
+
}
|
|
1584
|
+
}
|
|
1585
|
+
if (minver && range.test(minver)) {
|
|
1586
|
+
return minver;
|
|
1587
|
+
}
|
|
1588
|
+
return null;
|
|
1589
|
+
};
|
|
1590
|
+
module.exports = minVersion;
|
|
1591
|
+
}
|
|
1592
|
+
});
|
|
1593
|
+
|
|
1594
|
+
// ../../plugins/sdk/dev-host/node_modules/semver/ranges/valid.js
|
|
1595
|
+
var require_valid2 = __commonJS({
|
|
1596
|
+
"../../plugins/sdk/dev-host/node_modules/semver/ranges/valid.js"(exports, module) {
|
|
1597
|
+
"use strict";
|
|
1598
|
+
var Range = require_range();
|
|
1599
|
+
var validRange = (range, options) => {
|
|
1600
|
+
try {
|
|
1601
|
+
return new Range(range, options).range || "*";
|
|
1602
|
+
} catch (er) {
|
|
1603
|
+
return null;
|
|
1604
|
+
}
|
|
1605
|
+
};
|
|
1606
|
+
module.exports = validRange;
|
|
1607
|
+
}
|
|
1608
|
+
});
|
|
1609
|
+
|
|
1610
|
+
// ../../plugins/sdk/dev-host/node_modules/semver/ranges/outside.js
|
|
1611
|
+
var require_outside = __commonJS({
|
|
1612
|
+
"../../plugins/sdk/dev-host/node_modules/semver/ranges/outside.js"(exports, module) {
|
|
1613
|
+
"use strict";
|
|
1614
|
+
var SemVer = require_semver();
|
|
1615
|
+
var Comparator = require_comparator();
|
|
1616
|
+
var { ANY } = Comparator;
|
|
1617
|
+
var Range = require_range();
|
|
1618
|
+
var satisfies = require_satisfies();
|
|
1619
|
+
var gt = require_gt();
|
|
1620
|
+
var lt = require_lt();
|
|
1621
|
+
var lte = require_lte();
|
|
1622
|
+
var gte = require_gte();
|
|
1623
|
+
var outside = (version, range, hilo, options) => {
|
|
1624
|
+
version = new SemVer(version, options);
|
|
1625
|
+
range = new Range(range, options);
|
|
1626
|
+
let gtfn, ltefn, ltfn, comp, ecomp;
|
|
1627
|
+
switch (hilo) {
|
|
1628
|
+
case ">":
|
|
1629
|
+
gtfn = gt;
|
|
1630
|
+
ltefn = lte;
|
|
1631
|
+
ltfn = lt;
|
|
1632
|
+
comp = ">";
|
|
1633
|
+
ecomp = ">=";
|
|
1634
|
+
break;
|
|
1635
|
+
case "<":
|
|
1636
|
+
gtfn = lt;
|
|
1637
|
+
ltefn = gte;
|
|
1638
|
+
ltfn = gt;
|
|
1639
|
+
comp = "<";
|
|
1640
|
+
ecomp = "<=";
|
|
1641
|
+
break;
|
|
1642
|
+
default:
|
|
1643
|
+
throw new TypeError('Must provide a hilo val of "<" or ">"');
|
|
1644
|
+
}
|
|
1645
|
+
if (satisfies(version, range, options)) {
|
|
1646
|
+
return false;
|
|
1647
|
+
}
|
|
1648
|
+
for (let i = 0; i < range.set.length; ++i) {
|
|
1649
|
+
const comparators = range.set[i];
|
|
1650
|
+
let high = null;
|
|
1651
|
+
let low = null;
|
|
1652
|
+
comparators.forEach((comparator) => {
|
|
1653
|
+
if (comparator.semver === ANY) {
|
|
1654
|
+
comparator = new Comparator(">=0.0.0");
|
|
1655
|
+
}
|
|
1656
|
+
high = high || comparator;
|
|
1657
|
+
low = low || comparator;
|
|
1658
|
+
if (gtfn(comparator.semver, high.semver, options)) {
|
|
1659
|
+
high = comparator;
|
|
1660
|
+
} else if (ltfn(comparator.semver, low.semver, options)) {
|
|
1661
|
+
low = comparator;
|
|
1662
|
+
}
|
|
1663
|
+
});
|
|
1664
|
+
if (high.operator === comp || high.operator === ecomp) {
|
|
1665
|
+
return false;
|
|
1666
|
+
}
|
|
1667
|
+
if ((!low.operator || low.operator === comp) && ltefn(version, low.semver)) {
|
|
1668
|
+
return false;
|
|
1669
|
+
} else if (low.operator === ecomp && ltfn(version, low.semver)) {
|
|
1670
|
+
return false;
|
|
1671
|
+
}
|
|
1672
|
+
}
|
|
1673
|
+
return true;
|
|
1674
|
+
};
|
|
1675
|
+
module.exports = outside;
|
|
1676
|
+
}
|
|
1677
|
+
});
|
|
1678
|
+
|
|
1679
|
+
// ../../plugins/sdk/dev-host/node_modules/semver/ranges/gtr.js
|
|
1680
|
+
var require_gtr = __commonJS({
|
|
1681
|
+
"../../plugins/sdk/dev-host/node_modules/semver/ranges/gtr.js"(exports, module) {
|
|
1682
|
+
"use strict";
|
|
1683
|
+
var outside = require_outside();
|
|
1684
|
+
var gtr = (version, range, options) => outside(version, range, ">", options);
|
|
1685
|
+
module.exports = gtr;
|
|
1686
|
+
}
|
|
1687
|
+
});
|
|
1688
|
+
|
|
1689
|
+
// ../../plugins/sdk/dev-host/node_modules/semver/ranges/ltr.js
|
|
1690
|
+
var require_ltr = __commonJS({
|
|
1691
|
+
"../../plugins/sdk/dev-host/node_modules/semver/ranges/ltr.js"(exports, module) {
|
|
1692
|
+
"use strict";
|
|
1693
|
+
var outside = require_outside();
|
|
1694
|
+
var ltr = (version, range, options) => outside(version, range, "<", options);
|
|
1695
|
+
module.exports = ltr;
|
|
1696
|
+
}
|
|
1697
|
+
});
|
|
1698
|
+
|
|
1699
|
+
// ../../plugins/sdk/dev-host/node_modules/semver/ranges/intersects.js
|
|
1700
|
+
var require_intersects = __commonJS({
|
|
1701
|
+
"../../plugins/sdk/dev-host/node_modules/semver/ranges/intersects.js"(exports, module) {
|
|
1702
|
+
"use strict";
|
|
1703
|
+
var Range = require_range();
|
|
1704
|
+
var intersects = (r1, r2, options) => {
|
|
1705
|
+
r1 = new Range(r1, options);
|
|
1706
|
+
r2 = new Range(r2, options);
|
|
1707
|
+
return r1.intersects(r2, options);
|
|
1708
|
+
};
|
|
1709
|
+
module.exports = intersects;
|
|
1710
|
+
}
|
|
1711
|
+
});
|
|
1712
|
+
|
|
1713
|
+
// ../../plugins/sdk/dev-host/node_modules/semver/ranges/simplify.js
|
|
1714
|
+
var require_simplify = __commonJS({
|
|
1715
|
+
"../../plugins/sdk/dev-host/node_modules/semver/ranges/simplify.js"(exports, module) {
|
|
1716
|
+
"use strict";
|
|
1717
|
+
var satisfies = require_satisfies();
|
|
1718
|
+
var compare = require_compare();
|
|
1719
|
+
module.exports = (versions, range, options) => {
|
|
1720
|
+
const set = [];
|
|
1721
|
+
let first = null;
|
|
1722
|
+
let prev = null;
|
|
1723
|
+
const v = versions.sort((a, b) => compare(a, b, options));
|
|
1724
|
+
for (const version of v) {
|
|
1725
|
+
const included = satisfies(version, range, options);
|
|
1726
|
+
if (included) {
|
|
1727
|
+
prev = version;
|
|
1728
|
+
if (!first) {
|
|
1729
|
+
first = version;
|
|
1730
|
+
}
|
|
1731
|
+
} else {
|
|
1732
|
+
if (prev) {
|
|
1733
|
+
set.push([first, prev]);
|
|
1734
|
+
}
|
|
1735
|
+
prev = null;
|
|
1736
|
+
first = null;
|
|
1737
|
+
}
|
|
1738
|
+
}
|
|
1739
|
+
if (first) {
|
|
1740
|
+
set.push([first, null]);
|
|
1741
|
+
}
|
|
1742
|
+
const ranges = [];
|
|
1743
|
+
for (const [min, max] of set) {
|
|
1744
|
+
if (min === max) {
|
|
1745
|
+
ranges.push(min);
|
|
1746
|
+
} else if (!max && min === v[0]) {
|
|
1747
|
+
ranges.push("*");
|
|
1748
|
+
} else if (!max) {
|
|
1749
|
+
ranges.push(`>=${min}`);
|
|
1750
|
+
} else if (min === v[0]) {
|
|
1751
|
+
ranges.push(`<=${max}`);
|
|
1752
|
+
} else {
|
|
1753
|
+
ranges.push(`${min} - ${max}`);
|
|
1754
|
+
}
|
|
1755
|
+
}
|
|
1756
|
+
const simplified = ranges.join(" || ");
|
|
1757
|
+
const original = typeof range.raw === "string" ? range.raw : String(range);
|
|
1758
|
+
return simplified.length < original.length ? simplified : range;
|
|
1759
|
+
};
|
|
1760
|
+
}
|
|
1761
|
+
});
|
|
1762
|
+
|
|
1763
|
+
// ../../plugins/sdk/dev-host/node_modules/semver/ranges/subset.js
|
|
1764
|
+
var require_subset = __commonJS({
|
|
1765
|
+
"../../plugins/sdk/dev-host/node_modules/semver/ranges/subset.js"(exports, module) {
|
|
1766
|
+
"use strict";
|
|
1767
|
+
var Range = require_range();
|
|
1768
|
+
var Comparator = require_comparator();
|
|
1769
|
+
var { ANY } = Comparator;
|
|
1770
|
+
var satisfies = require_satisfies();
|
|
1771
|
+
var compare = require_compare();
|
|
1772
|
+
var subset = (sub, dom, options = {}) => {
|
|
1773
|
+
if (sub === dom) {
|
|
1774
|
+
return true;
|
|
1775
|
+
}
|
|
1776
|
+
sub = new Range(sub, options);
|
|
1777
|
+
dom = new Range(dom, options);
|
|
1778
|
+
let sawNonNull = false;
|
|
1779
|
+
OUTER: for (const simpleSub of sub.set) {
|
|
1780
|
+
for (const simpleDom of dom.set) {
|
|
1781
|
+
const isSub = simpleSubset(simpleSub, simpleDom, options);
|
|
1782
|
+
sawNonNull = sawNonNull || isSub !== null;
|
|
1783
|
+
if (isSub) {
|
|
1784
|
+
continue OUTER;
|
|
1785
|
+
}
|
|
1786
|
+
}
|
|
1787
|
+
if (sawNonNull) {
|
|
1788
|
+
return false;
|
|
1789
|
+
}
|
|
1790
|
+
}
|
|
1791
|
+
return true;
|
|
1792
|
+
};
|
|
1793
|
+
var minimumVersionWithPreRelease = [new Comparator(">=0.0.0-0")];
|
|
1794
|
+
var minimumVersion = [new Comparator(">=0.0.0")];
|
|
1795
|
+
var simpleSubset = (sub, dom, options) => {
|
|
1796
|
+
if (sub === dom) {
|
|
1797
|
+
return true;
|
|
1798
|
+
}
|
|
1799
|
+
if (sub.length === 1 && sub[0].semver === ANY) {
|
|
1800
|
+
if (dom.length === 1 && dom[0].semver === ANY) {
|
|
1801
|
+
return true;
|
|
1802
|
+
} else if (options.includePrerelease) {
|
|
1803
|
+
sub = minimumVersionWithPreRelease;
|
|
1804
|
+
} else {
|
|
1805
|
+
sub = minimumVersion;
|
|
1806
|
+
}
|
|
1807
|
+
}
|
|
1808
|
+
if (dom.length === 1 && dom[0].semver === ANY) {
|
|
1809
|
+
if (options.includePrerelease) {
|
|
1810
|
+
return true;
|
|
1811
|
+
} else {
|
|
1812
|
+
dom = minimumVersion;
|
|
1813
|
+
}
|
|
1814
|
+
}
|
|
1815
|
+
const eqSet = /* @__PURE__ */ new Set();
|
|
1816
|
+
let gt, lt;
|
|
1817
|
+
for (const c of sub) {
|
|
1818
|
+
if (c.operator === ">" || c.operator === ">=") {
|
|
1819
|
+
gt = higherGT(gt, c, options);
|
|
1820
|
+
} else if (c.operator === "<" || c.operator === "<=") {
|
|
1821
|
+
lt = lowerLT(lt, c, options);
|
|
1822
|
+
} else {
|
|
1823
|
+
eqSet.add(c.semver);
|
|
1824
|
+
}
|
|
1825
|
+
}
|
|
1826
|
+
if (eqSet.size > 1) {
|
|
1827
|
+
return null;
|
|
1828
|
+
}
|
|
1829
|
+
let gtltComp;
|
|
1830
|
+
if (gt && lt) {
|
|
1831
|
+
gtltComp = compare(gt.semver, lt.semver, options);
|
|
1832
|
+
if (gtltComp > 0) {
|
|
1833
|
+
return null;
|
|
1834
|
+
} else if (gtltComp === 0 && (gt.operator !== ">=" || lt.operator !== "<=")) {
|
|
1835
|
+
return null;
|
|
1836
|
+
}
|
|
1837
|
+
}
|
|
1838
|
+
for (const eq of eqSet) {
|
|
1839
|
+
if (gt && !satisfies(eq, String(gt), options)) {
|
|
1840
|
+
return null;
|
|
1841
|
+
}
|
|
1842
|
+
if (lt && !satisfies(eq, String(lt), options)) {
|
|
1843
|
+
return null;
|
|
1844
|
+
}
|
|
1845
|
+
for (const c of dom) {
|
|
1846
|
+
if (!satisfies(eq, String(c), options)) {
|
|
1847
|
+
return false;
|
|
1848
|
+
}
|
|
1849
|
+
}
|
|
1850
|
+
return true;
|
|
1851
|
+
}
|
|
1852
|
+
let higher, lower;
|
|
1853
|
+
let hasDomLT, hasDomGT;
|
|
1854
|
+
let needDomLTPre = lt && !options.includePrerelease && lt.semver.prerelease.length ? lt.semver : false;
|
|
1855
|
+
let needDomGTPre = gt && !options.includePrerelease && gt.semver.prerelease.length ? gt.semver : false;
|
|
1856
|
+
if (needDomLTPre && needDomLTPre.prerelease.length === 1 && lt.operator === "<" && needDomLTPre.prerelease[0] === 0) {
|
|
1857
|
+
needDomLTPre = false;
|
|
1858
|
+
}
|
|
1859
|
+
for (const c of dom) {
|
|
1860
|
+
hasDomGT = hasDomGT || c.operator === ">" || c.operator === ">=";
|
|
1861
|
+
hasDomLT = hasDomLT || c.operator === "<" || c.operator === "<=";
|
|
1862
|
+
if (gt) {
|
|
1863
|
+
if (needDomGTPre) {
|
|
1864
|
+
if (c.semver.prerelease && c.semver.prerelease.length && c.semver.major === needDomGTPre.major && c.semver.minor === needDomGTPre.minor && c.semver.patch === needDomGTPre.patch) {
|
|
1865
|
+
needDomGTPre = false;
|
|
1866
|
+
}
|
|
1867
|
+
}
|
|
1868
|
+
if (c.operator === ">" || c.operator === ">=") {
|
|
1869
|
+
higher = higherGT(gt, c, options);
|
|
1870
|
+
if (higher === c && higher !== gt) {
|
|
1871
|
+
return false;
|
|
1872
|
+
}
|
|
1873
|
+
} else if (gt.operator === ">=" && !c.test(gt.semver)) {
|
|
1874
|
+
return false;
|
|
1875
|
+
}
|
|
1876
|
+
}
|
|
1877
|
+
if (lt) {
|
|
1878
|
+
if (needDomLTPre) {
|
|
1879
|
+
if (c.semver.prerelease && c.semver.prerelease.length && c.semver.major === needDomLTPre.major && c.semver.minor === needDomLTPre.minor && c.semver.patch === needDomLTPre.patch) {
|
|
1880
|
+
needDomLTPre = false;
|
|
1881
|
+
}
|
|
1882
|
+
}
|
|
1883
|
+
if (c.operator === "<" || c.operator === "<=") {
|
|
1884
|
+
lower = lowerLT(lt, c, options);
|
|
1885
|
+
if (lower === c && lower !== lt) {
|
|
1886
|
+
return false;
|
|
1887
|
+
}
|
|
1888
|
+
} else if (lt.operator === "<=" && !c.test(lt.semver)) {
|
|
1889
|
+
return false;
|
|
1890
|
+
}
|
|
1891
|
+
}
|
|
1892
|
+
if (!c.operator && (lt || gt) && gtltComp !== 0) {
|
|
1893
|
+
return false;
|
|
1894
|
+
}
|
|
1895
|
+
}
|
|
1896
|
+
if (gt && hasDomLT && !lt && gtltComp !== 0) {
|
|
1897
|
+
return false;
|
|
1898
|
+
}
|
|
1899
|
+
if (lt && hasDomGT && !gt && gtltComp !== 0) {
|
|
1900
|
+
return false;
|
|
1901
|
+
}
|
|
1902
|
+
if (needDomGTPre || needDomLTPre) {
|
|
1903
|
+
return false;
|
|
1904
|
+
}
|
|
1905
|
+
return true;
|
|
1906
|
+
};
|
|
1907
|
+
var higherGT = (a, b, options) => {
|
|
1908
|
+
if (!a) {
|
|
1909
|
+
return b;
|
|
1910
|
+
}
|
|
1911
|
+
const comp = compare(a.semver, b.semver, options);
|
|
1912
|
+
return comp > 0 ? a : comp < 0 ? b : b.operator === ">" && a.operator === ">=" ? b : a;
|
|
1913
|
+
};
|
|
1914
|
+
var lowerLT = (a, b, options) => {
|
|
1915
|
+
if (!a) {
|
|
1916
|
+
return b;
|
|
1917
|
+
}
|
|
1918
|
+
const comp = compare(a.semver, b.semver, options);
|
|
1919
|
+
return comp < 0 ? a : comp > 0 ? b : b.operator === "<" && a.operator === "<=" ? b : a;
|
|
1920
|
+
};
|
|
1921
|
+
module.exports = subset;
|
|
1922
|
+
}
|
|
1923
|
+
});
|
|
1924
|
+
|
|
1925
|
+
// ../../plugins/sdk/dev-host/node_modules/semver/index.js
|
|
1926
|
+
var require_semver2 = __commonJS({
|
|
1927
|
+
"../../plugins/sdk/dev-host/node_modules/semver/index.js"(exports, module) {
|
|
1928
|
+
"use strict";
|
|
1929
|
+
var internalRe = require_re();
|
|
1930
|
+
var constants = require_constants();
|
|
1931
|
+
var SemVer = require_semver();
|
|
1932
|
+
var identifiers = require_identifiers();
|
|
1933
|
+
var parse = require_parse();
|
|
1934
|
+
var valid = require_valid();
|
|
1935
|
+
var clean = require_clean();
|
|
1936
|
+
var inc = require_inc();
|
|
1937
|
+
var diff = require_diff();
|
|
1938
|
+
var major = require_major();
|
|
1939
|
+
var minor = require_minor();
|
|
1940
|
+
var patch = require_patch();
|
|
1941
|
+
var prerelease = require_prerelease();
|
|
1942
|
+
var compare = require_compare();
|
|
1943
|
+
var rcompare = require_rcompare();
|
|
1944
|
+
var compareLoose = require_compare_loose();
|
|
1945
|
+
var compareBuild = require_compare_build();
|
|
1946
|
+
var sort = require_sort();
|
|
1947
|
+
var rsort = require_rsort();
|
|
1948
|
+
var gt = require_gt();
|
|
1949
|
+
var lt = require_lt();
|
|
1950
|
+
var eq = require_eq();
|
|
1951
|
+
var neq = require_neq();
|
|
1952
|
+
var gte = require_gte();
|
|
1953
|
+
var lte = require_lte();
|
|
1954
|
+
var cmp = require_cmp();
|
|
1955
|
+
var coerce = require_coerce();
|
|
1956
|
+
var truncate = require_truncate();
|
|
1957
|
+
var Comparator = require_comparator();
|
|
1958
|
+
var Range = require_range();
|
|
1959
|
+
var satisfies = require_satisfies();
|
|
1960
|
+
var toComparators = require_to_comparators();
|
|
1961
|
+
var maxSatisfying = require_max_satisfying();
|
|
1962
|
+
var minSatisfying = require_min_satisfying();
|
|
1963
|
+
var minVersion = require_min_version();
|
|
1964
|
+
var validRange = require_valid2();
|
|
1965
|
+
var outside = require_outside();
|
|
1966
|
+
var gtr = require_gtr();
|
|
1967
|
+
var ltr = require_ltr();
|
|
1968
|
+
var intersects = require_intersects();
|
|
1969
|
+
var simplifyRange = require_simplify();
|
|
1970
|
+
var subset = require_subset();
|
|
1971
|
+
module.exports = {
|
|
1972
|
+
parse,
|
|
1973
|
+
valid,
|
|
1974
|
+
clean,
|
|
1975
|
+
inc,
|
|
1976
|
+
diff,
|
|
1977
|
+
major,
|
|
1978
|
+
minor,
|
|
1979
|
+
patch,
|
|
1980
|
+
prerelease,
|
|
1981
|
+
compare,
|
|
1982
|
+
rcompare,
|
|
1983
|
+
compareLoose,
|
|
1984
|
+
compareBuild,
|
|
1985
|
+
sort,
|
|
1986
|
+
rsort,
|
|
1987
|
+
gt,
|
|
1988
|
+
lt,
|
|
1989
|
+
eq,
|
|
1990
|
+
neq,
|
|
1991
|
+
gte,
|
|
1992
|
+
lte,
|
|
1993
|
+
cmp,
|
|
1994
|
+
coerce,
|
|
1995
|
+
truncate,
|
|
1996
|
+
Comparator,
|
|
1997
|
+
Range,
|
|
1998
|
+
satisfies,
|
|
1999
|
+
toComparators,
|
|
2000
|
+
maxSatisfying,
|
|
2001
|
+
minSatisfying,
|
|
2002
|
+
minVersion,
|
|
2003
|
+
validRange,
|
|
2004
|
+
outside,
|
|
2005
|
+
gtr,
|
|
2006
|
+
ltr,
|
|
2007
|
+
intersects,
|
|
2008
|
+
simplifyRange,
|
|
2009
|
+
subset,
|
|
2010
|
+
SemVer,
|
|
2011
|
+
re: internalRe.re,
|
|
2012
|
+
src: internalRe.src,
|
|
2013
|
+
tokens: internalRe.t,
|
|
2014
|
+
SEMVER_SPEC_VERSION: constants.SEMVER_SPEC_VERSION,
|
|
2015
|
+
RELEASE_TYPES: constants.RELEASE_TYPES,
|
|
2016
|
+
compareIdentifiers: identifiers.compareIdentifiers,
|
|
2017
|
+
rcompareIdentifiers: identifiers.rcompareIdentifiers
|
|
2018
|
+
};
|
|
2019
|
+
}
|
|
2020
|
+
});
|
|
2021
|
+
|
|
2022
|
+
// ../../plugins/sdk/dev-host/runtime.mjs
|
|
2023
|
+
import { spawn as spawn3 } from "node:child_process";
|
|
2024
|
+
import { mkdir as mkdir2, writeFile as writeFile2, chmod as chmod2 } from "node:fs/promises";
|
|
2025
|
+
import { resolve as resolve3, dirname } from "node:path";
|
|
2026
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
2027
|
+
|
|
2028
|
+
// ../../plugins/sdk/dev-host/server.mjs
|
|
2029
|
+
var import_semver = __toESM(require_semver2(), 1);
|
|
2030
|
+
import http from "node:http";
|
|
2031
|
+
import { randomUUID as randomUUID3, randomBytes } from "node:crypto";
|
|
2032
|
+
import { readFile as readFile3, realpath as realpath2, watch } from "node:fs/promises";
|
|
2033
|
+
import { resolve as resolve2, relative as relative2, isAbsolute as isAbsolute2, sep } from "node:path";
|
|
2034
|
+
|
|
2035
|
+
// ../../plugins/sdk/dev-host/sidecar.mjs
|
|
2036
|
+
import { EventEmitter } from "node:events";
|
|
2037
|
+
import { spawn as spawn2 } from "node:child_process";
|
|
2038
|
+
|
|
2039
|
+
// ../../plugins/sdk/dev-host/process-tree.mjs
|
|
2040
|
+
import { spawn } from "node:child_process";
|
|
2041
|
+
import { setTimeout as delay } from "node:timers/promises";
|
|
2042
|
+
async function stopProcessTree(child) {
|
|
2043
|
+
if (!child?.pid) return;
|
|
2044
|
+
if (process.platform === "win32") {
|
|
2045
|
+
await new Promise((resolve4) => {
|
|
2046
|
+
const killer = spawn("taskkill", ["/pid", String(child.pid), "/T", "/F"], { stdio: "ignore" });
|
|
2047
|
+
killer.once("error", resolve4);
|
|
2048
|
+
killer.once("close", resolve4);
|
|
2049
|
+
});
|
|
2050
|
+
return;
|
|
2051
|
+
}
|
|
2052
|
+
const signal = (value) => {
|
|
2053
|
+
try {
|
|
2054
|
+
process.kill(-child.pid, value);
|
|
2055
|
+
return true;
|
|
2056
|
+
} catch (error) {
|
|
2057
|
+
if (error.code === "ESRCH" || value === 0 && error.code === "EPERM") return false;
|
|
2058
|
+
throw error;
|
|
2059
|
+
}
|
|
2060
|
+
};
|
|
2061
|
+
if (!signal("SIGTERM")) return;
|
|
2062
|
+
for (let i = 0; i < 40; i++) {
|
|
2063
|
+
await delay(50);
|
|
2064
|
+
if (!signal(0)) return;
|
|
2065
|
+
}
|
|
2066
|
+
signal("SIGKILL");
|
|
2067
|
+
}
|
|
2068
|
+
|
|
2069
|
+
// ../../plugins/sdk/dev-host/sidecar.mjs
|
|
2070
|
+
var JSON_LIMIT = 8 * 1024 * 1024;
|
|
2071
|
+
var BINARY_LIMIT = 64 * 1024 * 1024;
|
|
2072
|
+
function protocolName(value) {
|
|
2073
|
+
if (typeof value !== "string" || !/^[A-Za-z0-9][A-Za-z0-9._:/-]{0,255}$/.test(value)) throw new Error("Invalid protocol name");
|
|
2074
|
+
return value;
|
|
2075
|
+
}
|
|
2076
|
+
function frame(kind, payload) {
|
|
2077
|
+
const header = Buffer.alloc(5);
|
|
2078
|
+
header[0] = kind;
|
|
2079
|
+
header.writeUInt32BE(payload.length, 1);
|
|
2080
|
+
return Buffer.concat([header, payload]);
|
|
2081
|
+
}
|
|
2082
|
+
function binaryPayload(channel, data) {
|
|
2083
|
+
const name = Buffer.from(protocolName(channel));
|
|
2084
|
+
if (data.length > BINARY_LIMIT) throw new Error("Binary payload exceeds limit");
|
|
2085
|
+
const header = Buffer.alloc(2);
|
|
2086
|
+
header.writeUInt16BE(name.length);
|
|
2087
|
+
return Buffer.concat([header, name, data]);
|
|
2088
|
+
}
|
|
2089
|
+
var FrameDecoder = class {
|
|
2090
|
+
buffer = Buffer.alloc(0);
|
|
2091
|
+
constructor(onFrame) {
|
|
2092
|
+
this.onFrame = onFrame;
|
|
2093
|
+
}
|
|
2094
|
+
push(chunk) {
|
|
2095
|
+
this.buffer = Buffer.concat([this.buffer, chunk]);
|
|
2096
|
+
while (this.buffer.length >= 5) {
|
|
2097
|
+
const kind = this.buffer[0], length = this.buffer.readUInt32BE(1);
|
|
2098
|
+
if (![0, 1].includes(kind)) throw new Error("Unknown frame kind");
|
|
2099
|
+
if (length > (kind === 0 ? JSON_LIMIT : BINARY_LIMIT + 1024)) throw new Error("Frame exceeds limit");
|
|
2100
|
+
if (this.buffer.length < length + 5) return;
|
|
2101
|
+
const payload = this.buffer.subarray(5, length + 5);
|
|
2102
|
+
this.buffer = this.buffer.subarray(length + 5);
|
|
2103
|
+
if (kind === 0) this.onFrame({ kind, message: JSON.parse(payload.toString("utf8")) });
|
|
2104
|
+
else {
|
|
2105
|
+
if (payload.length < 2) throw new Error("Invalid binary frame");
|
|
2106
|
+
const size = payload.readUInt16BE(0);
|
|
2107
|
+
if (!size || size + 2 > payload.length) throw new Error("Invalid binary channel");
|
|
2108
|
+
const channel = protocolName(new TextDecoder("utf-8", { fatal: true }).decode(payload.subarray(2, 2 + size)));
|
|
2109
|
+
this.onFrame({ kind, channel, data: payload.subarray(2 + size) });
|
|
2110
|
+
}
|
|
2111
|
+
}
|
|
2112
|
+
}
|
|
2113
|
+
};
|
|
2114
|
+
var JsonLineDecoder = class {
|
|
2115
|
+
buffer = Buffer.alloc(0);
|
|
2116
|
+
constructor(onFrame) {
|
|
2117
|
+
this.onFrame = onFrame;
|
|
2118
|
+
}
|
|
2119
|
+
push(chunk) {
|
|
2120
|
+
this.buffer = Buffer.concat([this.buffer, chunk]);
|
|
2121
|
+
let newline;
|
|
2122
|
+
while ((newline = this.buffer.indexOf(10)) !== -1) {
|
|
2123
|
+
if (newline > JSON_LIMIT) throw new Error("JSON line exceeds limit");
|
|
2124
|
+
const line = this.buffer.subarray(0, newline).toString("utf8").trim();
|
|
2125
|
+
this.buffer = this.buffer.subarray(newline + 1);
|
|
2126
|
+
if (line) this.onFrame({ kind: 0, message: JSON.parse(line) });
|
|
2127
|
+
}
|
|
2128
|
+
if (this.buffer.length > JSON_LIMIT) throw new Error("JSON line exceeds limit");
|
|
2129
|
+
}
|
|
2130
|
+
};
|
|
2131
|
+
var Sidecar = class extends EventEmitter {
|
|
2132
|
+
pending = /* @__PURE__ */ new Map();
|
|
2133
|
+
sequence = 0;
|
|
2134
|
+
state = "stopped";
|
|
2135
|
+
constructor({ executable, args = [], cwd, manifest, transport }) {
|
|
2136
|
+
super();
|
|
2137
|
+
Object.assign(this, { executable, args, cwd, manifest });
|
|
2138
|
+
this.transport = transport || manifest.entrypoints?.backend?.transport || "stdio-jsonl";
|
|
2139
|
+
}
|
|
2140
|
+
async start() {
|
|
2141
|
+
if (!this.executable) {
|
|
2142
|
+
this.state = "frontend";
|
|
2143
|
+
this.emit("status", this.state);
|
|
2144
|
+
return null;
|
|
2145
|
+
}
|
|
2146
|
+
if (this.child) throw new Error("Sidecar is already running");
|
|
2147
|
+
this.state = "starting";
|
|
2148
|
+
this.emit("status", this.state);
|
|
2149
|
+
const child = spawn2(this.executable, this.args, { cwd: this.cwd, stdio: ["pipe", "pipe", "pipe"], detached: process.platform !== "win32" });
|
|
2150
|
+
this.child = child;
|
|
2151
|
+
const Decoder = this.transport === "stdio-framed" ? FrameDecoder : JsonLineDecoder;
|
|
2152
|
+
const decoder = new Decoder((packet) => {
|
|
2153
|
+
if (packet.kind === 1) return this.emit("binary", { channel: packet.channel, dataBase64: packet.data.toString("base64") });
|
|
2154
|
+
const message = packet.message;
|
|
2155
|
+
if (message.jsonrpc !== "2.0") throw new Error("Invalid JSON-RPC message");
|
|
2156
|
+
if (message.id !== void 0) {
|
|
2157
|
+
const waiter = this.pending.get(message.id);
|
|
2158
|
+
if (!waiter) return;
|
|
2159
|
+
this.pending.delete(message.id);
|
|
2160
|
+
clearTimeout(waiter.timer);
|
|
2161
|
+
if (message.error) waiter.reject(Object.assign(new Error(message.error.message || "Sidecar error"), { rpc: message.error }));
|
|
2162
|
+
else waiter.resolve(message.result);
|
|
2163
|
+
} else if (message.method) this.emit("event", { method: protocolName(message.method), params: message.params });
|
|
2164
|
+
});
|
|
2165
|
+
child.stdout.on("data", (chunk) => {
|
|
2166
|
+
try {
|
|
2167
|
+
decoder.push(chunk);
|
|
2168
|
+
} catch {
|
|
2169
|
+
this.emit("diagnostic", { level: "error", message: "\u540E\u7AEF\u534F\u8BAE\u89E3\u6790\u5931\u8D25", details: { reason: "invalid-frame" } });
|
|
2170
|
+
this.fail("Invalid sidecar frame");
|
|
2171
|
+
child.kill();
|
|
2172
|
+
}
|
|
2173
|
+
});
|
|
2174
|
+
child.stderr.resume();
|
|
2175
|
+
child.on("error", () => this.fail("Cannot start sidecar executable"));
|
|
2176
|
+
child.stdin.on("error", () => this.fail("Sidecar input closed"));
|
|
2177
|
+
child.on("exit", (code) => {
|
|
2178
|
+
this.emit("diagnostic", { level: this.state === "stopping" ? "info" : "error", message: "\u540E\u7AEF\u8FDB\u7A0B\u9000\u51FA", details: { exitCode: code } });
|
|
2179
|
+
this.child = void 0;
|
|
2180
|
+
this.cleanup = stopProcessTree(child);
|
|
2181
|
+
if (this.state !== "stopping") this.fail("Sidecar exited");
|
|
2182
|
+
else {
|
|
2183
|
+
this.state = "stopped";
|
|
2184
|
+
this.emit("status", this.state);
|
|
2185
|
+
}
|
|
2186
|
+
});
|
|
2187
|
+
try {
|
|
2188
|
+
const info = await this.request("plugin/initialize", { host: { protocolVersions: [1] } }, 1e4);
|
|
2189
|
+
if (info?.protocolVersion !== 1 || info?.plugin?.id !== this.manifest.id || info?.plugin?.version !== this.manifest.version) {
|
|
2190
|
+
throw new Error("Sidecar identity or protocol does not match manifest");
|
|
2191
|
+
}
|
|
2192
|
+
this.state = "ready";
|
|
2193
|
+
this.emit("status", this.state);
|
|
2194
|
+
return info;
|
|
2195
|
+
} catch (error) {
|
|
2196
|
+
await this.stop();
|
|
2197
|
+
this.fail(error.message);
|
|
2198
|
+
throw error;
|
|
2199
|
+
}
|
|
2200
|
+
}
|
|
2201
|
+
fail(message, state = "failed") {
|
|
2202
|
+
this.state = state;
|
|
2203
|
+
for (const waiter of this.pending.values()) {
|
|
2204
|
+
clearTimeout(waiter.timer);
|
|
2205
|
+
waiter.reject(new Error(message));
|
|
2206
|
+
}
|
|
2207
|
+
this.pending.clear();
|
|
2208
|
+
this.emit("status", this.state);
|
|
2209
|
+
}
|
|
2210
|
+
write(kind, payload) {
|
|
2211
|
+
if (!this.executable) return Promise.reject(new Error("This plugin has no backend"));
|
|
2212
|
+
if (kind === 1 && this.transport !== "stdio-framed") return Promise.reject(new Error("Binary channels require stdio-framed transport"));
|
|
2213
|
+
if (!this.child || !["starting", "ready"].includes(this.state)) return Promise.reject(new Error("Sidecar is not ready"));
|
|
2214
|
+
if (kind === 0 && payload.length > JSON_LIMIT) return Promise.reject(new Error("JSON payload exceeds limit"));
|
|
2215
|
+
if (this.child.stdin.writableLength > 16 * 1024 * 1024) return Promise.reject(new Error("Sidecar input is busy"));
|
|
2216
|
+
const output = this.transport === "stdio-framed" ? frame(kind, payload) : Buffer.concat([payload, Buffer.from("\n")]);
|
|
2217
|
+
return new Promise((resolve4, reject) => this.child.stdin.write(output, (error) => error ? reject(new Error("Sidecar write failed")) : resolve4()));
|
|
2218
|
+
}
|
|
2219
|
+
request(method, params = null, timeoutMs = 3e4) {
|
|
2220
|
+
protocolName(method);
|
|
2221
|
+
if (!Number.isInteger(timeoutMs) || timeoutMs < 1 || timeoutMs > 3e5) throw new Error("Invalid request timeout");
|
|
2222
|
+
if (this.pending.size >= 256) return Promise.reject(new Error("Too many pending requests"));
|
|
2223
|
+
const id = ++this.sequence;
|
|
2224
|
+
const started = performance.now();
|
|
2225
|
+
this.emit("diagnostic", { level: "debug", message: "RPC \u5F00\u59CB", details: { requestId: id, method, transport: this.transport, params } });
|
|
2226
|
+
return new Promise((resolve4, reject) => {
|
|
2227
|
+
const timer = setTimeout(() => {
|
|
2228
|
+
this.pending.delete(id);
|
|
2229
|
+
reject(new Error("Sidecar request timed out; operation may still be running"));
|
|
2230
|
+
}, timeoutMs);
|
|
2231
|
+
this.pending.set(id, { resolve: resolve4, reject, timer });
|
|
2232
|
+
this.write(0, Buffer.from(JSON.stringify({ jsonrpc: "2.0", id, method, params }))).catch((error) => {
|
|
2233
|
+
clearTimeout(timer);
|
|
2234
|
+
this.pending.delete(id);
|
|
2235
|
+
reject(error);
|
|
2236
|
+
});
|
|
2237
|
+
}).then(
|
|
2238
|
+
(result) => {
|
|
2239
|
+
this.emit("diagnostic", { level: "debug", message: "RPC \u5B8C\u6210", details: { requestId: id, method, result, durationMs: Math.round(performance.now() - started) } });
|
|
2240
|
+
return result;
|
|
2241
|
+
},
|
|
2242
|
+
(error) => {
|
|
2243
|
+
const reason = error.message.startsWith("Sidecar request timed out") ? "timeout" : error.rpc ? "backend-error" : "transport-error";
|
|
2244
|
+
this.emit("diagnostic", { level: "error", message: "RPC \u5931\u8D25", details: { requestId: id, method, reason, error: error.rpc ? { code: error.rpc.code, data: error.rpc.data } : { reason }, durationMs: Math.round(performance.now() - started) } });
|
|
2245
|
+
throw error;
|
|
2246
|
+
}
|
|
2247
|
+
);
|
|
2248
|
+
}
|
|
2249
|
+
notify(method, params) {
|
|
2250
|
+
return this.write(0, Buffer.from(JSON.stringify({ jsonrpc: "2.0", method: protocolName(method), params })));
|
|
2251
|
+
}
|
|
2252
|
+
sendBinary(channel, data) {
|
|
2253
|
+
return this.write(1, binaryPayload(channel, data));
|
|
2254
|
+
}
|
|
2255
|
+
async stop() {
|
|
2256
|
+
const child = this.child;
|
|
2257
|
+
if (!child) {
|
|
2258
|
+
await this.cleanup;
|
|
2259
|
+
return;
|
|
2260
|
+
}
|
|
2261
|
+
if (!child.pid) {
|
|
2262
|
+
this.child = void 0;
|
|
2263
|
+
this.state = "stopped";
|
|
2264
|
+
return;
|
|
2265
|
+
}
|
|
2266
|
+
this.fail("Sidecar stopped", "stopping");
|
|
2267
|
+
if (process.platform !== "win32") child.stdin.end();
|
|
2268
|
+
await stopProcessTree(child);
|
|
2269
|
+
await this.cleanup;
|
|
2270
|
+
}
|
|
2271
|
+
};
|
|
2272
|
+
|
|
2273
|
+
// ../../plugins/sdk/dev-host/connections.mjs
|
|
2274
|
+
import { mkdir, readFile, writeFile, rename, chmod, lstat } from "node:fs/promises";
|
|
2275
|
+
import { join } from "node:path";
|
|
2276
|
+
import { randomUUID } from "node:crypto";
|
|
2277
|
+
function providerFor(manifest, id) {
|
|
2278
|
+
const provider = manifest.contributions?.find((c) => c.type === "connection-provider" && c.id === id);
|
|
2279
|
+
if (!provider) throw new Error("Unknown connection provider");
|
|
2280
|
+
return provider;
|
|
2281
|
+
}
|
|
2282
|
+
function binding(field) {
|
|
2283
|
+
return field.binding || (field.type === "password" ? "secret" : "config");
|
|
2284
|
+
}
|
|
2285
|
+
function validateRecord(manifest, record, required = true) {
|
|
2286
|
+
if (!record || typeof record !== "object" || Array.isArray(record)) throw new Error("Invalid connection record");
|
|
2287
|
+
if (record.id !== void 0 && (typeof record.id !== "string" || !/^[a-zA-Z0-9_.-]{1,128}$/.test(record.id))) throw new Error("Invalid connection ID");
|
|
2288
|
+
const provider = providerFor(manifest, record.providerId);
|
|
2289
|
+
if (!record.values || typeof record.values !== "object" || Array.isArray(record.values)) throw new Error("Invalid connection fields");
|
|
2290
|
+
if (Object.keys(record.values).some((key) => !provider.fields.some((f) => f.key === key))) throw new Error("Unknown connection field");
|
|
2291
|
+
const values = {};
|
|
2292
|
+
for (const f of provider.fields) {
|
|
2293
|
+
const value = record.values[f.key] ?? f.default;
|
|
2294
|
+
const empty = value === void 0 || value === null || value === "";
|
|
2295
|
+
if (empty) {
|
|
2296
|
+
if (required && f.required) throw new Error(`Missing field: ${f.key}`);
|
|
2297
|
+
continue;
|
|
2298
|
+
}
|
|
2299
|
+
if (f.type === "number" ? typeof value !== "number" || !Number.isFinite(value) : f.type === "boolean" ? typeof value !== "boolean" : typeof value !== "string") {
|
|
2300
|
+
throw new Error(`Invalid field type: ${f.key}`);
|
|
2301
|
+
}
|
|
2302
|
+
if (f.type === "select" && !f.options?.some((option) => option.value === value)) throw new Error(`Invalid option: ${f.key}`);
|
|
2303
|
+
if (binding(f) === "port" && (!Number.isInteger(value) || value < 0 || value > 65535)) throw new Error("Port must be between 0 and 65535");
|
|
2304
|
+
Object.defineProperty(values, f.key, { enumerable: true, configurable: true, writable: true, value });
|
|
2305
|
+
}
|
|
2306
|
+
if (record.readOnly !== void 0 && typeof record.readOnly !== "boolean") throw new Error("Invalid read-only value");
|
|
2307
|
+
return { id: record.id || randomUUID(), providerId: provider.id, values, readOnly: record.readOnly || false };
|
|
2308
|
+
}
|
|
2309
|
+
function lifecyclePayload(manifest, record) {
|
|
2310
|
+
const provider = providerFor(manifest, record.providerId);
|
|
2311
|
+
const c = {
|
|
2312
|
+
id: record.id,
|
|
2313
|
+
db_type: "plugin",
|
|
2314
|
+
plugin_id: manifest.id,
|
|
2315
|
+
plugin_connection_provider: provider.id,
|
|
2316
|
+
plugin_connection_type: provider.database_type,
|
|
2317
|
+
name: provider.label,
|
|
2318
|
+
host: "",
|
|
2319
|
+
port: 0,
|
|
2320
|
+
username: "",
|
|
2321
|
+
external_config: {},
|
|
2322
|
+
connection_secrets: {},
|
|
2323
|
+
read_only: record.readOnly,
|
|
2324
|
+
query_timeout_secs: 60,
|
|
2325
|
+
idle_timeout_secs: 60
|
|
2326
|
+
};
|
|
2327
|
+
for (const f of provider.fields) {
|
|
2328
|
+
const value = record.values[f.key] ?? f.default;
|
|
2329
|
+
if (value === void 0 || value === null) continue;
|
|
2330
|
+
const target = binding(f);
|
|
2331
|
+
if (target === "config") Object.defineProperty(c.external_config, f.key, { value, enumerable: true });
|
|
2332
|
+
else if (target === "secret") Object.defineProperty(c.connection_secrets, f.key, { value: String(value), enumerable: true });
|
|
2333
|
+
else if (["name", "host", "port", "username", "password", "database"].includes(target)) c[target] = value;
|
|
2334
|
+
else throw new Error("Unsupported field binding");
|
|
2335
|
+
}
|
|
2336
|
+
return { provider: { id: provider.id, databaseType: provider.database_type }, connection: c, runtime: null };
|
|
2337
|
+
}
|
|
2338
|
+
function summary(manifest, record) {
|
|
2339
|
+
const provider = providerFor(manifest, record.providerId);
|
|
2340
|
+
const name = provider.fields.find((f) => binding(f) === "name");
|
|
2341
|
+
return { id: record.id, providerId: record.providerId, name: name ? record.values[name.key] || provider.label : provider.label, label: provider.label };
|
|
2342
|
+
}
|
|
2343
|
+
var ConnectionStore = class {
|
|
2344
|
+
records = [];
|
|
2345
|
+
constructor(directory, manifest) {
|
|
2346
|
+
this.directory = directory;
|
|
2347
|
+
this.manifest = manifest;
|
|
2348
|
+
this.file = join(directory, "connections.json");
|
|
2349
|
+
}
|
|
2350
|
+
async load() {
|
|
2351
|
+
await mkdir(this.directory, { recursive: true, mode: 448 });
|
|
2352
|
+
if ((await lstat(this.directory)).isSymbolicLink()) throw new Error("Data directory cannot be a symlink");
|
|
2353
|
+
await chmod(this.directory, 448);
|
|
2354
|
+
try {
|
|
2355
|
+
if ((await lstat(this.file)).isSymbolicLink()) throw new Error("Connection store cannot be a symlink");
|
|
2356
|
+
const stored = JSON.parse(await readFile(this.file, "utf8"));
|
|
2357
|
+
if (stored.pluginId !== this.manifest.id || stored.version !== 1 || !Array.isArray(stored.connections)) throw new Error("Invalid connection store");
|
|
2358
|
+
this.records = stored.connections.map((r) => validateRecord(this.manifest, r, false));
|
|
2359
|
+
if (new Set(this.records.map((r) => r.id)).size !== this.records.length) throw new Error("Duplicate connection IDs");
|
|
2360
|
+
await chmod(this.file, 384);
|
|
2361
|
+
} catch (error) {
|
|
2362
|
+
if (error.code !== "ENOENT") throw error;
|
|
2363
|
+
}
|
|
2364
|
+
}
|
|
2365
|
+
get(id) {
|
|
2366
|
+
const record = this.records.find((r) => r.id === id);
|
|
2367
|
+
if (!record) throw new Error("Connection not found");
|
|
2368
|
+
return structuredClone(record);
|
|
2369
|
+
}
|
|
2370
|
+
async replace(records) {
|
|
2371
|
+
const next = records.map((r) => validateRecord(this.manifest, r, false));
|
|
2372
|
+
const temporary = join(this.directory, `.connections-${randomUUID()}.tmp`);
|
|
2373
|
+
await writeFile(temporary, JSON.stringify({ version: 1, pluginId: this.manifest.id, connections: next }, null, 2), { mode: 384, flag: "wx" });
|
|
2374
|
+
await rename(temporary, this.file);
|
|
2375
|
+
this.records = next;
|
|
2376
|
+
}
|
|
2377
|
+
};
|
|
2378
|
+
|
|
2379
|
+
// ../../plugins/sdk/dev-host/assets.mjs
|
|
2380
|
+
import { readFile as readFile2, realpath, stat } from "node:fs/promises";
|
|
2381
|
+
import { resolve, relative, isAbsolute, extname } from "node:path";
|
|
2382
|
+
async function readAsset(root, path) {
|
|
2383
|
+
if (typeof path !== "string" || !path || path.includes("\0") || isAbsolute(path)) throw new Error("Invalid asset path");
|
|
2384
|
+
const base = await realpath(root), file = await realpath(resolve(base, path));
|
|
2385
|
+
const rel = relative(base, file);
|
|
2386
|
+
if (rel.startsWith("..") || isAbsolute(rel)) throw new Error("Asset is outside UI root");
|
|
2387
|
+
const info = await stat(file);
|
|
2388
|
+
if (!info.isFile() || info.size > 8 * 1024 * 1024) throw new Error("Asset exceeds limit or is not a file");
|
|
2389
|
+
const types = { ".html": "text/html", ".js": "text/javascript", ".css": "text/css", ".json": "application/json", ".png": "image/png", ".jpg": "image/jpeg", ".jpeg": "image/jpeg", ".gif": "image/gif", ".webp": "image/webp", ".svg": "image/svg+xml", ".woff2": "font/woff2" };
|
|
2390
|
+
return { dataBase64: (await readFile2(file)).toString("base64"), contentType: types[extname(file)] || "application/octet-stream" };
|
|
2391
|
+
}
|
|
2392
|
+
|
|
2393
|
+
// ../../plugins/sdk/dev-host/browser-bridge.mjs
|
|
2394
|
+
function installBridge(channel) {
|
|
2395
|
+
let sequence = 0, context = {}, locale = "zh-CN", theme;
|
|
2396
|
+
const pending = /* @__PURE__ */ new Map(), listeners = { context: /* @__PURE__ */ new Set(), init: /* @__PURE__ */ new Set(), event: /* @__PURE__ */ new Set(), binary: /* @__PURE__ */ new Set() };
|
|
2397
|
+
let resolveReady;
|
|
2398
|
+
const ready = new Promise((resolve4) => {
|
|
2399
|
+
resolveReady = resolve4;
|
|
2400
|
+
});
|
|
2401
|
+
let initialized = false;
|
|
2402
|
+
const readyTimer = setInterval(() => {
|
|
2403
|
+
if (!initialized) parent.postMessage({ source: "dbx-plugin", version: 1, channel, type: "ready" }, "*");
|
|
2404
|
+
}, 200);
|
|
2405
|
+
const encode = (input) => {
|
|
2406
|
+
const data = input instanceof Uint8Array ? input : new Uint8Array(input);
|
|
2407
|
+
let result = "";
|
|
2408
|
+
for (let i = 0; i < data.length; i += 8192) result += String.fromCharCode(...data.subarray(i, i + 8192));
|
|
2409
|
+
return btoa(result);
|
|
2410
|
+
};
|
|
2411
|
+
const decode = (value) => Uint8Array.from(atob(value), (c) => c.charCodeAt(0));
|
|
2412
|
+
const request = (method, params) => new Promise((resolve4, reject) => {
|
|
2413
|
+
const id = ++sequence;
|
|
2414
|
+
const timer = setTimeout(() => {
|
|
2415
|
+
pending.delete(id);
|
|
2416
|
+
reject(new Error("Mock host request timed out"));
|
|
2417
|
+
}, 31e4);
|
|
2418
|
+
pending.set(id, { resolve: resolve4, reject, timer });
|
|
2419
|
+
parent.postMessage({ source: "dbx-plugin", version: 1, channel, type: "request", id, method, params }, "*");
|
|
2420
|
+
});
|
|
2421
|
+
const listen = (kind, callback) => {
|
|
2422
|
+
listeners[kind].add(callback);
|
|
2423
|
+
return () => listeners[kind].delete(callback);
|
|
2424
|
+
};
|
|
2425
|
+
function applyTheme(value) {
|
|
2426
|
+
if (!value) return;
|
|
2427
|
+
theme = value;
|
|
2428
|
+
document.documentElement.dataset.dbxTheme = value.appearance;
|
|
2429
|
+
for (const [name, token] of Object.entries(value.tokens || {})) {
|
|
2430
|
+
if (/^--[a-z0-9-]+$/i.test(name) && typeof token === "string") document.documentElement.style.setProperty(name, token);
|
|
2431
|
+
}
|
|
2432
|
+
}
|
|
2433
|
+
window.dbxPlugin = Object.freeze({
|
|
2434
|
+
ready,
|
|
2435
|
+
get context() {
|
|
2436
|
+
return context;
|
|
2437
|
+
},
|
|
2438
|
+
get locale() {
|
|
2439
|
+
return locale;
|
|
2440
|
+
},
|
|
2441
|
+
get theme() {
|
|
2442
|
+
return theme;
|
|
2443
|
+
},
|
|
2444
|
+
request,
|
|
2445
|
+
invoke: (method, params, options = {}) => request("backend.invoke", { method, params, timeoutMs: options.timeoutMs }),
|
|
2446
|
+
notify: (method, params) => request("backend.notify", { method, params }),
|
|
2447
|
+
sendBinary: (channel2, data) => request("backend.sendBinary", { channel: channel2, dataBase64: typeof data === "string" ? data : encode(data) }),
|
|
2448
|
+
readAsset: (path) => request("ui.readAsset", { path }),
|
|
2449
|
+
readAssetUrl: async (path) => {
|
|
2450
|
+
const asset = await request("ui.readAsset", { path });
|
|
2451
|
+
return URL.createObjectURL(new Blob([decode(asset.dataBase64)], { type: asset.contentType }));
|
|
2452
|
+
},
|
|
2453
|
+
openWorkbench: (contributionId, context2) => request("host.openWorkbench", { contributionId, context: context2 }),
|
|
2454
|
+
openFilesystem: (providerId, context2) => request("host.openFilesystem", { providerId, context: context2 }),
|
|
2455
|
+
onContext: (fn) => listen("context", fn),
|
|
2456
|
+
onEvent: (fn) => listen("event", fn),
|
|
2457
|
+
onBinary: (fn) => listen("binary", fn),
|
|
2458
|
+
onInit: (fn) => {
|
|
2459
|
+
const off = listen("init", fn);
|
|
2460
|
+
if (initialized) fn(context);
|
|
2461
|
+
return off;
|
|
2462
|
+
},
|
|
2463
|
+
encodeBase64: encode,
|
|
2464
|
+
decodeBase64: decode
|
|
2465
|
+
});
|
|
2466
|
+
addEventListener("message", (event) => {
|
|
2467
|
+
const m = event.data;
|
|
2468
|
+
if (event.source !== parent || m?.source !== "dbx-host" || m.channel !== channel || m.version !== 1) return;
|
|
2469
|
+
if (m.type === "init") {
|
|
2470
|
+
initialized = true;
|
|
2471
|
+
clearInterval(readyTimer);
|
|
2472
|
+
context = m.context || {};
|
|
2473
|
+
locale = m.locale || "zh-CN";
|
|
2474
|
+
applyTheme(m.theme);
|
|
2475
|
+
resolveReady(context);
|
|
2476
|
+
for (const fn of listeners.init) fn(context);
|
|
2477
|
+
dispatchEvent(new CustomEvent("dbx-plugin-init", { detail: m }));
|
|
2478
|
+
}
|
|
2479
|
+
if (m.type === "context") {
|
|
2480
|
+
context = m.context || {};
|
|
2481
|
+
for (const fn of listeners.context) fn(context);
|
|
2482
|
+
dispatchEvent(new CustomEvent("dbx-plugin-context", { detail: context }));
|
|
2483
|
+
}
|
|
2484
|
+
if (m.type === "env") {
|
|
2485
|
+
locale = m.locale || locale;
|
|
2486
|
+
applyTheme(m.theme);
|
|
2487
|
+
for (const fn of listeners.event) fn(m);
|
|
2488
|
+
dispatchEvent(new CustomEvent("dbx-plugin-env", { detail: m }));
|
|
2489
|
+
}
|
|
2490
|
+
if (m.type === "event") {
|
|
2491
|
+
for (const fn of listeners.event) fn(m);
|
|
2492
|
+
dispatchEvent(new CustomEvent("dbx-plugin-event", { detail: m }));
|
|
2493
|
+
}
|
|
2494
|
+
if (m.type === "binary") {
|
|
2495
|
+
const payload = { channel: m.binaryChannel, data: decode(m.dataBase64) };
|
|
2496
|
+
for (const fn of listeners.binary) fn(payload);
|
|
2497
|
+
dispatchEvent(new CustomEvent("dbx-plugin-binary", { detail: payload }));
|
|
2498
|
+
}
|
|
2499
|
+
if (m.type === "response") {
|
|
2500
|
+
const waiter = pending.get(m.id);
|
|
2501
|
+
if (!waiter) return;
|
|
2502
|
+
pending.delete(m.id);
|
|
2503
|
+
clearTimeout(waiter.timer);
|
|
2504
|
+
if (m.error) waiter.reject(Object.assign(new Error(m.error.message || "Host request failed"), { code: m.error.code, data: m.error.data }));
|
|
2505
|
+
else waiter.resolve(m.result);
|
|
2506
|
+
}
|
|
2507
|
+
});
|
|
2508
|
+
}
|
|
2509
|
+
function sandboxDocument(html, channel) {
|
|
2510
|
+
const csp = `<meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src 'unsafe-inline' blob:; style-src 'unsafe-inline' blob:; img-src data: blob:; font-src data: blob:; media-src data: blob:; connect-src 'none';">`;
|
|
2511
|
+
const bootstrap = `<script>(${installBridge.toString()})(${JSON.stringify(channel)});</script>`;
|
|
2512
|
+
if (/<head\b[^>]*>/i.test(html)) return html.replace(/<head\b[^>]*>/i, (match) => match + csp + bootstrap);
|
|
2513
|
+
return `<!doctype html><html><head>${csp}${bootstrap}</head><body>${html}</body></html>`;
|
|
2514
|
+
}
|
|
2515
|
+
|
|
2516
|
+
// ../../plugins/sdk/dev-host/diagnostics.mjs
|
|
2517
|
+
import { EventEmitter as EventEmitter2 } from "node:events";
|
|
2518
|
+
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
2519
|
+
var sensitive = /password|passwd|secret|token|authorization|cookie|credential|private.?key|access.?key|api.?key|csrf/i;
|
|
2520
|
+
function redact(value, secretKeys = /* @__PURE__ */ new Set()) {
|
|
2521
|
+
let budget = 8192, nodes = 0;
|
|
2522
|
+
const seen = /* @__PURE__ */ new WeakSet();
|
|
2523
|
+
function visit(v, key = "", depth = 0) {
|
|
2524
|
+
if (sensitive.test(key) || secretKeys.has(key) || key === "headers" || key === "channel") return "[REDACTED]";
|
|
2525
|
+
if (/base64|binary|^html$/i.test(key)) return "[content omitted]";
|
|
2526
|
+
if (++nodes > 150 || budget <= 0 || depth > 6) return "[truncated]";
|
|
2527
|
+
if (typeof v === "string") {
|
|
2528
|
+
const limit = Math.min(2048, budget), source = v.slice(0, limit);
|
|
2529
|
+
if (/-----BEGIN [^-]*PRIVATE KEY-----/.test(source)) return "[REDACTED]";
|
|
2530
|
+
const safe = source.replace(/(\b[a-z][a-z0-9+.-]{0,30}:\/\/)[^\s/@]+:[^\s/@]+@/gi, "$1[REDACTED]@").replace(/([?&](?:[^=&\s]*(?:token|key|password|secret)[^=&\s]*)=)[^&#\s]*/gi, "$1[REDACTED]");
|
|
2531
|
+
budget -= source.length;
|
|
2532
|
+
return safe + (v.length > limit ? " [truncated]" : "");
|
|
2533
|
+
}
|
|
2534
|
+
if (v === null || typeof v === "boolean" || typeof v === "number") return v;
|
|
2535
|
+
if (typeof v !== "object") return String(v);
|
|
2536
|
+
if (seen.has(v)) return "[circular]";
|
|
2537
|
+
seen.add(v);
|
|
2538
|
+
if (Array.isArray(v))
|
|
2539
|
+
return v.slice(0, 40).map((item) => visit(item, "", depth + 1)).concat(v.length > 40 ? ["[truncated]"] : []);
|
|
2540
|
+
return Object.fromEntries(
|
|
2541
|
+
Object.entries(v).slice(0, 40).map(([k, item]) => [k.slice(0, 128), visit(item, k, depth + 1)])
|
|
2542
|
+
);
|
|
2543
|
+
}
|
|
2544
|
+
return visit(value);
|
|
2545
|
+
}
|
|
2546
|
+
var Diagnostics = class extends EventEmitter2 {
|
|
2547
|
+
instanceId = randomUUID2();
|
|
2548
|
+
entries = [];
|
|
2549
|
+
sequence = 0;
|
|
2550
|
+
secretKeys = /* @__PURE__ */ new Set();
|
|
2551
|
+
context = {};
|
|
2552
|
+
constructor(output = (line) => console.log(line)) {
|
|
2553
|
+
super();
|
|
2554
|
+
this.output = output;
|
|
2555
|
+
}
|
|
2556
|
+
record(level, category, message, details = {}) {
|
|
2557
|
+
const safe = { ...this.context };
|
|
2558
|
+
for (const key of ["requestId", "status", "durationMs", "bytes", "port", "exitCode"]) {
|
|
2559
|
+
if (Number.isFinite(details[key])) safe[key] = details[key];
|
|
2560
|
+
}
|
|
2561
|
+
for (const key of ["method", "state", "reason", "transport"]) {
|
|
2562
|
+
if (typeof details[key] === "string" && /^[A-Za-z0-9._:/-]{1,256}$/.test(details[key])) safe[key] = details[key];
|
|
2563
|
+
}
|
|
2564
|
+
for (const key of ["path", "project", "uiRoot", "backend", "params", "result", "error"]) {
|
|
2565
|
+
if (details[key] !== void 0) safe[key] = redact(details[key], this.secretKeys);
|
|
2566
|
+
}
|
|
2567
|
+
const entry = { id: ++this.sequence, time: (/* @__PURE__ */ new Date()).toISOString(), level, category, message, details: safe };
|
|
2568
|
+
this.entries.push(entry);
|
|
2569
|
+
if (this.entries.length > 500) this.entries.shift();
|
|
2570
|
+
this.output(`[dbx-dev] ${JSON.stringify(entry)}`);
|
|
2571
|
+
this.emit("entry", entry);
|
|
2572
|
+
return entry;
|
|
2573
|
+
}
|
|
2574
|
+
snapshot() {
|
|
2575
|
+
return structuredClone(this.entries);
|
|
2576
|
+
}
|
|
2577
|
+
query(params) {
|
|
2578
|
+
for (const key of params.keys()) if (!["after", "limit", "level", "instanceId"].includes(key) || params.getAll(key).length !== 1) throw new Error("Invalid diagnostics query");
|
|
2579
|
+
const integer = (key, fallback, max) => {
|
|
2580
|
+
const raw = params.get(key);
|
|
2581
|
+
if (raw === null) return fallback;
|
|
2582
|
+
if (!/^\d+$/.test(raw) || !Number.isSafeInteger(Number(raw)) || Number(raw) > max) throw new Error(`Invalid ${key}`);
|
|
2583
|
+
return Number(raw);
|
|
2584
|
+
};
|
|
2585
|
+
const after = integer("after", 0, Number.MAX_SAFE_INTEGER), limit = integer("limit", 100, 500);
|
|
2586
|
+
const level = params.get("level");
|
|
2587
|
+
if (limit < 1 || level && !["debug", "info", "error"].includes(level)) throw new Error("Invalid diagnostics filter");
|
|
2588
|
+
const reset = !!(params.get("instanceId") && params.get("instanceId") !== this.instanceId) || after > this.sequence;
|
|
2589
|
+
const cursor = reset ? 0 : after, oldestId = this.entries[0]?.id || 0;
|
|
2590
|
+
const matched = this.entries.filter((e) => e.id > cursor && (!level || e.level === level));
|
|
2591
|
+
const entries = matched.slice(0, limit), hasMore = matched.length > limit;
|
|
2592
|
+
return { instanceId: this.instanceId, entries: structuredClone(entries), nextAfter: hasMore ? entries.at(-1).id : this.sequence, hasMore, reset, truncated: oldestId > cursor + 1, oldestId, latestId: this.sequence };
|
|
2593
|
+
}
|
|
2594
|
+
};
|
|
2595
|
+
|
|
2596
|
+
// ../../plugins/sdk/dev-host/auto-reload.mjs
|
|
2597
|
+
var AutoReload = class {
|
|
2598
|
+
enabled = false;
|
|
2599
|
+
running = false;
|
|
2600
|
+
pending = false;
|
|
2601
|
+
timer;
|
|
2602
|
+
constructor(action, delay2 = 500) {
|
|
2603
|
+
this.action = action;
|
|
2604
|
+
this.delay = delay2;
|
|
2605
|
+
}
|
|
2606
|
+
enable(value) {
|
|
2607
|
+
this.enabled = value;
|
|
2608
|
+
if (!value) {
|
|
2609
|
+
clearTimeout(this.timer);
|
|
2610
|
+
this.pending = false;
|
|
2611
|
+
}
|
|
2612
|
+
}
|
|
2613
|
+
changed() {
|
|
2614
|
+
if (!this.enabled) return;
|
|
2615
|
+
this.pending = true;
|
|
2616
|
+
clearTimeout(this.timer);
|
|
2617
|
+
this.timer = setTimeout(() => void this.flush(), this.delay);
|
|
2618
|
+
}
|
|
2619
|
+
async flush() {
|
|
2620
|
+
if (!this.enabled || !this.pending || this.running) return;
|
|
2621
|
+
this.pending = false;
|
|
2622
|
+
this.running = true;
|
|
2623
|
+
try {
|
|
2624
|
+
await this.action();
|
|
2625
|
+
} finally {
|
|
2626
|
+
this.running = false;
|
|
2627
|
+
if (this.pending && this.enabled) this.changed();
|
|
2628
|
+
}
|
|
2629
|
+
}
|
|
2630
|
+
};
|
|
2631
|
+
|
|
2632
|
+
// ../../plugins/sdk/dev-host/server.mjs
|
|
2633
|
+
var BRIDGE_LIMIT = 2 * 1024 * 1024;
|
|
2634
|
+
var UI_BINARY_LIMIT = 8 * 1024 * 1024;
|
|
2635
|
+
function jsonSize(value) {
|
|
2636
|
+
return Buffer.byteLength(JSON.stringify(value) ?? "null");
|
|
2637
|
+
}
|
|
2638
|
+
function requirePermission(manifest, permission) {
|
|
2639
|
+
if (!manifest.permissions?.includes(permission)) throw new Error(`Plugin permission required: ${permission}`);
|
|
2640
|
+
}
|
|
2641
|
+
function ensureSucceeded(result) {
|
|
2642
|
+
if (result?.success === false) throw new Error(result.message || "Plugin connection operation failed");
|
|
2643
|
+
}
|
|
2644
|
+
function pageId(value = "legacy") {
|
|
2645
|
+
if (typeof value !== "string" || !/^[a-zA-Z0-9-]{1,64}$/.test(value)) throw new Error("Invalid page ID");
|
|
2646
|
+
return value;
|
|
2647
|
+
}
|
|
2648
|
+
async function createMockHost(options) {
|
|
2649
|
+
const diagnostics = options.diagnostics || new Diagnostics();
|
|
2650
|
+
const project = resolve2(options.project), manifest = JSON.parse(await readFile3(resolve2(project, "manifest.json"), "utf8"));
|
|
2651
|
+
for (const contribution of manifest.contributions || [])
|
|
2652
|
+
for (const field of contribution.fields || []) {
|
|
2653
|
+
if (field.type === "password" || ["password", "secret"].includes(field.binding)) diagnostics.secretKeys.add(field.key);
|
|
2654
|
+
}
|
|
2655
|
+
if (manifest.manifest_version !== void 0 && manifest.manifest_version !== 1) throw new Error("Unsupported manifest version");
|
|
2656
|
+
if (manifest.engines?.host_api && !import_semver.default.satisfies("1.0.0", manifest.engines.host_api.replaceAll(",", " "))) throw new Error("Plugin does not support Host API 1.0.0");
|
|
2657
|
+
const backendEntry = manifest.entrypoints?.backend;
|
|
2658
|
+
const transport = backendEntry?.transport || "stdio-jsonl";
|
|
2659
|
+
if (backendEntry && (!["stdio-framed", "stdio-jsonl"].includes(transport) || !(backendEntry.protocol_versions || [1]).includes(1))) throw new Error("Unsupported backend transport or protocol version");
|
|
2660
|
+
const declaredRoot = resolve2(project, manifest.entrypoints.ui.root || "ui");
|
|
2661
|
+
const uiRoot = resolve2(project, options.uiRoot || declaredRoot);
|
|
2662
|
+
const entry = relative2(declaredRoot, resolve2(project, manifest.entrypoints.ui.entry));
|
|
2663
|
+
await readAsset(uiRoot, entry);
|
|
2664
|
+
const store = new ConnectionStore(resolve2(options.dataDir), manifest);
|
|
2665
|
+
await store.load();
|
|
2666
|
+
const dataRelative = relative2(await realpath2(uiRoot), await realpath2(store.directory));
|
|
2667
|
+
if (!dataRelative || !isAbsolute2(dataRelative) && dataRelative !== ".." && !dataRelative.startsWith(`..${sep}`)) {
|
|
2668
|
+
throw new Error("Development data directory must be outside the UI resource root");
|
|
2669
|
+
}
|
|
2670
|
+
if (backendEntry && !options.backend) throw new Error("Backend executable is required");
|
|
2671
|
+
const sidecar = new Sidecar({ executable: backendEntry ? resolve2(project, options.backend) : void 0, args: options.backendArgs || [], cwd: project, manifest, transport });
|
|
2672
|
+
const connected = /* @__PURE__ */ new Set(), frames = /* @__PURE__ */ new Map(), sessions = /* @__PURE__ */ new Map(), streams = /* @__PURE__ */ new Set();
|
|
2673
|
+
const pages = /* @__PURE__ */ new Map();
|
|
2674
|
+
let revision = 0, restarting = false, closing = false, origin, cookieName;
|
|
2675
|
+
let lifecycleQueue = Promise.resolve();
|
|
2676
|
+
const serialize = (action) => {
|
|
2677
|
+
const task = lifecycleQueue.then(action);
|
|
2678
|
+
lifecycleQueue = task.catch(() => {
|
|
2679
|
+
});
|
|
2680
|
+
return task;
|
|
2681
|
+
};
|
|
2682
|
+
let autoReload = false;
|
|
2683
|
+
const backendReload = new AutoReload(async () => {
|
|
2684
|
+
try {
|
|
2685
|
+
await serialize(async () => {
|
|
2686
|
+
if (autoReload && !closing) await restartBackend();
|
|
2687
|
+
});
|
|
2688
|
+
} catch {
|
|
2689
|
+
broadcast("auto-reload-error", {});
|
|
2690
|
+
}
|
|
2691
|
+
});
|
|
2692
|
+
const broadcast = (type, payload) => {
|
|
2693
|
+
const message = `data: ${JSON.stringify({ type, ...payload })}
|
|
2694
|
+
|
|
2695
|
+
`;
|
|
2696
|
+
for (const stream of streams) {
|
|
2697
|
+
if (stream.writableLength > 16 * 1024 * 1024) {
|
|
2698
|
+
stream.destroy();
|
|
2699
|
+
streams.delete(stream);
|
|
2700
|
+
} else stream.write(message);
|
|
2701
|
+
}
|
|
2702
|
+
};
|
|
2703
|
+
const onDiagnostic = (entry2) => broadcast("diagnostic", { entry: entry2 });
|
|
2704
|
+
diagnostics.on("entry", onDiagnostic);
|
|
2705
|
+
sidecar.on("diagnostic", (event) => diagnostics.record(event.level, "rpc", event.message, event.details));
|
|
2706
|
+
sidecar.on("status", (state) => diagnostics.record(state === "failed" ? "error" : "info", "backend", "\u540E\u7AEF\u72B6\u6001\u53D8\u5316", { state, transport }));
|
|
2707
|
+
sidecar.on("event", () => diagnostics.record("debug", "event", "\u6536\u5230\u540E\u7AEF\u4E8B\u4EF6"));
|
|
2708
|
+
sidecar.on("binary", (event) => diagnostics.record("debug", "binary", "\u6536\u5230\u4E8C\u8FDB\u5236\u5E27", { bytes: Buffer.byteLength(event.dataBase64, "base64") }));
|
|
2709
|
+
sidecar.on("status", (state) => {
|
|
2710
|
+
if (state !== "ready") connected.clear();
|
|
2711
|
+
broadcast("status", { state });
|
|
2712
|
+
});
|
|
2713
|
+
sidecar.on("event", (event) => {
|
|
2714
|
+
if (manifest.permissions?.includes("host.events")) broadcast("event", event);
|
|
2715
|
+
});
|
|
2716
|
+
sidecar.on("binary", (event) => {
|
|
2717
|
+
if (manifest.permissions?.includes("host.binary") && event.dataBase64.length <= UI_BINARY_LIMIT / 3 * 4 + 4) broadcast("binary", event);
|
|
2718
|
+
});
|
|
2719
|
+
try {
|
|
2720
|
+
await sidecar.start();
|
|
2721
|
+
} catch (error) {
|
|
2722
|
+
diagnostics.removeListener("entry", onDiagnostic);
|
|
2723
|
+
throw error;
|
|
2724
|
+
}
|
|
2725
|
+
const listing = () => store.records.map((r) => ({ ...summary(manifest, r), connected: connected.has(r.id) }));
|
|
2726
|
+
async function disconnect(id) {
|
|
2727
|
+
if (connected.has(id) && sidecar.state === "ready") {
|
|
2728
|
+
ensureSucceeded(await sidecar.request("connection/disconnect", lifecyclePayload(manifest, store.get(id)), 1e4));
|
|
2729
|
+
}
|
|
2730
|
+
connected.delete(id);
|
|
2731
|
+
}
|
|
2732
|
+
async function connect(record) {
|
|
2733
|
+
if (restarting || sidecar.state !== "ready") throw new Error("Backend is not ready; restart it first");
|
|
2734
|
+
const provider = providerFor(manifest, record.providerId);
|
|
2735
|
+
if (!provider.capabilities?.includes("connect")) throw new Error("Provider does not support connect");
|
|
2736
|
+
validateRecord(manifest, record);
|
|
2737
|
+
if (!connected.has(record.id)) {
|
|
2738
|
+
ensureSucceeded(await sidecar.request("connection/connect", lifecyclePayload(manifest, record), 6e4));
|
|
2739
|
+
connected.add(record.id);
|
|
2740
|
+
}
|
|
2741
|
+
}
|
|
2742
|
+
async function openFrame(session, connectionId, contributionId, suppliedContext) {
|
|
2743
|
+
const record = connectionId ? store.get(connectionId) : void 0;
|
|
2744
|
+
const provider = record ? providerFor(manifest, record.providerId) : void 0;
|
|
2745
|
+
const contribution = manifest.contributions.find((c) => c.id === (contributionId || provider?.workbench) && c.type === "workbench");
|
|
2746
|
+
if (!contribution) throw new Error("Unknown workbench contribution");
|
|
2747
|
+
if (record) await connect(record);
|
|
2748
|
+
const context = record ? { ...suppliedContext, connectionId: record.id, providerId: provider.id, connectionType: provider.database_type } : { ...suppliedContext };
|
|
2749
|
+
const name = record ? summary(manifest, record).name : contribution.label;
|
|
2750
|
+
if (jsonSize(context) > BRIDGE_LIMIT) throw new Error("Context exceeds limit");
|
|
2751
|
+
const existing = [...frames.values()].find((f) => f.session === session.id && f.page === session.page && f.connectionId === connectionId && f.contributionId === contribution.id);
|
|
2752
|
+
if (existing) {
|
|
2753
|
+
existing.context = context;
|
|
2754
|
+
existing.name = name;
|
|
2755
|
+
return expose(existing);
|
|
2756
|
+
}
|
|
2757
|
+
const frame2 = { id: randomUUID3(), channel: randomUUID3(), session: session.id, page: session.page, connectionId, contributionId: contribution.id, context, name };
|
|
2758
|
+
frames.set(frame2.id, frame2);
|
|
2759
|
+
return expose(frame2);
|
|
2760
|
+
}
|
|
2761
|
+
function expose(frame2) {
|
|
2762
|
+
const { session: _session, page: _page, ...safe } = frame2;
|
|
2763
|
+
return structuredClone(safe);
|
|
2764
|
+
}
|
|
2765
|
+
function frameFor(session, id) {
|
|
2766
|
+
const f = frames.get(id);
|
|
2767
|
+
if (!f || f.session !== session.id || f.page !== session.page) throw new Error("Unknown workbench frame");
|
|
2768
|
+
return f;
|
|
2769
|
+
}
|
|
2770
|
+
async function bridge(session, input) {
|
|
2771
|
+
const frame2 = frameFor(session, input.frameId), p = input.params || {};
|
|
2772
|
+
if (input.channel !== frame2.channel) throw new Error("Stale workbench generation");
|
|
2773
|
+
if (input.method !== "backend.sendBinary" && jsonSize(p) > BRIDGE_LIMIT) throw new Error("Bridge request exceeds 2 MiB");
|
|
2774
|
+
switch (input.method) {
|
|
2775
|
+
case "host.getContext":
|
|
2776
|
+
return structuredClone(frame2.context);
|
|
2777
|
+
case "backend.invoke": {
|
|
2778
|
+
if (p.timeoutMs !== void 0 && (typeof p.timeoutMs !== "number" || !Number.isFinite(p.timeoutMs))) throw new Error("Invalid request timeout");
|
|
2779
|
+
const timeout = p.timeoutMs === void 0 ? 3e4 : Math.min(12e4, Math.max(1, Math.round(p.timeoutMs)));
|
|
2780
|
+
return sidecar.request(protocolName(p.method), p.params ?? null, timeout);
|
|
2781
|
+
}
|
|
2782
|
+
case "backend.notify":
|
|
2783
|
+
await sidecar.notify(protocolName(p.method), p.params ?? null);
|
|
2784
|
+
return null;
|
|
2785
|
+
case "backend.sendBinary": {
|
|
2786
|
+
requirePermission(manifest, "host.binary");
|
|
2787
|
+
if (typeof p.dataBase64 !== "string" || p.dataBase64.length > Math.ceil(UI_BINARY_LIMIT / 3) * 4) throw new Error("Invalid base64 or binary exceeds limit");
|
|
2788
|
+
const data = Buffer.from(p.dataBase64, "base64");
|
|
2789
|
+
if (data.toString("base64") !== p.dataBase64) throw new Error("Invalid base64");
|
|
2790
|
+
if (data.length > UI_BINARY_LIMIT) throw new Error("Bridge binary exceeds 8 MiB");
|
|
2791
|
+
await sidecar.sendBinary(p.channel, data);
|
|
2792
|
+
return null;
|
|
2793
|
+
}
|
|
2794
|
+
case "ui.readAsset": {
|
|
2795
|
+
const prefix = (manifest.entrypoints.ui.root || "ui").replace(/\/$/, "") + "/";
|
|
2796
|
+
const path = typeof p.path === "string" && p.path.startsWith(prefix) ? p.path.slice(prefix.length) : p.path;
|
|
2797
|
+
return readAsset(uiRoot, path);
|
|
2798
|
+
}
|
|
2799
|
+
case "host.openWorkbench": {
|
|
2800
|
+
requirePermission(manifest, "host.workbench");
|
|
2801
|
+
return { mockHostOpenFrame: await serialize(() => openFrame(session, p.context?.connectionId || frame2.connectionId, p.contributionId, p.context)) };
|
|
2802
|
+
}
|
|
2803
|
+
default:
|
|
2804
|
+
throw new Error(`Unsupported mock host method: ${input.method}`);
|
|
2805
|
+
}
|
|
2806
|
+
}
|
|
2807
|
+
async function api(session, route, p) {
|
|
2808
|
+
if (route === "/api/bridge") return bridge(session, p);
|
|
2809
|
+
if (route === "/api/frame-document") {
|
|
2810
|
+
const f = frameFor(session, p.frameId);
|
|
2811
|
+
const asset = await readAsset(uiRoot, entry);
|
|
2812
|
+
f.channel = randomUUID3();
|
|
2813
|
+
return { ...expose(f), html: sandboxDocument(Buffer.from(asset.dataBase64, "base64").toString("utf8"), f.channel) };
|
|
2814
|
+
}
|
|
2815
|
+
return serialize(async () => {
|
|
2816
|
+
switch (route) {
|
|
2817
|
+
case "/api/auto-reload": {
|
|
2818
|
+
if (typeof p.enabled !== "boolean") throw new Error("Invalid automatic reload setting");
|
|
2819
|
+
autoReload = p.enabled;
|
|
2820
|
+
backendReload.enable(autoReload);
|
|
2821
|
+
broadcast("auto-reload", { enabled: autoReload });
|
|
2822
|
+
diagnostics.record("info", "build", autoReload ? "\u81EA\u52A8\u91CD\u8F7D\u5DF2\u542F\u7528" : "\u81EA\u52A8\u91CD\u8F7D\u5DF2\u5173\u95ED");
|
|
2823
|
+
return { enabled: autoReload };
|
|
2824
|
+
}
|
|
2825
|
+
case "/api/workbenches/open":
|
|
2826
|
+
return { frame: await openFrame(session, void 0, p.contributionId) };
|
|
2827
|
+
case "/api/connections/edit":
|
|
2828
|
+
return store.get(p.id);
|
|
2829
|
+
case "/api/connections/save": {
|
|
2830
|
+
const existing = p.id ? store.get(p.id) : void 0;
|
|
2831
|
+
const record = validateRecord(manifest, p);
|
|
2832
|
+
if (existing && existing.providerId !== record.providerId) throw new Error("Create a new connection to change its provider");
|
|
2833
|
+
if (existing) await disconnect(existing.id);
|
|
2834
|
+
await store.replace([...store.records.filter((r) => r.id !== record.id), record]);
|
|
2835
|
+
return { connections: listing(), id: record.id };
|
|
2836
|
+
}
|
|
2837
|
+
case "/api/connections/test": {
|
|
2838
|
+
const record = validateRecord(manifest, { ...p, id: randomUUID3() });
|
|
2839
|
+
if (!providerFor(manifest, record.providerId).capabilities?.includes("test")) throw new Error("Provider does not support test");
|
|
2840
|
+
ensureSucceeded(await sidecar.request("connection/test", lifecyclePayload(manifest, record), 6e4));
|
|
2841
|
+
return { message: "\u8FDE\u63A5\u6D4B\u8BD5\u6210\u529F" };
|
|
2842
|
+
}
|
|
2843
|
+
case "/api/connections/connect":
|
|
2844
|
+
return { frame: await openFrame(session, p.id), connections: listing() };
|
|
2845
|
+
case "/api/connections/disconnect":
|
|
2846
|
+
await disconnect(p.id);
|
|
2847
|
+
return { connections: listing() };
|
|
2848
|
+
case "/api/connections/delete": {
|
|
2849
|
+
store.get(p.id);
|
|
2850
|
+
await disconnect(p.id);
|
|
2851
|
+
await store.replace(store.records.filter((r) => r.id !== p.id));
|
|
2852
|
+
for (const f of frames.values()) if (f.connectionId === p.id) frames.delete(f.id);
|
|
2853
|
+
broadcast("frames-removed", { connectionId: p.id });
|
|
2854
|
+
return { connections: listing() };
|
|
2855
|
+
}
|
|
2856
|
+
case "/api/connections/import": {
|
|
2857
|
+
if (!Array.isArray(p.connections) || p.connections.length > 100) throw new Error("Invalid connection import");
|
|
2858
|
+
const imported = p.connections.map((r) => validateRecord(manifest, { ...r, id: randomUUID3() }));
|
|
2859
|
+
await store.replace([...store.records, ...imported]);
|
|
2860
|
+
return { connections: listing() };
|
|
2861
|
+
}
|
|
2862
|
+
case "/api/frames/close": {
|
|
2863
|
+
const f = frameFor(session, p.id);
|
|
2864
|
+
if (f.connectionId && ![...frames.values()].some((other) => other.id !== f.id && other.connectionId === f.connectionId)) await disconnect(f.connectionId);
|
|
2865
|
+
frames.delete(f.id);
|
|
2866
|
+
return { connections: listing() };
|
|
2867
|
+
}
|
|
2868
|
+
case "/api/backend/restart":
|
|
2869
|
+
return restartBackend();
|
|
2870
|
+
default:
|
|
2871
|
+
throw new Error("Unknown mock host endpoint");
|
|
2872
|
+
}
|
|
2873
|
+
});
|
|
2874
|
+
}
|
|
2875
|
+
async function restartBackend() {
|
|
2876
|
+
restarting = true;
|
|
2877
|
+
diagnostics.record("info", "build", "\u5F00\u59CB\u91CD\u5EFA\u540E\u7AEF");
|
|
2878
|
+
try {
|
|
2879
|
+
for (const id of connected) await disconnect(id).catch(() => connected.delete(id));
|
|
2880
|
+
await sidecar.stop();
|
|
2881
|
+
if (options.buildBackend) await options.buildBackend();
|
|
2882
|
+
await sidecar.start();
|
|
2883
|
+
diagnostics.record("info", "build", "\u540E\u7AEF\u91CD\u5EFA\u5B8C\u6210");
|
|
2884
|
+
return { connections: listing(), state: sidecar.state };
|
|
2885
|
+
} catch (error) {
|
|
2886
|
+
diagnostics.record("error", "build", "\u540E\u7AEF\u91CD\u5EFA\u5931\u8D25");
|
|
2887
|
+
throw error;
|
|
2888
|
+
} finally {
|
|
2889
|
+
restarting = false;
|
|
2890
|
+
}
|
|
2891
|
+
}
|
|
2892
|
+
const server = http.createServer(async (request, response) => {
|
|
2893
|
+
const started = performance.now();
|
|
2894
|
+
let route = "unknown", rejection;
|
|
2895
|
+
response.on("finish", () => {
|
|
2896
|
+
if (route === "diagnostics" || route === "events" || route === "bootstrap" && response.statusCode < 400) return;
|
|
2897
|
+
diagnostics.record(response.statusCode >= 400 ? "error" : "debug", "http", "HTTP \u8BF7\u6C42\u5B8C\u6210", {
|
|
2898
|
+
method: route,
|
|
2899
|
+
path: route === "unknown" ? "[unknown route]" : route.startsWith("/") ? route : `/api/${route}`,
|
|
2900
|
+
status: response.statusCode,
|
|
2901
|
+
durationMs: Math.round(performance.now() - started),
|
|
2902
|
+
reason: rejection
|
|
2903
|
+
});
|
|
2904
|
+
});
|
|
2905
|
+
response.setHeader("Cache-Control", "no-store");
|
|
2906
|
+
response.setHeader("X-Content-Type-Options", "nosniff");
|
|
2907
|
+
response.setHeader("Referrer-Policy", "no-referrer");
|
|
2908
|
+
try {
|
|
2909
|
+
if (request.headers.host !== new URL(origin).host) {
|
|
2910
|
+
rejection = "invalid-host";
|
|
2911
|
+
return respond(response, 403, { error: { message: "Invalid Host" } });
|
|
2912
|
+
}
|
|
2913
|
+
if (request.headers["sec-fetch-site"] === "cross-site" || request.headers.origin && request.headers.origin !== origin) {
|
|
2914
|
+
rejection = "invalid-origin";
|
|
2915
|
+
return respond(response, 403, { error: { message: "Invalid Origin" } });
|
|
2916
|
+
}
|
|
2917
|
+
const path = new URL(request.url, origin).pathname;
|
|
2918
|
+
const known = [
|
|
2919
|
+
"/",
|
|
2920
|
+
"/api/bootstrap",
|
|
2921
|
+
"/api/events",
|
|
2922
|
+
"/api/bridge",
|
|
2923
|
+
"/api/frame-document",
|
|
2924
|
+
"/api/workbenches/open",
|
|
2925
|
+
"/api/connections/edit",
|
|
2926
|
+
"/api/connections/save",
|
|
2927
|
+
"/api/connections/test",
|
|
2928
|
+
"/api/connections/connect",
|
|
2929
|
+
"/api/connections/disconnect",
|
|
2930
|
+
"/api/connections/delete",
|
|
2931
|
+
"/api/connections/import",
|
|
2932
|
+
"/api/frames/close",
|
|
2933
|
+
"/api/backend/restart"
|
|
2934
|
+
];
|
|
2935
|
+
route = known.includes(path) ? path.replace("/api/", "") || "/" : "unknown";
|
|
2936
|
+
if (path === "/api/diagnostics") {
|
|
2937
|
+
route = "diagnostics";
|
|
2938
|
+
if (request.method !== "GET") return respond(response, 405, { error: { message: "Diagnostics is read-only; use GET" } });
|
|
2939
|
+
return respond(response, 200, { ...diagnostics.query(new URL(request.url, origin).searchParams), plugin: { id: manifest.id, version: manifest.version }, backendState: sidecar.state, port: server.address().port });
|
|
2940
|
+
}
|
|
2941
|
+
const cookie = (request.headers.cookie || "").split(";").map((part) => part.trim()).find((part) => part.startsWith(`${cookieName}=`))?.slice(cookieName.length + 1);
|
|
2942
|
+
let session = sessions.get(cookie);
|
|
2943
|
+
if (path === "/api/bootstrap" && request.method === "GET") {
|
|
2944
|
+
if (!session) {
|
|
2945
|
+
if (sessions.size >= 128) throw new Error("Too many browser sessions");
|
|
2946
|
+
session = { id: randomBytes(24).toString("hex"), csrf: randomBytes(24).toString("hex") };
|
|
2947
|
+
sessions.set(session.id, session);
|
|
2948
|
+
response.setHeader("Set-Cookie", `${cookieName}=${session.id}; HttpOnly; SameSite=Strict; Path=/`);
|
|
2949
|
+
}
|
|
2950
|
+
return respond(response, 200, { manifest, connections: listing(), csrf: session.csrf, state: sidecar.state, revision, autoReload, diagnostics: diagnostics.snapshot() });
|
|
2951
|
+
}
|
|
2952
|
+
if (path === "/api/events" && request.method === "GET" && session) {
|
|
2953
|
+
const page = pageId(new URL(request.url, origin).searchParams.get("page") || void 0);
|
|
2954
|
+
const key = `${session.id}:${page}`;
|
|
2955
|
+
let lease = pages.get(key);
|
|
2956
|
+
if (!lease) {
|
|
2957
|
+
lease = { count: 0 };
|
|
2958
|
+
pages.set(key, lease);
|
|
2959
|
+
}
|
|
2960
|
+
clearTimeout(lease.timer);
|
|
2961
|
+
lease.count++;
|
|
2962
|
+
response.writeHead(200, { "Content-Type": "text/event-stream", Connection: "keep-alive" });
|
|
2963
|
+
response.write(`data: ${JSON.stringify({ type: "page-frames", ids: [...frames.values()].filter((f) => f.session === session.id && f.page === page).map((f) => f.id) })}
|
|
2964
|
+
|
|
2965
|
+
`);
|
|
2966
|
+
response.write(`data: ${JSON.stringify({ type: "status", state: sidecar.state })}
|
|
2967
|
+
|
|
2968
|
+
`);
|
|
2969
|
+
streams.add(response);
|
|
2970
|
+
response.write(`data: ${JSON.stringify({ type: "auto-reload", enabled: autoReload })}
|
|
2971
|
+
|
|
2972
|
+
`);
|
|
2973
|
+
response.write(`data: ${JSON.stringify({ type: "diagnostic-history", entries: diagnostics.snapshot() })}
|
|
2974
|
+
|
|
2975
|
+
`);
|
|
2976
|
+
const heartbeat = setInterval(() => response.write(": heartbeat\n\n"), 2e4);
|
|
2977
|
+
response.on("close", () => {
|
|
2978
|
+
streams.delete(response);
|
|
2979
|
+
clearInterval(heartbeat);
|
|
2980
|
+
if (--lease.count || closing) return;
|
|
2981
|
+
lease.timer = setTimeout(() => {
|
|
2982
|
+
void serialize(async () => {
|
|
2983
|
+
if (closing || lease.count || pages.get(key) !== lease) return;
|
|
2984
|
+
pages.delete(key);
|
|
2985
|
+
const ids = /* @__PURE__ */ new Set();
|
|
2986
|
+
for (const f of frames.values()) {
|
|
2987
|
+
if (f.session !== session.id || f.page !== page) continue;
|
|
2988
|
+
frames.delete(f.id);
|
|
2989
|
+
if (f.connectionId) ids.add(f.connectionId);
|
|
2990
|
+
}
|
|
2991
|
+
for (const id of ids) {
|
|
2992
|
+
if ([...frames.values()].some((f) => f.connectionId === id)) continue;
|
|
2993
|
+
try {
|
|
2994
|
+
await disconnect(id);
|
|
2995
|
+
} catch {
|
|
2996
|
+
diagnostics.record("error", "backend", "\u9875\u9762\u56DE\u6536\u65F6\u65AD\u5F00\u8FDE\u63A5\u5931\u8D25");
|
|
2997
|
+
}
|
|
2998
|
+
}
|
|
2999
|
+
broadcast("connections", { connections: listing() });
|
|
3000
|
+
});
|
|
3001
|
+
}, options.pageGraceMs ?? 3e4);
|
|
3002
|
+
});
|
|
3003
|
+
return;
|
|
3004
|
+
}
|
|
3005
|
+
if (path.startsWith("/api/")) {
|
|
3006
|
+
if (request.method !== "POST" || !session || request.headers.origin !== origin || request.headers["x-mock-csrf"] !== session.csrf || !request.headers["content-type"]?.startsWith("application/json")) {
|
|
3007
|
+
rejection = request.method !== "POST" ? "invalid-method" : !session ? "missing-or-expired-session" : request.headers.origin !== origin ? "missing-origin" : request.headers["x-mock-csrf"] !== session.csrf ? "csrf-mismatch" : "invalid-content-type";
|
|
3008
|
+
return respond(response, 403, { error: { message: "Invalid browser session or request" } });
|
|
3009
|
+
}
|
|
3010
|
+
let bytes = 0;
|
|
3011
|
+
const chunks = [];
|
|
3012
|
+
for await (const chunk of request) {
|
|
3013
|
+
bytes += chunk.length;
|
|
3014
|
+
if (bytes > 12 * 1024 * 1024) throw new Error("HTTP payload exceeds limit");
|
|
3015
|
+
chunks.push(chunk);
|
|
3016
|
+
}
|
|
3017
|
+
const body = JSON.parse(Buffer.concat(chunks).toString("utf8"));
|
|
3018
|
+
const page = pageId(request.headers["x-dbx-page"]);
|
|
3019
|
+
return respond(response, 200, { value: await api({ ...session, page }, path, body) });
|
|
3020
|
+
}
|
|
3021
|
+
if (path === "/" && request.method === "GET") {
|
|
3022
|
+
response.setHeader("Content-Type", "text/html; charset=utf-8");
|
|
3023
|
+
response.setHeader(
|
|
3024
|
+
"Content-Security-Policy",
|
|
3025
|
+
"default-src 'self'; script-src 'self' 'unsafe-inline' blob:; style-src 'self' 'unsafe-inline' blob:; img-src 'self' data: blob:; font-src 'self' data: blob:; media-src 'self' data: blob:; frame-src 'self' blob:; connect-src 'self'; object-src 'none'; base-uri 'none'; frame-ancestors 'none'"
|
|
3026
|
+
);
|
|
3027
|
+
return response.end(await readFile3(options.shellHtml));
|
|
3028
|
+
}
|
|
3029
|
+
respond(response, 404, { error: { message: "Not found" } });
|
|
3030
|
+
} catch (error) {
|
|
3031
|
+
const rpc = error.rpc;
|
|
3032
|
+
rejection = rpc ? "backend-error" : error.message?.startsWith("Plugin permission required:") ? "permission-denied" : error.message?.startsWith("Unsupported mock host method:") ? "unsupported-method" : error.message === "Stale workbench generation" ? "stale-frame" : "operation-failed";
|
|
3033
|
+
const message = error.code ? "Local development service operation failed" : error.message;
|
|
3034
|
+
respond(response, 400, { error: { message, ...rpc ? { code: rpc.code, data: rpc.data } : {} } });
|
|
3035
|
+
}
|
|
3036
|
+
});
|
|
3037
|
+
server.requestTimeout = 32e4;
|
|
3038
|
+
try {
|
|
3039
|
+
await new Promise((accept, reject) => {
|
|
3040
|
+
server.once("error", (error) => {
|
|
3041
|
+
if (error.code === "EADDRINUSE") {
|
|
3042
|
+
server.once("error", reject);
|
|
3043
|
+
server.listen(0, "127.0.0.1", accept);
|
|
3044
|
+
} else reject(error);
|
|
3045
|
+
});
|
|
3046
|
+
server.listen(options.port ?? 5190, "127.0.0.1", accept);
|
|
3047
|
+
});
|
|
3048
|
+
} catch (error) {
|
|
3049
|
+
await sidecar.stop();
|
|
3050
|
+
throw error;
|
|
3051
|
+
}
|
|
3052
|
+
origin = `http://127.0.0.1:${server.address().port}`;
|
|
3053
|
+
cookieName = `dbx_dev_session_${server.address().port}`;
|
|
3054
|
+
diagnostics.context = { port: server.address().port };
|
|
3055
|
+
diagnostics.record("info", "server", "\u8C03\u8BD5\u670D\u52A1\u5DF2\u542F\u52A8", { port: server.address().port, project, uiRoot, backend: options.backend });
|
|
3056
|
+
const watchStop = new AbortController();
|
|
3057
|
+
if (options.backendWatch && options.buildBackend)
|
|
3058
|
+
void (async () => {
|
|
3059
|
+
try {
|
|
3060
|
+
for await (const event of watch(options.backendWatch, { signal: watchStop.signal, recursive: true })) {
|
|
3061
|
+
const path = String(event.filename || "").replaceAll("\\", "/");
|
|
3062
|
+
if (path.split("/").some((p) => ["target", ".git", ".dbx-dev", "node_modules", "vendor"].includes(p))) continue;
|
|
3063
|
+
if (/\.(rs|go)$|(^|\/)(Cargo\.toml|Cargo\.lock|build\.rs|go\.mod|go\.sum)$/.test(path)) backendReload.changed();
|
|
3064
|
+
}
|
|
3065
|
+
} catch (error) {
|
|
3066
|
+
if (error.name !== "AbortError") {
|
|
3067
|
+
diagnostics.record("error", "build", "\u540E\u7AEF\u6E90\u7801\u76D1\u542C\u5DF2\u505C\u6B62");
|
|
3068
|
+
broadcast("auto-reload-error", {});
|
|
3069
|
+
}
|
|
3070
|
+
}
|
|
3071
|
+
})();
|
|
3072
|
+
let debounce;
|
|
3073
|
+
void (async () => {
|
|
3074
|
+
try {
|
|
3075
|
+
for await (const _event of watch(uiRoot, { signal: watchStop.signal, recursive: true })) {
|
|
3076
|
+
if (options.uiBuildSignals) continue;
|
|
3077
|
+
clearTimeout(debounce);
|
|
3078
|
+
debounce = setTimeout(async () => {
|
|
3079
|
+
try {
|
|
3080
|
+
await readAsset(uiRoot, entry);
|
|
3081
|
+
broadcast("ui-rebuilt", { revision: ++revision });
|
|
3082
|
+
} catch {
|
|
3083
|
+
broadcast("watch-error", {});
|
|
3084
|
+
}
|
|
3085
|
+
}, 500);
|
|
3086
|
+
}
|
|
3087
|
+
} catch (error) {
|
|
3088
|
+
if (error.name !== "AbortError") broadcast("watch-error", {});
|
|
3089
|
+
}
|
|
3090
|
+
})();
|
|
3091
|
+
return {
|
|
3092
|
+
origin,
|
|
3093
|
+
server,
|
|
3094
|
+
sidecar,
|
|
3095
|
+
store,
|
|
3096
|
+
diagnostics,
|
|
3097
|
+
async uiBuilt() {
|
|
3098
|
+
await readAsset(uiRoot, entry);
|
|
3099
|
+
broadcast("ui-rebuilt", { revision: ++revision });
|
|
3100
|
+
},
|
|
3101
|
+
async close() {
|
|
3102
|
+
if (closing) return;
|
|
3103
|
+
closing = true;
|
|
3104
|
+
for (const lease of pages.values()) clearTimeout(lease.timer);
|
|
3105
|
+
pages.clear();
|
|
3106
|
+
backendReload.enable(false);
|
|
3107
|
+
watchStop.abort();
|
|
3108
|
+
clearTimeout(debounce);
|
|
3109
|
+
for (const stream of streams) stream.end();
|
|
3110
|
+
streams.clear();
|
|
3111
|
+
server.close();
|
|
3112
|
+
await serialize(async () => {
|
|
3113
|
+
for (const id of connected) await disconnect(id).catch(() => {
|
|
3114
|
+
});
|
|
3115
|
+
await sidecar.stop();
|
|
3116
|
+
});
|
|
3117
|
+
server.closeAllConnections();
|
|
3118
|
+
diagnostics.record("info", "server", "\u8C03\u8BD5\u670D\u52A1\u5DF2\u505C\u6B62");
|
|
3119
|
+
diagnostics.removeListener("entry", onDiagnostic);
|
|
3120
|
+
}
|
|
3121
|
+
};
|
|
3122
|
+
}
|
|
3123
|
+
function respond(response, code, value) {
|
|
3124
|
+
if (response.headersSent || response.destroyed) return;
|
|
3125
|
+
response.writeHead(code, { "Content-Type": "application/json; charset=utf-8" });
|
|
3126
|
+
response.end(JSON.stringify(value));
|
|
3127
|
+
}
|
|
3128
|
+
|
|
3129
|
+
// ../../plugins/sdk/dev-host/runtime.mjs
|
|
3130
|
+
async function startDevelopment(options) {
|
|
3131
|
+
const diagnostics = options.diagnostics || new Diagnostics();
|
|
3132
|
+
if (Number(process.versions.node.split(".")[0]) < 22) throw new Error("dbx-plugin dev requires Node.js 22+");
|
|
3133
|
+
const project = resolve3(options.project), dataDir = resolve3(options.dataDir || resolve3(project, ".dbx-dev"));
|
|
3134
|
+
await mkdir2(dataDir, { recursive: true, mode: 448 });
|
|
3135
|
+
await chmod2(dataDir, 448);
|
|
3136
|
+
await mkdir2(resolve3(dataDir, "bin"), { recursive: true });
|
|
3137
|
+
const children = /* @__PURE__ */ new Set();
|
|
3138
|
+
let host, stopping = false;
|
|
3139
|
+
async function spawnCommand(spec, watch2 = false) {
|
|
3140
|
+
if (stopping) throw new Error("Development host is stopping");
|
|
3141
|
+
if (Array.isArray(spec)) spec = { command: spec[0], args: spec.slice(1), cwd: project };
|
|
3142
|
+
if (!spec?.command || !Array.isArray(spec.args) || spec.args.some((a) => typeof a !== "string")) throw new Error("Invalid build command");
|
|
3143
|
+
const env = { ...process.env };
|
|
3144
|
+
if (spec.goWorkspace) {
|
|
3145
|
+
const work = resolve3(dataDir, "go.work");
|
|
3146
|
+
await writeFile2(work, `go 1.22
|
|
3147
|
+
|
|
3148
|
+
use (
|
|
3149
|
+
${spec.goWorkspace.map((p) => " " + JSON.stringify(p)).join("\n")}
|
|
3150
|
+
)
|
|
3151
|
+
`, { mode: 384 });
|
|
3152
|
+
env.GOWORK = work;
|
|
3153
|
+
}
|
|
3154
|
+
let command = spec.command === "node" ? process.execPath : spec.command;
|
|
3155
|
+
let args = spec.args;
|
|
3156
|
+
if (process.platform === "win32" && command === "npm") {
|
|
3157
|
+
const npm = process.env.npm_execpath || resolve3(dirname(process.execPath), "node_modules/npm/bin/npm-cli.js");
|
|
3158
|
+
command = process.execPath;
|
|
3159
|
+
args = [npm, ...args];
|
|
3160
|
+
}
|
|
3161
|
+
if (stopping) throw new Error("Development host is stopping");
|
|
3162
|
+
const child = spawn3(command, args, { cwd: spec.cwd || project, env, stdio: ["ignore", watch2 ? "pipe" : "inherit", "inherit"], detached: process.platform !== "win32" });
|
|
3163
|
+
children.add(child);
|
|
3164
|
+
child.once("exit", () => {
|
|
3165
|
+
child.cleanup = stopProcessTree(child);
|
|
3166
|
+
child.cleanup.then(
|
|
3167
|
+
() => children.delete(child),
|
|
3168
|
+
() => {
|
|
3169
|
+
}
|
|
3170
|
+
);
|
|
3171
|
+
});
|
|
3172
|
+
return child;
|
|
3173
|
+
}
|
|
3174
|
+
async function run(spec) {
|
|
3175
|
+
diagnostics.record("info", "build", "\u6784\u5EFA\u547D\u4EE4\u5F00\u59CB");
|
|
3176
|
+
const child = await spawnCommand(spec);
|
|
3177
|
+
await new Promise((accept, reject) => {
|
|
3178
|
+
child.once("error", () => reject(new Error("Cannot start build command")));
|
|
3179
|
+
child.once("exit", (code) => code === 0 ? accept() : reject(new Error(`Build failed (exit ${code})`)));
|
|
3180
|
+
}).catch((error) => {
|
|
3181
|
+
diagnostics.record("error", "build", "\u6784\u5EFA\u547D\u4EE4\u5931\u8D25");
|
|
3182
|
+
throw error;
|
|
3183
|
+
});
|
|
3184
|
+
diagnostics.record("info", "build", "\u6784\u5EFA\u547D\u4EE4\u5B8C\u6210");
|
|
3185
|
+
if (stopping) throw new Error("Development host is stopping");
|
|
3186
|
+
}
|
|
3187
|
+
async function stopChildren() {
|
|
3188
|
+
await Promise.all([...children].map((child) => child.cleanup || stopProcessTree(child)));
|
|
3189
|
+
}
|
|
3190
|
+
const stop = async () => {
|
|
3191
|
+
if (stopping) return;
|
|
3192
|
+
stopping = true;
|
|
3193
|
+
process.removeListener("SIGINT", onSignal);
|
|
3194
|
+
process.removeListener("SIGTERM", onSignal);
|
|
3195
|
+
await stopChildren();
|
|
3196
|
+
await host?.close();
|
|
3197
|
+
};
|
|
3198
|
+
const onSignal = () => void stop();
|
|
3199
|
+
process.once("SIGINT", onSignal);
|
|
3200
|
+
process.once("SIGTERM", onSignal);
|
|
3201
|
+
try {
|
|
3202
|
+
const commands = options.commands || {};
|
|
3203
|
+
if (commands.backend) await run(commands.backend);
|
|
3204
|
+
if (commands.ui?.length) await run(commands.ui);
|
|
3205
|
+
if (stopping) throw new Error("Development host is stopping");
|
|
3206
|
+
host = await createMockHost({
|
|
3207
|
+
...options,
|
|
3208
|
+
project,
|
|
3209
|
+
dataDir,
|
|
3210
|
+
diagnostics,
|
|
3211
|
+
uiBuildSignals: Boolean(commands.watch?.length),
|
|
3212
|
+
shellHtml: options.shellHtml || resolve3(dirname(fileURLToPath(import.meta.url)), "ui/index.html"),
|
|
3213
|
+
buildBackend: commands.backend ? () => run(commands.backend) : void 0
|
|
3214
|
+
});
|
|
3215
|
+
if (stopping) {
|
|
3216
|
+
await host.close();
|
|
3217
|
+
throw new Error("Development host is stopping");
|
|
3218
|
+
}
|
|
3219
|
+
if (commands.watch?.length) {
|
|
3220
|
+
const watcher = await spawnCommand(commands.watch, true);
|
|
3221
|
+
let line = "", oversized = false;
|
|
3222
|
+
watcher.stdout.setEncoding("utf8");
|
|
3223
|
+
watcher.stdout.on("data", (chunk) => {
|
|
3224
|
+
process.stdout.write(chunk);
|
|
3225
|
+
for (const character of chunk) {
|
|
3226
|
+
if (character === "\n") {
|
|
3227
|
+
if (!oversized && line.replace(/\r$/, "") === "DBX_UI_BUILD_SUCCESS") {
|
|
3228
|
+
void host.uiBuilt().catch(() => diagnostics.record("error", "build", "\u524D\u7AEF\u6784\u5EFA\u4EA7\u7269\u4E0D\u53EF\u8BFB\u53D6"));
|
|
3229
|
+
}
|
|
3230
|
+
line = "";
|
|
3231
|
+
oversized = false;
|
|
3232
|
+
} else if (line.length < 1024) line += character;
|
|
3233
|
+
else oversized = true;
|
|
3234
|
+
}
|
|
3235
|
+
});
|
|
3236
|
+
watcher.on("error", () => diagnostics.record("error", "build", "\u524D\u7AEF\u6784\u5EFA\u76D1\u542C\u542F\u52A8\u5931\u8D25"));
|
|
3237
|
+
watcher.on("exit", (code) => {
|
|
3238
|
+
if (!stopping) diagnostics.record("error", "build", "\u524D\u7AEF\u6784\u5EFA\u76D1\u542C\u5DF2\u9000\u51FA", { exitCode: code });
|
|
3239
|
+
});
|
|
3240
|
+
}
|
|
3241
|
+
console.log(`Plugin dev host: ${host.origin}`);
|
|
3242
|
+
console.log("Development credentials are stored locally as plaintext in the configured data directory.");
|
|
3243
|
+
return { ...host, close: stop };
|
|
3244
|
+
} catch (error) {
|
|
3245
|
+
await stop();
|
|
3246
|
+
throw error;
|
|
3247
|
+
}
|
|
3248
|
+
}
|
|
3249
|
+
if (process.argv[1] && import.meta.url === pathToFileURL(resolve3(process.argv[1])).href) {
|
|
3250
|
+
try {
|
|
3251
|
+
if (process.argv[2] !== "--config" || !process.argv[3]) throw new Error("Start this runtime using dbx-plugin dev");
|
|
3252
|
+
await startDevelopment(JSON.parse(process.argv[3]));
|
|
3253
|
+
} catch (error) {
|
|
3254
|
+
console.error(error.message);
|
|
3255
|
+
process.exitCode = 1;
|
|
3256
|
+
}
|
|
3257
|
+
}
|
|
3258
|
+
export {
|
|
3259
|
+
startDevelopment
|
|
3260
|
+
};
|