@zenbujs/core 0.0.5 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{advice-config-QYB2qEd_.mjs → advice-config-DXSIo0sg.mjs} +40 -39
- package/dist/advice.d.mts +8 -8
- package/dist/advice.mjs +2 -2
- package/dist/{base-window-BbFRRhKP.mjs → base-window-BxBZ2md_.mjs} +51 -7
- package/dist/{transforms-CuTODvDx.d.mts → build-config-Dzg2frpk.d.mts} +98 -28
- package/dist/build-config-pWdmLnrk.mjs +53 -0
- package/dist/{build-electron-CNJ0dLND.mjs → build-electron-Dsbb1EMl.mjs} +308 -120
- package/dist/{build-source-C2puqEVr.mjs → build-source-d1J3shV8.mjs} +62 -27
- package/dist/cli/bin.mjs +7 -7
- package/dist/cli/build.d.mts +2 -2
- package/dist/cli/build.mjs +2 -3
- package/dist/cli/resolve-config.mjs +1 -1
- package/dist/{cli-C3R1LBMY.mjs → cli-kL6mPgBE.mjs} +2 -2
- package/dist/config.d.mts +3 -3
- package/dist/config.mjs +2 -3
- package/dist/{db-xjvahRFJ.mjs → db-Bc292RYo.mjs} +2 -2
- package/dist/db.d.mts +1 -1
- package/dist/dev-B2emj0HZ.mjs +301 -0
- package/dist/env-bootstrap.d.mts +1 -1
- package/dist/events.d.mts +19 -0
- package/dist/events.mjs +1 -0
- package/dist/host-version-BIrF8tX7.mjs +65 -0
- package/dist/index-w5QyDjuf.d.mts +780 -0
- package/dist/index.d.mts +5 -6
- package/dist/index.mjs +2 -2
- package/dist/installing-preload.cjs +60 -0
- package/dist/launcher.mjs +2615 -122
- package/dist/{link-c0_aLWQ3.mjs → link-glX89NV5.mjs} +215 -89
- package/dist/{load-config-xMf2wxH8.mjs → load-config-C4Oe2qZO.mjs} +5 -1
- package/dist/loaders/zenbu.mjs +102 -0
- package/dist/node-loader.mjs +1 -1
- package/dist/{publish-source-Dill72NS.mjs → publish-source-Dq2c0iOw.mjs} +2 -2
- package/dist/react.d.mts +55 -6
- package/dist/react.mjs +116 -5
- package/dist/registry-CMp8FYgS.d.mts +47 -0
- package/dist/registry-generated.d.mts +26 -0
- package/dist/registry-generated.mjs +1 -0
- package/dist/registry.d.mts +2 -2
- package/dist/{reloader-DzEO8kJr.mjs → reloader-B22UiNA2.mjs} +2 -4
- package/dist/{renderer-host-Cau9JK0v.mjs → renderer-host-DD16MXhI.mjs} +152 -43
- package/dist/{rpc-JfGv-Wuw.mjs → rpc-C4_NQmpT.mjs} +5 -4
- package/dist/{runtime-pCeVzj--.d.mts → runtime-BQWntcOb.d.mts} +85 -48
- package/dist/runtime.d.mts +2 -2
- package/dist/runtime.mjs +139 -83
- package/dist/{schema-Dl85YjXW.d.mts → schema-CjrMVk36.d.mts} +3 -3
- package/dist/schema.d.mts +1 -1
- package/dist/schema.mjs +1 -1
- package/dist/{server-y3PPbh3l.mjs → server-CZLMF8Dj.mjs} +1 -3
- package/dist/services/default.d.mts +3 -3
- package/dist/services/default.mjs +14 -13
- package/dist/services/index.d.mts +2 -280
- package/dist/services/index.mjs +8 -7
- package/dist/setup-gate.d.mts +1 -1
- package/dist/setup-gate.mjs +117 -24
- package/dist/{transform-CmFYPmt8.mjs → transform-BzrwkEdf.mjs} +22 -916
- package/dist/updater-DCkz9M1c.mjs +1008 -0
- package/dist/{vite-plugins-Do7liKi_.mjs → vite-plugins-tt6KAtyE.mjs} +26 -25
- package/dist/vite.d.mts +3 -3
- package/dist/vite.mjs +1 -1
- package/dist/{window-o2NGUsIb.mjs → window-YFKvAM0l.mjs} +30 -16
- package/package.json +15 -2
- package/dist/build-config-C3a-o3_B.mjs +0 -23
- package/dist/dev-Dazhu66l.mjs +0 -85
- package/dist/registry-eX6e2oql.d.mts +0 -61
- package/dist/transforms-htxfTwsY.mjs +0 -47
- /package/dist/{config-DXRCDUxG.mjs → config-BK78JDRI.mjs} +0 -0
- /package/dist/{env-bootstrap-DW2hVhSO.d.mts → env-bootstrap-rTs8KR3-.d.mts} +0 -0
- /package/dist/{index-M_lSNBrq.d.mts → index-DeDxePAa.d.mts} +0 -0
- /package/dist/{mirror-sync-PDzxhf1w.mjs → mirror-sync-pYU6f3-c.mjs} +0 -0
- /package/dist/{monorepo-3avKJwzJ.mjs → monorepo-Dct-kkbQ.mjs} +0 -0
- /package/dist/{node-_8xShqxr.mjs → node-BhfLKYCi.mjs} +0 -0
- /package/dist/{setup-gate-Dcy8gGPJ.d.mts → setup-gate-BQq0QgZH.d.mts} +0 -0
package/dist/launcher.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
|
-
import { app } from "electron";
|
|
3
|
-
import crypto$1 from "node:crypto";
|
|
4
|
-
import { spawn } from "node:child_process";
|
|
2
|
+
import { BaseWindow, WebContentsView, app } from "electron";
|
|
5
3
|
import fs, { existsSync } from "node:fs";
|
|
6
4
|
import fsp from "node:fs/promises";
|
|
7
5
|
import os from "node:os";
|
|
8
6
|
import path from "node:path";
|
|
7
|
+
import crypto$1 from "node:crypto";
|
|
8
|
+
import { spawn } from "node:child_process";
|
|
9
9
|
//#region \0rolldown/runtime.js
|
|
10
10
|
var __create = Object.create;
|
|
11
11
|
var __defProp = Object.defineProperty;
|
|
@@ -317,7 +317,7 @@ var require_eval = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
317
317
|
}));
|
|
318
318
|
//#endregion
|
|
319
319
|
//#region ../../node_modules/.pnpm/es-errors@1.3.0/node_modules/es-errors/range.js
|
|
320
|
-
var require_range = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
320
|
+
var require_range$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
321
321
|
/** @type {import('./range')} */
|
|
322
322
|
module.exports = RangeError;
|
|
323
323
|
}));
|
|
@@ -626,7 +626,7 @@ var require_get_intrinsic = /* @__PURE__ */ __commonJSMin(((exports, module) =>
|
|
|
626
626
|
var $Object = require_es_object_atoms();
|
|
627
627
|
var $Error = require_es_errors();
|
|
628
628
|
var $EvalError = require_eval();
|
|
629
|
-
var $RangeError = require_range();
|
|
629
|
+
var $RangeError = require_range$1();
|
|
630
630
|
var $ReferenceError = require_ref();
|
|
631
631
|
var $SyntaxError = require_syntax();
|
|
632
632
|
var $TypeError = require_type();
|
|
@@ -5134,7 +5134,7 @@ var require_inflate$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
5134
5134
|
}));
|
|
5135
5135
|
//#endregion
|
|
5136
5136
|
//#region ../../node_modules/.pnpm/pako@1.0.11/node_modules/pako/lib/zlib/constants.js
|
|
5137
|
-
var require_constants = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
5137
|
+
var require_constants$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
5138
5138
|
module.exports = {
|
|
5139
5139
|
Z_NO_FLUSH: 0,
|
|
5140
5140
|
Z_PARTIAL_FLUSH: 1,
|
|
@@ -5188,7 +5188,7 @@ var require_inflate = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
5188
5188
|
var zlib_inflate = require_inflate$1();
|
|
5189
5189
|
var utils = require_common();
|
|
5190
5190
|
var strings = require_strings();
|
|
5191
|
-
var c = require_constants();
|
|
5191
|
+
var c = require_constants$1();
|
|
5192
5192
|
var msg = require_messages();
|
|
5193
5193
|
var ZStream = require_zstream();
|
|
5194
5194
|
var GZheader = require_gzheader();
|
|
@@ -5488,7 +5488,7 @@ var require_pako = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
5488
5488
|
var assign = require_common().assign;
|
|
5489
5489
|
var deflate = require_deflate();
|
|
5490
5490
|
var inflate = require_inflate();
|
|
5491
|
-
var constants = require_constants();
|
|
5491
|
+
var constants = require_constants$1();
|
|
5492
5492
|
var pako = {};
|
|
5493
5493
|
assign(pako, deflate, inflate, constants);
|
|
5494
5494
|
module.exports = pako;
|
|
@@ -10012,6 +10012,100 @@ ${obj.gpgsig ? obj.gpgsig : ""}`;
|
|
|
10012
10012
|
return ignoredStatus;
|
|
10013
10013
|
}
|
|
10014
10014
|
};
|
|
10015
|
+
async function resolveCommit({ fs, cache, gitdir, oid }) {
|
|
10016
|
+
const { type, object } = await _readObject({
|
|
10017
|
+
fs,
|
|
10018
|
+
cache,
|
|
10019
|
+
gitdir,
|
|
10020
|
+
oid
|
|
10021
|
+
});
|
|
10022
|
+
if (type === "tag") {
|
|
10023
|
+
oid = GitAnnotatedTag.from(object).parse().object;
|
|
10024
|
+
return resolveCommit({
|
|
10025
|
+
fs,
|
|
10026
|
+
cache,
|
|
10027
|
+
gitdir,
|
|
10028
|
+
oid
|
|
10029
|
+
});
|
|
10030
|
+
}
|
|
10031
|
+
if (type !== "commit") throw new ObjectTypeError(oid, type, "commit");
|
|
10032
|
+
return {
|
|
10033
|
+
commit: GitCommit.from(object),
|
|
10034
|
+
oid
|
|
10035
|
+
};
|
|
10036
|
+
}
|
|
10037
|
+
/**
|
|
10038
|
+
* @param {object} args
|
|
10039
|
+
* @param {import('../models/FileSystem.js').FileSystem} args.fs
|
|
10040
|
+
* @param {any} args.cache
|
|
10041
|
+
* @param {string} args.gitdir
|
|
10042
|
+
* @param {string} args.oid
|
|
10043
|
+
*
|
|
10044
|
+
* @returns {Promise<ReadCommitResult>} Resolves successfully with a git commit object
|
|
10045
|
+
* @see ReadCommitResult
|
|
10046
|
+
* @see CommitObject
|
|
10047
|
+
*
|
|
10048
|
+
*/
|
|
10049
|
+
async function _readCommit({ fs, cache, gitdir, oid }) {
|
|
10050
|
+
const { commit, oid: commitOid } = await resolveCommit({
|
|
10051
|
+
fs,
|
|
10052
|
+
cache,
|
|
10053
|
+
gitdir,
|
|
10054
|
+
oid
|
|
10055
|
+
});
|
|
10056
|
+
return {
|
|
10057
|
+
oid: commitOid,
|
|
10058
|
+
commit: commit.parse(),
|
|
10059
|
+
payload: commit.withoutSignature()
|
|
10060
|
+
};
|
|
10061
|
+
}
|
|
10062
|
+
async function resolveFilepath({ fs, cache, gitdir, oid, filepath }) {
|
|
10063
|
+
if (filepath.startsWith("/")) throw new InvalidFilepathError("leading-slash");
|
|
10064
|
+
else if (filepath.endsWith("/")) throw new InvalidFilepathError("trailing-slash");
|
|
10065
|
+
const _oid = oid;
|
|
10066
|
+
const result = await resolveTree({
|
|
10067
|
+
fs,
|
|
10068
|
+
cache,
|
|
10069
|
+
gitdir,
|
|
10070
|
+
oid
|
|
10071
|
+
});
|
|
10072
|
+
const tree = result.tree;
|
|
10073
|
+
if (filepath === "") oid = result.oid;
|
|
10074
|
+
else oid = await _resolveFilepath({
|
|
10075
|
+
fs,
|
|
10076
|
+
cache,
|
|
10077
|
+
gitdir,
|
|
10078
|
+
tree,
|
|
10079
|
+
pathArray: filepath.split("/"),
|
|
10080
|
+
oid: _oid,
|
|
10081
|
+
filepath
|
|
10082
|
+
});
|
|
10083
|
+
return oid;
|
|
10084
|
+
}
|
|
10085
|
+
async function _resolveFilepath({ fs, cache, gitdir, tree, pathArray, oid, filepath }) {
|
|
10086
|
+
const name = pathArray.shift();
|
|
10087
|
+
for (const entry of tree) if (entry.path === name) if (pathArray.length === 0) return entry.oid;
|
|
10088
|
+
else {
|
|
10089
|
+
const { type, object } = await _readObject({
|
|
10090
|
+
fs,
|
|
10091
|
+
cache,
|
|
10092
|
+
gitdir,
|
|
10093
|
+
oid: entry.oid
|
|
10094
|
+
});
|
|
10095
|
+
if (type !== "tree") throw new ObjectTypeError(oid, type, "tree", filepath);
|
|
10096
|
+
tree = GitTree.from(object);
|
|
10097
|
+
return _resolveFilepath({
|
|
10098
|
+
fs,
|
|
10099
|
+
cache,
|
|
10100
|
+
gitdir,
|
|
10101
|
+
tree,
|
|
10102
|
+
pathArray,
|
|
10103
|
+
oid,
|
|
10104
|
+
filepath
|
|
10105
|
+
});
|
|
10106
|
+
}
|
|
10107
|
+
throw new NotFoundError(`file or directory found at "${oid}:${filepath}"`);
|
|
10108
|
+
}
|
|
10015
10109
|
const bad = /(^|[/.])([/.]|$)|^@$|@{|[\x00-\x20\x7f~^:?*[\\]|\.lock(\/|$)/;
|
|
10016
10110
|
function isValidRef(name, onelevel) {
|
|
10017
10111
|
if (typeof name !== "string") throw new TypeError("Reference name must be a string");
|
|
@@ -11858,6 +11952,361 @@ ${obj.gpgsig ? obj.gpgsig : ""}`;
|
|
|
11858
11952
|
throw err;
|
|
11859
11953
|
}
|
|
11860
11954
|
}
|
|
11955
|
+
function compareAge(a, b) {
|
|
11956
|
+
return a.committer.timestamp - b.committer.timestamp;
|
|
11957
|
+
}
|
|
11958
|
+
const EMPTY_OID = "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391";
|
|
11959
|
+
async function resolveFileIdInTree({ fs, cache, gitdir, oid, fileId }) {
|
|
11960
|
+
if (fileId === EMPTY_OID) return;
|
|
11961
|
+
const _oid = oid;
|
|
11962
|
+
let filepath;
|
|
11963
|
+
const result = await resolveTree({
|
|
11964
|
+
fs,
|
|
11965
|
+
cache,
|
|
11966
|
+
gitdir,
|
|
11967
|
+
oid
|
|
11968
|
+
});
|
|
11969
|
+
const tree = result.tree;
|
|
11970
|
+
if (fileId === result.oid) filepath = result.path;
|
|
11971
|
+
else {
|
|
11972
|
+
filepath = await _resolveFileId({
|
|
11973
|
+
fs,
|
|
11974
|
+
cache,
|
|
11975
|
+
gitdir,
|
|
11976
|
+
tree,
|
|
11977
|
+
fileId,
|
|
11978
|
+
oid: _oid
|
|
11979
|
+
});
|
|
11980
|
+
if (Array.isArray(filepath)) {
|
|
11981
|
+
if (filepath.length === 0) filepath = void 0;
|
|
11982
|
+
else if (filepath.length === 1) filepath = filepath[0];
|
|
11983
|
+
}
|
|
11984
|
+
}
|
|
11985
|
+
return filepath;
|
|
11986
|
+
}
|
|
11987
|
+
async function _resolveFileId({ fs, cache, gitdir, tree, fileId, oid, filepaths = [], parentPath = "" }) {
|
|
11988
|
+
const walks = tree.entries().map(function(entry) {
|
|
11989
|
+
let result;
|
|
11990
|
+
if (entry.oid === fileId) {
|
|
11991
|
+
result = join(parentPath, entry.path);
|
|
11992
|
+
filepaths.push(result);
|
|
11993
|
+
} else if (entry.type === "tree") result = _readObject({
|
|
11994
|
+
fs,
|
|
11995
|
+
cache,
|
|
11996
|
+
gitdir,
|
|
11997
|
+
oid: entry.oid
|
|
11998
|
+
}).then(function({ object }) {
|
|
11999
|
+
return _resolveFileId({
|
|
12000
|
+
fs,
|
|
12001
|
+
cache,
|
|
12002
|
+
gitdir,
|
|
12003
|
+
tree: GitTree.from(object),
|
|
12004
|
+
fileId,
|
|
12005
|
+
oid,
|
|
12006
|
+
filepaths,
|
|
12007
|
+
parentPath: join(parentPath, entry.path)
|
|
12008
|
+
});
|
|
12009
|
+
});
|
|
12010
|
+
return result;
|
|
12011
|
+
});
|
|
12012
|
+
await Promise.all(walks);
|
|
12013
|
+
return filepaths;
|
|
12014
|
+
}
|
|
12015
|
+
/**
|
|
12016
|
+
* Get commit descriptions from the git history
|
|
12017
|
+
*
|
|
12018
|
+
* @param {object} args
|
|
12019
|
+
* @param {import('../models/FileSystem.js').FileSystem} args.fs
|
|
12020
|
+
* @param {any} args.cache
|
|
12021
|
+
* @param {string} args.gitdir
|
|
12022
|
+
* @param {string=} args.filepath optional get the commit for the filepath only
|
|
12023
|
+
* @param {string} args.ref
|
|
12024
|
+
* @param {number|void} args.depth
|
|
12025
|
+
* @param {boolean=} [args.force=false] do not throw error if filepath is not exist (works only for a single file). defaults to false
|
|
12026
|
+
* @param {boolean=} [args.follow=false] Continue listing the history of a file beyond renames (works only for a single file). defaults to false
|
|
12027
|
+
* @param {boolean=} args.follow Continue listing the history of a file beyond renames (works only for a single file). defaults to false
|
|
12028
|
+
*
|
|
12029
|
+
* @returns {Promise<Array<ReadCommitResult>>} Resolves to an array of ReadCommitResult objects
|
|
12030
|
+
* @see ReadCommitResult
|
|
12031
|
+
* @see CommitObject
|
|
12032
|
+
*
|
|
12033
|
+
* @example
|
|
12034
|
+
* let commits = await git.log({ dir: '$input((/))', depth: $input((5)), ref: '$input((master))' })
|
|
12035
|
+
* console.log(commits)
|
|
12036
|
+
*
|
|
12037
|
+
*/
|
|
12038
|
+
async function _log({ fs, cache, gitdir, filepath, ref, depth, since, force, follow }) {
|
|
12039
|
+
const sinceTimestamp = typeof since === "undefined" ? void 0 : Math.floor(since.valueOf() / 1e3);
|
|
12040
|
+
const commits = [];
|
|
12041
|
+
const shallowCommits = await GitShallowManager.read({
|
|
12042
|
+
fs,
|
|
12043
|
+
gitdir
|
|
12044
|
+
});
|
|
12045
|
+
const tips = [await _readCommit({
|
|
12046
|
+
fs,
|
|
12047
|
+
cache,
|
|
12048
|
+
gitdir,
|
|
12049
|
+
oid: await GitRefManager.resolve({
|
|
12050
|
+
fs,
|
|
12051
|
+
gitdir,
|
|
12052
|
+
ref
|
|
12053
|
+
})
|
|
12054
|
+
})];
|
|
12055
|
+
let lastFileOid;
|
|
12056
|
+
let lastCommit;
|
|
12057
|
+
let isOk;
|
|
12058
|
+
function endCommit(commit) {
|
|
12059
|
+
if (isOk && filepath) commits.push(commit);
|
|
12060
|
+
}
|
|
12061
|
+
while (tips.length > 0) {
|
|
12062
|
+
const commit = tips.pop();
|
|
12063
|
+
if (sinceTimestamp !== void 0 && commit.commit.committer.timestamp <= sinceTimestamp) break;
|
|
12064
|
+
if (filepath) {
|
|
12065
|
+
let vFileOid;
|
|
12066
|
+
try {
|
|
12067
|
+
vFileOid = await resolveFilepath({
|
|
12068
|
+
fs,
|
|
12069
|
+
cache,
|
|
12070
|
+
gitdir,
|
|
12071
|
+
oid: commit.commit.tree,
|
|
12072
|
+
filepath
|
|
12073
|
+
});
|
|
12074
|
+
if (lastCommit && lastFileOid !== vFileOid) commits.push(lastCommit);
|
|
12075
|
+
lastFileOid = vFileOid;
|
|
12076
|
+
lastCommit = commit;
|
|
12077
|
+
isOk = true;
|
|
12078
|
+
} catch (e) {
|
|
12079
|
+
if (e instanceof NotFoundError) {
|
|
12080
|
+
let found = follow && lastFileOid;
|
|
12081
|
+
if (found) {
|
|
12082
|
+
found = await resolveFileIdInTree({
|
|
12083
|
+
fs,
|
|
12084
|
+
cache,
|
|
12085
|
+
gitdir,
|
|
12086
|
+
oid: commit.commit.tree,
|
|
12087
|
+
fileId: lastFileOid
|
|
12088
|
+
});
|
|
12089
|
+
if (found) if (Array.isArray(found)) {
|
|
12090
|
+
if (lastCommit) {
|
|
12091
|
+
const lastFound = await resolveFileIdInTree({
|
|
12092
|
+
fs,
|
|
12093
|
+
cache,
|
|
12094
|
+
gitdir,
|
|
12095
|
+
oid: lastCommit.commit.tree,
|
|
12096
|
+
fileId: lastFileOid
|
|
12097
|
+
});
|
|
12098
|
+
if (Array.isArray(lastFound)) {
|
|
12099
|
+
found = found.filter((p) => lastFound.indexOf(p) === -1);
|
|
12100
|
+
if (found.length === 1) {
|
|
12101
|
+
found = found[0];
|
|
12102
|
+
filepath = found;
|
|
12103
|
+
if (lastCommit) commits.push(lastCommit);
|
|
12104
|
+
} else {
|
|
12105
|
+
found = false;
|
|
12106
|
+
if (lastCommit) commits.push(lastCommit);
|
|
12107
|
+
break;
|
|
12108
|
+
}
|
|
12109
|
+
}
|
|
12110
|
+
}
|
|
12111
|
+
} else {
|
|
12112
|
+
filepath = found;
|
|
12113
|
+
if (lastCommit) commits.push(lastCommit);
|
|
12114
|
+
}
|
|
12115
|
+
}
|
|
12116
|
+
if (!found) {
|
|
12117
|
+
if (isOk && lastFileOid) {
|
|
12118
|
+
commits.push(lastCommit);
|
|
12119
|
+
if (!force) break;
|
|
12120
|
+
}
|
|
12121
|
+
if (!force && !follow) throw e;
|
|
12122
|
+
}
|
|
12123
|
+
lastCommit = commit;
|
|
12124
|
+
isOk = false;
|
|
12125
|
+
} else throw e;
|
|
12126
|
+
}
|
|
12127
|
+
} else commits.push(commit);
|
|
12128
|
+
if (depth !== void 0 && commits.length === depth) {
|
|
12129
|
+
endCommit(commit);
|
|
12130
|
+
break;
|
|
12131
|
+
}
|
|
12132
|
+
if (!shallowCommits.has(commit.oid)) for (const oid of commit.commit.parent) {
|
|
12133
|
+
const commit = await _readCommit({
|
|
12134
|
+
fs,
|
|
12135
|
+
cache,
|
|
12136
|
+
gitdir,
|
|
12137
|
+
oid
|
|
12138
|
+
});
|
|
12139
|
+
if (!tips.map((commit) => commit.oid).includes(commit.oid)) tips.push(commit);
|
|
12140
|
+
}
|
|
12141
|
+
if (tips.length === 0) endCommit(commit);
|
|
12142
|
+
tips.sort((a, b) => compareAge(a.commit, b.commit));
|
|
12143
|
+
}
|
|
12144
|
+
return commits;
|
|
12145
|
+
}
|
|
12146
|
+
/**
|
|
12147
|
+
* Get commit descriptions from the git history
|
|
12148
|
+
*
|
|
12149
|
+
* @param {object} args
|
|
12150
|
+
* @param {FsClient} args.fs - a file system client
|
|
12151
|
+
* @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
|
|
12152
|
+
* @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
|
|
12153
|
+
* @param {string=} args.filepath optional get the commit for the filepath only
|
|
12154
|
+
* @param {string} [args.ref = 'HEAD'] - The commit to begin walking backwards through the history from
|
|
12155
|
+
* @param {number=} [args.depth] - Limit the number of commits returned. No limit by default.
|
|
12156
|
+
* @param {Date} [args.since] - Return history newer than the given date. Can be combined with `depth` to get whichever is shorter.
|
|
12157
|
+
* @param {boolean=} [args.force=false] do not throw error if filepath is not exist (works only for a single file). defaults to false
|
|
12158
|
+
* @param {boolean=} [args.follow=false] Continue listing the history of a file beyond renames (works only for a single file). defaults to false
|
|
12159
|
+
* @param {object} [args.cache] - a [cache](cache.md) object
|
|
12160
|
+
*
|
|
12161
|
+
* @returns {Promise<Array<ReadCommitResult>>} Resolves to an array of ReadCommitResult objects
|
|
12162
|
+
* @see ReadCommitResult
|
|
12163
|
+
* @see CommitObject
|
|
12164
|
+
*
|
|
12165
|
+
* @example
|
|
12166
|
+
* let commits = await git.log({
|
|
12167
|
+
* fs,
|
|
12168
|
+
* dir: '/tutorial',
|
|
12169
|
+
* depth: 5,
|
|
12170
|
+
* ref: 'main'
|
|
12171
|
+
* })
|
|
12172
|
+
* console.log(commits)
|
|
12173
|
+
*
|
|
12174
|
+
*/
|
|
12175
|
+
async function log({ fs, dir, gitdir = join(dir, ".git"), filepath, ref = "HEAD", depth, since, force, follow, cache = {} }) {
|
|
12176
|
+
try {
|
|
12177
|
+
assertParameter("fs", fs);
|
|
12178
|
+
assertParameter("gitdir", gitdir);
|
|
12179
|
+
assertParameter("ref", ref);
|
|
12180
|
+
const fsp = new FileSystem(fs);
|
|
12181
|
+
return await _log({
|
|
12182
|
+
fs: fsp,
|
|
12183
|
+
cache,
|
|
12184
|
+
gitdir: await discoverGitdir({
|
|
12185
|
+
fsp,
|
|
12186
|
+
dotgit: gitdir
|
|
12187
|
+
}),
|
|
12188
|
+
filepath,
|
|
12189
|
+
ref,
|
|
12190
|
+
depth,
|
|
12191
|
+
since,
|
|
12192
|
+
force,
|
|
12193
|
+
follow
|
|
12194
|
+
});
|
|
12195
|
+
} catch (err) {
|
|
12196
|
+
err.caller = "git.log";
|
|
12197
|
+
throw err;
|
|
12198
|
+
}
|
|
12199
|
+
}
|
|
12200
|
+
async function resolveBlob({ fs, cache, gitdir, oid }) {
|
|
12201
|
+
const { type, object } = await _readObject({
|
|
12202
|
+
fs,
|
|
12203
|
+
cache,
|
|
12204
|
+
gitdir,
|
|
12205
|
+
oid
|
|
12206
|
+
});
|
|
12207
|
+
if (type === "tag") {
|
|
12208
|
+
oid = GitAnnotatedTag.from(object).parse().object;
|
|
12209
|
+
return resolveBlob({
|
|
12210
|
+
fs,
|
|
12211
|
+
cache,
|
|
12212
|
+
gitdir,
|
|
12213
|
+
oid
|
|
12214
|
+
});
|
|
12215
|
+
}
|
|
12216
|
+
if (type !== "blob") throw new ObjectTypeError(oid, type, "blob");
|
|
12217
|
+
return {
|
|
12218
|
+
oid,
|
|
12219
|
+
blob: new Uint8Array(object)
|
|
12220
|
+
};
|
|
12221
|
+
}
|
|
12222
|
+
/**
|
|
12223
|
+
*
|
|
12224
|
+
* @typedef {Object} ReadBlobResult - The object returned has the following schema:
|
|
12225
|
+
* @property {string} oid
|
|
12226
|
+
* @property {Uint8Array} blob
|
|
12227
|
+
*
|
|
12228
|
+
*/
|
|
12229
|
+
/**
|
|
12230
|
+
* @param {object} args
|
|
12231
|
+
* @param {import('../models/FileSystem.js').FileSystem} args.fs
|
|
12232
|
+
* @param {any} args.cache
|
|
12233
|
+
* @param {string} args.gitdir
|
|
12234
|
+
* @param {string} args.oid
|
|
12235
|
+
* @param {string} [args.filepath]
|
|
12236
|
+
*
|
|
12237
|
+
* @returns {Promise<ReadBlobResult>} Resolves successfully with a blob object description
|
|
12238
|
+
* @see ReadBlobResult
|
|
12239
|
+
*/
|
|
12240
|
+
async function _readBlob({ fs, cache, gitdir, oid, filepath = void 0 }) {
|
|
12241
|
+
if (filepath !== void 0) oid = await resolveFilepath({
|
|
12242
|
+
fs,
|
|
12243
|
+
cache,
|
|
12244
|
+
gitdir,
|
|
12245
|
+
oid,
|
|
12246
|
+
filepath
|
|
12247
|
+
});
|
|
12248
|
+
return await resolveBlob({
|
|
12249
|
+
fs,
|
|
12250
|
+
cache,
|
|
12251
|
+
gitdir,
|
|
12252
|
+
oid
|
|
12253
|
+
});
|
|
12254
|
+
}
|
|
12255
|
+
/**
|
|
12256
|
+
*
|
|
12257
|
+
* @typedef {Object} ReadBlobResult - The object returned has the following schema:
|
|
12258
|
+
* @property {string} oid
|
|
12259
|
+
* @property {Uint8Array} blob
|
|
12260
|
+
*
|
|
12261
|
+
*/
|
|
12262
|
+
/**
|
|
12263
|
+
* Read a blob object directly
|
|
12264
|
+
*
|
|
12265
|
+
* @param {object} args
|
|
12266
|
+
* @param {FsClient} args.fs - a file system client
|
|
12267
|
+
* @param {string} [args.dir] - The [working tree](dir-vs-gitdir.md) directory path
|
|
12268
|
+
* @param {string} [args.gitdir=join(dir,'.git')] - [required] The [git directory](dir-vs-gitdir.md) path
|
|
12269
|
+
* @param {string} args.oid - The SHA-1 object id to get. Annotated tags, commits, and trees are peeled.
|
|
12270
|
+
* @param {string} [args.filepath] - Don't return the object with `oid` itself, but resolve `oid` to a tree and then return the blob object at that filepath.
|
|
12271
|
+
* @param {object} [args.cache] - a [cache](cache.md) object
|
|
12272
|
+
*
|
|
12273
|
+
* @returns {Promise<ReadBlobResult>} Resolves successfully with a blob object description
|
|
12274
|
+
* @see ReadBlobResult
|
|
12275
|
+
*
|
|
12276
|
+
* @example
|
|
12277
|
+
* // Get the contents of 'README.md' in the main branch.
|
|
12278
|
+
* let commitOid = await git.resolveRef({ fs, dir: '/tutorial', ref: 'main' })
|
|
12279
|
+
* console.log(commitOid)
|
|
12280
|
+
* let { blob } = await git.readBlob({
|
|
12281
|
+
* fs,
|
|
12282
|
+
* dir: '/tutorial',
|
|
12283
|
+
* oid: commitOid,
|
|
12284
|
+
* filepath: 'README.md'
|
|
12285
|
+
* })
|
|
12286
|
+
* console.log(Buffer.from(blob).toString('utf8'))
|
|
12287
|
+
*
|
|
12288
|
+
*/
|
|
12289
|
+
async function readBlob({ fs, dir, gitdir = join(dir, ".git"), oid, filepath, cache = {} }) {
|
|
12290
|
+
try {
|
|
12291
|
+
assertParameter("fs", fs);
|
|
12292
|
+
assertParameter("gitdir", gitdir);
|
|
12293
|
+
assertParameter("oid", oid);
|
|
12294
|
+
const fsp = new FileSystem(fs);
|
|
12295
|
+
return await _readBlob({
|
|
12296
|
+
fs: fsp,
|
|
12297
|
+
cache,
|
|
12298
|
+
gitdir: await discoverGitdir({
|
|
12299
|
+
fsp,
|
|
12300
|
+
dotgit: gitdir
|
|
12301
|
+
}),
|
|
12302
|
+
oid,
|
|
12303
|
+
filepath
|
|
12304
|
+
});
|
|
12305
|
+
} catch (err) {
|
|
12306
|
+
err.caller = "git.readBlob";
|
|
12307
|
+
throw err;
|
|
12308
|
+
}
|
|
12309
|
+
}
|
|
11861
12310
|
/**
|
|
11862
12311
|
* Get the value of a symbolic ref or resolve a ref to its SHA-1 object id
|
|
11863
12312
|
*
|
|
@@ -12113,6 +12562,8 @@ ${obj.gpgsig ? obj.gpgsig : ""}`;
|
|
|
12113
12562
|
exports.checkout = checkout;
|
|
12114
12563
|
exports.clone = clone;
|
|
12115
12564
|
exports.fetch = fetch;
|
|
12565
|
+
exports.log = log;
|
|
12566
|
+
exports.readBlob = readBlob;
|
|
12116
12567
|
exports.resolveRef = resolveRef;
|
|
12117
12568
|
exports.statusMatrix = statusMatrix;
|
|
12118
12569
|
}));
|
|
@@ -18011,9 +18462,1940 @@ async function request({ onProgress, url, method = "GET", headers = {}, agent, b
|
|
|
18011
18462
|
}
|
|
18012
18463
|
var index = { request };
|
|
18013
18464
|
//#endregion
|
|
18014
|
-
//#region src/
|
|
18465
|
+
//#region src/shared/pm-install.ts
|
|
18015
18466
|
/**
|
|
18016
|
-
*
|
|
18467
|
+
* Bundled-toolchain `<pm> install` helpers.
|
|
18468
|
+
*
|
|
18469
|
+
* Imported by both:
|
|
18470
|
+
* - `packages/core/src/launcher.ts` (tsdown inlines this into
|
|
18471
|
+
* `dist/launcher.mjs`; the launcher cannot `import "@zenbujs/core"`)
|
|
18472
|
+
* - `packages/core/src/services/updater.ts` (resolved through normal
|
|
18473
|
+
* `@zenbujs/core/...` resolution at runtime)
|
|
18474
|
+
*
|
|
18475
|
+
* Both call sites operate on the apps-dir (`~/.zenbu/apps/<name>/`) and
|
|
18476
|
+
* the .app's `Resources/` (where `provisionToolchain` staged
|
|
18477
|
+
* `bun`, `pnpm`, etc.). The launcher kicks off the FIRST install at
|
|
18478
|
+
* launch; the updater service runs the SAME logic when an `update()`
|
|
18479
|
+
* lockfile-diff says deps drifted.
|
|
18480
|
+
*/
|
|
18481
|
+
function lockfileFor(type) {
|
|
18482
|
+
switch (type) {
|
|
18483
|
+
case "pnpm": return "pnpm-lock.yaml";
|
|
18484
|
+
case "npm": return "package-lock.json";
|
|
18485
|
+
case "yarn": return "yarn.lock";
|
|
18486
|
+
case "bun": return "bun.lock";
|
|
18487
|
+
}
|
|
18488
|
+
}
|
|
18489
|
+
function isYarnBerry(version) {
|
|
18490
|
+
const major = parseInt(version.split(".")[0] ?? "", 10);
|
|
18491
|
+
return Number.isFinite(major) && major >= 2;
|
|
18492
|
+
}
|
|
18493
|
+
function bundledToolPath(name, resourcesPath) {
|
|
18494
|
+
const candidates = [path.join(resourcesPath, "toolchain", "bin", name), path.join(resourcesPath, "toolchain", name)];
|
|
18495
|
+
for (const candidate of candidates) if (existsSync(candidate)) return candidate;
|
|
18496
|
+
return null;
|
|
18497
|
+
}
|
|
18498
|
+
/**
|
|
18499
|
+
* Resolve the entrypoint we'll exec for a given PM, mirroring the layout
|
|
18500
|
+
* `provisionToolchain` writes into the bundle's `Resources/toolchain/`.
|
|
18501
|
+
*/
|
|
18502
|
+
function bundledPmEntry(pm, resourcesPath) {
|
|
18503
|
+
switch (pm.type) {
|
|
18504
|
+
case "pnpm": {
|
|
18505
|
+
const p = path.join(resourcesPath, "toolchain", "pnpm", "bin", "pnpm.cjs");
|
|
18506
|
+
if (!existsSync(p)) throw new Error(`bundled pnpm entry not found at ${p}. The .app's toolchain is incomplete.`);
|
|
18507
|
+
return {
|
|
18508
|
+
kind: "js",
|
|
18509
|
+
path: p
|
|
18510
|
+
};
|
|
18511
|
+
}
|
|
18512
|
+
case "npm": {
|
|
18513
|
+
const p = path.join(resourcesPath, "toolchain", "npm", "bin", "npm-cli.js");
|
|
18514
|
+
if (!existsSync(p)) throw new Error(`bundled npm entry not found at ${p}. The .app's toolchain is incomplete.`);
|
|
18515
|
+
return {
|
|
18516
|
+
kind: "js",
|
|
18517
|
+
path: p
|
|
18518
|
+
};
|
|
18519
|
+
}
|
|
18520
|
+
case "yarn": {
|
|
18521
|
+
if (isYarnBerry(pm.version)) {
|
|
18522
|
+
const p = path.join(resourcesPath, "toolchain", "yarn.cjs");
|
|
18523
|
+
if (!existsSync(p)) throw new Error(`bundled yarn (berry) entry not found at ${p}. The .app's toolchain is incomplete.`);
|
|
18524
|
+
return {
|
|
18525
|
+
kind: "js",
|
|
18526
|
+
path: p
|
|
18527
|
+
};
|
|
18528
|
+
}
|
|
18529
|
+
const p = path.join(resourcesPath, "toolchain", "yarn", "bin", "yarn.js");
|
|
18530
|
+
if (!existsSync(p)) throw new Error(`bundled yarn (classic) entry not found at ${p}. The .app's toolchain is incomplete.`);
|
|
18531
|
+
return {
|
|
18532
|
+
kind: "js",
|
|
18533
|
+
path: p
|
|
18534
|
+
};
|
|
18535
|
+
}
|
|
18536
|
+
case "bun": return { kind: "bun" };
|
|
18537
|
+
}
|
|
18538
|
+
}
|
|
18539
|
+
function electronTargetVersion(appsDir) {
|
|
18540
|
+
if (process.versions.electron) return process.versions.electron;
|
|
18541
|
+
try {
|
|
18542
|
+
const pkg = JSON.parse(fs.readFileSync(path.join(appsDir, "package.json"), "utf8"));
|
|
18543
|
+
return (pkg.devDependencies?.electron ?? pkg.dependencies?.electron ?? "").replace(/^[^\d]*/, "") || "42.0.0";
|
|
18544
|
+
} catch {
|
|
18545
|
+
return "42.0.0";
|
|
18546
|
+
}
|
|
18547
|
+
}
|
|
18548
|
+
function buildInstallEnv(appsDir) {
|
|
18549
|
+
const target = electronTargetVersion(appsDir);
|
|
18550
|
+
return {
|
|
18551
|
+
...process.env,
|
|
18552
|
+
CI: "true",
|
|
18553
|
+
HOME: path.join(appsDir, ".zenbu", ".node-gyp"),
|
|
18554
|
+
npm_config_runtime: "electron",
|
|
18555
|
+
npm_config_target: target,
|
|
18556
|
+
npm_config_disturl: "https://electronjs.org/headers",
|
|
18557
|
+
npm_config_arch: process.arch
|
|
18558
|
+
};
|
|
18559
|
+
}
|
|
18560
|
+
/**
|
|
18561
|
+
* Best-effort progress regex per package manager. We pass each stdout line
|
|
18562
|
+
* through these and return a `progress` payload when one matches; otherwise
|
|
18563
|
+
* `null`. Failing to match is fine — the UI just won't show fine-grained
|
|
18564
|
+
* progress for that PM.
|
|
18565
|
+
*/
|
|
18566
|
+
const PNPM_RESOLVED_RE = /Progress:\s+resolved\s+(\d+),\s+reused\s+(\d+),\s+downloaded\s+(\d+)/i;
|
|
18567
|
+
const PNPM_PROGRESS_RE = /(\d+)\s*\/\s*(\d+)/;
|
|
18568
|
+
function parseInstallProgress(pm, line) {
|
|
18569
|
+
if (pm === "pnpm") {
|
|
18570
|
+
const m = line.match(PNPM_RESOLVED_RE);
|
|
18571
|
+
if (m) {
|
|
18572
|
+
const resolved = parseInt(m[1], 10);
|
|
18573
|
+
const reused = parseInt(m[2], 10);
|
|
18574
|
+
const downloaded = parseInt(m[3], 10);
|
|
18575
|
+
return {
|
|
18576
|
+
phase: "resolve",
|
|
18577
|
+
loaded: reused + downloaded,
|
|
18578
|
+
total: resolved,
|
|
18579
|
+
ratio: resolved > 0 ? (reused + downloaded) / resolved : void 0
|
|
18580
|
+
};
|
|
18581
|
+
}
|
|
18582
|
+
}
|
|
18583
|
+
const m = line.match(PNPM_PROGRESS_RE);
|
|
18584
|
+
if (m) {
|
|
18585
|
+
const loaded = parseInt(m[1], 10);
|
|
18586
|
+
const total = parseInt(m[2], 10);
|
|
18587
|
+
if (total > 0) return {
|
|
18588
|
+
loaded,
|
|
18589
|
+
total,
|
|
18590
|
+
ratio: loaded / total
|
|
18591
|
+
};
|
|
18592
|
+
}
|
|
18593
|
+
return null;
|
|
18594
|
+
}
|
|
18595
|
+
function spawnInstall(args) {
|
|
18596
|
+
const { bin, cliArgs, cwd, env, label, pmType, reporter, signal } = args;
|
|
18597
|
+
return new Promise((resolve, reject) => {
|
|
18598
|
+
if (signal?.aborted) {
|
|
18599
|
+
reject(/* @__PURE__ */ new Error(`${label} aborted before start`));
|
|
18600
|
+
return;
|
|
18601
|
+
}
|
|
18602
|
+
const usePiped = reporter != null;
|
|
18603
|
+
const child = spawn(bin, cliArgs, {
|
|
18604
|
+
cwd,
|
|
18605
|
+
stdio: usePiped ? [
|
|
18606
|
+
"inherit",
|
|
18607
|
+
"pipe",
|
|
18608
|
+
"pipe"
|
|
18609
|
+
] : "inherit",
|
|
18610
|
+
env
|
|
18611
|
+
});
|
|
18612
|
+
const onAbort = () => {
|
|
18613
|
+
try {
|
|
18614
|
+
child.kill("SIGTERM");
|
|
18615
|
+
} catch {}
|
|
18616
|
+
};
|
|
18617
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
18618
|
+
if (usePiped) {
|
|
18619
|
+
const wireStream = (stream, which) => {
|
|
18620
|
+
if (!stream) return;
|
|
18621
|
+
let buf = "";
|
|
18622
|
+
stream.setEncoding("utf8");
|
|
18623
|
+
stream.on("data", (chunk) => {
|
|
18624
|
+
buf += chunk;
|
|
18625
|
+
let nl;
|
|
18626
|
+
while ((nl = buf.indexOf("\n")) >= 0) {
|
|
18627
|
+
const rawLine = buf.slice(0, nl);
|
|
18628
|
+
buf = buf.slice(nl + 1);
|
|
18629
|
+
reporter?.rawLine?.(which, rawLine);
|
|
18630
|
+
const line = rawLine.replace(/\r/g, "").trimEnd();
|
|
18631
|
+
if (!line) continue;
|
|
18632
|
+
reporter?.message?.(line);
|
|
18633
|
+
const progress = parseInstallProgress(pmType, line);
|
|
18634
|
+
if (progress) reporter?.progress?.(progress);
|
|
18635
|
+
}
|
|
18636
|
+
});
|
|
18637
|
+
stream.on("end", () => {
|
|
18638
|
+
if (buf.length > 0) {
|
|
18639
|
+
reporter?.rawLine?.(which, buf);
|
|
18640
|
+
const line = buf.replace(/\r/g, "").trimEnd();
|
|
18641
|
+
if (line) reporter?.message?.(line);
|
|
18642
|
+
}
|
|
18643
|
+
});
|
|
18644
|
+
};
|
|
18645
|
+
wireStream(child.stdout, "stdout");
|
|
18646
|
+
wireStream(child.stderr, "stderr");
|
|
18647
|
+
}
|
|
18648
|
+
child.on("error", (err) => {
|
|
18649
|
+
signal?.removeEventListener("abort", onAbort);
|
|
18650
|
+
reject(err);
|
|
18651
|
+
});
|
|
18652
|
+
child.on("close", (code, sig) => {
|
|
18653
|
+
signal?.removeEventListener("abort", onAbort);
|
|
18654
|
+
if (code === 0) resolve();
|
|
18655
|
+
else if (signal?.aborted) reject(/* @__PURE__ */ new Error(`${label} aborted (${sig ?? code})`));
|
|
18656
|
+
else reject(/* @__PURE__ */ new Error(`${label} exited with code ${code}`));
|
|
18657
|
+
});
|
|
18658
|
+
});
|
|
18659
|
+
}
|
|
18660
|
+
async function runInstall(opts) {
|
|
18661
|
+
const { appsDir, resourcesPath, pm, reporter = null, signal } = opts;
|
|
18662
|
+
const env = buildInstallEnv(appsDir);
|
|
18663
|
+
const entry = bundledPmEntry(pm, resourcesPath);
|
|
18664
|
+
switch (pm.type) {
|
|
18665
|
+
case "pnpm": {
|
|
18666
|
+
if (entry.kind !== "js") throw new Error("internal: pnpm entry shape");
|
|
18667
|
+
const bun = bundledToolPath("bun", resourcesPath);
|
|
18668
|
+
if (!bun) throw new Error(`bundled bun not found in ${resourcesPath}/toolchain (required to host the pnpm.cjs entry)`);
|
|
18669
|
+
await spawnInstall({
|
|
18670
|
+
bin: bun,
|
|
18671
|
+
cliArgs: [
|
|
18672
|
+
entry.path,
|
|
18673
|
+
"install",
|
|
18674
|
+
"--reporter=append-only"
|
|
18675
|
+
],
|
|
18676
|
+
cwd: appsDir,
|
|
18677
|
+
env,
|
|
18678
|
+
label: "pnpm install",
|
|
18679
|
+
pmType: pm.type,
|
|
18680
|
+
reporter,
|
|
18681
|
+
signal
|
|
18682
|
+
});
|
|
18683
|
+
return;
|
|
18684
|
+
}
|
|
18685
|
+
case "npm": {
|
|
18686
|
+
if (entry.kind !== "js") throw new Error("internal: npm entry shape");
|
|
18687
|
+
const bun = bundledToolPath("bun", resourcesPath);
|
|
18688
|
+
if (!bun) throw new Error(`bundled bun not found in ${resourcesPath}/toolchain (required to host the npm-cli.js entry)`);
|
|
18689
|
+
await spawnInstall({
|
|
18690
|
+
bin: bun,
|
|
18691
|
+
cliArgs: [
|
|
18692
|
+
entry.path,
|
|
18693
|
+
"install",
|
|
18694
|
+
"--no-audit",
|
|
18695
|
+
"--no-fund",
|
|
18696
|
+
"--no-progress"
|
|
18697
|
+
],
|
|
18698
|
+
cwd: appsDir,
|
|
18699
|
+
env,
|
|
18700
|
+
label: "npm install",
|
|
18701
|
+
pmType: pm.type,
|
|
18702
|
+
reporter,
|
|
18703
|
+
signal
|
|
18704
|
+
});
|
|
18705
|
+
return;
|
|
18706
|
+
}
|
|
18707
|
+
case "yarn": {
|
|
18708
|
+
if (entry.kind !== "js") throw new Error("internal: yarn entry shape");
|
|
18709
|
+
const bun = bundledToolPath("bun", resourcesPath);
|
|
18710
|
+
if (!bun) throw new Error(`bundled bun not found in ${resourcesPath}/toolchain (required to host the yarn.js entry)`);
|
|
18711
|
+
if (isYarnBerry(pm.version)) await spawnInstall({
|
|
18712
|
+
bin: bun,
|
|
18713
|
+
cliArgs: [entry.path, "install"],
|
|
18714
|
+
cwd: appsDir,
|
|
18715
|
+
env: {
|
|
18716
|
+
...env,
|
|
18717
|
+
YARN_ENABLE_IMMUTABLE_INSTALLS: "false"
|
|
18718
|
+
},
|
|
18719
|
+
label: `yarn install (${pm.version})`,
|
|
18720
|
+
pmType: pm.type,
|
|
18721
|
+
reporter,
|
|
18722
|
+
signal
|
|
18723
|
+
});
|
|
18724
|
+
else {
|
|
18725
|
+
const rcPath = path.join(appsDir, ".zenbu", "yarn-classic-bun.yarnrc");
|
|
18726
|
+
await fsp.mkdir(path.dirname(rcPath), { recursive: true });
|
|
18727
|
+
await fsp.writeFile(rcPath, "strict-ssl false\n");
|
|
18728
|
+
await spawnInstall({
|
|
18729
|
+
bin: bun,
|
|
18730
|
+
cliArgs: [
|
|
18731
|
+
entry.path,
|
|
18732
|
+
"install",
|
|
18733
|
+
"--non-interactive",
|
|
18734
|
+
"--no-progress",
|
|
18735
|
+
"--network-timeout",
|
|
18736
|
+
"600000",
|
|
18737
|
+
"--use-yarnrc",
|
|
18738
|
+
rcPath,
|
|
18739
|
+
"--registry",
|
|
18740
|
+
"https://registry.npmjs.org/"
|
|
18741
|
+
],
|
|
18742
|
+
cwd: appsDir,
|
|
18743
|
+
env,
|
|
18744
|
+
label: `yarn install (${pm.version})`,
|
|
18745
|
+
pmType: pm.type,
|
|
18746
|
+
reporter,
|
|
18747
|
+
signal
|
|
18748
|
+
});
|
|
18749
|
+
}
|
|
18750
|
+
return;
|
|
18751
|
+
}
|
|
18752
|
+
case "bun": {
|
|
18753
|
+
const bun = bundledToolPath("bun", resourcesPath);
|
|
18754
|
+
if (!bun) throw new Error(`bundled bun not found in ${resourcesPath}/toolchain. The .app is missing required toolchain binaries.`);
|
|
18755
|
+
await spawnInstall({
|
|
18756
|
+
bin: bun,
|
|
18757
|
+
cliArgs: ["install", "--no-progress"],
|
|
18758
|
+
cwd: appsDir,
|
|
18759
|
+
env,
|
|
18760
|
+
label: "bun install",
|
|
18761
|
+
pmType: pm.type,
|
|
18762
|
+
reporter,
|
|
18763
|
+
signal
|
|
18764
|
+
});
|
|
18765
|
+
return;
|
|
18766
|
+
}
|
|
18767
|
+
}
|
|
18768
|
+
}
|
|
18769
|
+
async function fileHash(hash, filePath) {
|
|
18770
|
+
hash.update(filePath);
|
|
18771
|
+
hash.update("\0");
|
|
18772
|
+
try {
|
|
18773
|
+
hash.update(await fsp.readFile(filePath));
|
|
18774
|
+
} catch {}
|
|
18775
|
+
hash.update("\0");
|
|
18776
|
+
}
|
|
18777
|
+
async function depsSignature(appsDir, pm) {
|
|
18778
|
+
const hash = crypto$1.createHash("sha256");
|
|
18779
|
+
await fileHash(hash, path.join(appsDir, "package.json"));
|
|
18780
|
+
await fileHash(hash, path.join(appsDir, lockfileFor(pm.type)));
|
|
18781
|
+
hash.update(`${pm.type}@${pm.version}`);
|
|
18782
|
+
hash.update("\0");
|
|
18783
|
+
hash.update(process.versions.electron ?? "no-electron");
|
|
18784
|
+
hash.update("\0");
|
|
18785
|
+
hash.update(process.platform);
|
|
18786
|
+
hash.update("\0");
|
|
18787
|
+
hash.update(process.arch);
|
|
18788
|
+
return hash.digest("hex");
|
|
18789
|
+
}
|
|
18790
|
+
/**
|
|
18791
|
+
* Read `<appsDir>/.zenbu/deps-sig` (the signature recorded after the
|
|
18792
|
+
* last successful install). Returns `null` when missing.
|
|
18793
|
+
*/
|
|
18794
|
+
async function readDepsSig(appsDir) {
|
|
18795
|
+
const sigPath = path.join(appsDir, ".zenbu", "deps-sig");
|
|
18796
|
+
try {
|
|
18797
|
+
return await fsp.readFile(sigPath, "utf8");
|
|
18798
|
+
} catch {
|
|
18799
|
+
return null;
|
|
18800
|
+
}
|
|
18801
|
+
}
|
|
18802
|
+
async function writeDepsSig(appsDir, sig) {
|
|
18803
|
+
const sigPath = path.join(appsDir, ".zenbu", "deps-sig");
|
|
18804
|
+
await fsp.mkdir(path.dirname(sigPath), { recursive: true });
|
|
18805
|
+
await fsp.writeFile(sigPath, sig);
|
|
18806
|
+
}
|
|
18807
|
+
//#endregion
|
|
18808
|
+
//#region src/shared/host-version.ts
|
|
18809
|
+
/**
|
|
18810
|
+
* Single source of truth for reading the .app's "host version" — the
|
|
18811
|
+
* concrete semver string the developer authored on
|
|
18812
|
+
* `defineBuildConfig({ hostVersion: "..." })` and that
|
|
18813
|
+
* `zen build:electron` baked into `<bundle>/host.json`.
|
|
18814
|
+
*
|
|
18815
|
+
* Imported by both:
|
|
18816
|
+
* - `packages/core/src/launcher.ts` (tsdown inlines this into
|
|
18817
|
+
* `dist/launcher.mjs`; the launcher cannot `import "@zenbujs/core"`)
|
|
18818
|
+
* - `packages/core/src/services/updater.ts` (resolved through normal
|
|
18819
|
+
* `@zenbujs/core/...` resolution at runtime)
|
|
18820
|
+
*
|
|
18821
|
+
* The file lives at the bundle root (`<APP_PATH>/host.json`, where
|
|
18822
|
+
* `APP_PATH = app.getAppPath()`), separate from `app-config.json` so
|
|
18823
|
+
* its single purpose stays obvious.
|
|
18824
|
+
*/
|
|
18825
|
+
const HOST_VERSION_FILENAME = "host.json";
|
|
18826
|
+
/**
|
|
18827
|
+
* Read `<appPath>/host.json` and return its `version` field. Throws an
|
|
18828
|
+
* informative error if the file is missing, unreadable, malformed, or
|
|
18829
|
+
* the `version` field is missing/empty. Callers in dev mode should
|
|
18830
|
+
* check for the file's existence first (or use `tryReadHostVersion`).
|
|
18831
|
+
*/
|
|
18832
|
+
function readHostVersion(appPath) {
|
|
18833
|
+
const filePath = path.join(appPath, HOST_VERSION_FILENAME);
|
|
18834
|
+
let raw;
|
|
18835
|
+
try {
|
|
18836
|
+
raw = fs.readFileSync(filePath, "utf8");
|
|
18837
|
+
} catch (err) {
|
|
18838
|
+
const e = err;
|
|
18839
|
+
if (e.code === "ENOENT") throw new Error(`[host-version] missing ${filePath}. Was this .app built with a recent \`zen build:electron\`? The build step is responsible for writing host.json.`);
|
|
18840
|
+
throw new Error(`[host-version] failed to read ${filePath}: ${e.message ?? String(e)}`);
|
|
18841
|
+
}
|
|
18842
|
+
let parsed;
|
|
18843
|
+
try {
|
|
18844
|
+
parsed = JSON.parse(raw);
|
|
18845
|
+
} catch (err) {
|
|
18846
|
+
throw new Error(`[host-version] ${filePath} is not valid JSON: ${err.message}`);
|
|
18847
|
+
}
|
|
18848
|
+
if (typeof parsed !== "object" || parsed === null || typeof parsed.version !== "string" || parsed.version.trim().length === 0) throw new Error(`[host-version] ${filePath} is missing a non-empty \`version\` string.`);
|
|
18849
|
+
return {
|
|
18850
|
+
version: parsed.version.trim(),
|
|
18851
|
+
path: filePath
|
|
18852
|
+
};
|
|
18853
|
+
}
|
|
18854
|
+
//#endregion
|
|
18855
|
+
//#region ../../node_modules/.pnpm/semver@7.8.0/node_modules/semver/internal/constants.js
|
|
18856
|
+
var require_constants = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
18857
|
+
const SEMVER_SPEC_VERSION = "2.0.0";
|
|
18858
|
+
const MAX_LENGTH = 256;
|
|
18859
|
+
const MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || 9007199254740991;
|
|
18860
|
+
module.exports = {
|
|
18861
|
+
MAX_LENGTH,
|
|
18862
|
+
MAX_SAFE_COMPONENT_LENGTH: 16,
|
|
18863
|
+
MAX_SAFE_BUILD_LENGTH: MAX_LENGTH - 6,
|
|
18864
|
+
MAX_SAFE_INTEGER,
|
|
18865
|
+
RELEASE_TYPES: [
|
|
18866
|
+
"major",
|
|
18867
|
+
"premajor",
|
|
18868
|
+
"minor",
|
|
18869
|
+
"preminor",
|
|
18870
|
+
"patch",
|
|
18871
|
+
"prepatch",
|
|
18872
|
+
"prerelease"
|
|
18873
|
+
],
|
|
18874
|
+
SEMVER_SPEC_VERSION,
|
|
18875
|
+
FLAG_INCLUDE_PRERELEASE: 1,
|
|
18876
|
+
FLAG_LOOSE: 2
|
|
18877
|
+
};
|
|
18878
|
+
}));
|
|
18879
|
+
//#endregion
|
|
18880
|
+
//#region ../../node_modules/.pnpm/semver@7.8.0/node_modules/semver/internal/debug.js
|
|
18881
|
+
var require_debug = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
18882
|
+
module.exports = typeof process === "object" && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG) ? (...args) => console.error("SEMVER", ...args) : () => {};
|
|
18883
|
+
}));
|
|
18884
|
+
//#endregion
|
|
18885
|
+
//#region ../../node_modules/.pnpm/semver@7.8.0/node_modules/semver/internal/re.js
|
|
18886
|
+
var require_re = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
18887
|
+
const { MAX_SAFE_COMPONENT_LENGTH, MAX_SAFE_BUILD_LENGTH, MAX_LENGTH } = require_constants();
|
|
18888
|
+
const debug = require_debug();
|
|
18889
|
+
exports = module.exports = {};
|
|
18890
|
+
const re = exports.re = [];
|
|
18891
|
+
const safeRe = exports.safeRe = [];
|
|
18892
|
+
const src = exports.src = [];
|
|
18893
|
+
const safeSrc = exports.safeSrc = [];
|
|
18894
|
+
const t = exports.t = {};
|
|
18895
|
+
let R = 0;
|
|
18896
|
+
const LETTERDASHNUMBER = "[a-zA-Z0-9-]";
|
|
18897
|
+
const safeRegexReplacements = [
|
|
18898
|
+
["\\s", 1],
|
|
18899
|
+
["\\d", MAX_LENGTH],
|
|
18900
|
+
[LETTERDASHNUMBER, MAX_SAFE_BUILD_LENGTH]
|
|
18901
|
+
];
|
|
18902
|
+
const makeSafeRegex = (value) => {
|
|
18903
|
+
for (const [token, max] of safeRegexReplacements) value = value.split(`${token}*`).join(`${token}{0,${max}}`).split(`${token}+`).join(`${token}{1,${max}}`);
|
|
18904
|
+
return value;
|
|
18905
|
+
};
|
|
18906
|
+
const createToken = (name, value, isGlobal) => {
|
|
18907
|
+
const safe = makeSafeRegex(value);
|
|
18908
|
+
const index = R++;
|
|
18909
|
+
debug(name, index, value);
|
|
18910
|
+
t[name] = index;
|
|
18911
|
+
src[index] = value;
|
|
18912
|
+
safeSrc[index] = safe;
|
|
18913
|
+
re[index] = new RegExp(value, isGlobal ? "g" : void 0);
|
|
18914
|
+
safeRe[index] = new RegExp(safe, isGlobal ? "g" : void 0);
|
|
18915
|
+
};
|
|
18916
|
+
createToken("NUMERICIDENTIFIER", "0|[1-9]\\d*");
|
|
18917
|
+
createToken("NUMERICIDENTIFIERLOOSE", "\\d+");
|
|
18918
|
+
createToken("NONNUMERICIDENTIFIER", `\\d*[a-zA-Z-]${LETTERDASHNUMBER}*`);
|
|
18919
|
+
createToken("MAINVERSION", `(${src[t.NUMERICIDENTIFIER]})\\.(${src[t.NUMERICIDENTIFIER]})\\.(${src[t.NUMERICIDENTIFIER]})`);
|
|
18920
|
+
createToken("MAINVERSIONLOOSE", `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.(${src[t.NUMERICIDENTIFIERLOOSE]})\\.(${src[t.NUMERICIDENTIFIERLOOSE]})`);
|
|
18921
|
+
createToken("PRERELEASEIDENTIFIER", `(?:${src[t.NONNUMERICIDENTIFIER]}|${src[t.NUMERICIDENTIFIER]})`);
|
|
18922
|
+
createToken("PRERELEASEIDENTIFIERLOOSE", `(?:${src[t.NONNUMERICIDENTIFIER]}|${src[t.NUMERICIDENTIFIERLOOSE]})`);
|
|
18923
|
+
createToken("PRERELEASE", `(?:-(${src[t.PRERELEASEIDENTIFIER]}(?:\\.${src[t.PRERELEASEIDENTIFIER]})*))`);
|
|
18924
|
+
createToken("PRERELEASELOOSE", `(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${src[t.PRERELEASEIDENTIFIERLOOSE]})*))`);
|
|
18925
|
+
createToken("BUILDIDENTIFIER", `${LETTERDASHNUMBER}+`);
|
|
18926
|
+
createToken("BUILD", `(?:\\+(${src[t.BUILDIDENTIFIER]}(?:\\.${src[t.BUILDIDENTIFIER]})*))`);
|
|
18927
|
+
createToken("FULLPLAIN", `v?${src[t.MAINVERSION]}${src[t.PRERELEASE]}?${src[t.BUILD]}?`);
|
|
18928
|
+
createToken("FULL", `^${src[t.FULLPLAIN]}$`);
|
|
18929
|
+
createToken("LOOSEPLAIN", `[v=\\s]*${src[t.MAINVERSIONLOOSE]}${src[t.PRERELEASELOOSE]}?${src[t.BUILD]}?`);
|
|
18930
|
+
createToken("LOOSE", `^${src[t.LOOSEPLAIN]}$`);
|
|
18931
|
+
createToken("GTLT", "((?:<|>)?=?)");
|
|
18932
|
+
createToken("XRANGEIDENTIFIERLOOSE", `${src[t.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);
|
|
18933
|
+
createToken("XRANGEIDENTIFIER", `${src[t.NUMERICIDENTIFIER]}|x|X|\\*`);
|
|
18934
|
+
createToken("XRANGEPLAIN", `[v=\\s]*(${src[t.XRANGEIDENTIFIER]})(?:\\.(${src[t.XRANGEIDENTIFIER]})(?:\\.(${src[t.XRANGEIDENTIFIER]})(?:${src[t.PRERELEASE]})?${src[t.BUILD]}?)?)?`);
|
|
18935
|
+
createToken("XRANGEPLAINLOOSE", `[v=\\s]*(${src[t.XRANGEIDENTIFIERLOOSE]})(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})(?:${src[t.PRERELEASELOOSE]})?${src[t.BUILD]}?)?)?`);
|
|
18936
|
+
createToken("XRANGE", `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAIN]}$`);
|
|
18937
|
+
createToken("XRANGELOOSE", `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAINLOOSE]}$`);
|
|
18938
|
+
createToken("COERCEPLAIN", `(^|[^\\d])(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}})(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?`);
|
|
18939
|
+
createToken("COERCE", `${src[t.COERCEPLAIN]}(?:$|[^\\d])`);
|
|
18940
|
+
createToken("COERCEFULL", src[t.COERCEPLAIN] + `(?:${src[t.PRERELEASE]})?(?:${src[t.BUILD]})?(?:$|[^\\d])`);
|
|
18941
|
+
createToken("COERCERTL", src[t.COERCE], true);
|
|
18942
|
+
createToken("COERCERTLFULL", src[t.COERCEFULL], true);
|
|
18943
|
+
createToken("LONETILDE", "(?:~>?)");
|
|
18944
|
+
createToken("TILDETRIM", `(\\s*)${src[t.LONETILDE]}\\s+`, true);
|
|
18945
|
+
exports.tildeTrimReplace = "$1~";
|
|
18946
|
+
createToken("TILDE", `^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`);
|
|
18947
|
+
createToken("TILDELOOSE", `^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`);
|
|
18948
|
+
createToken("LONECARET", "(?:\\^)");
|
|
18949
|
+
createToken("CARETTRIM", `(\\s*)${src[t.LONECARET]}\\s+`, true);
|
|
18950
|
+
exports.caretTrimReplace = "$1^";
|
|
18951
|
+
createToken("CARET", `^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`);
|
|
18952
|
+
createToken("CARETLOOSE", `^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`);
|
|
18953
|
+
createToken("COMPARATORLOOSE", `^${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]})$|^$`);
|
|
18954
|
+
createToken("COMPARATOR", `^${src[t.GTLT]}\\s*(${src[t.FULLPLAIN]})$|^$`);
|
|
18955
|
+
createToken("COMPARATORTRIM", `(\\s*)${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]}|${src[t.XRANGEPLAIN]})`, true);
|
|
18956
|
+
exports.comparatorTrimReplace = "$1$2$3";
|
|
18957
|
+
createToken("HYPHENRANGE", `^\\s*(${src[t.XRANGEPLAIN]})\\s+-\\s+(${src[t.XRANGEPLAIN]})\\s*$`);
|
|
18958
|
+
createToken("HYPHENRANGELOOSE", `^\\s*(${src[t.XRANGEPLAINLOOSE]})\\s+-\\s+(${src[t.XRANGEPLAINLOOSE]})\\s*$`);
|
|
18959
|
+
createToken("STAR", "(<|>)?=?\\s*\\*");
|
|
18960
|
+
createToken("GTE0", "^\\s*>=\\s*0\\.0\\.0\\s*$");
|
|
18961
|
+
createToken("GTE0PRE", "^\\s*>=\\s*0\\.0\\.0-0\\s*$");
|
|
18962
|
+
}));
|
|
18963
|
+
//#endregion
|
|
18964
|
+
//#region ../../node_modules/.pnpm/semver@7.8.0/node_modules/semver/internal/parse-options.js
|
|
18965
|
+
var require_parse_options = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
18966
|
+
const looseOption = Object.freeze({ loose: true });
|
|
18967
|
+
const emptyOpts = Object.freeze({});
|
|
18968
|
+
const parseOptions = (options) => {
|
|
18969
|
+
if (!options) return emptyOpts;
|
|
18970
|
+
if (typeof options !== "object") return looseOption;
|
|
18971
|
+
return options;
|
|
18972
|
+
};
|
|
18973
|
+
module.exports = parseOptions;
|
|
18974
|
+
}));
|
|
18975
|
+
//#endregion
|
|
18976
|
+
//#region ../../node_modules/.pnpm/semver@7.8.0/node_modules/semver/internal/identifiers.js
|
|
18977
|
+
var require_identifiers = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
18978
|
+
const numeric = /^[0-9]+$/;
|
|
18979
|
+
const compareIdentifiers = (a, b) => {
|
|
18980
|
+
if (typeof a === "number" && typeof b === "number") return a === b ? 0 : a < b ? -1 : 1;
|
|
18981
|
+
const anum = numeric.test(a);
|
|
18982
|
+
const bnum = numeric.test(b);
|
|
18983
|
+
if (anum && bnum) {
|
|
18984
|
+
a = +a;
|
|
18985
|
+
b = +b;
|
|
18986
|
+
}
|
|
18987
|
+
return a === b ? 0 : anum && !bnum ? -1 : bnum && !anum ? 1 : a < b ? -1 : 1;
|
|
18988
|
+
};
|
|
18989
|
+
const rcompareIdentifiers = (a, b) => compareIdentifiers(b, a);
|
|
18990
|
+
module.exports = {
|
|
18991
|
+
compareIdentifiers,
|
|
18992
|
+
rcompareIdentifiers
|
|
18993
|
+
};
|
|
18994
|
+
}));
|
|
18995
|
+
//#endregion
|
|
18996
|
+
//#region ../../node_modules/.pnpm/semver@7.8.0/node_modules/semver/classes/semver.js
|
|
18997
|
+
var require_semver$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
18998
|
+
const debug = require_debug();
|
|
18999
|
+
const { MAX_LENGTH, MAX_SAFE_INTEGER } = require_constants();
|
|
19000
|
+
const { safeRe: re, t } = require_re();
|
|
19001
|
+
const parseOptions = require_parse_options();
|
|
19002
|
+
const { compareIdentifiers } = require_identifiers();
|
|
19003
|
+
module.exports = class SemVer {
|
|
19004
|
+
constructor(version, options) {
|
|
19005
|
+
options = parseOptions(options);
|
|
19006
|
+
if (version instanceof SemVer) if (version.loose === !!options.loose && version.includePrerelease === !!options.includePrerelease) return version;
|
|
19007
|
+
else version = version.version;
|
|
19008
|
+
else if (typeof version !== "string") throw new TypeError(`Invalid version. Must be a string. Got type "${typeof version}".`);
|
|
19009
|
+
if (version.length > MAX_LENGTH) throw new TypeError(`version is longer than ${MAX_LENGTH} characters`);
|
|
19010
|
+
debug("SemVer", version, options);
|
|
19011
|
+
this.options = options;
|
|
19012
|
+
this.loose = !!options.loose;
|
|
19013
|
+
this.includePrerelease = !!options.includePrerelease;
|
|
19014
|
+
const m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]);
|
|
19015
|
+
if (!m) throw new TypeError(`Invalid Version: ${version}`);
|
|
19016
|
+
this.raw = version;
|
|
19017
|
+
this.major = +m[1];
|
|
19018
|
+
this.minor = +m[2];
|
|
19019
|
+
this.patch = +m[3];
|
|
19020
|
+
if (this.major > MAX_SAFE_INTEGER || this.major < 0) throw new TypeError("Invalid major version");
|
|
19021
|
+
if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) throw new TypeError("Invalid minor version");
|
|
19022
|
+
if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) throw new TypeError("Invalid patch version");
|
|
19023
|
+
if (!m[4]) this.prerelease = [];
|
|
19024
|
+
else this.prerelease = m[4].split(".").map((id) => {
|
|
19025
|
+
if (/^[0-9]+$/.test(id)) {
|
|
19026
|
+
const num = +id;
|
|
19027
|
+
if (num >= 0 && num < MAX_SAFE_INTEGER) return num;
|
|
19028
|
+
}
|
|
19029
|
+
return id;
|
|
19030
|
+
});
|
|
19031
|
+
this.build = m[5] ? m[5].split(".") : [];
|
|
19032
|
+
this.format();
|
|
19033
|
+
}
|
|
19034
|
+
format() {
|
|
19035
|
+
this.version = `${this.major}.${this.minor}.${this.patch}`;
|
|
19036
|
+
if (this.prerelease.length) this.version += `-${this.prerelease.join(".")}`;
|
|
19037
|
+
return this.version;
|
|
19038
|
+
}
|
|
19039
|
+
toString() {
|
|
19040
|
+
return this.version;
|
|
19041
|
+
}
|
|
19042
|
+
compare(other) {
|
|
19043
|
+
debug("SemVer.compare", this.version, this.options, other);
|
|
19044
|
+
if (!(other instanceof SemVer)) {
|
|
19045
|
+
if (typeof other === "string" && other === this.version) return 0;
|
|
19046
|
+
other = new SemVer(other, this.options);
|
|
19047
|
+
}
|
|
19048
|
+
if (other.version === this.version) return 0;
|
|
19049
|
+
return this.compareMain(other) || this.comparePre(other);
|
|
19050
|
+
}
|
|
19051
|
+
compareMain(other) {
|
|
19052
|
+
if (!(other instanceof SemVer)) other = new SemVer(other, this.options);
|
|
19053
|
+
if (this.major < other.major) return -1;
|
|
19054
|
+
if (this.major > other.major) return 1;
|
|
19055
|
+
if (this.minor < other.minor) return -1;
|
|
19056
|
+
if (this.minor > other.minor) return 1;
|
|
19057
|
+
if (this.patch < other.patch) return -1;
|
|
19058
|
+
if (this.patch > other.patch) return 1;
|
|
19059
|
+
return 0;
|
|
19060
|
+
}
|
|
19061
|
+
comparePre(other) {
|
|
19062
|
+
if (!(other instanceof SemVer)) other = new SemVer(other, this.options);
|
|
19063
|
+
if (this.prerelease.length && !other.prerelease.length) return -1;
|
|
19064
|
+
else if (!this.prerelease.length && other.prerelease.length) return 1;
|
|
19065
|
+
else if (!this.prerelease.length && !other.prerelease.length) return 0;
|
|
19066
|
+
let i = 0;
|
|
19067
|
+
do {
|
|
19068
|
+
const a = this.prerelease[i];
|
|
19069
|
+
const b = other.prerelease[i];
|
|
19070
|
+
debug("prerelease compare", i, a, b);
|
|
19071
|
+
if (a === void 0 && b === void 0) return 0;
|
|
19072
|
+
else if (b === void 0) return 1;
|
|
19073
|
+
else if (a === void 0) return -1;
|
|
19074
|
+
else if (a === b) continue;
|
|
19075
|
+
else return compareIdentifiers(a, b);
|
|
19076
|
+
} while (++i);
|
|
19077
|
+
}
|
|
19078
|
+
compareBuild(other) {
|
|
19079
|
+
if (!(other instanceof SemVer)) other = new SemVer(other, this.options);
|
|
19080
|
+
let i = 0;
|
|
19081
|
+
do {
|
|
19082
|
+
const a = this.build[i];
|
|
19083
|
+
const b = other.build[i];
|
|
19084
|
+
debug("build compare", i, a, b);
|
|
19085
|
+
if (a === void 0 && b === void 0) return 0;
|
|
19086
|
+
else if (b === void 0) return 1;
|
|
19087
|
+
else if (a === void 0) return -1;
|
|
19088
|
+
else if (a === b) continue;
|
|
19089
|
+
else return compareIdentifiers(a, b);
|
|
19090
|
+
} while (++i);
|
|
19091
|
+
}
|
|
19092
|
+
inc(release, identifier, identifierBase) {
|
|
19093
|
+
if (release.startsWith("pre")) {
|
|
19094
|
+
if (!identifier && identifierBase === false) throw new Error("invalid increment argument: identifier is empty");
|
|
19095
|
+
if (identifier) {
|
|
19096
|
+
const match = `-${identifier}`.match(this.options.loose ? re[t.PRERELEASELOOSE] : re[t.PRERELEASE]);
|
|
19097
|
+
if (!match || match[1] !== identifier) throw new Error(`invalid identifier: ${identifier}`);
|
|
19098
|
+
}
|
|
19099
|
+
}
|
|
19100
|
+
switch (release) {
|
|
19101
|
+
case "premajor":
|
|
19102
|
+
this.prerelease.length = 0;
|
|
19103
|
+
this.patch = 0;
|
|
19104
|
+
this.minor = 0;
|
|
19105
|
+
this.major++;
|
|
19106
|
+
this.inc("pre", identifier, identifierBase);
|
|
19107
|
+
break;
|
|
19108
|
+
case "preminor":
|
|
19109
|
+
this.prerelease.length = 0;
|
|
19110
|
+
this.patch = 0;
|
|
19111
|
+
this.minor++;
|
|
19112
|
+
this.inc("pre", identifier, identifierBase);
|
|
19113
|
+
break;
|
|
19114
|
+
case "prepatch":
|
|
19115
|
+
this.prerelease.length = 0;
|
|
19116
|
+
this.inc("patch", identifier, identifierBase);
|
|
19117
|
+
this.inc("pre", identifier, identifierBase);
|
|
19118
|
+
break;
|
|
19119
|
+
case "prerelease":
|
|
19120
|
+
if (this.prerelease.length === 0) this.inc("patch", identifier, identifierBase);
|
|
19121
|
+
this.inc("pre", identifier, identifierBase);
|
|
19122
|
+
break;
|
|
19123
|
+
case "release":
|
|
19124
|
+
if (this.prerelease.length === 0) throw new Error(`version ${this.raw} is not a prerelease`);
|
|
19125
|
+
this.prerelease.length = 0;
|
|
19126
|
+
break;
|
|
19127
|
+
case "major":
|
|
19128
|
+
if (this.minor !== 0 || this.patch !== 0 || this.prerelease.length === 0) this.major++;
|
|
19129
|
+
this.minor = 0;
|
|
19130
|
+
this.patch = 0;
|
|
19131
|
+
this.prerelease = [];
|
|
19132
|
+
break;
|
|
19133
|
+
case "minor":
|
|
19134
|
+
if (this.patch !== 0 || this.prerelease.length === 0) this.minor++;
|
|
19135
|
+
this.patch = 0;
|
|
19136
|
+
this.prerelease = [];
|
|
19137
|
+
break;
|
|
19138
|
+
case "patch":
|
|
19139
|
+
if (this.prerelease.length === 0) this.patch++;
|
|
19140
|
+
this.prerelease = [];
|
|
19141
|
+
break;
|
|
19142
|
+
case "pre": {
|
|
19143
|
+
const base = Number(identifierBase) ? 1 : 0;
|
|
19144
|
+
if (this.prerelease.length === 0) this.prerelease = [base];
|
|
19145
|
+
else {
|
|
19146
|
+
let i = this.prerelease.length;
|
|
19147
|
+
while (--i >= 0) if (typeof this.prerelease[i] === "number") {
|
|
19148
|
+
this.prerelease[i]++;
|
|
19149
|
+
i = -2;
|
|
19150
|
+
}
|
|
19151
|
+
if (i === -1) {
|
|
19152
|
+
if (identifier === this.prerelease.join(".") && identifierBase === false) throw new Error("invalid increment argument: identifier already exists");
|
|
19153
|
+
this.prerelease.push(base);
|
|
19154
|
+
}
|
|
19155
|
+
}
|
|
19156
|
+
if (identifier) {
|
|
19157
|
+
let prerelease = [identifier, base];
|
|
19158
|
+
if (identifierBase === false) prerelease = [identifier];
|
|
19159
|
+
if (compareIdentifiers(this.prerelease[0], identifier) === 0) {
|
|
19160
|
+
if (isNaN(this.prerelease[1])) this.prerelease = prerelease;
|
|
19161
|
+
} else this.prerelease = prerelease;
|
|
19162
|
+
}
|
|
19163
|
+
break;
|
|
19164
|
+
}
|
|
19165
|
+
default: throw new Error(`invalid increment argument: ${release}`);
|
|
19166
|
+
}
|
|
19167
|
+
this.raw = this.format();
|
|
19168
|
+
if (this.build.length) this.raw += `+${this.build.join(".")}`;
|
|
19169
|
+
return this;
|
|
19170
|
+
}
|
|
19171
|
+
};
|
|
19172
|
+
}));
|
|
19173
|
+
//#endregion
|
|
19174
|
+
//#region ../../node_modules/.pnpm/semver@7.8.0/node_modules/semver/functions/parse.js
|
|
19175
|
+
var require_parse = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
19176
|
+
const SemVer = require_semver$1();
|
|
19177
|
+
const parse = (version, options, throwErrors = false) => {
|
|
19178
|
+
if (version instanceof SemVer) return version;
|
|
19179
|
+
try {
|
|
19180
|
+
return new SemVer(version, options);
|
|
19181
|
+
} catch (er) {
|
|
19182
|
+
if (!throwErrors) return null;
|
|
19183
|
+
throw er;
|
|
19184
|
+
}
|
|
19185
|
+
};
|
|
19186
|
+
module.exports = parse;
|
|
19187
|
+
}));
|
|
19188
|
+
//#endregion
|
|
19189
|
+
//#region ../../node_modules/.pnpm/semver@7.8.0/node_modules/semver/functions/valid.js
|
|
19190
|
+
var require_valid$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
19191
|
+
const parse = require_parse();
|
|
19192
|
+
const valid = (version, options) => {
|
|
19193
|
+
const v = parse(version, options);
|
|
19194
|
+
return v ? v.version : null;
|
|
19195
|
+
};
|
|
19196
|
+
module.exports = valid;
|
|
19197
|
+
}));
|
|
19198
|
+
//#endregion
|
|
19199
|
+
//#region ../../node_modules/.pnpm/semver@7.8.0/node_modules/semver/functions/clean.js
|
|
19200
|
+
var require_clean = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
19201
|
+
const parse = require_parse();
|
|
19202
|
+
const clean = (version, options) => {
|
|
19203
|
+
const s = parse(version.trim().replace(/^[=v]+/, ""), options);
|
|
19204
|
+
return s ? s.version : null;
|
|
19205
|
+
};
|
|
19206
|
+
module.exports = clean;
|
|
19207
|
+
}));
|
|
19208
|
+
//#endregion
|
|
19209
|
+
//#region ../../node_modules/.pnpm/semver@7.8.0/node_modules/semver/functions/inc.js
|
|
19210
|
+
var require_inc = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
19211
|
+
const SemVer = require_semver$1();
|
|
19212
|
+
const inc = (version, release, options, identifier, identifierBase) => {
|
|
19213
|
+
if (typeof options === "string") {
|
|
19214
|
+
identifierBase = identifier;
|
|
19215
|
+
identifier = options;
|
|
19216
|
+
options = void 0;
|
|
19217
|
+
}
|
|
19218
|
+
try {
|
|
19219
|
+
return new SemVer(version instanceof SemVer ? version.version : version, options).inc(release, identifier, identifierBase).version;
|
|
19220
|
+
} catch (er) {
|
|
19221
|
+
return null;
|
|
19222
|
+
}
|
|
19223
|
+
};
|
|
19224
|
+
module.exports = inc;
|
|
19225
|
+
}));
|
|
19226
|
+
//#endregion
|
|
19227
|
+
//#region ../../node_modules/.pnpm/semver@7.8.0/node_modules/semver/functions/diff.js
|
|
19228
|
+
var require_diff = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
19229
|
+
const parse = require_parse();
|
|
19230
|
+
const diff = (version1, version2) => {
|
|
19231
|
+
const v1 = parse(version1, null, true);
|
|
19232
|
+
const v2 = parse(version2, null, true);
|
|
19233
|
+
const comparison = v1.compare(v2);
|
|
19234
|
+
if (comparison === 0) return null;
|
|
19235
|
+
const v1Higher = comparison > 0;
|
|
19236
|
+
const highVersion = v1Higher ? v1 : v2;
|
|
19237
|
+
const lowVersion = v1Higher ? v2 : v1;
|
|
19238
|
+
const highHasPre = !!highVersion.prerelease.length;
|
|
19239
|
+
if (!!lowVersion.prerelease.length && !highHasPre) {
|
|
19240
|
+
if (!lowVersion.patch && !lowVersion.minor) return "major";
|
|
19241
|
+
if (lowVersion.compareMain(highVersion) === 0) {
|
|
19242
|
+
if (lowVersion.minor && !lowVersion.patch) return "minor";
|
|
19243
|
+
return "patch";
|
|
19244
|
+
}
|
|
19245
|
+
}
|
|
19246
|
+
const prefix = highHasPre ? "pre" : "";
|
|
19247
|
+
if (v1.major !== v2.major) return prefix + "major";
|
|
19248
|
+
if (v1.minor !== v2.minor) return prefix + "minor";
|
|
19249
|
+
if (v1.patch !== v2.patch) return prefix + "patch";
|
|
19250
|
+
return "prerelease";
|
|
19251
|
+
};
|
|
19252
|
+
module.exports = diff;
|
|
19253
|
+
}));
|
|
19254
|
+
//#endregion
|
|
19255
|
+
//#region ../../node_modules/.pnpm/semver@7.8.0/node_modules/semver/functions/major.js
|
|
19256
|
+
var require_major = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
19257
|
+
const SemVer = require_semver$1();
|
|
19258
|
+
const major = (a, loose) => new SemVer(a, loose).major;
|
|
19259
|
+
module.exports = major;
|
|
19260
|
+
}));
|
|
19261
|
+
//#endregion
|
|
19262
|
+
//#region ../../node_modules/.pnpm/semver@7.8.0/node_modules/semver/functions/minor.js
|
|
19263
|
+
var require_minor = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
19264
|
+
const SemVer = require_semver$1();
|
|
19265
|
+
const minor = (a, loose) => new SemVer(a, loose).minor;
|
|
19266
|
+
module.exports = minor;
|
|
19267
|
+
}));
|
|
19268
|
+
//#endregion
|
|
19269
|
+
//#region ../../node_modules/.pnpm/semver@7.8.0/node_modules/semver/functions/patch.js
|
|
19270
|
+
var require_patch = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
19271
|
+
const SemVer = require_semver$1();
|
|
19272
|
+
const patch = (a, loose) => new SemVer(a, loose).patch;
|
|
19273
|
+
module.exports = patch;
|
|
19274
|
+
}));
|
|
19275
|
+
//#endregion
|
|
19276
|
+
//#region ../../node_modules/.pnpm/semver@7.8.0/node_modules/semver/functions/prerelease.js
|
|
19277
|
+
var require_prerelease = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
19278
|
+
const parse = require_parse();
|
|
19279
|
+
const prerelease = (version, options) => {
|
|
19280
|
+
const parsed = parse(version, options);
|
|
19281
|
+
return parsed && parsed.prerelease.length ? parsed.prerelease : null;
|
|
19282
|
+
};
|
|
19283
|
+
module.exports = prerelease;
|
|
19284
|
+
}));
|
|
19285
|
+
//#endregion
|
|
19286
|
+
//#region ../../node_modules/.pnpm/semver@7.8.0/node_modules/semver/functions/compare.js
|
|
19287
|
+
var require_compare = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
19288
|
+
const SemVer = require_semver$1();
|
|
19289
|
+
const compare = (a, b, loose) => new SemVer(a, loose).compare(new SemVer(b, loose));
|
|
19290
|
+
module.exports = compare;
|
|
19291
|
+
}));
|
|
19292
|
+
//#endregion
|
|
19293
|
+
//#region ../../node_modules/.pnpm/semver@7.8.0/node_modules/semver/functions/rcompare.js
|
|
19294
|
+
var require_rcompare = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
19295
|
+
const compare = require_compare();
|
|
19296
|
+
const rcompare = (a, b, loose) => compare(b, a, loose);
|
|
19297
|
+
module.exports = rcompare;
|
|
19298
|
+
}));
|
|
19299
|
+
//#endregion
|
|
19300
|
+
//#region ../../node_modules/.pnpm/semver@7.8.0/node_modules/semver/functions/compare-loose.js
|
|
19301
|
+
var require_compare_loose = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
19302
|
+
const compare = require_compare();
|
|
19303
|
+
const compareLoose = (a, b) => compare(a, b, true);
|
|
19304
|
+
module.exports = compareLoose;
|
|
19305
|
+
}));
|
|
19306
|
+
//#endregion
|
|
19307
|
+
//#region ../../node_modules/.pnpm/semver@7.8.0/node_modules/semver/functions/compare-build.js
|
|
19308
|
+
var require_compare_build = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
19309
|
+
const SemVer = require_semver$1();
|
|
19310
|
+
const compareBuild = (a, b, loose) => {
|
|
19311
|
+
const versionA = new SemVer(a, loose);
|
|
19312
|
+
const versionB = new SemVer(b, loose);
|
|
19313
|
+
return versionA.compare(versionB) || versionA.compareBuild(versionB);
|
|
19314
|
+
};
|
|
19315
|
+
module.exports = compareBuild;
|
|
19316
|
+
}));
|
|
19317
|
+
//#endregion
|
|
19318
|
+
//#region ../../node_modules/.pnpm/semver@7.8.0/node_modules/semver/functions/sort.js
|
|
19319
|
+
var require_sort = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
19320
|
+
const compareBuild = require_compare_build();
|
|
19321
|
+
const sort = (list, loose) => list.sort((a, b) => compareBuild(a, b, loose));
|
|
19322
|
+
module.exports = sort;
|
|
19323
|
+
}));
|
|
19324
|
+
//#endregion
|
|
19325
|
+
//#region ../../node_modules/.pnpm/semver@7.8.0/node_modules/semver/functions/rsort.js
|
|
19326
|
+
var require_rsort = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
19327
|
+
const compareBuild = require_compare_build();
|
|
19328
|
+
const rsort = (list, loose) => list.sort((a, b) => compareBuild(b, a, loose));
|
|
19329
|
+
module.exports = rsort;
|
|
19330
|
+
}));
|
|
19331
|
+
//#endregion
|
|
19332
|
+
//#region ../../node_modules/.pnpm/semver@7.8.0/node_modules/semver/functions/gt.js
|
|
19333
|
+
var require_gt = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
19334
|
+
const compare = require_compare();
|
|
19335
|
+
const gt = (a, b, loose) => compare(a, b, loose) > 0;
|
|
19336
|
+
module.exports = gt;
|
|
19337
|
+
}));
|
|
19338
|
+
//#endregion
|
|
19339
|
+
//#region ../../node_modules/.pnpm/semver@7.8.0/node_modules/semver/functions/lt.js
|
|
19340
|
+
var require_lt = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
19341
|
+
const compare = require_compare();
|
|
19342
|
+
const lt = (a, b, loose) => compare(a, b, loose) < 0;
|
|
19343
|
+
module.exports = lt;
|
|
19344
|
+
}));
|
|
19345
|
+
//#endregion
|
|
19346
|
+
//#region ../../node_modules/.pnpm/semver@7.8.0/node_modules/semver/functions/eq.js
|
|
19347
|
+
var require_eq = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
19348
|
+
const compare = require_compare();
|
|
19349
|
+
const eq = (a, b, loose) => compare(a, b, loose) === 0;
|
|
19350
|
+
module.exports = eq;
|
|
19351
|
+
}));
|
|
19352
|
+
//#endregion
|
|
19353
|
+
//#region ../../node_modules/.pnpm/semver@7.8.0/node_modules/semver/functions/neq.js
|
|
19354
|
+
var require_neq = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
19355
|
+
const compare = require_compare();
|
|
19356
|
+
const neq = (a, b, loose) => compare(a, b, loose) !== 0;
|
|
19357
|
+
module.exports = neq;
|
|
19358
|
+
}));
|
|
19359
|
+
//#endregion
|
|
19360
|
+
//#region ../../node_modules/.pnpm/semver@7.8.0/node_modules/semver/functions/gte.js
|
|
19361
|
+
var require_gte = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
19362
|
+
const compare = require_compare();
|
|
19363
|
+
const gte = (a, b, loose) => compare(a, b, loose) >= 0;
|
|
19364
|
+
module.exports = gte;
|
|
19365
|
+
}));
|
|
19366
|
+
//#endregion
|
|
19367
|
+
//#region ../../node_modules/.pnpm/semver@7.8.0/node_modules/semver/functions/lte.js
|
|
19368
|
+
var require_lte = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
19369
|
+
const compare = require_compare();
|
|
19370
|
+
const lte = (a, b, loose) => compare(a, b, loose) <= 0;
|
|
19371
|
+
module.exports = lte;
|
|
19372
|
+
}));
|
|
19373
|
+
//#endregion
|
|
19374
|
+
//#region ../../node_modules/.pnpm/semver@7.8.0/node_modules/semver/functions/cmp.js
|
|
19375
|
+
var require_cmp = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
19376
|
+
const eq = require_eq();
|
|
19377
|
+
const neq = require_neq();
|
|
19378
|
+
const gt = require_gt();
|
|
19379
|
+
const gte = require_gte();
|
|
19380
|
+
const lt = require_lt();
|
|
19381
|
+
const lte = require_lte();
|
|
19382
|
+
const cmp = (a, op, b, loose) => {
|
|
19383
|
+
switch (op) {
|
|
19384
|
+
case "===":
|
|
19385
|
+
if (typeof a === "object") a = a.version;
|
|
19386
|
+
if (typeof b === "object") b = b.version;
|
|
19387
|
+
return a === b;
|
|
19388
|
+
case "!==":
|
|
19389
|
+
if (typeof a === "object") a = a.version;
|
|
19390
|
+
if (typeof b === "object") b = b.version;
|
|
19391
|
+
return a !== b;
|
|
19392
|
+
case "":
|
|
19393
|
+
case "=":
|
|
19394
|
+
case "==": return eq(a, b, loose);
|
|
19395
|
+
case "!=": return neq(a, b, loose);
|
|
19396
|
+
case ">": return gt(a, b, loose);
|
|
19397
|
+
case ">=": return gte(a, b, loose);
|
|
19398
|
+
case "<": return lt(a, b, loose);
|
|
19399
|
+
case "<=": return lte(a, b, loose);
|
|
19400
|
+
default: throw new TypeError(`Invalid operator: ${op}`);
|
|
19401
|
+
}
|
|
19402
|
+
};
|
|
19403
|
+
module.exports = cmp;
|
|
19404
|
+
}));
|
|
19405
|
+
//#endregion
|
|
19406
|
+
//#region ../../node_modules/.pnpm/semver@7.8.0/node_modules/semver/functions/coerce.js
|
|
19407
|
+
var require_coerce = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
19408
|
+
const SemVer = require_semver$1();
|
|
19409
|
+
const parse = require_parse();
|
|
19410
|
+
const { safeRe: re, t } = require_re();
|
|
19411
|
+
const coerce = (version, options) => {
|
|
19412
|
+
if (version instanceof SemVer) return version;
|
|
19413
|
+
if (typeof version === "number") version = String(version);
|
|
19414
|
+
if (typeof version !== "string") return null;
|
|
19415
|
+
options = options || {};
|
|
19416
|
+
let match = null;
|
|
19417
|
+
if (!options.rtl) match = version.match(options.includePrerelease ? re[t.COERCEFULL] : re[t.COERCE]);
|
|
19418
|
+
else {
|
|
19419
|
+
const coerceRtlRegex = options.includePrerelease ? re[t.COERCERTLFULL] : re[t.COERCERTL];
|
|
19420
|
+
let next;
|
|
19421
|
+
while ((next = coerceRtlRegex.exec(version)) && (!match || match.index + match[0].length !== version.length)) {
|
|
19422
|
+
if (!match || next.index + next[0].length !== match.index + match[0].length) match = next;
|
|
19423
|
+
coerceRtlRegex.lastIndex = next.index + next[1].length + next[2].length;
|
|
19424
|
+
}
|
|
19425
|
+
coerceRtlRegex.lastIndex = -1;
|
|
19426
|
+
}
|
|
19427
|
+
if (match === null) return null;
|
|
19428
|
+
const major = match[2];
|
|
19429
|
+
return parse(`${major}.${match[3] || "0"}.${match[4] || "0"}${options.includePrerelease && match[5] ? `-${match[5]}` : ""}${options.includePrerelease && match[6] ? `+${match[6]}` : ""}`, options);
|
|
19430
|
+
};
|
|
19431
|
+
module.exports = coerce;
|
|
19432
|
+
}));
|
|
19433
|
+
//#endregion
|
|
19434
|
+
//#region ../../node_modules/.pnpm/semver@7.8.0/node_modules/semver/functions/truncate.js
|
|
19435
|
+
var require_truncate = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
19436
|
+
const parse = require_parse();
|
|
19437
|
+
const constants = require_constants();
|
|
19438
|
+
const SemVer = require_semver$1();
|
|
19439
|
+
const truncate = (version, truncation, options) => {
|
|
19440
|
+
if (!constants.RELEASE_TYPES.includes(truncation)) return null;
|
|
19441
|
+
const clonedVersion = cloneInputVersion(version, options);
|
|
19442
|
+
return clonedVersion && doTruncation(clonedVersion, truncation);
|
|
19443
|
+
};
|
|
19444
|
+
const cloneInputVersion = (version, options) => {
|
|
19445
|
+
return parse(version instanceof SemVer ? version.version : version, options);
|
|
19446
|
+
};
|
|
19447
|
+
const doTruncation = (version, truncation) => {
|
|
19448
|
+
if (isPrerelease(truncation)) return version.version;
|
|
19449
|
+
version.prerelease = [];
|
|
19450
|
+
switch (truncation) {
|
|
19451
|
+
case "major":
|
|
19452
|
+
version.minor = 0;
|
|
19453
|
+
version.patch = 0;
|
|
19454
|
+
break;
|
|
19455
|
+
case "minor":
|
|
19456
|
+
version.patch = 0;
|
|
19457
|
+
break;
|
|
19458
|
+
}
|
|
19459
|
+
return version.format();
|
|
19460
|
+
};
|
|
19461
|
+
const isPrerelease = (type) => {
|
|
19462
|
+
return type.startsWith("pre");
|
|
19463
|
+
};
|
|
19464
|
+
module.exports = truncate;
|
|
19465
|
+
}));
|
|
19466
|
+
//#endregion
|
|
19467
|
+
//#region ../../node_modules/.pnpm/semver@7.8.0/node_modules/semver/internal/lrucache.js
|
|
19468
|
+
var require_lrucache = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
19469
|
+
var LRUCache = class {
|
|
19470
|
+
constructor() {
|
|
19471
|
+
this.max = 1e3;
|
|
19472
|
+
this.map = /* @__PURE__ */ new Map();
|
|
19473
|
+
}
|
|
19474
|
+
get(key) {
|
|
19475
|
+
const value = this.map.get(key);
|
|
19476
|
+
if (value === void 0) return;
|
|
19477
|
+
else {
|
|
19478
|
+
this.map.delete(key);
|
|
19479
|
+
this.map.set(key, value);
|
|
19480
|
+
return value;
|
|
19481
|
+
}
|
|
19482
|
+
}
|
|
19483
|
+
delete(key) {
|
|
19484
|
+
return this.map.delete(key);
|
|
19485
|
+
}
|
|
19486
|
+
set(key, value) {
|
|
19487
|
+
if (!this.delete(key) && value !== void 0) {
|
|
19488
|
+
if (this.map.size >= this.max) {
|
|
19489
|
+
const firstKey = this.map.keys().next().value;
|
|
19490
|
+
this.delete(firstKey);
|
|
19491
|
+
}
|
|
19492
|
+
this.map.set(key, value);
|
|
19493
|
+
}
|
|
19494
|
+
return this;
|
|
19495
|
+
}
|
|
19496
|
+
};
|
|
19497
|
+
module.exports = LRUCache;
|
|
19498
|
+
}));
|
|
19499
|
+
//#endregion
|
|
19500
|
+
//#region ../../node_modules/.pnpm/semver@7.8.0/node_modules/semver/classes/range.js
|
|
19501
|
+
var require_range = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
19502
|
+
const SPACE_CHARACTERS = /\s+/g;
|
|
19503
|
+
module.exports = class Range {
|
|
19504
|
+
constructor(range, options) {
|
|
19505
|
+
options = parseOptions(options);
|
|
19506
|
+
if (range instanceof Range) if (range.loose === !!options.loose && range.includePrerelease === !!options.includePrerelease) return range;
|
|
19507
|
+
else return new Range(range.raw, options);
|
|
19508
|
+
if (range instanceof Comparator) {
|
|
19509
|
+
this.raw = range.value;
|
|
19510
|
+
this.set = [[range]];
|
|
19511
|
+
this.formatted = void 0;
|
|
19512
|
+
return this;
|
|
19513
|
+
}
|
|
19514
|
+
this.options = options;
|
|
19515
|
+
this.loose = !!options.loose;
|
|
19516
|
+
this.includePrerelease = !!options.includePrerelease;
|
|
19517
|
+
this.raw = range.trim().replace(SPACE_CHARACTERS, " ");
|
|
19518
|
+
this.set = this.raw.split("||").map((r) => this.parseRange(r.trim())).filter((c) => c.length);
|
|
19519
|
+
if (!this.set.length) throw new TypeError(`Invalid SemVer Range: ${this.raw}`);
|
|
19520
|
+
if (this.set.length > 1) {
|
|
19521
|
+
const first = this.set[0];
|
|
19522
|
+
this.set = this.set.filter((c) => !isNullSet(c[0]));
|
|
19523
|
+
if (this.set.length === 0) this.set = [first];
|
|
19524
|
+
else if (this.set.length > 1) {
|
|
19525
|
+
for (const c of this.set) if (c.length === 1 && isAny(c[0])) {
|
|
19526
|
+
this.set = [c];
|
|
19527
|
+
break;
|
|
19528
|
+
}
|
|
19529
|
+
}
|
|
19530
|
+
}
|
|
19531
|
+
this.formatted = void 0;
|
|
19532
|
+
}
|
|
19533
|
+
get range() {
|
|
19534
|
+
if (this.formatted === void 0) {
|
|
19535
|
+
this.formatted = "";
|
|
19536
|
+
for (let i = 0; i < this.set.length; i++) {
|
|
19537
|
+
if (i > 0) this.formatted += "||";
|
|
19538
|
+
const comps = this.set[i];
|
|
19539
|
+
for (let k = 0; k < comps.length; k++) {
|
|
19540
|
+
if (k > 0) this.formatted += " ";
|
|
19541
|
+
this.formatted += comps[k].toString().trim();
|
|
19542
|
+
}
|
|
19543
|
+
}
|
|
19544
|
+
}
|
|
19545
|
+
return this.formatted;
|
|
19546
|
+
}
|
|
19547
|
+
format() {
|
|
19548
|
+
return this.range;
|
|
19549
|
+
}
|
|
19550
|
+
toString() {
|
|
19551
|
+
return this.range;
|
|
19552
|
+
}
|
|
19553
|
+
parseRange(range) {
|
|
19554
|
+
const memoKey = ((this.options.includePrerelease && FLAG_INCLUDE_PRERELEASE) | (this.options.loose && FLAG_LOOSE)) + ":" + range;
|
|
19555
|
+
const cached = cache.get(memoKey);
|
|
19556
|
+
if (cached) return cached;
|
|
19557
|
+
const loose = this.options.loose;
|
|
19558
|
+
const hr = loose ? re[t.HYPHENRANGELOOSE] : re[t.HYPHENRANGE];
|
|
19559
|
+
range = range.replace(hr, hyphenReplace(this.options.includePrerelease));
|
|
19560
|
+
debug("hyphen replace", range);
|
|
19561
|
+
range = range.replace(re[t.COMPARATORTRIM], comparatorTrimReplace);
|
|
19562
|
+
debug("comparator trim", range);
|
|
19563
|
+
range = range.replace(re[t.TILDETRIM], tildeTrimReplace);
|
|
19564
|
+
debug("tilde trim", range);
|
|
19565
|
+
range = range.replace(re[t.CARETTRIM], caretTrimReplace);
|
|
19566
|
+
debug("caret trim", range);
|
|
19567
|
+
let rangeList = range.split(" ").map((comp) => parseComparator(comp, this.options)).join(" ").split(/\s+/).map((comp) => replaceGTE0(comp, this.options));
|
|
19568
|
+
if (loose) rangeList = rangeList.filter((comp) => {
|
|
19569
|
+
debug("loose invalid filter", comp, this.options);
|
|
19570
|
+
return !!comp.match(re[t.COMPARATORLOOSE]);
|
|
19571
|
+
});
|
|
19572
|
+
debug("range list", rangeList);
|
|
19573
|
+
const rangeMap = /* @__PURE__ */ new Map();
|
|
19574
|
+
const comparators = rangeList.map((comp) => new Comparator(comp, this.options));
|
|
19575
|
+
for (const comp of comparators) {
|
|
19576
|
+
if (isNullSet(comp)) return [comp];
|
|
19577
|
+
rangeMap.set(comp.value, comp);
|
|
19578
|
+
}
|
|
19579
|
+
if (rangeMap.size > 1 && rangeMap.has("")) rangeMap.delete("");
|
|
19580
|
+
const result = [...rangeMap.values()];
|
|
19581
|
+
cache.set(memoKey, result);
|
|
19582
|
+
return result;
|
|
19583
|
+
}
|
|
19584
|
+
intersects(range, options) {
|
|
19585
|
+
if (!(range instanceof Range)) throw new TypeError("a Range is required");
|
|
19586
|
+
return this.set.some((thisComparators) => {
|
|
19587
|
+
return isSatisfiable(thisComparators, options) && range.set.some((rangeComparators) => {
|
|
19588
|
+
return isSatisfiable(rangeComparators, options) && thisComparators.every((thisComparator) => {
|
|
19589
|
+
return rangeComparators.every((rangeComparator) => {
|
|
19590
|
+
return thisComparator.intersects(rangeComparator, options);
|
|
19591
|
+
});
|
|
19592
|
+
});
|
|
19593
|
+
});
|
|
19594
|
+
});
|
|
19595
|
+
}
|
|
19596
|
+
test(version) {
|
|
19597
|
+
if (!version) return false;
|
|
19598
|
+
if (typeof version === "string") try {
|
|
19599
|
+
version = new SemVer(version, this.options);
|
|
19600
|
+
} catch (er) {
|
|
19601
|
+
return false;
|
|
19602
|
+
}
|
|
19603
|
+
for (let i = 0; i < this.set.length; i++) if (testSet(this.set[i], version, this.options)) return true;
|
|
19604
|
+
return false;
|
|
19605
|
+
}
|
|
19606
|
+
};
|
|
19607
|
+
const cache = new (require_lrucache())();
|
|
19608
|
+
const parseOptions = require_parse_options();
|
|
19609
|
+
const Comparator = require_comparator();
|
|
19610
|
+
const debug = require_debug();
|
|
19611
|
+
const SemVer = require_semver$1();
|
|
19612
|
+
const { safeRe: re, t, comparatorTrimReplace, tildeTrimReplace, caretTrimReplace } = require_re();
|
|
19613
|
+
const { FLAG_INCLUDE_PRERELEASE, FLAG_LOOSE } = require_constants();
|
|
19614
|
+
const isNullSet = (c) => c.value === "<0.0.0-0";
|
|
19615
|
+
const isAny = (c) => c.value === "";
|
|
19616
|
+
const isSatisfiable = (comparators, options) => {
|
|
19617
|
+
let result = true;
|
|
19618
|
+
const remainingComparators = comparators.slice();
|
|
19619
|
+
let testComparator = remainingComparators.pop();
|
|
19620
|
+
while (result && remainingComparators.length) {
|
|
19621
|
+
result = remainingComparators.every((otherComparator) => {
|
|
19622
|
+
return testComparator.intersects(otherComparator, options);
|
|
19623
|
+
});
|
|
19624
|
+
testComparator = remainingComparators.pop();
|
|
19625
|
+
}
|
|
19626
|
+
return result;
|
|
19627
|
+
};
|
|
19628
|
+
const parseComparator = (comp, options) => {
|
|
19629
|
+
comp = comp.replace(re[t.BUILD], "");
|
|
19630
|
+
debug("comp", comp, options);
|
|
19631
|
+
comp = replaceCarets(comp, options);
|
|
19632
|
+
debug("caret", comp);
|
|
19633
|
+
comp = replaceTildes(comp, options);
|
|
19634
|
+
debug("tildes", comp);
|
|
19635
|
+
comp = replaceXRanges(comp, options);
|
|
19636
|
+
debug("xrange", comp);
|
|
19637
|
+
comp = replaceStars(comp, options);
|
|
19638
|
+
debug("stars", comp);
|
|
19639
|
+
return comp;
|
|
19640
|
+
};
|
|
19641
|
+
const isX = (id) => !id || id.toLowerCase() === "x" || id === "*";
|
|
19642
|
+
const replaceTildes = (comp, options) => {
|
|
19643
|
+
return comp.trim().split(/\s+/).map((c) => replaceTilde(c, options)).join(" ");
|
|
19644
|
+
};
|
|
19645
|
+
const replaceTilde = (comp, options) => {
|
|
19646
|
+
const r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE];
|
|
19647
|
+
return comp.replace(r, (_, M, m, p, pr) => {
|
|
19648
|
+
debug("tilde", comp, _, M, m, p, pr);
|
|
19649
|
+
let ret;
|
|
19650
|
+
if (isX(M)) ret = "";
|
|
19651
|
+
else if (isX(m)) ret = `>=${M}.0.0 <${+M + 1}.0.0-0`;
|
|
19652
|
+
else if (isX(p)) ret = `>=${M}.${m}.0 <${M}.${+m + 1}.0-0`;
|
|
19653
|
+
else if (pr) {
|
|
19654
|
+
debug("replaceTilde pr", pr);
|
|
19655
|
+
ret = `>=${M}.${m}.${p}-${pr} <${M}.${+m + 1}.0-0`;
|
|
19656
|
+
} else ret = `>=${M}.${m}.${p} <${M}.${+m + 1}.0-0`;
|
|
19657
|
+
debug("tilde return", ret);
|
|
19658
|
+
return ret;
|
|
19659
|
+
});
|
|
19660
|
+
};
|
|
19661
|
+
const replaceCarets = (comp, options) => {
|
|
19662
|
+
return comp.trim().split(/\s+/).map((c) => replaceCaret(c, options)).join(" ");
|
|
19663
|
+
};
|
|
19664
|
+
const replaceCaret = (comp, options) => {
|
|
19665
|
+
debug("caret", comp, options);
|
|
19666
|
+
const r = options.loose ? re[t.CARETLOOSE] : re[t.CARET];
|
|
19667
|
+
const z = options.includePrerelease ? "-0" : "";
|
|
19668
|
+
return comp.replace(r, (_, M, m, p, pr) => {
|
|
19669
|
+
debug("caret", comp, _, M, m, p, pr);
|
|
19670
|
+
let ret;
|
|
19671
|
+
if (isX(M)) ret = "";
|
|
19672
|
+
else if (isX(m)) ret = `>=${M}.0.0${z} <${+M + 1}.0.0-0`;
|
|
19673
|
+
else if (isX(p)) if (M === "0") ret = `>=${M}.${m}.0${z} <${M}.${+m + 1}.0-0`;
|
|
19674
|
+
else ret = `>=${M}.${m}.0${z} <${+M + 1}.0.0-0`;
|
|
19675
|
+
else if (pr) {
|
|
19676
|
+
debug("replaceCaret pr", pr);
|
|
19677
|
+
if (M === "0") if (m === "0") ret = `>=${M}.${m}.${p}-${pr} <${M}.${m}.${+p + 1}-0`;
|
|
19678
|
+
else ret = `>=${M}.${m}.${p}-${pr} <${M}.${+m + 1}.0-0`;
|
|
19679
|
+
else ret = `>=${M}.${m}.${p}-${pr} <${+M + 1}.0.0-0`;
|
|
19680
|
+
} else {
|
|
19681
|
+
debug("no pr");
|
|
19682
|
+
if (M === "0") if (m === "0") ret = `>=${M}.${m}.${p}${z} <${M}.${m}.${+p + 1}-0`;
|
|
19683
|
+
else ret = `>=${M}.${m}.${p}${z} <${M}.${+m + 1}.0-0`;
|
|
19684
|
+
else ret = `>=${M}.${m}.${p} <${+M + 1}.0.0-0`;
|
|
19685
|
+
}
|
|
19686
|
+
debug("caret return", ret);
|
|
19687
|
+
return ret;
|
|
19688
|
+
});
|
|
19689
|
+
};
|
|
19690
|
+
const replaceXRanges = (comp, options) => {
|
|
19691
|
+
debug("replaceXRanges", comp, options);
|
|
19692
|
+
return comp.split(/\s+/).map((c) => replaceXRange(c, options)).join(" ");
|
|
19693
|
+
};
|
|
19694
|
+
const replaceXRange = (comp, options) => {
|
|
19695
|
+
comp = comp.trim();
|
|
19696
|
+
const r = options.loose ? re[t.XRANGELOOSE] : re[t.XRANGE];
|
|
19697
|
+
return comp.replace(r, (ret, gtlt, M, m, p, pr) => {
|
|
19698
|
+
debug("xRange", comp, ret, gtlt, M, m, p, pr);
|
|
19699
|
+
const xM = isX(M);
|
|
19700
|
+
const xm = xM || isX(m);
|
|
19701
|
+
const xp = xm || isX(p);
|
|
19702
|
+
const anyX = xp;
|
|
19703
|
+
if (gtlt === "=" && anyX) gtlt = "";
|
|
19704
|
+
pr = options.includePrerelease ? "-0" : "";
|
|
19705
|
+
if (xM) if (gtlt === ">" || gtlt === "<") ret = "<0.0.0-0";
|
|
19706
|
+
else ret = "*";
|
|
19707
|
+
else if (gtlt && anyX) {
|
|
19708
|
+
if (xm) m = 0;
|
|
19709
|
+
p = 0;
|
|
19710
|
+
if (gtlt === ">") {
|
|
19711
|
+
gtlt = ">=";
|
|
19712
|
+
if (xm) {
|
|
19713
|
+
M = +M + 1;
|
|
19714
|
+
m = 0;
|
|
19715
|
+
p = 0;
|
|
19716
|
+
} else {
|
|
19717
|
+
m = +m + 1;
|
|
19718
|
+
p = 0;
|
|
19719
|
+
}
|
|
19720
|
+
} else if (gtlt === "<=") {
|
|
19721
|
+
gtlt = "<";
|
|
19722
|
+
if (xm) M = +M + 1;
|
|
19723
|
+
else m = +m + 1;
|
|
19724
|
+
}
|
|
19725
|
+
if (gtlt === "<") pr = "-0";
|
|
19726
|
+
ret = `${gtlt + M}.${m}.${p}${pr}`;
|
|
19727
|
+
} else if (xm) ret = `>=${M}.0.0${pr} <${+M + 1}.0.0-0`;
|
|
19728
|
+
else if (xp) ret = `>=${M}.${m}.0${pr} <${M}.${+m + 1}.0-0`;
|
|
19729
|
+
debug("xRange return", ret);
|
|
19730
|
+
return ret;
|
|
19731
|
+
});
|
|
19732
|
+
};
|
|
19733
|
+
const replaceStars = (comp, options) => {
|
|
19734
|
+
debug("replaceStars", comp, options);
|
|
19735
|
+
return comp.trim().replace(re[t.STAR], "");
|
|
19736
|
+
};
|
|
19737
|
+
const replaceGTE0 = (comp, options) => {
|
|
19738
|
+
debug("replaceGTE0", comp, options);
|
|
19739
|
+
return comp.trim().replace(re[options.includePrerelease ? t.GTE0PRE : t.GTE0], "");
|
|
19740
|
+
};
|
|
19741
|
+
const hyphenReplace = (incPr) => ($0, from, fM, fm, fp, fpr, fb, to, tM, tm, tp, tpr) => {
|
|
19742
|
+
if (isX(fM)) from = "";
|
|
19743
|
+
else if (isX(fm)) from = `>=${fM}.0.0${incPr ? "-0" : ""}`;
|
|
19744
|
+
else if (isX(fp)) from = `>=${fM}.${fm}.0${incPr ? "-0" : ""}`;
|
|
19745
|
+
else if (fpr) from = `>=${from}`;
|
|
19746
|
+
else from = `>=${from}${incPr ? "-0" : ""}`;
|
|
19747
|
+
if (isX(tM)) to = "";
|
|
19748
|
+
else if (isX(tm)) to = `<${+tM + 1}.0.0-0`;
|
|
19749
|
+
else if (isX(tp)) to = `<${tM}.${+tm + 1}.0-0`;
|
|
19750
|
+
else if (tpr) to = `<=${tM}.${tm}.${tp}-${tpr}`;
|
|
19751
|
+
else if (incPr) to = `<${tM}.${tm}.${+tp + 1}-0`;
|
|
19752
|
+
else to = `<=${to}`;
|
|
19753
|
+
return `${from} ${to}`.trim();
|
|
19754
|
+
};
|
|
19755
|
+
const testSet = (set, version, options) => {
|
|
19756
|
+
for (let i = 0; i < set.length; i++) if (!set[i].test(version)) return false;
|
|
19757
|
+
if (version.prerelease.length && !options.includePrerelease) {
|
|
19758
|
+
for (let i = 0; i < set.length; i++) {
|
|
19759
|
+
debug(set[i].semver);
|
|
19760
|
+
if (set[i].semver === Comparator.ANY) continue;
|
|
19761
|
+
if (set[i].semver.prerelease.length > 0) {
|
|
19762
|
+
const allowed = set[i].semver;
|
|
19763
|
+
if (allowed.major === version.major && allowed.minor === version.minor && allowed.patch === version.patch) return true;
|
|
19764
|
+
}
|
|
19765
|
+
}
|
|
19766
|
+
return false;
|
|
19767
|
+
}
|
|
19768
|
+
return true;
|
|
19769
|
+
};
|
|
19770
|
+
}));
|
|
19771
|
+
//#endregion
|
|
19772
|
+
//#region ../../node_modules/.pnpm/semver@7.8.0/node_modules/semver/classes/comparator.js
|
|
19773
|
+
var require_comparator = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
19774
|
+
const ANY = Symbol("SemVer ANY");
|
|
19775
|
+
module.exports = class Comparator {
|
|
19776
|
+
static get ANY() {
|
|
19777
|
+
return ANY;
|
|
19778
|
+
}
|
|
19779
|
+
constructor(comp, options) {
|
|
19780
|
+
options = parseOptions(options);
|
|
19781
|
+
if (comp instanceof Comparator) if (comp.loose === !!options.loose) return comp;
|
|
19782
|
+
else comp = comp.value;
|
|
19783
|
+
comp = comp.trim().split(/\s+/).join(" ");
|
|
19784
|
+
debug("comparator", comp, options);
|
|
19785
|
+
this.options = options;
|
|
19786
|
+
this.loose = !!options.loose;
|
|
19787
|
+
this.parse(comp);
|
|
19788
|
+
if (this.semver === ANY) this.value = "";
|
|
19789
|
+
else this.value = this.operator + this.semver.version;
|
|
19790
|
+
debug("comp", this);
|
|
19791
|
+
}
|
|
19792
|
+
parse(comp) {
|
|
19793
|
+
const r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR];
|
|
19794
|
+
const m = comp.match(r);
|
|
19795
|
+
if (!m) throw new TypeError(`Invalid comparator: ${comp}`);
|
|
19796
|
+
this.operator = m[1] !== void 0 ? m[1] : "";
|
|
19797
|
+
if (this.operator === "=") this.operator = "";
|
|
19798
|
+
if (!m[2]) this.semver = ANY;
|
|
19799
|
+
else this.semver = new SemVer(m[2], this.options.loose);
|
|
19800
|
+
}
|
|
19801
|
+
toString() {
|
|
19802
|
+
return this.value;
|
|
19803
|
+
}
|
|
19804
|
+
test(version) {
|
|
19805
|
+
debug("Comparator.test", version, this.options.loose);
|
|
19806
|
+
if (this.semver === ANY || version === ANY) return true;
|
|
19807
|
+
if (typeof version === "string") try {
|
|
19808
|
+
version = new SemVer(version, this.options);
|
|
19809
|
+
} catch (er) {
|
|
19810
|
+
return false;
|
|
19811
|
+
}
|
|
19812
|
+
return cmp(version, this.operator, this.semver, this.options);
|
|
19813
|
+
}
|
|
19814
|
+
intersects(comp, options) {
|
|
19815
|
+
if (!(comp instanceof Comparator)) throw new TypeError("a Comparator is required");
|
|
19816
|
+
if (this.operator === "") {
|
|
19817
|
+
if (this.value === "") return true;
|
|
19818
|
+
return new Range(comp.value, options).test(this.value);
|
|
19819
|
+
} else if (comp.operator === "") {
|
|
19820
|
+
if (comp.value === "") return true;
|
|
19821
|
+
return new Range(this.value, options).test(comp.semver);
|
|
19822
|
+
}
|
|
19823
|
+
options = parseOptions(options);
|
|
19824
|
+
if (options.includePrerelease && (this.value === "<0.0.0-0" || comp.value === "<0.0.0-0")) return false;
|
|
19825
|
+
if (!options.includePrerelease && (this.value.startsWith("<0.0.0") || comp.value.startsWith("<0.0.0"))) return false;
|
|
19826
|
+
if (this.operator.startsWith(">") && comp.operator.startsWith(">")) return true;
|
|
19827
|
+
if (this.operator.startsWith("<") && comp.operator.startsWith("<")) return true;
|
|
19828
|
+
if (this.semver.version === comp.semver.version && this.operator.includes("=") && comp.operator.includes("=")) return true;
|
|
19829
|
+
if (cmp(this.semver, "<", comp.semver, options) && this.operator.startsWith(">") && comp.operator.startsWith("<")) return true;
|
|
19830
|
+
if (cmp(this.semver, ">", comp.semver, options) && this.operator.startsWith("<") && comp.operator.startsWith(">")) return true;
|
|
19831
|
+
return false;
|
|
19832
|
+
}
|
|
19833
|
+
};
|
|
19834
|
+
const parseOptions = require_parse_options();
|
|
19835
|
+
const { safeRe: re, t } = require_re();
|
|
19836
|
+
const cmp = require_cmp();
|
|
19837
|
+
const debug = require_debug();
|
|
19838
|
+
const SemVer = require_semver$1();
|
|
19839
|
+
const Range = require_range();
|
|
19840
|
+
}));
|
|
19841
|
+
//#endregion
|
|
19842
|
+
//#region ../../node_modules/.pnpm/semver@7.8.0/node_modules/semver/functions/satisfies.js
|
|
19843
|
+
var require_satisfies = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
19844
|
+
const Range = require_range();
|
|
19845
|
+
const satisfies = (version, range, options) => {
|
|
19846
|
+
try {
|
|
19847
|
+
range = new Range(range, options);
|
|
19848
|
+
} catch (er) {
|
|
19849
|
+
return false;
|
|
19850
|
+
}
|
|
19851
|
+
return range.test(version);
|
|
19852
|
+
};
|
|
19853
|
+
module.exports = satisfies;
|
|
19854
|
+
}));
|
|
19855
|
+
//#endregion
|
|
19856
|
+
//#region ../../node_modules/.pnpm/semver@7.8.0/node_modules/semver/ranges/to-comparators.js
|
|
19857
|
+
var require_to_comparators = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
19858
|
+
const Range = require_range();
|
|
19859
|
+
const toComparators = (range, options) => new Range(range, options).set.map((comp) => comp.map((c) => c.value).join(" ").trim().split(" "));
|
|
19860
|
+
module.exports = toComparators;
|
|
19861
|
+
}));
|
|
19862
|
+
//#endregion
|
|
19863
|
+
//#region ../../node_modules/.pnpm/semver@7.8.0/node_modules/semver/ranges/max-satisfying.js
|
|
19864
|
+
var require_max_satisfying = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
19865
|
+
const SemVer = require_semver$1();
|
|
19866
|
+
const Range = require_range();
|
|
19867
|
+
const maxSatisfying = (versions, range, options) => {
|
|
19868
|
+
let max = null;
|
|
19869
|
+
let maxSV = null;
|
|
19870
|
+
let rangeObj = null;
|
|
19871
|
+
try {
|
|
19872
|
+
rangeObj = new Range(range, options);
|
|
19873
|
+
} catch (er) {
|
|
19874
|
+
return null;
|
|
19875
|
+
}
|
|
19876
|
+
versions.forEach((v) => {
|
|
19877
|
+
if (rangeObj.test(v)) {
|
|
19878
|
+
if (!max || maxSV.compare(v) === -1) {
|
|
19879
|
+
max = v;
|
|
19880
|
+
maxSV = new SemVer(max, options);
|
|
19881
|
+
}
|
|
19882
|
+
}
|
|
19883
|
+
});
|
|
19884
|
+
return max;
|
|
19885
|
+
};
|
|
19886
|
+
module.exports = maxSatisfying;
|
|
19887
|
+
}));
|
|
19888
|
+
//#endregion
|
|
19889
|
+
//#region ../../node_modules/.pnpm/semver@7.8.0/node_modules/semver/ranges/min-satisfying.js
|
|
19890
|
+
var require_min_satisfying = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
19891
|
+
const SemVer = require_semver$1();
|
|
19892
|
+
const Range = require_range();
|
|
19893
|
+
const minSatisfying = (versions, range, options) => {
|
|
19894
|
+
let min = null;
|
|
19895
|
+
let minSV = null;
|
|
19896
|
+
let rangeObj = null;
|
|
19897
|
+
try {
|
|
19898
|
+
rangeObj = new Range(range, options);
|
|
19899
|
+
} catch (er) {
|
|
19900
|
+
return null;
|
|
19901
|
+
}
|
|
19902
|
+
versions.forEach((v) => {
|
|
19903
|
+
if (rangeObj.test(v)) {
|
|
19904
|
+
if (!min || minSV.compare(v) === 1) {
|
|
19905
|
+
min = v;
|
|
19906
|
+
minSV = new SemVer(min, options);
|
|
19907
|
+
}
|
|
19908
|
+
}
|
|
19909
|
+
});
|
|
19910
|
+
return min;
|
|
19911
|
+
};
|
|
19912
|
+
module.exports = minSatisfying;
|
|
19913
|
+
}));
|
|
19914
|
+
//#endregion
|
|
19915
|
+
//#region ../../node_modules/.pnpm/semver@7.8.0/node_modules/semver/ranges/min-version.js
|
|
19916
|
+
var require_min_version = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
19917
|
+
const SemVer = require_semver$1();
|
|
19918
|
+
const Range = require_range();
|
|
19919
|
+
const gt = require_gt();
|
|
19920
|
+
const minVersion = (range, loose) => {
|
|
19921
|
+
range = new Range(range, loose);
|
|
19922
|
+
let minver = new SemVer("0.0.0");
|
|
19923
|
+
if (range.test(minver)) return minver;
|
|
19924
|
+
minver = new SemVer("0.0.0-0");
|
|
19925
|
+
if (range.test(minver)) return minver;
|
|
19926
|
+
minver = null;
|
|
19927
|
+
for (let i = 0; i < range.set.length; ++i) {
|
|
19928
|
+
const comparators = range.set[i];
|
|
19929
|
+
let setMin = null;
|
|
19930
|
+
comparators.forEach((comparator) => {
|
|
19931
|
+
const compver = new SemVer(comparator.semver.version);
|
|
19932
|
+
switch (comparator.operator) {
|
|
19933
|
+
case ">":
|
|
19934
|
+
if (compver.prerelease.length === 0) compver.patch++;
|
|
19935
|
+
else compver.prerelease.push(0);
|
|
19936
|
+
compver.raw = compver.format();
|
|
19937
|
+
case "":
|
|
19938
|
+
case ">=":
|
|
19939
|
+
if (!setMin || gt(compver, setMin)) setMin = compver;
|
|
19940
|
+
break;
|
|
19941
|
+
case "<":
|
|
19942
|
+
case "<=": break;
|
|
19943
|
+
/* istanbul ignore next */
|
|
19944
|
+
default: throw new Error(`Unexpected operation: ${comparator.operator}`);
|
|
19945
|
+
}
|
|
19946
|
+
});
|
|
19947
|
+
if (setMin && (!minver || gt(minver, setMin))) minver = setMin;
|
|
19948
|
+
}
|
|
19949
|
+
if (minver && range.test(minver)) return minver;
|
|
19950
|
+
return null;
|
|
19951
|
+
};
|
|
19952
|
+
module.exports = minVersion;
|
|
19953
|
+
}));
|
|
19954
|
+
//#endregion
|
|
19955
|
+
//#region ../../node_modules/.pnpm/semver@7.8.0/node_modules/semver/ranges/valid.js
|
|
19956
|
+
var require_valid = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
19957
|
+
const Range = require_range();
|
|
19958
|
+
const validRange = (range, options) => {
|
|
19959
|
+
try {
|
|
19960
|
+
return new Range(range, options).range || "*";
|
|
19961
|
+
} catch (er) {
|
|
19962
|
+
return null;
|
|
19963
|
+
}
|
|
19964
|
+
};
|
|
19965
|
+
module.exports = validRange;
|
|
19966
|
+
}));
|
|
19967
|
+
//#endregion
|
|
19968
|
+
//#region ../../node_modules/.pnpm/semver@7.8.0/node_modules/semver/ranges/outside.js
|
|
19969
|
+
var require_outside = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
19970
|
+
const SemVer = require_semver$1();
|
|
19971
|
+
const Comparator = require_comparator();
|
|
19972
|
+
const { ANY } = Comparator;
|
|
19973
|
+
const Range = require_range();
|
|
19974
|
+
const satisfies = require_satisfies();
|
|
19975
|
+
const gt = require_gt();
|
|
19976
|
+
const lt = require_lt();
|
|
19977
|
+
const lte = require_lte();
|
|
19978
|
+
const gte = require_gte();
|
|
19979
|
+
const outside = (version, range, hilo, options) => {
|
|
19980
|
+
version = new SemVer(version, options);
|
|
19981
|
+
range = new Range(range, options);
|
|
19982
|
+
let gtfn, ltefn, ltfn, comp, ecomp;
|
|
19983
|
+
switch (hilo) {
|
|
19984
|
+
case ">":
|
|
19985
|
+
gtfn = gt;
|
|
19986
|
+
ltefn = lte;
|
|
19987
|
+
ltfn = lt;
|
|
19988
|
+
comp = ">";
|
|
19989
|
+
ecomp = ">=";
|
|
19990
|
+
break;
|
|
19991
|
+
case "<":
|
|
19992
|
+
gtfn = lt;
|
|
19993
|
+
ltefn = gte;
|
|
19994
|
+
ltfn = gt;
|
|
19995
|
+
comp = "<";
|
|
19996
|
+
ecomp = "<=";
|
|
19997
|
+
break;
|
|
19998
|
+
default: throw new TypeError("Must provide a hilo val of \"<\" or \">\"");
|
|
19999
|
+
}
|
|
20000
|
+
if (satisfies(version, range, options)) return false;
|
|
20001
|
+
for (let i = 0; i < range.set.length; ++i) {
|
|
20002
|
+
const comparators = range.set[i];
|
|
20003
|
+
let high = null;
|
|
20004
|
+
let low = null;
|
|
20005
|
+
comparators.forEach((comparator) => {
|
|
20006
|
+
if (comparator.semver === ANY) comparator = new Comparator(">=0.0.0");
|
|
20007
|
+
high = high || comparator;
|
|
20008
|
+
low = low || comparator;
|
|
20009
|
+
if (gtfn(comparator.semver, high.semver, options)) high = comparator;
|
|
20010
|
+
else if (ltfn(comparator.semver, low.semver, options)) low = comparator;
|
|
20011
|
+
});
|
|
20012
|
+
if (high.operator === comp || high.operator === ecomp) return false;
|
|
20013
|
+
if ((!low.operator || low.operator === comp) && ltefn(version, low.semver)) return false;
|
|
20014
|
+
else if (low.operator === ecomp && ltfn(version, low.semver)) return false;
|
|
20015
|
+
}
|
|
20016
|
+
return true;
|
|
20017
|
+
};
|
|
20018
|
+
module.exports = outside;
|
|
20019
|
+
}));
|
|
20020
|
+
//#endregion
|
|
20021
|
+
//#region ../../node_modules/.pnpm/semver@7.8.0/node_modules/semver/ranges/gtr.js
|
|
20022
|
+
var require_gtr = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
20023
|
+
const outside = require_outside();
|
|
20024
|
+
const gtr = (version, range, options) => outside(version, range, ">", options);
|
|
20025
|
+
module.exports = gtr;
|
|
20026
|
+
}));
|
|
20027
|
+
//#endregion
|
|
20028
|
+
//#region ../../node_modules/.pnpm/semver@7.8.0/node_modules/semver/ranges/ltr.js
|
|
20029
|
+
var require_ltr = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
20030
|
+
const outside = require_outside();
|
|
20031
|
+
const ltr = (version, range, options) => outside(version, range, "<", options);
|
|
20032
|
+
module.exports = ltr;
|
|
20033
|
+
}));
|
|
20034
|
+
//#endregion
|
|
20035
|
+
//#region ../../node_modules/.pnpm/semver@7.8.0/node_modules/semver/ranges/intersects.js
|
|
20036
|
+
var require_intersects = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
20037
|
+
const Range = require_range();
|
|
20038
|
+
const intersects = (r1, r2, options) => {
|
|
20039
|
+
r1 = new Range(r1, options);
|
|
20040
|
+
r2 = new Range(r2, options);
|
|
20041
|
+
return r1.intersects(r2, options);
|
|
20042
|
+
};
|
|
20043
|
+
module.exports = intersects;
|
|
20044
|
+
}));
|
|
20045
|
+
//#endregion
|
|
20046
|
+
//#region ../../node_modules/.pnpm/semver@7.8.0/node_modules/semver/ranges/simplify.js
|
|
20047
|
+
var require_simplify = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
20048
|
+
const satisfies = require_satisfies();
|
|
20049
|
+
const compare = require_compare();
|
|
20050
|
+
module.exports = (versions, range, options) => {
|
|
20051
|
+
const set = [];
|
|
20052
|
+
let first = null;
|
|
20053
|
+
let prev = null;
|
|
20054
|
+
const v = versions.sort((a, b) => compare(a, b, options));
|
|
20055
|
+
for (const version of v) if (satisfies(version, range, options)) {
|
|
20056
|
+
prev = version;
|
|
20057
|
+
if (!first) first = version;
|
|
20058
|
+
} else {
|
|
20059
|
+
if (prev) set.push([first, prev]);
|
|
20060
|
+
prev = null;
|
|
20061
|
+
first = null;
|
|
20062
|
+
}
|
|
20063
|
+
if (first) set.push([first, null]);
|
|
20064
|
+
const ranges = [];
|
|
20065
|
+
for (const [min, max] of set) if (min === max) ranges.push(min);
|
|
20066
|
+
else if (!max && min === v[0]) ranges.push("*");
|
|
20067
|
+
else if (!max) ranges.push(`>=${min}`);
|
|
20068
|
+
else if (min === v[0]) ranges.push(`<=${max}`);
|
|
20069
|
+
else ranges.push(`${min} - ${max}`);
|
|
20070
|
+
const simplified = ranges.join(" || ");
|
|
20071
|
+
const original = typeof range.raw === "string" ? range.raw : String(range);
|
|
20072
|
+
return simplified.length < original.length ? simplified : range;
|
|
20073
|
+
};
|
|
20074
|
+
}));
|
|
20075
|
+
//#endregion
|
|
20076
|
+
//#region ../../node_modules/.pnpm/semver@7.8.0/node_modules/semver/ranges/subset.js
|
|
20077
|
+
var require_subset = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
20078
|
+
const Range = require_range();
|
|
20079
|
+
const Comparator = require_comparator();
|
|
20080
|
+
const { ANY } = Comparator;
|
|
20081
|
+
const satisfies = require_satisfies();
|
|
20082
|
+
const compare = require_compare();
|
|
20083
|
+
const subset = (sub, dom, options = {}) => {
|
|
20084
|
+
if (sub === dom) return true;
|
|
20085
|
+
sub = new Range(sub, options);
|
|
20086
|
+
dom = new Range(dom, options);
|
|
20087
|
+
let sawNonNull = false;
|
|
20088
|
+
OUTER: for (const simpleSub of sub.set) {
|
|
20089
|
+
for (const simpleDom of dom.set) {
|
|
20090
|
+
const isSub = simpleSubset(simpleSub, simpleDom, options);
|
|
20091
|
+
sawNonNull = sawNonNull || isSub !== null;
|
|
20092
|
+
if (isSub) continue OUTER;
|
|
20093
|
+
}
|
|
20094
|
+
if (sawNonNull) return false;
|
|
20095
|
+
}
|
|
20096
|
+
return true;
|
|
20097
|
+
};
|
|
20098
|
+
const minimumVersionWithPreRelease = [new Comparator(">=0.0.0-0")];
|
|
20099
|
+
const minimumVersion = [new Comparator(">=0.0.0")];
|
|
20100
|
+
const simpleSubset = (sub, dom, options) => {
|
|
20101
|
+
if (sub === dom) return true;
|
|
20102
|
+
if (sub.length === 1 && sub[0].semver === ANY) if (dom.length === 1 && dom[0].semver === ANY) return true;
|
|
20103
|
+
else if (options.includePrerelease) sub = minimumVersionWithPreRelease;
|
|
20104
|
+
else sub = minimumVersion;
|
|
20105
|
+
if (dom.length === 1 && dom[0].semver === ANY) if (options.includePrerelease) return true;
|
|
20106
|
+
else dom = minimumVersion;
|
|
20107
|
+
const eqSet = /* @__PURE__ */ new Set();
|
|
20108
|
+
let gt, lt;
|
|
20109
|
+
for (const c of sub) if (c.operator === ">" || c.operator === ">=") gt = higherGT(gt, c, options);
|
|
20110
|
+
else if (c.operator === "<" || c.operator === "<=") lt = lowerLT(lt, c, options);
|
|
20111
|
+
else eqSet.add(c.semver);
|
|
20112
|
+
if (eqSet.size > 1) return null;
|
|
20113
|
+
let gtltComp;
|
|
20114
|
+
if (gt && lt) {
|
|
20115
|
+
gtltComp = compare(gt.semver, lt.semver, options);
|
|
20116
|
+
if (gtltComp > 0) return null;
|
|
20117
|
+
else if (gtltComp === 0 && (gt.operator !== ">=" || lt.operator !== "<=")) return null;
|
|
20118
|
+
}
|
|
20119
|
+
for (const eq of eqSet) {
|
|
20120
|
+
if (gt && !satisfies(eq, String(gt), options)) return null;
|
|
20121
|
+
if (lt && !satisfies(eq, String(lt), options)) return null;
|
|
20122
|
+
for (const c of dom) if (!satisfies(eq, String(c), options)) return false;
|
|
20123
|
+
return true;
|
|
20124
|
+
}
|
|
20125
|
+
let higher, lower;
|
|
20126
|
+
let hasDomLT, hasDomGT;
|
|
20127
|
+
let needDomLTPre = lt && !options.includePrerelease && lt.semver.prerelease.length ? lt.semver : false;
|
|
20128
|
+
let needDomGTPre = gt && !options.includePrerelease && gt.semver.prerelease.length ? gt.semver : false;
|
|
20129
|
+
if (needDomLTPre && needDomLTPre.prerelease.length === 1 && lt.operator === "<" && needDomLTPre.prerelease[0] === 0) needDomLTPre = false;
|
|
20130
|
+
for (const c of dom) {
|
|
20131
|
+
hasDomGT = hasDomGT || c.operator === ">" || c.operator === ">=";
|
|
20132
|
+
hasDomLT = hasDomLT || c.operator === "<" || c.operator === "<=";
|
|
20133
|
+
if (gt) {
|
|
20134
|
+
if (needDomGTPre) {
|
|
20135
|
+
if (c.semver.prerelease && c.semver.prerelease.length && c.semver.major === needDomGTPre.major && c.semver.minor === needDomGTPre.minor && c.semver.patch === needDomGTPre.patch) needDomGTPre = false;
|
|
20136
|
+
}
|
|
20137
|
+
if (c.operator === ">" || c.operator === ">=") {
|
|
20138
|
+
higher = higherGT(gt, c, options);
|
|
20139
|
+
if (higher === c && higher !== gt) return false;
|
|
20140
|
+
} else if (gt.operator === ">=" && !satisfies(gt.semver, String(c), options)) return false;
|
|
20141
|
+
}
|
|
20142
|
+
if (lt) {
|
|
20143
|
+
if (needDomLTPre) {
|
|
20144
|
+
if (c.semver.prerelease && c.semver.prerelease.length && c.semver.major === needDomLTPre.major && c.semver.minor === needDomLTPre.minor && c.semver.patch === needDomLTPre.patch) needDomLTPre = false;
|
|
20145
|
+
}
|
|
20146
|
+
if (c.operator === "<" || c.operator === "<=") {
|
|
20147
|
+
lower = lowerLT(lt, c, options);
|
|
20148
|
+
if (lower === c && lower !== lt) return false;
|
|
20149
|
+
} else if (lt.operator === "<=" && !satisfies(lt.semver, String(c), options)) return false;
|
|
20150
|
+
}
|
|
20151
|
+
if (!c.operator && (lt || gt) && gtltComp !== 0) return false;
|
|
20152
|
+
}
|
|
20153
|
+
if (gt && hasDomLT && !lt && gtltComp !== 0) return false;
|
|
20154
|
+
if (lt && hasDomGT && !gt && gtltComp !== 0) return false;
|
|
20155
|
+
if (needDomGTPre || needDomLTPre) return false;
|
|
20156
|
+
return true;
|
|
20157
|
+
};
|
|
20158
|
+
const higherGT = (a, b, options) => {
|
|
20159
|
+
if (!a) return b;
|
|
20160
|
+
const comp = compare(a.semver, b.semver, options);
|
|
20161
|
+
return comp > 0 ? a : comp < 0 ? b : b.operator === ">" && a.operator === ">=" ? b : a;
|
|
20162
|
+
};
|
|
20163
|
+
const lowerLT = (a, b, options) => {
|
|
20164
|
+
if (!a) return b;
|
|
20165
|
+
const comp = compare(a.semver, b.semver, options);
|
|
20166
|
+
return comp < 0 ? a : comp > 0 ? b : b.operator === "<" && a.operator === "<=" ? b : a;
|
|
20167
|
+
};
|
|
20168
|
+
module.exports = subset;
|
|
20169
|
+
}));
|
|
20170
|
+
//#endregion
|
|
20171
|
+
//#region src/shared/range-resolver.ts
|
|
20172
|
+
/**
|
|
20173
|
+
* Resolves the latest commit on a source-mirror branch whose
|
|
20174
|
+
* `package.json#zenbu.host` semver range still satisfies the running
|
|
20175
|
+
* .app's `host.json#version`. Pure functions over `isomorphic-git` plus
|
|
20176
|
+
* `semver` — no Electron dependency.
|
|
20177
|
+
*
|
|
20178
|
+
* Imported by both:
|
|
20179
|
+
* - `packages/core/src/launcher.ts` (tsdown inlines this into
|
|
20180
|
+
* `dist/launcher.mjs`; the launcher cannot `import "@zenbujs/core"`)
|
|
20181
|
+
* - `packages/core/src/services/updater.ts` (resolved through normal
|
|
20182
|
+
* `@zenbujs/core/...` resolution at runtime)
|
|
20183
|
+
*
|
|
20184
|
+
* Algorithm:
|
|
20185
|
+
* 1. Hot path — resolve `refs/remotes/origin/<branch>` (caller is
|
|
20186
|
+
* responsible for an upstream-fresh ref; the launcher and updater
|
|
20187
|
+
* both `git.fetch` before invoking us). If the tip's
|
|
20188
|
+
* `package.json#zenbu.host` already satisfies `hostVersion`,
|
|
20189
|
+
* return tip.
|
|
20190
|
+
* 2. Cold path — deepen the local shallow history geometrically
|
|
20191
|
+
* (`git.fetch({depth: nextDepth, relative: false})`), running
|
|
20192
|
+
* `git.log({depth: nextDepth})` to enumerate the now-known history.
|
|
20193
|
+
* Lower-bound binary search inside that window for the smallest
|
|
20194
|
+
* index whose commit is compatible — i.e. the LATEST compatible
|
|
20195
|
+
* commit. The search assumes monotonic ranges (newer commits'
|
|
20196
|
+
* `zenbu.host` is equal-or-stricter than older commits'); if a
|
|
20197
|
+
* project violates this, the resolver may pick a slightly older
|
|
20198
|
+
* compatible commit than the absolute latest.
|
|
20199
|
+
* 3. If deepen exhausts the branch's history without finding a
|
|
20200
|
+
* compatible commit, return `targetSha: null`. The caller decides
|
|
20201
|
+
* what to do (the launcher errors out; the updater service surfaces
|
|
20202
|
+
* `phase: "incompatible"`).
|
|
20203
|
+
*/
|
|
20204
|
+
var import_semver = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
20205
|
+
const internalRe = require_re();
|
|
20206
|
+
const constants = require_constants();
|
|
20207
|
+
const SemVer = require_semver$1();
|
|
20208
|
+
const identifiers = require_identifiers();
|
|
20209
|
+
module.exports = {
|
|
20210
|
+
parse: require_parse(),
|
|
20211
|
+
valid: require_valid$1(),
|
|
20212
|
+
clean: require_clean(),
|
|
20213
|
+
inc: require_inc(),
|
|
20214
|
+
diff: require_diff(),
|
|
20215
|
+
major: require_major(),
|
|
20216
|
+
minor: require_minor(),
|
|
20217
|
+
patch: require_patch(),
|
|
20218
|
+
prerelease: require_prerelease(),
|
|
20219
|
+
compare: require_compare(),
|
|
20220
|
+
rcompare: require_rcompare(),
|
|
20221
|
+
compareLoose: require_compare_loose(),
|
|
20222
|
+
compareBuild: require_compare_build(),
|
|
20223
|
+
sort: require_sort(),
|
|
20224
|
+
rsort: require_rsort(),
|
|
20225
|
+
gt: require_gt(),
|
|
20226
|
+
lt: require_lt(),
|
|
20227
|
+
eq: require_eq(),
|
|
20228
|
+
neq: require_neq(),
|
|
20229
|
+
gte: require_gte(),
|
|
20230
|
+
lte: require_lte(),
|
|
20231
|
+
cmp: require_cmp(),
|
|
20232
|
+
coerce: require_coerce(),
|
|
20233
|
+
truncate: require_truncate(),
|
|
20234
|
+
Comparator: require_comparator(),
|
|
20235
|
+
Range: require_range(),
|
|
20236
|
+
satisfies: require_satisfies(),
|
|
20237
|
+
toComparators: require_to_comparators(),
|
|
20238
|
+
maxSatisfying: require_max_satisfying(),
|
|
20239
|
+
minSatisfying: require_min_satisfying(),
|
|
20240
|
+
minVersion: require_min_version(),
|
|
20241
|
+
validRange: require_valid(),
|
|
20242
|
+
outside: require_outside(),
|
|
20243
|
+
gtr: require_gtr(),
|
|
20244
|
+
ltr: require_ltr(),
|
|
20245
|
+
intersects: require_intersects(),
|
|
20246
|
+
simplifyRange: require_simplify(),
|
|
20247
|
+
subset: require_subset(),
|
|
20248
|
+
SemVer,
|
|
20249
|
+
re: internalRe.re,
|
|
20250
|
+
src: internalRe.src,
|
|
20251
|
+
tokens: internalRe.t,
|
|
20252
|
+
SEMVER_SPEC_VERSION: constants.SEMVER_SPEC_VERSION,
|
|
20253
|
+
RELEASE_TYPES: constants.RELEASE_TYPES,
|
|
20254
|
+
compareIdentifiers: identifiers.compareIdentifiers,
|
|
20255
|
+
rcompareIdentifiers: identifiers.rcompareIdentifiers
|
|
20256
|
+
};
|
|
20257
|
+
})))(), 1);
|
|
20258
|
+
const FIRST_DEEPEN_DEPTH = 16;
|
|
20259
|
+
const MAX_DEEPEN_DEPTH = 4096;
|
|
20260
|
+
async function readZenbuHostAt(args) {
|
|
20261
|
+
try {
|
|
20262
|
+
const { blob } = await import_isomorphic_git.readBlob({
|
|
20263
|
+
fs: args.fs,
|
|
20264
|
+
dir: args.dir,
|
|
20265
|
+
oid: args.commitOid,
|
|
20266
|
+
filepath: "package.json"
|
|
20267
|
+
});
|
|
20268
|
+
const text = Buffer.from(blob).toString("utf8");
|
|
20269
|
+
const raw = JSON.parse(text).zenbu?.host;
|
|
20270
|
+
if (typeof raw !== "string" || raw.trim().length === 0) return {
|
|
20271
|
+
range: null,
|
|
20272
|
+
missing: true
|
|
20273
|
+
};
|
|
20274
|
+
return {
|
|
20275
|
+
range: raw.trim(),
|
|
20276
|
+
missing: false
|
|
20277
|
+
};
|
|
20278
|
+
} catch {
|
|
20279
|
+
return {
|
|
20280
|
+
range: null,
|
|
20281
|
+
missing: true
|
|
20282
|
+
};
|
|
20283
|
+
}
|
|
20284
|
+
}
|
|
20285
|
+
function isCompatible(hostVersion, range) {
|
|
20286
|
+
if (!range) return true;
|
|
20287
|
+
try {
|
|
20288
|
+
return import_semver.default.satisfies(hostVersion, range, { includePrerelease: true });
|
|
20289
|
+
} catch {
|
|
20290
|
+
return false;
|
|
20291
|
+
}
|
|
20292
|
+
}
|
|
20293
|
+
async function resolveTargetSha(input) {
|
|
20294
|
+
const { fs, http, dir, mirror, hostVersion, reporter = null, signal } = input;
|
|
20295
|
+
const remoteRef = `refs/remotes/origin/${mirror.branch}`;
|
|
20296
|
+
reporter?.step?.("resolve", `Resolving compatible commit (host=${hostVersion})`);
|
|
20297
|
+
const tipSha = await import_isomorphic_git.resolveRef({
|
|
20298
|
+
fs,
|
|
20299
|
+
dir,
|
|
20300
|
+
ref: remoteRef
|
|
20301
|
+
});
|
|
20302
|
+
let consideredCommits = 1;
|
|
20303
|
+
const tipInfo = await readZenbuHostAt({
|
|
20304
|
+
fs,
|
|
20305
|
+
dir,
|
|
20306
|
+
commitOid: tipSha
|
|
20307
|
+
});
|
|
20308
|
+
if (isCompatible(hostVersion, tipInfo.range)) {
|
|
20309
|
+
reporter?.message?.(`[resolve] tip ${tipSha.slice(0, 7)} ` + (tipInfo.range ? `range="${tipInfo.range}" ok for host=${hostVersion}` : `no zenbu.host declared; assuming compatible`));
|
|
20310
|
+
reporter?.done?.("resolve");
|
|
20311
|
+
return {
|
|
20312
|
+
targetSha: tipSha,
|
|
20313
|
+
tipSha,
|
|
20314
|
+
consideredCommits,
|
|
20315
|
+
exhaustedHistory: false
|
|
20316
|
+
};
|
|
20317
|
+
}
|
|
20318
|
+
reporter?.message?.(`[resolve] tip ${tipSha.slice(0, 7)} range="${tipInfo.range}" does not satisfy host=${hostVersion}; deepening history...`);
|
|
20319
|
+
let depth = FIRST_DEEPEN_DEPTH;
|
|
20320
|
+
let lastSeen = 1;
|
|
20321
|
+
let exhausted = false;
|
|
20322
|
+
while (depth <= MAX_DEEPEN_DEPTH) {
|
|
20323
|
+
if (signal?.aborted) throw new Error("resolveTargetSha aborted");
|
|
20324
|
+
reporter?.progress?.({
|
|
20325
|
+
phase: "resolve",
|
|
20326
|
+
loaded: depth,
|
|
20327
|
+
total: MAX_DEEPEN_DEPTH
|
|
20328
|
+
});
|
|
20329
|
+
try {
|
|
20330
|
+
await import_isomorphic_git.fetch({
|
|
20331
|
+
fs,
|
|
20332
|
+
http,
|
|
20333
|
+
dir,
|
|
20334
|
+
url: mirror.url,
|
|
20335
|
+
ref: mirror.branch,
|
|
20336
|
+
singleBranch: true,
|
|
20337
|
+
depth,
|
|
20338
|
+
relative: false,
|
|
20339
|
+
tags: false
|
|
20340
|
+
});
|
|
20341
|
+
} catch (err) {
|
|
20342
|
+
reporter?.message?.(`[resolve] deepen depth=${depth} failed: ${err.message}`);
|
|
20343
|
+
break;
|
|
20344
|
+
}
|
|
20345
|
+
const log = await import_isomorphic_git.log({
|
|
20346
|
+
fs,
|
|
20347
|
+
dir,
|
|
20348
|
+
ref: remoteRef,
|
|
20349
|
+
depth
|
|
20350
|
+
});
|
|
20351
|
+
if (log.length <= lastSeen) {
|
|
20352
|
+
exhausted = true;
|
|
20353
|
+
break;
|
|
20354
|
+
}
|
|
20355
|
+
lastSeen = log.length;
|
|
20356
|
+
consideredCommits = log.length;
|
|
20357
|
+
const oids = log.map((c) => c.oid);
|
|
20358
|
+
let lo = 0;
|
|
20359
|
+
let hi = oids.length;
|
|
20360
|
+
while (lo < hi) {
|
|
20361
|
+
if (signal?.aborted) throw new Error("resolveTargetSha aborted");
|
|
20362
|
+
const mid = lo + hi >>> 1;
|
|
20363
|
+
if (isCompatible(hostVersion, (await readZenbuHostAt({
|
|
20364
|
+
fs,
|
|
20365
|
+
dir,
|
|
20366
|
+
commitOid: oids[mid]
|
|
20367
|
+
})).range)) hi = mid;
|
|
20368
|
+
else lo = mid + 1;
|
|
20369
|
+
}
|
|
20370
|
+
if (lo < oids.length) {
|
|
20371
|
+
const targetSha = oids[lo];
|
|
20372
|
+
reporter?.message?.(`[resolve] picked ${targetSha.slice(0, 7)} (${oids.length - lo} commits behind tip; host=${hostVersion} ok)`);
|
|
20373
|
+
reporter?.done?.("resolve");
|
|
20374
|
+
return {
|
|
20375
|
+
targetSha,
|
|
20376
|
+
tipSha,
|
|
20377
|
+
consideredCommits,
|
|
20378
|
+
exhaustedHistory: false
|
|
20379
|
+
};
|
|
20380
|
+
}
|
|
20381
|
+
depth *= 2;
|
|
20382
|
+
}
|
|
20383
|
+
reporter?.message?.(`[resolve] no compatible commit found in ${consideredCommits} commits on origin/${mirror.branch} (host=${hostVersion})`);
|
|
20384
|
+
reporter?.error?.({
|
|
20385
|
+
id: "resolve",
|
|
20386
|
+
message: `no commit on origin/${mirror.branch} declares zenbu.host that satisfies host=${hostVersion}`
|
|
20387
|
+
});
|
|
20388
|
+
return {
|
|
20389
|
+
targetSha: null,
|
|
20390
|
+
tipSha,
|
|
20391
|
+
consideredCommits,
|
|
20392
|
+
exhaustedHistory: exhausted
|
|
20393
|
+
};
|
|
20394
|
+
}
|
|
20395
|
+
//#endregion
|
|
20396
|
+
//#region src/launcher.ts
|
|
20397
|
+
/**
|
|
20398
|
+
* Zenbu launcher shim.
|
|
18017
20399
|
*
|
|
18018
20400
|
* Shipped inside `@zenbujs/core/dist/launcher.mjs` and copied into the .app
|
|
18019
20401
|
* bundle by `zen build:electron`. The bundle's `package.json#main` points
|
|
@@ -18072,8 +20454,128 @@ process.on("unhandledRejection", (reason) => {
|
|
|
18072
20454
|
_logStream.write("[UNHANDLED] " + (err?.stack ?? err?.message ?? String(reason)) + "\n");
|
|
18073
20455
|
} catch {}
|
|
18074
20456
|
});
|
|
20457
|
+
const LEGACY_PACKAGE_MANAGER = {
|
|
20458
|
+
type: "pnpm",
|
|
20459
|
+
version: "10.33.0"
|
|
20460
|
+
};
|
|
18075
20461
|
const APP_PATH = app.getAppPath();
|
|
18076
20462
|
const RESOURCES_PATH = path.dirname(APP_PATH);
|
|
20463
|
+
function readBgColor(htmlPath, fallback) {
|
|
20464
|
+
try {
|
|
20465
|
+
const match = fs.readFileSync(htmlPath, "utf8").match(/<meta\s+name=["']zenbu-bg["']\s+content=["']([^"']+)["']/i);
|
|
20466
|
+
if (match?.[1]) return match[1];
|
|
20467
|
+
} catch {}
|
|
20468
|
+
return fallback;
|
|
20469
|
+
}
|
|
20470
|
+
async function maybeOpenInstallingWindow(cfg) {
|
|
20471
|
+
if (!cfg.installingHtml) return null;
|
|
20472
|
+
const htmlPath = path.join(RESOURCES_PATH, cfg.installingHtml);
|
|
20473
|
+
if (!existsSync(htmlPath)) {
|
|
20474
|
+
_logStream.write(`[installer] installing.html not found at ${htmlPath}; skipping window\n`);
|
|
20475
|
+
return null;
|
|
20476
|
+
}
|
|
20477
|
+
const preloadPath = cfg.installingPreload ? path.join(RESOURCES_PATH, cfg.installingPreload) : null;
|
|
20478
|
+
if (!preloadPath || !existsSync(preloadPath)) {
|
|
20479
|
+
_logStream.write(`[installer] installing-preload.cjs not found at ${preloadPath}; skipping window\n`);
|
|
20480
|
+
return null;
|
|
20481
|
+
}
|
|
20482
|
+
const win = new BaseWindow({
|
|
20483
|
+
width: 1100,
|
|
20484
|
+
height: 750,
|
|
20485
|
+
titleBarStyle: "hidden",
|
|
20486
|
+
trafficLightPosition: {
|
|
20487
|
+
x: 14,
|
|
20488
|
+
y: 10
|
|
20489
|
+
},
|
|
20490
|
+
backgroundColor: readBgColor(htmlPath, "#F4F4F4")
|
|
20491
|
+
});
|
|
20492
|
+
const view = new WebContentsView({ webPreferences: {
|
|
20493
|
+
preload: preloadPath,
|
|
20494
|
+
contextIsolation: true,
|
|
20495
|
+
sandbox: true,
|
|
20496
|
+
nodeIntegration: false
|
|
20497
|
+
} });
|
|
20498
|
+
win.contentView.addChildView(view);
|
|
20499
|
+
const layout = () => {
|
|
20500
|
+
const { width, height } = win.getContentBounds();
|
|
20501
|
+
view.setBounds({
|
|
20502
|
+
x: 0,
|
|
20503
|
+
y: 0,
|
|
20504
|
+
width,
|
|
20505
|
+
height
|
|
20506
|
+
});
|
|
20507
|
+
};
|
|
20508
|
+
layout();
|
|
20509
|
+
win.on("resize", layout);
|
|
20510
|
+
let ready = false;
|
|
20511
|
+
const pending = [];
|
|
20512
|
+
view.webContents.once("did-finish-load", () => {
|
|
20513
|
+
ready = true;
|
|
20514
|
+
for (const p of pending) try {
|
|
20515
|
+
if (view.webContents.isDestroyed()) break;
|
|
20516
|
+
view.webContents.send(`zenbu:install:${p.event}`, p.payload);
|
|
20517
|
+
} catch {}
|
|
20518
|
+
pending.length = 0;
|
|
20519
|
+
});
|
|
20520
|
+
view.webContents.once("did-fail-load", (_e, _code, desc) => {
|
|
20521
|
+
_logStream.write(`[installer] did-fail-load: ${desc}\n`);
|
|
20522
|
+
pending.length = 0;
|
|
20523
|
+
ready = true;
|
|
20524
|
+
});
|
|
20525
|
+
view.webContents.loadFile(htmlPath).catch((err) => {
|
|
20526
|
+
_logStream.write(`[installer] loadFile failed: ${err.message ?? err}\n`);
|
|
20527
|
+
});
|
|
20528
|
+
const emit = (event, payload) => {
|
|
20529
|
+
if (!ready) {
|
|
20530
|
+
pending.push({
|
|
20531
|
+
event,
|
|
20532
|
+
payload
|
|
20533
|
+
});
|
|
20534
|
+
return;
|
|
20535
|
+
}
|
|
20536
|
+
try {
|
|
20537
|
+
if (view.webContents.isDestroyed()) return;
|
|
20538
|
+
view.webContents.send(`zenbu:install:${event}`, payload);
|
|
20539
|
+
} catch {}
|
|
20540
|
+
};
|
|
20541
|
+
let currentStep = null;
|
|
20542
|
+
return {
|
|
20543
|
+
emit,
|
|
20544
|
+
get currentStep() {
|
|
20545
|
+
return currentStep;
|
|
20546
|
+
},
|
|
20547
|
+
step(id, label) {
|
|
20548
|
+
currentStep = id;
|
|
20549
|
+
emit("step", {
|
|
20550
|
+
id,
|
|
20551
|
+
label
|
|
20552
|
+
});
|
|
20553
|
+
},
|
|
20554
|
+
done(id) {
|
|
20555
|
+
emit("done", { id });
|
|
20556
|
+
},
|
|
20557
|
+
message(text) {
|
|
20558
|
+
emit("message", { text });
|
|
20559
|
+
},
|
|
20560
|
+
progress(payload) {
|
|
20561
|
+
emit("progress", payload);
|
|
20562
|
+
},
|
|
20563
|
+
fail(err, id) {
|
|
20564
|
+
const message = err instanceof Error ? err.stack ?? err.message : String(err);
|
|
20565
|
+
emit("error", {
|
|
20566
|
+
id: id ?? currentStep ?? void 0,
|
|
20567
|
+
message
|
|
20568
|
+
});
|
|
20569
|
+
},
|
|
20570
|
+
handoff() {
|
|
20571
|
+
const slot = globalThis;
|
|
20572
|
+
slot.__zenbu_boot_windows__ = [...slot.__zenbu_boot_windows__ ?? [], {
|
|
20573
|
+
windowId: "main",
|
|
20574
|
+
win
|
|
20575
|
+
}];
|
|
20576
|
+
}
|
|
20577
|
+
};
|
|
20578
|
+
}
|
|
18077
20579
|
function readAppConfig() {
|
|
18078
20580
|
const configPath = path.join(APP_PATH, "app-config.json");
|
|
18079
20581
|
return JSON.parse(fs.readFileSync(configPath, "utf8"));
|
|
@@ -18082,64 +20584,6 @@ function appsDirFor(name) {
|
|
|
18082
20584
|
if (process.env.ZENBU_APPS_DIR) return path.resolve(process.env.ZENBU_APPS_DIR);
|
|
18083
20585
|
return path.join(os.homedir(), ".zenbu", "apps", name);
|
|
18084
20586
|
}
|
|
18085
|
-
async function fileHash(hash, filePath) {
|
|
18086
|
-
hash.update(filePath);
|
|
18087
|
-
hash.update("\0");
|
|
18088
|
-
try {
|
|
18089
|
-
hash.update(await fsp.readFile(filePath));
|
|
18090
|
-
} catch {}
|
|
18091
|
-
hash.update("\0");
|
|
18092
|
-
}
|
|
18093
|
-
async function depsSignature(appsDir) {
|
|
18094
|
-
const hash = crypto$1.createHash("sha256");
|
|
18095
|
-
await fileHash(hash, path.join(appsDir, "package.json"));
|
|
18096
|
-
await fileHash(hash, path.join(appsDir, "pnpm-lock.yaml"));
|
|
18097
|
-
hash.update(process.versions.electron ?? "no-electron");
|
|
18098
|
-
hash.update("\0");
|
|
18099
|
-
hash.update(process.platform);
|
|
18100
|
-
hash.update("\0");
|
|
18101
|
-
hash.update(process.arch);
|
|
18102
|
-
return hash.digest("hex");
|
|
18103
|
-
}
|
|
18104
|
-
function bundledToolPath(name) {
|
|
18105
|
-
const candidates = [path.join(RESOURCES_PATH, "toolchain", "bin", name), path.join(RESOURCES_PATH, "toolchain", name)];
|
|
18106
|
-
for (const candidate of candidates) if (existsSync(candidate)) return candidate;
|
|
18107
|
-
return null;
|
|
18108
|
-
}
|
|
18109
|
-
function electronTargetVersion(appsDir) {
|
|
18110
|
-
if (process.versions.electron) return process.versions.electron;
|
|
18111
|
-
try {
|
|
18112
|
-
const pkg = JSON.parse(fs.readFileSync(path.join(appsDir, "package.json"), "utf8"));
|
|
18113
|
-
return (pkg.devDependencies?.electron ?? pkg.dependencies?.electron ?? "").replace(/^[^\d]*/, "") || "42.0.0";
|
|
18114
|
-
} catch {
|
|
18115
|
-
return "42.0.0";
|
|
18116
|
-
}
|
|
18117
|
-
}
|
|
18118
|
-
async function runPnpmInstall(appsDir) {
|
|
18119
|
-
const pnpm = bundledToolPath("pnpm");
|
|
18120
|
-
if (!pnpm) throw new Error(`bundled pnpm not found in ${RESOURCES_PATH}/toolchain. The .app is missing required toolchain binaries.`);
|
|
18121
|
-
const target = electronTargetVersion(appsDir);
|
|
18122
|
-
await new Promise((resolve, reject) => {
|
|
18123
|
-
const child = spawn(pnpm, ["install", "--no-frozen-lockfile"], {
|
|
18124
|
-
cwd: appsDir,
|
|
18125
|
-
stdio: "inherit",
|
|
18126
|
-
env: {
|
|
18127
|
-
...process.env,
|
|
18128
|
-
CI: "true",
|
|
18129
|
-
HOME: path.join(appsDir, ".zenbu", ".node-gyp"),
|
|
18130
|
-
npm_config_runtime: "electron",
|
|
18131
|
-
npm_config_target: target,
|
|
18132
|
-
npm_config_disturl: "https://electronjs.org/headers",
|
|
18133
|
-
npm_config_arch: process.arch
|
|
18134
|
-
}
|
|
18135
|
-
});
|
|
18136
|
-
child.on("error", reject);
|
|
18137
|
-
child.on("close", (code) => {
|
|
18138
|
-
if (code === 0) resolve();
|
|
18139
|
-
else reject(/* @__PURE__ */ new Error(`pnpm install exited with code ${code}`));
|
|
18140
|
-
});
|
|
18141
|
-
});
|
|
18142
|
-
}
|
|
18143
20587
|
function resolveMirror(cfg) {
|
|
18144
20588
|
if (!cfg.mirrorUrl) throw new Error("[launcher] no mirror configured. The .app's app-config.json must contain `mirrorUrl` (the GitHub repo cloned on first launch). Configure `mirror.target` in zenbu.build.ts and rebuild.");
|
|
18145
20589
|
return {
|
|
@@ -18168,8 +20612,9 @@ async function hasLocalModifications(dir) {
|
|
|
18168
20612
|
return false;
|
|
18169
20613
|
}
|
|
18170
20614
|
}
|
|
18171
|
-
async function cloneMirror(dir, mirror) {
|
|
20615
|
+
async function cloneMirror(dir, mirror, installer) {
|
|
18172
20616
|
console.log(`[launcher] cloning ${mirror.url}#${mirror.branch} -> ${dir}`);
|
|
20617
|
+
installer?.step("clone", `Cloning ${mirror.url}#${mirror.branch}`);
|
|
18173
20618
|
await fsp.mkdir(dir, { recursive: true });
|
|
18174
20619
|
await import_isomorphic_git.clone({
|
|
18175
20620
|
fs,
|
|
@@ -18178,21 +20623,29 @@ async function cloneMirror(dir, mirror) {
|
|
|
18178
20623
|
url: mirror.url,
|
|
18179
20624
|
ref: mirror.branch,
|
|
18180
20625
|
singleBranch: true,
|
|
18181
|
-
depth: 1
|
|
20626
|
+
depth: 1,
|
|
20627
|
+
onProgress: installer ? (e) => {
|
|
20628
|
+
const ratio = e.total ? e.loaded / e.total : void 0;
|
|
20629
|
+
installer.progress({
|
|
20630
|
+
phase: e.phase,
|
|
20631
|
+
loaded: e.loaded,
|
|
20632
|
+
total: e.total,
|
|
20633
|
+
ratio
|
|
20634
|
+
});
|
|
20635
|
+
} : void 0,
|
|
20636
|
+
onMessage: installer ? (msg) => installer.message(msg.replace(/\n+$/g, "")) : void 0
|
|
18182
20637
|
});
|
|
18183
20638
|
console.log(`[launcher] clone complete`);
|
|
20639
|
+
installer?.done("clone");
|
|
18184
20640
|
}
|
|
18185
20641
|
/**
|
|
18186
|
-
*
|
|
18187
|
-
*
|
|
18188
|
-
*
|
|
18189
|
-
*
|
|
18190
|
-
*
|
|
18191
|
-
* On clean trees with new commits, we `checkout --force` the remote sha.
|
|
18192
|
-
* That's equivalent to `git reset --hard origin/<branch>` for a fast-forward
|
|
18193
|
-
* scenario and avoids isomorphic-git's lack of a built-in pull operation.
|
|
20642
|
+
* Best-effort `git fetch --depth=1` against `origin/<branch>`. Failures
|
|
20643
|
+
* are non-fatal — the resolver runs next and may still find a local
|
|
20644
|
+
* compatible commit on a previously-deepened working tree. Skips the
|
|
20645
|
+
* remote checkout entirely (the resolver decides which sha to land on).
|
|
18194
20646
|
*/
|
|
18195
|
-
async function
|
|
20647
|
+
async function fetchTip(dir, mirror, installer) {
|
|
20648
|
+
installer?.step("fetch", `Updating from ${mirror.url}#${mirror.branch}`);
|
|
18196
20649
|
try {
|
|
18197
20650
|
await import_isomorphic_git.fetch({
|
|
18198
20651
|
fs,
|
|
@@ -18202,67 +20655,97 @@ async function fetchAndUpdate(dir, mirror) {
|
|
|
18202
20655
|
ref: mirror.branch,
|
|
18203
20656
|
singleBranch: true,
|
|
18204
20657
|
depth: 1,
|
|
18205
|
-
tags: false
|
|
20658
|
+
tags: false,
|
|
20659
|
+
onProgress: installer ? (e) => {
|
|
20660
|
+
const ratio = e.total ? e.loaded / e.total : void 0;
|
|
20661
|
+
installer.progress({
|
|
20662
|
+
phase: e.phase,
|
|
20663
|
+
loaded: e.loaded,
|
|
20664
|
+
total: e.total,
|
|
20665
|
+
ratio
|
|
20666
|
+
});
|
|
20667
|
+
} : void 0,
|
|
20668
|
+
onMessage: installer ? (msg) => installer.message(msg.replace(/\n+$/g, "")) : void 0
|
|
18206
20669
|
});
|
|
18207
20670
|
} catch (err) {
|
|
18208
20671
|
console.warn(`[launcher] fetch failed (${err.message}); using local state`);
|
|
18209
|
-
|
|
20672
|
+
} finally {
|
|
20673
|
+
installer?.done("fetch");
|
|
18210
20674
|
}
|
|
18211
|
-
|
|
18212
|
-
|
|
20675
|
+
}
|
|
20676
|
+
/**
|
|
20677
|
+
* Resolve the latest commit on origin/<branch> whose
|
|
20678
|
+
* `package.json#zenbu.host` satisfies the running .app's `hostVersion`,
|
|
20679
|
+
* and check it out if HEAD isn't already there. Pure delegation to
|
|
20680
|
+
* `resolveTargetSha` from `shared/range-resolver.ts` — same code path
|
|
20681
|
+
* used by `UpdaterService.update()` at runtime.
|
|
20682
|
+
*/
|
|
20683
|
+
async function resolveAndCheckout(dir, mirror, hostVersion, installer) {
|
|
20684
|
+
const result = await resolveTargetSha({
|
|
20685
|
+
fs,
|
|
20686
|
+
http: index,
|
|
20687
|
+
dir,
|
|
20688
|
+
mirror: {
|
|
20689
|
+
url: mirror.url,
|
|
20690
|
+
branch: mirror.branch
|
|
20691
|
+
},
|
|
20692
|
+
hostVersion,
|
|
20693
|
+
reporter: installer
|
|
20694
|
+
});
|
|
20695
|
+
if (result.targetSha === null) throw new Error(`[launcher] no commit on origin/${mirror.branch} declares a package.json#zenbu.host range that satisfies host=${hostVersion}. Update the .app to a newer build, or push a compatible source commit to the mirror.`);
|
|
20696
|
+
let localSha = null;
|
|
18213
20697
|
try {
|
|
18214
20698
|
localSha = await import_isomorphic_git.resolveRef({
|
|
18215
20699
|
fs,
|
|
18216
20700
|
dir,
|
|
18217
20701
|
ref: "HEAD"
|
|
18218
20702
|
});
|
|
18219
|
-
|
|
18220
|
-
|
|
18221
|
-
dir,
|
|
18222
|
-
ref: `refs/remotes/origin/${mirror.branch}`
|
|
18223
|
-
});
|
|
18224
|
-
} catch (err) {
|
|
18225
|
-
console.warn(`[launcher] could not resolve refs (${err.message}); using local state`);
|
|
18226
|
-
return;
|
|
18227
|
-
}
|
|
18228
|
-
if (localSha === remoteSha) {
|
|
20703
|
+
} catch {}
|
|
20704
|
+
if (localSha === result.targetSha) {
|
|
18229
20705
|
console.log(`[launcher] up to date (${localSha.slice(0, 7)})`);
|
|
18230
20706
|
return;
|
|
18231
20707
|
}
|
|
18232
|
-
|
|
18233
|
-
console.warn(`[launcher] working tree at ${dir} has uncommitted modifications; skipping fast-forward to ${remoteSha.slice(0, 7)}.`);
|
|
18234
|
-
return;
|
|
18235
|
-
}
|
|
18236
|
-
console.log(`[launcher] fast-forwarding ${localSha.slice(0, 7)} -> ${remoteSha.slice(0, 7)}`);
|
|
20708
|
+
console.log(`[launcher] checking out ${result.targetSha.slice(0, 7)}` + (localSha ? ` (was ${localSha.slice(0, 7)})` : "") + (result.targetSha === result.tipSha ? "" : ` (tip=${result.tipSha.slice(0, 7)})`));
|
|
18237
20709
|
await import_isomorphic_git.checkout({
|
|
18238
20710
|
fs,
|
|
18239
20711
|
dir,
|
|
18240
|
-
ref:
|
|
20712
|
+
ref: result.targetSha,
|
|
18241
20713
|
force: true
|
|
18242
20714
|
});
|
|
18243
20715
|
}
|
|
18244
|
-
async function ensureAppsDir(appsDir, mirror) {
|
|
20716
|
+
async function ensureAppsDir(appsDir, mirror, hostVersion, installer) {
|
|
18245
20717
|
if (isExistingClone(appsDir)) {
|
|
18246
|
-
await
|
|
18247
|
-
|
|
18248
|
-
|
|
18249
|
-
|
|
18250
|
-
|
|
18251
|
-
|
|
20718
|
+
if (await hasLocalModifications(appsDir)) {
|
|
20719
|
+
console.warn(`[launcher] working tree at ${appsDir} has uncommitted modifications; skipping fetch + resolve.`);
|
|
20720
|
+
installer?.message(`[launcher] uncommitted modifications detected; skipping update`);
|
|
20721
|
+
return;
|
|
20722
|
+
}
|
|
20723
|
+
await fetchTip(appsDir, mirror, installer);
|
|
20724
|
+
} else {
|
|
20725
|
+
if (existsSync(appsDir)) {
|
|
20726
|
+
const entries = await fsp.readdir(appsDir).catch(() => []);
|
|
20727
|
+
if (entries.length > 0) throw new Error(`[launcher] ${appsDir} exists and isn't a git working tree (has ${entries.length} entries). Move or delete it, then relaunch.`);
|
|
20728
|
+
}
|
|
20729
|
+
await cloneMirror(appsDir, mirror, installer);
|
|
18252
20730
|
}
|
|
18253
|
-
await
|
|
20731
|
+
await resolveAndCheckout(appsDir, mirror, hostVersion, installer);
|
|
18254
20732
|
}
|
|
18255
|
-
async function ensureDepsInstalled(appsDir) {
|
|
18256
|
-
const sigPath = path.join(appsDir, ".zenbu", "deps-sig");
|
|
20733
|
+
async function ensureDepsInstalled(appsDir, pm, installer) {
|
|
18257
20734
|
const nodeModules = path.join(appsDir, "node_modules");
|
|
18258
|
-
const nextSig = await depsSignature(appsDir);
|
|
18259
|
-
if (existsSync(nodeModules))
|
|
18260
|
-
if (await
|
|
18261
|
-
}
|
|
18262
|
-
console.log(`[launcher] installing deps in ${appsDir}`);
|
|
18263
|
-
|
|
18264
|
-
await
|
|
18265
|
-
|
|
20735
|
+
const nextSig = await depsSignature(appsDir, pm);
|
|
20736
|
+
if (existsSync(nodeModules)) {
|
|
20737
|
+
if (await readDepsSig(appsDir) === nextSig) return;
|
|
20738
|
+
}
|
|
20739
|
+
console.log(`[launcher] installing deps in ${appsDir} via ${pm.type}@${pm.version}`);
|
|
20740
|
+
installer?.step("install", `Installing dependencies (${pm.type}@${pm.version})`);
|
|
20741
|
+
await runInstall({
|
|
20742
|
+
appsDir,
|
|
20743
|
+
resourcesPath: RESOURCES_PATH,
|
|
20744
|
+
pm,
|
|
20745
|
+
reporter: installer
|
|
20746
|
+
});
|
|
20747
|
+
await writeDepsSig(appsDir, nextSig);
|
|
20748
|
+
installer?.done("install");
|
|
18266
20749
|
}
|
|
18267
20750
|
async function handoff(appsDir) {
|
|
18268
20751
|
const entry = path.join(appsDir, "node_modules", "@zenbujs", "core", "dist", "setup-gate.mjs");
|
|
@@ -18274,11 +20757,21 @@ async function handoff(appsDir) {
|
|
|
18274
20757
|
async function main() {
|
|
18275
20758
|
await app.whenReady();
|
|
18276
20759
|
const cfg = readAppConfig();
|
|
18277
|
-
const
|
|
18278
|
-
|
|
18279
|
-
|
|
18280
|
-
|
|
18281
|
-
|
|
20760
|
+
const installer = await maybeOpenInstallingWindow(cfg);
|
|
20761
|
+
try {
|
|
20762
|
+
const mirror = resolveMirror(cfg);
|
|
20763
|
+
const appsDir = appsDirFor(cfg.name);
|
|
20764
|
+
const pm = cfg.packageManager ?? LEGACY_PACKAGE_MANAGER;
|
|
20765
|
+
const { version: hostVersion } = readHostVersion(APP_PATH);
|
|
20766
|
+
await ensureAppsDir(appsDir, mirror, hostVersion, installer);
|
|
20767
|
+
await ensureDepsInstalled(appsDir, pm, installer);
|
|
20768
|
+
installer?.step("handoff", "Starting app");
|
|
20769
|
+
installer?.handoff();
|
|
20770
|
+
await handoff(appsDir);
|
|
20771
|
+
} catch (err) {
|
|
20772
|
+
installer?.fail(err);
|
|
20773
|
+
throw err;
|
|
20774
|
+
}
|
|
18282
20775
|
}
|
|
18283
20776
|
main().catch((err) => {
|
|
18284
20777
|
console.error("[launcher] fatal:", err);
|