adhdev 0.6.72 → 0.6.75
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/index.js +2107 -315
- package/dist/cli/index.js.map +1 -1
- package/dist/index.js +2037 -221
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -517,8 +517,8 @@ async function detectIDEs() {
|
|
|
517
517
|
if ((0, import_fs2.existsSync)(bundledCli)) resolvedCli = bundledCli;
|
|
518
518
|
}
|
|
519
519
|
if (!resolvedCli && appPath && os18 === "win32") {
|
|
520
|
-
const { dirname:
|
|
521
|
-
const appDir =
|
|
520
|
+
const { dirname: dirname8 } = await import("path");
|
|
521
|
+
const appDir = dirname8(appPath);
|
|
522
522
|
const candidates = [
|
|
523
523
|
`${appDir}\\\\bin\\\\${def.cli}.cmd`,
|
|
524
524
|
`${appDir}\\\\bin\\\\${def.cli}`,
|
|
@@ -561,15 +561,15 @@ var init_ide_detector = __esm({
|
|
|
561
561
|
|
|
562
562
|
// ../../oss/packages/daemon-core/src/detection/cli-detector.ts
|
|
563
563
|
function execAsync(cmd, timeoutMs = 5e3) {
|
|
564
|
-
return new Promise((
|
|
564
|
+
return new Promise((resolve10) => {
|
|
565
565
|
const child = (0, import_child_process2.exec)(cmd, { encoding: "utf-8", timeout: timeoutMs }, (err, stdout) => {
|
|
566
566
|
if (err || !stdout?.trim()) {
|
|
567
|
-
|
|
567
|
+
resolve10(null);
|
|
568
568
|
} else {
|
|
569
|
-
|
|
569
|
+
resolve10(stdout.trim());
|
|
570
570
|
}
|
|
571
571
|
});
|
|
572
|
-
child.on("error", () =>
|
|
572
|
+
child.on("error", () => resolve10(null));
|
|
573
573
|
});
|
|
574
574
|
}
|
|
575
575
|
async function detectCLIs(providerLoader) {
|
|
@@ -693,8 +693,8 @@ function cleanOldLogs() {
|
|
|
693
693
|
}
|
|
694
694
|
function rotateSizeIfNeeded() {
|
|
695
695
|
try {
|
|
696
|
-
const
|
|
697
|
-
if (
|
|
696
|
+
const stat4 = fs2.statSync(currentLogFile);
|
|
697
|
+
if (stat4.size > MAX_LOG_SIZE) {
|
|
698
698
|
const backup = currentLogFile.replace(".log", ".1.log");
|
|
699
699
|
try {
|
|
700
700
|
fs2.unlinkSync(backup);
|
|
@@ -823,8 +823,8 @@ var init_logger = __esm({
|
|
|
823
823
|
try {
|
|
824
824
|
const oldLog = path3.join(LOG_DIR, "daemon.log");
|
|
825
825
|
if (fs2.existsSync(oldLog)) {
|
|
826
|
-
const
|
|
827
|
-
const oldDate =
|
|
826
|
+
const stat4 = fs2.statSync(oldLog);
|
|
827
|
+
const oldDate = stat4.mtime.toISOString().slice(0, 10);
|
|
828
828
|
fs2.renameSync(oldLog, path3.join(LOG_DIR, `daemon-${oldDate}.log`));
|
|
829
829
|
}
|
|
830
830
|
const oldLogBackup = path3.join(LOG_DIR, "daemon.log.old");
|
|
@@ -948,7 +948,7 @@ var init_manager = __esm({
|
|
|
948
948
|
* Returns multiple entries if multiple IDE windows are open on same port
|
|
949
949
|
*/
|
|
950
950
|
static listAllTargets(port) {
|
|
951
|
-
return new Promise((
|
|
951
|
+
return new Promise((resolve10) => {
|
|
952
952
|
const req = http.get(`http://127.0.0.1:${port}/json`, (res) => {
|
|
953
953
|
let data = "";
|
|
954
954
|
res.on("data", (chunk) => data += chunk.toString());
|
|
@@ -964,16 +964,16 @@ var init_manager = __esm({
|
|
|
964
964
|
(t) => !isNonMain(t.title || "") && t.url?.includes("workbench.html") && !t.url?.includes("agent")
|
|
965
965
|
);
|
|
966
966
|
const fallbackPages = pages.filter((t) => !isNonMain(t.title || ""));
|
|
967
|
-
|
|
967
|
+
resolve10(mainPages.length > 0 ? mainPages : fallbackPages);
|
|
968
968
|
} catch {
|
|
969
|
-
|
|
969
|
+
resolve10([]);
|
|
970
970
|
}
|
|
971
971
|
});
|
|
972
972
|
});
|
|
973
|
-
req.on("error", () =>
|
|
973
|
+
req.on("error", () => resolve10([]));
|
|
974
974
|
req.setTimeout(2e3, () => {
|
|
975
975
|
req.destroy();
|
|
976
|
-
|
|
976
|
+
resolve10([]);
|
|
977
977
|
});
|
|
978
978
|
});
|
|
979
979
|
}
|
|
@@ -1013,7 +1013,7 @@ var init_manager = __esm({
|
|
|
1013
1013
|
}
|
|
1014
1014
|
}
|
|
1015
1015
|
findTargetOnPort(port) {
|
|
1016
|
-
return new Promise((
|
|
1016
|
+
return new Promise((resolve10) => {
|
|
1017
1017
|
const req = http.get(`http://127.0.0.1:${port}/json`, (res) => {
|
|
1018
1018
|
let data = "";
|
|
1019
1019
|
res.on("data", (chunk) => data += chunk.toString());
|
|
@@ -1024,7 +1024,7 @@ var init_manager = __esm({
|
|
|
1024
1024
|
(t) => (t.type === "page" || t.type === "browser" || t.type === "Page") && t.webSocketDebuggerUrl
|
|
1025
1025
|
);
|
|
1026
1026
|
if (pages.length === 0) {
|
|
1027
|
-
|
|
1027
|
+
resolve10(targets.find((t) => t.webSocketDebuggerUrl) || null);
|
|
1028
1028
|
return;
|
|
1029
1029
|
}
|
|
1030
1030
|
const mainPages = pages.filter((t) => !this.isNonMainTitle(t.title || ""));
|
|
@@ -1034,24 +1034,24 @@ var init_manager = __esm({
|
|
|
1034
1034
|
const specific = list.find((t) => t.id === this._targetId);
|
|
1035
1035
|
if (specific) {
|
|
1036
1036
|
this._pageTitle = specific.title || "";
|
|
1037
|
-
|
|
1037
|
+
resolve10(specific);
|
|
1038
1038
|
} else {
|
|
1039
1039
|
this.log(`[CDP] Target ${this._targetId} not found in page list`);
|
|
1040
|
-
|
|
1040
|
+
resolve10(null);
|
|
1041
1041
|
}
|
|
1042
1042
|
return;
|
|
1043
1043
|
}
|
|
1044
1044
|
this._pageTitle = list[0]?.title || "";
|
|
1045
|
-
|
|
1045
|
+
resolve10(list[0]);
|
|
1046
1046
|
} catch {
|
|
1047
|
-
|
|
1047
|
+
resolve10(null);
|
|
1048
1048
|
}
|
|
1049
1049
|
});
|
|
1050
1050
|
});
|
|
1051
|
-
req.on("error", () =>
|
|
1051
|
+
req.on("error", () => resolve10(null));
|
|
1052
1052
|
req.setTimeout(2e3, () => {
|
|
1053
1053
|
req.destroy();
|
|
1054
|
-
|
|
1054
|
+
resolve10(null);
|
|
1055
1055
|
});
|
|
1056
1056
|
});
|
|
1057
1057
|
}
|
|
@@ -1062,7 +1062,7 @@ var init_manager = __esm({
|
|
|
1062
1062
|
this.extensionProviders = providers;
|
|
1063
1063
|
}
|
|
1064
1064
|
connectToTarget(wsUrl) {
|
|
1065
|
-
return new Promise((
|
|
1065
|
+
return new Promise((resolve10) => {
|
|
1066
1066
|
this.ws = new import_ws.default(wsUrl);
|
|
1067
1067
|
this.ws.on("open", async () => {
|
|
1068
1068
|
this._connected = true;
|
|
@@ -1072,17 +1072,17 @@ var init_manager = __esm({
|
|
|
1072
1072
|
}
|
|
1073
1073
|
this.connectBrowserWs().catch(() => {
|
|
1074
1074
|
});
|
|
1075
|
-
|
|
1075
|
+
resolve10(true);
|
|
1076
1076
|
});
|
|
1077
1077
|
this.ws.on("message", (data) => {
|
|
1078
1078
|
try {
|
|
1079
1079
|
const msg = JSON.parse(data.toString());
|
|
1080
1080
|
if (msg.id && this.pending.has(msg.id)) {
|
|
1081
|
-
const { resolve:
|
|
1081
|
+
const { resolve: resolve11, reject } = this.pending.get(msg.id);
|
|
1082
1082
|
this.pending.delete(msg.id);
|
|
1083
1083
|
this.failureCount = 0;
|
|
1084
1084
|
if (msg.error) reject(new Error(msg.error.message));
|
|
1085
|
-
else
|
|
1085
|
+
else resolve11(msg.result);
|
|
1086
1086
|
} else if (msg.method === "Runtime.executionContextCreated") {
|
|
1087
1087
|
this.contexts.add(msg.params.context.id);
|
|
1088
1088
|
} else if (msg.method === "Runtime.executionContextDestroyed") {
|
|
@@ -1105,7 +1105,7 @@ var init_manager = __esm({
|
|
|
1105
1105
|
this.ws.on("error", (err) => {
|
|
1106
1106
|
this.log(`[CDP] WebSocket error: ${err.message}`);
|
|
1107
1107
|
this._connected = false;
|
|
1108
|
-
|
|
1108
|
+
resolve10(false);
|
|
1109
1109
|
});
|
|
1110
1110
|
});
|
|
1111
1111
|
}
|
|
@@ -1119,7 +1119,7 @@ var init_manager = __esm({
|
|
|
1119
1119
|
return;
|
|
1120
1120
|
}
|
|
1121
1121
|
this.log(`[CDP] Connecting browser WS for target discovery...`);
|
|
1122
|
-
await new Promise((
|
|
1122
|
+
await new Promise((resolve10, reject) => {
|
|
1123
1123
|
this.browserWs = new import_ws.default(browserWsUrl);
|
|
1124
1124
|
this.browserWs.on("open", async () => {
|
|
1125
1125
|
this._browserConnected = true;
|
|
@@ -1129,16 +1129,16 @@ var init_manager = __esm({
|
|
|
1129
1129
|
} catch (e) {
|
|
1130
1130
|
this.log(`[CDP] setDiscoverTargets failed: ${e.message}`);
|
|
1131
1131
|
}
|
|
1132
|
-
|
|
1132
|
+
resolve10();
|
|
1133
1133
|
});
|
|
1134
1134
|
this.browserWs.on("message", (data) => {
|
|
1135
1135
|
try {
|
|
1136
1136
|
const msg = JSON.parse(data.toString());
|
|
1137
1137
|
if (msg.id && this.browserPending.has(msg.id)) {
|
|
1138
|
-
const { resolve:
|
|
1138
|
+
const { resolve: resolve11, reject: reject2 } = this.browserPending.get(msg.id);
|
|
1139
1139
|
this.browserPending.delete(msg.id);
|
|
1140
1140
|
if (msg.error) reject2(new Error(msg.error.message));
|
|
1141
|
-
else
|
|
1141
|
+
else resolve11(msg.result);
|
|
1142
1142
|
}
|
|
1143
1143
|
} catch {
|
|
1144
1144
|
}
|
|
@@ -1158,31 +1158,31 @@ var init_manager = __esm({
|
|
|
1158
1158
|
}
|
|
1159
1159
|
}
|
|
1160
1160
|
getBrowserWsUrl() {
|
|
1161
|
-
return new Promise((
|
|
1161
|
+
return new Promise((resolve10) => {
|
|
1162
1162
|
const req = http.get(`http://127.0.0.1:${this.port}/json/version`, (res) => {
|
|
1163
1163
|
let data = "";
|
|
1164
1164
|
res.on("data", (chunk) => data += chunk.toString());
|
|
1165
1165
|
res.on("end", () => {
|
|
1166
1166
|
try {
|
|
1167
1167
|
const info = JSON.parse(data);
|
|
1168
|
-
|
|
1168
|
+
resolve10(info.webSocketDebuggerUrl || null);
|
|
1169
1169
|
} catch {
|
|
1170
|
-
|
|
1170
|
+
resolve10(null);
|
|
1171
1171
|
}
|
|
1172
1172
|
});
|
|
1173
1173
|
});
|
|
1174
|
-
req.on("error", () =>
|
|
1174
|
+
req.on("error", () => resolve10(null));
|
|
1175
1175
|
req.setTimeout(3e3, () => {
|
|
1176
1176
|
req.destroy();
|
|
1177
|
-
|
|
1177
|
+
resolve10(null);
|
|
1178
1178
|
});
|
|
1179
1179
|
});
|
|
1180
1180
|
}
|
|
1181
1181
|
sendBrowser(method, params = {}, timeoutMs = 15e3) {
|
|
1182
|
-
return new Promise((
|
|
1182
|
+
return new Promise((resolve10, reject) => {
|
|
1183
1183
|
if (!this.browserWs || !this._browserConnected) return reject(new Error("Browser WS not connected"));
|
|
1184
1184
|
const id = this.browserMsgId++;
|
|
1185
|
-
this.browserPending.set(id, { resolve:
|
|
1185
|
+
this.browserPending.set(id, { resolve: resolve10, reject });
|
|
1186
1186
|
this.browserWs.send(JSON.stringify({ id, method, params }));
|
|
1187
1187
|
setTimeout(() => {
|
|
1188
1188
|
if (this.browserPending.has(id)) {
|
|
@@ -1222,11 +1222,11 @@ var init_manager = __esm({
|
|
|
1222
1222
|
}
|
|
1223
1223
|
// ─── CDP Protocol ────────────────────────────────────────
|
|
1224
1224
|
sendInternal(method, params = {}, timeoutMs = 15e3) {
|
|
1225
|
-
return new Promise((
|
|
1225
|
+
return new Promise((resolve10, reject) => {
|
|
1226
1226
|
if (!this.ws || !this._connected) return reject(new Error("CDP not connected"));
|
|
1227
1227
|
if (this.ws.readyState !== import_ws.default.OPEN) return reject(new Error("WebSocket not open"));
|
|
1228
1228
|
const id = this.msgId++;
|
|
1229
|
-
this.pending.set(id, { resolve:
|
|
1229
|
+
this.pending.set(id, { resolve: resolve10, reject });
|
|
1230
1230
|
this.ws.send(JSON.stringify({ id, method, params }));
|
|
1231
1231
|
setTimeout(() => {
|
|
1232
1232
|
if (this.pending.has(id)) {
|
|
@@ -1475,7 +1475,7 @@ var init_manager = __esm({
|
|
|
1475
1475
|
const browserWs = this.browserWs;
|
|
1476
1476
|
let msgId = this.browserMsgId;
|
|
1477
1477
|
const sendWs = (method, params = {}, sessionId) => {
|
|
1478
|
-
return new Promise((
|
|
1478
|
+
return new Promise((resolve10, reject) => {
|
|
1479
1479
|
const mid = msgId++;
|
|
1480
1480
|
this.browserMsgId = msgId;
|
|
1481
1481
|
const handler = (raw) => {
|
|
@@ -1484,7 +1484,7 @@ var init_manager = __esm({
|
|
|
1484
1484
|
if (msg.id === mid) {
|
|
1485
1485
|
browserWs.removeListener("message", handler);
|
|
1486
1486
|
if (msg.error) reject(new Error(msg.error.message || JSON.stringify(msg.error)));
|
|
1487
|
-
else
|
|
1487
|
+
else resolve10(msg.result);
|
|
1488
1488
|
}
|
|
1489
1489
|
} catch {
|
|
1490
1490
|
}
|
|
@@ -1666,14 +1666,14 @@ var init_manager = __esm({
|
|
|
1666
1666
|
if (!ws2 || ws2.readyState !== import_ws.default.OPEN) {
|
|
1667
1667
|
throw new Error("CDP not connected");
|
|
1668
1668
|
}
|
|
1669
|
-
return new Promise((
|
|
1669
|
+
return new Promise((resolve10, reject) => {
|
|
1670
1670
|
const id = getNextId();
|
|
1671
1671
|
pendingMap.set(id, {
|
|
1672
1672
|
resolve: (result) => {
|
|
1673
1673
|
if (result?.result?.subtype === "error") {
|
|
1674
1674
|
reject(new Error(result.result.description));
|
|
1675
1675
|
} else {
|
|
1676
|
-
|
|
1676
|
+
resolve10(result?.result?.value);
|
|
1677
1677
|
}
|
|
1678
1678
|
},
|
|
1679
1679
|
reject
|
|
@@ -1705,10 +1705,10 @@ var init_manager = __esm({
|
|
|
1705
1705
|
throw new Error("CDP not connected");
|
|
1706
1706
|
}
|
|
1707
1707
|
const sendViaSession = (method, params = {}) => {
|
|
1708
|
-
return new Promise((
|
|
1708
|
+
return new Promise((resolve10, reject) => {
|
|
1709
1709
|
const pendingMap = this._browserConnected ? this.browserPending : this.pending;
|
|
1710
1710
|
const id = this._browserConnected ? this.browserMsgId++ : this.msgId++;
|
|
1711
|
-
pendingMap.set(id, { resolve:
|
|
1711
|
+
pendingMap.set(id, { resolve: resolve10, reject });
|
|
1712
1712
|
ws2.send(JSON.stringify({ id, sessionId, method, params }));
|
|
1713
1713
|
setTimeout(() => {
|
|
1714
1714
|
if (pendingMap.has(id)) {
|
|
@@ -2524,8 +2524,8 @@ ${next}`;
|
|
|
2524
2524
|
const files = fs3.readdirSync(dirPath).filter((f) => f.endsWith(".jsonl") || f.endsWith(".terminal.log"));
|
|
2525
2525
|
for (const file2 of files) {
|
|
2526
2526
|
const filePath = path4.join(dirPath, file2);
|
|
2527
|
-
const
|
|
2528
|
-
if (
|
|
2527
|
+
const stat4 = fs3.statSync(filePath);
|
|
2528
|
+
if (stat4.mtimeMs < cutoff) {
|
|
2529
2529
|
fs3.unlinkSync(filePath);
|
|
2530
2530
|
}
|
|
2531
2531
|
}
|
|
@@ -5048,7 +5048,7 @@ var init_handler = __esm({
|
|
|
5048
5048
|
try {
|
|
5049
5049
|
const http3 = await import("http");
|
|
5050
5050
|
const postData = JSON.stringify(body);
|
|
5051
|
-
const result = await new Promise((
|
|
5051
|
+
const result = await new Promise((resolve10, reject) => {
|
|
5052
5052
|
const req = http3.request({
|
|
5053
5053
|
hostname: "127.0.0.1",
|
|
5054
5054
|
port: 19280,
|
|
@@ -5060,9 +5060,9 @@ var init_handler = __esm({
|
|
|
5060
5060
|
res.on("data", (chunk) => data += chunk);
|
|
5061
5061
|
res.on("end", () => {
|
|
5062
5062
|
try {
|
|
5063
|
-
|
|
5063
|
+
resolve10(JSON.parse(data));
|
|
5064
5064
|
} catch {
|
|
5065
|
-
|
|
5065
|
+
resolve10({ raw: data });
|
|
5066
5066
|
}
|
|
5067
5067
|
});
|
|
5068
5068
|
});
|
|
@@ -5080,15 +5080,15 @@ var init_handler = __esm({
|
|
|
5080
5080
|
if (!providerType) return { success: false, error: "providerType required" };
|
|
5081
5081
|
try {
|
|
5082
5082
|
const http3 = await import("http");
|
|
5083
|
-
const result = await new Promise((
|
|
5083
|
+
const result = await new Promise((resolve10, reject) => {
|
|
5084
5084
|
http3.get(`http://127.0.0.1:19280/api/providers/${providerType}/${endpoint}`, (res) => {
|
|
5085
5085
|
let data = "";
|
|
5086
5086
|
res.on("data", (chunk) => data += chunk);
|
|
5087
5087
|
res.on("end", () => {
|
|
5088
5088
|
try {
|
|
5089
|
-
|
|
5089
|
+
resolve10(JSON.parse(data));
|
|
5090
5090
|
} catch {
|
|
5091
|
-
|
|
5091
|
+
resolve10({ raw: data });
|
|
5092
5092
|
}
|
|
5093
5093
|
});
|
|
5094
5094
|
}).on("error", reject);
|
|
@@ -5102,7 +5102,7 @@ var init_handler = __esm({
|
|
|
5102
5102
|
try {
|
|
5103
5103
|
const http3 = await import("http");
|
|
5104
5104
|
const postData = JSON.stringify(args || {});
|
|
5105
|
-
const result = await new Promise((
|
|
5105
|
+
const result = await new Promise((resolve10, reject) => {
|
|
5106
5106
|
const req = http3.request({
|
|
5107
5107
|
hostname: "127.0.0.1",
|
|
5108
5108
|
port: 19280,
|
|
@@ -5114,9 +5114,9 @@ var init_handler = __esm({
|
|
|
5114
5114
|
res.on("data", (chunk) => data += chunk);
|
|
5115
5115
|
res.on("end", () => {
|
|
5116
5116
|
try {
|
|
5117
|
-
|
|
5117
|
+
resolve10(JSON.parse(data));
|
|
5118
5118
|
} catch {
|
|
5119
|
-
|
|
5119
|
+
resolve10({ raw: data });
|
|
5120
5120
|
}
|
|
5121
5121
|
});
|
|
5122
5122
|
});
|
|
@@ -5133,6 +5133,1755 @@ var init_handler = __esm({
|
|
|
5133
5133
|
}
|
|
5134
5134
|
});
|
|
5135
5135
|
|
|
5136
|
+
// ../../oss/packages/daemon-core/node_modules/readdirp/index.js
|
|
5137
|
+
function readdirp(root, options = {}) {
|
|
5138
|
+
let type = options.entryType || options.type;
|
|
5139
|
+
if (type === "both")
|
|
5140
|
+
type = EntryTypes.FILE_DIR_TYPE;
|
|
5141
|
+
if (type)
|
|
5142
|
+
options.type = type;
|
|
5143
|
+
if (!root) {
|
|
5144
|
+
throw new Error("readdirp: root argument is required. Usage: readdirp(root, options)");
|
|
5145
|
+
} else if (typeof root !== "string") {
|
|
5146
|
+
throw new TypeError("readdirp: root argument must be a string. Usage: readdirp(root, options)");
|
|
5147
|
+
} else if (type && !ALL_TYPES.includes(type)) {
|
|
5148
|
+
throw new Error(`readdirp: Invalid type passed. Use one of ${ALL_TYPES.join(", ")}`);
|
|
5149
|
+
}
|
|
5150
|
+
options.root = root;
|
|
5151
|
+
return new ReaddirpStream(options);
|
|
5152
|
+
}
|
|
5153
|
+
var import_promises, import_node_path, import_node_stream, EntryTypes, defaultOptions, RECURSIVE_ERROR_CODE, NORMAL_FLOW_ERRORS, ALL_TYPES, DIR_TYPES, FILE_TYPES, isNormalFlowError, wantBigintFsStats, emptyFn, normalizeFilter, ReaddirpStream;
|
|
5154
|
+
var init_readdirp = __esm({
|
|
5155
|
+
"../../oss/packages/daemon-core/node_modules/readdirp/index.js"() {
|
|
5156
|
+
"use strict";
|
|
5157
|
+
import_promises = require("fs/promises");
|
|
5158
|
+
import_node_path = require("path");
|
|
5159
|
+
import_node_stream = require("stream");
|
|
5160
|
+
EntryTypes = {
|
|
5161
|
+
FILE_TYPE: "files",
|
|
5162
|
+
DIR_TYPE: "directories",
|
|
5163
|
+
FILE_DIR_TYPE: "files_directories",
|
|
5164
|
+
EVERYTHING_TYPE: "all"
|
|
5165
|
+
};
|
|
5166
|
+
defaultOptions = {
|
|
5167
|
+
root: ".",
|
|
5168
|
+
fileFilter: (_entryInfo) => true,
|
|
5169
|
+
directoryFilter: (_entryInfo) => true,
|
|
5170
|
+
type: EntryTypes.FILE_TYPE,
|
|
5171
|
+
lstat: false,
|
|
5172
|
+
depth: 2147483648,
|
|
5173
|
+
alwaysStat: false,
|
|
5174
|
+
highWaterMark: 4096
|
|
5175
|
+
};
|
|
5176
|
+
Object.freeze(defaultOptions);
|
|
5177
|
+
RECURSIVE_ERROR_CODE = "READDIRP_RECURSIVE_ERROR";
|
|
5178
|
+
NORMAL_FLOW_ERRORS = /* @__PURE__ */ new Set(["ENOENT", "EPERM", "EACCES", "ELOOP", RECURSIVE_ERROR_CODE]);
|
|
5179
|
+
ALL_TYPES = [
|
|
5180
|
+
EntryTypes.DIR_TYPE,
|
|
5181
|
+
EntryTypes.EVERYTHING_TYPE,
|
|
5182
|
+
EntryTypes.FILE_DIR_TYPE,
|
|
5183
|
+
EntryTypes.FILE_TYPE
|
|
5184
|
+
];
|
|
5185
|
+
DIR_TYPES = /* @__PURE__ */ new Set([
|
|
5186
|
+
EntryTypes.DIR_TYPE,
|
|
5187
|
+
EntryTypes.EVERYTHING_TYPE,
|
|
5188
|
+
EntryTypes.FILE_DIR_TYPE
|
|
5189
|
+
]);
|
|
5190
|
+
FILE_TYPES = /* @__PURE__ */ new Set([
|
|
5191
|
+
EntryTypes.EVERYTHING_TYPE,
|
|
5192
|
+
EntryTypes.FILE_DIR_TYPE,
|
|
5193
|
+
EntryTypes.FILE_TYPE
|
|
5194
|
+
]);
|
|
5195
|
+
isNormalFlowError = (error48) => NORMAL_FLOW_ERRORS.has(error48.code);
|
|
5196
|
+
wantBigintFsStats = process.platform === "win32";
|
|
5197
|
+
emptyFn = (_entryInfo) => true;
|
|
5198
|
+
normalizeFilter = (filter) => {
|
|
5199
|
+
if (filter === void 0)
|
|
5200
|
+
return emptyFn;
|
|
5201
|
+
if (typeof filter === "function")
|
|
5202
|
+
return filter;
|
|
5203
|
+
if (typeof filter === "string") {
|
|
5204
|
+
const fl2 = filter.trim();
|
|
5205
|
+
return (entry) => entry.basename === fl2;
|
|
5206
|
+
}
|
|
5207
|
+
if (Array.isArray(filter)) {
|
|
5208
|
+
const trItems = filter.map((item) => item.trim());
|
|
5209
|
+
return (entry) => trItems.some((f) => entry.basename === f);
|
|
5210
|
+
}
|
|
5211
|
+
return emptyFn;
|
|
5212
|
+
};
|
|
5213
|
+
ReaddirpStream = class extends import_node_stream.Readable {
|
|
5214
|
+
parents;
|
|
5215
|
+
reading;
|
|
5216
|
+
parent;
|
|
5217
|
+
_stat;
|
|
5218
|
+
_maxDepth;
|
|
5219
|
+
_wantsDir;
|
|
5220
|
+
_wantsFile;
|
|
5221
|
+
_wantsEverything;
|
|
5222
|
+
_root;
|
|
5223
|
+
_isDirent;
|
|
5224
|
+
_statsProp;
|
|
5225
|
+
_rdOptions;
|
|
5226
|
+
_fileFilter;
|
|
5227
|
+
_directoryFilter;
|
|
5228
|
+
constructor(options = {}) {
|
|
5229
|
+
super({
|
|
5230
|
+
objectMode: true,
|
|
5231
|
+
autoDestroy: true,
|
|
5232
|
+
highWaterMark: options.highWaterMark
|
|
5233
|
+
});
|
|
5234
|
+
const opts = { ...defaultOptions, ...options };
|
|
5235
|
+
const { root, type } = opts;
|
|
5236
|
+
this._fileFilter = normalizeFilter(opts.fileFilter);
|
|
5237
|
+
this._directoryFilter = normalizeFilter(opts.directoryFilter);
|
|
5238
|
+
const statMethod = opts.lstat ? import_promises.lstat : import_promises.stat;
|
|
5239
|
+
if (wantBigintFsStats) {
|
|
5240
|
+
this._stat = (path15) => statMethod(path15, { bigint: true });
|
|
5241
|
+
} else {
|
|
5242
|
+
this._stat = statMethod;
|
|
5243
|
+
}
|
|
5244
|
+
this._maxDepth = opts.depth != null && Number.isSafeInteger(opts.depth) ? opts.depth : defaultOptions.depth;
|
|
5245
|
+
this._wantsDir = type ? DIR_TYPES.has(type) : false;
|
|
5246
|
+
this._wantsFile = type ? FILE_TYPES.has(type) : false;
|
|
5247
|
+
this._wantsEverything = type === EntryTypes.EVERYTHING_TYPE;
|
|
5248
|
+
this._root = (0, import_node_path.resolve)(root);
|
|
5249
|
+
this._isDirent = !opts.alwaysStat;
|
|
5250
|
+
this._statsProp = this._isDirent ? "dirent" : "stats";
|
|
5251
|
+
this._rdOptions = { encoding: "utf8", withFileTypes: this._isDirent };
|
|
5252
|
+
this.parents = [this._exploreDir(root, 1)];
|
|
5253
|
+
this.reading = false;
|
|
5254
|
+
this.parent = void 0;
|
|
5255
|
+
}
|
|
5256
|
+
async _read(batch) {
|
|
5257
|
+
if (this.reading)
|
|
5258
|
+
return;
|
|
5259
|
+
this.reading = true;
|
|
5260
|
+
try {
|
|
5261
|
+
while (!this.destroyed && batch > 0) {
|
|
5262
|
+
const par = this.parent;
|
|
5263
|
+
const fil = par && par.files;
|
|
5264
|
+
if (fil && fil.length > 0) {
|
|
5265
|
+
const { path: path15, depth } = par;
|
|
5266
|
+
const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent, path15));
|
|
5267
|
+
const awaited = await Promise.all(slice);
|
|
5268
|
+
for (const entry of awaited) {
|
|
5269
|
+
if (!entry)
|
|
5270
|
+
continue;
|
|
5271
|
+
if (this.destroyed)
|
|
5272
|
+
return;
|
|
5273
|
+
const entryType = await this._getEntryType(entry);
|
|
5274
|
+
if (entryType === "directory" && this._directoryFilter(entry)) {
|
|
5275
|
+
if (depth <= this._maxDepth) {
|
|
5276
|
+
this.parents.push(this._exploreDir(entry.fullPath, depth + 1));
|
|
5277
|
+
}
|
|
5278
|
+
if (this._wantsDir) {
|
|
5279
|
+
this.push(entry);
|
|
5280
|
+
batch--;
|
|
5281
|
+
}
|
|
5282
|
+
} else if ((entryType === "file" || this._includeAsFile(entry)) && this._fileFilter(entry)) {
|
|
5283
|
+
if (this._wantsFile) {
|
|
5284
|
+
this.push(entry);
|
|
5285
|
+
batch--;
|
|
5286
|
+
}
|
|
5287
|
+
}
|
|
5288
|
+
}
|
|
5289
|
+
} else {
|
|
5290
|
+
const parent = this.parents.pop();
|
|
5291
|
+
if (!parent) {
|
|
5292
|
+
this.push(null);
|
|
5293
|
+
break;
|
|
5294
|
+
}
|
|
5295
|
+
this.parent = await parent;
|
|
5296
|
+
if (this.destroyed)
|
|
5297
|
+
return;
|
|
5298
|
+
}
|
|
5299
|
+
}
|
|
5300
|
+
} catch (error48) {
|
|
5301
|
+
this.destroy(error48);
|
|
5302
|
+
} finally {
|
|
5303
|
+
this.reading = false;
|
|
5304
|
+
}
|
|
5305
|
+
}
|
|
5306
|
+
async _exploreDir(path15, depth) {
|
|
5307
|
+
let files;
|
|
5308
|
+
try {
|
|
5309
|
+
files = await (0, import_promises.readdir)(path15, this._rdOptions);
|
|
5310
|
+
} catch (error48) {
|
|
5311
|
+
this._onError(error48);
|
|
5312
|
+
}
|
|
5313
|
+
return { files, depth, path: path15 };
|
|
5314
|
+
}
|
|
5315
|
+
async _formatEntry(dirent, path15) {
|
|
5316
|
+
let entry;
|
|
5317
|
+
const basename5 = this._isDirent ? dirent.name : dirent;
|
|
5318
|
+
try {
|
|
5319
|
+
const fullPath = (0, import_node_path.resolve)((0, import_node_path.join)(path15, basename5));
|
|
5320
|
+
entry = { path: (0, import_node_path.relative)(this._root, fullPath), fullPath, basename: basename5 };
|
|
5321
|
+
entry[this._statsProp] = this._isDirent ? dirent : await this._stat(fullPath);
|
|
5322
|
+
} catch (err) {
|
|
5323
|
+
this._onError(err);
|
|
5324
|
+
return;
|
|
5325
|
+
}
|
|
5326
|
+
return entry;
|
|
5327
|
+
}
|
|
5328
|
+
_onError(err) {
|
|
5329
|
+
if (isNormalFlowError(err) && !this.destroyed) {
|
|
5330
|
+
this.emit("warn", err);
|
|
5331
|
+
} else {
|
|
5332
|
+
this.destroy(err);
|
|
5333
|
+
}
|
|
5334
|
+
}
|
|
5335
|
+
async _getEntryType(entry) {
|
|
5336
|
+
if (!entry && this._statsProp in entry) {
|
|
5337
|
+
return "";
|
|
5338
|
+
}
|
|
5339
|
+
const stats = entry[this._statsProp];
|
|
5340
|
+
if (stats.isFile())
|
|
5341
|
+
return "file";
|
|
5342
|
+
if (stats.isDirectory())
|
|
5343
|
+
return "directory";
|
|
5344
|
+
if (stats && stats.isSymbolicLink()) {
|
|
5345
|
+
const full = entry.fullPath;
|
|
5346
|
+
try {
|
|
5347
|
+
const entryRealPath = await (0, import_promises.realpath)(full);
|
|
5348
|
+
const entryRealPathStats = await (0, import_promises.lstat)(entryRealPath);
|
|
5349
|
+
if (entryRealPathStats.isFile()) {
|
|
5350
|
+
return "file";
|
|
5351
|
+
}
|
|
5352
|
+
if (entryRealPathStats.isDirectory()) {
|
|
5353
|
+
const len = entryRealPath.length;
|
|
5354
|
+
if (full.startsWith(entryRealPath) && full.substr(len, 1) === import_node_path.sep) {
|
|
5355
|
+
const recursiveError = new Error(`Circular symlink detected: "${full}" points to "${entryRealPath}"`);
|
|
5356
|
+
recursiveError.code = RECURSIVE_ERROR_CODE;
|
|
5357
|
+
return this._onError(recursiveError);
|
|
5358
|
+
}
|
|
5359
|
+
return "directory";
|
|
5360
|
+
}
|
|
5361
|
+
} catch (error48) {
|
|
5362
|
+
this._onError(error48);
|
|
5363
|
+
return "";
|
|
5364
|
+
}
|
|
5365
|
+
}
|
|
5366
|
+
}
|
|
5367
|
+
_includeAsFile(entry) {
|
|
5368
|
+
const stats = entry && entry[this._statsProp];
|
|
5369
|
+
return stats && this._wantsEverything && !stats.isDirectory();
|
|
5370
|
+
}
|
|
5371
|
+
};
|
|
5372
|
+
}
|
|
5373
|
+
});
|
|
5374
|
+
|
|
5375
|
+
// ../../oss/packages/daemon-core/node_modules/chokidar/handler.js
|
|
5376
|
+
function createFsWatchInstance(path15, options, listener, errHandler, emitRaw) {
|
|
5377
|
+
const handleEvent = (rawEvent, evPath) => {
|
|
5378
|
+
listener(path15);
|
|
5379
|
+
emitRaw(rawEvent, evPath, { watchedPath: path15 });
|
|
5380
|
+
if (evPath && path15 !== evPath) {
|
|
5381
|
+
fsWatchBroadcast(sp.resolve(path15, evPath), KEY_LISTENERS, sp.join(path15, evPath));
|
|
5382
|
+
}
|
|
5383
|
+
};
|
|
5384
|
+
try {
|
|
5385
|
+
return (0, import_node_fs.watch)(path15, {
|
|
5386
|
+
persistent: options.persistent
|
|
5387
|
+
}, handleEvent);
|
|
5388
|
+
} catch (error48) {
|
|
5389
|
+
errHandler(error48);
|
|
5390
|
+
return void 0;
|
|
5391
|
+
}
|
|
5392
|
+
}
|
|
5393
|
+
var import_node_fs, import_promises2, import_node_os, sp, STR_DATA, STR_END, STR_CLOSE, EMPTY_FN, pl, isWindows, isMacos, isLinux, isFreeBSD, isIBMi, EVENTS, EV, THROTTLE_MODE_WATCH, statMethods, KEY_LISTENERS, KEY_ERR, KEY_RAW, HANDLER_KEYS, binaryExtensions, isBinaryPath, foreach, addAndConvert, clearItem, delFromSet, isEmptySet, FsWatchInstances, fsWatchBroadcast, setFsWatchListener, FsWatchFileInstances, setFsWatchFileListener, NodeFsHandler;
|
|
5394
|
+
var init_handler2 = __esm({
|
|
5395
|
+
"../../oss/packages/daemon-core/node_modules/chokidar/handler.js"() {
|
|
5396
|
+
"use strict";
|
|
5397
|
+
import_node_fs = require("fs");
|
|
5398
|
+
import_promises2 = require("fs/promises");
|
|
5399
|
+
import_node_os = require("os");
|
|
5400
|
+
sp = __toESM(require("path"), 1);
|
|
5401
|
+
STR_DATA = "data";
|
|
5402
|
+
STR_END = "end";
|
|
5403
|
+
STR_CLOSE = "close";
|
|
5404
|
+
EMPTY_FN = () => {
|
|
5405
|
+
};
|
|
5406
|
+
pl = process.platform;
|
|
5407
|
+
isWindows = pl === "win32";
|
|
5408
|
+
isMacos = pl === "darwin";
|
|
5409
|
+
isLinux = pl === "linux";
|
|
5410
|
+
isFreeBSD = pl === "freebsd";
|
|
5411
|
+
isIBMi = (0, import_node_os.type)() === "OS400";
|
|
5412
|
+
EVENTS = {
|
|
5413
|
+
ALL: "all",
|
|
5414
|
+
READY: "ready",
|
|
5415
|
+
ADD: "add",
|
|
5416
|
+
CHANGE: "change",
|
|
5417
|
+
ADD_DIR: "addDir",
|
|
5418
|
+
UNLINK: "unlink",
|
|
5419
|
+
UNLINK_DIR: "unlinkDir",
|
|
5420
|
+
RAW: "raw",
|
|
5421
|
+
ERROR: "error"
|
|
5422
|
+
};
|
|
5423
|
+
EV = EVENTS;
|
|
5424
|
+
THROTTLE_MODE_WATCH = "watch";
|
|
5425
|
+
statMethods = { lstat: import_promises2.lstat, stat: import_promises2.stat };
|
|
5426
|
+
KEY_LISTENERS = "listeners";
|
|
5427
|
+
KEY_ERR = "errHandlers";
|
|
5428
|
+
KEY_RAW = "rawEmitters";
|
|
5429
|
+
HANDLER_KEYS = [KEY_LISTENERS, KEY_ERR, KEY_RAW];
|
|
5430
|
+
binaryExtensions = /* @__PURE__ */ new Set([
|
|
5431
|
+
"3dm",
|
|
5432
|
+
"3ds",
|
|
5433
|
+
"3g2",
|
|
5434
|
+
"3gp",
|
|
5435
|
+
"7z",
|
|
5436
|
+
"a",
|
|
5437
|
+
"aac",
|
|
5438
|
+
"adp",
|
|
5439
|
+
"afdesign",
|
|
5440
|
+
"afphoto",
|
|
5441
|
+
"afpub",
|
|
5442
|
+
"ai",
|
|
5443
|
+
"aif",
|
|
5444
|
+
"aiff",
|
|
5445
|
+
"alz",
|
|
5446
|
+
"ape",
|
|
5447
|
+
"apk",
|
|
5448
|
+
"appimage",
|
|
5449
|
+
"ar",
|
|
5450
|
+
"arj",
|
|
5451
|
+
"asf",
|
|
5452
|
+
"au",
|
|
5453
|
+
"avi",
|
|
5454
|
+
"bak",
|
|
5455
|
+
"baml",
|
|
5456
|
+
"bh",
|
|
5457
|
+
"bin",
|
|
5458
|
+
"bk",
|
|
5459
|
+
"bmp",
|
|
5460
|
+
"btif",
|
|
5461
|
+
"bz2",
|
|
5462
|
+
"bzip2",
|
|
5463
|
+
"cab",
|
|
5464
|
+
"caf",
|
|
5465
|
+
"cgm",
|
|
5466
|
+
"class",
|
|
5467
|
+
"cmx",
|
|
5468
|
+
"cpio",
|
|
5469
|
+
"cr2",
|
|
5470
|
+
"cur",
|
|
5471
|
+
"dat",
|
|
5472
|
+
"dcm",
|
|
5473
|
+
"deb",
|
|
5474
|
+
"dex",
|
|
5475
|
+
"djvu",
|
|
5476
|
+
"dll",
|
|
5477
|
+
"dmg",
|
|
5478
|
+
"dng",
|
|
5479
|
+
"doc",
|
|
5480
|
+
"docm",
|
|
5481
|
+
"docx",
|
|
5482
|
+
"dot",
|
|
5483
|
+
"dotm",
|
|
5484
|
+
"dra",
|
|
5485
|
+
"DS_Store",
|
|
5486
|
+
"dsk",
|
|
5487
|
+
"dts",
|
|
5488
|
+
"dtshd",
|
|
5489
|
+
"dvb",
|
|
5490
|
+
"dwg",
|
|
5491
|
+
"dxf",
|
|
5492
|
+
"ecelp4800",
|
|
5493
|
+
"ecelp7470",
|
|
5494
|
+
"ecelp9600",
|
|
5495
|
+
"egg",
|
|
5496
|
+
"eol",
|
|
5497
|
+
"eot",
|
|
5498
|
+
"epub",
|
|
5499
|
+
"exe",
|
|
5500
|
+
"f4v",
|
|
5501
|
+
"fbs",
|
|
5502
|
+
"fh",
|
|
5503
|
+
"fla",
|
|
5504
|
+
"flac",
|
|
5505
|
+
"flatpak",
|
|
5506
|
+
"fli",
|
|
5507
|
+
"flv",
|
|
5508
|
+
"fpx",
|
|
5509
|
+
"fst",
|
|
5510
|
+
"fvt",
|
|
5511
|
+
"g3",
|
|
5512
|
+
"gh",
|
|
5513
|
+
"gif",
|
|
5514
|
+
"graffle",
|
|
5515
|
+
"gz",
|
|
5516
|
+
"gzip",
|
|
5517
|
+
"h261",
|
|
5518
|
+
"h263",
|
|
5519
|
+
"h264",
|
|
5520
|
+
"icns",
|
|
5521
|
+
"ico",
|
|
5522
|
+
"ief",
|
|
5523
|
+
"img",
|
|
5524
|
+
"ipa",
|
|
5525
|
+
"iso",
|
|
5526
|
+
"jar",
|
|
5527
|
+
"jpeg",
|
|
5528
|
+
"jpg",
|
|
5529
|
+
"jpgv",
|
|
5530
|
+
"jpm",
|
|
5531
|
+
"jxr",
|
|
5532
|
+
"key",
|
|
5533
|
+
"ktx",
|
|
5534
|
+
"lha",
|
|
5535
|
+
"lib",
|
|
5536
|
+
"lvp",
|
|
5537
|
+
"lz",
|
|
5538
|
+
"lzh",
|
|
5539
|
+
"lzma",
|
|
5540
|
+
"lzo",
|
|
5541
|
+
"m3u",
|
|
5542
|
+
"m4a",
|
|
5543
|
+
"m4v",
|
|
5544
|
+
"mar",
|
|
5545
|
+
"mdi",
|
|
5546
|
+
"mht",
|
|
5547
|
+
"mid",
|
|
5548
|
+
"midi",
|
|
5549
|
+
"mj2",
|
|
5550
|
+
"mka",
|
|
5551
|
+
"mkv",
|
|
5552
|
+
"mmr",
|
|
5553
|
+
"mng",
|
|
5554
|
+
"mobi",
|
|
5555
|
+
"mov",
|
|
5556
|
+
"movie",
|
|
5557
|
+
"mp3",
|
|
5558
|
+
"mp4",
|
|
5559
|
+
"mp4a",
|
|
5560
|
+
"mpeg",
|
|
5561
|
+
"mpg",
|
|
5562
|
+
"mpga",
|
|
5563
|
+
"mxu",
|
|
5564
|
+
"nef",
|
|
5565
|
+
"npx",
|
|
5566
|
+
"numbers",
|
|
5567
|
+
"nupkg",
|
|
5568
|
+
"o",
|
|
5569
|
+
"odp",
|
|
5570
|
+
"ods",
|
|
5571
|
+
"odt",
|
|
5572
|
+
"oga",
|
|
5573
|
+
"ogg",
|
|
5574
|
+
"ogv",
|
|
5575
|
+
"otf",
|
|
5576
|
+
"ott",
|
|
5577
|
+
"pages",
|
|
5578
|
+
"pbm",
|
|
5579
|
+
"pcx",
|
|
5580
|
+
"pdb",
|
|
5581
|
+
"pdf",
|
|
5582
|
+
"pea",
|
|
5583
|
+
"pgm",
|
|
5584
|
+
"pic",
|
|
5585
|
+
"png",
|
|
5586
|
+
"pnm",
|
|
5587
|
+
"pot",
|
|
5588
|
+
"potm",
|
|
5589
|
+
"potx",
|
|
5590
|
+
"ppa",
|
|
5591
|
+
"ppam",
|
|
5592
|
+
"ppm",
|
|
5593
|
+
"pps",
|
|
5594
|
+
"ppsm",
|
|
5595
|
+
"ppsx",
|
|
5596
|
+
"ppt",
|
|
5597
|
+
"pptm",
|
|
5598
|
+
"pptx",
|
|
5599
|
+
"psd",
|
|
5600
|
+
"pya",
|
|
5601
|
+
"pyc",
|
|
5602
|
+
"pyo",
|
|
5603
|
+
"pyv",
|
|
5604
|
+
"qt",
|
|
5605
|
+
"rar",
|
|
5606
|
+
"ras",
|
|
5607
|
+
"raw",
|
|
5608
|
+
"resources",
|
|
5609
|
+
"rgb",
|
|
5610
|
+
"rip",
|
|
5611
|
+
"rlc",
|
|
5612
|
+
"rmf",
|
|
5613
|
+
"rmvb",
|
|
5614
|
+
"rpm",
|
|
5615
|
+
"rtf",
|
|
5616
|
+
"rz",
|
|
5617
|
+
"s3m",
|
|
5618
|
+
"s7z",
|
|
5619
|
+
"scpt",
|
|
5620
|
+
"sgi",
|
|
5621
|
+
"shar",
|
|
5622
|
+
"snap",
|
|
5623
|
+
"sil",
|
|
5624
|
+
"sketch",
|
|
5625
|
+
"slk",
|
|
5626
|
+
"smv",
|
|
5627
|
+
"snk",
|
|
5628
|
+
"so",
|
|
5629
|
+
"stl",
|
|
5630
|
+
"suo",
|
|
5631
|
+
"sub",
|
|
5632
|
+
"swf",
|
|
5633
|
+
"tar",
|
|
5634
|
+
"tbz",
|
|
5635
|
+
"tbz2",
|
|
5636
|
+
"tga",
|
|
5637
|
+
"tgz",
|
|
5638
|
+
"thmx",
|
|
5639
|
+
"tif",
|
|
5640
|
+
"tiff",
|
|
5641
|
+
"tlz",
|
|
5642
|
+
"ttc",
|
|
5643
|
+
"ttf",
|
|
5644
|
+
"txz",
|
|
5645
|
+
"udf",
|
|
5646
|
+
"uvh",
|
|
5647
|
+
"uvi",
|
|
5648
|
+
"uvm",
|
|
5649
|
+
"uvp",
|
|
5650
|
+
"uvs",
|
|
5651
|
+
"uvu",
|
|
5652
|
+
"viv",
|
|
5653
|
+
"vob",
|
|
5654
|
+
"war",
|
|
5655
|
+
"wav",
|
|
5656
|
+
"wax",
|
|
5657
|
+
"wbmp",
|
|
5658
|
+
"wdp",
|
|
5659
|
+
"weba",
|
|
5660
|
+
"webm",
|
|
5661
|
+
"webp",
|
|
5662
|
+
"whl",
|
|
5663
|
+
"wim",
|
|
5664
|
+
"wm",
|
|
5665
|
+
"wma",
|
|
5666
|
+
"wmv",
|
|
5667
|
+
"wmx",
|
|
5668
|
+
"woff",
|
|
5669
|
+
"woff2",
|
|
5670
|
+
"wrm",
|
|
5671
|
+
"wvx",
|
|
5672
|
+
"xbm",
|
|
5673
|
+
"xif",
|
|
5674
|
+
"xla",
|
|
5675
|
+
"xlam",
|
|
5676
|
+
"xls",
|
|
5677
|
+
"xlsb",
|
|
5678
|
+
"xlsm",
|
|
5679
|
+
"xlsx",
|
|
5680
|
+
"xlt",
|
|
5681
|
+
"xltm",
|
|
5682
|
+
"xltx",
|
|
5683
|
+
"xm",
|
|
5684
|
+
"xmind",
|
|
5685
|
+
"xpi",
|
|
5686
|
+
"xpm",
|
|
5687
|
+
"xwd",
|
|
5688
|
+
"xz",
|
|
5689
|
+
"z",
|
|
5690
|
+
"zip",
|
|
5691
|
+
"zipx"
|
|
5692
|
+
]);
|
|
5693
|
+
isBinaryPath = (filePath) => binaryExtensions.has(sp.extname(filePath).slice(1).toLowerCase());
|
|
5694
|
+
foreach = (val, fn2) => {
|
|
5695
|
+
if (val instanceof Set) {
|
|
5696
|
+
val.forEach(fn2);
|
|
5697
|
+
} else {
|
|
5698
|
+
fn2(val);
|
|
5699
|
+
}
|
|
5700
|
+
};
|
|
5701
|
+
addAndConvert = (main, prop, item) => {
|
|
5702
|
+
let container = main[prop];
|
|
5703
|
+
if (!(container instanceof Set)) {
|
|
5704
|
+
main[prop] = container = /* @__PURE__ */ new Set([container]);
|
|
5705
|
+
}
|
|
5706
|
+
container.add(item);
|
|
5707
|
+
};
|
|
5708
|
+
clearItem = (cont) => (key) => {
|
|
5709
|
+
const set2 = cont[key];
|
|
5710
|
+
if (set2 instanceof Set) {
|
|
5711
|
+
set2.clear();
|
|
5712
|
+
} else {
|
|
5713
|
+
delete cont[key];
|
|
5714
|
+
}
|
|
5715
|
+
};
|
|
5716
|
+
delFromSet = (main, prop, item) => {
|
|
5717
|
+
const container = main[prop];
|
|
5718
|
+
if (container instanceof Set) {
|
|
5719
|
+
container.delete(item);
|
|
5720
|
+
} else if (container === item) {
|
|
5721
|
+
delete main[prop];
|
|
5722
|
+
}
|
|
5723
|
+
};
|
|
5724
|
+
isEmptySet = (val) => val instanceof Set ? val.size === 0 : !val;
|
|
5725
|
+
FsWatchInstances = /* @__PURE__ */ new Map();
|
|
5726
|
+
fsWatchBroadcast = (fullPath, listenerType, val1, val2, val3) => {
|
|
5727
|
+
const cont = FsWatchInstances.get(fullPath);
|
|
5728
|
+
if (!cont)
|
|
5729
|
+
return;
|
|
5730
|
+
foreach(cont[listenerType], (listener) => {
|
|
5731
|
+
listener(val1, val2, val3);
|
|
5732
|
+
});
|
|
5733
|
+
};
|
|
5734
|
+
setFsWatchListener = (path15, fullPath, options, handlers) => {
|
|
5735
|
+
const { listener, errHandler, rawEmitter } = handlers;
|
|
5736
|
+
let cont = FsWatchInstances.get(fullPath);
|
|
5737
|
+
let watcher;
|
|
5738
|
+
if (!options.persistent) {
|
|
5739
|
+
watcher = createFsWatchInstance(path15, options, listener, errHandler, rawEmitter);
|
|
5740
|
+
if (!watcher)
|
|
5741
|
+
return;
|
|
5742
|
+
return watcher.close.bind(watcher);
|
|
5743
|
+
}
|
|
5744
|
+
if (cont) {
|
|
5745
|
+
addAndConvert(cont, KEY_LISTENERS, listener);
|
|
5746
|
+
addAndConvert(cont, KEY_ERR, errHandler);
|
|
5747
|
+
addAndConvert(cont, KEY_RAW, rawEmitter);
|
|
5748
|
+
} else {
|
|
5749
|
+
watcher = createFsWatchInstance(
|
|
5750
|
+
path15,
|
|
5751
|
+
options,
|
|
5752
|
+
fsWatchBroadcast.bind(null, fullPath, KEY_LISTENERS),
|
|
5753
|
+
errHandler,
|
|
5754
|
+
// no need to use broadcast here
|
|
5755
|
+
fsWatchBroadcast.bind(null, fullPath, KEY_RAW)
|
|
5756
|
+
);
|
|
5757
|
+
if (!watcher)
|
|
5758
|
+
return;
|
|
5759
|
+
watcher.on(EV.ERROR, async (error48) => {
|
|
5760
|
+
const broadcastErr = fsWatchBroadcast.bind(null, fullPath, KEY_ERR);
|
|
5761
|
+
if (cont)
|
|
5762
|
+
cont.watcherUnusable = true;
|
|
5763
|
+
if (isWindows && error48.code === "EPERM") {
|
|
5764
|
+
try {
|
|
5765
|
+
const fd = await (0, import_promises2.open)(path15, "r");
|
|
5766
|
+
await fd.close();
|
|
5767
|
+
broadcastErr(error48);
|
|
5768
|
+
} catch (err) {
|
|
5769
|
+
}
|
|
5770
|
+
} else {
|
|
5771
|
+
broadcastErr(error48);
|
|
5772
|
+
}
|
|
5773
|
+
});
|
|
5774
|
+
cont = {
|
|
5775
|
+
listeners: listener,
|
|
5776
|
+
errHandlers: errHandler,
|
|
5777
|
+
rawEmitters: rawEmitter,
|
|
5778
|
+
watcher
|
|
5779
|
+
};
|
|
5780
|
+
FsWatchInstances.set(fullPath, cont);
|
|
5781
|
+
}
|
|
5782
|
+
return () => {
|
|
5783
|
+
delFromSet(cont, KEY_LISTENERS, listener);
|
|
5784
|
+
delFromSet(cont, KEY_ERR, errHandler);
|
|
5785
|
+
delFromSet(cont, KEY_RAW, rawEmitter);
|
|
5786
|
+
if (isEmptySet(cont.listeners)) {
|
|
5787
|
+
cont.watcher.close();
|
|
5788
|
+
FsWatchInstances.delete(fullPath);
|
|
5789
|
+
HANDLER_KEYS.forEach(clearItem(cont));
|
|
5790
|
+
cont.watcher = void 0;
|
|
5791
|
+
Object.freeze(cont);
|
|
5792
|
+
}
|
|
5793
|
+
};
|
|
5794
|
+
};
|
|
5795
|
+
FsWatchFileInstances = /* @__PURE__ */ new Map();
|
|
5796
|
+
setFsWatchFileListener = (path15, fullPath, options, handlers) => {
|
|
5797
|
+
const { listener, rawEmitter } = handlers;
|
|
5798
|
+
let cont = FsWatchFileInstances.get(fullPath);
|
|
5799
|
+
const copts = cont && cont.options;
|
|
5800
|
+
if (copts && (copts.persistent < options.persistent || copts.interval > options.interval)) {
|
|
5801
|
+
(0, import_node_fs.unwatchFile)(fullPath);
|
|
5802
|
+
cont = void 0;
|
|
5803
|
+
}
|
|
5804
|
+
if (cont) {
|
|
5805
|
+
addAndConvert(cont, KEY_LISTENERS, listener);
|
|
5806
|
+
addAndConvert(cont, KEY_RAW, rawEmitter);
|
|
5807
|
+
} else {
|
|
5808
|
+
cont = {
|
|
5809
|
+
listeners: listener,
|
|
5810
|
+
rawEmitters: rawEmitter,
|
|
5811
|
+
options,
|
|
5812
|
+
watcher: (0, import_node_fs.watchFile)(fullPath, options, (curr, prev) => {
|
|
5813
|
+
foreach(cont.rawEmitters, (rawEmitter2) => {
|
|
5814
|
+
rawEmitter2(EV.CHANGE, fullPath, { curr, prev });
|
|
5815
|
+
});
|
|
5816
|
+
const currmtime = curr.mtimeMs;
|
|
5817
|
+
if (curr.size !== prev.size || currmtime > prev.mtimeMs || currmtime === 0) {
|
|
5818
|
+
foreach(cont.listeners, (listener2) => listener2(path15, curr));
|
|
5819
|
+
}
|
|
5820
|
+
})
|
|
5821
|
+
};
|
|
5822
|
+
FsWatchFileInstances.set(fullPath, cont);
|
|
5823
|
+
}
|
|
5824
|
+
return () => {
|
|
5825
|
+
delFromSet(cont, KEY_LISTENERS, listener);
|
|
5826
|
+
delFromSet(cont, KEY_RAW, rawEmitter);
|
|
5827
|
+
if (isEmptySet(cont.listeners)) {
|
|
5828
|
+
FsWatchFileInstances.delete(fullPath);
|
|
5829
|
+
(0, import_node_fs.unwatchFile)(fullPath);
|
|
5830
|
+
cont.options = cont.watcher = void 0;
|
|
5831
|
+
Object.freeze(cont);
|
|
5832
|
+
}
|
|
5833
|
+
};
|
|
5834
|
+
};
|
|
5835
|
+
NodeFsHandler = class {
|
|
5836
|
+
fsw;
|
|
5837
|
+
_boundHandleError;
|
|
5838
|
+
constructor(fsW) {
|
|
5839
|
+
this.fsw = fsW;
|
|
5840
|
+
this._boundHandleError = (error48) => fsW._handleError(error48);
|
|
5841
|
+
}
|
|
5842
|
+
/**
|
|
5843
|
+
* Watch file for changes with fs_watchFile or fs_watch.
|
|
5844
|
+
* @param path to file or dir
|
|
5845
|
+
* @param listener on fs change
|
|
5846
|
+
* @returns closer for the watcher instance
|
|
5847
|
+
*/
|
|
5848
|
+
_watchWithNodeFs(path15, listener) {
|
|
5849
|
+
const opts = this.fsw.options;
|
|
5850
|
+
const directory = sp.dirname(path15);
|
|
5851
|
+
const basename5 = sp.basename(path15);
|
|
5852
|
+
const parent = this.fsw._getWatchedDir(directory);
|
|
5853
|
+
parent.add(basename5);
|
|
5854
|
+
const absolutePath = sp.resolve(path15);
|
|
5855
|
+
const options = {
|
|
5856
|
+
persistent: opts.persistent
|
|
5857
|
+
};
|
|
5858
|
+
if (!listener)
|
|
5859
|
+
listener = EMPTY_FN;
|
|
5860
|
+
let closer;
|
|
5861
|
+
if (opts.usePolling) {
|
|
5862
|
+
const enableBin = opts.interval !== opts.binaryInterval;
|
|
5863
|
+
options.interval = enableBin && isBinaryPath(basename5) ? opts.binaryInterval : opts.interval;
|
|
5864
|
+
closer = setFsWatchFileListener(path15, absolutePath, options, {
|
|
5865
|
+
listener,
|
|
5866
|
+
rawEmitter: this.fsw._emitRaw
|
|
5867
|
+
});
|
|
5868
|
+
} else {
|
|
5869
|
+
closer = setFsWatchListener(path15, absolutePath, options, {
|
|
5870
|
+
listener,
|
|
5871
|
+
errHandler: this._boundHandleError,
|
|
5872
|
+
rawEmitter: this.fsw._emitRaw
|
|
5873
|
+
});
|
|
5874
|
+
}
|
|
5875
|
+
return closer;
|
|
5876
|
+
}
|
|
5877
|
+
/**
|
|
5878
|
+
* Watch a file and emit add event if warranted.
|
|
5879
|
+
* @returns closer for the watcher instance
|
|
5880
|
+
*/
|
|
5881
|
+
_handleFile(file2, stats, initialAdd) {
|
|
5882
|
+
if (this.fsw.closed) {
|
|
5883
|
+
return;
|
|
5884
|
+
}
|
|
5885
|
+
const dirname8 = sp.dirname(file2);
|
|
5886
|
+
const basename5 = sp.basename(file2);
|
|
5887
|
+
const parent = this.fsw._getWatchedDir(dirname8);
|
|
5888
|
+
let prevStats = stats;
|
|
5889
|
+
if (parent.has(basename5))
|
|
5890
|
+
return;
|
|
5891
|
+
const listener = async (path15, newStats) => {
|
|
5892
|
+
if (!this.fsw._throttle(THROTTLE_MODE_WATCH, file2, 5))
|
|
5893
|
+
return;
|
|
5894
|
+
if (!newStats || newStats.mtimeMs === 0) {
|
|
5895
|
+
try {
|
|
5896
|
+
const newStats2 = await (0, import_promises2.stat)(file2);
|
|
5897
|
+
if (this.fsw.closed)
|
|
5898
|
+
return;
|
|
5899
|
+
const at2 = newStats2.atimeMs;
|
|
5900
|
+
const mt2 = newStats2.mtimeMs;
|
|
5901
|
+
if (!at2 || at2 <= mt2 || mt2 !== prevStats.mtimeMs) {
|
|
5902
|
+
this.fsw._emit(EV.CHANGE, file2, newStats2);
|
|
5903
|
+
}
|
|
5904
|
+
if ((isMacos || isLinux || isFreeBSD) && prevStats.ino !== newStats2.ino) {
|
|
5905
|
+
this.fsw._closeFile(path15);
|
|
5906
|
+
prevStats = newStats2;
|
|
5907
|
+
const closer2 = this._watchWithNodeFs(file2, listener);
|
|
5908
|
+
if (closer2)
|
|
5909
|
+
this.fsw._addPathCloser(path15, closer2);
|
|
5910
|
+
} else {
|
|
5911
|
+
prevStats = newStats2;
|
|
5912
|
+
}
|
|
5913
|
+
} catch (error48) {
|
|
5914
|
+
this.fsw._remove(dirname8, basename5);
|
|
5915
|
+
}
|
|
5916
|
+
} else if (parent.has(basename5)) {
|
|
5917
|
+
const at2 = newStats.atimeMs;
|
|
5918
|
+
const mt2 = newStats.mtimeMs;
|
|
5919
|
+
if (!at2 || at2 <= mt2 || mt2 !== prevStats.mtimeMs) {
|
|
5920
|
+
this.fsw._emit(EV.CHANGE, file2, newStats);
|
|
5921
|
+
}
|
|
5922
|
+
prevStats = newStats;
|
|
5923
|
+
}
|
|
5924
|
+
};
|
|
5925
|
+
const closer = this._watchWithNodeFs(file2, listener);
|
|
5926
|
+
if (!(initialAdd && this.fsw.options.ignoreInitial) && this.fsw._isntIgnored(file2)) {
|
|
5927
|
+
if (!this.fsw._throttle(EV.ADD, file2, 0))
|
|
5928
|
+
return;
|
|
5929
|
+
this.fsw._emit(EV.ADD, file2, stats);
|
|
5930
|
+
}
|
|
5931
|
+
return closer;
|
|
5932
|
+
}
|
|
5933
|
+
/**
|
|
5934
|
+
* Handle symlinks encountered while reading a dir.
|
|
5935
|
+
* @param entry returned by readdirp
|
|
5936
|
+
* @param directory path of dir being read
|
|
5937
|
+
* @param path of this item
|
|
5938
|
+
* @param item basename of this item
|
|
5939
|
+
* @returns true if no more processing is needed for this entry.
|
|
5940
|
+
*/
|
|
5941
|
+
async _handleSymlink(entry, directory, path15, item) {
|
|
5942
|
+
if (this.fsw.closed) {
|
|
5943
|
+
return;
|
|
5944
|
+
}
|
|
5945
|
+
const full = entry.fullPath;
|
|
5946
|
+
const dir = this.fsw._getWatchedDir(directory);
|
|
5947
|
+
if (!this.fsw.options.followSymlinks) {
|
|
5948
|
+
this.fsw._incrReadyCount();
|
|
5949
|
+
let linkPath;
|
|
5950
|
+
try {
|
|
5951
|
+
linkPath = await (0, import_promises2.realpath)(path15);
|
|
5952
|
+
} catch (e) {
|
|
5953
|
+
this.fsw._emitReady();
|
|
5954
|
+
return true;
|
|
5955
|
+
}
|
|
5956
|
+
if (this.fsw.closed)
|
|
5957
|
+
return;
|
|
5958
|
+
if (dir.has(item)) {
|
|
5959
|
+
if (this.fsw._symlinkPaths.get(full) !== linkPath) {
|
|
5960
|
+
this.fsw._symlinkPaths.set(full, linkPath);
|
|
5961
|
+
this.fsw._emit(EV.CHANGE, path15, entry.stats);
|
|
5962
|
+
}
|
|
5963
|
+
} else {
|
|
5964
|
+
dir.add(item);
|
|
5965
|
+
this.fsw._symlinkPaths.set(full, linkPath);
|
|
5966
|
+
this.fsw._emit(EV.ADD, path15, entry.stats);
|
|
5967
|
+
}
|
|
5968
|
+
this.fsw._emitReady();
|
|
5969
|
+
return true;
|
|
5970
|
+
}
|
|
5971
|
+
if (this.fsw._symlinkPaths.has(full)) {
|
|
5972
|
+
return true;
|
|
5973
|
+
}
|
|
5974
|
+
this.fsw._symlinkPaths.set(full, true);
|
|
5975
|
+
}
|
|
5976
|
+
_handleRead(directory, initialAdd, wh, target, dir, depth, throttler) {
|
|
5977
|
+
directory = sp.join(directory, "");
|
|
5978
|
+
const throttleKey = target ? `${directory}:${target}` : directory;
|
|
5979
|
+
throttler = this.fsw._throttle("readdir", throttleKey, 1e3);
|
|
5980
|
+
if (!throttler)
|
|
5981
|
+
return;
|
|
5982
|
+
const previous = this.fsw._getWatchedDir(wh.path);
|
|
5983
|
+
const current = /* @__PURE__ */ new Set();
|
|
5984
|
+
let stream = this.fsw._readdirp(directory, {
|
|
5985
|
+
fileFilter: (entry) => wh.filterPath(entry),
|
|
5986
|
+
directoryFilter: (entry) => wh.filterDir(entry)
|
|
5987
|
+
});
|
|
5988
|
+
if (!stream)
|
|
5989
|
+
return;
|
|
5990
|
+
stream.on(STR_DATA, async (entry) => {
|
|
5991
|
+
if (this.fsw.closed) {
|
|
5992
|
+
stream = void 0;
|
|
5993
|
+
return;
|
|
5994
|
+
}
|
|
5995
|
+
const item = entry.path;
|
|
5996
|
+
let path15 = sp.join(directory, item);
|
|
5997
|
+
current.add(item);
|
|
5998
|
+
if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory, path15, item)) {
|
|
5999
|
+
return;
|
|
6000
|
+
}
|
|
6001
|
+
if (this.fsw.closed) {
|
|
6002
|
+
stream = void 0;
|
|
6003
|
+
return;
|
|
6004
|
+
}
|
|
6005
|
+
if (item === target || !target && !previous.has(item)) {
|
|
6006
|
+
this.fsw._incrReadyCount();
|
|
6007
|
+
path15 = sp.join(dir, sp.relative(dir, path15));
|
|
6008
|
+
this._addToNodeFs(path15, initialAdd, wh, depth + 1);
|
|
6009
|
+
}
|
|
6010
|
+
}).on(EV.ERROR, this._boundHandleError);
|
|
6011
|
+
return new Promise((resolve10, reject) => {
|
|
6012
|
+
if (!stream)
|
|
6013
|
+
return reject();
|
|
6014
|
+
stream.once(STR_END, () => {
|
|
6015
|
+
if (this.fsw.closed) {
|
|
6016
|
+
stream = void 0;
|
|
6017
|
+
return;
|
|
6018
|
+
}
|
|
6019
|
+
const wasThrottled = throttler ? throttler.clear() : false;
|
|
6020
|
+
resolve10(void 0);
|
|
6021
|
+
previous.getChildren().filter((item) => {
|
|
6022
|
+
return item !== directory && !current.has(item);
|
|
6023
|
+
}).forEach((item) => {
|
|
6024
|
+
this.fsw._remove(directory, item);
|
|
6025
|
+
});
|
|
6026
|
+
stream = void 0;
|
|
6027
|
+
if (wasThrottled)
|
|
6028
|
+
this._handleRead(directory, false, wh, target, dir, depth, throttler);
|
|
6029
|
+
});
|
|
6030
|
+
});
|
|
6031
|
+
}
|
|
6032
|
+
/**
|
|
6033
|
+
* Read directory to add / remove files from `@watched` list and re-read it on change.
|
|
6034
|
+
* @param dir fs path
|
|
6035
|
+
* @param stats
|
|
6036
|
+
* @param initialAdd
|
|
6037
|
+
* @param depth relative to user-supplied path
|
|
6038
|
+
* @param target child path targeted for watch
|
|
6039
|
+
* @param wh Common watch helpers for this path
|
|
6040
|
+
* @param realpath
|
|
6041
|
+
* @returns closer for the watcher instance.
|
|
6042
|
+
*/
|
|
6043
|
+
async _handleDir(dir, stats, initialAdd, depth, target, wh, realpath2) {
|
|
6044
|
+
const parentDir = this.fsw._getWatchedDir(sp.dirname(dir));
|
|
6045
|
+
const tracked = parentDir.has(sp.basename(dir));
|
|
6046
|
+
if (!(initialAdd && this.fsw.options.ignoreInitial) && !target && !tracked) {
|
|
6047
|
+
this.fsw._emit(EV.ADD_DIR, dir, stats);
|
|
6048
|
+
}
|
|
6049
|
+
parentDir.add(sp.basename(dir));
|
|
6050
|
+
this.fsw._getWatchedDir(dir);
|
|
6051
|
+
let throttler;
|
|
6052
|
+
let closer;
|
|
6053
|
+
const oDepth = this.fsw.options.depth;
|
|
6054
|
+
if ((oDepth == null || depth <= oDepth) && !this.fsw._symlinkPaths.has(realpath2)) {
|
|
6055
|
+
if (!target) {
|
|
6056
|
+
await this._handleRead(dir, initialAdd, wh, target, dir, depth, throttler);
|
|
6057
|
+
if (this.fsw.closed)
|
|
6058
|
+
return;
|
|
6059
|
+
}
|
|
6060
|
+
closer = this._watchWithNodeFs(dir, (dirPath, stats2) => {
|
|
6061
|
+
if (stats2 && stats2.mtimeMs === 0)
|
|
6062
|
+
return;
|
|
6063
|
+
this._handleRead(dirPath, false, wh, target, dir, depth, throttler);
|
|
6064
|
+
});
|
|
6065
|
+
}
|
|
6066
|
+
return closer;
|
|
6067
|
+
}
|
|
6068
|
+
/**
|
|
6069
|
+
* Handle added file, directory, or glob pattern.
|
|
6070
|
+
* Delegates call to _handleFile / _handleDir after checks.
|
|
6071
|
+
* @param path to file or ir
|
|
6072
|
+
* @param initialAdd was the file added at watch instantiation?
|
|
6073
|
+
* @param priorWh depth relative to user-supplied path
|
|
6074
|
+
* @param depth Child path actually targeted for watch
|
|
6075
|
+
* @param target Child path actually targeted for watch
|
|
6076
|
+
*/
|
|
6077
|
+
async _addToNodeFs(path15, initialAdd, priorWh, depth, target) {
|
|
6078
|
+
const ready = this.fsw._emitReady;
|
|
6079
|
+
if (this.fsw._isIgnored(path15) || this.fsw.closed) {
|
|
6080
|
+
ready();
|
|
6081
|
+
return false;
|
|
6082
|
+
}
|
|
6083
|
+
const wh = this.fsw._getWatchHelpers(path15);
|
|
6084
|
+
if (priorWh) {
|
|
6085
|
+
wh.filterPath = (entry) => priorWh.filterPath(entry);
|
|
6086
|
+
wh.filterDir = (entry) => priorWh.filterDir(entry);
|
|
6087
|
+
}
|
|
6088
|
+
try {
|
|
6089
|
+
const stats = await statMethods[wh.statMethod](wh.watchPath);
|
|
6090
|
+
if (this.fsw.closed)
|
|
6091
|
+
return;
|
|
6092
|
+
if (this.fsw._isIgnored(wh.watchPath, stats)) {
|
|
6093
|
+
ready();
|
|
6094
|
+
return false;
|
|
6095
|
+
}
|
|
6096
|
+
const follow = this.fsw.options.followSymlinks;
|
|
6097
|
+
let closer;
|
|
6098
|
+
if (stats.isDirectory()) {
|
|
6099
|
+
const absPath = sp.resolve(path15);
|
|
6100
|
+
const targetPath = follow ? await (0, import_promises2.realpath)(path15) : path15;
|
|
6101
|
+
if (this.fsw.closed)
|
|
6102
|
+
return;
|
|
6103
|
+
closer = await this._handleDir(wh.watchPath, stats, initialAdd, depth, target, wh, targetPath);
|
|
6104
|
+
if (this.fsw.closed)
|
|
6105
|
+
return;
|
|
6106
|
+
if (absPath !== targetPath && targetPath !== void 0) {
|
|
6107
|
+
this.fsw._symlinkPaths.set(absPath, targetPath);
|
|
6108
|
+
}
|
|
6109
|
+
} else if (stats.isSymbolicLink()) {
|
|
6110
|
+
const targetPath = follow ? await (0, import_promises2.realpath)(path15) : path15;
|
|
6111
|
+
if (this.fsw.closed)
|
|
6112
|
+
return;
|
|
6113
|
+
const parent = sp.dirname(wh.watchPath);
|
|
6114
|
+
this.fsw._getWatchedDir(parent).add(wh.watchPath);
|
|
6115
|
+
this.fsw._emit(EV.ADD, wh.watchPath, stats);
|
|
6116
|
+
closer = await this._handleDir(parent, stats, initialAdd, depth, path15, wh, targetPath);
|
|
6117
|
+
if (this.fsw.closed)
|
|
6118
|
+
return;
|
|
6119
|
+
if (targetPath !== void 0) {
|
|
6120
|
+
this.fsw._symlinkPaths.set(sp.resolve(path15), targetPath);
|
|
6121
|
+
}
|
|
6122
|
+
} else {
|
|
6123
|
+
closer = this._handleFile(wh.watchPath, stats, initialAdd);
|
|
6124
|
+
}
|
|
6125
|
+
ready();
|
|
6126
|
+
if (closer)
|
|
6127
|
+
this.fsw._addPathCloser(path15, closer);
|
|
6128
|
+
return false;
|
|
6129
|
+
} catch (error48) {
|
|
6130
|
+
if (this.fsw._handleError(error48)) {
|
|
6131
|
+
ready();
|
|
6132
|
+
return path15;
|
|
6133
|
+
}
|
|
6134
|
+
}
|
|
6135
|
+
}
|
|
6136
|
+
};
|
|
6137
|
+
}
|
|
6138
|
+
});
|
|
6139
|
+
|
|
6140
|
+
// ../../oss/packages/daemon-core/node_modules/chokidar/index.js
|
|
6141
|
+
function arrify(item) {
|
|
6142
|
+
return Array.isArray(item) ? item : [item];
|
|
6143
|
+
}
|
|
6144
|
+
function createPattern(matcher) {
|
|
6145
|
+
if (typeof matcher === "function")
|
|
6146
|
+
return matcher;
|
|
6147
|
+
if (typeof matcher === "string")
|
|
6148
|
+
return (string4) => matcher === string4;
|
|
6149
|
+
if (matcher instanceof RegExp)
|
|
6150
|
+
return (string4) => matcher.test(string4);
|
|
6151
|
+
if (typeof matcher === "object" && matcher !== null) {
|
|
6152
|
+
return (string4) => {
|
|
6153
|
+
if (matcher.path === string4)
|
|
6154
|
+
return true;
|
|
6155
|
+
if (matcher.recursive) {
|
|
6156
|
+
const relative3 = sp2.relative(matcher.path, string4);
|
|
6157
|
+
if (!relative3) {
|
|
6158
|
+
return false;
|
|
6159
|
+
}
|
|
6160
|
+
return !relative3.startsWith("..") && !sp2.isAbsolute(relative3);
|
|
6161
|
+
}
|
|
6162
|
+
return false;
|
|
6163
|
+
};
|
|
6164
|
+
}
|
|
6165
|
+
return () => false;
|
|
6166
|
+
}
|
|
6167
|
+
function normalizePath(path15) {
|
|
6168
|
+
if (typeof path15 !== "string")
|
|
6169
|
+
throw new Error("string expected");
|
|
6170
|
+
path15 = sp2.normalize(path15);
|
|
6171
|
+
path15 = path15.replace(/\\/g, "/");
|
|
6172
|
+
let prepend = false;
|
|
6173
|
+
if (path15.startsWith("//"))
|
|
6174
|
+
prepend = true;
|
|
6175
|
+
path15 = path15.replace(DOUBLE_SLASH_RE, "/");
|
|
6176
|
+
if (prepend)
|
|
6177
|
+
path15 = "/" + path15;
|
|
6178
|
+
return path15;
|
|
6179
|
+
}
|
|
6180
|
+
function matchPatterns(patterns, testString, stats) {
|
|
6181
|
+
const path15 = normalizePath(testString);
|
|
6182
|
+
for (let index = 0; index < patterns.length; index++) {
|
|
6183
|
+
const pattern = patterns[index];
|
|
6184
|
+
if (pattern(path15, stats)) {
|
|
6185
|
+
return true;
|
|
6186
|
+
}
|
|
6187
|
+
}
|
|
6188
|
+
return false;
|
|
6189
|
+
}
|
|
6190
|
+
function anymatch(matchers, testString) {
|
|
6191
|
+
if (matchers == null) {
|
|
6192
|
+
throw new TypeError("anymatch: specify first argument");
|
|
6193
|
+
}
|
|
6194
|
+
const matchersArray = arrify(matchers);
|
|
6195
|
+
const patterns = matchersArray.map((matcher) => createPattern(matcher));
|
|
6196
|
+
if (testString == null) {
|
|
6197
|
+
return (testString2, stats) => {
|
|
6198
|
+
return matchPatterns(patterns, testString2, stats);
|
|
6199
|
+
};
|
|
6200
|
+
}
|
|
6201
|
+
return matchPatterns(patterns, testString);
|
|
6202
|
+
}
|
|
6203
|
+
function watch(paths, options = {}) {
|
|
6204
|
+
const watcher = new FSWatcher(options);
|
|
6205
|
+
watcher.add(paths);
|
|
6206
|
+
return watcher;
|
|
6207
|
+
}
|
|
6208
|
+
var import_node_events, import_node_fs2, import_promises3, sp2, SLASH, SLASH_SLASH, ONE_DOT, TWO_DOTS, STRING_TYPE, BACK_SLASH_RE, DOUBLE_SLASH_RE, DOT_RE, REPLACER_RE, isMatcherObject, unifyPaths, toUnix, normalizePathToUnix, normalizeIgnored, getAbsolutePath, EMPTY_SET, DirEntry, STAT_METHOD_F, STAT_METHOD_L, WatchHelper, FSWatcher;
|
|
6209
|
+
var init_chokidar = __esm({
|
|
6210
|
+
"../../oss/packages/daemon-core/node_modules/chokidar/index.js"() {
|
|
6211
|
+
"use strict";
|
|
6212
|
+
import_node_events = require("events");
|
|
6213
|
+
import_node_fs2 = require("fs");
|
|
6214
|
+
import_promises3 = require("fs/promises");
|
|
6215
|
+
sp2 = __toESM(require("path"), 1);
|
|
6216
|
+
init_readdirp();
|
|
6217
|
+
init_handler2();
|
|
6218
|
+
SLASH = "/";
|
|
6219
|
+
SLASH_SLASH = "//";
|
|
6220
|
+
ONE_DOT = ".";
|
|
6221
|
+
TWO_DOTS = "..";
|
|
6222
|
+
STRING_TYPE = "string";
|
|
6223
|
+
BACK_SLASH_RE = /\\/g;
|
|
6224
|
+
DOUBLE_SLASH_RE = /\/\//g;
|
|
6225
|
+
DOT_RE = /\..*\.(sw[px])$|~$|\.subl.*\.tmp/;
|
|
6226
|
+
REPLACER_RE = /^\.[/\\]/;
|
|
6227
|
+
isMatcherObject = (matcher) => typeof matcher === "object" && matcher !== null && !(matcher instanceof RegExp);
|
|
6228
|
+
unifyPaths = (paths_) => {
|
|
6229
|
+
const paths = arrify(paths_).flat();
|
|
6230
|
+
if (!paths.every((p) => typeof p === STRING_TYPE)) {
|
|
6231
|
+
throw new TypeError(`Non-string provided as watch path: ${paths}`);
|
|
6232
|
+
}
|
|
6233
|
+
return paths.map(normalizePathToUnix);
|
|
6234
|
+
};
|
|
6235
|
+
toUnix = (string4) => {
|
|
6236
|
+
let str = string4.replace(BACK_SLASH_RE, SLASH);
|
|
6237
|
+
let prepend = false;
|
|
6238
|
+
if (str.startsWith(SLASH_SLASH)) {
|
|
6239
|
+
prepend = true;
|
|
6240
|
+
}
|
|
6241
|
+
str = str.replace(DOUBLE_SLASH_RE, SLASH);
|
|
6242
|
+
if (prepend) {
|
|
6243
|
+
str = SLASH + str;
|
|
6244
|
+
}
|
|
6245
|
+
return str;
|
|
6246
|
+
};
|
|
6247
|
+
normalizePathToUnix = (path15) => toUnix(sp2.normalize(toUnix(path15)));
|
|
6248
|
+
normalizeIgnored = (cwd = "") => (path15) => {
|
|
6249
|
+
if (typeof path15 === "string") {
|
|
6250
|
+
return normalizePathToUnix(sp2.isAbsolute(path15) ? path15 : sp2.join(cwd, path15));
|
|
6251
|
+
} else {
|
|
6252
|
+
return path15;
|
|
6253
|
+
}
|
|
6254
|
+
};
|
|
6255
|
+
getAbsolutePath = (path15, cwd) => {
|
|
6256
|
+
if (sp2.isAbsolute(path15)) {
|
|
6257
|
+
return path15;
|
|
6258
|
+
}
|
|
6259
|
+
return sp2.join(cwd, path15);
|
|
6260
|
+
};
|
|
6261
|
+
EMPTY_SET = Object.freeze(/* @__PURE__ */ new Set());
|
|
6262
|
+
DirEntry = class {
|
|
6263
|
+
path;
|
|
6264
|
+
_removeWatcher;
|
|
6265
|
+
items;
|
|
6266
|
+
constructor(dir, removeWatcher) {
|
|
6267
|
+
this.path = dir;
|
|
6268
|
+
this._removeWatcher = removeWatcher;
|
|
6269
|
+
this.items = /* @__PURE__ */ new Set();
|
|
6270
|
+
}
|
|
6271
|
+
add(item) {
|
|
6272
|
+
const { items } = this;
|
|
6273
|
+
if (!items)
|
|
6274
|
+
return;
|
|
6275
|
+
if (item !== ONE_DOT && item !== TWO_DOTS)
|
|
6276
|
+
items.add(item);
|
|
6277
|
+
}
|
|
6278
|
+
async remove(item) {
|
|
6279
|
+
const { items } = this;
|
|
6280
|
+
if (!items)
|
|
6281
|
+
return;
|
|
6282
|
+
items.delete(item);
|
|
6283
|
+
if (items.size > 0)
|
|
6284
|
+
return;
|
|
6285
|
+
const dir = this.path;
|
|
6286
|
+
try {
|
|
6287
|
+
await (0, import_promises3.readdir)(dir);
|
|
6288
|
+
} catch (err) {
|
|
6289
|
+
if (this._removeWatcher) {
|
|
6290
|
+
this._removeWatcher(sp2.dirname(dir), sp2.basename(dir));
|
|
6291
|
+
}
|
|
6292
|
+
}
|
|
6293
|
+
}
|
|
6294
|
+
has(item) {
|
|
6295
|
+
const { items } = this;
|
|
6296
|
+
if (!items)
|
|
6297
|
+
return;
|
|
6298
|
+
return items.has(item);
|
|
6299
|
+
}
|
|
6300
|
+
getChildren() {
|
|
6301
|
+
const { items } = this;
|
|
6302
|
+
if (!items)
|
|
6303
|
+
return [];
|
|
6304
|
+
return [...items.values()];
|
|
6305
|
+
}
|
|
6306
|
+
dispose() {
|
|
6307
|
+
this.items.clear();
|
|
6308
|
+
this.path = "";
|
|
6309
|
+
this._removeWatcher = EMPTY_FN;
|
|
6310
|
+
this.items = EMPTY_SET;
|
|
6311
|
+
Object.freeze(this);
|
|
6312
|
+
}
|
|
6313
|
+
};
|
|
6314
|
+
STAT_METHOD_F = "stat";
|
|
6315
|
+
STAT_METHOD_L = "lstat";
|
|
6316
|
+
WatchHelper = class {
|
|
6317
|
+
fsw;
|
|
6318
|
+
path;
|
|
6319
|
+
watchPath;
|
|
6320
|
+
fullWatchPath;
|
|
6321
|
+
dirParts;
|
|
6322
|
+
followSymlinks;
|
|
6323
|
+
statMethod;
|
|
6324
|
+
constructor(path15, follow, fsw) {
|
|
6325
|
+
this.fsw = fsw;
|
|
6326
|
+
const watchPath = path15;
|
|
6327
|
+
this.path = path15 = path15.replace(REPLACER_RE, "");
|
|
6328
|
+
this.watchPath = watchPath;
|
|
6329
|
+
this.fullWatchPath = sp2.resolve(watchPath);
|
|
6330
|
+
this.dirParts = [];
|
|
6331
|
+
this.dirParts.forEach((parts) => {
|
|
6332
|
+
if (parts.length > 1)
|
|
6333
|
+
parts.pop();
|
|
6334
|
+
});
|
|
6335
|
+
this.followSymlinks = follow;
|
|
6336
|
+
this.statMethod = follow ? STAT_METHOD_F : STAT_METHOD_L;
|
|
6337
|
+
}
|
|
6338
|
+
entryPath(entry) {
|
|
6339
|
+
return sp2.join(this.watchPath, sp2.relative(this.watchPath, entry.fullPath));
|
|
6340
|
+
}
|
|
6341
|
+
filterPath(entry) {
|
|
6342
|
+
const { stats } = entry;
|
|
6343
|
+
if (stats && stats.isSymbolicLink())
|
|
6344
|
+
return this.filterDir(entry);
|
|
6345
|
+
const resolvedPath = this.entryPath(entry);
|
|
6346
|
+
return this.fsw._isntIgnored(resolvedPath, stats) && this.fsw._hasReadPermissions(stats);
|
|
6347
|
+
}
|
|
6348
|
+
filterDir(entry) {
|
|
6349
|
+
return this.fsw._isntIgnored(this.entryPath(entry), entry.stats);
|
|
6350
|
+
}
|
|
6351
|
+
};
|
|
6352
|
+
FSWatcher = class extends import_node_events.EventEmitter {
|
|
6353
|
+
closed;
|
|
6354
|
+
options;
|
|
6355
|
+
_closers;
|
|
6356
|
+
_ignoredPaths;
|
|
6357
|
+
_throttled;
|
|
6358
|
+
_streams;
|
|
6359
|
+
_symlinkPaths;
|
|
6360
|
+
_watched;
|
|
6361
|
+
_pendingWrites;
|
|
6362
|
+
_pendingUnlinks;
|
|
6363
|
+
_readyCount;
|
|
6364
|
+
_emitReady;
|
|
6365
|
+
_closePromise;
|
|
6366
|
+
_userIgnored;
|
|
6367
|
+
_readyEmitted;
|
|
6368
|
+
_emitRaw;
|
|
6369
|
+
_boundRemove;
|
|
6370
|
+
_nodeFsHandler;
|
|
6371
|
+
// Not indenting methods for history sake; for now.
|
|
6372
|
+
constructor(_opts = {}) {
|
|
6373
|
+
super();
|
|
6374
|
+
this.closed = false;
|
|
6375
|
+
this._closers = /* @__PURE__ */ new Map();
|
|
6376
|
+
this._ignoredPaths = /* @__PURE__ */ new Set();
|
|
6377
|
+
this._throttled = /* @__PURE__ */ new Map();
|
|
6378
|
+
this._streams = /* @__PURE__ */ new Set();
|
|
6379
|
+
this._symlinkPaths = /* @__PURE__ */ new Map();
|
|
6380
|
+
this._watched = /* @__PURE__ */ new Map();
|
|
6381
|
+
this._pendingWrites = /* @__PURE__ */ new Map();
|
|
6382
|
+
this._pendingUnlinks = /* @__PURE__ */ new Map();
|
|
6383
|
+
this._readyCount = 0;
|
|
6384
|
+
this._readyEmitted = false;
|
|
6385
|
+
const awf = _opts.awaitWriteFinish;
|
|
6386
|
+
const DEF_AWF = { stabilityThreshold: 2e3, pollInterval: 100 };
|
|
6387
|
+
const opts = {
|
|
6388
|
+
// Defaults
|
|
6389
|
+
persistent: true,
|
|
6390
|
+
ignoreInitial: false,
|
|
6391
|
+
ignorePermissionErrors: false,
|
|
6392
|
+
interval: 100,
|
|
6393
|
+
binaryInterval: 300,
|
|
6394
|
+
followSymlinks: true,
|
|
6395
|
+
usePolling: false,
|
|
6396
|
+
// useAsync: false,
|
|
6397
|
+
atomic: true,
|
|
6398
|
+
// NOTE: overwritten later (depends on usePolling)
|
|
6399
|
+
..._opts,
|
|
6400
|
+
// Change format
|
|
6401
|
+
ignored: _opts.ignored ? arrify(_opts.ignored) : arrify([]),
|
|
6402
|
+
awaitWriteFinish: awf === true ? DEF_AWF : typeof awf === "object" ? { ...DEF_AWF, ...awf } : false
|
|
6403
|
+
};
|
|
6404
|
+
if (isIBMi)
|
|
6405
|
+
opts.usePolling = true;
|
|
6406
|
+
if (opts.atomic === void 0)
|
|
6407
|
+
opts.atomic = !opts.usePolling;
|
|
6408
|
+
const envPoll = process.env.CHOKIDAR_USEPOLLING;
|
|
6409
|
+
if (envPoll !== void 0) {
|
|
6410
|
+
const envLower = envPoll.toLowerCase();
|
|
6411
|
+
if (envLower === "false" || envLower === "0")
|
|
6412
|
+
opts.usePolling = false;
|
|
6413
|
+
else if (envLower === "true" || envLower === "1")
|
|
6414
|
+
opts.usePolling = true;
|
|
6415
|
+
else
|
|
6416
|
+
opts.usePolling = !!envLower;
|
|
6417
|
+
}
|
|
6418
|
+
const envInterval = process.env.CHOKIDAR_INTERVAL;
|
|
6419
|
+
if (envInterval)
|
|
6420
|
+
opts.interval = Number.parseInt(envInterval, 10);
|
|
6421
|
+
let readyCalls = 0;
|
|
6422
|
+
this._emitReady = () => {
|
|
6423
|
+
readyCalls++;
|
|
6424
|
+
if (readyCalls >= this._readyCount) {
|
|
6425
|
+
this._emitReady = EMPTY_FN;
|
|
6426
|
+
this._readyEmitted = true;
|
|
6427
|
+
process.nextTick(() => this.emit(EVENTS.READY));
|
|
6428
|
+
}
|
|
6429
|
+
};
|
|
6430
|
+
this._emitRaw = (...args) => this.emit(EVENTS.RAW, ...args);
|
|
6431
|
+
this._boundRemove = this._remove.bind(this);
|
|
6432
|
+
this.options = opts;
|
|
6433
|
+
this._nodeFsHandler = new NodeFsHandler(this);
|
|
6434
|
+
Object.freeze(opts);
|
|
6435
|
+
}
|
|
6436
|
+
_addIgnoredPath(matcher) {
|
|
6437
|
+
if (isMatcherObject(matcher)) {
|
|
6438
|
+
for (const ignored of this._ignoredPaths) {
|
|
6439
|
+
if (isMatcherObject(ignored) && ignored.path === matcher.path && ignored.recursive === matcher.recursive) {
|
|
6440
|
+
return;
|
|
6441
|
+
}
|
|
6442
|
+
}
|
|
6443
|
+
}
|
|
6444
|
+
this._ignoredPaths.add(matcher);
|
|
6445
|
+
}
|
|
6446
|
+
_removeIgnoredPath(matcher) {
|
|
6447
|
+
this._ignoredPaths.delete(matcher);
|
|
6448
|
+
if (typeof matcher === "string") {
|
|
6449
|
+
for (const ignored of this._ignoredPaths) {
|
|
6450
|
+
if (isMatcherObject(ignored) && ignored.path === matcher) {
|
|
6451
|
+
this._ignoredPaths.delete(ignored);
|
|
6452
|
+
}
|
|
6453
|
+
}
|
|
6454
|
+
}
|
|
6455
|
+
}
|
|
6456
|
+
// Public methods
|
|
6457
|
+
/**
|
|
6458
|
+
* Adds paths to be watched on an existing FSWatcher instance.
|
|
6459
|
+
* @param paths_ file or file list. Other arguments are unused
|
|
6460
|
+
*/
|
|
6461
|
+
add(paths_, _origAdd, _internal) {
|
|
6462
|
+
const { cwd } = this.options;
|
|
6463
|
+
this.closed = false;
|
|
6464
|
+
this._closePromise = void 0;
|
|
6465
|
+
let paths = unifyPaths(paths_);
|
|
6466
|
+
if (cwd) {
|
|
6467
|
+
paths = paths.map((path15) => {
|
|
6468
|
+
const absPath = getAbsolutePath(path15, cwd);
|
|
6469
|
+
return absPath;
|
|
6470
|
+
});
|
|
6471
|
+
}
|
|
6472
|
+
paths.forEach((path15) => {
|
|
6473
|
+
this._removeIgnoredPath(path15);
|
|
6474
|
+
});
|
|
6475
|
+
this._userIgnored = void 0;
|
|
6476
|
+
if (!this._readyCount)
|
|
6477
|
+
this._readyCount = 0;
|
|
6478
|
+
this._readyCount += paths.length;
|
|
6479
|
+
Promise.all(paths.map(async (path15) => {
|
|
6480
|
+
const res = await this._nodeFsHandler._addToNodeFs(path15, !_internal, void 0, 0, _origAdd);
|
|
6481
|
+
if (res)
|
|
6482
|
+
this._emitReady();
|
|
6483
|
+
return res;
|
|
6484
|
+
})).then((results) => {
|
|
6485
|
+
if (this.closed)
|
|
6486
|
+
return;
|
|
6487
|
+
results.forEach((item) => {
|
|
6488
|
+
if (item)
|
|
6489
|
+
this.add(sp2.dirname(item), sp2.basename(_origAdd || item));
|
|
6490
|
+
});
|
|
6491
|
+
});
|
|
6492
|
+
return this;
|
|
6493
|
+
}
|
|
6494
|
+
/**
|
|
6495
|
+
* Close watchers or start ignoring events from specified paths.
|
|
6496
|
+
*/
|
|
6497
|
+
unwatch(paths_) {
|
|
6498
|
+
if (this.closed)
|
|
6499
|
+
return this;
|
|
6500
|
+
const paths = unifyPaths(paths_);
|
|
6501
|
+
const { cwd } = this.options;
|
|
6502
|
+
paths.forEach((path15) => {
|
|
6503
|
+
if (!sp2.isAbsolute(path15) && !this._closers.has(path15)) {
|
|
6504
|
+
if (cwd)
|
|
6505
|
+
path15 = sp2.join(cwd, path15);
|
|
6506
|
+
path15 = sp2.resolve(path15);
|
|
6507
|
+
}
|
|
6508
|
+
this._closePath(path15);
|
|
6509
|
+
this._addIgnoredPath(path15);
|
|
6510
|
+
if (this._watched.has(path15)) {
|
|
6511
|
+
this._addIgnoredPath({
|
|
6512
|
+
path: path15,
|
|
6513
|
+
recursive: true
|
|
6514
|
+
});
|
|
6515
|
+
}
|
|
6516
|
+
this._userIgnored = void 0;
|
|
6517
|
+
});
|
|
6518
|
+
return this;
|
|
6519
|
+
}
|
|
6520
|
+
/**
|
|
6521
|
+
* Close watchers and remove all listeners from watched paths.
|
|
6522
|
+
*/
|
|
6523
|
+
close() {
|
|
6524
|
+
if (this._closePromise) {
|
|
6525
|
+
return this._closePromise;
|
|
6526
|
+
}
|
|
6527
|
+
this.closed = true;
|
|
6528
|
+
this.removeAllListeners();
|
|
6529
|
+
const closers = [];
|
|
6530
|
+
this._closers.forEach((closerList) => closerList.forEach((closer) => {
|
|
6531
|
+
const promise2 = closer();
|
|
6532
|
+
if (promise2 instanceof Promise)
|
|
6533
|
+
closers.push(promise2);
|
|
6534
|
+
}));
|
|
6535
|
+
this._streams.forEach((stream) => stream.destroy());
|
|
6536
|
+
this._userIgnored = void 0;
|
|
6537
|
+
this._readyCount = 0;
|
|
6538
|
+
this._readyEmitted = false;
|
|
6539
|
+
this._watched.forEach((dirent) => dirent.dispose());
|
|
6540
|
+
this._closers.clear();
|
|
6541
|
+
this._watched.clear();
|
|
6542
|
+
this._streams.clear();
|
|
6543
|
+
this._symlinkPaths.clear();
|
|
6544
|
+
this._throttled.clear();
|
|
6545
|
+
this._closePromise = closers.length ? Promise.all(closers).then(() => void 0) : Promise.resolve();
|
|
6546
|
+
return this._closePromise;
|
|
6547
|
+
}
|
|
6548
|
+
/**
|
|
6549
|
+
* Expose list of watched paths
|
|
6550
|
+
* @returns for chaining
|
|
6551
|
+
*/
|
|
6552
|
+
getWatched() {
|
|
6553
|
+
const watchList = {};
|
|
6554
|
+
this._watched.forEach((entry, dir) => {
|
|
6555
|
+
const key = this.options.cwd ? sp2.relative(this.options.cwd, dir) : dir;
|
|
6556
|
+
const index = key || ONE_DOT;
|
|
6557
|
+
watchList[index] = entry.getChildren().sort();
|
|
6558
|
+
});
|
|
6559
|
+
return watchList;
|
|
6560
|
+
}
|
|
6561
|
+
emitWithAll(event, args) {
|
|
6562
|
+
this.emit(event, ...args);
|
|
6563
|
+
if (event !== EVENTS.ERROR)
|
|
6564
|
+
this.emit(EVENTS.ALL, event, ...args);
|
|
6565
|
+
}
|
|
6566
|
+
// Common helpers
|
|
6567
|
+
// --------------
|
|
6568
|
+
/**
|
|
6569
|
+
* Normalize and emit events.
|
|
6570
|
+
* Calling _emit DOES NOT MEAN emit() would be called!
|
|
6571
|
+
* @param event Type of event
|
|
6572
|
+
* @param path File or directory path
|
|
6573
|
+
* @param stats arguments to be passed with event
|
|
6574
|
+
* @returns the error if defined, otherwise the value of the FSWatcher instance's `closed` flag
|
|
6575
|
+
*/
|
|
6576
|
+
async _emit(event, path15, stats) {
|
|
6577
|
+
if (this.closed)
|
|
6578
|
+
return;
|
|
6579
|
+
const opts = this.options;
|
|
6580
|
+
if (isWindows)
|
|
6581
|
+
path15 = sp2.normalize(path15);
|
|
6582
|
+
if (opts.cwd)
|
|
6583
|
+
path15 = sp2.relative(opts.cwd, path15);
|
|
6584
|
+
const args = [path15];
|
|
6585
|
+
if (stats != null)
|
|
6586
|
+
args.push(stats);
|
|
6587
|
+
const awf = opts.awaitWriteFinish;
|
|
6588
|
+
let pw;
|
|
6589
|
+
if (awf && (pw = this._pendingWrites.get(path15))) {
|
|
6590
|
+
pw.lastChange = /* @__PURE__ */ new Date();
|
|
6591
|
+
return this;
|
|
6592
|
+
}
|
|
6593
|
+
if (opts.atomic) {
|
|
6594
|
+
if (event === EVENTS.UNLINK) {
|
|
6595
|
+
this._pendingUnlinks.set(path15, [event, ...args]);
|
|
6596
|
+
setTimeout(() => {
|
|
6597
|
+
this._pendingUnlinks.forEach((entry, path16) => {
|
|
6598
|
+
this.emit(...entry);
|
|
6599
|
+
this.emit(EVENTS.ALL, ...entry);
|
|
6600
|
+
this._pendingUnlinks.delete(path16);
|
|
6601
|
+
});
|
|
6602
|
+
}, typeof opts.atomic === "number" ? opts.atomic : 100);
|
|
6603
|
+
return this;
|
|
6604
|
+
}
|
|
6605
|
+
if (event === EVENTS.ADD && this._pendingUnlinks.has(path15)) {
|
|
6606
|
+
event = EVENTS.CHANGE;
|
|
6607
|
+
this._pendingUnlinks.delete(path15);
|
|
6608
|
+
}
|
|
6609
|
+
}
|
|
6610
|
+
if (awf && (event === EVENTS.ADD || event === EVENTS.CHANGE) && this._readyEmitted) {
|
|
6611
|
+
const awfEmit = (err, stats2) => {
|
|
6612
|
+
if (err) {
|
|
6613
|
+
event = EVENTS.ERROR;
|
|
6614
|
+
args[0] = err;
|
|
6615
|
+
this.emitWithAll(event, args);
|
|
6616
|
+
} else if (stats2) {
|
|
6617
|
+
if (args.length > 1) {
|
|
6618
|
+
args[1] = stats2;
|
|
6619
|
+
} else {
|
|
6620
|
+
args.push(stats2);
|
|
6621
|
+
}
|
|
6622
|
+
this.emitWithAll(event, args);
|
|
6623
|
+
}
|
|
6624
|
+
};
|
|
6625
|
+
this._awaitWriteFinish(path15, awf.stabilityThreshold, event, awfEmit);
|
|
6626
|
+
return this;
|
|
6627
|
+
}
|
|
6628
|
+
if (event === EVENTS.CHANGE) {
|
|
6629
|
+
const isThrottled = !this._throttle(EVENTS.CHANGE, path15, 50);
|
|
6630
|
+
if (isThrottled)
|
|
6631
|
+
return this;
|
|
6632
|
+
}
|
|
6633
|
+
if (opts.alwaysStat && stats === void 0 && (event === EVENTS.ADD || event === EVENTS.ADD_DIR || event === EVENTS.CHANGE)) {
|
|
6634
|
+
const fullPath = opts.cwd ? sp2.join(opts.cwd, path15) : path15;
|
|
6635
|
+
let stats2;
|
|
6636
|
+
try {
|
|
6637
|
+
stats2 = await (0, import_promises3.stat)(fullPath);
|
|
6638
|
+
} catch (err) {
|
|
6639
|
+
}
|
|
6640
|
+
if (!stats2 || this.closed)
|
|
6641
|
+
return;
|
|
6642
|
+
args.push(stats2);
|
|
6643
|
+
}
|
|
6644
|
+
this.emitWithAll(event, args);
|
|
6645
|
+
return this;
|
|
6646
|
+
}
|
|
6647
|
+
/**
|
|
6648
|
+
* Common handler for errors
|
|
6649
|
+
* @returns The error if defined, otherwise the value of the FSWatcher instance's `closed` flag
|
|
6650
|
+
*/
|
|
6651
|
+
_handleError(error48) {
|
|
6652
|
+
const code = error48 && error48.code;
|
|
6653
|
+
if (error48 && code !== "ENOENT" && code !== "ENOTDIR" && (!this.options.ignorePermissionErrors || code !== "EPERM" && code !== "EACCES")) {
|
|
6654
|
+
this.emit(EVENTS.ERROR, error48);
|
|
6655
|
+
}
|
|
6656
|
+
return error48 || this.closed;
|
|
6657
|
+
}
|
|
6658
|
+
/**
|
|
6659
|
+
* Helper utility for throttling
|
|
6660
|
+
* @param actionType type being throttled
|
|
6661
|
+
* @param path being acted upon
|
|
6662
|
+
* @param timeout duration of time to suppress duplicate actions
|
|
6663
|
+
* @returns tracking object or false if action should be suppressed
|
|
6664
|
+
*/
|
|
6665
|
+
_throttle(actionType, path15, timeout) {
|
|
6666
|
+
if (!this._throttled.has(actionType)) {
|
|
6667
|
+
this._throttled.set(actionType, /* @__PURE__ */ new Map());
|
|
6668
|
+
}
|
|
6669
|
+
const action = this._throttled.get(actionType);
|
|
6670
|
+
if (!action)
|
|
6671
|
+
throw new Error("invalid throttle");
|
|
6672
|
+
const actionPath = action.get(path15);
|
|
6673
|
+
if (actionPath) {
|
|
6674
|
+
actionPath.count++;
|
|
6675
|
+
return false;
|
|
6676
|
+
}
|
|
6677
|
+
let timeoutObject;
|
|
6678
|
+
const clear = () => {
|
|
6679
|
+
const item = action.get(path15);
|
|
6680
|
+
const count = item ? item.count : 0;
|
|
6681
|
+
action.delete(path15);
|
|
6682
|
+
clearTimeout(timeoutObject);
|
|
6683
|
+
if (item)
|
|
6684
|
+
clearTimeout(item.timeoutObject);
|
|
6685
|
+
return count;
|
|
6686
|
+
};
|
|
6687
|
+
timeoutObject = setTimeout(clear, timeout);
|
|
6688
|
+
const thr = { timeoutObject, clear, count: 0 };
|
|
6689
|
+
action.set(path15, thr);
|
|
6690
|
+
return thr;
|
|
6691
|
+
}
|
|
6692
|
+
_incrReadyCount() {
|
|
6693
|
+
return this._readyCount++;
|
|
6694
|
+
}
|
|
6695
|
+
/**
|
|
6696
|
+
* Awaits write operation to finish.
|
|
6697
|
+
* Polls a newly created file for size variations. When files size does not change for 'threshold' milliseconds calls callback.
|
|
6698
|
+
* @param path being acted upon
|
|
6699
|
+
* @param threshold Time in milliseconds a file size must be fixed before acknowledging write OP is finished
|
|
6700
|
+
* @param event
|
|
6701
|
+
* @param awfEmit Callback to be called when ready for event to be emitted.
|
|
6702
|
+
*/
|
|
6703
|
+
_awaitWriteFinish(path15, threshold, event, awfEmit) {
|
|
6704
|
+
const awf = this.options.awaitWriteFinish;
|
|
6705
|
+
if (typeof awf !== "object")
|
|
6706
|
+
return;
|
|
6707
|
+
const pollInterval = awf.pollInterval;
|
|
6708
|
+
let timeoutHandler;
|
|
6709
|
+
let fullPath = path15;
|
|
6710
|
+
if (this.options.cwd && !sp2.isAbsolute(path15)) {
|
|
6711
|
+
fullPath = sp2.join(this.options.cwd, path15);
|
|
6712
|
+
}
|
|
6713
|
+
const now = /* @__PURE__ */ new Date();
|
|
6714
|
+
const writes = this._pendingWrites;
|
|
6715
|
+
function awaitWriteFinishFn(prevStat) {
|
|
6716
|
+
(0, import_node_fs2.stat)(fullPath, (err, curStat) => {
|
|
6717
|
+
if (err || !writes.has(path15)) {
|
|
6718
|
+
if (err && err.code !== "ENOENT")
|
|
6719
|
+
awfEmit(err);
|
|
6720
|
+
return;
|
|
6721
|
+
}
|
|
6722
|
+
const now2 = Number(/* @__PURE__ */ new Date());
|
|
6723
|
+
if (prevStat && curStat.size !== prevStat.size) {
|
|
6724
|
+
writes.get(path15).lastChange = now2;
|
|
6725
|
+
}
|
|
6726
|
+
const pw = writes.get(path15);
|
|
6727
|
+
const df = now2 - pw.lastChange;
|
|
6728
|
+
if (df >= threshold) {
|
|
6729
|
+
writes.delete(path15);
|
|
6730
|
+
awfEmit(void 0, curStat);
|
|
6731
|
+
} else {
|
|
6732
|
+
timeoutHandler = setTimeout(awaitWriteFinishFn, pollInterval, curStat);
|
|
6733
|
+
}
|
|
6734
|
+
});
|
|
6735
|
+
}
|
|
6736
|
+
if (!writes.has(path15)) {
|
|
6737
|
+
writes.set(path15, {
|
|
6738
|
+
lastChange: now,
|
|
6739
|
+
cancelWait: () => {
|
|
6740
|
+
writes.delete(path15);
|
|
6741
|
+
clearTimeout(timeoutHandler);
|
|
6742
|
+
return event;
|
|
6743
|
+
}
|
|
6744
|
+
});
|
|
6745
|
+
timeoutHandler = setTimeout(awaitWriteFinishFn, pollInterval);
|
|
6746
|
+
}
|
|
6747
|
+
}
|
|
6748
|
+
/**
|
|
6749
|
+
* Determines whether user has asked to ignore this path.
|
|
6750
|
+
*/
|
|
6751
|
+
_isIgnored(path15, stats) {
|
|
6752
|
+
if (this.options.atomic && DOT_RE.test(path15))
|
|
6753
|
+
return true;
|
|
6754
|
+
if (!this._userIgnored) {
|
|
6755
|
+
const { cwd } = this.options;
|
|
6756
|
+
const ign = this.options.ignored;
|
|
6757
|
+
const ignored = (ign || []).map(normalizeIgnored(cwd));
|
|
6758
|
+
const ignoredPaths = [...this._ignoredPaths];
|
|
6759
|
+
const list = [...ignoredPaths.map(normalizeIgnored(cwd)), ...ignored];
|
|
6760
|
+
this._userIgnored = anymatch(list, void 0);
|
|
6761
|
+
}
|
|
6762
|
+
return this._userIgnored(path15, stats);
|
|
6763
|
+
}
|
|
6764
|
+
_isntIgnored(path15, stat4) {
|
|
6765
|
+
return !this._isIgnored(path15, stat4);
|
|
6766
|
+
}
|
|
6767
|
+
/**
|
|
6768
|
+
* Provides a set of common helpers and properties relating to symlink handling.
|
|
6769
|
+
* @param path file or directory pattern being watched
|
|
6770
|
+
*/
|
|
6771
|
+
_getWatchHelpers(path15) {
|
|
6772
|
+
return new WatchHelper(path15, this.options.followSymlinks, this);
|
|
6773
|
+
}
|
|
6774
|
+
// Directory helpers
|
|
6775
|
+
// -----------------
|
|
6776
|
+
/**
|
|
6777
|
+
* Provides directory tracking objects
|
|
6778
|
+
* @param directory path of the directory
|
|
6779
|
+
*/
|
|
6780
|
+
_getWatchedDir(directory) {
|
|
6781
|
+
const dir = sp2.resolve(directory);
|
|
6782
|
+
if (!this._watched.has(dir))
|
|
6783
|
+
this._watched.set(dir, new DirEntry(dir, this._boundRemove));
|
|
6784
|
+
return this._watched.get(dir);
|
|
6785
|
+
}
|
|
6786
|
+
// File helpers
|
|
6787
|
+
// ------------
|
|
6788
|
+
/**
|
|
6789
|
+
* Check for read permissions: https://stackoverflow.com/a/11781404/1358405
|
|
6790
|
+
*/
|
|
6791
|
+
_hasReadPermissions(stats) {
|
|
6792
|
+
if (this.options.ignorePermissionErrors)
|
|
6793
|
+
return true;
|
|
6794
|
+
return Boolean(Number(stats.mode) & 256);
|
|
6795
|
+
}
|
|
6796
|
+
/**
|
|
6797
|
+
* Handles emitting unlink events for
|
|
6798
|
+
* files and directories, and via recursion, for
|
|
6799
|
+
* files and directories within directories that are unlinked
|
|
6800
|
+
* @param directory within which the following item is located
|
|
6801
|
+
* @param item base path of item/directory
|
|
6802
|
+
*/
|
|
6803
|
+
_remove(directory, item, isDirectory) {
|
|
6804
|
+
const path15 = sp2.join(directory, item);
|
|
6805
|
+
const fullPath = sp2.resolve(path15);
|
|
6806
|
+
isDirectory = isDirectory != null ? isDirectory : this._watched.has(path15) || this._watched.has(fullPath);
|
|
6807
|
+
if (!this._throttle("remove", path15, 100))
|
|
6808
|
+
return;
|
|
6809
|
+
if (!isDirectory && this._watched.size === 1) {
|
|
6810
|
+
this.add(directory, item, true);
|
|
6811
|
+
}
|
|
6812
|
+
const wp = this._getWatchedDir(path15);
|
|
6813
|
+
const nestedDirectoryChildren = wp.getChildren();
|
|
6814
|
+
nestedDirectoryChildren.forEach((nested) => this._remove(path15, nested));
|
|
6815
|
+
const parent = this._getWatchedDir(directory);
|
|
6816
|
+
const wasTracked = parent.has(item);
|
|
6817
|
+
parent.remove(item);
|
|
6818
|
+
if (this._symlinkPaths.has(fullPath)) {
|
|
6819
|
+
this._symlinkPaths.delete(fullPath);
|
|
6820
|
+
}
|
|
6821
|
+
let relPath = path15;
|
|
6822
|
+
if (this.options.cwd)
|
|
6823
|
+
relPath = sp2.relative(this.options.cwd, path15);
|
|
6824
|
+
if (this.options.awaitWriteFinish && this._pendingWrites.has(relPath)) {
|
|
6825
|
+
const event = this._pendingWrites.get(relPath).cancelWait();
|
|
6826
|
+
if (event === EVENTS.ADD)
|
|
6827
|
+
return;
|
|
6828
|
+
}
|
|
6829
|
+
this._watched.delete(path15);
|
|
6830
|
+
this._watched.delete(fullPath);
|
|
6831
|
+
const eventName = isDirectory ? EVENTS.UNLINK_DIR : EVENTS.UNLINK;
|
|
6832
|
+
if (wasTracked && !this._isIgnored(path15))
|
|
6833
|
+
this._emit(eventName, path15);
|
|
6834
|
+
this._closePath(path15);
|
|
6835
|
+
}
|
|
6836
|
+
/**
|
|
6837
|
+
* Closes all watchers for a path
|
|
6838
|
+
*/
|
|
6839
|
+
_closePath(path15) {
|
|
6840
|
+
this._closeFile(path15);
|
|
6841
|
+
const dir = sp2.dirname(path15);
|
|
6842
|
+
this._getWatchedDir(dir).remove(sp2.basename(path15));
|
|
6843
|
+
}
|
|
6844
|
+
/**
|
|
6845
|
+
* Closes only file-specific watchers
|
|
6846
|
+
*/
|
|
6847
|
+
_closeFile(path15) {
|
|
6848
|
+
const closers = this._closers.get(path15);
|
|
6849
|
+
if (!closers)
|
|
6850
|
+
return;
|
|
6851
|
+
closers.forEach((closer) => closer());
|
|
6852
|
+
this._closers.delete(path15);
|
|
6853
|
+
}
|
|
6854
|
+
_addPathCloser(path15, closer) {
|
|
6855
|
+
if (!closer)
|
|
6856
|
+
return;
|
|
6857
|
+
let list = this._closers.get(path15);
|
|
6858
|
+
if (!list) {
|
|
6859
|
+
list = [];
|
|
6860
|
+
this._closers.set(path15, list);
|
|
6861
|
+
}
|
|
6862
|
+
list.push(closer);
|
|
6863
|
+
}
|
|
6864
|
+
_readdirp(root, opts) {
|
|
6865
|
+
if (this.closed)
|
|
6866
|
+
return;
|
|
6867
|
+
const options = { type: EVENTS.ALL, alwaysStat: true, lstat: true, ...opts, depth: 0 };
|
|
6868
|
+
let stream = readdirp(root, options);
|
|
6869
|
+
this._streams.add(stream);
|
|
6870
|
+
stream.once(STR_CLOSE, () => {
|
|
6871
|
+
stream = void 0;
|
|
6872
|
+
});
|
|
6873
|
+
stream.once(STR_END, () => {
|
|
6874
|
+
if (stream) {
|
|
6875
|
+
this._streams.delete(stream);
|
|
6876
|
+
stream = void 0;
|
|
6877
|
+
}
|
|
6878
|
+
});
|
|
6879
|
+
return stream;
|
|
6880
|
+
}
|
|
6881
|
+
};
|
|
6882
|
+
}
|
|
6883
|
+
});
|
|
6884
|
+
|
|
5136
6885
|
// ../../oss/packages/daemon-core/src/providers/provider-loader.ts
|
|
5137
6886
|
var fs5, path6, os7, ProviderLoader;
|
|
5138
6887
|
var init_provider_loader = __esm({
|
|
@@ -5141,11 +6890,11 @@ var init_provider_loader = __esm({
|
|
|
5141
6890
|
fs5 = __toESM(require("fs"));
|
|
5142
6891
|
path6 = __toESM(require("path"));
|
|
5143
6892
|
os7 = __toESM(require("os"));
|
|
6893
|
+
init_chokidar();
|
|
5144
6894
|
init_ide_detector();
|
|
5145
6895
|
init_logger();
|
|
5146
6896
|
ProviderLoader = class _ProviderLoader {
|
|
5147
6897
|
providers = /* @__PURE__ */ new Map();
|
|
5148
|
-
builtinDirs;
|
|
5149
6898
|
userDir;
|
|
5150
6899
|
upstreamDir;
|
|
5151
6900
|
disableUpstream;
|
|
@@ -5160,36 +6909,31 @@ var init_provider_loader = __esm({
|
|
|
5160
6909
|
static GITHUB_TARBALL_URL = "https://github.com/vilmire/adhdev-providers/archive/refs/heads/main.tar.gz";
|
|
5161
6910
|
static META_FILE = ".meta.json";
|
|
5162
6911
|
constructor(options) {
|
|
5163
|
-
|
|
5164
|
-
|
|
6912
|
+
this.logFn = options?.logFn || LOG.forComponent("Provider").asLogFn();
|
|
6913
|
+
const defaultProvidersDir = path6.join(os7.homedir(), ".adhdev", "providers");
|
|
6914
|
+
if (options?.userDir) {
|
|
6915
|
+
this.userDir = options.userDir;
|
|
6916
|
+
this.log(`Config 'providerDir' applied: ${this.userDir}`);
|
|
5165
6917
|
} else {
|
|
5166
|
-
|
|
6918
|
+
const localRepoPath = path6.resolve(__dirname, "../../../../../adhdev-providers");
|
|
6919
|
+
if (fs5.existsSync(localRepoPath)) {
|
|
6920
|
+
this.userDir = localRepoPath;
|
|
6921
|
+
this.log(`Auto-detected local public repository: ${this.userDir} (Dev workspace speedup)`);
|
|
6922
|
+
} else {
|
|
6923
|
+
this.userDir = defaultProvidersDir;
|
|
6924
|
+
this.log(`Using default user providers directory: ${this.userDir}`);
|
|
6925
|
+
}
|
|
5167
6926
|
}
|
|
5168
|
-
const defaultProvidersDir = path6.join(os7.homedir(), ".adhdev", "providers");
|
|
5169
|
-
this.userDir = options?.userDir || defaultProvidersDir;
|
|
5170
6927
|
this.upstreamDir = path6.join(defaultProvidersDir, ".upstream");
|
|
5171
6928
|
this.disableUpstream = options?.disableUpstream ?? false;
|
|
5172
|
-
this.logFn = options?.logFn || LOG.forComponent("Provider").asLogFn();
|
|
5173
6929
|
}
|
|
5174
6930
|
log(msg) {
|
|
5175
6931
|
this.logFn(`[ProviderLoader] ${msg}`);
|
|
5176
6932
|
}
|
|
5177
6933
|
// ─── Public API ────────────────────────────────
|
|
5178
6934
|
/**
|
|
5179
|
-
|
|
5180
|
-
|
|
5181
|
-
getBuiltinDirs() {
|
|
5182
|
-
return [...this.builtinDirs];
|
|
5183
|
-
}
|
|
5184
|
-
/**
|
|
5185
|
-
* Primary builtin root used for local scaffolding/reference flows.
|
|
5186
|
-
*/
|
|
5187
|
-
getPrimaryBuiltinDir() {
|
|
5188
|
-
return this.builtinDirs[0];
|
|
5189
|
-
}
|
|
5190
|
-
/**
|
|
5191
|
-
* User override root (~/.adhdev/providers by default).
|
|
5192
|
-
*/
|
|
6935
|
+
* User override root (~/.adhdev/providers by default).
|
|
6936
|
+
*/
|
|
5193
6937
|
getUserDir() {
|
|
5194
6938
|
return this.userDir;
|
|
5195
6939
|
}
|
|
@@ -5200,11 +6944,11 @@ var init_provider_loader = __esm({
|
|
|
5200
6944
|
return this.upstreamDir;
|
|
5201
6945
|
}
|
|
5202
6946
|
/**
|
|
5203
|
-
|
|
5204
|
-
|
|
5205
|
-
|
|
6947
|
+
* Provider search order for on-disk lookups.
|
|
6948
|
+
* Highest-priority editable overrides come first.
|
|
6949
|
+
*/
|
|
5206
6950
|
getProviderRoots() {
|
|
5207
|
-
return [this.userDir, this.upstreamDir
|
|
6951
|
+
return [this.userDir, this.upstreamDir];
|
|
5208
6952
|
}
|
|
5209
6953
|
/**
|
|
5210
6954
|
* Canonical provider directory shape for a given root.
|
|
@@ -5225,16 +6969,9 @@ var init_provider_loader = __esm({
|
|
|
5225
6969
|
return this.getProviderDir(this.upstreamDir, category, type);
|
|
5226
6970
|
}
|
|
5227
6971
|
/**
|
|
5228
|
-
*
|
|
6972
|
+
* Find the on-disk directory for a provider by type.
|
|
6973
|
+
* Search order: user override → upstream.
|
|
5229
6974
|
*/
|
|
5230
|
-
getBuiltinProviderDir(category, type) {
|
|
5231
|
-
const builtinRoot = this.getPrimaryBuiltinDir();
|
|
5232
|
-
return builtinRoot ? this.getProviderDir(builtinRoot, category, type) : "";
|
|
5233
|
-
}
|
|
5234
|
-
/**
|
|
5235
|
-
* Find the on-disk directory for a provider by type.
|
|
5236
|
-
* Search order: user override → upstream → builtin fallback.
|
|
5237
|
-
*/
|
|
5238
6975
|
findProviderDir(type) {
|
|
5239
6976
|
return this.findProviderDirInternal(type);
|
|
5240
6977
|
}
|
|
@@ -5599,13 +7336,12 @@ var init_provider_loader = __esm({
|
|
|
5599
7336
|
}
|
|
5600
7337
|
}
|
|
5601
7338
|
const result = this.buildScriptWrappersFromDir(dir);
|
|
5602
|
-
this.log(` [loadScriptsFromDir] ${type}: built wrappers from ${dir} (${Object.keys(result).length} scripts)`);
|
|
5603
7339
|
this.scriptsCache.set(dir, result);
|
|
5604
7340
|
return result;
|
|
5605
7341
|
}
|
|
5606
7342
|
/**
|
|
5607
|
-
|
|
5608
|
-
|
|
7343
|
+
* Hot-reload: start watching for file changes
|
|
7344
|
+
*/
|
|
5609
7345
|
watch() {
|
|
5610
7346
|
this.stopWatch();
|
|
5611
7347
|
const watchDir = (dir) => {
|
|
@@ -5617,18 +7353,27 @@ var init_provider_loader = __esm({
|
|
|
5617
7353
|
}
|
|
5618
7354
|
}
|
|
5619
7355
|
try {
|
|
5620
|
-
const watcher =
|
|
5621
|
-
|
|
5622
|
-
|
|
5623
|
-
|
|
5624
|
-
|
|
7356
|
+
const watcher = watch(dir, {
|
|
7357
|
+
ignored: /(^|[\/\\])\.\./,
|
|
7358
|
+
// ignore dotfiles
|
|
7359
|
+
persistent: true,
|
|
7360
|
+
ignoreInitial: true,
|
|
7361
|
+
awaitWriteFinish: { stabilityThreshold: 200, pollInterval: 50 }
|
|
5625
7362
|
});
|
|
7363
|
+
const handleChange = (filePath) => {
|
|
7364
|
+
if (filePath.endsWith(".js") || filePath.endsWith(".json")) {
|
|
7365
|
+
this.log(`File changed: ${path6.basename(filePath)}, reloading...`);
|
|
7366
|
+
this.reload();
|
|
7367
|
+
}
|
|
7368
|
+
};
|
|
7369
|
+
watcher.on("add", handleChange).on("change", handleChange).on("unlink", handleChange);
|
|
7370
|
+
watcher.on("error", (err) => this.log(`Watch error: ${err.message}`));
|
|
5626
7371
|
this.watchers.push(watcher);
|
|
7372
|
+
this.log(`Hot-reload watcher active: ${dir}`);
|
|
5627
7373
|
} catch (e) {
|
|
5628
7374
|
this.log(`Watch failed for ${dir}: ${e.message}`);
|
|
5629
7375
|
}
|
|
5630
7376
|
};
|
|
5631
|
-
this.builtinDirs.forEach((dir) => watchDir(dir));
|
|
5632
7377
|
watchDir(this.userDir);
|
|
5633
7378
|
}
|
|
5634
7379
|
/**
|
|
@@ -5689,7 +7434,7 @@ var init_provider_loader = __esm({
|
|
|
5689
7434
|
return { updated: false };
|
|
5690
7435
|
}
|
|
5691
7436
|
try {
|
|
5692
|
-
const etag = await new Promise((
|
|
7437
|
+
const etag = await new Promise((resolve10, reject) => {
|
|
5693
7438
|
const options = {
|
|
5694
7439
|
method: "HEAD",
|
|
5695
7440
|
hostname: "github.com",
|
|
@@ -5707,7 +7452,7 @@ var init_provider_loader = __esm({
|
|
|
5707
7452
|
headers: { "User-Agent": "adhdev-launcher" },
|
|
5708
7453
|
timeout: 1e4
|
|
5709
7454
|
}, (res2) => {
|
|
5710
|
-
|
|
7455
|
+
resolve10(res2.headers.etag || res2.headers["last-modified"] || "");
|
|
5711
7456
|
});
|
|
5712
7457
|
req2.on("error", reject);
|
|
5713
7458
|
req2.on("timeout", () => {
|
|
@@ -5716,7 +7461,7 @@ var init_provider_loader = __esm({
|
|
|
5716
7461
|
});
|
|
5717
7462
|
req2.end();
|
|
5718
7463
|
} else {
|
|
5719
|
-
|
|
7464
|
+
resolve10(res.headers.etag || res.headers["last-modified"] || "");
|
|
5720
7465
|
}
|
|
5721
7466
|
});
|
|
5722
7467
|
req.on("error", reject);
|
|
@@ -5780,7 +7525,7 @@ var init_provider_loader = __esm({
|
|
|
5780
7525
|
downloadFile(url2, destPath) {
|
|
5781
7526
|
const https = require("https");
|
|
5782
7527
|
const http3 = require("http");
|
|
5783
|
-
return new Promise((
|
|
7528
|
+
return new Promise((resolve10, reject) => {
|
|
5784
7529
|
const doRequest = (reqUrl, redirectCount = 0) => {
|
|
5785
7530
|
if (redirectCount > 5) {
|
|
5786
7531
|
reject(new Error("Too many redirects"));
|
|
@@ -5800,7 +7545,7 @@ var init_provider_loader = __esm({
|
|
|
5800
7545
|
res.pipe(ws2);
|
|
5801
7546
|
ws2.on("finish", () => {
|
|
5802
7547
|
ws2.close();
|
|
5803
|
-
|
|
7548
|
+
resolve10();
|
|
5804
7549
|
});
|
|
5805
7550
|
ws2.on("error", reject);
|
|
5806
7551
|
});
|
|
@@ -6072,8 +7817,8 @@ var init_provider_loader = __esm({
|
|
|
6072
7817
|
const existed = this.providers.has(mod.type);
|
|
6073
7818
|
this.providers.set(mod.type, mod);
|
|
6074
7819
|
count++;
|
|
6075
|
-
const source = d.startsWith(this.userDir) && !d.includes(".upstream") ? "user" :
|
|
6076
|
-
const overrideWarning = existed && source === "user" ? " \u26A0 OVERRIDES
|
|
7820
|
+
const source = d.startsWith(this.userDir) && !d.includes(".upstream") ? "user" : "upstream";
|
|
7821
|
+
const overrideWarning = existed && source === "user" ? " \u26A0 OVERRIDES upstream" : "";
|
|
6077
7822
|
this.log(` ${existed ? "\u{1F504}" : "\u2705"} ${mod.type} (${mod.category}) \u2014 ${mod.name} [${source}]${overrideWarning}`);
|
|
6078
7823
|
}
|
|
6079
7824
|
} catch (e) {
|
|
@@ -6120,9 +7865,9 @@ var init_provider_loader = __esm({
|
|
|
6120
7865
|
}
|
|
6121
7866
|
}
|
|
6122
7867
|
compareVersions(a, b2) {
|
|
6123
|
-
const
|
|
6124
|
-
const pa2 =
|
|
6125
|
-
const pb =
|
|
7868
|
+
const normalize3 = (v2) => v2.split(/[-_+]/)[0].split(".").map((x) => parseInt(x, 10) || 0);
|
|
7869
|
+
const pa2 = normalize3(a);
|
|
7870
|
+
const pb = normalize3(b2);
|
|
6126
7871
|
for (let i = 0; i < Math.max(pa2.length, pb.length); i++) {
|
|
6127
7872
|
const va2 = pa2[i] || 0;
|
|
6128
7873
|
const vb = pb[i] || 0;
|
|
@@ -6166,17 +7911,17 @@ async function findFreePort(ports) {
|
|
|
6166
7911
|
throw new Error("No free port found");
|
|
6167
7912
|
}
|
|
6168
7913
|
function checkPortFree(port) {
|
|
6169
|
-
return new Promise((
|
|
7914
|
+
return new Promise((resolve10) => {
|
|
6170
7915
|
const server = net.createServer();
|
|
6171
7916
|
server.unref();
|
|
6172
|
-
server.on("error", () =>
|
|
7917
|
+
server.on("error", () => resolve10(false));
|
|
6173
7918
|
server.listen(port, "127.0.0.1", () => {
|
|
6174
|
-
server.close(() =>
|
|
7919
|
+
server.close(() => resolve10(true));
|
|
6175
7920
|
});
|
|
6176
7921
|
});
|
|
6177
7922
|
}
|
|
6178
7923
|
async function isCdpActive(port) {
|
|
6179
|
-
return new Promise((
|
|
7924
|
+
return new Promise((resolve10) => {
|
|
6180
7925
|
const req = require("http").get(`http://127.0.0.1:${port}/json/version`, {
|
|
6181
7926
|
timeout: 2e3
|
|
6182
7927
|
}, (res) => {
|
|
@@ -6185,16 +7930,16 @@ async function isCdpActive(port) {
|
|
|
6185
7930
|
res.on("end", () => {
|
|
6186
7931
|
try {
|
|
6187
7932
|
const info = JSON.parse(data);
|
|
6188
|
-
|
|
7933
|
+
resolve10(!!info["WebKit-Version"] || !!info["Browser"]);
|
|
6189
7934
|
} catch {
|
|
6190
|
-
|
|
7935
|
+
resolve10(false);
|
|
6191
7936
|
}
|
|
6192
7937
|
});
|
|
6193
7938
|
});
|
|
6194
|
-
req.on("error", () =>
|
|
7939
|
+
req.on("error", () => resolve10(false));
|
|
6195
7940
|
req.on("timeout", () => {
|
|
6196
7941
|
req.destroy();
|
|
6197
|
-
|
|
7942
|
+
resolve10(false);
|
|
6198
7943
|
});
|
|
6199
7944
|
});
|
|
6200
7945
|
}
|
|
@@ -6539,8 +8284,8 @@ function cleanOldFiles() {
|
|
|
6539
8284
|
}
|
|
6540
8285
|
function checkSize() {
|
|
6541
8286
|
try {
|
|
6542
|
-
const
|
|
6543
|
-
if (
|
|
8287
|
+
const stat4 = fs6.statSync(currentFile);
|
|
8288
|
+
if (stat4.size > MAX_FILE_SIZE) {
|
|
6544
8289
|
const backup = currentFile.replace(".jsonl", ".1.jsonl");
|
|
6545
8290
|
try {
|
|
6546
8291
|
fs6.unlinkSync(backup);
|
|
@@ -16523,9 +18268,9 @@ var init_provider_cli_adapter = __esm({
|
|
|
16523
18268
|
const platformArch = `${os12.platform()}-${os12.arch()}`;
|
|
16524
18269
|
const helper = path9.join(ptyDir, "prebuilds", platformArch, "spawn-helper");
|
|
16525
18270
|
if (fs13.existsSync(helper)) {
|
|
16526
|
-
const
|
|
16527
|
-
if (!(
|
|
16528
|
-
fs13.chmodSync(helper,
|
|
18271
|
+
const stat4 = fs13.statSync(helper);
|
|
18272
|
+
if (!(stat4.mode & 73)) {
|
|
18273
|
+
fs13.chmodSync(helper, stat4.mode | 493);
|
|
16529
18274
|
LOG.info("CLI", "[node-pty] Fixed spawn-helper permissions");
|
|
16530
18275
|
}
|
|
16531
18276
|
}
|
|
@@ -16588,6 +18333,8 @@ var init_provider_cli_adapter = __esm({
|
|
|
16588
18333
|
spawnAt = 0;
|
|
16589
18334
|
// PTY I/O
|
|
16590
18335
|
onPtyDataCallback = null;
|
|
18336
|
+
pendingOutputParseBuffer = "";
|
|
18337
|
+
pendingOutputParseTimer = null;
|
|
16591
18338
|
ptyOutputBuffer = "";
|
|
16592
18339
|
ptyOutputFlushTimer = null;
|
|
16593
18340
|
// Server log forwarding
|
|
@@ -16683,6 +18430,16 @@ var init_provider_cli_adapter = __esm({
|
|
|
16683
18430
|
setOnPtyData(callback) {
|
|
16684
18431
|
this.onPtyDataCallback = callback;
|
|
16685
18432
|
}
|
|
18433
|
+
flushPendingOutputParse() {
|
|
18434
|
+
if (this.pendingOutputParseTimer) {
|
|
18435
|
+
clearTimeout(this.pendingOutputParseTimer);
|
|
18436
|
+
this.pendingOutputParseTimer = null;
|
|
18437
|
+
}
|
|
18438
|
+
if (!this.pendingOutputParseBuffer) return;
|
|
18439
|
+
const rawData = this.pendingOutputParseBuffer;
|
|
18440
|
+
this.pendingOutputParseBuffer = "";
|
|
18441
|
+
this.handleOutput(rawData);
|
|
18442
|
+
}
|
|
16686
18443
|
async spawn() {
|
|
16687
18444
|
if (this.ptyProcess) return;
|
|
16688
18445
|
if (!pty) throw new Error("node-pty is not installed");
|
|
@@ -16731,7 +18488,17 @@ var init_provider_cli_adapter = __esm({
|
|
|
16731
18488
|
}
|
|
16732
18489
|
}
|
|
16733
18490
|
this.ptyProcess.onData((data) => {
|
|
16734
|
-
|
|
18491
|
+
if (Date.now() < this.resizeSuppressUntil) return;
|
|
18492
|
+
if (data.includes("\x1B[6n") || data.includes("\x1B[?6n")) {
|
|
18493
|
+
this.ptyProcess?.write("\x1B[1;1R");
|
|
18494
|
+
}
|
|
18495
|
+
this.pendingOutputParseBuffer += data;
|
|
18496
|
+
if (!this.pendingOutputParseTimer) {
|
|
18497
|
+
this.pendingOutputParseTimer = setTimeout(() => {
|
|
18498
|
+
this.pendingOutputParseTimer = null;
|
|
18499
|
+
this.flushPendingOutputParse();
|
|
18500
|
+
}, this.timeouts.ptyFlush);
|
|
18501
|
+
}
|
|
16735
18502
|
if (this.onPtyDataCallback) {
|
|
16736
18503
|
this.ptyOutputBuffer += data;
|
|
16737
18504
|
if (!this.ptyOutputFlushTimer) {
|
|
@@ -16747,6 +18514,7 @@ var init_provider_cli_adapter = __esm({
|
|
|
16747
18514
|
});
|
|
16748
18515
|
this.ptyProcess.onExit(({ exitCode }) => {
|
|
16749
18516
|
LOG.info("CLI", `[${this.cliType}] Exit code ${exitCode}`);
|
|
18517
|
+
this.flushPendingOutputParse();
|
|
16750
18518
|
this.ptyProcess = null;
|
|
16751
18519
|
this.setStatus("stopped", "pty_exit");
|
|
16752
18520
|
this.ready = false;
|
|
@@ -16766,10 +18534,6 @@ var init_provider_cli_adapter = __esm({
|
|
|
16766
18534
|
}
|
|
16767
18535
|
// ─── Output Handling ────────────────────────────
|
|
16768
18536
|
handleOutput(rawData) {
|
|
16769
|
-
if (Date.now() < this.resizeSuppressUntil) return;
|
|
16770
|
-
if (rawData.includes("\x1B[6n") || rawData.includes("\x1B[?6n")) {
|
|
16771
|
-
this.ptyProcess?.write("\x1B[1;1R");
|
|
16772
|
-
}
|
|
16773
18537
|
this.terminalScreen.write(rawData);
|
|
16774
18538
|
this.terminalHistory = mergeTerminalHistory(this.terminalHistory, this.terminalScreen.getText());
|
|
16775
18539
|
const cleanData = stripAnsi(rawData);
|
|
@@ -17120,7 +18884,7 @@ ${data.message || ""}`.trim();
|
|
|
17120
18884
|
if (this.startupParseGate) {
|
|
17121
18885
|
const deadline = Date.now() + 1e4;
|
|
17122
18886
|
while (this.startupParseGate && Date.now() < deadline) {
|
|
17123
|
-
await new Promise((
|
|
18887
|
+
await new Promise((resolve10) => setTimeout(resolve10, 50));
|
|
17124
18888
|
}
|
|
17125
18889
|
}
|
|
17126
18890
|
if (!this.ready) throw new Error(`${this.cliName} not ready (status: ${this.currentStatus})`);
|
|
@@ -17257,6 +19021,16 @@ ${data.message || ""}`.trim();
|
|
|
17257
19021
|
clearTimeout(this.submitRetryTimer);
|
|
17258
19022
|
this.submitRetryTimer = null;
|
|
17259
19023
|
}
|
|
19024
|
+
if (this.pendingOutputParseTimer) {
|
|
19025
|
+
clearTimeout(this.pendingOutputParseTimer);
|
|
19026
|
+
this.pendingOutputParseTimer = null;
|
|
19027
|
+
}
|
|
19028
|
+
this.pendingOutputParseBuffer = "";
|
|
19029
|
+
if (this.ptyOutputFlushTimer) {
|
|
19030
|
+
clearTimeout(this.ptyOutputFlushTimer);
|
|
19031
|
+
this.ptyOutputFlushTimer = null;
|
|
19032
|
+
}
|
|
19033
|
+
this.ptyOutputBuffer = "";
|
|
17260
19034
|
if (this.ptyProcess) {
|
|
17261
19035
|
this.ptyProcess.write("");
|
|
17262
19036
|
setTimeout(() => {
|
|
@@ -17282,6 +19056,16 @@ ${data.message || ""}`.trim();
|
|
|
17282
19056
|
this.currentTurnScope = null;
|
|
17283
19057
|
this.submitRetryUsed = false;
|
|
17284
19058
|
this.submitRetryPromptSnippet = "";
|
|
19059
|
+
if (this.pendingOutputParseTimer) {
|
|
19060
|
+
clearTimeout(this.pendingOutputParseTimer);
|
|
19061
|
+
this.pendingOutputParseTimer = null;
|
|
19062
|
+
}
|
|
19063
|
+
this.pendingOutputParseBuffer = "";
|
|
19064
|
+
if (this.ptyOutputFlushTimer) {
|
|
19065
|
+
clearTimeout(this.ptyOutputFlushTimer);
|
|
19066
|
+
this.ptyOutputFlushTimer = null;
|
|
19067
|
+
}
|
|
19068
|
+
this.ptyOutputBuffer = "";
|
|
17285
19069
|
this.terminalScreen.reset();
|
|
17286
19070
|
this.onStatusChange?.();
|
|
17287
19071
|
}
|
|
@@ -17359,6 +19143,8 @@ ${data.message || ""}`.trim();
|
|
|
17359
19143
|
scriptNames: Object.keys(this.cliScripts).filter((k) => typeof this.cliScripts[k] === "function"),
|
|
17360
19144
|
statusHistory: this.statusHistory.slice(-30),
|
|
17361
19145
|
timeouts: this.timeouts,
|
|
19146
|
+
pendingOutputParseBufferLength: this.pendingOutputParseBuffer.length,
|
|
19147
|
+
pendingOutputParseScheduled: !!this.pendingOutputParseTimer,
|
|
17362
19148
|
ptyAlive: !!this.ptyProcess
|
|
17363
19149
|
};
|
|
17364
19150
|
}
|
|
@@ -33663,8 +35449,8 @@ var init_acp = __esm({
|
|
|
33663
35449
|
this.#requestHandler = requestHandler;
|
|
33664
35450
|
this.#notificationHandler = notificationHandler;
|
|
33665
35451
|
this.#stream = stream;
|
|
33666
|
-
this.#closedPromise = new Promise((
|
|
33667
|
-
this.#abortController.signal.addEventListener("abort", () =>
|
|
35452
|
+
this.#closedPromise = new Promise((resolve10) => {
|
|
35453
|
+
this.#abortController.signal.addEventListener("abort", () => resolve10());
|
|
33668
35454
|
});
|
|
33669
35455
|
this.#receive();
|
|
33670
35456
|
}
|
|
@@ -33813,8 +35599,8 @@ var init_acp = __esm({
|
|
|
33813
35599
|
}
|
|
33814
35600
|
async sendRequest(method, params) {
|
|
33815
35601
|
const id = this.#nextRequestId++;
|
|
33816
|
-
const responsePromise = new Promise((
|
|
33817
|
-
this.#pendingResponses.set(id, { resolve:
|
|
35602
|
+
const responsePromise = new Promise((resolve10, reject) => {
|
|
35603
|
+
this.#pendingResponses.set(id, { resolve: resolve10, reject });
|
|
33818
35604
|
});
|
|
33819
35605
|
await this.#sendMessage({ jsonrpc: "2.0", id, method, params });
|
|
33820
35606
|
return responsePromise;
|
|
@@ -34346,13 +36132,13 @@ var init_acp_provider_instance = __esm({
|
|
|
34346
36132
|
}
|
|
34347
36133
|
this.currentStatus = "waiting_approval";
|
|
34348
36134
|
this.detectStatusTransition();
|
|
34349
|
-
const approved = await new Promise((
|
|
34350
|
-
this.permissionResolvers.push(
|
|
36135
|
+
const approved = await new Promise((resolve10) => {
|
|
36136
|
+
this.permissionResolvers.push(resolve10);
|
|
34351
36137
|
setTimeout(() => {
|
|
34352
|
-
const idx = this.permissionResolvers.indexOf(
|
|
36138
|
+
const idx = this.permissionResolvers.indexOf(resolve10);
|
|
34353
36139
|
if (idx >= 0) {
|
|
34354
36140
|
this.permissionResolvers.splice(idx, 1);
|
|
34355
|
-
|
|
36141
|
+
resolve10(false);
|
|
34356
36142
|
}
|
|
34357
36143
|
}, 3e5);
|
|
34358
36144
|
});
|
|
@@ -36544,15 +38330,15 @@ var init_dev_server = __esm({
|
|
|
36544
38330
|
this.json(res, 500, { error: e.message });
|
|
36545
38331
|
}
|
|
36546
38332
|
});
|
|
36547
|
-
return new Promise((
|
|
38333
|
+
return new Promise((resolve10, reject) => {
|
|
36548
38334
|
this.server.listen(port, "127.0.0.1", () => {
|
|
36549
38335
|
this.log(`Dev server listening on http://127.0.0.1:${port}`);
|
|
36550
|
-
|
|
38336
|
+
resolve10();
|
|
36551
38337
|
});
|
|
36552
38338
|
this.server.on("error", (e) => {
|
|
36553
38339
|
if (e.code === "EADDRINUSE") {
|
|
36554
38340
|
this.log(`Port ${port} in use, skipping dev server`);
|
|
36555
|
-
|
|
38341
|
+
resolve10();
|
|
36556
38342
|
} else {
|
|
36557
38343
|
reject(e);
|
|
36558
38344
|
}
|
|
@@ -36635,20 +38421,20 @@ var init_dev_server = __esm({
|
|
|
36635
38421
|
child.stderr?.on("data", (d) => {
|
|
36636
38422
|
stderr += d.toString().slice(0, 2e3);
|
|
36637
38423
|
});
|
|
36638
|
-
await new Promise((
|
|
38424
|
+
await new Promise((resolve10) => {
|
|
36639
38425
|
const timer = setTimeout(() => {
|
|
36640
38426
|
child.kill();
|
|
36641
|
-
|
|
38427
|
+
resolve10();
|
|
36642
38428
|
}, 3e3);
|
|
36643
38429
|
child.on("exit", () => {
|
|
36644
38430
|
clearTimeout(timer);
|
|
36645
|
-
|
|
38431
|
+
resolve10();
|
|
36646
38432
|
});
|
|
36647
38433
|
child.stdout?.once("data", () => {
|
|
36648
38434
|
setTimeout(() => {
|
|
36649
38435
|
child.kill();
|
|
36650
38436
|
clearTimeout(timer);
|
|
36651
|
-
|
|
38437
|
+
resolve10();
|
|
36652
38438
|
}, 500);
|
|
36653
38439
|
});
|
|
36654
38440
|
});
|
|
@@ -37075,8 +38861,8 @@ var init_dev_server = __esm({
|
|
|
37075
38861
|
files.push({ path: rel, size: 0, type: "dir" });
|
|
37076
38862
|
scan(path12.join(d, entry.name), rel);
|
|
37077
38863
|
} else {
|
|
37078
|
-
const
|
|
37079
|
-
files.push({ path: rel, size:
|
|
38864
|
+
const stat4 = fs10.statSync(path12.join(d, entry.name));
|
|
38865
|
+
files.push({ path: rel, size: stat4.size, type: "file" });
|
|
37080
38866
|
}
|
|
37081
38867
|
}
|
|
37082
38868
|
} catch {
|
|
@@ -37392,14 +39178,14 @@ var init_dev_server = __esm({
|
|
|
37392
39178
|
child.stderr?.on("data", (d) => {
|
|
37393
39179
|
stderr += d.toString();
|
|
37394
39180
|
});
|
|
37395
|
-
await new Promise((
|
|
39181
|
+
await new Promise((resolve10) => {
|
|
37396
39182
|
const timer = setTimeout(() => {
|
|
37397
39183
|
child.kill();
|
|
37398
|
-
|
|
39184
|
+
resolve10();
|
|
37399
39185
|
}, timeout);
|
|
37400
39186
|
child.on("exit", () => {
|
|
37401
39187
|
clearTimeout(timer);
|
|
37402
|
-
|
|
39188
|
+
resolve10();
|
|
37403
39189
|
});
|
|
37404
39190
|
});
|
|
37405
39191
|
const elapsed = Date.now() - start;
|
|
@@ -38243,25 +40029,63 @@ var init_dev_server = __esm({
|
|
|
38243
40029
|
const ref = this.providerLoader.resolve(desired) || this.providerLoader.getMeta(desired);
|
|
38244
40030
|
if (ref?.category === category) return desired;
|
|
38245
40031
|
const all = this.providerLoader.getAll();
|
|
38246
|
-
const fallback = all.
|
|
40032
|
+
const fallback = all.filter((p) => p.category === category && p.type !== targetType).sort((a, b2) => String(a.type || "").localeCompare(String(b2.type || ""), void 0, { numeric: true, sensitivity: "base" }))[0];
|
|
38247
40033
|
return fallback?.type || null;
|
|
38248
40034
|
}
|
|
38249
|
-
|
|
38250
|
-
if (!
|
|
38251
|
-
const refDir = this.providerLoader.getUpstreamProviderDir(category, referenceType);
|
|
38252
|
-
if (!fs10.existsSync(refDir)) return {};
|
|
38253
|
-
const referenceScripts = {};
|
|
38254
|
-
const scriptsDir = path12.join(refDir, "scripts");
|
|
38255
|
-
if (!fs10.existsSync(scriptsDir)) return referenceScripts;
|
|
40035
|
+
getLatestScriptVersionDir(scriptsDir) {
|
|
40036
|
+
if (!fs10.existsSync(scriptsDir)) return null;
|
|
38256
40037
|
const versions = fs10.readdirSync(scriptsDir).filter((d) => {
|
|
38257
40038
|
try {
|
|
38258
40039
|
return fs10.statSync(path12.join(scriptsDir, d)).isDirectory();
|
|
38259
40040
|
} catch {
|
|
38260
40041
|
return false;
|
|
38261
40042
|
}
|
|
38262
|
-
}).sort().
|
|
38263
|
-
if (versions.length === 0) return
|
|
38264
|
-
|
|
40043
|
+
}).sort((a, b2) => b2.localeCompare(a, void 0, { numeric: true, sensitivity: "base" }));
|
|
40044
|
+
if (versions.length === 0) return null;
|
|
40045
|
+
return path12.join(scriptsDir, versions[0]);
|
|
40046
|
+
}
|
|
40047
|
+
resolveAutoImplWritableProviderDir(category, type, requestedDir) {
|
|
40048
|
+
const canonicalUserDir = path12.resolve(this.providerLoader.getUserProviderDir(category, type));
|
|
40049
|
+
const desiredDir = requestedDir ? path12.resolve(requestedDir) : canonicalUserDir;
|
|
40050
|
+
if (desiredDir !== canonicalUserDir) {
|
|
40051
|
+
return null;
|
|
40052
|
+
}
|
|
40053
|
+
const userRoot = path12.resolve(this.providerLoader.getUserDir());
|
|
40054
|
+
if (desiredDir !== userRoot && !desiredDir.startsWith(`${userRoot}${path12.sep}`)) {
|
|
40055
|
+
return null;
|
|
40056
|
+
}
|
|
40057
|
+
const sourceDir = this.findProviderDir(type);
|
|
40058
|
+
if (!sourceDir) {
|
|
40059
|
+
return null;
|
|
40060
|
+
}
|
|
40061
|
+
if (!fs10.existsSync(desiredDir)) {
|
|
40062
|
+
fs10.mkdirSync(path12.dirname(desiredDir), { recursive: true });
|
|
40063
|
+
fs10.cpSync(sourceDir, desiredDir, { recursive: true });
|
|
40064
|
+
this.log(`Auto-implement writable copy created: ${desiredDir}`);
|
|
40065
|
+
}
|
|
40066
|
+
const providerJson = path12.join(desiredDir, "provider.json");
|
|
40067
|
+
if (!fs10.existsSync(providerJson)) {
|
|
40068
|
+
return null;
|
|
40069
|
+
}
|
|
40070
|
+
try {
|
|
40071
|
+
const providerData = JSON.parse(fs10.readFileSync(providerJson, "utf-8"));
|
|
40072
|
+
if (providerData.disableUpstream !== true) {
|
|
40073
|
+
providerData.disableUpstream = true;
|
|
40074
|
+
fs10.writeFileSync(providerJson, JSON.stringify(providerData, null, 2));
|
|
40075
|
+
}
|
|
40076
|
+
} catch {
|
|
40077
|
+
return null;
|
|
40078
|
+
}
|
|
40079
|
+
return desiredDir;
|
|
40080
|
+
}
|
|
40081
|
+
loadAutoImplReferenceScripts(referenceType) {
|
|
40082
|
+
if (!referenceType) return {};
|
|
40083
|
+
const refDir = this.findProviderDir(referenceType);
|
|
40084
|
+
if (!refDir || !fs10.existsSync(refDir)) return {};
|
|
40085
|
+
const referenceScripts = {};
|
|
40086
|
+
const scriptsDir = path12.join(refDir, "scripts");
|
|
40087
|
+
const latestDir = this.getLatestScriptVersionDir(scriptsDir);
|
|
40088
|
+
if (!latestDir) return referenceScripts;
|
|
38265
40089
|
for (const file2 of fs10.readdirSync(latestDir)) {
|
|
38266
40090
|
if (!file2.endsWith(".js")) continue;
|
|
38267
40091
|
try {
|
|
@@ -38273,7 +40097,7 @@ var init_dev_server = __esm({
|
|
|
38273
40097
|
}
|
|
38274
40098
|
async handleAutoImplement(type, req, res) {
|
|
38275
40099
|
const body = await this.readBody(req);
|
|
38276
|
-
const { agent = "claude-cli", functions, reference
|
|
40100
|
+
const { agent = "claude-cli", functions, reference, model, comment, providerDir: requestedProviderDir } = body;
|
|
38277
40101
|
if (!functions || !Array.isArray(functions) || functions.length === 0) {
|
|
38278
40102
|
this.json(res, 400, { error: 'functions[] is required (e.g. ["readChat", "sendMessage"])' });
|
|
38279
40103
|
return;
|
|
@@ -38287,9 +40111,11 @@ var init_dev_server = __esm({
|
|
|
38287
40111
|
this.json(res, 404, { error: `Provider not found: ${type}` });
|
|
38288
40112
|
return;
|
|
38289
40113
|
}
|
|
38290
|
-
const providerDir = this.
|
|
40114
|
+
const providerDir = this.resolveAutoImplWritableProviderDir(provider.category, type, requestedProviderDir);
|
|
38291
40115
|
if (!providerDir) {
|
|
38292
|
-
this.json(res,
|
|
40116
|
+
this.json(res, 409, {
|
|
40117
|
+
error: `Auto-implement only writes to the canonical user provider directory for '${type}'.`
|
|
40118
|
+
});
|
|
38293
40119
|
return;
|
|
38294
40120
|
}
|
|
38295
40121
|
try {
|
|
@@ -38311,7 +40137,7 @@ var init_dev_server = __esm({
|
|
|
38311
40137
|
message: `Loading reference script (${resolvedReference || "none"})...`
|
|
38312
40138
|
}
|
|
38313
40139
|
});
|
|
38314
|
-
const referenceScripts = this.loadAutoImplReferenceScripts(
|
|
40140
|
+
const referenceScripts = this.loadAutoImplReferenceScripts(resolvedReference);
|
|
38315
40141
|
const prompt = this.buildAutoImplPrompt(type, provider, providerDir, functions, domContext, referenceScripts, comment, resolvedReference);
|
|
38316
40142
|
const tmpDir = path12.join(os15.tmpdir(), "adhdev-autoimpl");
|
|
38317
40143
|
if (!fs10.existsSync(tmpDir)) fs10.mkdirSync(tmpDir, { recursive: true });
|
|
@@ -38333,7 +40159,7 @@ var init_dev_server = __esm({
|
|
|
38333
40159
|
this.sendAutoImplSSE({ event: "progress", data: { function: "_init", status: "spawning", message: `Spawning ACP agent: ${spawn3.command} ${(spawn3.args || []).join(" ")}` } });
|
|
38334
40160
|
this.autoImplStatus = { running: true, type, progress: [] };
|
|
38335
40161
|
const { ClientSideConnection: ClientSideConnection2, ndJsonStream: ndJsonStream2, PROTOCOL_VERSION: PROTOCOL_VERSION2 } = await Promise.resolve().then(() => (init_acp(), acp_exports));
|
|
38336
|
-
const { Readable:
|
|
40162
|
+
const { Readable: Readable3, Writable: Writable2 } = await import("stream");
|
|
38337
40163
|
const { spawn: spawnFn2 } = await import("child_process");
|
|
38338
40164
|
const acpArgs = [...spawn3.args || []];
|
|
38339
40165
|
if (model) {
|
|
@@ -38352,7 +40178,7 @@ var init_dev_server = __esm({
|
|
|
38352
40178
|
this.sendAutoImplSSE({ event: "output", data: { chunk, stream: "stderr" } });
|
|
38353
40179
|
});
|
|
38354
40180
|
const webStdin = Writable2.toWeb(child2.stdin);
|
|
38355
|
-
const webStdout =
|
|
40181
|
+
const webStdout = Readable3.toWeb(child2.stdout);
|
|
38356
40182
|
const stream = ndJsonStream2(webStdin, webStdout);
|
|
38357
40183
|
const connection = new ClientSideConnection2((_agent) => ({
|
|
38358
40184
|
// Auto-approve all tool calls for auto-implement
|
|
@@ -38667,29 +40493,20 @@ var init_dev_server = __esm({
|
|
|
38667
40493
|
lines.push("These are the files you need to EDIT. They contain TODO stubs \u2014 replace them with working implementations.");
|
|
38668
40494
|
lines.push("");
|
|
38669
40495
|
const scriptsDir = path12.join(providerDir, "scripts");
|
|
38670
|
-
|
|
38671
|
-
|
|
38672
|
-
|
|
38673
|
-
|
|
38674
|
-
|
|
38675
|
-
|
|
38676
|
-
|
|
38677
|
-
|
|
38678
|
-
|
|
38679
|
-
|
|
38680
|
-
|
|
38681
|
-
|
|
38682
|
-
|
|
38683
|
-
|
|
38684
|
-
try {
|
|
38685
|
-
const content = fs10.readFileSync(path12.join(vDir, file2), "utf-8");
|
|
38686
|
-
lines.push(`### \`${file2}\``);
|
|
38687
|
-
lines.push("```javascript");
|
|
38688
|
-
lines.push(content);
|
|
38689
|
-
lines.push("```");
|
|
38690
|
-
lines.push("");
|
|
38691
|
-
} catch {
|
|
38692
|
-
}
|
|
40496
|
+
const latestScriptsDir = this.getLatestScriptVersionDir(scriptsDir);
|
|
40497
|
+
if (latestScriptsDir) {
|
|
40498
|
+
lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
|
|
40499
|
+
lines.push("");
|
|
40500
|
+
for (const file2 of fs10.readdirSync(latestScriptsDir)) {
|
|
40501
|
+
if (file2.endsWith(".js")) {
|
|
40502
|
+
try {
|
|
40503
|
+
const content = fs10.readFileSync(path12.join(latestScriptsDir, file2), "utf-8");
|
|
40504
|
+
lines.push(`### \`${file2}\``);
|
|
40505
|
+
lines.push("```javascript");
|
|
40506
|
+
lines.push(content);
|
|
40507
|
+
lines.push("```");
|
|
40508
|
+
lines.push("");
|
|
40509
|
+
} catch {
|
|
38693
40510
|
}
|
|
38694
40511
|
}
|
|
38695
40512
|
}
|
|
@@ -38770,7 +40587,7 @@ var init_dev_server = __esm({
|
|
|
38770
40587
|
lines.push("## Rules");
|
|
38771
40588
|
lines.push("1. **Scripts WITHOUT params** \u2192 IIFE: `(() => { ... })()`");
|
|
38772
40589
|
lines.push("2. **Scripts WITH params** \u2192 arrow: `(params) => { ... }` \u2014 router calls `(${script})(${JSON.stringify(params)})`");
|
|
38773
|
-
lines.push("3.
|
|
40590
|
+
lines.push("3. If live DOM analysis is included above, use it. Otherwise, discover selectors yourself via CDP before coding.");
|
|
38774
40591
|
lines.push("4. Always wrap in try-catch, return `JSON.stringify(result)`");
|
|
38775
40592
|
lines.push("5. Do NOT modify `scripts.js` router \u2014 only edit individual `*.js` files");
|
|
38776
40593
|
lines.push("6. All scripts run in the browser (CDP evaluate) \u2014 use DOM APIs only");
|
|
@@ -38819,8 +40636,12 @@ var init_dev_server = __esm({
|
|
|
38819
40636
|
lines.push(" - `listSessions`: If sessions are unmounted when the panel is closed, try to explicitly interact with the UI to open the history/sessions view (e.g., clicking a history icon usually found near the chat header) BEFORE scraping.");
|
|
38820
40637
|
lines.push(" - `switchSession`: Prove your switch was successful by subsequently calling `readChat` and explicitly checking that the chat context has actually changed.");
|
|
38821
40638
|
lines.push("");
|
|
38822
|
-
lines.push("##
|
|
38823
|
-
|
|
40639
|
+
lines.push("## DOM Exploration");
|
|
40640
|
+
if (domContext) {
|
|
40641
|
+
lines.push("A lightweight DOM snapshot is included above, but you MUST still verify selectors yourself before finalizing the scripts.");
|
|
40642
|
+
} else {
|
|
40643
|
+
lines.push("No DOM snapshot is included here. You MUST use your command-line tools to discover the IDE structure dynamically.");
|
|
40644
|
+
}
|
|
38824
40645
|
lines.push("");
|
|
38825
40646
|
lines.push("### 1. Evaluate JS to explore IDE DOM");
|
|
38826
40647
|
lines.push("Use cURL to run JavaScript inside the IDE:");
|
|
@@ -38907,29 +40728,20 @@ var init_dev_server = __esm({
|
|
|
38907
40728
|
lines.push("These are the files you need to edit. Replace TODO or heuristic-only logic with working PTY-aware implementations.");
|
|
38908
40729
|
lines.push("");
|
|
38909
40730
|
const scriptsDir = path12.join(providerDir, "scripts");
|
|
38910
|
-
|
|
38911
|
-
|
|
40731
|
+
const latestScriptsDir = this.getLatestScriptVersionDir(scriptsDir);
|
|
40732
|
+
if (latestScriptsDir) {
|
|
40733
|
+
lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
|
|
40734
|
+
lines.push("");
|
|
40735
|
+
for (const file2 of fs10.readdirSync(latestScriptsDir)) {
|
|
40736
|
+
if (!file2.endsWith(".js")) continue;
|
|
38912
40737
|
try {
|
|
38913
|
-
|
|
40738
|
+
const content = fs10.readFileSync(path12.join(latestScriptsDir, file2), "utf-8");
|
|
40739
|
+
lines.push(`### \`${file2}\``);
|
|
40740
|
+
lines.push("```javascript");
|
|
40741
|
+
lines.push(content);
|
|
40742
|
+
lines.push("```");
|
|
40743
|
+
lines.push("");
|
|
38914
40744
|
} catch {
|
|
38915
|
-
return false;
|
|
38916
|
-
}
|
|
38917
|
-
}).sort().reverse();
|
|
38918
|
-
if (versions.length > 0) {
|
|
38919
|
-
const vDir = path12.join(scriptsDir, versions[0]);
|
|
38920
|
-
lines.push(`Scripts version directory: \`${vDir}\``);
|
|
38921
|
-
lines.push("");
|
|
38922
|
-
for (const file2 of fs10.readdirSync(vDir)) {
|
|
38923
|
-
if (!file2.endsWith(".js")) continue;
|
|
38924
|
-
try {
|
|
38925
|
-
const content = fs10.readFileSync(path12.join(vDir, file2), "utf-8");
|
|
38926
|
-
lines.push(`### \`${file2}\``);
|
|
38927
|
-
lines.push("```javascript");
|
|
38928
|
-
lines.push(content);
|
|
38929
|
-
lines.push("```");
|
|
38930
|
-
lines.push("");
|
|
38931
|
-
} catch {
|
|
38932
|
-
}
|
|
38933
40745
|
}
|
|
38934
40746
|
}
|
|
38935
40747
|
}
|
|
@@ -39143,14 +40955,14 @@ data: ${JSON.stringify(msg.data)}
|
|
|
39143
40955
|
res.end(JSON.stringify(data, null, 2));
|
|
39144
40956
|
}
|
|
39145
40957
|
async readBody(req) {
|
|
39146
|
-
return new Promise((
|
|
40958
|
+
return new Promise((resolve10) => {
|
|
39147
40959
|
let body = "";
|
|
39148
40960
|
req.on("data", (chunk) => body += chunk);
|
|
39149
40961
|
req.on("end", () => {
|
|
39150
40962
|
try {
|
|
39151
|
-
|
|
40963
|
+
resolve10(JSON.parse(body));
|
|
39152
40964
|
} catch {
|
|
39153
|
-
|
|
40965
|
+
resolve10({});
|
|
39154
40966
|
}
|
|
39155
40967
|
});
|
|
39156
40968
|
});
|
|
@@ -39586,6 +41398,7 @@ var init_daemon_lifecycle = __esm({
|
|
|
39586
41398
|
init_provider_loader();
|
|
39587
41399
|
init_version_archive();
|
|
39588
41400
|
init_provider_instance_manager();
|
|
41401
|
+
init_dev_server();
|
|
39589
41402
|
init_ide_detector();
|
|
39590
41403
|
init_logger();
|
|
39591
41404
|
init_config();
|
|
@@ -40079,13 +41892,13 @@ ${e?.stack || ""}`);
|
|
|
40079
41892
|
} catch {
|
|
40080
41893
|
}
|
|
40081
41894
|
const http3 = esmRequire("https");
|
|
40082
|
-
const data = await new Promise((
|
|
41895
|
+
const data = await new Promise((resolve10, reject) => {
|
|
40083
41896
|
const req = http3.get(`${serverUrl}/api/v1/turn/credentials`, {
|
|
40084
41897
|
headers: { "Authorization": `Bearer ${token}` }
|
|
40085
41898
|
}, (res) => {
|
|
40086
41899
|
let d = "";
|
|
40087
41900
|
res.on("data", (c) => d += c);
|
|
40088
|
-
res.on("end", () =>
|
|
41901
|
+
res.on("end", () => resolve10(d));
|
|
40089
41902
|
});
|
|
40090
41903
|
req.on("error", reject);
|
|
40091
41904
|
req.setTimeout(5e3, () => {
|
|
@@ -40941,7 +42754,7 @@ var init_adhdev_daemon = __esm({
|
|
|
40941
42754
|
fs12 = __toESM(require("fs"));
|
|
40942
42755
|
path14 = __toESM(require("path"));
|
|
40943
42756
|
import_chalk2 = __toESM(require("chalk"));
|
|
40944
|
-
pkgVersion = "0.6.
|
|
42757
|
+
pkgVersion = "0.6.75";
|
|
40945
42758
|
if (pkgVersion === "unknown") {
|
|
40946
42759
|
try {
|
|
40947
42760
|
const possiblePaths = [
|
|
@@ -41166,7 +42979,7 @@ ${err?.stack || ""}`);
|
|
|
41166
42979
|
this.running = true;
|
|
41167
42980
|
process.on("SIGINT", () => this.stop());
|
|
41168
42981
|
process.on("SIGTERM", () => this.stop());
|
|
41169
|
-
if (options.dev) {
|
|
42982
|
+
if (options.dev && this.components) {
|
|
41170
42983
|
const devServer = new DevServer({
|
|
41171
42984
|
providerLoader: this.components.providerLoader,
|
|
41172
42985
|
cdpManagers: this.components.cdpManagers,
|
|
@@ -41759,6 +43572,9 @@ async function installCliOnly() {
|
|
|
41759
43572
|
});
|
|
41760
43573
|
/*! Bundled license information:
|
|
41761
43574
|
|
|
43575
|
+
chokidar/index.js:
|
|
43576
|
+
(*! chokidar - MIT License (c) 2012 Paul Miller (paulmillr.com) *)
|
|
43577
|
+
|
|
41762
43578
|
@xterm/xterm/lib/xterm.mjs:
|
|
41763
43579
|
(**
|
|
41764
43580
|
* Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
|