@mmmbuto/qwen-code-termux 0.16.1-termux → 0.18.0-termux
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +79 -109
- package/bundled/new-app/SKILL.md +22 -0
- package/bundled/qc-helper/SKILL.md +29 -24
- package/bundled/qc-helper/docs/_meta.ts +1 -0
- package/bundled/qc-helper/docs/configuration/_meta.ts +0 -3
- package/bundled/qc-helper/docs/configuration/settings.md +37 -31
- package/bundled/qc-helper/docs/configuration/themes.md +39 -0
- package/bundled/qc-helper/docs/features/_meta.ts +1 -3
- package/bundled/qc-helper/docs/features/approval-mode.md +35 -35
- package/bundled/qc-helper/docs/features/auto-mode.md +54 -9
- package/bundled/qc-helper/docs/features/channels/_meta.ts +1 -0
- package/bundled/qc-helper/docs/features/channels/feishu.md +170 -0
- package/bundled/qc-helper/docs/features/commands.md +115 -35
- package/bundled/qc-helper/docs/features/followup-suggestions.md +2 -2
- package/bundled/qc-helper/docs/features/headless.md +32 -0
- package/bundled/qc-helper/docs/features/markdown-rendering.md +21 -1
- package/bundled/qc-helper/docs/features/memory.md +22 -5
- package/bundled/qc-helper/docs/features/scheduled-tasks.md +1 -1
- package/bundled/qc-helper/docs/features/status-line.md +168 -32
- package/bundled/qc-helper/docs/features/sub-agents.md +60 -0
- package/bundled/qc-helper/docs/features/worktree.md +345 -0
- package/bundled/qc-helper/docs/overview.md +4 -4
- package/bundled/qc-helper/docs/quickstart.md +4 -4
- package/bundled/qc-helper/docs/qwen-serve-deploy-local.md +221 -0
- package/bundled/qc-helper/docs/qwen-serve.md +234 -24
- package/bundled/qc-helper/docs/reference/keyboard-shortcuts.md +16 -0
- package/bundled/qc-helper/docs/support/Uninstall.md +19 -1
- package/bundled/qc-helper/docs/support/troubleshooting.md +2 -1
- package/bundled/simplify/SKILL.md +123 -0
- package/chunks/agent-IDS4HMOX.js +56 -0
- package/chunks/agent-headless-5Q2EUSPS.js +50 -0
- package/chunks/{anthropicContentGenerator-SSGKR6DO.js → anthropicContentGenerator-2HBRNQ3B.js} +52 -9
- package/chunks/{askUserQuestion-PJWUUXKN.js → askUserQuestion-75TDJVK2.js} +45 -3
- package/chunks/{ca-UZ7BANMN.js → ca-BARBRL6N.js} +89 -5
- package/chunks/{chunk-GGNTZ2NH.js → chunk-2Y5SYSD3.js} +368 -597
- package/chunks/{chunk-2LA2TREA.js → chunk-3AA2DK35.js} +1448 -207
- package/chunks/{chunk-I2V5WXHJ.js → chunk-3AUHFMSK.js} +80 -38
- package/chunks/chunk-3DHXZ6EV.js +241 -0
- package/chunks/{chunk-PR4T27R7.js → chunk-3HTIVKZE.js} +42 -8
- package/chunks/chunk-3HX5LZ6R.js +1798 -0
- package/chunks/chunk-3PJXIDKI.js +2517 -0
- package/chunks/{chunk-MYAKAFEC.js → chunk-55ZMG67I.js} +7451 -3517
- package/chunks/{chunk-66CXYE4B.js → chunk-5IFG2VC4.js} +293 -242
- package/chunks/chunk-64WXLC72.js +98 -0
- package/chunks/{chunk-C6WMLUNB.js → chunk-72LDN5PP.js} +1 -1
- package/chunks/{chunk-F23NCRJ2.js → chunk-A7B4ISQP.js} +1 -1
- package/chunks/chunk-B7HXHOHU.js +393 -0
- package/chunks/{chunk-XEGHDASV.js → chunk-D3RHSPAS.js} +435 -540
- package/chunks/{chunk-XKS5KBFJ.js → chunk-EYENRK4D.js} +694 -384
- package/chunks/chunk-H6BD2ELD.js +36 -0
- package/chunks/{chunk-XP27SJMH.js → chunk-HR7SV7AY.js} +79 -48
- package/chunks/{chunk-D5NTAHYL.js → chunk-IDX6COTE.js} +7 -2
- package/chunks/{chunk-SHT4VJWU.js → chunk-IWKSG2AR.js} +2 -2
- package/chunks/chunk-J37FGIOA.js +1623 -0
- package/chunks/chunk-J5MDQKJL.js +2230 -0
- package/chunks/{chunk-USE2VQ5P.js → chunk-JTQAQBTV.js} +21 -0
- package/chunks/{chunk-NCTLV2NB.js → chunk-KQJMQJPI.js} +1 -1
- package/chunks/{chunk-5FBA5XC2.js → chunk-KRIHGKNA.js} +1 -1
- package/chunks/chunk-LD2XBG6Z.js +102 -0
- package/chunks/{chunk-MAY32HXD.js → chunk-M6VTDSVR.js} +3 -1
- package/chunks/chunk-MRO43B25.js +30 -0
- package/chunks/{chunk-N4WOREMD.js → chunk-NVFMZBX2.js} +43 -3
- package/chunks/chunk-OHEGWO4L.js +264 -0
- package/chunks/{chunk-K6O2NBMF.js → chunk-OQ7NJIY7.js} +4604 -6397
- package/chunks/chunk-QQDPRDVW.js +25 -0
- package/chunks/{chunk-KXZ4TJB4.js → chunk-SEGYWKIH.js} +1 -1
- package/chunks/chunk-SKBPNJEW.js +45 -0
- package/chunks/{chunk-4AOCVI6J.js → chunk-SNGELLWX.js} +52 -6
- package/chunks/{chunk-3OCRHZA3.js → chunk-TD4OPI4T.js} +56742 -44104
- package/chunks/{chunk-DQ4QTG7E.js → chunk-VV4F63BD.js} +11 -11
- package/chunks/chunk-XBY7E2FX.js +605 -0
- package/chunks/{chunk-JKMBWLFB.js → chunk-YILFYI5W.js} +48 -26
- package/chunks/chunk-YOGAOMYB.js +159 -0
- package/chunks/{chunk-QWSRH265.js → chunk-Z2Z3GUXZ.js} +777 -776
- package/chunks/{chunk-SDHRQFOS.js → chunk-ZTZ4DDQE.js} +2 -2
- package/chunks/computer-use-W2TYQNEE.js +825 -0
- package/chunks/contextCommand-6FGX3A7J.js +52 -0
- package/chunks/{cron-create-3ZBBN7WB.js → cron-create-APL5LU6I.js} +3 -3
- package/chunks/{cron-delete-NAGKKIIG.js → cron-delete-4SBJSCN4.js} +3 -3
- package/chunks/{cron-list-PAGRXNAI.js → cron-list-2AMGOMVO.js} +3 -3
- package/chunks/{de-V4IE2OOZ.js → de-YGKK2BC4.js} +89 -5
- package/chunks/{devtools-TWVXEJQB.js → devtools-FM6GJPYG.js} +2 -1
- package/chunks/{dist-4L54HRX2.js → dist-4LXD6L6X.js} +24 -5
- package/chunks/dist-H6ONXVLG.js +94146 -0
- package/chunks/{dist-XKWIWPWQ.js → dist-KAZ3SEBX.js} +1083 -3856
- package/chunks/{dist-BXDUQ2QY.js → dist-PK7DFCAW.js} +1 -1
- package/chunks/{edit-NVO3FOAK.js → edit-ZCEZC264.js} +30 -22
- package/chunks/{en-HGJ2SPLM.js → en-DHGYHIHX.js} +127 -6
- package/chunks/{enter-worktree-UEBG4WFC.js → enter-worktree-BBHCFCHG.js} +30 -20
- package/chunks/enterPlanMode-3M6KTD3B.js +158 -0
- package/chunks/{exit-worktree-UZ3MAQZN.js → exit-worktree-73YPIEQO.js} +27 -19
- package/chunks/exitPlanMode-TYZM6BAE.js +703 -0
- package/chunks/{fr-CJULI7ZX.js → fr-JXBKPJKQ.js} +89 -5
- package/chunks/{geminiContentGenerator-3UZFXGNT.js → geminiContentGenerator-7N2V3VW2.js} +8 -6
- package/chunks/{getMachineId-bsd-JXOSIJV2.js → getMachineId-bsd-4CASPIU4.js} +4 -4
- package/chunks/{getMachineId-darwin-TE4QRR42.js → getMachineId-darwin-HPQPEMZR.js} +4 -4
- package/chunks/{getMachineId-linux-S3OL52XK.js → getMachineId-linux-AUARKYHL.js} +3 -3
- package/chunks/{getMachineId-unsupported-DWUSBAPX.js → getMachineId-unsupported-S32ZDA2T.js} +3 -3
- package/chunks/{getMachineId-win-AAC5P3AP.js → getMachineId-win-4EFLHYIJ.js} +4 -4
- package/chunks/{glob-KNHSFFFG.js → glob-5XBCPQ2A.js} +27 -19
- package/chunks/{grep-LACWDZW4.js → grep-VIUU3A7X.js} +30 -19
- package/chunks/{ja-L7CHRQEW.js → ja-TGPZSP2B.js} +89 -5
- package/chunks/{keychain-token-storage-335UOLJ6.js → keychain-token-storage-6IU6ORQN.js} +3 -3
- package/chunks/{ls-AGXQOKSG.js → ls-JRGYIGLY.js} +4 -4
- package/chunks/{lsp-UDMUHNPA.js → lsp-SHMKFOAC.js} +3 -3
- package/chunks/{monitor-ETKWPJEH.js → monitor-6R4LIJL5.js} +40 -25
- package/chunks/{multipart-parser-3QWGTLK3.js → multipart-parser-AJ4WASWR.js} +2 -2
- package/chunks/{notebook-edit-QJJLPNYT.js → notebook-edit-5E7ULDVQ.js} +28 -20
- package/chunks/{openaiContentGenerator-CNNN424U.js → openaiContentGenerator-ZVHFKM3O.js} +17 -14
- package/chunks/{pt-M6JULLEQ.js → pt-TIBG6BIO.js} +89 -5
- package/chunks/{qwenContentGenerator-BOLCGK3R.js → qwenContentGenerator-B2VTVSPJ.js} +31 -23
- package/chunks/{qwenOAuth2-EEJGROP7.js → qwenOAuth2-2KCKWDCF.js} +6 -4
- package/chunks/read-file-GIT7BCDR.js +27 -0
- package/chunks/ripGrep-MWKFVYMS.js +48 -0
- package/chunks/{ru-QILM4HBC.js → ru-JBCHCK4L.js} +89 -5
- package/chunks/scheduler-5VOOYGBH.js +308 -0
- package/chunks/send-message-4QNWQJF4.js +244 -0
- package/chunks/{serve-OLSI7WSR.js → serve-MN6HZBWN.js} +14262 -7414
- package/chunks/shell-NQZQGFM2.js +56 -0
- package/chunks/{skill-D6YRHTTI.js → skill-WCFW4644.js} +145 -119
- package/chunks/{src-TMOD5X6F.js → src-7XL4G4DC.js} +88 -46
- package/chunks/{src-4QH4FZ6I.js → src-IHA6DTUV.js} +452 -62
- package/chunks/{syntheticOutput-5PVFDDJ4.js → syntheticOutput-YTYS2ZMQ.js} +4 -4
- package/chunks/task-create-MPORPYN6.js +19 -0
- package/chunks/task-list-R2YDYPZT.js +151 -0
- package/chunks/{task-stop-AJKPSR6R.js → task-stop-SYWJYBCM.js} +3 -3
- package/chunks/task-update-E4NSLKMQ.js +408 -0
- package/chunks/team-create-7R7KA5IP.js +314 -0
- package/chunks/team-delete-25OIWUPN.js +116 -0
- package/chunks/{todoWrite-VLAUG4CA.js → todoWrite-4YHMIF4X.js} +16 -5
- package/chunks/{tool-search-MZGHUUKD.js → tool-search-YBRVZCLI.js} +29 -11
- package/chunks/{tts-notification-K3X7X7MN.js → tts-notification-7SOEMQK4.js} +5 -4
- package/chunks/{web-fetch-OILB464A.js → web-fetch-MFIRHIHI.js} +5 -5
- package/chunks/workflow-5RIKVCIE.js +960 -0
- package/chunks/{write-file-BIQAA57V.js → write-file-DMQTJZOM.js} +32 -24
- package/chunks/{zh-PWL2NKY3.js → zh-7H5OQC4I.js} +135 -11
- package/chunks/{zh-TW-S3YGWICZ.js → zh-TW-P4IDHD3M.js} +128 -11
- package/cli.js +45402 -20570
- package/examples/agent/agents/diary.md +86 -0
- package/examples/agent/qwen-extension.json +5 -0
- package/examples/commands/commands/fs/grep-code.md +3 -0
- package/examples/commands/qwen-extension.json +5 -0
- package/examples/context/QWEN.md +8 -0
- package/examples/context/qwen-extension.json +5 -0
- package/examples/mcp-server/example.ts +60 -0
- package/examples/mcp-server/package.json +18 -0
- package/examples/mcp-server/qwen-extension.json +12 -0
- package/examples/mcp-server/tsconfig.json +13 -0
- package/examples/skills/qwen-extension.json +5 -0
- package/examples/skills/skills/synonyms/SKILL.md +48 -0
- package/examples/starter/QWEN.md +30 -0
- package/examples/starter/README.md +59 -0
- package/examples/starter/agents/diary.md +86 -0
- package/examples/starter/commands/writing/polish.md +13 -0
- package/examples/starter/example.ts +64 -0
- package/examples/starter/package.json +18 -0
- package/examples/starter/qwen-extension.json +12 -0
- package/examples/starter/skills/synonyms/SKILL.md +48 -0
- package/examples/starter/tsconfig.json +13 -0
- package/fzfWorker.js +1083 -0
- package/locales/ca.js +118 -5
- package/locales/de.js +117 -5
- package/locales/en.js +169 -7
- package/locales/fr.js +119 -5
- package/locales/ja.js +114 -5
- package/locales/pt.js +117 -5
- package/locales/ru.js +116 -5
- package/locales/zh-TW.js +161 -12
- package/locales/zh.js +169 -12
- package/package.json +4 -2
- package/scripts/postinstall.cjs +2 -1
- package/bundled/qc-helper/docs/features/checkpointing.md +0 -77
- package/chunks/agent-7ZN3CRHR.js +0 -48
- package/chunks/chunk-6PCB2DEF.js +0 -434
- package/chunks/chunk-EM6ETG2K.js +0 -60
- package/chunks/chunk-G7YTSRES.js +0 -150
- package/chunks/contextCommand-7IBASARL.js +0 -44
- package/chunks/exitPlanMode-PZAMWIRW.js +0 -227
- package/chunks/multipart-parser-IXGBIOIN.js +0 -384
- package/chunks/read-file-CCUEUFG2.js +0 -24
- package/chunks/ripGrep-TADOH2HK.js +0 -40
- package/chunks/send-message-YL44UZFC.js +0 -151
- package/chunks/shell-7KKKC5G7.js +0 -48
- package/chunks/src-IPWIHNMI.js +0 -1406
- package/chunks/undici-F6ZOXSS5.js +0 -8
|
@@ -0,0 +1,2230 @@
|
|
|
1
|
+
// Force strict mode and setup for ESM
|
|
2
|
+
"use strict";
|
|
3
|
+
import {
|
|
4
|
+
INBOXES_DIR,
|
|
5
|
+
LEADER_NAME,
|
|
6
|
+
TASKS_DIR,
|
|
7
|
+
TEAMMATE_COLORS,
|
|
8
|
+
TEAMS_DIR,
|
|
9
|
+
TEAM_CONFIG_FILENAME
|
|
10
|
+
} from "./chunk-LD2XBG6Z.js";
|
|
11
|
+
import {
|
|
12
|
+
atomicWriteJSON
|
|
13
|
+
} from "./chunk-B7HXHOHU.js";
|
|
14
|
+
import {
|
|
15
|
+
Storage,
|
|
16
|
+
isNodeError
|
|
17
|
+
} from "./chunk-HR7SV7AY.js";
|
|
18
|
+
import {
|
|
19
|
+
init_esbuild_shims
|
|
20
|
+
} from "./chunk-A4BMJM77.js";
|
|
21
|
+
import {
|
|
22
|
+
__commonJS,
|
|
23
|
+
__name,
|
|
24
|
+
__require
|
|
25
|
+
} from "./chunk-J2S4EL5Y.js";
|
|
26
|
+
|
|
27
|
+
// node_modules/graceful-fs/polyfills.js
|
|
28
|
+
var require_polyfills = __commonJS({
|
|
29
|
+
"node_modules/graceful-fs/polyfills.js"(exports, module) {
|
|
30
|
+
init_esbuild_shims();
|
|
31
|
+
var constants = __require("constants");
|
|
32
|
+
var origCwd = process.cwd;
|
|
33
|
+
var cwd = null;
|
|
34
|
+
var platform = process.env.GRACEFUL_FS_PLATFORM || process.platform;
|
|
35
|
+
process.cwd = function() {
|
|
36
|
+
if (!cwd)
|
|
37
|
+
cwd = origCwd.call(process);
|
|
38
|
+
return cwd;
|
|
39
|
+
};
|
|
40
|
+
try {
|
|
41
|
+
process.cwd();
|
|
42
|
+
} catch (er) {
|
|
43
|
+
}
|
|
44
|
+
if (typeof process.chdir === "function") {
|
|
45
|
+
chdir = process.chdir;
|
|
46
|
+
process.chdir = function(d) {
|
|
47
|
+
cwd = null;
|
|
48
|
+
chdir.call(process, d);
|
|
49
|
+
};
|
|
50
|
+
if (Object.setPrototypeOf) Object.setPrototypeOf(process.chdir, chdir);
|
|
51
|
+
}
|
|
52
|
+
var chdir;
|
|
53
|
+
module.exports = patch;
|
|
54
|
+
function patch(fs2) {
|
|
55
|
+
if (constants.hasOwnProperty("O_SYMLINK") && process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)) {
|
|
56
|
+
patchLchmod(fs2);
|
|
57
|
+
}
|
|
58
|
+
if (!fs2.lutimes) {
|
|
59
|
+
patchLutimes(fs2);
|
|
60
|
+
}
|
|
61
|
+
fs2.chown = chownFix(fs2.chown);
|
|
62
|
+
fs2.fchown = chownFix(fs2.fchown);
|
|
63
|
+
fs2.lchown = chownFix(fs2.lchown);
|
|
64
|
+
fs2.chmod = chmodFix(fs2.chmod);
|
|
65
|
+
fs2.fchmod = chmodFix(fs2.fchmod);
|
|
66
|
+
fs2.lchmod = chmodFix(fs2.lchmod);
|
|
67
|
+
fs2.chownSync = chownFixSync(fs2.chownSync);
|
|
68
|
+
fs2.fchownSync = chownFixSync(fs2.fchownSync);
|
|
69
|
+
fs2.lchownSync = chownFixSync(fs2.lchownSync);
|
|
70
|
+
fs2.chmodSync = chmodFixSync(fs2.chmodSync);
|
|
71
|
+
fs2.fchmodSync = chmodFixSync(fs2.fchmodSync);
|
|
72
|
+
fs2.lchmodSync = chmodFixSync(fs2.lchmodSync);
|
|
73
|
+
fs2.stat = statFix(fs2.stat);
|
|
74
|
+
fs2.fstat = statFix(fs2.fstat);
|
|
75
|
+
fs2.lstat = statFix(fs2.lstat);
|
|
76
|
+
fs2.statSync = statFixSync(fs2.statSync);
|
|
77
|
+
fs2.fstatSync = statFixSync(fs2.fstatSync);
|
|
78
|
+
fs2.lstatSync = statFixSync(fs2.lstatSync);
|
|
79
|
+
if (fs2.chmod && !fs2.lchmod) {
|
|
80
|
+
fs2.lchmod = function(path2, mode, cb) {
|
|
81
|
+
if (cb) process.nextTick(cb);
|
|
82
|
+
};
|
|
83
|
+
fs2.lchmodSync = function() {
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
if (fs2.chown && !fs2.lchown) {
|
|
87
|
+
fs2.lchown = function(path2, uid, gid, cb) {
|
|
88
|
+
if (cb) process.nextTick(cb);
|
|
89
|
+
};
|
|
90
|
+
fs2.lchownSync = function() {
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
if (platform === "win32") {
|
|
94
|
+
fs2.rename = typeof fs2.rename !== "function" ? fs2.rename : function(fs$rename) {
|
|
95
|
+
function rename(from, to, cb) {
|
|
96
|
+
var start = Date.now();
|
|
97
|
+
var backoff = 0;
|
|
98
|
+
fs$rename(from, to, /* @__PURE__ */ __name(function CB(er) {
|
|
99
|
+
if (er && (er.code === "EACCES" || er.code === "EPERM" || er.code === "EBUSY") && Date.now() - start < 6e4) {
|
|
100
|
+
setTimeout(function() {
|
|
101
|
+
fs2.stat(to, function(stater, st) {
|
|
102
|
+
if (stater && stater.code === "ENOENT")
|
|
103
|
+
fs$rename(from, to, CB);
|
|
104
|
+
else
|
|
105
|
+
cb(er);
|
|
106
|
+
});
|
|
107
|
+
}, backoff);
|
|
108
|
+
if (backoff < 100)
|
|
109
|
+
backoff += 10;
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
if (cb) cb(er);
|
|
113
|
+
}, "CB"));
|
|
114
|
+
}
|
|
115
|
+
__name(rename, "rename");
|
|
116
|
+
if (Object.setPrototypeOf) Object.setPrototypeOf(rename, fs$rename);
|
|
117
|
+
return rename;
|
|
118
|
+
}(fs2.rename);
|
|
119
|
+
}
|
|
120
|
+
fs2.read = typeof fs2.read !== "function" ? fs2.read : function(fs$read) {
|
|
121
|
+
function read(fd, buffer, offset, length, position, callback_) {
|
|
122
|
+
var callback;
|
|
123
|
+
if (callback_ && typeof callback_ === "function") {
|
|
124
|
+
var eagCounter = 0;
|
|
125
|
+
callback = /* @__PURE__ */ __name(function(er, _, __) {
|
|
126
|
+
if (er && er.code === "EAGAIN" && eagCounter < 10) {
|
|
127
|
+
eagCounter++;
|
|
128
|
+
return fs$read.call(fs2, fd, buffer, offset, length, position, callback);
|
|
129
|
+
}
|
|
130
|
+
callback_.apply(this, arguments);
|
|
131
|
+
}, "callback");
|
|
132
|
+
}
|
|
133
|
+
return fs$read.call(fs2, fd, buffer, offset, length, position, callback);
|
|
134
|
+
}
|
|
135
|
+
__name(read, "read");
|
|
136
|
+
if (Object.setPrototypeOf) Object.setPrototypeOf(read, fs$read);
|
|
137
|
+
return read;
|
|
138
|
+
}(fs2.read);
|
|
139
|
+
fs2.readSync = typeof fs2.readSync !== "function" ? fs2.readSync : /* @__PURE__ */ function(fs$readSync) {
|
|
140
|
+
return function(fd, buffer, offset, length, position) {
|
|
141
|
+
var eagCounter = 0;
|
|
142
|
+
while (true) {
|
|
143
|
+
try {
|
|
144
|
+
return fs$readSync.call(fs2, fd, buffer, offset, length, position);
|
|
145
|
+
} catch (er) {
|
|
146
|
+
if (er.code === "EAGAIN" && eagCounter < 10) {
|
|
147
|
+
eagCounter++;
|
|
148
|
+
continue;
|
|
149
|
+
}
|
|
150
|
+
throw er;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
}(fs2.readSync);
|
|
155
|
+
function patchLchmod(fs3) {
|
|
156
|
+
fs3.lchmod = function(path2, mode, callback) {
|
|
157
|
+
fs3.open(
|
|
158
|
+
path2,
|
|
159
|
+
constants.O_WRONLY | constants.O_SYMLINK,
|
|
160
|
+
mode,
|
|
161
|
+
function(err, fd) {
|
|
162
|
+
if (err) {
|
|
163
|
+
if (callback) callback(err);
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
fs3.fchmod(fd, mode, function(err2) {
|
|
167
|
+
fs3.close(fd, function(err22) {
|
|
168
|
+
if (callback) callback(err2 || err22);
|
|
169
|
+
});
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
);
|
|
173
|
+
};
|
|
174
|
+
fs3.lchmodSync = function(path2, mode) {
|
|
175
|
+
var fd = fs3.openSync(path2, constants.O_WRONLY | constants.O_SYMLINK, mode);
|
|
176
|
+
var threw = true;
|
|
177
|
+
var ret;
|
|
178
|
+
try {
|
|
179
|
+
ret = fs3.fchmodSync(fd, mode);
|
|
180
|
+
threw = false;
|
|
181
|
+
} finally {
|
|
182
|
+
if (threw) {
|
|
183
|
+
try {
|
|
184
|
+
fs3.closeSync(fd);
|
|
185
|
+
} catch (er) {
|
|
186
|
+
}
|
|
187
|
+
} else {
|
|
188
|
+
fs3.closeSync(fd);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
return ret;
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
__name(patchLchmod, "patchLchmod");
|
|
195
|
+
function patchLutimes(fs3) {
|
|
196
|
+
if (constants.hasOwnProperty("O_SYMLINK") && fs3.futimes) {
|
|
197
|
+
fs3.lutimes = function(path2, at, mt, cb) {
|
|
198
|
+
fs3.open(path2, constants.O_SYMLINK, function(er, fd) {
|
|
199
|
+
if (er) {
|
|
200
|
+
if (cb) cb(er);
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
fs3.futimes(fd, at, mt, function(er2) {
|
|
204
|
+
fs3.close(fd, function(er22) {
|
|
205
|
+
if (cb) cb(er2 || er22);
|
|
206
|
+
});
|
|
207
|
+
});
|
|
208
|
+
});
|
|
209
|
+
};
|
|
210
|
+
fs3.lutimesSync = function(path2, at, mt) {
|
|
211
|
+
var fd = fs3.openSync(path2, constants.O_SYMLINK);
|
|
212
|
+
var ret;
|
|
213
|
+
var threw = true;
|
|
214
|
+
try {
|
|
215
|
+
ret = fs3.futimesSync(fd, at, mt);
|
|
216
|
+
threw = false;
|
|
217
|
+
} finally {
|
|
218
|
+
if (threw) {
|
|
219
|
+
try {
|
|
220
|
+
fs3.closeSync(fd);
|
|
221
|
+
} catch (er) {
|
|
222
|
+
}
|
|
223
|
+
} else {
|
|
224
|
+
fs3.closeSync(fd);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
return ret;
|
|
228
|
+
};
|
|
229
|
+
} else if (fs3.futimes) {
|
|
230
|
+
fs3.lutimes = function(_a, _b, _c, cb) {
|
|
231
|
+
if (cb) process.nextTick(cb);
|
|
232
|
+
};
|
|
233
|
+
fs3.lutimesSync = function() {
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
__name(patchLutimes, "patchLutimes");
|
|
238
|
+
function chmodFix(orig) {
|
|
239
|
+
if (!orig) return orig;
|
|
240
|
+
return function(target, mode, cb) {
|
|
241
|
+
return orig.call(fs2, target, mode, function(er) {
|
|
242
|
+
if (chownErOk(er)) er = null;
|
|
243
|
+
if (cb) cb.apply(this, arguments);
|
|
244
|
+
});
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
__name(chmodFix, "chmodFix");
|
|
248
|
+
function chmodFixSync(orig) {
|
|
249
|
+
if (!orig) return orig;
|
|
250
|
+
return function(target, mode) {
|
|
251
|
+
try {
|
|
252
|
+
return orig.call(fs2, target, mode);
|
|
253
|
+
} catch (er) {
|
|
254
|
+
if (!chownErOk(er)) throw er;
|
|
255
|
+
}
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
__name(chmodFixSync, "chmodFixSync");
|
|
259
|
+
function chownFix(orig) {
|
|
260
|
+
if (!orig) return orig;
|
|
261
|
+
return function(target, uid, gid, cb) {
|
|
262
|
+
return orig.call(fs2, target, uid, gid, function(er) {
|
|
263
|
+
if (chownErOk(er)) er = null;
|
|
264
|
+
if (cb) cb.apply(this, arguments);
|
|
265
|
+
});
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
__name(chownFix, "chownFix");
|
|
269
|
+
function chownFixSync(orig) {
|
|
270
|
+
if (!orig) return orig;
|
|
271
|
+
return function(target, uid, gid) {
|
|
272
|
+
try {
|
|
273
|
+
return orig.call(fs2, target, uid, gid);
|
|
274
|
+
} catch (er) {
|
|
275
|
+
if (!chownErOk(er)) throw er;
|
|
276
|
+
}
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
__name(chownFixSync, "chownFixSync");
|
|
280
|
+
function statFix(orig) {
|
|
281
|
+
if (!orig) return orig;
|
|
282
|
+
return function(target, options, cb) {
|
|
283
|
+
if (typeof options === "function") {
|
|
284
|
+
cb = options;
|
|
285
|
+
options = null;
|
|
286
|
+
}
|
|
287
|
+
function callback(er, stats) {
|
|
288
|
+
if (stats) {
|
|
289
|
+
if (stats.uid < 0) stats.uid += 4294967296;
|
|
290
|
+
if (stats.gid < 0) stats.gid += 4294967296;
|
|
291
|
+
}
|
|
292
|
+
if (cb) cb.apply(this, arguments);
|
|
293
|
+
}
|
|
294
|
+
__name(callback, "callback");
|
|
295
|
+
return options ? orig.call(fs2, target, options, callback) : orig.call(fs2, target, callback);
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
__name(statFix, "statFix");
|
|
299
|
+
function statFixSync(orig) {
|
|
300
|
+
if (!orig) return orig;
|
|
301
|
+
return function(target, options) {
|
|
302
|
+
var stats = options ? orig.call(fs2, target, options) : orig.call(fs2, target);
|
|
303
|
+
if (stats) {
|
|
304
|
+
if (stats.uid < 0) stats.uid += 4294967296;
|
|
305
|
+
if (stats.gid < 0) stats.gid += 4294967296;
|
|
306
|
+
}
|
|
307
|
+
return stats;
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
__name(statFixSync, "statFixSync");
|
|
311
|
+
function chownErOk(er) {
|
|
312
|
+
if (!er)
|
|
313
|
+
return true;
|
|
314
|
+
if (er.code === "ENOSYS")
|
|
315
|
+
return true;
|
|
316
|
+
var nonroot = !process.getuid || process.getuid() !== 0;
|
|
317
|
+
if (nonroot) {
|
|
318
|
+
if (er.code === "EINVAL" || er.code === "EPERM")
|
|
319
|
+
return true;
|
|
320
|
+
}
|
|
321
|
+
return false;
|
|
322
|
+
}
|
|
323
|
+
__name(chownErOk, "chownErOk");
|
|
324
|
+
}
|
|
325
|
+
__name(patch, "patch");
|
|
326
|
+
}
|
|
327
|
+
});
|
|
328
|
+
|
|
329
|
+
// node_modules/graceful-fs/legacy-streams.js
|
|
330
|
+
var require_legacy_streams = __commonJS({
|
|
331
|
+
"node_modules/graceful-fs/legacy-streams.js"(exports, module) {
|
|
332
|
+
init_esbuild_shims();
|
|
333
|
+
var Stream = __require("stream").Stream;
|
|
334
|
+
module.exports = legacy;
|
|
335
|
+
function legacy(fs2) {
|
|
336
|
+
return {
|
|
337
|
+
ReadStream,
|
|
338
|
+
WriteStream
|
|
339
|
+
};
|
|
340
|
+
function ReadStream(path2, options) {
|
|
341
|
+
if (!(this instanceof ReadStream)) return new ReadStream(path2, options);
|
|
342
|
+
Stream.call(this);
|
|
343
|
+
var self = this;
|
|
344
|
+
this.path = path2;
|
|
345
|
+
this.fd = null;
|
|
346
|
+
this.readable = true;
|
|
347
|
+
this.paused = false;
|
|
348
|
+
this.flags = "r";
|
|
349
|
+
this.mode = 438;
|
|
350
|
+
this.bufferSize = 64 * 1024;
|
|
351
|
+
options = options || {};
|
|
352
|
+
var keys = Object.keys(options);
|
|
353
|
+
for (var index = 0, length = keys.length; index < length; index++) {
|
|
354
|
+
var key = keys[index];
|
|
355
|
+
this[key] = options[key];
|
|
356
|
+
}
|
|
357
|
+
if (this.encoding) this.setEncoding(this.encoding);
|
|
358
|
+
if (this.start !== void 0) {
|
|
359
|
+
if ("number" !== typeof this.start) {
|
|
360
|
+
throw TypeError("start must be a Number");
|
|
361
|
+
}
|
|
362
|
+
if (this.end === void 0) {
|
|
363
|
+
this.end = Infinity;
|
|
364
|
+
} else if ("number" !== typeof this.end) {
|
|
365
|
+
throw TypeError("end must be a Number");
|
|
366
|
+
}
|
|
367
|
+
if (this.start > this.end) {
|
|
368
|
+
throw new Error("start must be <= end");
|
|
369
|
+
}
|
|
370
|
+
this.pos = this.start;
|
|
371
|
+
}
|
|
372
|
+
if (this.fd !== null) {
|
|
373
|
+
process.nextTick(function() {
|
|
374
|
+
self._read();
|
|
375
|
+
});
|
|
376
|
+
return;
|
|
377
|
+
}
|
|
378
|
+
fs2.open(this.path, this.flags, this.mode, function(err, fd) {
|
|
379
|
+
if (err) {
|
|
380
|
+
self.emit("error", err);
|
|
381
|
+
self.readable = false;
|
|
382
|
+
return;
|
|
383
|
+
}
|
|
384
|
+
self.fd = fd;
|
|
385
|
+
self.emit("open", fd);
|
|
386
|
+
self._read();
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
__name(ReadStream, "ReadStream");
|
|
390
|
+
function WriteStream(path2, options) {
|
|
391
|
+
if (!(this instanceof WriteStream)) return new WriteStream(path2, options);
|
|
392
|
+
Stream.call(this);
|
|
393
|
+
this.path = path2;
|
|
394
|
+
this.fd = null;
|
|
395
|
+
this.writable = true;
|
|
396
|
+
this.flags = "w";
|
|
397
|
+
this.encoding = "binary";
|
|
398
|
+
this.mode = 438;
|
|
399
|
+
this.bytesWritten = 0;
|
|
400
|
+
options = options || {};
|
|
401
|
+
var keys = Object.keys(options);
|
|
402
|
+
for (var index = 0, length = keys.length; index < length; index++) {
|
|
403
|
+
var key = keys[index];
|
|
404
|
+
this[key] = options[key];
|
|
405
|
+
}
|
|
406
|
+
if (this.start !== void 0) {
|
|
407
|
+
if ("number" !== typeof this.start) {
|
|
408
|
+
throw TypeError("start must be a Number");
|
|
409
|
+
}
|
|
410
|
+
if (this.start < 0) {
|
|
411
|
+
throw new Error("start must be >= zero");
|
|
412
|
+
}
|
|
413
|
+
this.pos = this.start;
|
|
414
|
+
}
|
|
415
|
+
this.busy = false;
|
|
416
|
+
this._queue = [];
|
|
417
|
+
if (this.fd === null) {
|
|
418
|
+
this._open = fs2.open;
|
|
419
|
+
this._queue.push([this._open, this.path, this.flags, this.mode, void 0]);
|
|
420
|
+
this.flush();
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
__name(WriteStream, "WriteStream");
|
|
424
|
+
}
|
|
425
|
+
__name(legacy, "legacy");
|
|
426
|
+
}
|
|
427
|
+
});
|
|
428
|
+
|
|
429
|
+
// node_modules/graceful-fs/clone.js
|
|
430
|
+
var require_clone = __commonJS({
|
|
431
|
+
"node_modules/graceful-fs/clone.js"(exports, module) {
|
|
432
|
+
"use strict";
|
|
433
|
+
init_esbuild_shims();
|
|
434
|
+
module.exports = clone;
|
|
435
|
+
var getPrototypeOf = Object.getPrototypeOf || function(obj) {
|
|
436
|
+
return obj.__proto__;
|
|
437
|
+
};
|
|
438
|
+
function clone(obj) {
|
|
439
|
+
if (obj === null || typeof obj !== "object")
|
|
440
|
+
return obj;
|
|
441
|
+
if (obj instanceof Object)
|
|
442
|
+
var copy = { __proto__: getPrototypeOf(obj) };
|
|
443
|
+
else
|
|
444
|
+
var copy = /* @__PURE__ */ Object.create(null);
|
|
445
|
+
Object.getOwnPropertyNames(obj).forEach(function(key) {
|
|
446
|
+
Object.defineProperty(copy, key, Object.getOwnPropertyDescriptor(obj, key));
|
|
447
|
+
});
|
|
448
|
+
return copy;
|
|
449
|
+
}
|
|
450
|
+
__name(clone, "clone");
|
|
451
|
+
}
|
|
452
|
+
});
|
|
453
|
+
|
|
454
|
+
// node_modules/graceful-fs/graceful-fs.js
|
|
455
|
+
var require_graceful_fs = __commonJS({
|
|
456
|
+
"node_modules/graceful-fs/graceful-fs.js"(exports, module) {
|
|
457
|
+
init_esbuild_shims();
|
|
458
|
+
var fs2 = __require("fs");
|
|
459
|
+
var polyfills = require_polyfills();
|
|
460
|
+
var legacy = require_legacy_streams();
|
|
461
|
+
var clone = require_clone();
|
|
462
|
+
var util = __require("util");
|
|
463
|
+
var gracefulQueue;
|
|
464
|
+
var previousSymbol;
|
|
465
|
+
if (typeof Symbol === "function" && typeof Symbol.for === "function") {
|
|
466
|
+
gracefulQueue = Symbol.for("graceful-fs.queue");
|
|
467
|
+
previousSymbol = Symbol.for("graceful-fs.previous");
|
|
468
|
+
} else {
|
|
469
|
+
gracefulQueue = "___graceful-fs.queue";
|
|
470
|
+
previousSymbol = "___graceful-fs.previous";
|
|
471
|
+
}
|
|
472
|
+
function noop() {
|
|
473
|
+
}
|
|
474
|
+
__name(noop, "noop");
|
|
475
|
+
function publishQueue(context, queue2) {
|
|
476
|
+
Object.defineProperty(context, gracefulQueue, {
|
|
477
|
+
get: /* @__PURE__ */ __name(function() {
|
|
478
|
+
return queue2;
|
|
479
|
+
}, "get")
|
|
480
|
+
});
|
|
481
|
+
}
|
|
482
|
+
__name(publishQueue, "publishQueue");
|
|
483
|
+
var debug = noop;
|
|
484
|
+
if (util.debuglog)
|
|
485
|
+
debug = util.debuglog("gfs4");
|
|
486
|
+
else if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || ""))
|
|
487
|
+
debug = /* @__PURE__ */ __name(function() {
|
|
488
|
+
var m = util.format.apply(util, arguments);
|
|
489
|
+
m = "GFS4: " + m.split(/\n/).join("\nGFS4: ");
|
|
490
|
+
console.error(m);
|
|
491
|
+
}, "debug");
|
|
492
|
+
if (!fs2[gracefulQueue]) {
|
|
493
|
+
queue = globalThis[gracefulQueue] || [];
|
|
494
|
+
publishQueue(fs2, queue);
|
|
495
|
+
fs2.close = function(fs$close) {
|
|
496
|
+
function close(fd, cb) {
|
|
497
|
+
return fs$close.call(fs2, fd, function(err) {
|
|
498
|
+
if (!err) {
|
|
499
|
+
resetQueue();
|
|
500
|
+
}
|
|
501
|
+
if (typeof cb === "function")
|
|
502
|
+
cb.apply(this, arguments);
|
|
503
|
+
});
|
|
504
|
+
}
|
|
505
|
+
__name(close, "close");
|
|
506
|
+
Object.defineProperty(close, previousSymbol, {
|
|
507
|
+
value: fs$close
|
|
508
|
+
});
|
|
509
|
+
return close;
|
|
510
|
+
}(fs2.close);
|
|
511
|
+
fs2.closeSync = function(fs$closeSync) {
|
|
512
|
+
function closeSync(fd) {
|
|
513
|
+
fs$closeSync.apply(fs2, arguments);
|
|
514
|
+
resetQueue();
|
|
515
|
+
}
|
|
516
|
+
__name(closeSync, "closeSync");
|
|
517
|
+
Object.defineProperty(closeSync, previousSymbol, {
|
|
518
|
+
value: fs$closeSync
|
|
519
|
+
});
|
|
520
|
+
return closeSync;
|
|
521
|
+
}(fs2.closeSync);
|
|
522
|
+
if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || "")) {
|
|
523
|
+
process.on("exit", function() {
|
|
524
|
+
debug(fs2[gracefulQueue]);
|
|
525
|
+
__require("assert").equal(fs2[gracefulQueue].length, 0);
|
|
526
|
+
});
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
var queue;
|
|
530
|
+
if (!globalThis[gracefulQueue]) {
|
|
531
|
+
publishQueue(globalThis, fs2[gracefulQueue]);
|
|
532
|
+
}
|
|
533
|
+
module.exports = patch(clone(fs2));
|
|
534
|
+
if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH && !fs2.__patched) {
|
|
535
|
+
module.exports = patch(fs2);
|
|
536
|
+
fs2.__patched = true;
|
|
537
|
+
}
|
|
538
|
+
function patch(fs3) {
|
|
539
|
+
polyfills(fs3);
|
|
540
|
+
fs3.gracefulify = patch;
|
|
541
|
+
fs3.createReadStream = createReadStream;
|
|
542
|
+
fs3.createWriteStream = createWriteStream;
|
|
543
|
+
var fs$readFile = fs3.readFile;
|
|
544
|
+
fs3.readFile = readFile2;
|
|
545
|
+
function readFile2(path2, options, cb) {
|
|
546
|
+
if (typeof options === "function")
|
|
547
|
+
cb = options, options = null;
|
|
548
|
+
return go$readFile(path2, options, cb);
|
|
549
|
+
function go$readFile(path3, options2, cb2, startTime) {
|
|
550
|
+
return fs$readFile(path3, options2, function(err) {
|
|
551
|
+
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
552
|
+
enqueue([go$readFile, [path3, options2, cb2], err, startTime || Date.now(), Date.now()]);
|
|
553
|
+
else {
|
|
554
|
+
if (typeof cb2 === "function")
|
|
555
|
+
cb2.apply(this, arguments);
|
|
556
|
+
}
|
|
557
|
+
});
|
|
558
|
+
}
|
|
559
|
+
__name(go$readFile, "go$readFile");
|
|
560
|
+
}
|
|
561
|
+
__name(readFile2, "readFile");
|
|
562
|
+
var fs$writeFile = fs3.writeFile;
|
|
563
|
+
fs3.writeFile = writeFile2;
|
|
564
|
+
function writeFile2(path2, data, options, cb) {
|
|
565
|
+
if (typeof options === "function")
|
|
566
|
+
cb = options, options = null;
|
|
567
|
+
return go$writeFile(path2, data, options, cb);
|
|
568
|
+
function go$writeFile(path3, data2, options2, cb2, startTime) {
|
|
569
|
+
return fs$writeFile(path3, data2, options2, function(err) {
|
|
570
|
+
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
571
|
+
enqueue([go$writeFile, [path3, data2, options2, cb2], err, startTime || Date.now(), Date.now()]);
|
|
572
|
+
else {
|
|
573
|
+
if (typeof cb2 === "function")
|
|
574
|
+
cb2.apply(this, arguments);
|
|
575
|
+
}
|
|
576
|
+
});
|
|
577
|
+
}
|
|
578
|
+
__name(go$writeFile, "go$writeFile");
|
|
579
|
+
}
|
|
580
|
+
__name(writeFile2, "writeFile");
|
|
581
|
+
var fs$appendFile = fs3.appendFile;
|
|
582
|
+
if (fs$appendFile)
|
|
583
|
+
fs3.appendFile = appendFile;
|
|
584
|
+
function appendFile(path2, data, options, cb) {
|
|
585
|
+
if (typeof options === "function")
|
|
586
|
+
cb = options, options = null;
|
|
587
|
+
return go$appendFile(path2, data, options, cb);
|
|
588
|
+
function go$appendFile(path3, data2, options2, cb2, startTime) {
|
|
589
|
+
return fs$appendFile(path3, data2, options2, function(err) {
|
|
590
|
+
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
591
|
+
enqueue([go$appendFile, [path3, data2, options2, cb2], err, startTime || Date.now(), Date.now()]);
|
|
592
|
+
else {
|
|
593
|
+
if (typeof cb2 === "function")
|
|
594
|
+
cb2.apply(this, arguments);
|
|
595
|
+
}
|
|
596
|
+
});
|
|
597
|
+
}
|
|
598
|
+
__name(go$appendFile, "go$appendFile");
|
|
599
|
+
}
|
|
600
|
+
__name(appendFile, "appendFile");
|
|
601
|
+
var fs$copyFile = fs3.copyFile;
|
|
602
|
+
if (fs$copyFile)
|
|
603
|
+
fs3.copyFile = copyFile;
|
|
604
|
+
function copyFile(src, dest, flags, cb) {
|
|
605
|
+
if (typeof flags === "function") {
|
|
606
|
+
cb = flags;
|
|
607
|
+
flags = 0;
|
|
608
|
+
}
|
|
609
|
+
return go$copyFile(src, dest, flags, cb);
|
|
610
|
+
function go$copyFile(src2, dest2, flags2, cb2, startTime) {
|
|
611
|
+
return fs$copyFile(src2, dest2, flags2, function(err) {
|
|
612
|
+
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
613
|
+
enqueue([go$copyFile, [src2, dest2, flags2, cb2], err, startTime || Date.now(), Date.now()]);
|
|
614
|
+
else {
|
|
615
|
+
if (typeof cb2 === "function")
|
|
616
|
+
cb2.apply(this, arguments);
|
|
617
|
+
}
|
|
618
|
+
});
|
|
619
|
+
}
|
|
620
|
+
__name(go$copyFile, "go$copyFile");
|
|
621
|
+
}
|
|
622
|
+
__name(copyFile, "copyFile");
|
|
623
|
+
var fs$readdir = fs3.readdir;
|
|
624
|
+
fs3.readdir = readdir2;
|
|
625
|
+
var noReaddirOptionVersions = /^v[0-5]\./;
|
|
626
|
+
function readdir2(path2, options, cb) {
|
|
627
|
+
if (typeof options === "function")
|
|
628
|
+
cb = options, options = null;
|
|
629
|
+
var go$readdir = noReaddirOptionVersions.test(process.version) ? /* @__PURE__ */ __name(function go$readdir2(path3, options2, cb2, startTime) {
|
|
630
|
+
return fs$readdir(path3, fs$readdirCallback(
|
|
631
|
+
path3,
|
|
632
|
+
options2,
|
|
633
|
+
cb2,
|
|
634
|
+
startTime
|
|
635
|
+
));
|
|
636
|
+
}, "go$readdir") : /* @__PURE__ */ __name(function go$readdir2(path3, options2, cb2, startTime) {
|
|
637
|
+
return fs$readdir(path3, options2, fs$readdirCallback(
|
|
638
|
+
path3,
|
|
639
|
+
options2,
|
|
640
|
+
cb2,
|
|
641
|
+
startTime
|
|
642
|
+
));
|
|
643
|
+
}, "go$readdir");
|
|
644
|
+
return go$readdir(path2, options, cb);
|
|
645
|
+
function fs$readdirCallback(path3, options2, cb2, startTime) {
|
|
646
|
+
return function(err, files) {
|
|
647
|
+
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
648
|
+
enqueue([
|
|
649
|
+
go$readdir,
|
|
650
|
+
[path3, options2, cb2],
|
|
651
|
+
err,
|
|
652
|
+
startTime || Date.now(),
|
|
653
|
+
Date.now()
|
|
654
|
+
]);
|
|
655
|
+
else {
|
|
656
|
+
if (files && files.sort)
|
|
657
|
+
files.sort();
|
|
658
|
+
if (typeof cb2 === "function")
|
|
659
|
+
cb2.call(this, err, files);
|
|
660
|
+
}
|
|
661
|
+
};
|
|
662
|
+
}
|
|
663
|
+
__name(fs$readdirCallback, "fs$readdirCallback");
|
|
664
|
+
}
|
|
665
|
+
__name(readdir2, "readdir");
|
|
666
|
+
if (process.version.substr(0, 4) === "v0.8") {
|
|
667
|
+
var legStreams = legacy(fs3);
|
|
668
|
+
ReadStream = legStreams.ReadStream;
|
|
669
|
+
WriteStream = legStreams.WriteStream;
|
|
670
|
+
}
|
|
671
|
+
var fs$ReadStream = fs3.ReadStream;
|
|
672
|
+
if (fs$ReadStream) {
|
|
673
|
+
ReadStream.prototype = Object.create(fs$ReadStream.prototype);
|
|
674
|
+
ReadStream.prototype.open = ReadStream$open;
|
|
675
|
+
}
|
|
676
|
+
var fs$WriteStream = fs3.WriteStream;
|
|
677
|
+
if (fs$WriteStream) {
|
|
678
|
+
WriteStream.prototype = Object.create(fs$WriteStream.prototype);
|
|
679
|
+
WriteStream.prototype.open = WriteStream$open;
|
|
680
|
+
}
|
|
681
|
+
Object.defineProperty(fs3, "ReadStream", {
|
|
682
|
+
get: /* @__PURE__ */ __name(function() {
|
|
683
|
+
return ReadStream;
|
|
684
|
+
}, "get"),
|
|
685
|
+
set: /* @__PURE__ */ __name(function(val) {
|
|
686
|
+
ReadStream = val;
|
|
687
|
+
}, "set"),
|
|
688
|
+
enumerable: true,
|
|
689
|
+
configurable: true
|
|
690
|
+
});
|
|
691
|
+
Object.defineProperty(fs3, "WriteStream", {
|
|
692
|
+
get: /* @__PURE__ */ __name(function() {
|
|
693
|
+
return WriteStream;
|
|
694
|
+
}, "get"),
|
|
695
|
+
set: /* @__PURE__ */ __name(function(val) {
|
|
696
|
+
WriteStream = val;
|
|
697
|
+
}, "set"),
|
|
698
|
+
enumerable: true,
|
|
699
|
+
configurable: true
|
|
700
|
+
});
|
|
701
|
+
var FileReadStream = ReadStream;
|
|
702
|
+
Object.defineProperty(fs3, "FileReadStream", {
|
|
703
|
+
get: /* @__PURE__ */ __name(function() {
|
|
704
|
+
return FileReadStream;
|
|
705
|
+
}, "get"),
|
|
706
|
+
set: /* @__PURE__ */ __name(function(val) {
|
|
707
|
+
FileReadStream = val;
|
|
708
|
+
}, "set"),
|
|
709
|
+
enumerable: true,
|
|
710
|
+
configurable: true
|
|
711
|
+
});
|
|
712
|
+
var FileWriteStream = WriteStream;
|
|
713
|
+
Object.defineProperty(fs3, "FileWriteStream", {
|
|
714
|
+
get: /* @__PURE__ */ __name(function() {
|
|
715
|
+
return FileWriteStream;
|
|
716
|
+
}, "get"),
|
|
717
|
+
set: /* @__PURE__ */ __name(function(val) {
|
|
718
|
+
FileWriteStream = val;
|
|
719
|
+
}, "set"),
|
|
720
|
+
enumerable: true,
|
|
721
|
+
configurable: true
|
|
722
|
+
});
|
|
723
|
+
function ReadStream(path2, options) {
|
|
724
|
+
if (this instanceof ReadStream)
|
|
725
|
+
return fs$ReadStream.apply(this, arguments), this;
|
|
726
|
+
else
|
|
727
|
+
return ReadStream.apply(Object.create(ReadStream.prototype), arguments);
|
|
728
|
+
}
|
|
729
|
+
__name(ReadStream, "ReadStream");
|
|
730
|
+
function ReadStream$open() {
|
|
731
|
+
var that = this;
|
|
732
|
+
open(that.path, that.flags, that.mode, function(err, fd) {
|
|
733
|
+
if (err) {
|
|
734
|
+
if (that.autoClose)
|
|
735
|
+
that.destroy();
|
|
736
|
+
that.emit("error", err);
|
|
737
|
+
} else {
|
|
738
|
+
that.fd = fd;
|
|
739
|
+
that.emit("open", fd);
|
|
740
|
+
that.read();
|
|
741
|
+
}
|
|
742
|
+
});
|
|
743
|
+
}
|
|
744
|
+
__name(ReadStream$open, "ReadStream$open");
|
|
745
|
+
function WriteStream(path2, options) {
|
|
746
|
+
if (this instanceof WriteStream)
|
|
747
|
+
return fs$WriteStream.apply(this, arguments), this;
|
|
748
|
+
else
|
|
749
|
+
return WriteStream.apply(Object.create(WriteStream.prototype), arguments);
|
|
750
|
+
}
|
|
751
|
+
__name(WriteStream, "WriteStream");
|
|
752
|
+
function WriteStream$open() {
|
|
753
|
+
var that = this;
|
|
754
|
+
open(that.path, that.flags, that.mode, function(err, fd) {
|
|
755
|
+
if (err) {
|
|
756
|
+
that.destroy();
|
|
757
|
+
that.emit("error", err);
|
|
758
|
+
} else {
|
|
759
|
+
that.fd = fd;
|
|
760
|
+
that.emit("open", fd);
|
|
761
|
+
}
|
|
762
|
+
});
|
|
763
|
+
}
|
|
764
|
+
__name(WriteStream$open, "WriteStream$open");
|
|
765
|
+
function createReadStream(path2, options) {
|
|
766
|
+
return new fs3.ReadStream(path2, options);
|
|
767
|
+
}
|
|
768
|
+
__name(createReadStream, "createReadStream");
|
|
769
|
+
function createWriteStream(path2, options) {
|
|
770
|
+
return new fs3.WriteStream(path2, options);
|
|
771
|
+
}
|
|
772
|
+
__name(createWriteStream, "createWriteStream");
|
|
773
|
+
var fs$open = fs3.open;
|
|
774
|
+
fs3.open = open;
|
|
775
|
+
function open(path2, flags, mode, cb) {
|
|
776
|
+
if (typeof mode === "function")
|
|
777
|
+
cb = mode, mode = null;
|
|
778
|
+
return go$open(path2, flags, mode, cb);
|
|
779
|
+
function go$open(path3, flags2, mode2, cb2, startTime) {
|
|
780
|
+
return fs$open(path3, flags2, mode2, function(err, fd) {
|
|
781
|
+
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
782
|
+
enqueue([go$open, [path3, flags2, mode2, cb2], err, startTime || Date.now(), Date.now()]);
|
|
783
|
+
else {
|
|
784
|
+
if (typeof cb2 === "function")
|
|
785
|
+
cb2.apply(this, arguments);
|
|
786
|
+
}
|
|
787
|
+
});
|
|
788
|
+
}
|
|
789
|
+
__name(go$open, "go$open");
|
|
790
|
+
}
|
|
791
|
+
__name(open, "open");
|
|
792
|
+
return fs3;
|
|
793
|
+
}
|
|
794
|
+
__name(patch, "patch");
|
|
795
|
+
function enqueue(elem) {
|
|
796
|
+
debug("ENQUEUE", elem[0].name, elem[1]);
|
|
797
|
+
fs2[gracefulQueue].push(elem);
|
|
798
|
+
retry();
|
|
799
|
+
}
|
|
800
|
+
__name(enqueue, "enqueue");
|
|
801
|
+
var retryTimer;
|
|
802
|
+
function resetQueue() {
|
|
803
|
+
var now = Date.now();
|
|
804
|
+
for (var i = 0; i < fs2[gracefulQueue].length; ++i) {
|
|
805
|
+
if (fs2[gracefulQueue][i].length > 2) {
|
|
806
|
+
fs2[gracefulQueue][i][3] = now;
|
|
807
|
+
fs2[gracefulQueue][i][4] = now;
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
retry();
|
|
811
|
+
}
|
|
812
|
+
__name(resetQueue, "resetQueue");
|
|
813
|
+
function retry() {
|
|
814
|
+
clearTimeout(retryTimer);
|
|
815
|
+
retryTimer = void 0;
|
|
816
|
+
if (fs2[gracefulQueue].length === 0)
|
|
817
|
+
return;
|
|
818
|
+
var elem = fs2[gracefulQueue].shift();
|
|
819
|
+
var fn = elem[0];
|
|
820
|
+
var args = elem[1];
|
|
821
|
+
var err = elem[2];
|
|
822
|
+
var startTime = elem[3];
|
|
823
|
+
var lastTime = elem[4];
|
|
824
|
+
if (startTime === void 0) {
|
|
825
|
+
debug("RETRY", fn.name, args);
|
|
826
|
+
fn.apply(null, args);
|
|
827
|
+
} else if (Date.now() - startTime >= 6e4) {
|
|
828
|
+
debug("TIMEOUT", fn.name, args);
|
|
829
|
+
var cb = args.pop();
|
|
830
|
+
if (typeof cb === "function")
|
|
831
|
+
cb.call(null, err);
|
|
832
|
+
} else {
|
|
833
|
+
var sinceAttempt = Date.now() - lastTime;
|
|
834
|
+
var sinceStart = Math.max(lastTime - startTime, 1);
|
|
835
|
+
var desiredDelay = Math.min(sinceStart * 1.2, 100);
|
|
836
|
+
if (sinceAttempt >= desiredDelay) {
|
|
837
|
+
debug("RETRY", fn.name, args);
|
|
838
|
+
fn.apply(null, args.concat([startTime]));
|
|
839
|
+
} else {
|
|
840
|
+
fs2[gracefulQueue].push(elem);
|
|
841
|
+
}
|
|
842
|
+
}
|
|
843
|
+
if (retryTimer === void 0) {
|
|
844
|
+
retryTimer = setTimeout(retry, 0);
|
|
845
|
+
}
|
|
846
|
+
}
|
|
847
|
+
__name(retry, "retry");
|
|
848
|
+
}
|
|
849
|
+
});
|
|
850
|
+
|
|
851
|
+
// node_modules/proper-lockfile/node_modules/retry/lib/retry_operation.js
|
|
852
|
+
var require_retry_operation = __commonJS({
|
|
853
|
+
"node_modules/proper-lockfile/node_modules/retry/lib/retry_operation.js"(exports, module) {
|
|
854
|
+
init_esbuild_shims();
|
|
855
|
+
function RetryOperation(timeouts, options) {
|
|
856
|
+
if (typeof options === "boolean") {
|
|
857
|
+
options = { forever: options };
|
|
858
|
+
}
|
|
859
|
+
this._originalTimeouts = JSON.parse(JSON.stringify(timeouts));
|
|
860
|
+
this._timeouts = timeouts;
|
|
861
|
+
this._options = options || {};
|
|
862
|
+
this._maxRetryTime = options && options.maxRetryTime || Infinity;
|
|
863
|
+
this._fn = null;
|
|
864
|
+
this._errors = [];
|
|
865
|
+
this._attempts = 1;
|
|
866
|
+
this._operationTimeout = null;
|
|
867
|
+
this._operationTimeoutCb = null;
|
|
868
|
+
this._timeout = null;
|
|
869
|
+
this._operationStart = null;
|
|
870
|
+
if (this._options.forever) {
|
|
871
|
+
this._cachedTimeouts = this._timeouts.slice(0);
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
__name(RetryOperation, "RetryOperation");
|
|
875
|
+
module.exports = RetryOperation;
|
|
876
|
+
RetryOperation.prototype.reset = function() {
|
|
877
|
+
this._attempts = 1;
|
|
878
|
+
this._timeouts = this._originalTimeouts;
|
|
879
|
+
};
|
|
880
|
+
RetryOperation.prototype.stop = function() {
|
|
881
|
+
if (this._timeout) {
|
|
882
|
+
clearTimeout(this._timeout);
|
|
883
|
+
}
|
|
884
|
+
this._timeouts = [];
|
|
885
|
+
this._cachedTimeouts = null;
|
|
886
|
+
};
|
|
887
|
+
RetryOperation.prototype.retry = function(err) {
|
|
888
|
+
if (this._timeout) {
|
|
889
|
+
clearTimeout(this._timeout);
|
|
890
|
+
}
|
|
891
|
+
if (!err) {
|
|
892
|
+
return false;
|
|
893
|
+
}
|
|
894
|
+
var currentTime = (/* @__PURE__ */ new Date()).getTime();
|
|
895
|
+
if (err && currentTime - this._operationStart >= this._maxRetryTime) {
|
|
896
|
+
this._errors.unshift(new Error("RetryOperation timeout occurred"));
|
|
897
|
+
return false;
|
|
898
|
+
}
|
|
899
|
+
this._errors.push(err);
|
|
900
|
+
var timeout = this._timeouts.shift();
|
|
901
|
+
if (timeout === void 0) {
|
|
902
|
+
if (this._cachedTimeouts) {
|
|
903
|
+
this._errors.splice(this._errors.length - 1, this._errors.length);
|
|
904
|
+
this._timeouts = this._cachedTimeouts.slice(0);
|
|
905
|
+
timeout = this._timeouts.shift();
|
|
906
|
+
} else {
|
|
907
|
+
return false;
|
|
908
|
+
}
|
|
909
|
+
}
|
|
910
|
+
var self = this;
|
|
911
|
+
var timer = setTimeout(function() {
|
|
912
|
+
self._attempts++;
|
|
913
|
+
if (self._operationTimeoutCb) {
|
|
914
|
+
self._timeout = setTimeout(function() {
|
|
915
|
+
self._operationTimeoutCb(self._attempts);
|
|
916
|
+
}, self._operationTimeout);
|
|
917
|
+
if (self._options.unref) {
|
|
918
|
+
self._timeout.unref();
|
|
919
|
+
}
|
|
920
|
+
}
|
|
921
|
+
self._fn(self._attempts);
|
|
922
|
+
}, timeout);
|
|
923
|
+
if (this._options.unref) {
|
|
924
|
+
timer.unref();
|
|
925
|
+
}
|
|
926
|
+
return true;
|
|
927
|
+
};
|
|
928
|
+
RetryOperation.prototype.attempt = function(fn, timeoutOps) {
|
|
929
|
+
this._fn = fn;
|
|
930
|
+
if (timeoutOps) {
|
|
931
|
+
if (timeoutOps.timeout) {
|
|
932
|
+
this._operationTimeout = timeoutOps.timeout;
|
|
933
|
+
}
|
|
934
|
+
if (timeoutOps.cb) {
|
|
935
|
+
this._operationTimeoutCb = timeoutOps.cb;
|
|
936
|
+
}
|
|
937
|
+
}
|
|
938
|
+
var self = this;
|
|
939
|
+
if (this._operationTimeoutCb) {
|
|
940
|
+
this._timeout = setTimeout(function() {
|
|
941
|
+
self._operationTimeoutCb();
|
|
942
|
+
}, self._operationTimeout);
|
|
943
|
+
}
|
|
944
|
+
this._operationStart = (/* @__PURE__ */ new Date()).getTime();
|
|
945
|
+
this._fn(this._attempts);
|
|
946
|
+
};
|
|
947
|
+
RetryOperation.prototype.try = function(fn) {
|
|
948
|
+
console.log("Using RetryOperation.try() is deprecated");
|
|
949
|
+
this.attempt(fn);
|
|
950
|
+
};
|
|
951
|
+
RetryOperation.prototype.start = function(fn) {
|
|
952
|
+
console.log("Using RetryOperation.start() is deprecated");
|
|
953
|
+
this.attempt(fn);
|
|
954
|
+
};
|
|
955
|
+
RetryOperation.prototype.start = RetryOperation.prototype.try;
|
|
956
|
+
RetryOperation.prototype.errors = function() {
|
|
957
|
+
return this._errors;
|
|
958
|
+
};
|
|
959
|
+
RetryOperation.prototype.attempts = function() {
|
|
960
|
+
return this._attempts;
|
|
961
|
+
};
|
|
962
|
+
RetryOperation.prototype.mainError = function() {
|
|
963
|
+
if (this._errors.length === 0) {
|
|
964
|
+
return null;
|
|
965
|
+
}
|
|
966
|
+
var counts = {};
|
|
967
|
+
var mainError = null;
|
|
968
|
+
var mainErrorCount = 0;
|
|
969
|
+
for (var i = 0; i < this._errors.length; i++) {
|
|
970
|
+
var error = this._errors[i];
|
|
971
|
+
var message = error.message;
|
|
972
|
+
var count = (counts[message] || 0) + 1;
|
|
973
|
+
counts[message] = count;
|
|
974
|
+
if (count >= mainErrorCount) {
|
|
975
|
+
mainError = error;
|
|
976
|
+
mainErrorCount = count;
|
|
977
|
+
}
|
|
978
|
+
}
|
|
979
|
+
return mainError;
|
|
980
|
+
};
|
|
981
|
+
}
|
|
982
|
+
});
|
|
983
|
+
|
|
984
|
+
// node_modules/proper-lockfile/node_modules/retry/lib/retry.js
|
|
985
|
+
var require_retry = __commonJS({
|
|
986
|
+
"node_modules/proper-lockfile/node_modules/retry/lib/retry.js"(exports) {
|
|
987
|
+
init_esbuild_shims();
|
|
988
|
+
var RetryOperation = require_retry_operation();
|
|
989
|
+
exports.operation = function(options) {
|
|
990
|
+
var timeouts = exports.timeouts(options);
|
|
991
|
+
return new RetryOperation(timeouts, {
|
|
992
|
+
forever: options && options.forever,
|
|
993
|
+
unref: options && options.unref,
|
|
994
|
+
maxRetryTime: options && options.maxRetryTime
|
|
995
|
+
});
|
|
996
|
+
};
|
|
997
|
+
exports.timeouts = function(options) {
|
|
998
|
+
if (options instanceof Array) {
|
|
999
|
+
return [].concat(options);
|
|
1000
|
+
}
|
|
1001
|
+
var opts = {
|
|
1002
|
+
retries: 10,
|
|
1003
|
+
factor: 2,
|
|
1004
|
+
minTimeout: 1 * 1e3,
|
|
1005
|
+
maxTimeout: Infinity,
|
|
1006
|
+
randomize: false
|
|
1007
|
+
};
|
|
1008
|
+
for (var key in options) {
|
|
1009
|
+
opts[key] = options[key];
|
|
1010
|
+
}
|
|
1011
|
+
if (opts.minTimeout > opts.maxTimeout) {
|
|
1012
|
+
throw new Error("minTimeout is greater than maxTimeout");
|
|
1013
|
+
}
|
|
1014
|
+
var timeouts = [];
|
|
1015
|
+
for (var i = 0; i < opts.retries; i++) {
|
|
1016
|
+
timeouts.push(this.createTimeout(i, opts));
|
|
1017
|
+
}
|
|
1018
|
+
if (options && options.forever && !timeouts.length) {
|
|
1019
|
+
timeouts.push(this.createTimeout(i, opts));
|
|
1020
|
+
}
|
|
1021
|
+
timeouts.sort(function(a, b) {
|
|
1022
|
+
return a - b;
|
|
1023
|
+
});
|
|
1024
|
+
return timeouts;
|
|
1025
|
+
};
|
|
1026
|
+
exports.createTimeout = function(attempt, opts) {
|
|
1027
|
+
var random = opts.randomize ? Math.random() + 1 : 1;
|
|
1028
|
+
var timeout = Math.round(random * opts.minTimeout * Math.pow(opts.factor, attempt));
|
|
1029
|
+
timeout = Math.min(timeout, opts.maxTimeout);
|
|
1030
|
+
return timeout;
|
|
1031
|
+
};
|
|
1032
|
+
exports.wrap = function(obj, options, methods) {
|
|
1033
|
+
if (options instanceof Array) {
|
|
1034
|
+
methods = options;
|
|
1035
|
+
options = null;
|
|
1036
|
+
}
|
|
1037
|
+
if (!methods) {
|
|
1038
|
+
methods = [];
|
|
1039
|
+
for (var key in obj) {
|
|
1040
|
+
if (typeof obj[key] === "function") {
|
|
1041
|
+
methods.push(key);
|
|
1042
|
+
}
|
|
1043
|
+
}
|
|
1044
|
+
}
|
|
1045
|
+
for (var i = 0; i < methods.length; i++) {
|
|
1046
|
+
var method = methods[i];
|
|
1047
|
+
var original = obj[method];
|
|
1048
|
+
obj[method] = (/* @__PURE__ */ __name(function retryWrapper(original2) {
|
|
1049
|
+
var op = exports.operation(options);
|
|
1050
|
+
var args = Array.prototype.slice.call(arguments, 1);
|
|
1051
|
+
var callback = args.pop();
|
|
1052
|
+
args.push(function(err) {
|
|
1053
|
+
if (op.retry(err)) {
|
|
1054
|
+
return;
|
|
1055
|
+
}
|
|
1056
|
+
if (err) {
|
|
1057
|
+
arguments[0] = op.mainError();
|
|
1058
|
+
}
|
|
1059
|
+
callback.apply(this, arguments);
|
|
1060
|
+
});
|
|
1061
|
+
op.attempt(function() {
|
|
1062
|
+
original2.apply(obj, args);
|
|
1063
|
+
});
|
|
1064
|
+
}, "retryWrapper")).bind(obj, original);
|
|
1065
|
+
obj[method].options = options;
|
|
1066
|
+
}
|
|
1067
|
+
};
|
|
1068
|
+
}
|
|
1069
|
+
});
|
|
1070
|
+
|
|
1071
|
+
// node_modules/proper-lockfile/node_modules/retry/index.js
|
|
1072
|
+
var require_retry2 = __commonJS({
|
|
1073
|
+
"node_modules/proper-lockfile/node_modules/retry/index.js"(exports, module) {
|
|
1074
|
+
init_esbuild_shims();
|
|
1075
|
+
module.exports = require_retry();
|
|
1076
|
+
}
|
|
1077
|
+
});
|
|
1078
|
+
|
|
1079
|
+
// node_modules/proper-lockfile/node_modules/signal-exit/signals.js
|
|
1080
|
+
var require_signals = __commonJS({
|
|
1081
|
+
"node_modules/proper-lockfile/node_modules/signal-exit/signals.js"(exports, module) {
|
|
1082
|
+
init_esbuild_shims();
|
|
1083
|
+
module.exports = [
|
|
1084
|
+
"SIGABRT",
|
|
1085
|
+
"SIGALRM",
|
|
1086
|
+
"SIGHUP",
|
|
1087
|
+
"SIGINT",
|
|
1088
|
+
"SIGTERM"
|
|
1089
|
+
];
|
|
1090
|
+
if (process.platform !== "win32") {
|
|
1091
|
+
module.exports.push(
|
|
1092
|
+
"SIGVTALRM",
|
|
1093
|
+
"SIGXCPU",
|
|
1094
|
+
"SIGXFSZ",
|
|
1095
|
+
"SIGUSR2",
|
|
1096
|
+
"SIGTRAP",
|
|
1097
|
+
"SIGSYS",
|
|
1098
|
+
"SIGQUIT",
|
|
1099
|
+
"SIGIOT"
|
|
1100
|
+
// should detect profiler and enable/disable accordingly.
|
|
1101
|
+
// see #21
|
|
1102
|
+
// 'SIGPROF'
|
|
1103
|
+
);
|
|
1104
|
+
}
|
|
1105
|
+
if (process.platform === "linux") {
|
|
1106
|
+
module.exports.push(
|
|
1107
|
+
"SIGIO",
|
|
1108
|
+
"SIGPOLL",
|
|
1109
|
+
"SIGPWR",
|
|
1110
|
+
"SIGSTKFLT",
|
|
1111
|
+
"SIGUNUSED"
|
|
1112
|
+
);
|
|
1113
|
+
}
|
|
1114
|
+
}
|
|
1115
|
+
});
|
|
1116
|
+
|
|
1117
|
+
// node_modules/proper-lockfile/node_modules/signal-exit/index.js
|
|
1118
|
+
var require_signal_exit = __commonJS({
|
|
1119
|
+
"node_modules/proper-lockfile/node_modules/signal-exit/index.js"(exports, module) {
|
|
1120
|
+
init_esbuild_shims();
|
|
1121
|
+
var process2 = globalThis.process;
|
|
1122
|
+
var processOk = /* @__PURE__ */ __name(function(process3) {
|
|
1123
|
+
return process3 && typeof process3 === "object" && typeof process3.removeListener === "function" && typeof process3.emit === "function" && typeof process3.reallyExit === "function" && typeof process3.listeners === "function" && typeof process3.kill === "function" && typeof process3.pid === "number" && typeof process3.on === "function";
|
|
1124
|
+
}, "processOk");
|
|
1125
|
+
if (!processOk(process2)) {
|
|
1126
|
+
module.exports = function() {
|
|
1127
|
+
return function() {
|
|
1128
|
+
};
|
|
1129
|
+
};
|
|
1130
|
+
} else {
|
|
1131
|
+
assert = __require("assert");
|
|
1132
|
+
signals = require_signals();
|
|
1133
|
+
isWin = /^win/i.test(process2.platform);
|
|
1134
|
+
EE = __require("events");
|
|
1135
|
+
if (typeof EE !== "function") {
|
|
1136
|
+
EE = EE.EventEmitter;
|
|
1137
|
+
}
|
|
1138
|
+
if (process2.__signal_exit_emitter__) {
|
|
1139
|
+
emitter = process2.__signal_exit_emitter__;
|
|
1140
|
+
} else {
|
|
1141
|
+
emitter = process2.__signal_exit_emitter__ = new EE();
|
|
1142
|
+
emitter.count = 0;
|
|
1143
|
+
emitter.emitted = {};
|
|
1144
|
+
}
|
|
1145
|
+
if (!emitter.infinite) {
|
|
1146
|
+
emitter.setMaxListeners(Infinity);
|
|
1147
|
+
emitter.infinite = true;
|
|
1148
|
+
}
|
|
1149
|
+
module.exports = function(cb, opts) {
|
|
1150
|
+
if (!processOk(globalThis.process)) {
|
|
1151
|
+
return function() {
|
|
1152
|
+
};
|
|
1153
|
+
}
|
|
1154
|
+
assert.equal(typeof cb, "function", "a callback must be provided for exit handler");
|
|
1155
|
+
if (loaded === false) {
|
|
1156
|
+
load();
|
|
1157
|
+
}
|
|
1158
|
+
var ev = "exit";
|
|
1159
|
+
if (opts && opts.alwaysLast) {
|
|
1160
|
+
ev = "afterexit";
|
|
1161
|
+
}
|
|
1162
|
+
var remove = /* @__PURE__ */ __name(function() {
|
|
1163
|
+
emitter.removeListener(ev, cb);
|
|
1164
|
+
if (emitter.listeners("exit").length === 0 && emitter.listeners("afterexit").length === 0) {
|
|
1165
|
+
unload();
|
|
1166
|
+
}
|
|
1167
|
+
}, "remove");
|
|
1168
|
+
emitter.on(ev, cb);
|
|
1169
|
+
return remove;
|
|
1170
|
+
};
|
|
1171
|
+
unload = /* @__PURE__ */ __name(function unload2() {
|
|
1172
|
+
if (!loaded || !processOk(globalThis.process)) {
|
|
1173
|
+
return;
|
|
1174
|
+
}
|
|
1175
|
+
loaded = false;
|
|
1176
|
+
signals.forEach(function(sig) {
|
|
1177
|
+
try {
|
|
1178
|
+
process2.removeListener(sig, sigListeners[sig]);
|
|
1179
|
+
} catch (er) {
|
|
1180
|
+
}
|
|
1181
|
+
});
|
|
1182
|
+
process2.emit = originalProcessEmit;
|
|
1183
|
+
process2.reallyExit = originalProcessReallyExit;
|
|
1184
|
+
emitter.count -= 1;
|
|
1185
|
+
}, "unload");
|
|
1186
|
+
module.exports.unload = unload;
|
|
1187
|
+
emit = /* @__PURE__ */ __name(function emit2(event, code, signal) {
|
|
1188
|
+
if (emitter.emitted[event]) {
|
|
1189
|
+
return;
|
|
1190
|
+
}
|
|
1191
|
+
emitter.emitted[event] = true;
|
|
1192
|
+
emitter.emit(event, code, signal);
|
|
1193
|
+
}, "emit");
|
|
1194
|
+
sigListeners = {};
|
|
1195
|
+
signals.forEach(function(sig) {
|
|
1196
|
+
sigListeners[sig] = /* @__PURE__ */ __name(function listener() {
|
|
1197
|
+
if (!processOk(globalThis.process)) {
|
|
1198
|
+
return;
|
|
1199
|
+
}
|
|
1200
|
+
var listeners = process2.listeners(sig);
|
|
1201
|
+
if (listeners.length === emitter.count) {
|
|
1202
|
+
unload();
|
|
1203
|
+
emit("exit", null, sig);
|
|
1204
|
+
emit("afterexit", null, sig);
|
|
1205
|
+
if (isWin && sig === "SIGHUP") {
|
|
1206
|
+
sig = "SIGINT";
|
|
1207
|
+
}
|
|
1208
|
+
process2.kill(process2.pid, sig);
|
|
1209
|
+
}
|
|
1210
|
+
}, "listener");
|
|
1211
|
+
});
|
|
1212
|
+
module.exports.signals = function() {
|
|
1213
|
+
return signals;
|
|
1214
|
+
};
|
|
1215
|
+
loaded = false;
|
|
1216
|
+
load = /* @__PURE__ */ __name(function load2() {
|
|
1217
|
+
if (loaded || !processOk(globalThis.process)) {
|
|
1218
|
+
return;
|
|
1219
|
+
}
|
|
1220
|
+
loaded = true;
|
|
1221
|
+
emitter.count += 1;
|
|
1222
|
+
signals = signals.filter(function(sig) {
|
|
1223
|
+
try {
|
|
1224
|
+
process2.on(sig, sigListeners[sig]);
|
|
1225
|
+
return true;
|
|
1226
|
+
} catch (er) {
|
|
1227
|
+
return false;
|
|
1228
|
+
}
|
|
1229
|
+
});
|
|
1230
|
+
process2.emit = processEmit;
|
|
1231
|
+
process2.reallyExit = processReallyExit;
|
|
1232
|
+
}, "load");
|
|
1233
|
+
module.exports.load = load;
|
|
1234
|
+
originalProcessReallyExit = process2.reallyExit;
|
|
1235
|
+
processReallyExit = /* @__PURE__ */ __name(function processReallyExit2(code) {
|
|
1236
|
+
if (!processOk(globalThis.process)) {
|
|
1237
|
+
return;
|
|
1238
|
+
}
|
|
1239
|
+
process2.exitCode = code || /* istanbul ignore next */
|
|
1240
|
+
0;
|
|
1241
|
+
emit("exit", process2.exitCode, null);
|
|
1242
|
+
emit("afterexit", process2.exitCode, null);
|
|
1243
|
+
originalProcessReallyExit.call(process2, process2.exitCode);
|
|
1244
|
+
}, "processReallyExit");
|
|
1245
|
+
originalProcessEmit = process2.emit;
|
|
1246
|
+
processEmit = /* @__PURE__ */ __name(function processEmit2(ev, arg) {
|
|
1247
|
+
if (ev === "exit" && processOk(globalThis.process)) {
|
|
1248
|
+
if (arg !== void 0) {
|
|
1249
|
+
process2.exitCode = arg;
|
|
1250
|
+
}
|
|
1251
|
+
var ret = originalProcessEmit.apply(this, arguments);
|
|
1252
|
+
emit("exit", process2.exitCode, null);
|
|
1253
|
+
emit("afterexit", process2.exitCode, null);
|
|
1254
|
+
return ret;
|
|
1255
|
+
} else {
|
|
1256
|
+
return originalProcessEmit.apply(this, arguments);
|
|
1257
|
+
}
|
|
1258
|
+
}, "processEmit");
|
|
1259
|
+
}
|
|
1260
|
+
var assert;
|
|
1261
|
+
var signals;
|
|
1262
|
+
var isWin;
|
|
1263
|
+
var EE;
|
|
1264
|
+
var emitter;
|
|
1265
|
+
var unload;
|
|
1266
|
+
var emit;
|
|
1267
|
+
var sigListeners;
|
|
1268
|
+
var loaded;
|
|
1269
|
+
var load;
|
|
1270
|
+
var originalProcessReallyExit;
|
|
1271
|
+
var processReallyExit;
|
|
1272
|
+
var originalProcessEmit;
|
|
1273
|
+
var processEmit;
|
|
1274
|
+
}
|
|
1275
|
+
});
|
|
1276
|
+
|
|
1277
|
+
// node_modules/proper-lockfile/lib/mtime-precision.js
|
|
1278
|
+
var require_mtime_precision = __commonJS({
|
|
1279
|
+
"node_modules/proper-lockfile/lib/mtime-precision.js"(exports, module) {
|
|
1280
|
+
"use strict";
|
|
1281
|
+
init_esbuild_shims();
|
|
1282
|
+
var cacheSymbol = Symbol();
|
|
1283
|
+
function probe(file, fs2, callback) {
|
|
1284
|
+
const cachedPrecision = fs2[cacheSymbol];
|
|
1285
|
+
if (cachedPrecision) {
|
|
1286
|
+
return fs2.stat(file, (err, stat) => {
|
|
1287
|
+
if (err) {
|
|
1288
|
+
return callback(err);
|
|
1289
|
+
}
|
|
1290
|
+
callback(null, stat.mtime, cachedPrecision);
|
|
1291
|
+
});
|
|
1292
|
+
}
|
|
1293
|
+
const mtime = new Date(Math.ceil(Date.now() / 1e3) * 1e3 + 5);
|
|
1294
|
+
fs2.utimes(file, mtime, mtime, (err) => {
|
|
1295
|
+
if (err) {
|
|
1296
|
+
return callback(err);
|
|
1297
|
+
}
|
|
1298
|
+
fs2.stat(file, (err2, stat) => {
|
|
1299
|
+
if (err2) {
|
|
1300
|
+
return callback(err2);
|
|
1301
|
+
}
|
|
1302
|
+
const precision = stat.mtime.getTime() % 1e3 === 0 ? "s" : "ms";
|
|
1303
|
+
Object.defineProperty(fs2, cacheSymbol, { value: precision });
|
|
1304
|
+
callback(null, stat.mtime, precision);
|
|
1305
|
+
});
|
|
1306
|
+
});
|
|
1307
|
+
}
|
|
1308
|
+
__name(probe, "probe");
|
|
1309
|
+
function getMtime(precision) {
|
|
1310
|
+
let now = Date.now();
|
|
1311
|
+
if (precision === "s") {
|
|
1312
|
+
now = Math.ceil(now / 1e3) * 1e3;
|
|
1313
|
+
}
|
|
1314
|
+
return new Date(now);
|
|
1315
|
+
}
|
|
1316
|
+
__name(getMtime, "getMtime");
|
|
1317
|
+
module.exports.probe = probe;
|
|
1318
|
+
module.exports.getMtime = getMtime;
|
|
1319
|
+
}
|
|
1320
|
+
});
|
|
1321
|
+
|
|
1322
|
+
// node_modules/proper-lockfile/lib/lockfile.js
|
|
1323
|
+
var require_lockfile = __commonJS({
|
|
1324
|
+
"node_modules/proper-lockfile/lib/lockfile.js"(exports, module) {
|
|
1325
|
+
"use strict";
|
|
1326
|
+
init_esbuild_shims();
|
|
1327
|
+
var path2 = __require("path");
|
|
1328
|
+
var fs2 = require_graceful_fs();
|
|
1329
|
+
var retry = require_retry2();
|
|
1330
|
+
var onExit = require_signal_exit();
|
|
1331
|
+
var mtimePrecision = require_mtime_precision();
|
|
1332
|
+
var locks = {};
|
|
1333
|
+
function getLockFile(file, options) {
|
|
1334
|
+
return options.lockfilePath || `${file}.lock`;
|
|
1335
|
+
}
|
|
1336
|
+
__name(getLockFile, "getLockFile");
|
|
1337
|
+
function resolveCanonicalPath(file, options, callback) {
|
|
1338
|
+
if (!options.realpath) {
|
|
1339
|
+
return callback(null, path2.resolve(file));
|
|
1340
|
+
}
|
|
1341
|
+
options.fs.realpath(file, callback);
|
|
1342
|
+
}
|
|
1343
|
+
__name(resolveCanonicalPath, "resolveCanonicalPath");
|
|
1344
|
+
function acquireLock(file, options, callback) {
|
|
1345
|
+
const lockfilePath = getLockFile(file, options);
|
|
1346
|
+
options.fs.mkdir(lockfilePath, (err) => {
|
|
1347
|
+
if (!err) {
|
|
1348
|
+
return mtimePrecision.probe(lockfilePath, options.fs, (err2, mtime, mtimePrecision2) => {
|
|
1349
|
+
if (err2) {
|
|
1350
|
+
options.fs.rmdir(lockfilePath, () => {
|
|
1351
|
+
});
|
|
1352
|
+
return callback(err2);
|
|
1353
|
+
}
|
|
1354
|
+
callback(null, mtime, mtimePrecision2);
|
|
1355
|
+
});
|
|
1356
|
+
}
|
|
1357
|
+
if (err.code !== "EEXIST") {
|
|
1358
|
+
return callback(err);
|
|
1359
|
+
}
|
|
1360
|
+
if (options.stale <= 0) {
|
|
1361
|
+
return callback(Object.assign(new Error("Lock file is already being held"), { code: "ELOCKED", file }));
|
|
1362
|
+
}
|
|
1363
|
+
options.fs.stat(lockfilePath, (err2, stat) => {
|
|
1364
|
+
if (err2) {
|
|
1365
|
+
if (err2.code === "ENOENT") {
|
|
1366
|
+
return acquireLock(file, { ...options, stale: 0 }, callback);
|
|
1367
|
+
}
|
|
1368
|
+
return callback(err2);
|
|
1369
|
+
}
|
|
1370
|
+
if (!isLockStale(stat, options)) {
|
|
1371
|
+
return callback(Object.assign(new Error("Lock file is already being held"), { code: "ELOCKED", file }));
|
|
1372
|
+
}
|
|
1373
|
+
removeLock(file, options, (err3) => {
|
|
1374
|
+
if (err3) {
|
|
1375
|
+
return callback(err3);
|
|
1376
|
+
}
|
|
1377
|
+
acquireLock(file, { ...options, stale: 0 }, callback);
|
|
1378
|
+
});
|
|
1379
|
+
});
|
|
1380
|
+
});
|
|
1381
|
+
}
|
|
1382
|
+
__name(acquireLock, "acquireLock");
|
|
1383
|
+
function isLockStale(stat, options) {
|
|
1384
|
+
return stat.mtime.getTime() < Date.now() - options.stale;
|
|
1385
|
+
}
|
|
1386
|
+
__name(isLockStale, "isLockStale");
|
|
1387
|
+
function removeLock(file, options, callback) {
|
|
1388
|
+
options.fs.rmdir(getLockFile(file, options), (err) => {
|
|
1389
|
+
if (err && err.code !== "ENOENT") {
|
|
1390
|
+
return callback(err);
|
|
1391
|
+
}
|
|
1392
|
+
callback();
|
|
1393
|
+
});
|
|
1394
|
+
}
|
|
1395
|
+
__name(removeLock, "removeLock");
|
|
1396
|
+
function updateLock(file, options) {
|
|
1397
|
+
const lock2 = locks[file];
|
|
1398
|
+
if (lock2.updateTimeout) {
|
|
1399
|
+
return;
|
|
1400
|
+
}
|
|
1401
|
+
lock2.updateDelay = lock2.updateDelay || options.update;
|
|
1402
|
+
lock2.updateTimeout = setTimeout(() => {
|
|
1403
|
+
lock2.updateTimeout = null;
|
|
1404
|
+
options.fs.stat(lock2.lockfilePath, (err, stat) => {
|
|
1405
|
+
const isOverThreshold = lock2.lastUpdate + options.stale < Date.now();
|
|
1406
|
+
if (err) {
|
|
1407
|
+
if (err.code === "ENOENT" || isOverThreshold) {
|
|
1408
|
+
return setLockAsCompromised(file, lock2, Object.assign(err, { code: "ECOMPROMISED" }));
|
|
1409
|
+
}
|
|
1410
|
+
lock2.updateDelay = 1e3;
|
|
1411
|
+
return updateLock(file, options);
|
|
1412
|
+
}
|
|
1413
|
+
const isMtimeOurs = lock2.mtime.getTime() === stat.mtime.getTime();
|
|
1414
|
+
if (!isMtimeOurs) {
|
|
1415
|
+
return setLockAsCompromised(
|
|
1416
|
+
file,
|
|
1417
|
+
lock2,
|
|
1418
|
+
Object.assign(
|
|
1419
|
+
new Error("Unable to update lock within the stale threshold"),
|
|
1420
|
+
{ code: "ECOMPROMISED" }
|
|
1421
|
+
)
|
|
1422
|
+
);
|
|
1423
|
+
}
|
|
1424
|
+
const mtime = mtimePrecision.getMtime(lock2.mtimePrecision);
|
|
1425
|
+
options.fs.utimes(lock2.lockfilePath, mtime, mtime, (err2) => {
|
|
1426
|
+
const isOverThreshold2 = lock2.lastUpdate + options.stale < Date.now();
|
|
1427
|
+
if (lock2.released) {
|
|
1428
|
+
return;
|
|
1429
|
+
}
|
|
1430
|
+
if (err2) {
|
|
1431
|
+
if (err2.code === "ENOENT" || isOverThreshold2) {
|
|
1432
|
+
return setLockAsCompromised(file, lock2, Object.assign(err2, { code: "ECOMPROMISED" }));
|
|
1433
|
+
}
|
|
1434
|
+
lock2.updateDelay = 1e3;
|
|
1435
|
+
return updateLock(file, options);
|
|
1436
|
+
}
|
|
1437
|
+
lock2.mtime = mtime;
|
|
1438
|
+
lock2.lastUpdate = Date.now();
|
|
1439
|
+
lock2.updateDelay = null;
|
|
1440
|
+
updateLock(file, options);
|
|
1441
|
+
});
|
|
1442
|
+
});
|
|
1443
|
+
}, lock2.updateDelay);
|
|
1444
|
+
if (lock2.updateTimeout.unref) {
|
|
1445
|
+
lock2.updateTimeout.unref();
|
|
1446
|
+
}
|
|
1447
|
+
}
|
|
1448
|
+
__name(updateLock, "updateLock");
|
|
1449
|
+
function setLockAsCompromised(file, lock2, err) {
|
|
1450
|
+
lock2.released = true;
|
|
1451
|
+
if (lock2.updateTimeout) {
|
|
1452
|
+
clearTimeout(lock2.updateTimeout);
|
|
1453
|
+
}
|
|
1454
|
+
if (locks[file] === lock2) {
|
|
1455
|
+
delete locks[file];
|
|
1456
|
+
}
|
|
1457
|
+
lock2.options.onCompromised(err);
|
|
1458
|
+
}
|
|
1459
|
+
__name(setLockAsCompromised, "setLockAsCompromised");
|
|
1460
|
+
function lock(file, options, callback) {
|
|
1461
|
+
options = {
|
|
1462
|
+
stale: 1e4,
|
|
1463
|
+
update: null,
|
|
1464
|
+
realpath: true,
|
|
1465
|
+
retries: 0,
|
|
1466
|
+
fs: fs2,
|
|
1467
|
+
onCompromised: /* @__PURE__ */ __name((err) => {
|
|
1468
|
+
throw err;
|
|
1469
|
+
}, "onCompromised"),
|
|
1470
|
+
...options
|
|
1471
|
+
};
|
|
1472
|
+
options.retries = options.retries || 0;
|
|
1473
|
+
options.retries = typeof options.retries === "number" ? { retries: options.retries } : options.retries;
|
|
1474
|
+
options.stale = Math.max(options.stale || 0, 2e3);
|
|
1475
|
+
options.update = options.update == null ? options.stale / 2 : options.update || 0;
|
|
1476
|
+
options.update = Math.max(Math.min(options.update, options.stale / 2), 1e3);
|
|
1477
|
+
resolveCanonicalPath(file, options, (err, file2) => {
|
|
1478
|
+
if (err) {
|
|
1479
|
+
return callback(err);
|
|
1480
|
+
}
|
|
1481
|
+
const operation = retry.operation(options.retries);
|
|
1482
|
+
operation.attempt(() => {
|
|
1483
|
+
acquireLock(file2, options, (err2, mtime, mtimePrecision2) => {
|
|
1484
|
+
if (operation.retry(err2)) {
|
|
1485
|
+
return;
|
|
1486
|
+
}
|
|
1487
|
+
if (err2) {
|
|
1488
|
+
return callback(operation.mainError());
|
|
1489
|
+
}
|
|
1490
|
+
const lock2 = locks[file2] = {
|
|
1491
|
+
lockfilePath: getLockFile(file2, options),
|
|
1492
|
+
mtime,
|
|
1493
|
+
mtimePrecision: mtimePrecision2,
|
|
1494
|
+
options,
|
|
1495
|
+
lastUpdate: Date.now()
|
|
1496
|
+
};
|
|
1497
|
+
updateLock(file2, options);
|
|
1498
|
+
callback(null, (releasedCallback) => {
|
|
1499
|
+
if (lock2.released) {
|
|
1500
|
+
return releasedCallback && releasedCallback(Object.assign(new Error("Lock is already released"), { code: "ERELEASED" }));
|
|
1501
|
+
}
|
|
1502
|
+
unlock(file2, { ...options, realpath: false }, releasedCallback);
|
|
1503
|
+
});
|
|
1504
|
+
});
|
|
1505
|
+
});
|
|
1506
|
+
});
|
|
1507
|
+
}
|
|
1508
|
+
__name(lock, "lock");
|
|
1509
|
+
function unlock(file, options, callback) {
|
|
1510
|
+
options = {
|
|
1511
|
+
fs: fs2,
|
|
1512
|
+
realpath: true,
|
|
1513
|
+
...options
|
|
1514
|
+
};
|
|
1515
|
+
resolveCanonicalPath(file, options, (err, file2) => {
|
|
1516
|
+
if (err) {
|
|
1517
|
+
return callback(err);
|
|
1518
|
+
}
|
|
1519
|
+
const lock2 = locks[file2];
|
|
1520
|
+
if (!lock2) {
|
|
1521
|
+
return callback(Object.assign(new Error("Lock is not acquired/owned by you"), { code: "ENOTACQUIRED" }));
|
|
1522
|
+
}
|
|
1523
|
+
lock2.updateTimeout && clearTimeout(lock2.updateTimeout);
|
|
1524
|
+
lock2.released = true;
|
|
1525
|
+
delete locks[file2];
|
|
1526
|
+
removeLock(file2, options, callback);
|
|
1527
|
+
});
|
|
1528
|
+
}
|
|
1529
|
+
__name(unlock, "unlock");
|
|
1530
|
+
function check(file, options, callback) {
|
|
1531
|
+
options = {
|
|
1532
|
+
stale: 1e4,
|
|
1533
|
+
realpath: true,
|
|
1534
|
+
fs: fs2,
|
|
1535
|
+
...options
|
|
1536
|
+
};
|
|
1537
|
+
options.stale = Math.max(options.stale || 0, 2e3);
|
|
1538
|
+
resolveCanonicalPath(file, options, (err, file2) => {
|
|
1539
|
+
if (err) {
|
|
1540
|
+
return callback(err);
|
|
1541
|
+
}
|
|
1542
|
+
options.fs.stat(getLockFile(file2, options), (err2, stat) => {
|
|
1543
|
+
if (err2) {
|
|
1544
|
+
return err2.code === "ENOENT" ? callback(null, false) : callback(err2);
|
|
1545
|
+
}
|
|
1546
|
+
return callback(null, !isLockStale(stat, options));
|
|
1547
|
+
});
|
|
1548
|
+
});
|
|
1549
|
+
}
|
|
1550
|
+
__name(check, "check");
|
|
1551
|
+
function getLocks() {
|
|
1552
|
+
return locks;
|
|
1553
|
+
}
|
|
1554
|
+
__name(getLocks, "getLocks");
|
|
1555
|
+
onExit(() => {
|
|
1556
|
+
for (const file in locks) {
|
|
1557
|
+
const options = locks[file].options;
|
|
1558
|
+
try {
|
|
1559
|
+
options.fs.rmdirSync(getLockFile(file, options));
|
|
1560
|
+
} catch (e) {
|
|
1561
|
+
}
|
|
1562
|
+
}
|
|
1563
|
+
});
|
|
1564
|
+
module.exports.lock = lock;
|
|
1565
|
+
module.exports.unlock = unlock;
|
|
1566
|
+
module.exports.check = check;
|
|
1567
|
+
module.exports.getLocks = getLocks;
|
|
1568
|
+
}
|
|
1569
|
+
});
|
|
1570
|
+
|
|
1571
|
+
// node_modules/proper-lockfile/lib/adapter.js
|
|
1572
|
+
var require_adapter = __commonJS({
|
|
1573
|
+
"node_modules/proper-lockfile/lib/adapter.js"(exports, module) {
|
|
1574
|
+
"use strict";
|
|
1575
|
+
init_esbuild_shims();
|
|
1576
|
+
var fs2 = require_graceful_fs();
|
|
1577
|
+
function createSyncFs(fs3) {
|
|
1578
|
+
const methods = ["mkdir", "realpath", "stat", "rmdir", "utimes"];
|
|
1579
|
+
const newFs = { ...fs3 };
|
|
1580
|
+
methods.forEach((method) => {
|
|
1581
|
+
newFs[method] = (...args) => {
|
|
1582
|
+
const callback = args.pop();
|
|
1583
|
+
let ret;
|
|
1584
|
+
try {
|
|
1585
|
+
ret = fs3[`${method}Sync`](...args);
|
|
1586
|
+
} catch (err) {
|
|
1587
|
+
return callback(err);
|
|
1588
|
+
}
|
|
1589
|
+
callback(null, ret);
|
|
1590
|
+
};
|
|
1591
|
+
});
|
|
1592
|
+
return newFs;
|
|
1593
|
+
}
|
|
1594
|
+
__name(createSyncFs, "createSyncFs");
|
|
1595
|
+
function toPromise(method) {
|
|
1596
|
+
return (...args) => new Promise((resolve, reject) => {
|
|
1597
|
+
args.push((err, result) => {
|
|
1598
|
+
if (err) {
|
|
1599
|
+
reject(err);
|
|
1600
|
+
} else {
|
|
1601
|
+
resolve(result);
|
|
1602
|
+
}
|
|
1603
|
+
});
|
|
1604
|
+
method(...args);
|
|
1605
|
+
});
|
|
1606
|
+
}
|
|
1607
|
+
__name(toPromise, "toPromise");
|
|
1608
|
+
function toSync(method) {
|
|
1609
|
+
return (...args) => {
|
|
1610
|
+
let err;
|
|
1611
|
+
let result;
|
|
1612
|
+
args.push((_err, _result) => {
|
|
1613
|
+
err = _err;
|
|
1614
|
+
result = _result;
|
|
1615
|
+
});
|
|
1616
|
+
method(...args);
|
|
1617
|
+
if (err) {
|
|
1618
|
+
throw err;
|
|
1619
|
+
}
|
|
1620
|
+
return result;
|
|
1621
|
+
};
|
|
1622
|
+
}
|
|
1623
|
+
__name(toSync, "toSync");
|
|
1624
|
+
function toSyncOptions(options) {
|
|
1625
|
+
options = { ...options };
|
|
1626
|
+
options.fs = createSyncFs(options.fs || fs2);
|
|
1627
|
+
if (typeof options.retries === "number" && options.retries > 0 || options.retries && typeof options.retries.retries === "number" && options.retries.retries > 0) {
|
|
1628
|
+
throw Object.assign(new Error("Cannot use retries with the sync api"), { code: "ESYNC" });
|
|
1629
|
+
}
|
|
1630
|
+
return options;
|
|
1631
|
+
}
|
|
1632
|
+
__name(toSyncOptions, "toSyncOptions");
|
|
1633
|
+
module.exports = {
|
|
1634
|
+
toPromise,
|
|
1635
|
+
toSync,
|
|
1636
|
+
toSyncOptions
|
|
1637
|
+
};
|
|
1638
|
+
}
|
|
1639
|
+
});
|
|
1640
|
+
|
|
1641
|
+
// node_modules/proper-lockfile/index.js
|
|
1642
|
+
var require_proper_lockfile = __commonJS({
|
|
1643
|
+
"node_modules/proper-lockfile/index.js"(exports, module) {
|
|
1644
|
+
"use strict";
|
|
1645
|
+
init_esbuild_shims();
|
|
1646
|
+
var lockfile = require_lockfile();
|
|
1647
|
+
var { toPromise, toSync, toSyncOptions } = require_adapter();
|
|
1648
|
+
async function lock(file, options) {
|
|
1649
|
+
const release = await toPromise(lockfile.lock)(file, options);
|
|
1650
|
+
return toPromise(release);
|
|
1651
|
+
}
|
|
1652
|
+
__name(lock, "lock");
|
|
1653
|
+
function lockSync(file, options) {
|
|
1654
|
+
const release = toSync(lockfile.lock)(file, toSyncOptions(options));
|
|
1655
|
+
return toSync(release);
|
|
1656
|
+
}
|
|
1657
|
+
__name(lockSync, "lockSync");
|
|
1658
|
+
function unlock(file, options) {
|
|
1659
|
+
return toPromise(lockfile.unlock)(file, options);
|
|
1660
|
+
}
|
|
1661
|
+
__name(unlock, "unlock");
|
|
1662
|
+
function unlockSync(file, options) {
|
|
1663
|
+
return toSync(lockfile.unlock)(file, toSyncOptions(options));
|
|
1664
|
+
}
|
|
1665
|
+
__name(unlockSync, "unlockSync");
|
|
1666
|
+
function check(file, options) {
|
|
1667
|
+
return toPromise(lockfile.check)(file, options);
|
|
1668
|
+
}
|
|
1669
|
+
__name(check, "check");
|
|
1670
|
+
function checkSync(file, options) {
|
|
1671
|
+
return toSync(lockfile.check)(file, toSyncOptions(options));
|
|
1672
|
+
}
|
|
1673
|
+
__name(checkSync, "checkSync");
|
|
1674
|
+
module.exports = lock;
|
|
1675
|
+
module.exports.lock = lock;
|
|
1676
|
+
module.exports.unlock = unlock;
|
|
1677
|
+
module.exports.lockSync = lockSync;
|
|
1678
|
+
module.exports.unlockSync = unlockSync;
|
|
1679
|
+
module.exports.check = check;
|
|
1680
|
+
module.exports.checkSync = checkSync;
|
|
1681
|
+
}
|
|
1682
|
+
});
|
|
1683
|
+
|
|
1684
|
+
// packages/core/src/agents/team/teamHelpers.ts
|
|
1685
|
+
init_esbuild_shims();
|
|
1686
|
+
import * as fs from "node:fs/promises";
|
|
1687
|
+
import * as path from "node:path";
|
|
1688
|
+
function getTeamsRootDir() {
|
|
1689
|
+
return path.join(Storage.getGlobalQwenDir(), TEAMS_DIR);
|
|
1690
|
+
}
|
|
1691
|
+
__name(getTeamsRootDir, "getTeamsRootDir");
|
|
1692
|
+
function getTeamDir(teamName) {
|
|
1693
|
+
return path.join(getTeamsRootDir(), teamName);
|
|
1694
|
+
}
|
|
1695
|
+
__name(getTeamDir, "getTeamDir");
|
|
1696
|
+
function getTeamFilePath(teamName) {
|
|
1697
|
+
return path.join(getTeamDir(teamName), TEAM_CONFIG_FILENAME);
|
|
1698
|
+
}
|
|
1699
|
+
__name(getTeamFilePath, "getTeamFilePath");
|
|
1700
|
+
function getInboxesDir(teamName) {
|
|
1701
|
+
return path.join(getTeamDir(teamName), INBOXES_DIR);
|
|
1702
|
+
}
|
|
1703
|
+
__name(getInboxesDir, "getInboxesDir");
|
|
1704
|
+
function getTasksDir(teamName) {
|
|
1705
|
+
return path.join(Storage.getGlobalQwenDir(), TASKS_DIR, teamName);
|
|
1706
|
+
}
|
|
1707
|
+
__name(getTasksDir, "getTasksDir");
|
|
1708
|
+
function sanitizeName(name) {
|
|
1709
|
+
return name.toLowerCase().replace(/[^a-z0-9-]/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
|
|
1710
|
+
}
|
|
1711
|
+
__name(sanitizeName, "sanitizeName");
|
|
1712
|
+
function formatAgentId(name, teamName) {
|
|
1713
|
+
return `${sanitizeName(name)}@${sanitizeName(teamName)}`;
|
|
1714
|
+
}
|
|
1715
|
+
__name(formatAgentId, "formatAgentId");
|
|
1716
|
+
function generateUniqueTeammateName(baseName, existingMembers) {
|
|
1717
|
+
const sanitized = sanitizeName(baseName);
|
|
1718
|
+
if (!sanitized) {
|
|
1719
|
+
throw new Error(
|
|
1720
|
+
`Teammate name "${baseName}" sanitizes to an empty string. Choose a name with at least one alphanumeric character.`
|
|
1721
|
+
);
|
|
1722
|
+
}
|
|
1723
|
+
if (sanitized === LEADER_NAME) {
|
|
1724
|
+
throw new Error(
|
|
1725
|
+
`"${LEADER_NAME}" is reserved for the team leader. Choose a different teammate name.`
|
|
1726
|
+
);
|
|
1727
|
+
}
|
|
1728
|
+
const existingNames = new Set(existingMembers.map((m) => m.name));
|
|
1729
|
+
if (existingNames.has(sanitized)) {
|
|
1730
|
+
const existingList = [...existingNames].join(", ") || "<none>";
|
|
1731
|
+
throw new Error(
|
|
1732
|
+
`A teammate named "${sanitized}" already exists in this team (existing: ${existingList}). Choose a different name.`
|
|
1733
|
+
);
|
|
1734
|
+
}
|
|
1735
|
+
return sanitized;
|
|
1736
|
+
}
|
|
1737
|
+
__name(generateUniqueTeammateName, "generateUniqueTeammateName");
|
|
1738
|
+
function assignTeammateColor(existingMembers) {
|
|
1739
|
+
const usedColors = new Set(
|
|
1740
|
+
existingMembers.map((m) => m.color).filter((c) => c !== void 0)
|
|
1741
|
+
);
|
|
1742
|
+
for (const color of TEAMMATE_COLORS) {
|
|
1743
|
+
if (!usedColors.has(color)) {
|
|
1744
|
+
return color;
|
|
1745
|
+
}
|
|
1746
|
+
}
|
|
1747
|
+
return TEAMMATE_COLORS[existingMembers.length % TEAMMATE_COLORS.length];
|
|
1748
|
+
}
|
|
1749
|
+
__name(assignTeammateColor, "assignTeammateColor");
|
|
1750
|
+
function clearTeammateColors(members) {
|
|
1751
|
+
return members.map((m) => {
|
|
1752
|
+
const { color: _, ...rest } = m;
|
|
1753
|
+
return rest;
|
|
1754
|
+
});
|
|
1755
|
+
}
|
|
1756
|
+
__name(clearTeammateColors, "clearTeammateColors");
|
|
1757
|
+
function setMemberActive(members, agentId, isActive) {
|
|
1758
|
+
return members.map((m) => m.agentId === agentId ? { ...m, isActive } : m);
|
|
1759
|
+
}
|
|
1760
|
+
__name(setMemberActive, "setMemberActive");
|
|
1761
|
+
function findMemberById(members, agentId) {
|
|
1762
|
+
return members.find((m) => m.agentId === agentId);
|
|
1763
|
+
}
|
|
1764
|
+
__name(findMemberById, "findMemberById");
|
|
1765
|
+
function findMemberByName(members, name) {
|
|
1766
|
+
const sanitized = sanitizeName(name);
|
|
1767
|
+
return members.find((m) => m.name === sanitized);
|
|
1768
|
+
}
|
|
1769
|
+
__name(findMemberByName, "findMemberByName");
|
|
1770
|
+
function classifyShutdownResponse(message) {
|
|
1771
|
+
const trimmed = message.trimStart();
|
|
1772
|
+
if (/^shutdown_approved\b/i.test(trimmed)) return "shutdown_approved";
|
|
1773
|
+
if (/^shutdown_rejected\b/i.test(trimmed)) return "shutdown_rejected";
|
|
1774
|
+
return void 0;
|
|
1775
|
+
}
|
|
1776
|
+
__name(classifyShutdownResponse, "classifyShutdownResponse");
|
|
1777
|
+
async function readTeamFile(teamName) {
|
|
1778
|
+
const filePath = getTeamFilePath(teamName);
|
|
1779
|
+
try {
|
|
1780
|
+
const raw = await fs.readFile(filePath, "utf-8");
|
|
1781
|
+
return JSON.parse(raw);
|
|
1782
|
+
} catch (err) {
|
|
1783
|
+
if (isNodeError(err) && err.code === "ENOENT") {
|
|
1784
|
+
return void 0;
|
|
1785
|
+
}
|
|
1786
|
+
throw err;
|
|
1787
|
+
}
|
|
1788
|
+
}
|
|
1789
|
+
__name(readTeamFile, "readTeamFile");
|
|
1790
|
+
async function writeTeamFile(teamName, teamFile) {
|
|
1791
|
+
const filePath = getTeamFilePath(teamName);
|
|
1792
|
+
await fs.mkdir(path.dirname(filePath), { recursive: true });
|
|
1793
|
+
await atomicWriteJSON(filePath, teamFile);
|
|
1794
|
+
}
|
|
1795
|
+
__name(writeTeamFile, "writeTeamFile");
|
|
1796
|
+
async function createTeamFile(teamName, teamFile) {
|
|
1797
|
+
const filePath = getTeamFilePath(teamName);
|
|
1798
|
+
await fs.mkdir(path.dirname(filePath), { recursive: true });
|
|
1799
|
+
await fs.writeFile(filePath, JSON.stringify(teamFile, null, 2) + "\n", {
|
|
1800
|
+
encoding: "utf-8",
|
|
1801
|
+
flag: "wx"
|
|
1802
|
+
});
|
|
1803
|
+
}
|
|
1804
|
+
__name(createTeamFile, "createTeamFile");
|
|
1805
|
+
function isPidAlive(pid) {
|
|
1806
|
+
try {
|
|
1807
|
+
process.kill(pid, 0);
|
|
1808
|
+
return true;
|
|
1809
|
+
} catch (err) {
|
|
1810
|
+
return isNodeError(err) && err.code === "EPERM";
|
|
1811
|
+
}
|
|
1812
|
+
}
|
|
1813
|
+
__name(isPidAlive, "isPidAlive");
|
|
1814
|
+
async function tryReclaimStaleTeam(teamName) {
|
|
1815
|
+
let existing;
|
|
1816
|
+
try {
|
|
1817
|
+
existing = await readTeamFile(teamName);
|
|
1818
|
+
} catch {
|
|
1819
|
+
return false;
|
|
1820
|
+
}
|
|
1821
|
+
if (!existing) {
|
|
1822
|
+
await deleteTeamDirs(teamName);
|
|
1823
|
+
return true;
|
|
1824
|
+
}
|
|
1825
|
+
if (typeof existing.leadPid !== "number" || existing.leadPid <= 0) {
|
|
1826
|
+
return false;
|
|
1827
|
+
}
|
|
1828
|
+
if (existing.leadPid !== process.pid && isPidAlive(existing.leadPid)) {
|
|
1829
|
+
return false;
|
|
1830
|
+
}
|
|
1831
|
+
await deleteTeamDirs(teamName);
|
|
1832
|
+
return true;
|
|
1833
|
+
}
|
|
1834
|
+
__name(tryReclaimStaleTeam, "tryReclaimStaleTeam");
|
|
1835
|
+
async function deleteTeamDirs(teamName) {
|
|
1836
|
+
const teamDir = getTeamDir(teamName);
|
|
1837
|
+
const tasksDir = getTasksDir(teamName);
|
|
1838
|
+
await Promise.allSettled([
|
|
1839
|
+
fs.rm(teamDir, { recursive: true, force: true }),
|
|
1840
|
+
fs.rm(tasksDir, { recursive: true, force: true })
|
|
1841
|
+
]);
|
|
1842
|
+
}
|
|
1843
|
+
__name(deleteTeamDirs, "deleteTeamDirs");
|
|
1844
|
+
async function listTeamNames() {
|
|
1845
|
+
const teamsRoot = getTeamsRootDir();
|
|
1846
|
+
try {
|
|
1847
|
+
const entries = await fs.readdir(teamsRoot, {
|
|
1848
|
+
withFileTypes: true
|
|
1849
|
+
});
|
|
1850
|
+
return entries.filter((e) => e.isDirectory()).map((e) => e.name);
|
|
1851
|
+
} catch {
|
|
1852
|
+
return [];
|
|
1853
|
+
}
|
|
1854
|
+
}
|
|
1855
|
+
__name(listTeamNames, "listTeamNames");
|
|
1856
|
+
|
|
1857
|
+
// node_modules/async-mutex/index.mjs
|
|
1858
|
+
init_esbuild_shims();
|
|
1859
|
+
var E_TIMEOUT = new Error("timeout while waiting for mutex to become available");
|
|
1860
|
+
var E_ALREADY_LOCKED = new Error("mutex already locked");
|
|
1861
|
+
var E_CANCELED = new Error("request for lock canceled");
|
|
1862
|
+
var __awaiter$2 = function(thisArg, _arguments, P, generator) {
|
|
1863
|
+
function adopt(value) {
|
|
1864
|
+
return value instanceof P ? value : new P(function(resolve) {
|
|
1865
|
+
resolve(value);
|
|
1866
|
+
});
|
|
1867
|
+
}
|
|
1868
|
+
__name(adopt, "adopt");
|
|
1869
|
+
return new (P || (P = Promise))(function(resolve, reject) {
|
|
1870
|
+
function fulfilled(value) {
|
|
1871
|
+
try {
|
|
1872
|
+
step(generator.next(value));
|
|
1873
|
+
} catch (e) {
|
|
1874
|
+
reject(e);
|
|
1875
|
+
}
|
|
1876
|
+
}
|
|
1877
|
+
__name(fulfilled, "fulfilled");
|
|
1878
|
+
function rejected(value) {
|
|
1879
|
+
try {
|
|
1880
|
+
step(generator["throw"](value));
|
|
1881
|
+
} catch (e) {
|
|
1882
|
+
reject(e);
|
|
1883
|
+
}
|
|
1884
|
+
}
|
|
1885
|
+
__name(rejected, "rejected");
|
|
1886
|
+
function step(result) {
|
|
1887
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
1888
|
+
}
|
|
1889
|
+
__name(step, "step");
|
|
1890
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
1891
|
+
});
|
|
1892
|
+
};
|
|
1893
|
+
var Semaphore = class {
|
|
1894
|
+
static {
|
|
1895
|
+
__name(this, "Semaphore");
|
|
1896
|
+
}
|
|
1897
|
+
constructor(_value, _cancelError = E_CANCELED) {
|
|
1898
|
+
this._value = _value;
|
|
1899
|
+
this._cancelError = _cancelError;
|
|
1900
|
+
this._queue = [];
|
|
1901
|
+
this._weightedWaiters = [];
|
|
1902
|
+
}
|
|
1903
|
+
acquire(weight = 1, priority = 0) {
|
|
1904
|
+
if (weight <= 0)
|
|
1905
|
+
throw new Error(`invalid weight ${weight}: must be positive`);
|
|
1906
|
+
return new Promise((resolve, reject) => {
|
|
1907
|
+
const task = { resolve, reject, weight, priority };
|
|
1908
|
+
const i = findIndexFromEnd(this._queue, (other) => priority <= other.priority);
|
|
1909
|
+
if (i === -1 && weight <= this._value) {
|
|
1910
|
+
this._dispatchItem(task);
|
|
1911
|
+
} else {
|
|
1912
|
+
this._queue.splice(i + 1, 0, task);
|
|
1913
|
+
}
|
|
1914
|
+
});
|
|
1915
|
+
}
|
|
1916
|
+
runExclusive(callback_1) {
|
|
1917
|
+
return __awaiter$2(this, arguments, void 0, function* (callback, weight = 1, priority = 0) {
|
|
1918
|
+
const [value, release] = yield this.acquire(weight, priority);
|
|
1919
|
+
try {
|
|
1920
|
+
return yield callback(value);
|
|
1921
|
+
} finally {
|
|
1922
|
+
release();
|
|
1923
|
+
}
|
|
1924
|
+
});
|
|
1925
|
+
}
|
|
1926
|
+
waitForUnlock(weight = 1, priority = 0) {
|
|
1927
|
+
if (weight <= 0)
|
|
1928
|
+
throw new Error(`invalid weight ${weight}: must be positive`);
|
|
1929
|
+
if (this._couldLockImmediately(weight, priority)) {
|
|
1930
|
+
return Promise.resolve();
|
|
1931
|
+
} else {
|
|
1932
|
+
return new Promise((resolve) => {
|
|
1933
|
+
if (!this._weightedWaiters[weight - 1])
|
|
1934
|
+
this._weightedWaiters[weight - 1] = [];
|
|
1935
|
+
insertSorted(this._weightedWaiters[weight - 1], { resolve, priority });
|
|
1936
|
+
});
|
|
1937
|
+
}
|
|
1938
|
+
}
|
|
1939
|
+
isLocked() {
|
|
1940
|
+
return this._value <= 0;
|
|
1941
|
+
}
|
|
1942
|
+
getValue() {
|
|
1943
|
+
return this._value;
|
|
1944
|
+
}
|
|
1945
|
+
setValue(value) {
|
|
1946
|
+
this._value = value;
|
|
1947
|
+
this._dispatchQueue();
|
|
1948
|
+
}
|
|
1949
|
+
release(weight = 1) {
|
|
1950
|
+
if (weight <= 0)
|
|
1951
|
+
throw new Error(`invalid weight ${weight}: must be positive`);
|
|
1952
|
+
this._value += weight;
|
|
1953
|
+
this._dispatchQueue();
|
|
1954
|
+
}
|
|
1955
|
+
cancel() {
|
|
1956
|
+
this._queue.forEach((entry) => entry.reject(this._cancelError));
|
|
1957
|
+
this._queue = [];
|
|
1958
|
+
}
|
|
1959
|
+
_dispatchQueue() {
|
|
1960
|
+
this._drainUnlockWaiters();
|
|
1961
|
+
while (this._queue.length > 0 && this._queue[0].weight <= this._value) {
|
|
1962
|
+
this._dispatchItem(this._queue.shift());
|
|
1963
|
+
this._drainUnlockWaiters();
|
|
1964
|
+
}
|
|
1965
|
+
}
|
|
1966
|
+
_dispatchItem(item) {
|
|
1967
|
+
const previousValue = this._value;
|
|
1968
|
+
this._value -= item.weight;
|
|
1969
|
+
item.resolve([previousValue, this._newReleaser(item.weight)]);
|
|
1970
|
+
}
|
|
1971
|
+
_newReleaser(weight) {
|
|
1972
|
+
let called = false;
|
|
1973
|
+
return () => {
|
|
1974
|
+
if (called)
|
|
1975
|
+
return;
|
|
1976
|
+
called = true;
|
|
1977
|
+
this.release(weight);
|
|
1978
|
+
};
|
|
1979
|
+
}
|
|
1980
|
+
_drainUnlockWaiters() {
|
|
1981
|
+
if (this._queue.length === 0) {
|
|
1982
|
+
for (let weight = this._value; weight > 0; weight--) {
|
|
1983
|
+
const waiters = this._weightedWaiters[weight - 1];
|
|
1984
|
+
if (!waiters)
|
|
1985
|
+
continue;
|
|
1986
|
+
waiters.forEach((waiter) => waiter.resolve());
|
|
1987
|
+
this._weightedWaiters[weight - 1] = [];
|
|
1988
|
+
}
|
|
1989
|
+
} else {
|
|
1990
|
+
const queuedPriority = this._queue[0].priority;
|
|
1991
|
+
for (let weight = this._value; weight > 0; weight--) {
|
|
1992
|
+
const waiters = this._weightedWaiters[weight - 1];
|
|
1993
|
+
if (!waiters)
|
|
1994
|
+
continue;
|
|
1995
|
+
const i = waiters.findIndex((waiter) => waiter.priority <= queuedPriority);
|
|
1996
|
+
(i === -1 ? waiters : waiters.splice(0, i)).forEach((waiter) => waiter.resolve());
|
|
1997
|
+
}
|
|
1998
|
+
}
|
|
1999
|
+
}
|
|
2000
|
+
_couldLockImmediately(weight, priority) {
|
|
2001
|
+
return (this._queue.length === 0 || this._queue[0].priority < priority) && weight <= this._value;
|
|
2002
|
+
}
|
|
2003
|
+
};
|
|
2004
|
+
function insertSorted(a, v) {
|
|
2005
|
+
const i = findIndexFromEnd(a, (other) => v.priority <= other.priority);
|
|
2006
|
+
a.splice(i + 1, 0, v);
|
|
2007
|
+
}
|
|
2008
|
+
__name(insertSorted, "insertSorted");
|
|
2009
|
+
function findIndexFromEnd(a, predicate) {
|
|
2010
|
+
for (let i = a.length - 1; i >= 0; i--) {
|
|
2011
|
+
if (predicate(a[i])) {
|
|
2012
|
+
return i;
|
|
2013
|
+
}
|
|
2014
|
+
}
|
|
2015
|
+
return -1;
|
|
2016
|
+
}
|
|
2017
|
+
__name(findIndexFromEnd, "findIndexFromEnd");
|
|
2018
|
+
var __awaiter$1 = function(thisArg, _arguments, P, generator) {
|
|
2019
|
+
function adopt(value) {
|
|
2020
|
+
return value instanceof P ? value : new P(function(resolve) {
|
|
2021
|
+
resolve(value);
|
|
2022
|
+
});
|
|
2023
|
+
}
|
|
2024
|
+
__name(adopt, "adopt");
|
|
2025
|
+
return new (P || (P = Promise))(function(resolve, reject) {
|
|
2026
|
+
function fulfilled(value) {
|
|
2027
|
+
try {
|
|
2028
|
+
step(generator.next(value));
|
|
2029
|
+
} catch (e) {
|
|
2030
|
+
reject(e);
|
|
2031
|
+
}
|
|
2032
|
+
}
|
|
2033
|
+
__name(fulfilled, "fulfilled");
|
|
2034
|
+
function rejected(value) {
|
|
2035
|
+
try {
|
|
2036
|
+
step(generator["throw"](value));
|
|
2037
|
+
} catch (e) {
|
|
2038
|
+
reject(e);
|
|
2039
|
+
}
|
|
2040
|
+
}
|
|
2041
|
+
__name(rejected, "rejected");
|
|
2042
|
+
function step(result) {
|
|
2043
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
2044
|
+
}
|
|
2045
|
+
__name(step, "step");
|
|
2046
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
2047
|
+
});
|
|
2048
|
+
};
|
|
2049
|
+
var Mutex = class {
|
|
2050
|
+
static {
|
|
2051
|
+
__name(this, "Mutex");
|
|
2052
|
+
}
|
|
2053
|
+
constructor(cancelError) {
|
|
2054
|
+
this._semaphore = new Semaphore(1, cancelError);
|
|
2055
|
+
}
|
|
2056
|
+
acquire() {
|
|
2057
|
+
return __awaiter$1(this, arguments, void 0, function* (priority = 0) {
|
|
2058
|
+
const [, releaser] = yield this._semaphore.acquire(1, priority);
|
|
2059
|
+
return releaser;
|
|
2060
|
+
});
|
|
2061
|
+
}
|
|
2062
|
+
runExclusive(callback, priority = 0) {
|
|
2063
|
+
return this._semaphore.runExclusive(() => callback(), 1, priority);
|
|
2064
|
+
}
|
|
2065
|
+
isLocked() {
|
|
2066
|
+
return this._semaphore.isLocked();
|
|
2067
|
+
}
|
|
2068
|
+
waitForUnlock(priority = 0) {
|
|
2069
|
+
return this._semaphore.waitForUnlock(1, priority);
|
|
2070
|
+
}
|
|
2071
|
+
release() {
|
|
2072
|
+
if (this._semaphore.isLocked())
|
|
2073
|
+
this._semaphore.release();
|
|
2074
|
+
}
|
|
2075
|
+
cancel() {
|
|
2076
|
+
return this._semaphore.cancel();
|
|
2077
|
+
}
|
|
2078
|
+
};
|
|
2079
|
+
var __awaiter = function(thisArg, _arguments, P, generator) {
|
|
2080
|
+
function adopt(value) {
|
|
2081
|
+
return value instanceof P ? value : new P(function(resolve) {
|
|
2082
|
+
resolve(value);
|
|
2083
|
+
});
|
|
2084
|
+
}
|
|
2085
|
+
__name(adopt, "adopt");
|
|
2086
|
+
return new (P || (P = Promise))(function(resolve, reject) {
|
|
2087
|
+
function fulfilled(value) {
|
|
2088
|
+
try {
|
|
2089
|
+
step(generator.next(value));
|
|
2090
|
+
} catch (e) {
|
|
2091
|
+
reject(e);
|
|
2092
|
+
}
|
|
2093
|
+
}
|
|
2094
|
+
__name(fulfilled, "fulfilled");
|
|
2095
|
+
function rejected(value) {
|
|
2096
|
+
try {
|
|
2097
|
+
step(generator["throw"](value));
|
|
2098
|
+
} catch (e) {
|
|
2099
|
+
reject(e);
|
|
2100
|
+
}
|
|
2101
|
+
}
|
|
2102
|
+
__name(rejected, "rejected");
|
|
2103
|
+
function step(result) {
|
|
2104
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
2105
|
+
}
|
|
2106
|
+
__name(step, "step");
|
|
2107
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
2108
|
+
});
|
|
2109
|
+
};
|
|
2110
|
+
function withTimeout(sync, timeout, timeoutError = E_TIMEOUT) {
|
|
2111
|
+
return {
|
|
2112
|
+
acquire: /* @__PURE__ */ __name((weightOrPriority, priority) => {
|
|
2113
|
+
let weight;
|
|
2114
|
+
if (isSemaphore(sync)) {
|
|
2115
|
+
weight = weightOrPriority;
|
|
2116
|
+
} else {
|
|
2117
|
+
weight = void 0;
|
|
2118
|
+
priority = weightOrPriority;
|
|
2119
|
+
}
|
|
2120
|
+
if (weight !== void 0 && weight <= 0) {
|
|
2121
|
+
throw new Error(`invalid weight ${weight}: must be positive`);
|
|
2122
|
+
}
|
|
2123
|
+
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
|
2124
|
+
let isTimeout = false;
|
|
2125
|
+
const handle = setTimeout(() => {
|
|
2126
|
+
isTimeout = true;
|
|
2127
|
+
reject(timeoutError);
|
|
2128
|
+
}, timeout);
|
|
2129
|
+
try {
|
|
2130
|
+
const ticket = yield isSemaphore(sync) ? sync.acquire(weight, priority) : sync.acquire(priority);
|
|
2131
|
+
if (isTimeout) {
|
|
2132
|
+
const release = Array.isArray(ticket) ? ticket[1] : ticket;
|
|
2133
|
+
release();
|
|
2134
|
+
} else {
|
|
2135
|
+
clearTimeout(handle);
|
|
2136
|
+
resolve(ticket);
|
|
2137
|
+
}
|
|
2138
|
+
} catch (e) {
|
|
2139
|
+
if (!isTimeout) {
|
|
2140
|
+
clearTimeout(handle);
|
|
2141
|
+
reject(e);
|
|
2142
|
+
}
|
|
2143
|
+
}
|
|
2144
|
+
}));
|
|
2145
|
+
}, "acquire"),
|
|
2146
|
+
runExclusive(callback, weight, priority) {
|
|
2147
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2148
|
+
let release = /* @__PURE__ */ __name(() => void 0, "release");
|
|
2149
|
+
try {
|
|
2150
|
+
const ticket = yield this.acquire(weight, priority);
|
|
2151
|
+
if (Array.isArray(ticket)) {
|
|
2152
|
+
release = ticket[1];
|
|
2153
|
+
return yield callback(ticket[0]);
|
|
2154
|
+
} else {
|
|
2155
|
+
release = ticket;
|
|
2156
|
+
return yield callback();
|
|
2157
|
+
}
|
|
2158
|
+
} finally {
|
|
2159
|
+
release();
|
|
2160
|
+
}
|
|
2161
|
+
});
|
|
2162
|
+
},
|
|
2163
|
+
release(weight) {
|
|
2164
|
+
sync.release(weight);
|
|
2165
|
+
},
|
|
2166
|
+
cancel() {
|
|
2167
|
+
return sync.cancel();
|
|
2168
|
+
},
|
|
2169
|
+
waitForUnlock: /* @__PURE__ */ __name((weightOrPriority, priority) => {
|
|
2170
|
+
let weight;
|
|
2171
|
+
if (isSemaphore(sync)) {
|
|
2172
|
+
weight = weightOrPriority;
|
|
2173
|
+
} else {
|
|
2174
|
+
weight = void 0;
|
|
2175
|
+
priority = weightOrPriority;
|
|
2176
|
+
}
|
|
2177
|
+
if (weight !== void 0 && weight <= 0) {
|
|
2178
|
+
throw new Error(`invalid weight ${weight}: must be positive`);
|
|
2179
|
+
}
|
|
2180
|
+
return new Promise((resolve, reject) => {
|
|
2181
|
+
const handle = setTimeout(() => reject(timeoutError), timeout);
|
|
2182
|
+
(isSemaphore(sync) ? sync.waitForUnlock(weight, priority) : sync.waitForUnlock(priority)).then(() => {
|
|
2183
|
+
clearTimeout(handle);
|
|
2184
|
+
resolve();
|
|
2185
|
+
});
|
|
2186
|
+
});
|
|
2187
|
+
}, "waitForUnlock"),
|
|
2188
|
+
isLocked: /* @__PURE__ */ __name(() => sync.isLocked(), "isLocked"),
|
|
2189
|
+
getValue: /* @__PURE__ */ __name(() => sync.getValue(), "getValue"),
|
|
2190
|
+
setValue: /* @__PURE__ */ __name((value) => sync.setValue(value), "setValue")
|
|
2191
|
+
};
|
|
2192
|
+
}
|
|
2193
|
+
__name(withTimeout, "withTimeout");
|
|
2194
|
+
function isSemaphore(sync) {
|
|
2195
|
+
return sync.getValue !== void 0;
|
|
2196
|
+
}
|
|
2197
|
+
__name(isSemaphore, "isSemaphore");
|
|
2198
|
+
|
|
2199
|
+
export {
|
|
2200
|
+
E_TIMEOUT,
|
|
2201
|
+
Mutex,
|
|
2202
|
+
withTimeout,
|
|
2203
|
+
getTeamsRootDir,
|
|
2204
|
+
getTeamDir,
|
|
2205
|
+
getTeamFilePath,
|
|
2206
|
+
getInboxesDir,
|
|
2207
|
+
getTasksDir,
|
|
2208
|
+
sanitizeName,
|
|
2209
|
+
formatAgentId,
|
|
2210
|
+
generateUniqueTeammateName,
|
|
2211
|
+
assignTeammateColor,
|
|
2212
|
+
clearTeammateColors,
|
|
2213
|
+
setMemberActive,
|
|
2214
|
+
findMemberById,
|
|
2215
|
+
findMemberByName,
|
|
2216
|
+
classifyShutdownResponse,
|
|
2217
|
+
readTeamFile,
|
|
2218
|
+
writeTeamFile,
|
|
2219
|
+
createTeamFile,
|
|
2220
|
+
tryReclaimStaleTeam,
|
|
2221
|
+
deleteTeamDirs,
|
|
2222
|
+
listTeamNames,
|
|
2223
|
+
require_graceful_fs,
|
|
2224
|
+
require_proper_lockfile
|
|
2225
|
+
};
|
|
2226
|
+
/**
|
|
2227
|
+
* @license
|
|
2228
|
+
* Copyright 2025 Qwen
|
|
2229
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
2230
|
+
*/
|