@pensar/apex 2.2.0 → 2.3.0-canary.f43660dd
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/build/{agent-q5hwjdtb.js → agent-54zbjp5g.js} +9 -9
- package/build/agent-dmfqxetq.js +19 -0
- package/build/{agent-yayy5x2a.js → agent-nr5eq27w.js} +7 -7
- package/build/{apps-0es69e2s.js → apps-yhq3vem2.js} +16 -16
- package/build/{auth-q73k9bh9.js → auth-kag9cbnd.js} +32 -39
- package/build/authentication-hx4920t3.js +19 -0
- package/build/blackboxAgent-ga9cc2sv.js +19 -0
- package/build/{blackboxPentest-h28nykk5.js → blackboxPentest-hac0kjq7.js} +14 -14
- package/build/{cli-7n43wz82.js → cli-0cw9k1tw.js} +4 -2
- package/build/{cli-2jn8104w.js → cli-3m2x8w2t.js} +2 -2
- package/build/{cli-s43t5ay0.js → cli-5b7x19aa.js} +1 -1
- package/build/{cli-vgg6h2ax.js → cli-5dj8fc52.js} +1 -1
- package/build/{cli-tz9yg4ew.js → cli-5vskcg6x.js} +8 -8
- package/build/{cli-1cf5vy5m.js → cli-8nmjfxpb.js} +58 -26
- package/build/{cli-51dkmt5p.js → cli-bpd40kwt.js} +1 -1
- package/build/{cli-7e5ad5js.js → cli-c5e9y4f7.js} +2 -2
- package/build/{cli-knqx15w6.js → cli-crbamax1.js} +2 -2
- package/build/{cli-ptzy9ak5.js → cli-ez994rr8.js} +1 -1
- package/build/{cli-n114n8mk.js → cli-jz6ak250.js} +2 -2
- package/build/{cli-1re2kv5v.js → cli-kkkxevak.js} +3 -3
- package/build/{cli-6kx46ck0.js → cli-kpabqavj.js} +19 -6
- package/build/{cli-4tc6888c.js → cli-mg5hqzfk.js} +51 -2
- package/build/{cli-1f636vzd.js → cli-nw87xhd7.js} +1 -1
- package/build/{cli-xbdn034b.js → cli-tzaxpbx8.js} +3983 -55
- package/build/{cli-xpn9tsw0.js → cli-y177s333.js} +3 -3
- package/build/cli.js +33 -33
- package/build/{config-xcf7rc6x.js → config-ejqssj7v.js} +3 -3
- package/build/{doctor-98zperf9.js → doctor-nq5j5b3n.js} +6 -6
- package/build/{fastStrike-9tm6bedh.js → fastStrike-r2nnp14k.js} +9 -9
- package/build/{fixes-1dry8j61.js → fixes-1k92rcye.js} +16 -16
- package/build/{index-6dbym5jy.js → index-dgskmca6.js} +21 -8
- package/build/{index-4hqbyzf5.js → index-emkkrdxh.js} +8 -8
- package/build/{index-pxwwcefn.js → index-fxdwg3rg.js} +9 -9
- package/build/{index-34h2nb6x.js → index-mdnk1yy1.js} +3 -3
- package/build/{index-31rwrakh.js → index-q0e883cx.js} +2 -2
- package/build/{index-f6ttv7np.js → index-qcvh5me4.js} +9 -5
- package/build/{index-0j880wqc.js → index-qgw3yp85.js} +1080 -898
- package/build/{issues-wjakj8yy.js → issues-vnk8x7da.js} +44 -16
- package/build/{logs-ewyzcspy.js → logs-rr9fwq7m.js} +16 -16
- package/build/{offesecAgent-7m9smy0t.js → offesecAgent-1sw6kh7y.js} +8 -8
- package/build/pentest-rks9g0xv.js +29 -0
- package/build/{pentests-1hcqjyk2.js → pentests-6kpja9cc.js} +16 -16
- package/build/{targetedPentest-3x13kqvc.js → targetedPentest-v3vyanfw.js} +9 -9
- package/build/{targets-nqz8w37e.js → targets-6h670bhe.js} +16 -16
- package/build/threatModel-gqpa574g.js +27 -0
- package/build/{uninstall-p1q5pkx2.js → uninstall-1vyfsbab.js} +1 -1
- package/build/{upload-x7etpfp4.js → upload-kaqk0rnk.js} +6 -6
- package/build/{utils-kw6yh5yn.js → utils-6gqkfbv5.js} +5 -5
- package/package.json +1 -1
- package/build/agent-3cdfwxcd.js +0 -19
- package/build/authentication-tqx2brcv.js +0 -19
- package/build/blackboxAgent-d0smgqt7.js +0 -19
- package/build/pentest-1cb5t0dt.js +0 -29
- package/build/threatModel-7f02av7y.js +0 -27
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
detectOSAndEnhancePrompt
|
|
3
|
-
} from "./cli-
|
|
3
|
+
} from "./cli-5b7x19aa.js";
|
|
4
4
|
import {
|
|
5
5
|
parseTargetUrl
|
|
6
6
|
} from "./cli-c8131c4q.js";
|
|
@@ -32,14 +32,14 @@ import {
|
|
|
32
32
|
streamResponse,
|
|
33
33
|
withSubagentSessionBaggage,
|
|
34
34
|
write
|
|
35
|
-
} from "./cli-
|
|
35
|
+
} from "./cli-kpabqavj.js";
|
|
36
36
|
import {
|
|
37
37
|
ensureValidToken,
|
|
38
38
|
getPensarApiUrl,
|
|
39
39
|
init_auth,
|
|
40
40
|
init_constants,
|
|
41
41
|
signGatewayRequest
|
|
42
|
-
} from "./cli-
|
|
42
|
+
} from "./cli-mg5hqzfk.js";
|
|
43
43
|
import {
|
|
44
44
|
_enum,
|
|
45
45
|
_null,
|
|
@@ -70,7 +70,7 @@ import {
|
|
|
70
70
|
import {
|
|
71
71
|
config,
|
|
72
72
|
init_config
|
|
73
|
-
} from "./cli-
|
|
73
|
+
} from "./cli-bpd40kwt.js";
|
|
74
74
|
import {
|
|
75
75
|
__commonJS,
|
|
76
76
|
__require,
|
|
@@ -106376,24 +106376,27 @@ function getTaskSummary(tasksDir, preloaded) {
|
|
|
106376
106376
|
|
|
106377
106377
|
// src/core/agents/offSecAgent/tools/createTask.ts
|
|
106378
106378
|
var createTaskInputSchema = exports_external.object({
|
|
106379
|
-
subject: exports_external.string().describe("Short subject line for the task (e.g., 'Test /api/users id param for UNION-based SQLi')"),
|
|
106380
|
-
description: exports_external.string().describe("Detailed description of what to
|
|
106381
|
-
objective: exports_external.string().describe("
|
|
106382
|
-
technique: exports_external.string().describe("
|
|
106383
|
-
metadata: exports_external.record(exports_external.string(), exports_external.unknown()).optional().describe("Optional metadata (e.g
|
|
106379
|
+
subject: exports_external.string().describe("Short subject line for the task (e.g., 'Apply parameterized query fix in login handler', 'Test /api/users id param for UNION-based SQLi')"),
|
|
106380
|
+
description: exports_external.string().describe("Detailed description of the work — for coding: what to change and how to verify; for testing: payloads, encoding strategies, or bypass techniques"),
|
|
106381
|
+
objective: exports_external.string().optional().describe("Optional higher-level objective this task addresses (e.g. a pentest objective or 'Fix SQL injection in auth'). Defaults to the subject when omitted."),
|
|
106382
|
+
technique: exports_external.string().optional().describe("Optional technique or approach label (e.g. 'parameterized queries', 'UNION-based SQL injection'). Defaults to 'general' when omitted."),
|
|
106383
|
+
metadata: exports_external.record(exports_external.string(), exports_external.unknown()).optional().describe("Optional metadata (e.g. { priority: 'high', file: 'src/auth.ts', endpoint: '/api/users' })")
|
|
106384
106384
|
});
|
|
106385
106385
|
function createTask2(ctx) {
|
|
106386
106386
|
return tool({
|
|
106387
|
-
description: `Create a
|
|
106387
|
+
description: `Create a task to track your work.
|
|
106388
106388
|
|
|
106389
|
-
|
|
106389
|
+
Use tasks as a lightweight todo list: decompose the job into concrete, atomic steps, create them early, and update status as you go.
|
|
106390
106390
|
|
|
106391
|
-
|
|
106391
|
+
Works for both coding agents (patch/fix/verify steps) and pentest agents (technique × endpoint tests).
|
|
106392
|
+
|
|
106393
|
+
Call this BEFORE you start substantive work to build your task list. Add more mid-run when you discover extra work.
|
|
106392
106394
|
|
|
106393
106395
|
Examples of good tasks:
|
|
106394
|
-
- "
|
|
106395
|
-
- "
|
|
106396
|
-
- "
|
|
106396
|
+
- "Read vulnerable login handler and related DB helpers"
|
|
106397
|
+
- "Apply parameterized query fix in src/auth/login.ts"
|
|
106398
|
+
- "Run lint, typecheck, and unit tests"
|
|
106399
|
+
- "Test /api/users id parameter for error-based SQL injection"`,
|
|
106397
106400
|
inputSchema: createTaskInputSchema,
|
|
106398
106401
|
execute: async ({
|
|
106399
106402
|
subject,
|
|
@@ -106412,8 +106415,8 @@ Examples of good tasks:
|
|
|
106412
106415
|
const task = createTask(ctx.tasksDir, {
|
|
106413
106416
|
subject,
|
|
106414
106417
|
description,
|
|
106415
|
-
objective,
|
|
106416
|
-
technique,
|
|
106418
|
+
objective: objective ?? subject,
|
|
106419
|
+
technique: technique ?? "general",
|
|
106417
106420
|
metadata
|
|
106418
106421
|
});
|
|
106419
106422
|
ctx.traceWriter?.appendTaskRecord({
|
|
@@ -106613,7 +106616,7 @@ IMPORTANT: Pass protectedEndpoints in authHints when you've discovered 401/403 e
|
|
|
106613
106616
|
if (credentials) {
|
|
106614
106617
|
ctx.session.credentialManager.addFromAuthCredentials(credentials);
|
|
106615
106618
|
}
|
|
106616
|
-
const { runAuthenticationAgent } = await import("./authentication-
|
|
106619
|
+
const { runAuthenticationAgent } = await import("./authentication-hx4920t3.js");
|
|
106617
106620
|
const localBus = new AgentEventBus;
|
|
106618
106621
|
AgentEventBus.attachChild(localBus, ctx.eventBus, subagentId);
|
|
106619
106622
|
const result = await runAuthenticationAgent({
|
|
@@ -107404,7 +107407,7 @@ async function generateThreatModelForEndpoint(ctx, input) {
|
|
|
107404
107407
|
return threatModelLimiter(async () => {
|
|
107405
107408
|
if (ctx.abortSignal?.aborted)
|
|
107406
107409
|
return null;
|
|
107407
|
-
const { CodeAgent } = await import("./agent-
|
|
107410
|
+
const { CodeAgent } = await import("./agent-dmfqxetq.js");
|
|
107408
107411
|
const subagentId = newSessionId();
|
|
107409
107412
|
const subagentName = `Threat Model: ${input.routePath}`;
|
|
107410
107413
|
ctx.eventBus?.emit("subagent-spawn", {
|
|
@@ -109327,7 +109330,7 @@ init_lazyLogger();
|
|
|
109327
109330
|
var log6 = scopedLogger(() => createLogger("FindingJudge"));
|
|
109328
109331
|
async function judgeFinding(input, ctx) {
|
|
109329
109332
|
try {
|
|
109330
|
-
const { FindingJudgeAgent } = await import("./agent-
|
|
109333
|
+
const { FindingJudgeAgent } = await import("./agent-nr5eq27w.js");
|
|
109331
109334
|
const agent = new FindingJudgeAgent({
|
|
109332
109335
|
finding: input,
|
|
109333
109336
|
model: ctx.model,
|
|
@@ -112327,6 +112330,8 @@ function createEmailAdapter(inbox) {
|
|
|
112327
112330
|
return new OutlookAdapter(inbox.accessToken, inbox.refreshToken, inbox.clientId, inbox.clientSecret);
|
|
112328
112331
|
case "imap":
|
|
112329
112332
|
return new ImapAdapter(inbox);
|
|
112333
|
+
case "http":
|
|
112334
|
+
return new HttpAdapter(inbox);
|
|
112330
112335
|
default:
|
|
112331
112336
|
throw new Error(`Unsupported email provider: ${inbox.provider}`);
|
|
112332
112337
|
}
|
|
@@ -112942,6 +112947,65 @@ function truncate(s, max) {
|
|
|
112942
112947
|
(truncated)` : s;
|
|
112943
112948
|
}
|
|
112944
112949
|
|
|
112950
|
+
class HttpAdapter {
|
|
112951
|
+
endpoint;
|
|
112952
|
+
token;
|
|
112953
|
+
address;
|
|
112954
|
+
constructor(inbox) {
|
|
112955
|
+
this.endpoint = inbox.endpoint.replace(/\/+$/, "");
|
|
112956
|
+
this.token = inbox.token;
|
|
112957
|
+
this.address = inbox.emailAddress;
|
|
112958
|
+
}
|
|
112959
|
+
async get(path, params) {
|
|
112960
|
+
const url = new URL(`${this.endpoint}${path}`);
|
|
112961
|
+
if (params) {
|
|
112962
|
+
for (const [key, value] of Object.entries(params)) {
|
|
112963
|
+
url.searchParams.set(key, value);
|
|
112964
|
+
}
|
|
112965
|
+
}
|
|
112966
|
+
const res = await fetch(url, {
|
|
112967
|
+
headers: { Authorization: `Bearer ${this.token}` }
|
|
112968
|
+
});
|
|
112969
|
+
if (!res.ok) {
|
|
112970
|
+
throw new Error(`Mailbox HTTP error ${res.status} ${res.statusText} for ${path}`);
|
|
112971
|
+
}
|
|
112972
|
+
return await res.json();
|
|
112973
|
+
}
|
|
112974
|
+
async listMessages(opts) {
|
|
112975
|
+
const params = { address: this.address };
|
|
112976
|
+
if (opts.maxResults !== undefined)
|
|
112977
|
+
params.limit = String(opts.maxResults);
|
|
112978
|
+
if (opts.pageToken)
|
|
112979
|
+
params.cursor = opts.pageToken;
|
|
112980
|
+
const data = await this.get("/messages", params);
|
|
112981
|
+
return { messages: data.messages, nextPageToken: data.nextCursor };
|
|
112982
|
+
}
|
|
112983
|
+
async searchMessages(opts) {
|
|
112984
|
+
const params = {
|
|
112985
|
+
address: this.address,
|
|
112986
|
+
q: opts.query
|
|
112987
|
+
};
|
|
112988
|
+
if (opts.maxResults !== undefined)
|
|
112989
|
+
params.limit = String(opts.maxResults);
|
|
112990
|
+
if (opts.pageToken)
|
|
112991
|
+
params.cursor = opts.pageToken;
|
|
112992
|
+
const data = await this.get("/messages", params);
|
|
112993
|
+
return { messages: data.messages, nextPageToken: data.nextCursor };
|
|
112994
|
+
}
|
|
112995
|
+
async getMessage(messageId, _folder) {
|
|
112996
|
+
return this.get(`/messages/${encodeURIComponent(messageId)}`);
|
|
112997
|
+
}
|
|
112998
|
+
async getAttachments(_messageId, _folder) {
|
|
112999
|
+
return [];
|
|
113000
|
+
}
|
|
113001
|
+
async getAttachmentContent(_messageId, _attachmentId, _folder) {
|
|
113002
|
+
throw new Error("Attachments are not supported by the http mailbox provider");
|
|
113003
|
+
}
|
|
113004
|
+
markAsRead(_messageId, _folder) {
|
|
113005
|
+
return Promise.resolve();
|
|
113006
|
+
}
|
|
113007
|
+
}
|
|
113008
|
+
|
|
112945
113009
|
// src/core/agents/offSecAgent/tools/email/getMessage.ts
|
|
112946
113010
|
function emailGetMessage(ctx) {
|
|
112947
113011
|
return tool({
|
|
@@ -115892,7 +115956,7 @@ should be passed directly to spawn_pentest_swarm for deep testing.`,
|
|
|
115892
115956
|
});
|
|
115893
115957
|
if (cwd) {
|
|
115894
115958
|
try {
|
|
115895
|
-
const { WhiteboxAttackSurfaceAgent } = await import("./index-
|
|
115959
|
+
const { WhiteboxAttackSurfaceAgent } = await import("./index-fxdwg3rg.js");
|
|
115896
115960
|
const localBus = new AgentEventBus;
|
|
115897
115961
|
AgentEventBus.attachChild(localBus, ctx.eventBus, subagentId);
|
|
115898
115962
|
const agent = new WhiteboxAttackSurfaceAgent({
|
|
@@ -115947,7 +116011,7 @@ should be passed directly to spawn_pentest_swarm for deep testing.`,
|
|
|
115947
116011
|
}
|
|
115948
116012
|
}
|
|
115949
116013
|
try {
|
|
115950
|
-
const { BlackboxAttackSurfaceAgent } = await import("./blackboxAgent-
|
|
116014
|
+
const { BlackboxAttackSurfaceAgent } = await import("./blackboxAgent-ga9cc2sv.js");
|
|
115951
116015
|
const localBus = new AgentEventBus;
|
|
115952
116016
|
AgentEventBus.attachChild(localBus, ctx.eventBus, subagentId);
|
|
115953
116017
|
const agent = new BlackboxAttackSurfaceAgent({
|
|
@@ -116025,7 +116089,7 @@ Omit \`cwd\` for blackbox mode (live target probing only).`,
|
|
|
116025
116089
|
toolCallDescription: exports_external.string().describe("A concise, human-readable description of what this tool call is doing")
|
|
116026
116090
|
}),
|
|
116027
116091
|
execute: async ({ target, cwd }) => {
|
|
116028
|
-
const { runPentestWorkflow: workflow } = await import("./pentest-
|
|
116092
|
+
const { runPentestWorkflow: workflow } = await import("./pentest-rks9g0xv.js");
|
|
116029
116093
|
if (!ctx.model) {
|
|
116030
116094
|
return {
|
|
116031
116095
|
success: false,
|
|
@@ -117603,7 +117667,7 @@ Returns an array of results with the text output from each agent.`,
|
|
|
117603
117667
|
});
|
|
117604
117668
|
}
|
|
117605
117669
|
async function runSingleCodingAgent(ctx, codebasePath, objective, agentIndex, name) {
|
|
117606
|
-
const { CodeAgent } = await import("./agent-
|
|
117670
|
+
const { CodeAgent } = await import("./agent-dmfqxetq.js");
|
|
117607
117671
|
const childSessionId = newSessionId();
|
|
117608
117672
|
const subagentId = childSessionId;
|
|
117609
117673
|
ctx.eventBus?.emit("subagent-spawn", {
|
|
@@ -118120,7 +118184,7 @@ Returns the worker's summary, objective results, and finding count — but NOT t
|
|
|
118120
118184
|
message: "spawn_pentest_agent requires a model in the tool context."
|
|
118121
118185
|
};
|
|
118122
118186
|
}
|
|
118123
|
-
const { TargetedPentestAgent } = await import("./agent-
|
|
118187
|
+
const { TargetedPentestAgent } = await import("./agent-54zbjp5g.js");
|
|
118124
118188
|
const findingsRegistry = ctx.findingsRegistry ?? FindingsRegistry.fromDirectory(ctx.session.findingsPath, {
|
|
118125
118189
|
model: ctx.model,
|
|
118126
118190
|
authConfig: ctx.authConfig,
|
|
@@ -118254,7 +118318,7 @@ Pass every target you want tested — the swarm handles concurrency automaticall
|
|
|
118254
118318
|
toolCallDescription: exports_external.string().describe("A concise, human-readable description of what this tool call is doing")
|
|
118255
118319
|
}),
|
|
118256
118320
|
execute: async ({ targets }) => {
|
|
118257
|
-
const { runPentestSwarm, DEFAULT_CONCURRENCY: DEFAULT_CONCURRENCY2 } = await import("./pentest-
|
|
118321
|
+
const { runPentestSwarm, DEFAULT_CONCURRENCY: DEFAULT_CONCURRENCY2 } = await import("./pentest-rks9g0xv.js");
|
|
118258
118322
|
if (!ctx.model) {
|
|
118259
118323
|
return {
|
|
118260
118324
|
success: false,
|
|
@@ -118938,6 +119002,3857 @@ Required plan sections:
|
|
|
118938
119002
|
}
|
|
118939
119003
|
});
|
|
118940
119004
|
}
|
|
119005
|
+
// src/core/agents/offSecAgent/tools/applyPatch.ts
|
|
119006
|
+
init_dist();
|
|
119007
|
+
init_zod();
|
|
119008
|
+
import { mkdir as mkdir4, readFile as readFile7, unlink, writeFile as writeFile6 } from "node:fs/promises";
|
|
119009
|
+
import { dirname as dirname7, isAbsolute as isAbsolute7, relative as relative5, resolve as resolve8 } from "node:path";
|
|
119010
|
+
var applyPatchInputSchema = exports_external.object({
|
|
119011
|
+
patch: exports_external.string().describe("Unified diff to apply. May contain one or more file hunks (---/+++/@@). Paths are relative to the agent working directory unless absolute."),
|
|
119012
|
+
toolCallDescription: exports_external.string().describe("A concise, human-readable description of what this tool call is doing (e.g., 'Apply parameterized-query fix across auth handlers')")
|
|
119013
|
+
});
|
|
119014
|
+
function stripPrefix(p) {
|
|
119015
|
+
if (p.startsWith("a/") || p.startsWith("b/"))
|
|
119016
|
+
return p.slice(2);
|
|
119017
|
+
return p;
|
|
119018
|
+
}
|
|
119019
|
+
function parseUnifiedDiff(patch) {
|
|
119020
|
+
const lines = patch.replace(/\r\n/g, `
|
|
119021
|
+
`).split(`
|
|
119022
|
+
`);
|
|
119023
|
+
const files = [];
|
|
119024
|
+
let i = 0;
|
|
119025
|
+
while (i < lines.length) {
|
|
119026
|
+
while (i < lines.length && !lines[i].startsWith("--- ") && !lines[i].startsWith("diff --git ")) {
|
|
119027
|
+
i++;
|
|
119028
|
+
}
|
|
119029
|
+
if (i >= lines.length)
|
|
119030
|
+
break;
|
|
119031
|
+
if (lines[i].startsWith("diff --git ")) {
|
|
119032
|
+
i++;
|
|
119033
|
+
continue;
|
|
119034
|
+
}
|
|
119035
|
+
const oldLine = lines[i];
|
|
119036
|
+
if (!oldLine.startsWith("--- ")) {
|
|
119037
|
+
throw new Error(`Expected "---" file header at line ${i + 1}`);
|
|
119038
|
+
}
|
|
119039
|
+
i++;
|
|
119040
|
+
if (i >= lines.length || !lines[i].startsWith("+++ ")) {
|
|
119041
|
+
throw new Error(`Expected "+++" file header after "---" at line ${i}`);
|
|
119042
|
+
}
|
|
119043
|
+
const newLine = lines[i];
|
|
119044
|
+
i++;
|
|
119045
|
+
const oldPathRaw = oldLine.slice(4).split("\t")[0].trim();
|
|
119046
|
+
const newPathRaw = newLine.slice(4).split("\t")[0].trim();
|
|
119047
|
+
const isNew = oldPathRaw === "/dev/null";
|
|
119048
|
+
const isDelete = newPathRaw === "/dev/null";
|
|
119049
|
+
const oldPath = isNew ? "" : stripPrefix(oldPathRaw);
|
|
119050
|
+
const newPath = isDelete ? "" : stripPrefix(newPathRaw);
|
|
119051
|
+
const hunks = [];
|
|
119052
|
+
while (i < lines.length && lines[i].startsWith("@@ ")) {
|
|
119053
|
+
const header = lines[i];
|
|
119054
|
+
const match = /^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/.exec(header);
|
|
119055
|
+
if (!match) {
|
|
119056
|
+
throw new Error(`Malformed hunk header: ${header}`);
|
|
119057
|
+
}
|
|
119058
|
+
i++;
|
|
119059
|
+
const hunkLines = [];
|
|
119060
|
+
while (i < lines.length && !lines[i].startsWith("@@ ") && !lines[i].startsWith("--- ") && !lines[i].startsWith("diff --git ")) {
|
|
119061
|
+
const l = lines[i];
|
|
119062
|
+
if (l.startsWith(" ") || l.startsWith("+") || l.startsWith("-") || l === "\") {
|
|
119063
|
+
hunkLines.push(l);
|
|
119064
|
+
i++;
|
|
119065
|
+
} else if (l === "") {
|
|
119066
|
+
break;
|
|
119067
|
+
} else {
|
|
119068
|
+
throw new Error(`Unexpected line in hunk: ${l}`);
|
|
119069
|
+
}
|
|
119070
|
+
}
|
|
119071
|
+
hunks.push({
|
|
119072
|
+
oldStart: Number(match[1]),
|
|
119073
|
+
oldCount: match[2] !== undefined ? Number(match[2]) : 1,
|
|
119074
|
+
newStart: Number(match[3]),
|
|
119075
|
+
newCount: match[4] !== undefined ? Number(match[4]) : 1,
|
|
119076
|
+
lines: hunkLines
|
|
119077
|
+
});
|
|
119078
|
+
}
|
|
119079
|
+
if (hunks.length === 0 && !isNew && !isDelete) {
|
|
119080
|
+
throw new Error(`No hunks found for file ${newPath || oldPath || "(unknown)"}`);
|
|
119081
|
+
}
|
|
119082
|
+
files.push({ oldPath, newPath, hunks, isNew, isDelete });
|
|
119083
|
+
}
|
|
119084
|
+
if (files.length === 0) {
|
|
119085
|
+
throw new Error("Patch contained no file diffs");
|
|
119086
|
+
}
|
|
119087
|
+
return files;
|
|
119088
|
+
}
|
|
119089
|
+
function resolveUnderCwd(agentCwd, filePath) {
|
|
119090
|
+
const resolved = isAbsolute7(filePath) ? filePath : resolve8(agentCwd, filePath);
|
|
119091
|
+
const rel = relative5(agentCwd, resolved);
|
|
119092
|
+
if (rel.startsWith("..") || isAbsolute7(rel)) {
|
|
119093
|
+
throw new Error(`Path escapes agent working directory: ${filePath}`);
|
|
119094
|
+
}
|
|
119095
|
+
return resolved;
|
|
119096
|
+
}
|
|
119097
|
+
function applyHunksToContent(content, hunks) {
|
|
119098
|
+
const endsWithNewline = content.endsWith(`
|
|
119099
|
+
`);
|
|
119100
|
+
const lines = content === "" ? [] : content.endsWith(`
|
|
119101
|
+
`) ? content.slice(0, -1).split(`
|
|
119102
|
+
`) : content.split(`
|
|
119103
|
+
`);
|
|
119104
|
+
const ordered = [...hunks].sort((a, b) => b.oldStart - a.oldStart);
|
|
119105
|
+
for (const hunk of ordered) {
|
|
119106
|
+
const startIdx = Math.max(0, hunk.oldStart - 1);
|
|
119107
|
+
let cursor = startIdx;
|
|
119108
|
+
const replacement = [];
|
|
119109
|
+
for (const raw of hunk.lines) {
|
|
119110
|
+
if (raw === "\")
|
|
119111
|
+
continue;
|
|
119112
|
+
const tag = raw[0];
|
|
119113
|
+
const text = raw.slice(1);
|
|
119114
|
+
if (tag === " " || tag === "-") {
|
|
119115
|
+
if (cursor >= lines.length || lines[cursor] !== text) {
|
|
119116
|
+
const actual = cursor < lines.length ? lines[cursor] : "<EOF>";
|
|
119117
|
+
throw new Error(`Hunk context mismatch at line ${cursor + 1}: expected ${JSON.stringify(text)}, got ${JSON.stringify(actual)}`);
|
|
119118
|
+
}
|
|
119119
|
+
if (tag === " ") {
|
|
119120
|
+
replacement.push(text);
|
|
119121
|
+
}
|
|
119122
|
+
cursor++;
|
|
119123
|
+
} else if (tag === "+") {
|
|
119124
|
+
replacement.push(text);
|
|
119125
|
+
} else {
|
|
119126
|
+
throw new Error(`Invalid hunk line prefix: ${raw}`);
|
|
119127
|
+
}
|
|
119128
|
+
}
|
|
119129
|
+
const endIdx = cursor;
|
|
119130
|
+
lines.splice(startIdx, endIdx - startIdx, ...replacement);
|
|
119131
|
+
}
|
|
119132
|
+
if (lines.length === 0)
|
|
119133
|
+
return endsWithNewline ? `
|
|
119134
|
+
` : "";
|
|
119135
|
+
return `${lines.join(`
|
|
119136
|
+
`)}
|
|
119137
|
+
`;
|
|
119138
|
+
}
|
|
119139
|
+
async function readLocal(path) {
|
|
119140
|
+
try {
|
|
119141
|
+
return await readFile7(path, "utf-8");
|
|
119142
|
+
} catch {
|
|
119143
|
+
return null;
|
|
119144
|
+
}
|
|
119145
|
+
}
|
|
119146
|
+
async function writeLocal(path, content) {
|
|
119147
|
+
await mkdir4(dirname7(path), { recursive: true });
|
|
119148
|
+
await writeFile6(path, content, "utf-8");
|
|
119149
|
+
}
|
|
119150
|
+
async function readViaSandbox(sandbox, path) {
|
|
119151
|
+
const result = await sandbox.execute(`test -f "${path}" && cat "${path}" | base64 -w 0`);
|
|
119152
|
+
if (!result.success || !result.stdout.trim()) {
|
|
119153
|
+
const exists = await sandbox.execute(`test -f "${path}"`);
|
|
119154
|
+
if (exists.exitCode !== 0)
|
|
119155
|
+
return null;
|
|
119156
|
+
return "";
|
|
119157
|
+
}
|
|
119158
|
+
return Buffer.from(result.stdout.trim(), "base64").toString("utf-8");
|
|
119159
|
+
}
|
|
119160
|
+
async function writeViaSandbox(sandbox, path, content) {
|
|
119161
|
+
const dir = dirname7(path);
|
|
119162
|
+
await sandbox.execute(`mkdir -p "${dir}"`);
|
|
119163
|
+
const b64 = Buffer.from(content).toString("base64");
|
|
119164
|
+
const result = await sandbox.execute(`echo "${b64}" | base64 -d > "${path}"`);
|
|
119165
|
+
if (!result.success) {
|
|
119166
|
+
throw new Error(result.stderr || `Failed to write ${path} in sandbox`);
|
|
119167
|
+
}
|
|
119168
|
+
}
|
|
119169
|
+
async function deleteViaSandbox(sandbox, path) {
|
|
119170
|
+
const result = await sandbox.execute(`rm "${path}"`);
|
|
119171
|
+
if (!result.success) {
|
|
119172
|
+
throw new Error(result.stderr || `Failed to delete ${path} in sandbox`);
|
|
119173
|
+
}
|
|
119174
|
+
}
|
|
119175
|
+
function applyPatch(ctx) {
|
|
119176
|
+
return tool({
|
|
119177
|
+
description: `Apply a unified diff patch to one or more files.
|
|
119178
|
+
|
|
119179
|
+
Use this for multi-hunk or multi-file edits. For a single small string replace,
|
|
119180
|
+
prefer update_file.
|
|
119181
|
+
|
|
119182
|
+
The patch must be a standard unified diff with ---/+++ headers and @@ hunks.
|
|
119183
|
+
Context lines must match the current file contents exactly — the tool fails
|
|
119184
|
+
loudly on mismatch and does not partially apply remaining files after a failure
|
|
119185
|
+
within a file. Paths must stay under the agent working directory.
|
|
119186
|
+
|
|
119187
|
+
Example:
|
|
119188
|
+
\`\`\`
|
|
119189
|
+
--- a/src/auth.ts
|
|
119190
|
+
+++ b/src/auth.ts
|
|
119191
|
+
@@ -10,7 +10,7 @@
|
|
119192
|
+
function login(user, pass) {
|
|
119193
|
+
- query = "SELECT * FROM users WHERE name='" + user + "'"
|
|
119194
|
+
+ query = db.prepare("SELECT * FROM users WHERE name=?")
|
|
119195
|
+
}
|
|
119196
|
+
\`\`\``,
|
|
119197
|
+
inputSchema: applyPatchInputSchema,
|
|
119198
|
+
execute: async ({ patch }) => {
|
|
119199
|
+
let files;
|
|
119200
|
+
try {
|
|
119201
|
+
files = parseUnifiedDiff(patch);
|
|
119202
|
+
} catch (err) {
|
|
119203
|
+
return {
|
|
119204
|
+
success: false,
|
|
119205
|
+
error: err instanceof Error ? err.message : String(err),
|
|
119206
|
+
files: []
|
|
119207
|
+
};
|
|
119208
|
+
}
|
|
119209
|
+
const results = [];
|
|
119210
|
+
for (const file of files) {
|
|
119211
|
+
const displayPath = file.newPath || file.oldPath;
|
|
119212
|
+
try {
|
|
119213
|
+
const targetPath = resolveUnderCwd(ctx.agentCwd, file.isDelete ? file.oldPath : file.newPath || file.oldPath);
|
|
119214
|
+
if (file.isDelete) {
|
|
119215
|
+
if (ctx.sandbox) {
|
|
119216
|
+
await deleteViaSandbox(ctx.sandbox, targetPath);
|
|
119217
|
+
} else {
|
|
119218
|
+
await unlink(targetPath);
|
|
119219
|
+
}
|
|
119220
|
+
results.push({
|
|
119221
|
+
path: displayPath,
|
|
119222
|
+
success: true,
|
|
119223
|
+
hunksApplied: 0
|
|
119224
|
+
});
|
|
119225
|
+
continue;
|
|
119226
|
+
}
|
|
119227
|
+
const existing = ctx.sandbox ? await readViaSandbox(ctx.sandbox, targetPath) : await readLocal(targetPath);
|
|
119228
|
+
if (file.isNew) {
|
|
119229
|
+
if (existing !== null) {
|
|
119230
|
+
throw new Error(`Cannot create ${targetPath}: file already exists`);
|
|
119231
|
+
}
|
|
119232
|
+
const created = applyHunksToContent("", file.hunks);
|
|
119233
|
+
if (ctx.sandbox) {
|
|
119234
|
+
await writeViaSandbox(ctx.sandbox, targetPath, created);
|
|
119235
|
+
} else {
|
|
119236
|
+
await writeLocal(targetPath, created);
|
|
119237
|
+
}
|
|
119238
|
+
results.push({
|
|
119239
|
+
path: displayPath,
|
|
119240
|
+
success: true,
|
|
119241
|
+
hunksApplied: file.hunks.length
|
|
119242
|
+
});
|
|
119243
|
+
continue;
|
|
119244
|
+
}
|
|
119245
|
+
if (existing === null) {
|
|
119246
|
+
throw new Error(`File not found: ${targetPath}`);
|
|
119247
|
+
}
|
|
119248
|
+
const updated = applyHunksToContent(existing, file.hunks);
|
|
119249
|
+
if (ctx.sandbox) {
|
|
119250
|
+
await writeViaSandbox(ctx.sandbox, targetPath, updated);
|
|
119251
|
+
} else {
|
|
119252
|
+
await writeLocal(targetPath, updated);
|
|
119253
|
+
}
|
|
119254
|
+
results.push({
|
|
119255
|
+
path: displayPath,
|
|
119256
|
+
success: true,
|
|
119257
|
+
hunksApplied: file.hunks.length
|
|
119258
|
+
});
|
|
119259
|
+
} catch (err) {
|
|
119260
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
119261
|
+
results.push({
|
|
119262
|
+
path: displayPath,
|
|
119263
|
+
success: false,
|
|
119264
|
+
error: message
|
|
119265
|
+
});
|
|
119266
|
+
return {
|
|
119267
|
+
success: false,
|
|
119268
|
+
error: `Failed applying patch to ${displayPath}: ${message}`,
|
|
119269
|
+
files: results
|
|
119270
|
+
};
|
|
119271
|
+
}
|
|
119272
|
+
}
|
|
119273
|
+
return {
|
|
119274
|
+
success: true,
|
|
119275
|
+
error: "",
|
|
119276
|
+
files: results
|
|
119277
|
+
};
|
|
119278
|
+
}
|
|
119279
|
+
});
|
|
119280
|
+
}
|
|
119281
|
+
// src/core/agents/offSecAgent/tools/deleteFile.ts
|
|
119282
|
+
init_dist();
|
|
119283
|
+
init_zod();
|
|
119284
|
+
import { unlink as unlink2 } from "node:fs/promises";
|
|
119285
|
+
import { isAbsolute as isAbsolute8, relative as relative6, resolve as resolve9 } from "node:path";
|
|
119286
|
+
var deleteFileInputSchema = exports_external.object({
|
|
119287
|
+
path: exports_external.string().describe("Absolute or relative path to the file to delete"),
|
|
119288
|
+
toolCallDescription: exports_external.string().describe("A concise, human-readable description of what this tool call is doing (e.g., 'Remove obsolete insecure helper')")
|
|
119289
|
+
});
|
|
119290
|
+
function resolveUnderCwd2(agentCwd, filePath) {
|
|
119291
|
+
const resolved = isAbsolute8(filePath) ? filePath : resolve9(agentCwd, filePath);
|
|
119292
|
+
const rel = relative6(agentCwd, resolved);
|
|
119293
|
+
if (rel.startsWith("..") || isAbsolute8(rel)) {
|
|
119294
|
+
throw new Error(`Path escapes agent working directory: ${filePath}`);
|
|
119295
|
+
}
|
|
119296
|
+
return resolved;
|
|
119297
|
+
}
|
|
119298
|
+
function deleteFile(ctx) {
|
|
119299
|
+
return tool({
|
|
119300
|
+
description: `Delete a file from the filesystem.
|
|
119301
|
+
|
|
119302
|
+
Only deletes files (not directories). Path must stay within the agent working directory.
|
|
119303
|
+
Fails loudly if the file does not exist.`,
|
|
119304
|
+
inputSchema: deleteFileInputSchema,
|
|
119305
|
+
execute: async ({ path: filePath }) => {
|
|
119306
|
+
let target;
|
|
119307
|
+
try {
|
|
119308
|
+
target = resolveUnderCwd2(ctx.agentCwd, filePath);
|
|
119309
|
+
} catch (err) {
|
|
119310
|
+
return {
|
|
119311
|
+
success: false,
|
|
119312
|
+
error: err instanceof Error ? err.message : String(err),
|
|
119313
|
+
path: filePath
|
|
119314
|
+
};
|
|
119315
|
+
}
|
|
119316
|
+
if (ctx.sandbox) {
|
|
119317
|
+
try {
|
|
119318
|
+
const check = await ctx.sandbox.execute(`test -f "${target}"`);
|
|
119319
|
+
if (check.exitCode !== 0) {
|
|
119320
|
+
return {
|
|
119321
|
+
success: false,
|
|
119322
|
+
error: `File not found: ${target}`,
|
|
119323
|
+
path: target
|
|
119324
|
+
};
|
|
119325
|
+
}
|
|
119326
|
+
const result = await ctx.sandbox.execute(`rm "${target}"`);
|
|
119327
|
+
if (!result.success) {
|
|
119328
|
+
return {
|
|
119329
|
+
success: false,
|
|
119330
|
+
error: result.stderr || "Failed to delete file in sandbox",
|
|
119331
|
+
path: target
|
|
119332
|
+
};
|
|
119333
|
+
}
|
|
119334
|
+
return { success: true, error: "", path: target };
|
|
119335
|
+
} catch (err) {
|
|
119336
|
+
return {
|
|
119337
|
+
success: false,
|
|
119338
|
+
error: err instanceof Error ? err.message : String(err),
|
|
119339
|
+
path: target
|
|
119340
|
+
};
|
|
119341
|
+
}
|
|
119342
|
+
}
|
|
119343
|
+
try {
|
|
119344
|
+
await unlink2(target);
|
|
119345
|
+
return { success: true, error: "", path: target };
|
|
119346
|
+
} catch (err) {
|
|
119347
|
+
return {
|
|
119348
|
+
success: false,
|
|
119349
|
+
error: err instanceof Error ? err.message : String(err),
|
|
119350
|
+
path: target
|
|
119351
|
+
};
|
|
119352
|
+
}
|
|
119353
|
+
}
|
|
119354
|
+
});
|
|
119355
|
+
}
|
|
119356
|
+
// src/core/agents/offSecAgent/tools/gitDiff.ts
|
|
119357
|
+
init_dist();
|
|
119358
|
+
init_zod();
|
|
119359
|
+
|
|
119360
|
+
// src/core/agents/offSecAgent/tools/gitStatus.ts
|
|
119361
|
+
init_dist();
|
|
119362
|
+
init_zod();
|
|
119363
|
+
var gitStatusInputSchema = exports_external.object({
|
|
119364
|
+
toolCallDescription: exports_external.string().describe("A concise, human-readable description of what this tool call is doing (e.g., 'Check which files were modified')")
|
|
119365
|
+
});
|
|
119366
|
+
async function runGit2(ctx, args) {
|
|
119367
|
+
const command = `git ${args.map((a) => `'${a.replace(/'/g, `'\\''`)}'`).join(" ")}`;
|
|
119368
|
+
const full = `cd "${ctx.agentCwd}" && ${command}`;
|
|
119369
|
+
if (ctx.sandbox) {
|
|
119370
|
+
const result = await ctx.sandbox.execute(full, { timeout: 30 });
|
|
119371
|
+
return {
|
|
119372
|
+
success: result.success,
|
|
119373
|
+
stdout: result.stdout,
|
|
119374
|
+
stderr: result.stderr
|
|
119375
|
+
};
|
|
119376
|
+
}
|
|
119377
|
+
if (ctx.persistentShell) {
|
|
119378
|
+
const result = await ctx.persistentShell.execute(full, 30, undefined, ctx.abortSignal);
|
|
119379
|
+
return {
|
|
119380
|
+
success: result.exitCode === 0,
|
|
119381
|
+
stdout: result.stdout,
|
|
119382
|
+
stderr: result.stderr
|
|
119383
|
+
};
|
|
119384
|
+
}
|
|
119385
|
+
return {
|
|
119386
|
+
success: false,
|
|
119387
|
+
stdout: "",
|
|
119388
|
+
stderr: "No shell or sandbox available"
|
|
119389
|
+
};
|
|
119390
|
+
}
|
|
119391
|
+
function gitStatus(ctx) {
|
|
119392
|
+
return tool({
|
|
119393
|
+
description: `Show git working-tree status (porcelain) for the agent repository.
|
|
119394
|
+
|
|
119395
|
+
Use this to self-check which files you changed before finalizing.
|
|
119396
|
+
Does not commit, stage, push, or open a PR.`,
|
|
119397
|
+
inputSchema: gitStatusInputSchema,
|
|
119398
|
+
execute: async () => {
|
|
119399
|
+
const result = await runGit2(ctx, ["status", "--porcelain"]);
|
|
119400
|
+
if (!result.success) {
|
|
119401
|
+
return {
|
|
119402
|
+
success: false,
|
|
119403
|
+
error: result.stderr || "git status failed",
|
|
119404
|
+
status: result.stdout,
|
|
119405
|
+
cwd: ctx.agentCwd
|
|
119406
|
+
};
|
|
119407
|
+
}
|
|
119408
|
+
return {
|
|
119409
|
+
success: true,
|
|
119410
|
+
error: "",
|
|
119411
|
+
status: result.stdout.trim() || "(clean)",
|
|
119412
|
+
cwd: ctx.agentCwd
|
|
119413
|
+
};
|
|
119414
|
+
}
|
|
119415
|
+
});
|
|
119416
|
+
}
|
|
119417
|
+
|
|
119418
|
+
// src/core/agents/offSecAgent/tools/gitDiff.ts
|
|
119419
|
+
var gitDiffInputSchema = exports_external.object({
|
|
119420
|
+
path: exports_external.string().optional().describe("Optional path to limit the diff to a single file or directory"),
|
|
119421
|
+
staged: exports_external.boolean().optional().describe("If true, show staged (--cached) diff. Default: unstaged."),
|
|
119422
|
+
toolCallDescription: exports_external.string().describe("A concise, human-readable description of what this tool call is doing (e.g., 'Review unstaged patch before finalize')")
|
|
119423
|
+
});
|
|
119424
|
+
var MAX_DIFF = 1e5;
|
|
119425
|
+
function gitDiff(ctx) {
|
|
119426
|
+
return tool({
|
|
119427
|
+
description: `Show the git diff for the agent repository.
|
|
119428
|
+
|
|
119429
|
+
Defaults to unstaged working-tree changes. Set staged=true for the index.
|
|
119430
|
+
Optionally pass path to limit output to one file/directory.
|
|
119431
|
+
Does not commit, stage, push, or open a PR.`,
|
|
119432
|
+
inputSchema: gitDiffInputSchema,
|
|
119433
|
+
execute: async ({ path, staged = false }) => {
|
|
119434
|
+
const args = ["diff"];
|
|
119435
|
+
if (staged)
|
|
119436
|
+
args.push("--cached");
|
|
119437
|
+
if (path)
|
|
119438
|
+
args.push("--", path);
|
|
119439
|
+
const result = await runGit2(ctx, args);
|
|
119440
|
+
if (!result.success) {
|
|
119441
|
+
return {
|
|
119442
|
+
success: false,
|
|
119443
|
+
error: result.stderr || "git diff failed",
|
|
119444
|
+
diff: result.stdout,
|
|
119445
|
+
cwd: ctx.agentCwd
|
|
119446
|
+
};
|
|
119447
|
+
}
|
|
119448
|
+
const raw = result.stdout;
|
|
119449
|
+
const truncated = raw.length > MAX_DIFF;
|
|
119450
|
+
return {
|
|
119451
|
+
success: true,
|
|
119452
|
+
error: truncated ? `Diff truncated to ${MAX_DIFF} characters — narrow with path` : "",
|
|
119453
|
+
diff: truncated ? `${raw.slice(0, MAX_DIFF)}
|
|
119454
|
+
|
|
119455
|
+
(truncated)` : raw || "(no changes)",
|
|
119456
|
+
cwd: ctx.agentCwd
|
|
119457
|
+
};
|
|
119458
|
+
}
|
|
119459
|
+
});
|
|
119460
|
+
}
|
|
119461
|
+
// src/core/agents/offSecAgent/tools/glob.ts
|
|
119462
|
+
init_dist();
|
|
119463
|
+
import { isAbsolute as isAbsolute9, relative as relative7, resolve as resolve10 } from "node:path";
|
|
119464
|
+
|
|
119465
|
+
// node_modules/glob/dist/esm/index.min.js
|
|
119466
|
+
import { fileURLToPath as Wi } from "node:url";
|
|
119467
|
+
import { posix as mi, win32 as re } from "node:path";
|
|
119468
|
+
import { fileURLToPath as gi } from "node:url";
|
|
119469
|
+
import { lstatSync as wi, readdir as yi, readdirSync as bi, readlinkSync as Si, realpathSync as Ei } from "fs";
|
|
119470
|
+
import * as xi from "node:fs";
|
|
119471
|
+
import { lstat as Ci, readdir as Ti, readlink as Ai, realpath as ki } from "node:fs/promises";
|
|
119472
|
+
import { EventEmitter as ee } from "node:events";
|
|
119473
|
+
import Pe from "node:stream";
|
|
119474
|
+
import { StringDecoder as ni } from "node:string_decoder";
|
|
119475
|
+
var Gt = (n, t, e) => {
|
|
119476
|
+
let s = n instanceof RegExp ? ce(n, e) : n, i = t instanceof RegExp ? ce(t, e) : t, r = s !== null && i != null && ss(s, i, e);
|
|
119477
|
+
return r && { start: r[0], end: r[1], pre: e.slice(0, r[0]), body: e.slice(r[0] + s.length, r[1]), post: e.slice(r[1] + i.length) };
|
|
119478
|
+
};
|
|
119479
|
+
var ce = (n, t) => {
|
|
119480
|
+
let e = t.match(n);
|
|
119481
|
+
return e ? e[0] : null;
|
|
119482
|
+
};
|
|
119483
|
+
var ss = (n, t, e) => {
|
|
119484
|
+
let s, i, r, o, h, a = e.indexOf(n), l = e.indexOf(t, a + 1), u = a;
|
|
119485
|
+
if (a >= 0 && l > 0) {
|
|
119486
|
+
if (n === t)
|
|
119487
|
+
return [a, l];
|
|
119488
|
+
for (s = [], r = e.length;u >= 0 && !h; ) {
|
|
119489
|
+
if (u === a)
|
|
119490
|
+
s.push(u), a = e.indexOf(n, u + 1);
|
|
119491
|
+
else if (s.length === 1) {
|
|
119492
|
+
let c = s.pop();
|
|
119493
|
+
c !== undefined && (h = [c, l]);
|
|
119494
|
+
} else
|
|
119495
|
+
i = s.pop(), i !== undefined && i < r && (r = i, o = l), l = e.indexOf(t, u + 1);
|
|
119496
|
+
u = a < l && a >= 0 ? a : l;
|
|
119497
|
+
}
|
|
119498
|
+
s.length && o !== undefined && (h = [r, o]);
|
|
119499
|
+
}
|
|
119500
|
+
return h;
|
|
119501
|
+
};
|
|
119502
|
+
var fe = "\x00SLASH" + Math.random() + "\x00";
|
|
119503
|
+
var ue = "\x00OPEN" + Math.random() + "\x00";
|
|
119504
|
+
var qt = "\x00CLOSE" + Math.random() + "\x00";
|
|
119505
|
+
var de = "\x00COMMA" + Math.random() + "\x00";
|
|
119506
|
+
var pe = "\x00PERIOD" + Math.random() + "\x00";
|
|
119507
|
+
var is = new RegExp(fe, "g");
|
|
119508
|
+
var rs = new RegExp(ue, "g");
|
|
119509
|
+
var ns = new RegExp(qt, "g");
|
|
119510
|
+
var os = new RegExp(de, "g");
|
|
119511
|
+
var hs = new RegExp(pe, "g");
|
|
119512
|
+
var as = /\\\\/g;
|
|
119513
|
+
var ls = /\\{/g;
|
|
119514
|
+
var cs = /\\}/g;
|
|
119515
|
+
var fs = /\\,/g;
|
|
119516
|
+
var us = /\\./g;
|
|
119517
|
+
var ds = 1e5;
|
|
119518
|
+
function Ht(n) {
|
|
119519
|
+
return isNaN(n) ? n.charCodeAt(0) : parseInt(n, 10);
|
|
119520
|
+
}
|
|
119521
|
+
function ps(n) {
|
|
119522
|
+
return n.replace(as, fe).replace(ls, ue).replace(cs, qt).replace(fs, de).replace(us, pe);
|
|
119523
|
+
}
|
|
119524
|
+
function ms(n) {
|
|
119525
|
+
return n.replace(is, "\\").replace(rs, "{").replace(ns, "}").replace(os, ",").replace(hs, ".");
|
|
119526
|
+
}
|
|
119527
|
+
function me(n) {
|
|
119528
|
+
if (!n)
|
|
119529
|
+
return [""];
|
|
119530
|
+
let t = [], e = Gt("{", "}", n);
|
|
119531
|
+
if (!e)
|
|
119532
|
+
return n.split(",");
|
|
119533
|
+
let { pre: s, body: i, post: r } = e, o = s.split(",");
|
|
119534
|
+
o[o.length - 1] += "{" + i + "}";
|
|
119535
|
+
let h = me(r);
|
|
119536
|
+
return r.length && (o[o.length - 1] += h.shift(), o.push.apply(o, h)), t.push.apply(t, o), t;
|
|
119537
|
+
}
|
|
119538
|
+
function ge(n, t = {}) {
|
|
119539
|
+
if (!n)
|
|
119540
|
+
return [];
|
|
119541
|
+
let { max: e = ds } = t;
|
|
119542
|
+
return n.slice(0, 2) === "{}" && (n = "\\{\\}" + n.slice(2)), ht(ps(n), e, true).map(ms);
|
|
119543
|
+
}
|
|
119544
|
+
function gs(n) {
|
|
119545
|
+
return "{" + n + "}";
|
|
119546
|
+
}
|
|
119547
|
+
function ws(n) {
|
|
119548
|
+
return /^-?0\d/.test(n);
|
|
119549
|
+
}
|
|
119550
|
+
function ys(n, t) {
|
|
119551
|
+
return n <= t;
|
|
119552
|
+
}
|
|
119553
|
+
function bs(n, t) {
|
|
119554
|
+
return n >= t;
|
|
119555
|
+
}
|
|
119556
|
+
function ht(n, t, e) {
|
|
119557
|
+
let s = [], i = Gt("{", "}", n);
|
|
119558
|
+
if (!i)
|
|
119559
|
+
return [n];
|
|
119560
|
+
let r = i.pre, o = i.post.length ? ht(i.post, t, false) : [""];
|
|
119561
|
+
if (/\$$/.test(i.pre))
|
|
119562
|
+
for (let h = 0;h < o.length && h < t; h++) {
|
|
119563
|
+
let a = r + "{" + i.body + "}" + o[h];
|
|
119564
|
+
s.push(a);
|
|
119565
|
+
}
|
|
119566
|
+
else {
|
|
119567
|
+
let h = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(i.body), a = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(i.body), l = h || a, u = i.body.indexOf(",") >= 0;
|
|
119568
|
+
if (!l && !u)
|
|
119569
|
+
return i.post.match(/,(?!,).*\}/) ? (n = i.pre + "{" + i.body + qt + i.post, ht(n, t, true)) : [n];
|
|
119570
|
+
let c;
|
|
119571
|
+
if (l)
|
|
119572
|
+
c = i.body.split(/\.\./);
|
|
119573
|
+
else if (c = me(i.body), c.length === 1 && c[0] !== undefined && (c = ht(c[0], t, false).map(gs), c.length === 1))
|
|
119574
|
+
return o.map((f) => i.pre + c[0] + f);
|
|
119575
|
+
let d;
|
|
119576
|
+
if (l && c[0] !== undefined && c[1] !== undefined) {
|
|
119577
|
+
let f = Ht(c[0]), m = Ht(c[1]), p = Math.max(c[0].length, c[1].length), w = c.length === 3 && c[2] !== undefined ? Math.abs(Ht(c[2])) : 1, g = ys;
|
|
119578
|
+
m < f && (w *= -1, g = bs);
|
|
119579
|
+
let E = c.some(ws);
|
|
119580
|
+
d = [];
|
|
119581
|
+
for (let y = f;g(y, m); y += w) {
|
|
119582
|
+
let b;
|
|
119583
|
+
if (a)
|
|
119584
|
+
b = String.fromCharCode(y), b === "\\" && (b = "");
|
|
119585
|
+
else if (b = String(y), E) {
|
|
119586
|
+
let z = p - b.length;
|
|
119587
|
+
if (z > 0) {
|
|
119588
|
+
let $ = new Array(z + 1).join("0");
|
|
119589
|
+
y < 0 ? b = "-" + $ + b.slice(1) : b = $ + b;
|
|
119590
|
+
}
|
|
119591
|
+
}
|
|
119592
|
+
d.push(b);
|
|
119593
|
+
}
|
|
119594
|
+
} else {
|
|
119595
|
+
d = [];
|
|
119596
|
+
for (let f = 0;f < c.length; f++)
|
|
119597
|
+
d.push.apply(d, ht(c[f], t, false));
|
|
119598
|
+
}
|
|
119599
|
+
for (let f = 0;f < d.length; f++)
|
|
119600
|
+
for (let m = 0;m < o.length && s.length < t; m++) {
|
|
119601
|
+
let p = r + d[f] + o[m];
|
|
119602
|
+
(!e || l || p) && s.push(p);
|
|
119603
|
+
}
|
|
119604
|
+
}
|
|
119605
|
+
return s;
|
|
119606
|
+
}
|
|
119607
|
+
var at = (n) => {
|
|
119608
|
+
if (typeof n != "string")
|
|
119609
|
+
throw new TypeError("invalid pattern");
|
|
119610
|
+
if (n.length > 65536)
|
|
119611
|
+
throw new TypeError("pattern is too long");
|
|
119612
|
+
};
|
|
119613
|
+
var Ss = { "[:alnum:]": ["\\p{L}\\p{Nl}\\p{Nd}", true], "[:alpha:]": ["\\p{L}\\p{Nl}", true], "[:ascii:]": ["\\x00-\\x7f", false], "[:blank:]": ["\\p{Zs}\\t", true], "[:cntrl:]": ["\\p{Cc}", true], "[:digit:]": ["\\p{Nd}", true], "[:graph:]": ["\\p{Z}\\p{C}", true, true], "[:lower:]": ["\\p{Ll}", true], "[:print:]": ["\\p{C}", true], "[:punct:]": ["\\p{P}", true], "[:space:]": ["\\p{Z}\\t\\r\\n\\v\\f", true], "[:upper:]": ["\\p{Lu}", true], "[:word:]": ["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}", true], "[:xdigit:]": ["A-Fa-f0-9", false] };
|
|
119614
|
+
var lt = (n) => n.replace(/[[\]\\-]/g, "\\$&");
|
|
119615
|
+
var Es = (n) => n.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
|
|
119616
|
+
var we = (n) => n.join("");
|
|
119617
|
+
var ye = (n, t) => {
|
|
119618
|
+
let e = t;
|
|
119619
|
+
if (n.charAt(e) !== "[")
|
|
119620
|
+
throw new Error("not in a brace expression");
|
|
119621
|
+
let s = [], i = [], r = e + 1, o = false, h = false, a = false, l = false, u = e, c = "";
|
|
119622
|
+
t:
|
|
119623
|
+
for (;r < n.length; ) {
|
|
119624
|
+
let p = n.charAt(r);
|
|
119625
|
+
if ((p === "!" || p === "^") && r === e + 1) {
|
|
119626
|
+
l = true, r++;
|
|
119627
|
+
continue;
|
|
119628
|
+
}
|
|
119629
|
+
if (p === "]" && o && !a) {
|
|
119630
|
+
u = r + 1;
|
|
119631
|
+
break;
|
|
119632
|
+
}
|
|
119633
|
+
if (o = true, p === "\\" && !a) {
|
|
119634
|
+
a = true, r++;
|
|
119635
|
+
continue;
|
|
119636
|
+
}
|
|
119637
|
+
if (p === "[" && !a) {
|
|
119638
|
+
for (let [w, [g, S, E]] of Object.entries(Ss))
|
|
119639
|
+
if (n.startsWith(w, r)) {
|
|
119640
|
+
if (c)
|
|
119641
|
+
return ["$.", false, n.length - e, true];
|
|
119642
|
+
r += w.length, E ? i.push(g) : s.push(g), h = h || S;
|
|
119643
|
+
continue t;
|
|
119644
|
+
}
|
|
119645
|
+
}
|
|
119646
|
+
if (a = false, c) {
|
|
119647
|
+
p > c ? s.push(lt(c) + "-" + lt(p)) : p === c && s.push(lt(p)), c = "", r++;
|
|
119648
|
+
continue;
|
|
119649
|
+
}
|
|
119650
|
+
if (n.startsWith("-]", r + 1)) {
|
|
119651
|
+
s.push(lt(p + "-")), r += 2;
|
|
119652
|
+
continue;
|
|
119653
|
+
}
|
|
119654
|
+
if (n.startsWith("-", r + 1)) {
|
|
119655
|
+
c = p, r += 2;
|
|
119656
|
+
continue;
|
|
119657
|
+
}
|
|
119658
|
+
s.push(lt(p)), r++;
|
|
119659
|
+
}
|
|
119660
|
+
if (u < r)
|
|
119661
|
+
return ["", false, 0, false];
|
|
119662
|
+
if (!s.length && !i.length)
|
|
119663
|
+
return ["$.", false, n.length - e, true];
|
|
119664
|
+
if (i.length === 0 && s.length === 1 && /^\\?.$/.test(s[0]) && !l) {
|
|
119665
|
+
let p = s[0].length === 2 ? s[0].slice(-1) : s[0];
|
|
119666
|
+
return [Es(p), false, u - e, false];
|
|
119667
|
+
}
|
|
119668
|
+
let d = "[" + (l ? "^" : "") + we(s) + "]", f = "[" + (l ? "" : "^") + we(i) + "]";
|
|
119669
|
+
return [s.length && i.length ? "(" + d + "|" + f + ")" : s.length ? d : f, h, u - e, true];
|
|
119670
|
+
};
|
|
119671
|
+
var W = (n, { windowsPathsNoEscape: t = false, magicalBraces: e = true } = {}) => e ? t ? n.replace(/\[([^\/\\])\]/g, "$1") : n.replace(/((?!\\).|^)\[([^\/\\])\]/g, "$1$2").replace(/\\([^\/])/g, "$1") : t ? n.replace(/\[([^\/\\{}])\]/g, "$1") : n.replace(/((?!\\).|^)\[([^\/\\{}])\]/g, "$1$2").replace(/\\([^\/{}])/g, "$1");
|
|
119672
|
+
var xs = new Set(["!", "?", "+", "*", "@"]);
|
|
119673
|
+
var be = (n) => xs.has(n);
|
|
119674
|
+
var vs = "(?!(?:^|/)\\.\\.?(?:$|/))";
|
|
119675
|
+
var Ct = "(?!\\.)";
|
|
119676
|
+
var Cs = new Set(["[", "."]);
|
|
119677
|
+
var Ts = new Set(["..", "."]);
|
|
119678
|
+
var As = new Set("().*{}+?[]^$\\!");
|
|
119679
|
+
var ks = (n) => n.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
|
|
119680
|
+
var Kt = "[^/]";
|
|
119681
|
+
var Se = Kt + "*?";
|
|
119682
|
+
var Ee = Kt + "+?";
|
|
119683
|
+
var Q = class n {
|
|
119684
|
+
type;
|
|
119685
|
+
#t;
|
|
119686
|
+
#s;
|
|
119687
|
+
#n = false;
|
|
119688
|
+
#r = [];
|
|
119689
|
+
#o;
|
|
119690
|
+
#S;
|
|
119691
|
+
#w;
|
|
119692
|
+
#c = false;
|
|
119693
|
+
#h;
|
|
119694
|
+
#u;
|
|
119695
|
+
#f = false;
|
|
119696
|
+
constructor(t, e, s = {}) {
|
|
119697
|
+
this.type = t, t && (this.#s = true), this.#o = e, this.#t = this.#o ? this.#o.#t : this, this.#h = this.#t === this ? s : this.#t.#h, this.#w = this.#t === this ? [] : this.#t.#w, t === "!" && !this.#t.#c && this.#w.push(this), this.#S = this.#o ? this.#o.#r.length : 0;
|
|
119698
|
+
}
|
|
119699
|
+
get hasMagic() {
|
|
119700
|
+
if (this.#s !== undefined)
|
|
119701
|
+
return this.#s;
|
|
119702
|
+
for (let t of this.#r)
|
|
119703
|
+
if (typeof t != "string" && (t.type || t.hasMagic))
|
|
119704
|
+
return this.#s = true;
|
|
119705
|
+
return this.#s;
|
|
119706
|
+
}
|
|
119707
|
+
toString() {
|
|
119708
|
+
return this.#u !== undefined ? this.#u : this.type ? this.#u = this.type + "(" + this.#r.map((t) => String(t)).join("|") + ")" : this.#u = this.#r.map((t) => String(t)).join("");
|
|
119709
|
+
}
|
|
119710
|
+
#a() {
|
|
119711
|
+
if (this !== this.#t)
|
|
119712
|
+
throw new Error("should only call on root");
|
|
119713
|
+
if (this.#c)
|
|
119714
|
+
return this;
|
|
119715
|
+
this.toString(), this.#c = true;
|
|
119716
|
+
let t;
|
|
119717
|
+
for (;t = this.#w.pop(); ) {
|
|
119718
|
+
if (t.type !== "!")
|
|
119719
|
+
continue;
|
|
119720
|
+
let e = t, s = e.#o;
|
|
119721
|
+
for (;s; ) {
|
|
119722
|
+
for (let i = e.#S + 1;!s.type && i < s.#r.length; i++)
|
|
119723
|
+
for (let r of t.#r) {
|
|
119724
|
+
if (typeof r == "string")
|
|
119725
|
+
throw new Error("string part in extglob AST??");
|
|
119726
|
+
r.copyIn(s.#r[i]);
|
|
119727
|
+
}
|
|
119728
|
+
e = s, s = e.#o;
|
|
119729
|
+
}
|
|
119730
|
+
}
|
|
119731
|
+
return this;
|
|
119732
|
+
}
|
|
119733
|
+
push(...t) {
|
|
119734
|
+
for (let e of t)
|
|
119735
|
+
if (e !== "") {
|
|
119736
|
+
if (typeof e != "string" && !(e instanceof n && e.#o === this))
|
|
119737
|
+
throw new Error("invalid part: " + e);
|
|
119738
|
+
this.#r.push(e);
|
|
119739
|
+
}
|
|
119740
|
+
}
|
|
119741
|
+
toJSON() {
|
|
119742
|
+
let t = this.type === null ? this.#r.slice().map((e) => typeof e == "string" ? e : e.toJSON()) : [this.type, ...this.#r.map((e) => e.toJSON())];
|
|
119743
|
+
return this.isStart() && !this.type && t.unshift([]), this.isEnd() && (this === this.#t || this.#t.#c && this.#o?.type === "!") && t.push({}), t;
|
|
119744
|
+
}
|
|
119745
|
+
isStart() {
|
|
119746
|
+
if (this.#t === this)
|
|
119747
|
+
return true;
|
|
119748
|
+
if (!this.#o?.isStart())
|
|
119749
|
+
return false;
|
|
119750
|
+
if (this.#S === 0)
|
|
119751
|
+
return true;
|
|
119752
|
+
let t = this.#o;
|
|
119753
|
+
for (let e = 0;e < this.#S; e++) {
|
|
119754
|
+
let s = t.#r[e];
|
|
119755
|
+
if (!(s instanceof n && s.type === "!"))
|
|
119756
|
+
return false;
|
|
119757
|
+
}
|
|
119758
|
+
return true;
|
|
119759
|
+
}
|
|
119760
|
+
isEnd() {
|
|
119761
|
+
if (this.#t === this || this.#o?.type === "!")
|
|
119762
|
+
return true;
|
|
119763
|
+
if (!this.#o?.isEnd())
|
|
119764
|
+
return false;
|
|
119765
|
+
if (!this.type)
|
|
119766
|
+
return this.#o?.isEnd();
|
|
119767
|
+
let t = this.#o ? this.#o.#r.length : 0;
|
|
119768
|
+
return this.#S === t - 1;
|
|
119769
|
+
}
|
|
119770
|
+
copyIn(t) {
|
|
119771
|
+
typeof t == "string" ? this.push(t) : this.push(t.clone(this));
|
|
119772
|
+
}
|
|
119773
|
+
clone(t) {
|
|
119774
|
+
let e = new n(this.type, t);
|
|
119775
|
+
for (let s of this.#r)
|
|
119776
|
+
e.copyIn(s);
|
|
119777
|
+
return e;
|
|
119778
|
+
}
|
|
119779
|
+
static #i(t, e, s, i) {
|
|
119780
|
+
let r = false, o = false, h = -1, a = false;
|
|
119781
|
+
if (e.type === null) {
|
|
119782
|
+
let f = s, m = "";
|
|
119783
|
+
for (;f < t.length; ) {
|
|
119784
|
+
let p = t.charAt(f++);
|
|
119785
|
+
if (r || p === "\\") {
|
|
119786
|
+
r = !r, m += p;
|
|
119787
|
+
continue;
|
|
119788
|
+
}
|
|
119789
|
+
if (o) {
|
|
119790
|
+
f === h + 1 ? (p === "^" || p === "!") && (a = true) : p === "]" && !(f === h + 2 && a) && (o = false), m += p;
|
|
119791
|
+
continue;
|
|
119792
|
+
} else if (p === "[") {
|
|
119793
|
+
o = true, h = f, a = false, m += p;
|
|
119794
|
+
continue;
|
|
119795
|
+
}
|
|
119796
|
+
if (!i.noext && be(p) && t.charAt(f) === "(") {
|
|
119797
|
+
e.push(m), m = "";
|
|
119798
|
+
let w = new n(p, e);
|
|
119799
|
+
f = n.#i(t, w, f, i), e.push(w);
|
|
119800
|
+
continue;
|
|
119801
|
+
}
|
|
119802
|
+
m += p;
|
|
119803
|
+
}
|
|
119804
|
+
return e.push(m), f;
|
|
119805
|
+
}
|
|
119806
|
+
let l = s + 1, u = new n(null, e), c = [], d = "";
|
|
119807
|
+
for (;l < t.length; ) {
|
|
119808
|
+
let f = t.charAt(l++);
|
|
119809
|
+
if (r || f === "\\") {
|
|
119810
|
+
r = !r, d += f;
|
|
119811
|
+
continue;
|
|
119812
|
+
}
|
|
119813
|
+
if (o) {
|
|
119814
|
+
l === h + 1 ? (f === "^" || f === "!") && (a = true) : f === "]" && !(l === h + 2 && a) && (o = false), d += f;
|
|
119815
|
+
continue;
|
|
119816
|
+
} else if (f === "[") {
|
|
119817
|
+
o = true, h = l, a = false, d += f;
|
|
119818
|
+
continue;
|
|
119819
|
+
}
|
|
119820
|
+
if (be(f) && t.charAt(l) === "(") {
|
|
119821
|
+
u.push(d), d = "";
|
|
119822
|
+
let m = new n(f, u);
|
|
119823
|
+
u.push(m), l = n.#i(t, m, l, i);
|
|
119824
|
+
continue;
|
|
119825
|
+
}
|
|
119826
|
+
if (f === "|") {
|
|
119827
|
+
u.push(d), d = "", c.push(u), u = new n(null, e);
|
|
119828
|
+
continue;
|
|
119829
|
+
}
|
|
119830
|
+
if (f === ")")
|
|
119831
|
+
return d === "" && e.#r.length === 0 && (e.#f = true), u.push(d), d = "", e.push(...c, u), l;
|
|
119832
|
+
d += f;
|
|
119833
|
+
}
|
|
119834
|
+
return e.type = null, e.#s = undefined, e.#r = [t.substring(s - 1)], l;
|
|
119835
|
+
}
|
|
119836
|
+
static fromGlob(t, e = {}) {
|
|
119837
|
+
let s = new n(null, undefined, e);
|
|
119838
|
+
return n.#i(t, s, 0, e), s;
|
|
119839
|
+
}
|
|
119840
|
+
toMMPattern() {
|
|
119841
|
+
if (this !== this.#t)
|
|
119842
|
+
return this.#t.toMMPattern();
|
|
119843
|
+
let t = this.toString(), [e, s, i, r] = this.toRegExpSource();
|
|
119844
|
+
if (!(i || this.#s || this.#h.nocase && !this.#h.nocaseMagicOnly && t.toUpperCase() !== t.toLowerCase()))
|
|
119845
|
+
return s;
|
|
119846
|
+
let h = (this.#h.nocase ? "i" : "") + (r ? "u" : "");
|
|
119847
|
+
return Object.assign(new RegExp(`^${e}$`, h), { _src: e, _glob: t });
|
|
119848
|
+
}
|
|
119849
|
+
get options() {
|
|
119850
|
+
return this.#h;
|
|
119851
|
+
}
|
|
119852
|
+
toRegExpSource(t) {
|
|
119853
|
+
let e = t ?? !!this.#h.dot;
|
|
119854
|
+
if (this.#t === this && this.#a(), !this.type) {
|
|
119855
|
+
let a = this.isStart() && this.isEnd() && !this.#r.some((f) => typeof f != "string"), l = this.#r.map((f) => {
|
|
119856
|
+
let [m, p, w, g] = typeof f == "string" ? n.#E(f, this.#s, a) : f.toRegExpSource(t);
|
|
119857
|
+
return this.#s = this.#s || w, this.#n = this.#n || g, m;
|
|
119858
|
+
}).join(""), u = "";
|
|
119859
|
+
if (this.isStart() && typeof this.#r[0] == "string" && !(this.#r.length === 1 && Ts.has(this.#r[0]))) {
|
|
119860
|
+
let m = Cs, p = e && m.has(l.charAt(0)) || l.startsWith("\\.") && m.has(l.charAt(2)) || l.startsWith("\\.\\.") && m.has(l.charAt(4)), w = !e && !t && m.has(l.charAt(0));
|
|
119861
|
+
u = p ? vs : w ? Ct : "";
|
|
119862
|
+
}
|
|
119863
|
+
let c = "";
|
|
119864
|
+
return this.isEnd() && this.#t.#c && this.#o?.type === "!" && (c = "(?:$|\\/)"), [u + l + c, W(l), this.#s = !!this.#s, this.#n];
|
|
119865
|
+
}
|
|
119866
|
+
let s = this.type === "*" || this.type === "+", i = this.type === "!" ? "(?:(?!(?:" : "(?:", r = this.#d(e);
|
|
119867
|
+
if (this.isStart() && this.isEnd() && !r && this.type !== "!") {
|
|
119868
|
+
let a = this.toString();
|
|
119869
|
+
return this.#r = [a], this.type = null, this.#s = undefined, [a, W(this.toString()), false, false];
|
|
119870
|
+
}
|
|
119871
|
+
let o = !s || t || e || !Ct ? "" : this.#d(true);
|
|
119872
|
+
o === r && (o = ""), o && (r = `(?:${r})(?:${o})*?`);
|
|
119873
|
+
let h = "";
|
|
119874
|
+
if (this.type === "!" && this.#f)
|
|
119875
|
+
h = (this.isStart() && !e ? Ct : "") + Ee;
|
|
119876
|
+
else {
|
|
119877
|
+
let a = this.type === "!" ? "))" + (this.isStart() && !e && !t ? Ct : "") + Se + ")" : this.type === "@" ? ")" : this.type === "?" ? ")?" : this.type === "+" && o ? ")" : this.type === "*" && o ? ")?" : `)${this.type}`;
|
|
119878
|
+
h = i + r + a;
|
|
119879
|
+
}
|
|
119880
|
+
return [h, W(r), this.#s = !!this.#s, this.#n];
|
|
119881
|
+
}
|
|
119882
|
+
#d(t) {
|
|
119883
|
+
return this.#r.map((e) => {
|
|
119884
|
+
if (typeof e == "string")
|
|
119885
|
+
throw new Error("string type in extglob ast??");
|
|
119886
|
+
let [s, i, r, o] = e.toRegExpSource(t);
|
|
119887
|
+
return this.#n = this.#n || o, s;
|
|
119888
|
+
}).filter((e) => !(this.isStart() && this.isEnd()) || !!e).join("|");
|
|
119889
|
+
}
|
|
119890
|
+
static #E(t, e, s = false) {
|
|
119891
|
+
let i = false, r = "", o = false, h = false;
|
|
119892
|
+
for (let a = 0;a < t.length; a++) {
|
|
119893
|
+
let l = t.charAt(a);
|
|
119894
|
+
if (i) {
|
|
119895
|
+
i = false, r += (As.has(l) ? "\\" : "") + l;
|
|
119896
|
+
continue;
|
|
119897
|
+
}
|
|
119898
|
+
if (l === "*") {
|
|
119899
|
+
if (h)
|
|
119900
|
+
continue;
|
|
119901
|
+
h = true, r += s && /^[*]+$/.test(t) ? Ee : Se, e = true;
|
|
119902
|
+
continue;
|
|
119903
|
+
} else
|
|
119904
|
+
h = false;
|
|
119905
|
+
if (l === "\\") {
|
|
119906
|
+
a === t.length - 1 ? r += "\\\\" : i = true;
|
|
119907
|
+
continue;
|
|
119908
|
+
}
|
|
119909
|
+
if (l === "[") {
|
|
119910
|
+
let [u, c, d, f] = ye(t, a);
|
|
119911
|
+
if (d) {
|
|
119912
|
+
r += u, o = o || c, a += d - 1, e = e || f;
|
|
119913
|
+
continue;
|
|
119914
|
+
}
|
|
119915
|
+
}
|
|
119916
|
+
if (l === "?") {
|
|
119917
|
+
r += Kt, e = true;
|
|
119918
|
+
continue;
|
|
119919
|
+
}
|
|
119920
|
+
r += ks(l);
|
|
119921
|
+
}
|
|
119922
|
+
return [r, W(t), !!e, o];
|
|
119923
|
+
}
|
|
119924
|
+
};
|
|
119925
|
+
var tt = (n2, { windowsPathsNoEscape: t = false, magicalBraces: e = false } = {}) => e ? t ? n2.replace(/[?*()[\]{}]/g, "[$&]") : n2.replace(/[?*()[\]\\{}]/g, "\\$&") : t ? n2.replace(/[?*()[\]]/g, "[$&]") : n2.replace(/[?*()[\]\\]/g, "\\$&");
|
|
119926
|
+
var O = (n2, t, e = {}) => (at(t), !e.nocomment && t.charAt(0) === "#" ? false : new D(t, e).match(n2));
|
|
119927
|
+
var Rs = /^\*+([^+@!?\*\[\(]*)$/;
|
|
119928
|
+
var Os = (n2) => (t) => !t.startsWith(".") && t.endsWith(n2);
|
|
119929
|
+
var Fs = (n2) => (t) => t.endsWith(n2);
|
|
119930
|
+
var Ds = (n2) => (n2 = n2.toLowerCase(), (t) => !t.startsWith(".") && t.toLowerCase().endsWith(n2));
|
|
119931
|
+
var Ms = (n2) => (n2 = n2.toLowerCase(), (t) => t.toLowerCase().endsWith(n2));
|
|
119932
|
+
var Ns = /^\*+\.\*+$/;
|
|
119933
|
+
var _s = (n2) => !n2.startsWith(".") && n2.includes(".");
|
|
119934
|
+
var Ls = (n2) => n2 !== "." && n2 !== ".." && n2.includes(".");
|
|
119935
|
+
var Ws = /^\.\*+$/;
|
|
119936
|
+
var Ps = (n2) => n2 !== "." && n2 !== ".." && n2.startsWith(".");
|
|
119937
|
+
var js = /^\*+$/;
|
|
119938
|
+
var Is = (n2) => n2.length !== 0 && !n2.startsWith(".");
|
|
119939
|
+
var zs = (n2) => n2.length !== 0 && n2 !== "." && n2 !== "..";
|
|
119940
|
+
var Bs = /^\?+([^+@!?\*\[\(]*)?$/;
|
|
119941
|
+
var Us = ([n2, t = ""]) => {
|
|
119942
|
+
let e = Ce([n2]);
|
|
119943
|
+
return t ? (t = t.toLowerCase(), (s) => e(s) && s.toLowerCase().endsWith(t)) : e;
|
|
119944
|
+
};
|
|
119945
|
+
var $s = ([n2, t = ""]) => {
|
|
119946
|
+
let e = Te([n2]);
|
|
119947
|
+
return t ? (t = t.toLowerCase(), (s) => e(s) && s.toLowerCase().endsWith(t)) : e;
|
|
119948
|
+
};
|
|
119949
|
+
var Gs = ([n2, t = ""]) => {
|
|
119950
|
+
let e = Te([n2]);
|
|
119951
|
+
return t ? (s) => e(s) && s.endsWith(t) : e;
|
|
119952
|
+
};
|
|
119953
|
+
var Hs = ([n2, t = ""]) => {
|
|
119954
|
+
let e = Ce([n2]);
|
|
119955
|
+
return t ? (s) => e(s) && s.endsWith(t) : e;
|
|
119956
|
+
};
|
|
119957
|
+
var Ce = ([n2]) => {
|
|
119958
|
+
let t = n2.length;
|
|
119959
|
+
return (e) => e.length === t && !e.startsWith(".");
|
|
119960
|
+
};
|
|
119961
|
+
var Te = ([n2]) => {
|
|
119962
|
+
let t = n2.length;
|
|
119963
|
+
return (e) => e.length === t && e !== "." && e !== "..";
|
|
119964
|
+
};
|
|
119965
|
+
var Ae = typeof process == "object" && process ? typeof process.env == "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix";
|
|
119966
|
+
var xe = { win32: { sep: "\\" }, posix: { sep: "/" } };
|
|
119967
|
+
var qs = Ae === "win32" ? xe.win32.sep : xe.posix.sep;
|
|
119968
|
+
O.sep = qs;
|
|
119969
|
+
var A = Symbol("globstar **");
|
|
119970
|
+
O.GLOBSTAR = A;
|
|
119971
|
+
var Ks = "[^/]";
|
|
119972
|
+
var Vs = Ks + "*?";
|
|
119973
|
+
var Ys = "(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?";
|
|
119974
|
+
var Xs = "(?:(?!(?:\\/|^)\\.).)*?";
|
|
119975
|
+
var Js = (n2, t = {}) => (e) => O(e, n2, t);
|
|
119976
|
+
O.filter = Js;
|
|
119977
|
+
var N = (n2, t = {}) => Object.assign({}, n2, t);
|
|
119978
|
+
var Zs = (n2) => {
|
|
119979
|
+
if (!n2 || typeof n2 != "object" || !Object.keys(n2).length)
|
|
119980
|
+
return O;
|
|
119981
|
+
let t = O;
|
|
119982
|
+
return Object.assign((s, i, r = {}) => t(s, i, N(n2, r)), { Minimatch: class extends t.Minimatch {
|
|
119983
|
+
constructor(i, r = {}) {
|
|
119984
|
+
super(i, N(n2, r));
|
|
119985
|
+
}
|
|
119986
|
+
static defaults(i) {
|
|
119987
|
+
return t.defaults(N(n2, i)).Minimatch;
|
|
119988
|
+
}
|
|
119989
|
+
}, AST: class extends t.AST {
|
|
119990
|
+
constructor(i, r, o = {}) {
|
|
119991
|
+
super(i, r, N(n2, o));
|
|
119992
|
+
}
|
|
119993
|
+
static fromGlob(i, r = {}) {
|
|
119994
|
+
return t.AST.fromGlob(i, N(n2, r));
|
|
119995
|
+
}
|
|
119996
|
+
}, unescape: (s, i = {}) => t.unescape(s, N(n2, i)), escape: (s, i = {}) => t.escape(s, N(n2, i)), filter: (s, i = {}) => t.filter(s, N(n2, i)), defaults: (s) => t.defaults(N(n2, s)), makeRe: (s, i = {}) => t.makeRe(s, N(n2, i)), braceExpand: (s, i = {}) => t.braceExpand(s, N(n2, i)), match: (s, i, r = {}) => t.match(s, i, N(n2, r)), sep: t.sep, GLOBSTAR: A });
|
|
119997
|
+
};
|
|
119998
|
+
O.defaults = Zs;
|
|
119999
|
+
var ke = (n2, t = {}) => (at(n2), t.nobrace || !/\{(?:(?!\{).)*\}/.test(n2) ? [n2] : ge(n2, { max: t.braceExpandMax }));
|
|
120000
|
+
O.braceExpand = ke;
|
|
120001
|
+
var Qs = (n2, t = {}) => new D(n2, t).makeRe();
|
|
120002
|
+
O.makeRe = Qs;
|
|
120003
|
+
var ti = (n2, t, e = {}) => {
|
|
120004
|
+
let s = new D(t, e);
|
|
120005
|
+
return n2 = n2.filter((i) => s.match(i)), s.options.nonull && !n2.length && n2.push(t), n2;
|
|
120006
|
+
};
|
|
120007
|
+
O.match = ti;
|
|
120008
|
+
var ve = /[?*]|[+@!]\(.*?\)|\[|\]/;
|
|
120009
|
+
var ei = (n2) => n2.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
|
|
120010
|
+
var D = class {
|
|
120011
|
+
options;
|
|
120012
|
+
set;
|
|
120013
|
+
pattern;
|
|
120014
|
+
windowsPathsNoEscape;
|
|
120015
|
+
nonegate;
|
|
120016
|
+
negate;
|
|
120017
|
+
comment;
|
|
120018
|
+
empty;
|
|
120019
|
+
preserveMultipleSlashes;
|
|
120020
|
+
partial;
|
|
120021
|
+
globSet;
|
|
120022
|
+
globParts;
|
|
120023
|
+
nocase;
|
|
120024
|
+
isWindows;
|
|
120025
|
+
platform;
|
|
120026
|
+
windowsNoMagicRoot;
|
|
120027
|
+
regexp;
|
|
120028
|
+
constructor(t, e = {}) {
|
|
120029
|
+
at(t), e = e || {}, this.options = e, this.pattern = t, this.platform = e.platform || Ae, this.isWindows = this.platform === "win32";
|
|
120030
|
+
let s = "allowWindowsEscape";
|
|
120031
|
+
this.windowsPathsNoEscape = !!e.windowsPathsNoEscape || e[s] === false, this.windowsPathsNoEscape && (this.pattern = this.pattern.replace(/\\/g, "/")), this.preserveMultipleSlashes = !!e.preserveMultipleSlashes, this.regexp = null, this.negate = false, this.nonegate = !!e.nonegate, this.comment = false, this.empty = false, this.partial = !!e.partial, this.nocase = !!this.options.nocase, this.windowsNoMagicRoot = e.windowsNoMagicRoot !== undefined ? e.windowsNoMagicRoot : !!(this.isWindows && this.nocase), this.globSet = [], this.globParts = [], this.set = [], this.make();
|
|
120032
|
+
}
|
|
120033
|
+
hasMagic() {
|
|
120034
|
+
if (this.options.magicalBraces && this.set.length > 1)
|
|
120035
|
+
return true;
|
|
120036
|
+
for (let t of this.set)
|
|
120037
|
+
for (let e of t)
|
|
120038
|
+
if (typeof e != "string")
|
|
120039
|
+
return true;
|
|
120040
|
+
return false;
|
|
120041
|
+
}
|
|
120042
|
+
debug(...t) {}
|
|
120043
|
+
make() {
|
|
120044
|
+
let t = this.pattern, e = this.options;
|
|
120045
|
+
if (!e.nocomment && t.charAt(0) === "#") {
|
|
120046
|
+
this.comment = true;
|
|
120047
|
+
return;
|
|
120048
|
+
}
|
|
120049
|
+
if (!t) {
|
|
120050
|
+
this.empty = true;
|
|
120051
|
+
return;
|
|
120052
|
+
}
|
|
120053
|
+
this.parseNegate(), this.globSet = [...new Set(this.braceExpand())], e.debug && (this.debug = (...r) => console.error(...r)), this.debug(this.pattern, this.globSet);
|
|
120054
|
+
let s = this.globSet.map((r) => this.slashSplit(r));
|
|
120055
|
+
this.globParts = this.preprocess(s), this.debug(this.pattern, this.globParts);
|
|
120056
|
+
let i = this.globParts.map((r, o, h) => {
|
|
120057
|
+
if (this.isWindows && this.windowsNoMagicRoot) {
|
|
120058
|
+
let a = r[0] === "" && r[1] === "" && (r[2] === "?" || !ve.test(r[2])) && !ve.test(r[3]), l = /^[a-z]:/i.test(r[0]);
|
|
120059
|
+
if (a)
|
|
120060
|
+
return [...r.slice(0, 4), ...r.slice(4).map((u) => this.parse(u))];
|
|
120061
|
+
if (l)
|
|
120062
|
+
return [r[0], ...r.slice(1).map((u) => this.parse(u))];
|
|
120063
|
+
}
|
|
120064
|
+
return r.map((a) => this.parse(a));
|
|
120065
|
+
});
|
|
120066
|
+
if (this.debug(this.pattern, i), this.set = i.filter((r) => r.indexOf(false) === -1), this.isWindows)
|
|
120067
|
+
for (let r = 0;r < this.set.length; r++) {
|
|
120068
|
+
let o = this.set[r];
|
|
120069
|
+
o[0] === "" && o[1] === "" && this.globParts[r][2] === "?" && typeof o[3] == "string" && /^[a-z]:$/i.test(o[3]) && (o[2] = "?");
|
|
120070
|
+
}
|
|
120071
|
+
this.debug(this.pattern, this.set);
|
|
120072
|
+
}
|
|
120073
|
+
preprocess(t) {
|
|
120074
|
+
if (this.options.noglobstar)
|
|
120075
|
+
for (let s = 0;s < t.length; s++)
|
|
120076
|
+
for (let i = 0;i < t[s].length; i++)
|
|
120077
|
+
t[s][i] === "**" && (t[s][i] = "*");
|
|
120078
|
+
let { optimizationLevel: e = 1 } = this.options;
|
|
120079
|
+
return e >= 2 ? (t = this.firstPhasePreProcess(t), t = this.secondPhasePreProcess(t)) : e >= 1 ? t = this.levelOneOptimize(t) : t = this.adjascentGlobstarOptimize(t), t;
|
|
120080
|
+
}
|
|
120081
|
+
adjascentGlobstarOptimize(t) {
|
|
120082
|
+
return t.map((e) => {
|
|
120083
|
+
let s = -1;
|
|
120084
|
+
for (;(s = e.indexOf("**", s + 1)) !== -1; ) {
|
|
120085
|
+
let i = s;
|
|
120086
|
+
for (;e[i + 1] === "**"; )
|
|
120087
|
+
i++;
|
|
120088
|
+
i !== s && e.splice(s, i - s);
|
|
120089
|
+
}
|
|
120090
|
+
return e;
|
|
120091
|
+
});
|
|
120092
|
+
}
|
|
120093
|
+
levelOneOptimize(t) {
|
|
120094
|
+
return t.map((e) => (e = e.reduce((s, i) => {
|
|
120095
|
+
let r = s[s.length - 1];
|
|
120096
|
+
return i === "**" && r === "**" ? s : i === ".." && r && r !== ".." && r !== "." && r !== "**" ? (s.pop(), s) : (s.push(i), s);
|
|
120097
|
+
}, []), e.length === 0 ? [""] : e));
|
|
120098
|
+
}
|
|
120099
|
+
levelTwoFileOptimize(t) {
|
|
120100
|
+
Array.isArray(t) || (t = this.slashSplit(t));
|
|
120101
|
+
let e = false;
|
|
120102
|
+
do {
|
|
120103
|
+
if (e = false, !this.preserveMultipleSlashes) {
|
|
120104
|
+
for (let i = 1;i < t.length - 1; i++) {
|
|
120105
|
+
let r = t[i];
|
|
120106
|
+
i === 1 && r === "" && t[0] === "" || (r === "." || r === "") && (e = true, t.splice(i, 1), i--);
|
|
120107
|
+
}
|
|
120108
|
+
t[0] === "." && t.length === 2 && (t[1] === "." || t[1] === "") && (e = true, t.pop());
|
|
120109
|
+
}
|
|
120110
|
+
let s = 0;
|
|
120111
|
+
for (;(s = t.indexOf("..", s + 1)) !== -1; ) {
|
|
120112
|
+
let i = t[s - 1];
|
|
120113
|
+
i && i !== "." && i !== ".." && i !== "**" && (e = true, t.splice(s - 1, 2), s -= 2);
|
|
120114
|
+
}
|
|
120115
|
+
} while (e);
|
|
120116
|
+
return t.length === 0 ? [""] : t;
|
|
120117
|
+
}
|
|
120118
|
+
firstPhasePreProcess(t) {
|
|
120119
|
+
let e = false;
|
|
120120
|
+
do {
|
|
120121
|
+
e = false;
|
|
120122
|
+
for (let s of t) {
|
|
120123
|
+
let i = -1;
|
|
120124
|
+
for (;(i = s.indexOf("**", i + 1)) !== -1; ) {
|
|
120125
|
+
let o = i;
|
|
120126
|
+
for (;s[o + 1] === "**"; )
|
|
120127
|
+
o++;
|
|
120128
|
+
o > i && s.splice(i + 1, o - i);
|
|
120129
|
+
let h = s[i + 1], a = s[i + 2], l = s[i + 3];
|
|
120130
|
+
if (h !== ".." || !a || a === "." || a === ".." || !l || l === "." || l === "..")
|
|
120131
|
+
continue;
|
|
120132
|
+
e = true, s.splice(i, 1);
|
|
120133
|
+
let u = s.slice(0);
|
|
120134
|
+
u[i] = "**", t.push(u), i--;
|
|
120135
|
+
}
|
|
120136
|
+
if (!this.preserveMultipleSlashes) {
|
|
120137
|
+
for (let o = 1;o < s.length - 1; o++) {
|
|
120138
|
+
let h = s[o];
|
|
120139
|
+
o === 1 && h === "" && s[0] === "" || (h === "." || h === "") && (e = true, s.splice(o, 1), o--);
|
|
120140
|
+
}
|
|
120141
|
+
s[0] === "." && s.length === 2 && (s[1] === "." || s[1] === "") && (e = true, s.pop());
|
|
120142
|
+
}
|
|
120143
|
+
let r = 0;
|
|
120144
|
+
for (;(r = s.indexOf("..", r + 1)) !== -1; ) {
|
|
120145
|
+
let o = s[r - 1];
|
|
120146
|
+
if (o && o !== "." && o !== ".." && o !== "**") {
|
|
120147
|
+
e = true;
|
|
120148
|
+
let a = r === 1 && s[r + 1] === "**" ? ["."] : [];
|
|
120149
|
+
s.splice(r - 1, 2, ...a), s.length === 0 && s.push(""), r -= 2;
|
|
120150
|
+
}
|
|
120151
|
+
}
|
|
120152
|
+
}
|
|
120153
|
+
} while (e);
|
|
120154
|
+
return t;
|
|
120155
|
+
}
|
|
120156
|
+
secondPhasePreProcess(t) {
|
|
120157
|
+
for (let e = 0;e < t.length - 1; e++)
|
|
120158
|
+
for (let s = e + 1;s < t.length; s++) {
|
|
120159
|
+
let i = this.partsMatch(t[e], t[s], !this.preserveMultipleSlashes);
|
|
120160
|
+
if (i) {
|
|
120161
|
+
t[e] = [], t[s] = i;
|
|
120162
|
+
break;
|
|
120163
|
+
}
|
|
120164
|
+
}
|
|
120165
|
+
return t.filter((e) => e.length);
|
|
120166
|
+
}
|
|
120167
|
+
partsMatch(t, e, s = false) {
|
|
120168
|
+
let i = 0, r = 0, o = [], h = "";
|
|
120169
|
+
for (;i < t.length && r < e.length; )
|
|
120170
|
+
if (t[i] === e[r])
|
|
120171
|
+
o.push(h === "b" ? e[r] : t[i]), i++, r++;
|
|
120172
|
+
else if (s && t[i] === "**" && e[r] === t[i + 1])
|
|
120173
|
+
o.push(t[i]), i++;
|
|
120174
|
+
else if (s && e[r] === "**" && t[i] === e[r + 1])
|
|
120175
|
+
o.push(e[r]), r++;
|
|
120176
|
+
else if (t[i] === "*" && e[r] && (this.options.dot || !e[r].startsWith(".")) && e[r] !== "**") {
|
|
120177
|
+
if (h === "b")
|
|
120178
|
+
return false;
|
|
120179
|
+
h = "a", o.push(t[i]), i++, r++;
|
|
120180
|
+
} else if (e[r] === "*" && t[i] && (this.options.dot || !t[i].startsWith(".")) && t[i] !== "**") {
|
|
120181
|
+
if (h === "a")
|
|
120182
|
+
return false;
|
|
120183
|
+
h = "b", o.push(e[r]), i++, r++;
|
|
120184
|
+
} else
|
|
120185
|
+
return false;
|
|
120186
|
+
return t.length === e.length && o;
|
|
120187
|
+
}
|
|
120188
|
+
parseNegate() {
|
|
120189
|
+
if (this.nonegate)
|
|
120190
|
+
return;
|
|
120191
|
+
let t = this.pattern, e = false, s = 0;
|
|
120192
|
+
for (let i = 0;i < t.length && t.charAt(i) === "!"; i++)
|
|
120193
|
+
e = !e, s++;
|
|
120194
|
+
s && (this.pattern = t.slice(s)), this.negate = e;
|
|
120195
|
+
}
|
|
120196
|
+
matchOne(t, e, s = false) {
|
|
120197
|
+
let i = this.options;
|
|
120198
|
+
if (this.isWindows) {
|
|
120199
|
+
let p = typeof t[0] == "string" && /^[a-z]:$/i.test(t[0]), w = !p && t[0] === "" && t[1] === "" && t[2] === "?" && /^[a-z]:$/i.test(t[3]), g = typeof e[0] == "string" && /^[a-z]:$/i.test(e[0]), S = !g && e[0] === "" && e[1] === "" && e[2] === "?" && typeof e[3] == "string" && /^[a-z]:$/i.test(e[3]), E = w ? 3 : p ? 0 : undefined, y = S ? 3 : g ? 0 : undefined;
|
|
120200
|
+
if (typeof E == "number" && typeof y == "number") {
|
|
120201
|
+
let [b, z] = [t[E], e[y]];
|
|
120202
|
+
b.toLowerCase() === z.toLowerCase() && (e[y] = b, y > E ? e = e.slice(y) : E > y && (t = t.slice(E)));
|
|
120203
|
+
}
|
|
120204
|
+
}
|
|
120205
|
+
let { optimizationLevel: r = 1 } = this.options;
|
|
120206
|
+
r >= 2 && (t = this.levelTwoFileOptimize(t)), this.debug("matchOne", this, { file: t, pattern: e }), this.debug("matchOne", t.length, e.length);
|
|
120207
|
+
for (var o = 0, h = 0, a = t.length, l = e.length;o < a && h < l; o++, h++) {
|
|
120208
|
+
this.debug("matchOne loop");
|
|
120209
|
+
var u = e[h], c = t[o];
|
|
120210
|
+
if (this.debug(e, u, c), u === false)
|
|
120211
|
+
return false;
|
|
120212
|
+
if (u === A) {
|
|
120213
|
+
this.debug("GLOBSTAR", [e, u, c]);
|
|
120214
|
+
var d = o, f = h + 1;
|
|
120215
|
+
if (f === l) {
|
|
120216
|
+
for (this.debug("** at the end");o < a; o++)
|
|
120217
|
+
if (t[o] === "." || t[o] === ".." || !i.dot && t[o].charAt(0) === ".")
|
|
120218
|
+
return false;
|
|
120219
|
+
return true;
|
|
120220
|
+
}
|
|
120221
|
+
for (;d < a; ) {
|
|
120222
|
+
var m = t[d];
|
|
120223
|
+
if (this.debug(`
|
|
120224
|
+
globstar while`, t, d, e, f, m), this.matchOne(t.slice(d), e.slice(f), s))
|
|
120225
|
+
return this.debug("globstar found match!", d, a, m), true;
|
|
120226
|
+
if (m === "." || m === ".." || !i.dot && m.charAt(0) === ".") {
|
|
120227
|
+
this.debug("dot detected!", t, d, e, f);
|
|
120228
|
+
break;
|
|
120229
|
+
}
|
|
120230
|
+
this.debug("globstar swallow a segment, and continue"), d++;
|
|
120231
|
+
}
|
|
120232
|
+
return !!(s && (this.debug(`
|
|
120233
|
+
>>> no match, partial?`, t, d, e, f), d === a));
|
|
120234
|
+
}
|
|
120235
|
+
let p;
|
|
120236
|
+
if (typeof u == "string" ? (p = c === u, this.debug("string match", u, c, p)) : (p = u.test(c), this.debug("pattern match", u, c, p)), !p)
|
|
120237
|
+
return false;
|
|
120238
|
+
}
|
|
120239
|
+
if (o === a && h === l)
|
|
120240
|
+
return true;
|
|
120241
|
+
if (o === a)
|
|
120242
|
+
return s;
|
|
120243
|
+
if (h === l)
|
|
120244
|
+
return o === a - 1 && t[o] === "";
|
|
120245
|
+
throw new Error("wtf?");
|
|
120246
|
+
}
|
|
120247
|
+
braceExpand() {
|
|
120248
|
+
return ke(this.pattern, this.options);
|
|
120249
|
+
}
|
|
120250
|
+
parse(t) {
|
|
120251
|
+
at(t);
|
|
120252
|
+
let e = this.options;
|
|
120253
|
+
if (t === "**")
|
|
120254
|
+
return A;
|
|
120255
|
+
if (t === "")
|
|
120256
|
+
return "";
|
|
120257
|
+
let s, i = null;
|
|
120258
|
+
(s = t.match(js)) ? i = e.dot ? zs : Is : (s = t.match(Rs)) ? i = (e.nocase ? e.dot ? Ms : Ds : e.dot ? Fs : Os)(s[1]) : (s = t.match(Bs)) ? i = (e.nocase ? e.dot ? $s : Us : e.dot ? Gs : Hs)(s) : (s = t.match(Ns)) ? i = e.dot ? Ls : _s : (s = t.match(Ws)) && (i = Ps);
|
|
120259
|
+
let r = Q.fromGlob(t, this.options).toMMPattern();
|
|
120260
|
+
return i && typeof r == "object" && Reflect.defineProperty(r, "test", { value: i }), r;
|
|
120261
|
+
}
|
|
120262
|
+
makeRe() {
|
|
120263
|
+
if (this.regexp || this.regexp === false)
|
|
120264
|
+
return this.regexp;
|
|
120265
|
+
let t = this.set;
|
|
120266
|
+
if (!t.length)
|
|
120267
|
+
return this.regexp = false, this.regexp;
|
|
120268
|
+
let e = this.options, s = e.noglobstar ? Vs : e.dot ? Ys : Xs, i = new Set(e.nocase ? ["i"] : []), r = t.map((a) => {
|
|
120269
|
+
let l = a.map((c) => {
|
|
120270
|
+
if (c instanceof RegExp)
|
|
120271
|
+
for (let d of c.flags.split(""))
|
|
120272
|
+
i.add(d);
|
|
120273
|
+
return typeof c == "string" ? ei(c) : c === A ? A : c._src;
|
|
120274
|
+
});
|
|
120275
|
+
l.forEach((c, d) => {
|
|
120276
|
+
let f = l[d + 1], m = l[d - 1];
|
|
120277
|
+
c !== A || m === A || (m === undefined ? f !== undefined && f !== A ? l[d + 1] = "(?:\\/|" + s + "\\/)?" + f : l[d] = s : f === undefined ? l[d - 1] = m + "(?:\\/|\\/" + s + ")?" : f !== A && (l[d - 1] = m + "(?:\\/|\\/" + s + "\\/)" + f, l[d + 1] = A));
|
|
120278
|
+
});
|
|
120279
|
+
let u = l.filter((c) => c !== A);
|
|
120280
|
+
if (this.partial && u.length >= 1) {
|
|
120281
|
+
let c = [];
|
|
120282
|
+
for (let d = 1;d <= u.length; d++)
|
|
120283
|
+
c.push(u.slice(0, d).join("/"));
|
|
120284
|
+
return "(?:" + c.join("|") + ")";
|
|
120285
|
+
}
|
|
120286
|
+
return u.join("/");
|
|
120287
|
+
}).join("|"), [o, h] = t.length > 1 ? ["(?:", ")"] : ["", ""];
|
|
120288
|
+
r = "^" + o + r + h + "$", this.partial && (r = "^(?:\\/|" + o + r.slice(1, -1) + h + ")$"), this.negate && (r = "^(?!" + r + ").+$");
|
|
120289
|
+
try {
|
|
120290
|
+
this.regexp = new RegExp(r, [...i].join(""));
|
|
120291
|
+
} catch {
|
|
120292
|
+
this.regexp = false;
|
|
120293
|
+
}
|
|
120294
|
+
return this.regexp;
|
|
120295
|
+
}
|
|
120296
|
+
slashSplit(t) {
|
|
120297
|
+
return this.preserveMultipleSlashes ? t.split("/") : this.isWindows && /^\/\/[^\/]+/.test(t) ? ["", ...t.split(/\/+/)] : t.split(/\/+/);
|
|
120298
|
+
}
|
|
120299
|
+
match(t, e = this.partial) {
|
|
120300
|
+
if (this.debug("match", t, this.pattern), this.comment)
|
|
120301
|
+
return false;
|
|
120302
|
+
if (this.empty)
|
|
120303
|
+
return t === "";
|
|
120304
|
+
if (t === "/" && e)
|
|
120305
|
+
return true;
|
|
120306
|
+
let s = this.options;
|
|
120307
|
+
this.isWindows && (t = t.split("\\").join("/"));
|
|
120308
|
+
let i = this.slashSplit(t);
|
|
120309
|
+
this.debug(this.pattern, "split", i);
|
|
120310
|
+
let r = this.set;
|
|
120311
|
+
this.debug(this.pattern, "set", r);
|
|
120312
|
+
let o = i[i.length - 1];
|
|
120313
|
+
if (!o)
|
|
120314
|
+
for (let h = i.length - 2;!o && h >= 0; h--)
|
|
120315
|
+
o = i[h];
|
|
120316
|
+
for (let h = 0;h < r.length; h++) {
|
|
120317
|
+
let a = r[h], l = i;
|
|
120318
|
+
if (s.matchBase && a.length === 1 && (l = [o]), this.matchOne(l, a, e))
|
|
120319
|
+
return s.flipNegate ? true : !this.negate;
|
|
120320
|
+
}
|
|
120321
|
+
return s.flipNegate ? false : this.negate;
|
|
120322
|
+
}
|
|
120323
|
+
static defaults(t) {
|
|
120324
|
+
return O.defaults(t).Minimatch;
|
|
120325
|
+
}
|
|
120326
|
+
};
|
|
120327
|
+
O.AST = Q;
|
|
120328
|
+
O.Minimatch = D;
|
|
120329
|
+
O.escape = tt;
|
|
120330
|
+
O.unescape = W;
|
|
120331
|
+
var si = typeof performance == "object" && performance && typeof performance.now == "function" ? performance : Date;
|
|
120332
|
+
var Oe = new Set;
|
|
120333
|
+
var Vt = typeof process == "object" && process ? process : {};
|
|
120334
|
+
var Fe = (n2, t, e, s) => {
|
|
120335
|
+
typeof Vt.emitWarning == "function" ? Vt.emitWarning(n2, t, e, s) : console.error(`[${e}] ${t}: ${n2}`);
|
|
120336
|
+
};
|
|
120337
|
+
var At = globalThis.AbortController;
|
|
120338
|
+
var Re = globalThis.AbortSignal;
|
|
120339
|
+
if (typeof At > "u") {
|
|
120340
|
+
Re = class {
|
|
120341
|
+
onabort;
|
|
120342
|
+
_onabort = [];
|
|
120343
|
+
reason;
|
|
120344
|
+
aborted = false;
|
|
120345
|
+
addEventListener(e, s) {
|
|
120346
|
+
this._onabort.push(s);
|
|
120347
|
+
}
|
|
120348
|
+
}, At = class {
|
|
120349
|
+
constructor() {
|
|
120350
|
+
t();
|
|
120351
|
+
}
|
|
120352
|
+
signal = new Re;
|
|
120353
|
+
abort(e) {
|
|
120354
|
+
if (!this.signal.aborted) {
|
|
120355
|
+
this.signal.reason = e, this.signal.aborted = true;
|
|
120356
|
+
for (let s of this.signal._onabort)
|
|
120357
|
+
s(e);
|
|
120358
|
+
this.signal.onabort?.(e);
|
|
120359
|
+
}
|
|
120360
|
+
}
|
|
120361
|
+
};
|
|
120362
|
+
let n2 = Vt.env?.LRU_CACHE_IGNORE_AC_WARNING !== "1", t = () => {
|
|
120363
|
+
n2 && (n2 = false, Fe("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.", "NO_ABORT_CONTROLLER", "ENOTSUP", t));
|
|
120364
|
+
};
|
|
120365
|
+
}
|
|
120366
|
+
var ii = (n2) => !Oe.has(n2);
|
|
120367
|
+
var q = (n2) => n2 && n2 === Math.floor(n2) && n2 > 0 && isFinite(n2);
|
|
120368
|
+
var De = (n2) => q(n2) ? n2 <= Math.pow(2, 8) ? Uint8Array : n2 <= Math.pow(2, 16) ? Uint16Array : n2 <= Math.pow(2, 32) ? Uint32Array : n2 <= Number.MAX_SAFE_INTEGER ? Tt : null : null;
|
|
120369
|
+
var Tt = class extends Array {
|
|
120370
|
+
constructor(n2) {
|
|
120371
|
+
super(n2), this.fill(0);
|
|
120372
|
+
}
|
|
120373
|
+
};
|
|
120374
|
+
var ri = class ct {
|
|
120375
|
+
heap;
|
|
120376
|
+
length;
|
|
120377
|
+
static #t = false;
|
|
120378
|
+
static create(t) {
|
|
120379
|
+
let e = De(t);
|
|
120380
|
+
if (!e)
|
|
120381
|
+
return [];
|
|
120382
|
+
ct.#t = true;
|
|
120383
|
+
let s = new ct(t, e);
|
|
120384
|
+
return ct.#t = false, s;
|
|
120385
|
+
}
|
|
120386
|
+
constructor(t, e) {
|
|
120387
|
+
if (!ct.#t)
|
|
120388
|
+
throw new TypeError("instantiate Stack using Stack.create(n)");
|
|
120389
|
+
this.heap = new e(t), this.length = 0;
|
|
120390
|
+
}
|
|
120391
|
+
push(t) {
|
|
120392
|
+
this.heap[this.length++] = t;
|
|
120393
|
+
}
|
|
120394
|
+
pop() {
|
|
120395
|
+
return this.heap[--this.length];
|
|
120396
|
+
}
|
|
120397
|
+
};
|
|
120398
|
+
var ft = class Me {
|
|
120399
|
+
#t;
|
|
120400
|
+
#s;
|
|
120401
|
+
#n;
|
|
120402
|
+
#r;
|
|
120403
|
+
#o;
|
|
120404
|
+
#S;
|
|
120405
|
+
#w;
|
|
120406
|
+
#c;
|
|
120407
|
+
get perf() {
|
|
120408
|
+
return this.#c;
|
|
120409
|
+
}
|
|
120410
|
+
ttl;
|
|
120411
|
+
ttlResolution;
|
|
120412
|
+
ttlAutopurge;
|
|
120413
|
+
updateAgeOnGet;
|
|
120414
|
+
updateAgeOnHas;
|
|
120415
|
+
allowStale;
|
|
120416
|
+
noDisposeOnSet;
|
|
120417
|
+
noUpdateTTL;
|
|
120418
|
+
maxEntrySize;
|
|
120419
|
+
sizeCalculation;
|
|
120420
|
+
noDeleteOnFetchRejection;
|
|
120421
|
+
noDeleteOnStaleGet;
|
|
120422
|
+
allowStaleOnFetchAbort;
|
|
120423
|
+
allowStaleOnFetchRejection;
|
|
120424
|
+
ignoreFetchAbort;
|
|
120425
|
+
#h;
|
|
120426
|
+
#u;
|
|
120427
|
+
#f;
|
|
120428
|
+
#a;
|
|
120429
|
+
#i;
|
|
120430
|
+
#d;
|
|
120431
|
+
#E;
|
|
120432
|
+
#b;
|
|
120433
|
+
#p;
|
|
120434
|
+
#R;
|
|
120435
|
+
#m;
|
|
120436
|
+
#C;
|
|
120437
|
+
#T;
|
|
120438
|
+
#g;
|
|
120439
|
+
#y;
|
|
120440
|
+
#x;
|
|
120441
|
+
#A;
|
|
120442
|
+
#e;
|
|
120443
|
+
#_;
|
|
120444
|
+
static unsafeExposeInternals(t) {
|
|
120445
|
+
return { starts: t.#T, ttls: t.#g, autopurgeTimers: t.#y, sizes: t.#C, keyMap: t.#f, keyList: t.#a, valList: t.#i, next: t.#d, prev: t.#E, get head() {
|
|
120446
|
+
return t.#b;
|
|
120447
|
+
}, get tail() {
|
|
120448
|
+
return t.#p;
|
|
120449
|
+
}, free: t.#R, isBackgroundFetch: (e) => t.#l(e), backgroundFetch: (e, s, i, r) => t.#U(e, s, i, r), moveToTail: (e) => t.#W(e), indexes: (e) => t.#F(e), rindexes: (e) => t.#D(e), isStale: (e) => t.#v(e) };
|
|
120450
|
+
}
|
|
120451
|
+
get max() {
|
|
120452
|
+
return this.#t;
|
|
120453
|
+
}
|
|
120454
|
+
get maxSize() {
|
|
120455
|
+
return this.#s;
|
|
120456
|
+
}
|
|
120457
|
+
get calculatedSize() {
|
|
120458
|
+
return this.#u;
|
|
120459
|
+
}
|
|
120460
|
+
get size() {
|
|
120461
|
+
return this.#h;
|
|
120462
|
+
}
|
|
120463
|
+
get fetchMethod() {
|
|
120464
|
+
return this.#S;
|
|
120465
|
+
}
|
|
120466
|
+
get memoMethod() {
|
|
120467
|
+
return this.#w;
|
|
120468
|
+
}
|
|
120469
|
+
get dispose() {
|
|
120470
|
+
return this.#n;
|
|
120471
|
+
}
|
|
120472
|
+
get onInsert() {
|
|
120473
|
+
return this.#r;
|
|
120474
|
+
}
|
|
120475
|
+
get disposeAfter() {
|
|
120476
|
+
return this.#o;
|
|
120477
|
+
}
|
|
120478
|
+
constructor(t) {
|
|
120479
|
+
let { max: e = 0, ttl: s, ttlResolution: i = 1, ttlAutopurge: r, updateAgeOnGet: o, updateAgeOnHas: h, allowStale: a, dispose: l, onInsert: u, disposeAfter: c, noDisposeOnSet: d, noUpdateTTL: f, maxSize: m = 0, maxEntrySize: p = 0, sizeCalculation: w, fetchMethod: g, memoMethod: S, noDeleteOnFetchRejection: E, noDeleteOnStaleGet: y, allowStaleOnFetchRejection: b, allowStaleOnFetchAbort: z, ignoreFetchAbort: $, perf: J } = t;
|
|
120480
|
+
if (J !== undefined && typeof J?.now != "function")
|
|
120481
|
+
throw new TypeError("perf option must have a now() method if specified");
|
|
120482
|
+
if (this.#c = J ?? si, e !== 0 && !q(e))
|
|
120483
|
+
throw new TypeError("max option must be a nonnegative integer");
|
|
120484
|
+
let Z = e ? De(e) : Array;
|
|
120485
|
+
if (!Z)
|
|
120486
|
+
throw new Error("invalid max value: " + e);
|
|
120487
|
+
if (this.#t = e, this.#s = m, this.maxEntrySize = p || this.#s, this.sizeCalculation = w, this.sizeCalculation) {
|
|
120488
|
+
if (!this.#s && !this.maxEntrySize)
|
|
120489
|
+
throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");
|
|
120490
|
+
if (typeof this.sizeCalculation != "function")
|
|
120491
|
+
throw new TypeError("sizeCalculation set to non-function");
|
|
120492
|
+
}
|
|
120493
|
+
if (S !== undefined && typeof S != "function")
|
|
120494
|
+
throw new TypeError("memoMethod must be a function if defined");
|
|
120495
|
+
if (this.#w = S, g !== undefined && typeof g != "function")
|
|
120496
|
+
throw new TypeError("fetchMethod must be a function if specified");
|
|
120497
|
+
if (this.#S = g, this.#A = !!g, this.#f = new Map, this.#a = new Array(e).fill(undefined), this.#i = new Array(e).fill(undefined), this.#d = new Z(e), this.#E = new Z(e), this.#b = 0, this.#p = 0, this.#R = ri.create(e), this.#h = 0, this.#u = 0, typeof l == "function" && (this.#n = l), typeof u == "function" && (this.#r = u), typeof c == "function" ? (this.#o = c, this.#m = []) : (this.#o = undefined, this.#m = undefined), this.#x = !!this.#n, this.#_ = !!this.#r, this.#e = !!this.#o, this.noDisposeOnSet = !!d, this.noUpdateTTL = !!f, this.noDeleteOnFetchRejection = !!E, this.allowStaleOnFetchRejection = !!b, this.allowStaleOnFetchAbort = !!z, this.ignoreFetchAbort = !!$, this.maxEntrySize !== 0) {
|
|
120498
|
+
if (this.#s !== 0 && !q(this.#s))
|
|
120499
|
+
throw new TypeError("maxSize must be a positive integer if specified");
|
|
120500
|
+
if (!q(this.maxEntrySize))
|
|
120501
|
+
throw new TypeError("maxEntrySize must be a positive integer if specified");
|
|
120502
|
+
this.#G();
|
|
120503
|
+
}
|
|
120504
|
+
if (this.allowStale = !!a, this.noDeleteOnStaleGet = !!y, this.updateAgeOnGet = !!o, this.updateAgeOnHas = !!h, this.ttlResolution = q(i) || i === 0 ? i : 1, this.ttlAutopurge = !!r, this.ttl = s || 0, this.ttl) {
|
|
120505
|
+
if (!q(this.ttl))
|
|
120506
|
+
throw new TypeError("ttl must be a positive integer if specified");
|
|
120507
|
+
this.#M();
|
|
120508
|
+
}
|
|
120509
|
+
if (this.#t === 0 && this.ttl === 0 && this.#s === 0)
|
|
120510
|
+
throw new TypeError("At least one of max, maxSize, or ttl is required");
|
|
120511
|
+
if (!this.ttlAutopurge && !this.#t && !this.#s) {
|
|
120512
|
+
let $t = "LRU_CACHE_UNBOUNDED";
|
|
120513
|
+
ii($t) && (Oe.add($t), Fe("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.", "UnboundedCacheWarning", $t, Me));
|
|
120514
|
+
}
|
|
120515
|
+
}
|
|
120516
|
+
getRemainingTTL(t) {
|
|
120517
|
+
return this.#f.has(t) ? 1 / 0 : 0;
|
|
120518
|
+
}
|
|
120519
|
+
#M() {
|
|
120520
|
+
let t = new Tt(this.#t), e = new Tt(this.#t);
|
|
120521
|
+
this.#g = t, this.#T = e;
|
|
120522
|
+
let s = this.ttlAutopurge ? new Array(this.#t) : undefined;
|
|
120523
|
+
this.#y = s, this.#j = (o, h, a = this.#c.now()) => {
|
|
120524
|
+
if (e[o] = h !== 0 ? a : 0, t[o] = h, s?.[o] && (clearTimeout(s[o]), s[o] = undefined), h !== 0 && s) {
|
|
120525
|
+
let l = setTimeout(() => {
|
|
120526
|
+
this.#v(o) && this.#O(this.#a[o], "expire");
|
|
120527
|
+
}, h + 1);
|
|
120528
|
+
l.unref && l.unref(), s[o] = l;
|
|
120529
|
+
}
|
|
120530
|
+
}, this.#k = (o) => {
|
|
120531
|
+
e[o] = t[o] !== 0 ? this.#c.now() : 0;
|
|
120532
|
+
}, this.#N = (o, h) => {
|
|
120533
|
+
if (t[h]) {
|
|
120534
|
+
let a = t[h], l = e[h];
|
|
120535
|
+
if (!a || !l)
|
|
120536
|
+
return;
|
|
120537
|
+
o.ttl = a, o.start = l, o.now = i || r();
|
|
120538
|
+
let u = o.now - l;
|
|
120539
|
+
o.remainingTTL = a - u;
|
|
120540
|
+
}
|
|
120541
|
+
};
|
|
120542
|
+
let i = 0, r = () => {
|
|
120543
|
+
let o = this.#c.now();
|
|
120544
|
+
if (this.ttlResolution > 0) {
|
|
120545
|
+
i = o;
|
|
120546
|
+
let h = setTimeout(() => i = 0, this.ttlResolution);
|
|
120547
|
+
h.unref && h.unref();
|
|
120548
|
+
}
|
|
120549
|
+
return o;
|
|
120550
|
+
};
|
|
120551
|
+
this.getRemainingTTL = (o) => {
|
|
120552
|
+
let h = this.#f.get(o);
|
|
120553
|
+
if (h === undefined)
|
|
120554
|
+
return 0;
|
|
120555
|
+
let a = t[h], l = e[h];
|
|
120556
|
+
if (!a || !l)
|
|
120557
|
+
return 1 / 0;
|
|
120558
|
+
let u = (i || r()) - l;
|
|
120559
|
+
return a - u;
|
|
120560
|
+
}, this.#v = (o) => {
|
|
120561
|
+
let h = e[o], a = t[o];
|
|
120562
|
+
return !!a && !!h && (i || r()) - h > a;
|
|
120563
|
+
};
|
|
120564
|
+
}
|
|
120565
|
+
#k = () => {};
|
|
120566
|
+
#N = () => {};
|
|
120567
|
+
#j = () => {};
|
|
120568
|
+
#v = () => false;
|
|
120569
|
+
#G() {
|
|
120570
|
+
let t = new Tt(this.#t);
|
|
120571
|
+
this.#u = 0, this.#C = t, this.#P = (e) => {
|
|
120572
|
+
this.#u -= t[e], t[e] = 0;
|
|
120573
|
+
}, this.#I = (e, s, i, r) => {
|
|
120574
|
+
if (this.#l(s))
|
|
120575
|
+
return 0;
|
|
120576
|
+
if (!q(i))
|
|
120577
|
+
if (r) {
|
|
120578
|
+
if (typeof r != "function")
|
|
120579
|
+
throw new TypeError("sizeCalculation must be a function");
|
|
120580
|
+
if (i = r(s, e), !q(i))
|
|
120581
|
+
throw new TypeError("sizeCalculation return invalid (expect positive integer)");
|
|
120582
|
+
} else
|
|
120583
|
+
throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");
|
|
120584
|
+
return i;
|
|
120585
|
+
}, this.#L = (e, s, i) => {
|
|
120586
|
+
if (t[e] = s, this.#s) {
|
|
120587
|
+
let r = this.#s - t[e];
|
|
120588
|
+
for (;this.#u > r; )
|
|
120589
|
+
this.#B(true);
|
|
120590
|
+
}
|
|
120591
|
+
this.#u += t[e], i && (i.entrySize = s, i.totalCalculatedSize = this.#u);
|
|
120592
|
+
};
|
|
120593
|
+
}
|
|
120594
|
+
#P = (t) => {};
|
|
120595
|
+
#L = (t, e, s) => {};
|
|
120596
|
+
#I = (t, e, s, i) => {
|
|
120597
|
+
if (s || i)
|
|
120598
|
+
throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");
|
|
120599
|
+
return 0;
|
|
120600
|
+
};
|
|
120601
|
+
*#F({ allowStale: t = this.allowStale } = {}) {
|
|
120602
|
+
if (this.#h)
|
|
120603
|
+
for (let e = this.#p;!(!this.#z(e) || ((t || !this.#v(e)) && (yield e), e === this.#b)); )
|
|
120604
|
+
e = this.#E[e];
|
|
120605
|
+
}
|
|
120606
|
+
*#D({ allowStale: t = this.allowStale } = {}) {
|
|
120607
|
+
if (this.#h)
|
|
120608
|
+
for (let e = this.#b;!(!this.#z(e) || ((t || !this.#v(e)) && (yield e), e === this.#p)); )
|
|
120609
|
+
e = this.#d[e];
|
|
120610
|
+
}
|
|
120611
|
+
#z(t) {
|
|
120612
|
+
return t !== undefined && this.#f.get(this.#a[t]) === t;
|
|
120613
|
+
}
|
|
120614
|
+
*entries() {
|
|
120615
|
+
for (let t of this.#F())
|
|
120616
|
+
this.#i[t] !== undefined && this.#a[t] !== undefined && !this.#l(this.#i[t]) && (yield [this.#a[t], this.#i[t]]);
|
|
120617
|
+
}
|
|
120618
|
+
*rentries() {
|
|
120619
|
+
for (let t of this.#D())
|
|
120620
|
+
this.#i[t] !== undefined && this.#a[t] !== undefined && !this.#l(this.#i[t]) && (yield [this.#a[t], this.#i[t]]);
|
|
120621
|
+
}
|
|
120622
|
+
*keys() {
|
|
120623
|
+
for (let t of this.#F()) {
|
|
120624
|
+
let e = this.#a[t];
|
|
120625
|
+
e !== undefined && !this.#l(this.#i[t]) && (yield e);
|
|
120626
|
+
}
|
|
120627
|
+
}
|
|
120628
|
+
*rkeys() {
|
|
120629
|
+
for (let t of this.#D()) {
|
|
120630
|
+
let e = this.#a[t];
|
|
120631
|
+
e !== undefined && !this.#l(this.#i[t]) && (yield e);
|
|
120632
|
+
}
|
|
120633
|
+
}
|
|
120634
|
+
*values() {
|
|
120635
|
+
for (let t of this.#F())
|
|
120636
|
+
this.#i[t] !== undefined && !this.#l(this.#i[t]) && (yield this.#i[t]);
|
|
120637
|
+
}
|
|
120638
|
+
*rvalues() {
|
|
120639
|
+
for (let t of this.#D())
|
|
120640
|
+
this.#i[t] !== undefined && !this.#l(this.#i[t]) && (yield this.#i[t]);
|
|
120641
|
+
}
|
|
120642
|
+
[Symbol.iterator]() {
|
|
120643
|
+
return this.entries();
|
|
120644
|
+
}
|
|
120645
|
+
[Symbol.toStringTag] = "LRUCache";
|
|
120646
|
+
find(t, e = {}) {
|
|
120647
|
+
for (let s of this.#F()) {
|
|
120648
|
+
let i = this.#i[s], r = this.#l(i) ? i.__staleWhileFetching : i;
|
|
120649
|
+
if (r !== undefined && t(r, this.#a[s], this))
|
|
120650
|
+
return this.get(this.#a[s], e);
|
|
120651
|
+
}
|
|
120652
|
+
}
|
|
120653
|
+
forEach(t, e = this) {
|
|
120654
|
+
for (let s of this.#F()) {
|
|
120655
|
+
let i = this.#i[s], r = this.#l(i) ? i.__staleWhileFetching : i;
|
|
120656
|
+
r !== undefined && t.call(e, r, this.#a[s], this);
|
|
120657
|
+
}
|
|
120658
|
+
}
|
|
120659
|
+
rforEach(t, e = this) {
|
|
120660
|
+
for (let s of this.#D()) {
|
|
120661
|
+
let i = this.#i[s], r = this.#l(i) ? i.__staleWhileFetching : i;
|
|
120662
|
+
r !== undefined && t.call(e, r, this.#a[s], this);
|
|
120663
|
+
}
|
|
120664
|
+
}
|
|
120665
|
+
purgeStale() {
|
|
120666
|
+
let t = false;
|
|
120667
|
+
for (let e of this.#D({ allowStale: true }))
|
|
120668
|
+
this.#v(e) && (this.#O(this.#a[e], "expire"), t = true);
|
|
120669
|
+
return t;
|
|
120670
|
+
}
|
|
120671
|
+
info(t) {
|
|
120672
|
+
let e = this.#f.get(t);
|
|
120673
|
+
if (e === undefined)
|
|
120674
|
+
return;
|
|
120675
|
+
let s = this.#i[e], i = this.#l(s) ? s.__staleWhileFetching : s;
|
|
120676
|
+
if (i === undefined)
|
|
120677
|
+
return;
|
|
120678
|
+
let r = { value: i };
|
|
120679
|
+
if (this.#g && this.#T) {
|
|
120680
|
+
let o = this.#g[e], h = this.#T[e];
|
|
120681
|
+
if (o && h) {
|
|
120682
|
+
let a = o - (this.#c.now() - h);
|
|
120683
|
+
r.ttl = a, r.start = Date.now();
|
|
120684
|
+
}
|
|
120685
|
+
}
|
|
120686
|
+
return this.#C && (r.size = this.#C[e]), r;
|
|
120687
|
+
}
|
|
120688
|
+
dump() {
|
|
120689
|
+
let t = [];
|
|
120690
|
+
for (let e of this.#F({ allowStale: true })) {
|
|
120691
|
+
let s = this.#a[e], i = this.#i[e], r = this.#l(i) ? i.__staleWhileFetching : i;
|
|
120692
|
+
if (r === undefined || s === undefined)
|
|
120693
|
+
continue;
|
|
120694
|
+
let o = { value: r };
|
|
120695
|
+
if (this.#g && this.#T) {
|
|
120696
|
+
o.ttl = this.#g[e];
|
|
120697
|
+
let h = this.#c.now() - this.#T[e];
|
|
120698
|
+
o.start = Math.floor(Date.now() - h);
|
|
120699
|
+
}
|
|
120700
|
+
this.#C && (o.size = this.#C[e]), t.unshift([s, o]);
|
|
120701
|
+
}
|
|
120702
|
+
return t;
|
|
120703
|
+
}
|
|
120704
|
+
load(t) {
|
|
120705
|
+
this.clear();
|
|
120706
|
+
for (let [e, s] of t) {
|
|
120707
|
+
if (s.start) {
|
|
120708
|
+
let i = Date.now() - s.start;
|
|
120709
|
+
s.start = this.#c.now() - i;
|
|
120710
|
+
}
|
|
120711
|
+
this.set(e, s.value, s);
|
|
120712
|
+
}
|
|
120713
|
+
}
|
|
120714
|
+
set(t, e, s = {}) {
|
|
120715
|
+
if (e === undefined)
|
|
120716
|
+
return this.delete(t), this;
|
|
120717
|
+
let { ttl: i = this.ttl, start: r, noDisposeOnSet: o = this.noDisposeOnSet, sizeCalculation: h = this.sizeCalculation, status: a } = s, { noUpdateTTL: l = this.noUpdateTTL } = s, u = this.#I(t, e, s.size || 0, h);
|
|
120718
|
+
if (this.maxEntrySize && u > this.maxEntrySize)
|
|
120719
|
+
return a && (a.set = "miss", a.maxEntrySizeExceeded = true), this.#O(t, "set"), this;
|
|
120720
|
+
let c = this.#h === 0 ? undefined : this.#f.get(t);
|
|
120721
|
+
if (c === undefined)
|
|
120722
|
+
c = this.#h === 0 ? this.#p : this.#R.length !== 0 ? this.#R.pop() : this.#h === this.#t ? this.#B(false) : this.#h, this.#a[c] = t, this.#i[c] = e, this.#f.set(t, c), this.#d[this.#p] = c, this.#E[c] = this.#p, this.#p = c, this.#h++, this.#L(c, u, a), a && (a.set = "add"), l = false, this.#_ && this.#r?.(e, t, "add");
|
|
120723
|
+
else {
|
|
120724
|
+
this.#W(c);
|
|
120725
|
+
let d = this.#i[c];
|
|
120726
|
+
if (e !== d) {
|
|
120727
|
+
if (this.#A && this.#l(d)) {
|
|
120728
|
+
d.__abortController.abort(new Error("replaced"));
|
|
120729
|
+
let { __staleWhileFetching: f } = d;
|
|
120730
|
+
f !== undefined && !o && (this.#x && this.#n?.(f, t, "set"), this.#e && this.#m?.push([f, t, "set"]));
|
|
120731
|
+
} else
|
|
120732
|
+
o || (this.#x && this.#n?.(d, t, "set"), this.#e && this.#m?.push([d, t, "set"]));
|
|
120733
|
+
if (this.#P(c), this.#L(c, u, a), this.#i[c] = e, a) {
|
|
120734
|
+
a.set = "replace";
|
|
120735
|
+
let f = d && this.#l(d) ? d.__staleWhileFetching : d;
|
|
120736
|
+
f !== undefined && (a.oldValue = f);
|
|
120737
|
+
}
|
|
120738
|
+
} else
|
|
120739
|
+
a && (a.set = "update");
|
|
120740
|
+
this.#_ && this.onInsert?.(e, t, e === d ? "update" : "replace");
|
|
120741
|
+
}
|
|
120742
|
+
if (i !== 0 && !this.#g && this.#M(), this.#g && (l || this.#j(c, i, r), a && this.#N(a, c)), !o && this.#e && this.#m) {
|
|
120743
|
+
let d = this.#m, f;
|
|
120744
|
+
for (;f = d?.shift(); )
|
|
120745
|
+
this.#o?.(...f);
|
|
120746
|
+
}
|
|
120747
|
+
return this;
|
|
120748
|
+
}
|
|
120749
|
+
pop() {
|
|
120750
|
+
try {
|
|
120751
|
+
for (;this.#h; ) {
|
|
120752
|
+
let t = this.#i[this.#b];
|
|
120753
|
+
if (this.#B(true), this.#l(t)) {
|
|
120754
|
+
if (t.__staleWhileFetching)
|
|
120755
|
+
return t.__staleWhileFetching;
|
|
120756
|
+
} else if (t !== undefined)
|
|
120757
|
+
return t;
|
|
120758
|
+
}
|
|
120759
|
+
} finally {
|
|
120760
|
+
if (this.#e && this.#m) {
|
|
120761
|
+
let t = this.#m, e;
|
|
120762
|
+
for (;e = t?.shift(); )
|
|
120763
|
+
this.#o?.(...e);
|
|
120764
|
+
}
|
|
120765
|
+
}
|
|
120766
|
+
}
|
|
120767
|
+
#B(t) {
|
|
120768
|
+
let e = this.#b, s = this.#a[e], i = this.#i[e];
|
|
120769
|
+
return this.#A && this.#l(i) ? i.__abortController.abort(new Error("evicted")) : (this.#x || this.#e) && (this.#x && this.#n?.(i, s, "evict"), this.#e && this.#m?.push([i, s, "evict"])), this.#P(e), this.#y?.[e] && (clearTimeout(this.#y[e]), this.#y[e] = undefined), t && (this.#a[e] = undefined, this.#i[e] = undefined, this.#R.push(e)), this.#h === 1 ? (this.#b = this.#p = 0, this.#R.length = 0) : this.#b = this.#d[e], this.#f.delete(s), this.#h--, e;
|
|
120770
|
+
}
|
|
120771
|
+
has(t, e = {}) {
|
|
120772
|
+
let { updateAgeOnHas: s = this.updateAgeOnHas, status: i } = e, r = this.#f.get(t);
|
|
120773
|
+
if (r !== undefined) {
|
|
120774
|
+
let o = this.#i[r];
|
|
120775
|
+
if (this.#l(o) && o.__staleWhileFetching === undefined)
|
|
120776
|
+
return false;
|
|
120777
|
+
if (this.#v(r))
|
|
120778
|
+
i && (i.has = "stale", this.#N(i, r));
|
|
120779
|
+
else
|
|
120780
|
+
return s && this.#k(r), i && (i.has = "hit", this.#N(i, r)), true;
|
|
120781
|
+
} else
|
|
120782
|
+
i && (i.has = "miss");
|
|
120783
|
+
return false;
|
|
120784
|
+
}
|
|
120785
|
+
peek(t, e = {}) {
|
|
120786
|
+
let { allowStale: s = this.allowStale } = e, i = this.#f.get(t);
|
|
120787
|
+
if (i === undefined || !s && this.#v(i))
|
|
120788
|
+
return;
|
|
120789
|
+
let r = this.#i[i];
|
|
120790
|
+
return this.#l(r) ? r.__staleWhileFetching : r;
|
|
120791
|
+
}
|
|
120792
|
+
#U(t, e, s, i) {
|
|
120793
|
+
let r = e === undefined ? undefined : this.#i[e];
|
|
120794
|
+
if (this.#l(r))
|
|
120795
|
+
return r;
|
|
120796
|
+
let o = new At, { signal: h } = s;
|
|
120797
|
+
h?.addEventListener("abort", () => o.abort(h.reason), { signal: o.signal });
|
|
120798
|
+
let a = { signal: o.signal, options: s, context: i }, l = (p, w = false) => {
|
|
120799
|
+
let { aborted: g } = o.signal, S = s.ignoreFetchAbort && p !== undefined, E = s.ignoreFetchAbort || !!(s.allowStaleOnFetchAbort && p !== undefined);
|
|
120800
|
+
if (s.status && (g && !w ? (s.status.fetchAborted = true, s.status.fetchError = o.signal.reason, S && (s.status.fetchAbortIgnored = true)) : s.status.fetchResolved = true), g && !S && !w)
|
|
120801
|
+
return c(o.signal.reason, E);
|
|
120802
|
+
let y = f, b = this.#i[e];
|
|
120803
|
+
return (b === f || S && w && b === undefined) && (p === undefined ? y.__staleWhileFetching !== undefined ? this.#i[e] = y.__staleWhileFetching : this.#O(t, "fetch") : (s.status && (s.status.fetchUpdated = true), this.set(t, p, a.options))), p;
|
|
120804
|
+
}, u = (p) => (s.status && (s.status.fetchRejected = true, s.status.fetchError = p), c(p, false)), c = (p, w) => {
|
|
120805
|
+
let { aborted: g } = o.signal, S = g && s.allowStaleOnFetchAbort, E = S || s.allowStaleOnFetchRejection, y = E || s.noDeleteOnFetchRejection, b = f;
|
|
120806
|
+
if (this.#i[e] === f && (!y || !w && b.__staleWhileFetching === undefined ? this.#O(t, "fetch") : S || (this.#i[e] = b.__staleWhileFetching)), E)
|
|
120807
|
+
return s.status && b.__staleWhileFetching !== undefined && (s.status.returnedStale = true), b.__staleWhileFetching;
|
|
120808
|
+
if (b.__returned === b)
|
|
120809
|
+
throw p;
|
|
120810
|
+
}, d = (p, w) => {
|
|
120811
|
+
let g = this.#S?.(t, r, a);
|
|
120812
|
+
g && g instanceof Promise && g.then((S) => p(S === undefined ? undefined : S), w), o.signal.addEventListener("abort", () => {
|
|
120813
|
+
(!s.ignoreFetchAbort || s.allowStaleOnFetchAbort) && (p(undefined), s.allowStaleOnFetchAbort && (p = (S) => l(S, true)));
|
|
120814
|
+
});
|
|
120815
|
+
};
|
|
120816
|
+
s.status && (s.status.fetchDispatched = true);
|
|
120817
|
+
let f = new Promise(d).then(l, u), m = Object.assign(f, { __abortController: o, __staleWhileFetching: r, __returned: undefined });
|
|
120818
|
+
return e === undefined ? (this.set(t, m, { ...a.options, status: undefined }), e = this.#f.get(t)) : this.#i[e] = m, m;
|
|
120819
|
+
}
|
|
120820
|
+
#l(t) {
|
|
120821
|
+
if (!this.#A)
|
|
120822
|
+
return false;
|
|
120823
|
+
let e = t;
|
|
120824
|
+
return !!e && e instanceof Promise && e.hasOwnProperty("__staleWhileFetching") && e.__abortController instanceof At;
|
|
120825
|
+
}
|
|
120826
|
+
async fetch(t, e = {}) {
|
|
120827
|
+
let { allowStale: s = this.allowStale, updateAgeOnGet: i = this.updateAgeOnGet, noDeleteOnStaleGet: r = this.noDeleteOnStaleGet, ttl: o = this.ttl, noDisposeOnSet: h = this.noDisposeOnSet, size: a = 0, sizeCalculation: l = this.sizeCalculation, noUpdateTTL: u = this.noUpdateTTL, noDeleteOnFetchRejection: c = this.noDeleteOnFetchRejection, allowStaleOnFetchRejection: d = this.allowStaleOnFetchRejection, ignoreFetchAbort: f = this.ignoreFetchAbort, allowStaleOnFetchAbort: m = this.allowStaleOnFetchAbort, context: p, forceRefresh: w = false, status: g, signal: S } = e;
|
|
120828
|
+
if (!this.#A)
|
|
120829
|
+
return g && (g.fetch = "get"), this.get(t, { allowStale: s, updateAgeOnGet: i, noDeleteOnStaleGet: r, status: g });
|
|
120830
|
+
let E = { allowStale: s, updateAgeOnGet: i, noDeleteOnStaleGet: r, ttl: o, noDisposeOnSet: h, size: a, sizeCalculation: l, noUpdateTTL: u, noDeleteOnFetchRejection: c, allowStaleOnFetchRejection: d, allowStaleOnFetchAbort: m, ignoreFetchAbort: f, status: g, signal: S }, y = this.#f.get(t);
|
|
120831
|
+
if (y === undefined) {
|
|
120832
|
+
g && (g.fetch = "miss");
|
|
120833
|
+
let b = this.#U(t, y, E, p);
|
|
120834
|
+
return b.__returned = b;
|
|
120835
|
+
} else {
|
|
120836
|
+
let b = this.#i[y];
|
|
120837
|
+
if (this.#l(b)) {
|
|
120838
|
+
let Z = s && b.__staleWhileFetching !== undefined;
|
|
120839
|
+
return g && (g.fetch = "inflight", Z && (g.returnedStale = true)), Z ? b.__staleWhileFetching : b.__returned = b;
|
|
120840
|
+
}
|
|
120841
|
+
let z = this.#v(y);
|
|
120842
|
+
if (!w && !z)
|
|
120843
|
+
return g && (g.fetch = "hit"), this.#W(y), i && this.#k(y), g && this.#N(g, y), b;
|
|
120844
|
+
let $ = this.#U(t, y, E, p), J = $.__staleWhileFetching !== undefined && s;
|
|
120845
|
+
return g && (g.fetch = z ? "stale" : "refresh", J && z && (g.returnedStale = true)), J ? $.__staleWhileFetching : $.__returned = $;
|
|
120846
|
+
}
|
|
120847
|
+
}
|
|
120848
|
+
async forceFetch(t, e = {}) {
|
|
120849
|
+
let s = await this.fetch(t, e);
|
|
120850
|
+
if (s === undefined)
|
|
120851
|
+
throw new Error("fetch() returned undefined");
|
|
120852
|
+
return s;
|
|
120853
|
+
}
|
|
120854
|
+
memo(t, e = {}) {
|
|
120855
|
+
let s = this.#w;
|
|
120856
|
+
if (!s)
|
|
120857
|
+
throw new Error("no memoMethod provided to constructor");
|
|
120858
|
+
let { context: i, forceRefresh: r, ...o } = e, h = this.get(t, o);
|
|
120859
|
+
if (!r && h !== undefined)
|
|
120860
|
+
return h;
|
|
120861
|
+
let a = s(t, h, { options: o, context: i });
|
|
120862
|
+
return this.set(t, a, o), a;
|
|
120863
|
+
}
|
|
120864
|
+
get(t, e = {}) {
|
|
120865
|
+
let { allowStale: s = this.allowStale, updateAgeOnGet: i = this.updateAgeOnGet, noDeleteOnStaleGet: r = this.noDeleteOnStaleGet, status: o } = e, h = this.#f.get(t);
|
|
120866
|
+
if (h !== undefined) {
|
|
120867
|
+
let a = this.#i[h], l = this.#l(a);
|
|
120868
|
+
return o && this.#N(o, h), this.#v(h) ? (o && (o.get = "stale"), l ? (o && s && a.__staleWhileFetching !== undefined && (o.returnedStale = true), s ? a.__staleWhileFetching : undefined) : (r || this.#O(t, "expire"), o && s && (o.returnedStale = true), s ? a : undefined)) : (o && (o.get = "hit"), l ? a.__staleWhileFetching : (this.#W(h), i && this.#k(h), a));
|
|
120869
|
+
} else
|
|
120870
|
+
o && (o.get = "miss");
|
|
120871
|
+
}
|
|
120872
|
+
#$(t, e) {
|
|
120873
|
+
this.#E[e] = t, this.#d[t] = e;
|
|
120874
|
+
}
|
|
120875
|
+
#W(t) {
|
|
120876
|
+
t !== this.#p && (t === this.#b ? this.#b = this.#d[t] : this.#$(this.#E[t], this.#d[t]), this.#$(this.#p, t), this.#p = t);
|
|
120877
|
+
}
|
|
120878
|
+
delete(t) {
|
|
120879
|
+
return this.#O(t, "delete");
|
|
120880
|
+
}
|
|
120881
|
+
#O(t, e) {
|
|
120882
|
+
let s = false;
|
|
120883
|
+
if (this.#h !== 0) {
|
|
120884
|
+
let i = this.#f.get(t);
|
|
120885
|
+
if (i !== undefined)
|
|
120886
|
+
if (this.#y?.[i] && (clearTimeout(this.#y?.[i]), this.#y[i] = undefined), s = true, this.#h === 1)
|
|
120887
|
+
this.#H(e);
|
|
120888
|
+
else {
|
|
120889
|
+
this.#P(i);
|
|
120890
|
+
let r = this.#i[i];
|
|
120891
|
+
if (this.#l(r) ? r.__abortController.abort(new Error("deleted")) : (this.#x || this.#e) && (this.#x && this.#n?.(r, t, e), this.#e && this.#m?.push([r, t, e])), this.#f.delete(t), this.#a[i] = undefined, this.#i[i] = undefined, i === this.#p)
|
|
120892
|
+
this.#p = this.#E[i];
|
|
120893
|
+
else if (i === this.#b)
|
|
120894
|
+
this.#b = this.#d[i];
|
|
120895
|
+
else {
|
|
120896
|
+
let o = this.#E[i];
|
|
120897
|
+
this.#d[o] = this.#d[i];
|
|
120898
|
+
let h = this.#d[i];
|
|
120899
|
+
this.#E[h] = this.#E[i];
|
|
120900
|
+
}
|
|
120901
|
+
this.#h--, this.#R.push(i);
|
|
120902
|
+
}
|
|
120903
|
+
}
|
|
120904
|
+
if (this.#e && this.#m?.length) {
|
|
120905
|
+
let i = this.#m, r;
|
|
120906
|
+
for (;r = i?.shift(); )
|
|
120907
|
+
this.#o?.(...r);
|
|
120908
|
+
}
|
|
120909
|
+
return s;
|
|
120910
|
+
}
|
|
120911
|
+
clear() {
|
|
120912
|
+
return this.#H("delete");
|
|
120913
|
+
}
|
|
120914
|
+
#H(t) {
|
|
120915
|
+
for (let e of this.#D({ allowStale: true })) {
|
|
120916
|
+
let s = this.#i[e];
|
|
120917
|
+
if (this.#l(s))
|
|
120918
|
+
s.__abortController.abort(new Error("deleted"));
|
|
120919
|
+
else {
|
|
120920
|
+
let i = this.#a[e];
|
|
120921
|
+
this.#x && this.#n?.(s, i, t), this.#e && this.#m?.push([s, i, t]);
|
|
120922
|
+
}
|
|
120923
|
+
}
|
|
120924
|
+
if (this.#f.clear(), this.#i.fill(undefined), this.#a.fill(undefined), this.#g && this.#T) {
|
|
120925
|
+
this.#g.fill(0), this.#T.fill(0);
|
|
120926
|
+
for (let e of this.#y ?? [])
|
|
120927
|
+
e !== undefined && clearTimeout(e);
|
|
120928
|
+
this.#y?.fill(undefined);
|
|
120929
|
+
}
|
|
120930
|
+
if (this.#C && this.#C.fill(0), this.#b = 0, this.#p = 0, this.#R.length = 0, this.#u = 0, this.#h = 0, this.#e && this.#m) {
|
|
120931
|
+
let e = this.#m, s;
|
|
120932
|
+
for (;s = e?.shift(); )
|
|
120933
|
+
this.#o?.(...s);
|
|
120934
|
+
}
|
|
120935
|
+
}
|
|
120936
|
+
};
|
|
120937
|
+
var Ne = typeof process == "object" && process ? process : { stdout: null, stderr: null };
|
|
120938
|
+
var oi = (n2) => !!n2 && typeof n2 == "object" && (n2 instanceof V || n2 instanceof Pe || hi(n2) || ai(n2));
|
|
120939
|
+
var hi = (n2) => !!n2 && typeof n2 == "object" && n2 instanceof ee && typeof n2.pipe == "function" && n2.pipe !== Pe.Writable.prototype.pipe;
|
|
120940
|
+
var ai = (n2) => !!n2 && typeof n2 == "object" && n2 instanceof ee && typeof n2.write == "function" && typeof n2.end == "function";
|
|
120941
|
+
var G = Symbol("EOF");
|
|
120942
|
+
var H = Symbol("maybeEmitEnd");
|
|
120943
|
+
var K = Symbol("emittedEnd");
|
|
120944
|
+
var kt = Symbol("emittingEnd");
|
|
120945
|
+
var ut = Symbol("emittedError");
|
|
120946
|
+
var Rt = Symbol("closed");
|
|
120947
|
+
var _e = Symbol("read");
|
|
120948
|
+
var Ot = Symbol("flush");
|
|
120949
|
+
var Le = Symbol("flushChunk");
|
|
120950
|
+
var P = Symbol("encoding");
|
|
120951
|
+
var et = Symbol("decoder");
|
|
120952
|
+
var v = Symbol("flowing");
|
|
120953
|
+
var dt = Symbol("paused");
|
|
120954
|
+
var st = Symbol("resume");
|
|
120955
|
+
var C = Symbol("buffer");
|
|
120956
|
+
var F = Symbol("pipes");
|
|
120957
|
+
var T = Symbol("bufferLength");
|
|
120958
|
+
var Yt = Symbol("bufferPush");
|
|
120959
|
+
var Ft = Symbol("bufferShift");
|
|
120960
|
+
var k = Symbol("objectMode");
|
|
120961
|
+
var x = Symbol("destroyed");
|
|
120962
|
+
var Xt = Symbol("error");
|
|
120963
|
+
var Jt = Symbol("emitData");
|
|
120964
|
+
var We = Symbol("emitEnd");
|
|
120965
|
+
var Zt = Symbol("emitEnd2");
|
|
120966
|
+
var B = Symbol("async");
|
|
120967
|
+
var Qt = Symbol("abort");
|
|
120968
|
+
var Dt = Symbol("aborted");
|
|
120969
|
+
var pt = Symbol("signal");
|
|
120970
|
+
var Y = Symbol("dataListeners");
|
|
120971
|
+
var M = Symbol("discarded");
|
|
120972
|
+
var mt = (n2) => Promise.resolve().then(n2);
|
|
120973
|
+
var li = (n2) => n2();
|
|
120974
|
+
var ci = (n2) => n2 === "end" || n2 === "finish" || n2 === "prefinish";
|
|
120975
|
+
var fi = (n2) => n2 instanceof ArrayBuffer || !!n2 && typeof n2 == "object" && n2.constructor && n2.constructor.name === "ArrayBuffer" && n2.byteLength >= 0;
|
|
120976
|
+
var ui = (n2) => !Buffer.isBuffer(n2) && ArrayBuffer.isView(n2);
|
|
120977
|
+
var Mt = class {
|
|
120978
|
+
src;
|
|
120979
|
+
dest;
|
|
120980
|
+
opts;
|
|
120981
|
+
ondrain;
|
|
120982
|
+
constructor(t, e, s) {
|
|
120983
|
+
this.src = t, this.dest = e, this.opts = s, this.ondrain = () => t[st](), this.dest.on("drain", this.ondrain);
|
|
120984
|
+
}
|
|
120985
|
+
unpipe() {
|
|
120986
|
+
this.dest.removeListener("drain", this.ondrain);
|
|
120987
|
+
}
|
|
120988
|
+
proxyErrors(t) {}
|
|
120989
|
+
end() {
|
|
120990
|
+
this.unpipe(), this.opts.end && this.dest.end();
|
|
120991
|
+
}
|
|
120992
|
+
};
|
|
120993
|
+
var te = class extends Mt {
|
|
120994
|
+
unpipe() {
|
|
120995
|
+
this.src.removeListener("error", this.proxyErrors), super.unpipe();
|
|
120996
|
+
}
|
|
120997
|
+
constructor(t, e, s) {
|
|
120998
|
+
super(t, e, s), this.proxyErrors = (i) => this.dest.emit("error", i), t.on("error", this.proxyErrors);
|
|
120999
|
+
}
|
|
121000
|
+
};
|
|
121001
|
+
var di = (n2) => !!n2.objectMode;
|
|
121002
|
+
var pi = (n2) => !n2.objectMode && !!n2.encoding && n2.encoding !== "buffer";
|
|
121003
|
+
var V = class extends ee {
|
|
121004
|
+
[v] = false;
|
|
121005
|
+
[dt] = false;
|
|
121006
|
+
[F] = [];
|
|
121007
|
+
[C] = [];
|
|
121008
|
+
[k];
|
|
121009
|
+
[P];
|
|
121010
|
+
[B];
|
|
121011
|
+
[et];
|
|
121012
|
+
[G] = false;
|
|
121013
|
+
[K] = false;
|
|
121014
|
+
[kt] = false;
|
|
121015
|
+
[Rt] = false;
|
|
121016
|
+
[ut] = null;
|
|
121017
|
+
[T] = 0;
|
|
121018
|
+
[x] = false;
|
|
121019
|
+
[pt];
|
|
121020
|
+
[Dt] = false;
|
|
121021
|
+
[Y] = 0;
|
|
121022
|
+
[M] = false;
|
|
121023
|
+
writable = true;
|
|
121024
|
+
readable = true;
|
|
121025
|
+
constructor(...t) {
|
|
121026
|
+
let e = t[0] || {};
|
|
121027
|
+
if (super(), e.objectMode && typeof e.encoding == "string")
|
|
121028
|
+
throw new TypeError("Encoding and objectMode may not be used together");
|
|
121029
|
+
di(e) ? (this[k] = true, this[P] = null) : pi(e) ? (this[P] = e.encoding, this[k] = false) : (this[k] = false, this[P] = null), this[B] = !!e.async, this[et] = this[P] ? new ni(this[P]) : null, e && e.debugExposeBuffer === true && Object.defineProperty(this, "buffer", { get: () => this[C] }), e && e.debugExposePipes === true && Object.defineProperty(this, "pipes", { get: () => this[F] });
|
|
121030
|
+
let { signal: s } = e;
|
|
121031
|
+
s && (this[pt] = s, s.aborted ? this[Qt]() : s.addEventListener("abort", () => this[Qt]()));
|
|
121032
|
+
}
|
|
121033
|
+
get bufferLength() {
|
|
121034
|
+
return this[T];
|
|
121035
|
+
}
|
|
121036
|
+
get encoding() {
|
|
121037
|
+
return this[P];
|
|
121038
|
+
}
|
|
121039
|
+
set encoding(t) {
|
|
121040
|
+
throw new Error("Encoding must be set at instantiation time");
|
|
121041
|
+
}
|
|
121042
|
+
setEncoding(t) {
|
|
121043
|
+
throw new Error("Encoding must be set at instantiation time");
|
|
121044
|
+
}
|
|
121045
|
+
get objectMode() {
|
|
121046
|
+
return this[k];
|
|
121047
|
+
}
|
|
121048
|
+
set objectMode(t) {
|
|
121049
|
+
throw new Error("objectMode must be set at instantiation time");
|
|
121050
|
+
}
|
|
121051
|
+
get async() {
|
|
121052
|
+
return this[B];
|
|
121053
|
+
}
|
|
121054
|
+
set async(t) {
|
|
121055
|
+
this[B] = this[B] || !!t;
|
|
121056
|
+
}
|
|
121057
|
+
[Qt]() {
|
|
121058
|
+
this[Dt] = true, this.emit("abort", this[pt]?.reason), this.destroy(this[pt]?.reason);
|
|
121059
|
+
}
|
|
121060
|
+
get aborted() {
|
|
121061
|
+
return this[Dt];
|
|
121062
|
+
}
|
|
121063
|
+
set aborted(t) {}
|
|
121064
|
+
write(t, e, s) {
|
|
121065
|
+
if (this[Dt])
|
|
121066
|
+
return false;
|
|
121067
|
+
if (this[G])
|
|
121068
|
+
throw new Error("write after end");
|
|
121069
|
+
if (this[x])
|
|
121070
|
+
return this.emit("error", Object.assign(new Error("Cannot call write after a stream was destroyed"), { code: "ERR_STREAM_DESTROYED" })), true;
|
|
121071
|
+
typeof e == "function" && (s = e, e = "utf8"), e || (e = "utf8");
|
|
121072
|
+
let i = this[B] ? mt : li;
|
|
121073
|
+
if (!this[k] && !Buffer.isBuffer(t)) {
|
|
121074
|
+
if (ui(t))
|
|
121075
|
+
t = Buffer.from(t.buffer, t.byteOffset, t.byteLength);
|
|
121076
|
+
else if (fi(t))
|
|
121077
|
+
t = Buffer.from(t);
|
|
121078
|
+
else if (typeof t != "string")
|
|
121079
|
+
throw new Error("Non-contiguous data written to non-objectMode stream");
|
|
121080
|
+
}
|
|
121081
|
+
return this[k] ? (this[v] && this[T] !== 0 && this[Ot](true), this[v] ? this.emit("data", t) : this[Yt](t), this[T] !== 0 && this.emit("readable"), s && i(s), this[v]) : t.length ? (typeof t == "string" && !(e === this[P] && !this[et]?.lastNeed) && (t = Buffer.from(t, e)), Buffer.isBuffer(t) && this[P] && (t = this[et].write(t)), this[v] && this[T] !== 0 && this[Ot](true), this[v] ? this.emit("data", t) : this[Yt](t), this[T] !== 0 && this.emit("readable"), s && i(s), this[v]) : (this[T] !== 0 && this.emit("readable"), s && i(s), this[v]);
|
|
121082
|
+
}
|
|
121083
|
+
read(t) {
|
|
121084
|
+
if (this[x])
|
|
121085
|
+
return null;
|
|
121086
|
+
if (this[M] = false, this[T] === 0 || t === 0 || t && t > this[T])
|
|
121087
|
+
return this[H](), null;
|
|
121088
|
+
this[k] && (t = null), this[C].length > 1 && !this[k] && (this[C] = [this[P] ? this[C].join("") : Buffer.concat(this[C], this[T])]);
|
|
121089
|
+
let e = this[_e](t || null, this[C][0]);
|
|
121090
|
+
return this[H](), e;
|
|
121091
|
+
}
|
|
121092
|
+
[_e](t, e) {
|
|
121093
|
+
if (this[k])
|
|
121094
|
+
this[Ft]();
|
|
121095
|
+
else {
|
|
121096
|
+
let s = e;
|
|
121097
|
+
t === s.length || t === null ? this[Ft]() : typeof s == "string" ? (this[C][0] = s.slice(t), e = s.slice(0, t), this[T] -= t) : (this[C][0] = s.subarray(t), e = s.subarray(0, t), this[T] -= t);
|
|
121098
|
+
}
|
|
121099
|
+
return this.emit("data", e), !this[C].length && !this[G] && this.emit("drain"), e;
|
|
121100
|
+
}
|
|
121101
|
+
end(t, e, s) {
|
|
121102
|
+
return typeof t == "function" && (s = t, t = undefined), typeof e == "function" && (s = e, e = "utf8"), t !== undefined && this.write(t, e), s && this.once("end", s), this[G] = true, this.writable = false, (this[v] || !this[dt]) && this[H](), this;
|
|
121103
|
+
}
|
|
121104
|
+
[st]() {
|
|
121105
|
+
this[x] || (!this[Y] && !this[F].length && (this[M] = true), this[dt] = false, this[v] = true, this.emit("resume"), this[C].length ? this[Ot]() : this[G] ? this[H]() : this.emit("drain"));
|
|
121106
|
+
}
|
|
121107
|
+
resume() {
|
|
121108
|
+
return this[st]();
|
|
121109
|
+
}
|
|
121110
|
+
pause() {
|
|
121111
|
+
this[v] = false, this[dt] = true, this[M] = false;
|
|
121112
|
+
}
|
|
121113
|
+
get destroyed() {
|
|
121114
|
+
return this[x];
|
|
121115
|
+
}
|
|
121116
|
+
get flowing() {
|
|
121117
|
+
return this[v];
|
|
121118
|
+
}
|
|
121119
|
+
get paused() {
|
|
121120
|
+
return this[dt];
|
|
121121
|
+
}
|
|
121122
|
+
[Yt](t) {
|
|
121123
|
+
this[k] ? this[T] += 1 : this[T] += t.length, this[C].push(t);
|
|
121124
|
+
}
|
|
121125
|
+
[Ft]() {
|
|
121126
|
+
return this[k] ? this[T] -= 1 : this[T] -= this[C][0].length, this[C].shift();
|
|
121127
|
+
}
|
|
121128
|
+
[Ot](t = false) {
|
|
121129
|
+
do
|
|
121130
|
+
;
|
|
121131
|
+
while (this[Le](this[Ft]()) && this[C].length);
|
|
121132
|
+
!t && !this[C].length && !this[G] && this.emit("drain");
|
|
121133
|
+
}
|
|
121134
|
+
[Le](t) {
|
|
121135
|
+
return this.emit("data", t), this[v];
|
|
121136
|
+
}
|
|
121137
|
+
pipe(t, e) {
|
|
121138
|
+
if (this[x])
|
|
121139
|
+
return t;
|
|
121140
|
+
this[M] = false;
|
|
121141
|
+
let s = this[K];
|
|
121142
|
+
return e = e || {}, t === Ne.stdout || t === Ne.stderr ? e.end = false : e.end = e.end !== false, e.proxyErrors = !!e.proxyErrors, s ? e.end && t.end() : (this[F].push(e.proxyErrors ? new te(this, t, e) : new Mt(this, t, e)), this[B] ? mt(() => this[st]()) : this[st]()), t;
|
|
121143
|
+
}
|
|
121144
|
+
unpipe(t) {
|
|
121145
|
+
let e = this[F].find((s) => s.dest === t);
|
|
121146
|
+
e && (this[F].length === 1 ? (this[v] && this[Y] === 0 && (this[v] = false), this[F] = []) : this[F].splice(this[F].indexOf(e), 1), e.unpipe());
|
|
121147
|
+
}
|
|
121148
|
+
addListener(t, e) {
|
|
121149
|
+
return this.on(t, e);
|
|
121150
|
+
}
|
|
121151
|
+
on(t, e) {
|
|
121152
|
+
let s = super.on(t, e);
|
|
121153
|
+
if (t === "data")
|
|
121154
|
+
this[M] = false, this[Y]++, !this[F].length && !this[v] && this[st]();
|
|
121155
|
+
else if (t === "readable" && this[T] !== 0)
|
|
121156
|
+
super.emit("readable");
|
|
121157
|
+
else if (ci(t) && this[K])
|
|
121158
|
+
super.emit(t), this.removeAllListeners(t);
|
|
121159
|
+
else if (t === "error" && this[ut]) {
|
|
121160
|
+
let i = e;
|
|
121161
|
+
this[B] ? mt(() => i.call(this, this[ut])) : i.call(this, this[ut]);
|
|
121162
|
+
}
|
|
121163
|
+
return s;
|
|
121164
|
+
}
|
|
121165
|
+
removeListener(t, e) {
|
|
121166
|
+
return this.off(t, e);
|
|
121167
|
+
}
|
|
121168
|
+
off(t, e) {
|
|
121169
|
+
let s = super.off(t, e);
|
|
121170
|
+
return t === "data" && (this[Y] = this.listeners("data").length, this[Y] === 0 && !this[M] && !this[F].length && (this[v] = false)), s;
|
|
121171
|
+
}
|
|
121172
|
+
removeAllListeners(t) {
|
|
121173
|
+
let e = super.removeAllListeners(t);
|
|
121174
|
+
return (t === "data" || t === undefined) && (this[Y] = 0, !this[M] && !this[F].length && (this[v] = false)), e;
|
|
121175
|
+
}
|
|
121176
|
+
get emittedEnd() {
|
|
121177
|
+
return this[K];
|
|
121178
|
+
}
|
|
121179
|
+
[H]() {
|
|
121180
|
+
!this[kt] && !this[K] && !this[x] && this[C].length === 0 && this[G] && (this[kt] = true, this.emit("end"), this.emit("prefinish"), this.emit("finish"), this[Rt] && this.emit("close"), this[kt] = false);
|
|
121181
|
+
}
|
|
121182
|
+
emit(t, ...e) {
|
|
121183
|
+
let s = e[0];
|
|
121184
|
+
if (t !== "error" && t !== "close" && t !== x && this[x])
|
|
121185
|
+
return false;
|
|
121186
|
+
if (t === "data")
|
|
121187
|
+
return !this[k] && !s ? false : this[B] ? (mt(() => this[Jt](s)), true) : this[Jt](s);
|
|
121188
|
+
if (t === "end")
|
|
121189
|
+
return this[We]();
|
|
121190
|
+
if (t === "close") {
|
|
121191
|
+
if (this[Rt] = true, !this[K] && !this[x])
|
|
121192
|
+
return false;
|
|
121193
|
+
let r = super.emit("close");
|
|
121194
|
+
return this.removeAllListeners("close"), r;
|
|
121195
|
+
} else if (t === "error") {
|
|
121196
|
+
this[ut] = s, super.emit(Xt, s);
|
|
121197
|
+
let r = !this[pt] || this.listeners("error").length ? super.emit("error", s) : false;
|
|
121198
|
+
return this[H](), r;
|
|
121199
|
+
} else if (t === "resume") {
|
|
121200
|
+
let r = super.emit("resume");
|
|
121201
|
+
return this[H](), r;
|
|
121202
|
+
} else if (t === "finish" || t === "prefinish") {
|
|
121203
|
+
let r = super.emit(t);
|
|
121204
|
+
return this.removeAllListeners(t), r;
|
|
121205
|
+
}
|
|
121206
|
+
let i = super.emit(t, ...e);
|
|
121207
|
+
return this[H](), i;
|
|
121208
|
+
}
|
|
121209
|
+
[Jt](t) {
|
|
121210
|
+
for (let s of this[F])
|
|
121211
|
+
s.dest.write(t) === false && this.pause();
|
|
121212
|
+
let e = this[M] ? false : super.emit("data", t);
|
|
121213
|
+
return this[H](), e;
|
|
121214
|
+
}
|
|
121215
|
+
[We]() {
|
|
121216
|
+
return this[K] ? false : (this[K] = true, this.readable = false, this[B] ? (mt(() => this[Zt]()), true) : this[Zt]());
|
|
121217
|
+
}
|
|
121218
|
+
[Zt]() {
|
|
121219
|
+
if (this[et]) {
|
|
121220
|
+
let e = this[et].end();
|
|
121221
|
+
if (e) {
|
|
121222
|
+
for (let s of this[F])
|
|
121223
|
+
s.dest.write(e);
|
|
121224
|
+
this[M] || super.emit("data", e);
|
|
121225
|
+
}
|
|
121226
|
+
}
|
|
121227
|
+
for (let e of this[F])
|
|
121228
|
+
e.end();
|
|
121229
|
+
let t = super.emit("end");
|
|
121230
|
+
return this.removeAllListeners("end"), t;
|
|
121231
|
+
}
|
|
121232
|
+
async collect() {
|
|
121233
|
+
let t = Object.assign([], { dataLength: 0 });
|
|
121234
|
+
this[k] || (t.dataLength = 0);
|
|
121235
|
+
let e = this.promise();
|
|
121236
|
+
return this.on("data", (s) => {
|
|
121237
|
+
t.push(s), this[k] || (t.dataLength += s.length);
|
|
121238
|
+
}), await e, t;
|
|
121239
|
+
}
|
|
121240
|
+
async concat() {
|
|
121241
|
+
if (this[k])
|
|
121242
|
+
throw new Error("cannot concat in objectMode");
|
|
121243
|
+
let t = await this.collect();
|
|
121244
|
+
return this[P] ? t.join("") : Buffer.concat(t, t.dataLength);
|
|
121245
|
+
}
|
|
121246
|
+
async promise() {
|
|
121247
|
+
return new Promise((t, e) => {
|
|
121248
|
+
this.on(x, () => e(new Error("stream destroyed"))), this.on("error", (s) => e(s)), this.on("end", () => t());
|
|
121249
|
+
});
|
|
121250
|
+
}
|
|
121251
|
+
[Symbol.asyncIterator]() {
|
|
121252
|
+
this[M] = false;
|
|
121253
|
+
let t = false, e = async () => (this.pause(), t = true, { value: undefined, done: true });
|
|
121254
|
+
return { next: () => {
|
|
121255
|
+
if (t)
|
|
121256
|
+
return e();
|
|
121257
|
+
let i = this.read();
|
|
121258
|
+
if (i !== null)
|
|
121259
|
+
return Promise.resolve({ done: false, value: i });
|
|
121260
|
+
if (this[G])
|
|
121261
|
+
return e();
|
|
121262
|
+
let r, o, h = (c) => {
|
|
121263
|
+
this.off("data", a), this.off("end", l), this.off(x, u), e(), o(c);
|
|
121264
|
+
}, a = (c) => {
|
|
121265
|
+
this.off("error", h), this.off("end", l), this.off(x, u), this.pause(), r({ value: c, done: !!this[G] });
|
|
121266
|
+
}, l = () => {
|
|
121267
|
+
this.off("error", h), this.off("data", a), this.off(x, u), e(), r({ done: true, value: undefined });
|
|
121268
|
+
}, u = () => h(new Error("stream destroyed"));
|
|
121269
|
+
return new Promise((c, d) => {
|
|
121270
|
+
o = d, r = c, this.once(x, u), this.once("error", h), this.once("end", l), this.once("data", a);
|
|
121271
|
+
});
|
|
121272
|
+
}, throw: e, return: e, [Symbol.asyncIterator]() {
|
|
121273
|
+
return this;
|
|
121274
|
+
}, [Symbol.asyncDispose]: async () => {} };
|
|
121275
|
+
}
|
|
121276
|
+
[Symbol.iterator]() {
|
|
121277
|
+
this[M] = false;
|
|
121278
|
+
let t = false, e = () => (this.pause(), this.off(Xt, e), this.off(x, e), this.off("end", e), t = true, { done: true, value: undefined }), s = () => {
|
|
121279
|
+
if (t)
|
|
121280
|
+
return e();
|
|
121281
|
+
let i = this.read();
|
|
121282
|
+
return i === null ? e() : { done: false, value: i };
|
|
121283
|
+
};
|
|
121284
|
+
return this.once("end", e), this.once(Xt, e), this.once(x, e), { next: s, throw: e, return: e, [Symbol.iterator]() {
|
|
121285
|
+
return this;
|
|
121286
|
+
}, [Symbol.dispose]: () => {} };
|
|
121287
|
+
}
|
|
121288
|
+
destroy(t) {
|
|
121289
|
+
if (this[x])
|
|
121290
|
+
return t ? this.emit("error", t) : this.emit(x), this;
|
|
121291
|
+
this[x] = true, this[M] = true, this[C].length = 0, this[T] = 0;
|
|
121292
|
+
let e = this;
|
|
121293
|
+
return typeof e.close == "function" && !this[Rt] && e.close(), t ? this.emit("error", t) : this.emit(x), this;
|
|
121294
|
+
}
|
|
121295
|
+
static get isStream() {
|
|
121296
|
+
return oi;
|
|
121297
|
+
}
|
|
121298
|
+
};
|
|
121299
|
+
var vi = Ei.native;
|
|
121300
|
+
var wt = { lstatSync: wi, readdir: yi, readdirSync: bi, readlinkSync: Si, realpathSync: vi, promises: { lstat: Ci, readdir: Ti, readlink: Ai, realpath: ki } };
|
|
121301
|
+
var Ue = (n2) => !n2 || n2 === wt || n2 === xi ? wt : { ...wt, ...n2, promises: { ...wt.promises, ...n2.promises || {} } };
|
|
121302
|
+
var $e = /^\\\\\?\\([a-z]:)\\?$/i;
|
|
121303
|
+
var Ri = (n2) => n2.replace(/\//g, "\\").replace($e, "$1\\");
|
|
121304
|
+
var Oi = /[\\\/]/;
|
|
121305
|
+
var L = 0;
|
|
121306
|
+
var Ge = 1;
|
|
121307
|
+
var He = 2;
|
|
121308
|
+
var U = 4;
|
|
121309
|
+
var qe = 6;
|
|
121310
|
+
var Ke = 8;
|
|
121311
|
+
var X = 10;
|
|
121312
|
+
var Ve = 12;
|
|
121313
|
+
var _ = 15;
|
|
121314
|
+
var gt = ~_;
|
|
121315
|
+
var se = 16;
|
|
121316
|
+
var je = 32;
|
|
121317
|
+
var yt = 64;
|
|
121318
|
+
var j = 128;
|
|
121319
|
+
var Nt = 256;
|
|
121320
|
+
var Lt = 512;
|
|
121321
|
+
var Ie = yt | j | Lt;
|
|
121322
|
+
var Fi = 1023;
|
|
121323
|
+
var ie = (n2) => n2.isFile() ? Ke : n2.isDirectory() ? U : n2.isSymbolicLink() ? X : n2.isCharacterDevice() ? He : n2.isBlockDevice() ? qe : n2.isSocket() ? Ve : n2.isFIFO() ? Ge : L;
|
|
121324
|
+
var ze = new ft({ max: 2 ** 12 });
|
|
121325
|
+
var bt = (n2) => {
|
|
121326
|
+
let t = ze.get(n2);
|
|
121327
|
+
if (t)
|
|
121328
|
+
return t;
|
|
121329
|
+
let e = n2.normalize("NFKD");
|
|
121330
|
+
return ze.set(n2, e), e;
|
|
121331
|
+
};
|
|
121332
|
+
var Be = new ft({ max: 2 ** 12 });
|
|
121333
|
+
var _t = (n2) => {
|
|
121334
|
+
let t = Be.get(n2);
|
|
121335
|
+
if (t)
|
|
121336
|
+
return t;
|
|
121337
|
+
let e = bt(n2.toLowerCase());
|
|
121338
|
+
return Be.set(n2, e), e;
|
|
121339
|
+
};
|
|
121340
|
+
var Wt = class extends ft {
|
|
121341
|
+
constructor() {
|
|
121342
|
+
super({ max: 256 });
|
|
121343
|
+
}
|
|
121344
|
+
};
|
|
121345
|
+
var ne = class extends ft {
|
|
121346
|
+
constructor(t = 16 * 1024) {
|
|
121347
|
+
super({ maxSize: t, sizeCalculation: (e) => e.length + 1 });
|
|
121348
|
+
}
|
|
121349
|
+
};
|
|
121350
|
+
var Ye = Symbol("PathScurry setAsCwd");
|
|
121351
|
+
var R = class {
|
|
121352
|
+
name;
|
|
121353
|
+
root;
|
|
121354
|
+
roots;
|
|
121355
|
+
parent;
|
|
121356
|
+
nocase;
|
|
121357
|
+
isCWD = false;
|
|
121358
|
+
#t;
|
|
121359
|
+
#s;
|
|
121360
|
+
get dev() {
|
|
121361
|
+
return this.#s;
|
|
121362
|
+
}
|
|
121363
|
+
#n;
|
|
121364
|
+
get mode() {
|
|
121365
|
+
return this.#n;
|
|
121366
|
+
}
|
|
121367
|
+
#r;
|
|
121368
|
+
get nlink() {
|
|
121369
|
+
return this.#r;
|
|
121370
|
+
}
|
|
121371
|
+
#o;
|
|
121372
|
+
get uid() {
|
|
121373
|
+
return this.#o;
|
|
121374
|
+
}
|
|
121375
|
+
#S;
|
|
121376
|
+
get gid() {
|
|
121377
|
+
return this.#S;
|
|
121378
|
+
}
|
|
121379
|
+
#w;
|
|
121380
|
+
get rdev() {
|
|
121381
|
+
return this.#w;
|
|
121382
|
+
}
|
|
121383
|
+
#c;
|
|
121384
|
+
get blksize() {
|
|
121385
|
+
return this.#c;
|
|
121386
|
+
}
|
|
121387
|
+
#h;
|
|
121388
|
+
get ino() {
|
|
121389
|
+
return this.#h;
|
|
121390
|
+
}
|
|
121391
|
+
#u;
|
|
121392
|
+
get size() {
|
|
121393
|
+
return this.#u;
|
|
121394
|
+
}
|
|
121395
|
+
#f;
|
|
121396
|
+
get blocks() {
|
|
121397
|
+
return this.#f;
|
|
121398
|
+
}
|
|
121399
|
+
#a;
|
|
121400
|
+
get atimeMs() {
|
|
121401
|
+
return this.#a;
|
|
121402
|
+
}
|
|
121403
|
+
#i;
|
|
121404
|
+
get mtimeMs() {
|
|
121405
|
+
return this.#i;
|
|
121406
|
+
}
|
|
121407
|
+
#d;
|
|
121408
|
+
get ctimeMs() {
|
|
121409
|
+
return this.#d;
|
|
121410
|
+
}
|
|
121411
|
+
#E;
|
|
121412
|
+
get birthtimeMs() {
|
|
121413
|
+
return this.#E;
|
|
121414
|
+
}
|
|
121415
|
+
#b;
|
|
121416
|
+
get atime() {
|
|
121417
|
+
return this.#b;
|
|
121418
|
+
}
|
|
121419
|
+
#p;
|
|
121420
|
+
get mtime() {
|
|
121421
|
+
return this.#p;
|
|
121422
|
+
}
|
|
121423
|
+
#R;
|
|
121424
|
+
get ctime() {
|
|
121425
|
+
return this.#R;
|
|
121426
|
+
}
|
|
121427
|
+
#m;
|
|
121428
|
+
get birthtime() {
|
|
121429
|
+
return this.#m;
|
|
121430
|
+
}
|
|
121431
|
+
#C;
|
|
121432
|
+
#T;
|
|
121433
|
+
#g;
|
|
121434
|
+
#y;
|
|
121435
|
+
#x;
|
|
121436
|
+
#A;
|
|
121437
|
+
#e;
|
|
121438
|
+
#_;
|
|
121439
|
+
#M;
|
|
121440
|
+
#k;
|
|
121441
|
+
get parentPath() {
|
|
121442
|
+
return (this.parent || this).fullpath();
|
|
121443
|
+
}
|
|
121444
|
+
get path() {
|
|
121445
|
+
return this.parentPath;
|
|
121446
|
+
}
|
|
121447
|
+
constructor(t, e = L, s, i, r, o, h) {
|
|
121448
|
+
this.name = t, this.#C = r ? _t(t) : bt(t), this.#e = e & Fi, this.nocase = r, this.roots = i, this.root = s || this, this.#_ = o, this.#g = h.fullpath, this.#x = h.relative, this.#A = h.relativePosix, this.parent = h.parent, this.parent ? this.#t = this.parent.#t : this.#t = Ue(h.fs);
|
|
121449
|
+
}
|
|
121450
|
+
depth() {
|
|
121451
|
+
return this.#T !== undefined ? this.#T : this.parent ? this.#T = this.parent.depth() + 1 : this.#T = 0;
|
|
121452
|
+
}
|
|
121453
|
+
childrenCache() {
|
|
121454
|
+
return this.#_;
|
|
121455
|
+
}
|
|
121456
|
+
resolve(t) {
|
|
121457
|
+
if (!t)
|
|
121458
|
+
return this;
|
|
121459
|
+
let e = this.getRootString(t), i = t.substring(e.length).split(this.splitSep);
|
|
121460
|
+
return e ? this.getRoot(e).#N(i) : this.#N(i);
|
|
121461
|
+
}
|
|
121462
|
+
#N(t) {
|
|
121463
|
+
let e = this;
|
|
121464
|
+
for (let s of t)
|
|
121465
|
+
e = e.child(s);
|
|
121466
|
+
return e;
|
|
121467
|
+
}
|
|
121468
|
+
children() {
|
|
121469
|
+
let t = this.#_.get(this);
|
|
121470
|
+
if (t)
|
|
121471
|
+
return t;
|
|
121472
|
+
let e = Object.assign([], { provisional: 0 });
|
|
121473
|
+
return this.#_.set(this, e), this.#e &= ~se, e;
|
|
121474
|
+
}
|
|
121475
|
+
child(t, e) {
|
|
121476
|
+
if (t === "" || t === ".")
|
|
121477
|
+
return this;
|
|
121478
|
+
if (t === "..")
|
|
121479
|
+
return this.parent || this;
|
|
121480
|
+
let s = this.children(), i = this.nocase ? _t(t) : bt(t);
|
|
121481
|
+
for (let a of s)
|
|
121482
|
+
if (a.#C === i)
|
|
121483
|
+
return a;
|
|
121484
|
+
let r = this.parent ? this.sep : "", o = this.#g ? this.#g + r + t : undefined, h = this.newChild(t, L, { ...e, parent: this, fullpath: o });
|
|
121485
|
+
return this.canReaddir() || (h.#e |= j), s.push(h), h;
|
|
121486
|
+
}
|
|
121487
|
+
relative() {
|
|
121488
|
+
if (this.isCWD)
|
|
121489
|
+
return "";
|
|
121490
|
+
if (this.#x !== undefined)
|
|
121491
|
+
return this.#x;
|
|
121492
|
+
let t = this.name, e = this.parent;
|
|
121493
|
+
if (!e)
|
|
121494
|
+
return this.#x = this.name;
|
|
121495
|
+
let s = e.relative();
|
|
121496
|
+
return s + (!s || !e.parent ? "" : this.sep) + t;
|
|
121497
|
+
}
|
|
121498
|
+
relativePosix() {
|
|
121499
|
+
if (this.sep === "/")
|
|
121500
|
+
return this.relative();
|
|
121501
|
+
if (this.isCWD)
|
|
121502
|
+
return "";
|
|
121503
|
+
if (this.#A !== undefined)
|
|
121504
|
+
return this.#A;
|
|
121505
|
+
let t = this.name, e = this.parent;
|
|
121506
|
+
if (!e)
|
|
121507
|
+
return this.#A = this.fullpathPosix();
|
|
121508
|
+
let s = e.relativePosix();
|
|
121509
|
+
return s + (!s || !e.parent ? "" : "/") + t;
|
|
121510
|
+
}
|
|
121511
|
+
fullpath() {
|
|
121512
|
+
if (this.#g !== undefined)
|
|
121513
|
+
return this.#g;
|
|
121514
|
+
let t = this.name, e = this.parent;
|
|
121515
|
+
if (!e)
|
|
121516
|
+
return this.#g = this.name;
|
|
121517
|
+
let i = e.fullpath() + (e.parent ? this.sep : "") + t;
|
|
121518
|
+
return this.#g = i;
|
|
121519
|
+
}
|
|
121520
|
+
fullpathPosix() {
|
|
121521
|
+
if (this.#y !== undefined)
|
|
121522
|
+
return this.#y;
|
|
121523
|
+
if (this.sep === "/")
|
|
121524
|
+
return this.#y = this.fullpath();
|
|
121525
|
+
if (!this.parent) {
|
|
121526
|
+
let i = this.fullpath().replace(/\\/g, "/");
|
|
121527
|
+
return /^[a-z]:\//i.test(i) ? this.#y = `//?/${i}` : this.#y = i;
|
|
121528
|
+
}
|
|
121529
|
+
let t = this.parent, e = t.fullpathPosix(), s = e + (!e || !t.parent ? "" : "/") + this.name;
|
|
121530
|
+
return this.#y = s;
|
|
121531
|
+
}
|
|
121532
|
+
isUnknown() {
|
|
121533
|
+
return (this.#e & _) === L;
|
|
121534
|
+
}
|
|
121535
|
+
isType(t) {
|
|
121536
|
+
return this[`is${t}`]();
|
|
121537
|
+
}
|
|
121538
|
+
getType() {
|
|
121539
|
+
return this.isUnknown() ? "Unknown" : this.isDirectory() ? "Directory" : this.isFile() ? "File" : this.isSymbolicLink() ? "SymbolicLink" : this.isFIFO() ? "FIFO" : this.isCharacterDevice() ? "CharacterDevice" : this.isBlockDevice() ? "BlockDevice" : this.isSocket() ? "Socket" : "Unknown";
|
|
121540
|
+
}
|
|
121541
|
+
isFile() {
|
|
121542
|
+
return (this.#e & _) === Ke;
|
|
121543
|
+
}
|
|
121544
|
+
isDirectory() {
|
|
121545
|
+
return (this.#e & _) === U;
|
|
121546
|
+
}
|
|
121547
|
+
isCharacterDevice() {
|
|
121548
|
+
return (this.#e & _) === He;
|
|
121549
|
+
}
|
|
121550
|
+
isBlockDevice() {
|
|
121551
|
+
return (this.#e & _) === qe;
|
|
121552
|
+
}
|
|
121553
|
+
isFIFO() {
|
|
121554
|
+
return (this.#e & _) === Ge;
|
|
121555
|
+
}
|
|
121556
|
+
isSocket() {
|
|
121557
|
+
return (this.#e & _) === Ve;
|
|
121558
|
+
}
|
|
121559
|
+
isSymbolicLink() {
|
|
121560
|
+
return (this.#e & X) === X;
|
|
121561
|
+
}
|
|
121562
|
+
lstatCached() {
|
|
121563
|
+
return this.#e & je ? this : undefined;
|
|
121564
|
+
}
|
|
121565
|
+
readlinkCached() {
|
|
121566
|
+
return this.#M;
|
|
121567
|
+
}
|
|
121568
|
+
realpathCached() {
|
|
121569
|
+
return this.#k;
|
|
121570
|
+
}
|
|
121571
|
+
readdirCached() {
|
|
121572
|
+
let t = this.children();
|
|
121573
|
+
return t.slice(0, t.provisional);
|
|
121574
|
+
}
|
|
121575
|
+
canReadlink() {
|
|
121576
|
+
if (this.#M)
|
|
121577
|
+
return true;
|
|
121578
|
+
if (!this.parent)
|
|
121579
|
+
return false;
|
|
121580
|
+
let t = this.#e & _;
|
|
121581
|
+
return !(t !== L && t !== X || this.#e & Nt || this.#e & j);
|
|
121582
|
+
}
|
|
121583
|
+
calledReaddir() {
|
|
121584
|
+
return !!(this.#e & se);
|
|
121585
|
+
}
|
|
121586
|
+
isENOENT() {
|
|
121587
|
+
return !!(this.#e & j);
|
|
121588
|
+
}
|
|
121589
|
+
isNamed(t) {
|
|
121590
|
+
return this.nocase ? this.#C === _t(t) : this.#C === bt(t);
|
|
121591
|
+
}
|
|
121592
|
+
async readlink() {
|
|
121593
|
+
let t = this.#M;
|
|
121594
|
+
if (t)
|
|
121595
|
+
return t;
|
|
121596
|
+
if (this.canReadlink() && this.parent)
|
|
121597
|
+
try {
|
|
121598
|
+
let e = await this.#t.promises.readlink(this.fullpath()), s = (await this.parent.realpath())?.resolve(e);
|
|
121599
|
+
if (s)
|
|
121600
|
+
return this.#M = s;
|
|
121601
|
+
} catch (e) {
|
|
121602
|
+
this.#D(e.code);
|
|
121603
|
+
return;
|
|
121604
|
+
}
|
|
121605
|
+
}
|
|
121606
|
+
readlinkSync() {
|
|
121607
|
+
let t = this.#M;
|
|
121608
|
+
if (t)
|
|
121609
|
+
return t;
|
|
121610
|
+
if (this.canReadlink() && this.parent)
|
|
121611
|
+
try {
|
|
121612
|
+
let e = this.#t.readlinkSync(this.fullpath()), s = this.parent.realpathSync()?.resolve(e);
|
|
121613
|
+
if (s)
|
|
121614
|
+
return this.#M = s;
|
|
121615
|
+
} catch (e) {
|
|
121616
|
+
this.#D(e.code);
|
|
121617
|
+
return;
|
|
121618
|
+
}
|
|
121619
|
+
}
|
|
121620
|
+
#j(t) {
|
|
121621
|
+
this.#e |= se;
|
|
121622
|
+
for (let e = t.provisional;e < t.length; e++) {
|
|
121623
|
+
let s = t[e];
|
|
121624
|
+
s && s.#v();
|
|
121625
|
+
}
|
|
121626
|
+
}
|
|
121627
|
+
#v() {
|
|
121628
|
+
this.#e & j || (this.#e = (this.#e | j) & gt, this.#G());
|
|
121629
|
+
}
|
|
121630
|
+
#G() {
|
|
121631
|
+
let t = this.children();
|
|
121632
|
+
t.provisional = 0;
|
|
121633
|
+
for (let e of t)
|
|
121634
|
+
e.#v();
|
|
121635
|
+
}
|
|
121636
|
+
#P() {
|
|
121637
|
+
this.#e |= Lt, this.#L();
|
|
121638
|
+
}
|
|
121639
|
+
#L() {
|
|
121640
|
+
if (this.#e & yt)
|
|
121641
|
+
return;
|
|
121642
|
+
let t = this.#e;
|
|
121643
|
+
(t & _) === U && (t &= gt), this.#e = t | yt, this.#G();
|
|
121644
|
+
}
|
|
121645
|
+
#I(t = "") {
|
|
121646
|
+
t === "ENOTDIR" || t === "EPERM" ? this.#L() : t === "ENOENT" ? this.#v() : this.children().provisional = 0;
|
|
121647
|
+
}
|
|
121648
|
+
#F(t = "") {
|
|
121649
|
+
t === "ENOTDIR" ? this.parent.#L() : t === "ENOENT" && this.#v();
|
|
121650
|
+
}
|
|
121651
|
+
#D(t = "") {
|
|
121652
|
+
let e = this.#e;
|
|
121653
|
+
e |= Nt, t === "ENOENT" && (e |= j), (t === "EINVAL" || t === "UNKNOWN") && (e &= gt), this.#e = e, t === "ENOTDIR" && this.parent && this.parent.#L();
|
|
121654
|
+
}
|
|
121655
|
+
#z(t, e) {
|
|
121656
|
+
return this.#U(t, e) || this.#B(t, e);
|
|
121657
|
+
}
|
|
121658
|
+
#B(t, e) {
|
|
121659
|
+
let s = ie(t), i = this.newChild(t.name, s, { parent: this }), r = i.#e & _;
|
|
121660
|
+
return r !== U && r !== X && r !== L && (i.#e |= yt), e.unshift(i), e.provisional++, i;
|
|
121661
|
+
}
|
|
121662
|
+
#U(t, e) {
|
|
121663
|
+
for (let s = e.provisional;s < e.length; s++) {
|
|
121664
|
+
let i = e[s];
|
|
121665
|
+
if ((this.nocase ? _t(t.name) : bt(t.name)) === i.#C)
|
|
121666
|
+
return this.#l(t, i, s, e);
|
|
121667
|
+
}
|
|
121668
|
+
}
|
|
121669
|
+
#l(t, e, s, i) {
|
|
121670
|
+
let r = e.name;
|
|
121671
|
+
return e.#e = e.#e & gt | ie(t), r !== t.name && (e.name = t.name), s !== i.provisional && (s === i.length - 1 ? i.pop() : i.splice(s, 1), i.unshift(e)), i.provisional++, e;
|
|
121672
|
+
}
|
|
121673
|
+
async lstat() {
|
|
121674
|
+
if ((this.#e & j) === 0)
|
|
121675
|
+
try {
|
|
121676
|
+
return this.#$(await this.#t.promises.lstat(this.fullpath())), this;
|
|
121677
|
+
} catch (t) {
|
|
121678
|
+
this.#F(t.code);
|
|
121679
|
+
}
|
|
121680
|
+
}
|
|
121681
|
+
lstatSync() {
|
|
121682
|
+
if ((this.#e & j) === 0)
|
|
121683
|
+
try {
|
|
121684
|
+
return this.#$(this.#t.lstatSync(this.fullpath())), this;
|
|
121685
|
+
} catch (t) {
|
|
121686
|
+
this.#F(t.code);
|
|
121687
|
+
}
|
|
121688
|
+
}
|
|
121689
|
+
#$(t) {
|
|
121690
|
+
let { atime: e, atimeMs: s, birthtime: i, birthtimeMs: r, blksize: o, blocks: h, ctime: a, ctimeMs: l, dev: u, gid: c, ino: d, mode: f, mtime: m, mtimeMs: p, nlink: w, rdev: g, size: S, uid: E } = t;
|
|
121691
|
+
this.#b = e, this.#a = s, this.#m = i, this.#E = r, this.#c = o, this.#f = h, this.#R = a, this.#d = l, this.#s = u, this.#S = c, this.#h = d, this.#n = f, this.#p = m, this.#i = p, this.#r = w, this.#w = g, this.#u = S, this.#o = E;
|
|
121692
|
+
let y = ie(t);
|
|
121693
|
+
this.#e = this.#e & gt | y | je, y !== L && y !== U && y !== X && (this.#e |= yt);
|
|
121694
|
+
}
|
|
121695
|
+
#W = [];
|
|
121696
|
+
#O = false;
|
|
121697
|
+
#H(t) {
|
|
121698
|
+
this.#O = false;
|
|
121699
|
+
let e = this.#W.slice();
|
|
121700
|
+
this.#W.length = 0, e.forEach((s) => s(null, t));
|
|
121701
|
+
}
|
|
121702
|
+
readdirCB(t, e = false) {
|
|
121703
|
+
if (!this.canReaddir()) {
|
|
121704
|
+
e ? t(null, []) : queueMicrotask(() => t(null, []));
|
|
121705
|
+
return;
|
|
121706
|
+
}
|
|
121707
|
+
let s = this.children();
|
|
121708
|
+
if (this.calledReaddir()) {
|
|
121709
|
+
let r = s.slice(0, s.provisional);
|
|
121710
|
+
e ? t(null, r) : queueMicrotask(() => t(null, r));
|
|
121711
|
+
return;
|
|
121712
|
+
}
|
|
121713
|
+
if (this.#W.push(t), this.#O)
|
|
121714
|
+
return;
|
|
121715
|
+
this.#O = true;
|
|
121716
|
+
let i = this.fullpath();
|
|
121717
|
+
this.#t.readdir(i, { withFileTypes: true }, (r, o) => {
|
|
121718
|
+
if (r)
|
|
121719
|
+
this.#I(r.code), s.provisional = 0;
|
|
121720
|
+
else {
|
|
121721
|
+
for (let h of o)
|
|
121722
|
+
this.#z(h, s);
|
|
121723
|
+
this.#j(s);
|
|
121724
|
+
}
|
|
121725
|
+
this.#H(s.slice(0, s.provisional));
|
|
121726
|
+
});
|
|
121727
|
+
}
|
|
121728
|
+
#q;
|
|
121729
|
+
async readdir() {
|
|
121730
|
+
if (!this.canReaddir())
|
|
121731
|
+
return [];
|
|
121732
|
+
let t = this.children();
|
|
121733
|
+
if (this.calledReaddir())
|
|
121734
|
+
return t.slice(0, t.provisional);
|
|
121735
|
+
let e = this.fullpath();
|
|
121736
|
+
if (this.#q)
|
|
121737
|
+
await this.#q;
|
|
121738
|
+
else {
|
|
121739
|
+
let s = () => {};
|
|
121740
|
+
this.#q = new Promise((i) => s = i);
|
|
121741
|
+
try {
|
|
121742
|
+
for (let i of await this.#t.promises.readdir(e, { withFileTypes: true }))
|
|
121743
|
+
this.#z(i, t);
|
|
121744
|
+
this.#j(t);
|
|
121745
|
+
} catch (i) {
|
|
121746
|
+
this.#I(i.code), t.provisional = 0;
|
|
121747
|
+
}
|
|
121748
|
+
this.#q = undefined, s();
|
|
121749
|
+
}
|
|
121750
|
+
return t.slice(0, t.provisional);
|
|
121751
|
+
}
|
|
121752
|
+
readdirSync() {
|
|
121753
|
+
if (!this.canReaddir())
|
|
121754
|
+
return [];
|
|
121755
|
+
let t = this.children();
|
|
121756
|
+
if (this.calledReaddir())
|
|
121757
|
+
return t.slice(0, t.provisional);
|
|
121758
|
+
let e = this.fullpath();
|
|
121759
|
+
try {
|
|
121760
|
+
for (let s of this.#t.readdirSync(e, { withFileTypes: true }))
|
|
121761
|
+
this.#z(s, t);
|
|
121762
|
+
this.#j(t);
|
|
121763
|
+
} catch (s) {
|
|
121764
|
+
this.#I(s.code), t.provisional = 0;
|
|
121765
|
+
}
|
|
121766
|
+
return t.slice(0, t.provisional);
|
|
121767
|
+
}
|
|
121768
|
+
canReaddir() {
|
|
121769
|
+
if (this.#e & Ie)
|
|
121770
|
+
return false;
|
|
121771
|
+
let t = _ & this.#e;
|
|
121772
|
+
return t === L || t === U || t === X;
|
|
121773
|
+
}
|
|
121774
|
+
shouldWalk(t, e) {
|
|
121775
|
+
return (this.#e & U) === U && !(this.#e & Ie) && !t.has(this) && (!e || e(this));
|
|
121776
|
+
}
|
|
121777
|
+
async realpath() {
|
|
121778
|
+
if (this.#k)
|
|
121779
|
+
return this.#k;
|
|
121780
|
+
if (!((Lt | Nt | j) & this.#e))
|
|
121781
|
+
try {
|
|
121782
|
+
let t = await this.#t.promises.realpath(this.fullpath());
|
|
121783
|
+
return this.#k = this.resolve(t);
|
|
121784
|
+
} catch {
|
|
121785
|
+
this.#P();
|
|
121786
|
+
}
|
|
121787
|
+
}
|
|
121788
|
+
realpathSync() {
|
|
121789
|
+
if (this.#k)
|
|
121790
|
+
return this.#k;
|
|
121791
|
+
if (!((Lt | Nt | j) & this.#e))
|
|
121792
|
+
try {
|
|
121793
|
+
let t = this.#t.realpathSync(this.fullpath());
|
|
121794
|
+
return this.#k = this.resolve(t);
|
|
121795
|
+
} catch {
|
|
121796
|
+
this.#P();
|
|
121797
|
+
}
|
|
121798
|
+
}
|
|
121799
|
+
[Ye](t) {
|
|
121800
|
+
if (t === this)
|
|
121801
|
+
return;
|
|
121802
|
+
t.isCWD = false, this.isCWD = true;
|
|
121803
|
+
let e = new Set([]), s = [], i = this;
|
|
121804
|
+
for (;i && i.parent; )
|
|
121805
|
+
e.add(i), i.#x = s.join(this.sep), i.#A = s.join("/"), i = i.parent, s.push("..");
|
|
121806
|
+
for (i = t;i && i.parent && !e.has(i); )
|
|
121807
|
+
i.#x = undefined, i.#A = undefined, i = i.parent;
|
|
121808
|
+
}
|
|
121809
|
+
};
|
|
121810
|
+
var Pt = class n2 extends R {
|
|
121811
|
+
sep = "\\";
|
|
121812
|
+
splitSep = Oi;
|
|
121813
|
+
constructor(t, e = L, s, i, r, o, h) {
|
|
121814
|
+
super(t, e, s, i, r, o, h);
|
|
121815
|
+
}
|
|
121816
|
+
newChild(t, e = L, s = {}) {
|
|
121817
|
+
return new n2(t, e, this.root, this.roots, this.nocase, this.childrenCache(), s);
|
|
121818
|
+
}
|
|
121819
|
+
getRootString(t) {
|
|
121820
|
+
return re.parse(t).root;
|
|
121821
|
+
}
|
|
121822
|
+
getRoot(t) {
|
|
121823
|
+
if (t = Ri(t.toUpperCase()), t === this.root.name)
|
|
121824
|
+
return this.root;
|
|
121825
|
+
for (let [e, s] of Object.entries(this.roots))
|
|
121826
|
+
if (this.sameRoot(t, e))
|
|
121827
|
+
return this.roots[t] = s;
|
|
121828
|
+
return this.roots[t] = new it(t, this).root;
|
|
121829
|
+
}
|
|
121830
|
+
sameRoot(t, e = this.root.name) {
|
|
121831
|
+
return t = t.toUpperCase().replace(/\//g, "\\").replace($e, "$1\\"), t === e;
|
|
121832
|
+
}
|
|
121833
|
+
};
|
|
121834
|
+
var jt = class n3 extends R {
|
|
121835
|
+
splitSep = "/";
|
|
121836
|
+
sep = "/";
|
|
121837
|
+
constructor(t, e = L, s, i, r, o, h) {
|
|
121838
|
+
super(t, e, s, i, r, o, h);
|
|
121839
|
+
}
|
|
121840
|
+
getRootString(t) {
|
|
121841
|
+
return t.startsWith("/") ? "/" : "";
|
|
121842
|
+
}
|
|
121843
|
+
getRoot(t) {
|
|
121844
|
+
return this.root;
|
|
121845
|
+
}
|
|
121846
|
+
newChild(t, e = L, s = {}) {
|
|
121847
|
+
return new n3(t, e, this.root, this.roots, this.nocase, this.childrenCache(), s);
|
|
121848
|
+
}
|
|
121849
|
+
};
|
|
121850
|
+
var It = class {
|
|
121851
|
+
root;
|
|
121852
|
+
rootPath;
|
|
121853
|
+
roots;
|
|
121854
|
+
cwd;
|
|
121855
|
+
#t;
|
|
121856
|
+
#s;
|
|
121857
|
+
#n;
|
|
121858
|
+
nocase;
|
|
121859
|
+
#r;
|
|
121860
|
+
constructor(t = process.cwd(), e, s, { nocase: i, childrenCacheSize: r = 16 * 1024, fs: o = wt } = {}) {
|
|
121861
|
+
this.#r = Ue(o), (t instanceof URL || t.startsWith("file://")) && (t = gi(t));
|
|
121862
|
+
let h = e.resolve(t);
|
|
121863
|
+
this.roots = Object.create(null), this.rootPath = this.parseRootPath(h), this.#t = new Wt, this.#s = new Wt, this.#n = new ne(r);
|
|
121864
|
+
let a = h.substring(this.rootPath.length).split(s);
|
|
121865
|
+
if (a.length === 1 && !a[0] && a.pop(), i === undefined)
|
|
121866
|
+
throw new TypeError("must provide nocase setting to PathScurryBase ctor");
|
|
121867
|
+
this.nocase = i, this.root = this.newRoot(this.#r), this.roots[this.rootPath] = this.root;
|
|
121868
|
+
let l = this.root, u = a.length - 1, c = e.sep, d = this.rootPath, f = false;
|
|
121869
|
+
for (let m of a) {
|
|
121870
|
+
let p = u--;
|
|
121871
|
+
l = l.child(m, { relative: new Array(p).fill("..").join(c), relativePosix: new Array(p).fill("..").join("/"), fullpath: d += (f ? "" : c) + m }), f = true;
|
|
121872
|
+
}
|
|
121873
|
+
this.cwd = l;
|
|
121874
|
+
}
|
|
121875
|
+
depth(t = this.cwd) {
|
|
121876
|
+
return typeof t == "string" && (t = this.cwd.resolve(t)), t.depth();
|
|
121877
|
+
}
|
|
121878
|
+
childrenCache() {
|
|
121879
|
+
return this.#n;
|
|
121880
|
+
}
|
|
121881
|
+
resolve(...t) {
|
|
121882
|
+
let e = "";
|
|
121883
|
+
for (let r = t.length - 1;r >= 0; r--) {
|
|
121884
|
+
let o = t[r];
|
|
121885
|
+
if (!(!o || o === ".") && (e = e ? `${o}/${e}` : o, this.isAbsolute(o)))
|
|
121886
|
+
break;
|
|
121887
|
+
}
|
|
121888
|
+
let s = this.#t.get(e);
|
|
121889
|
+
if (s !== undefined)
|
|
121890
|
+
return s;
|
|
121891
|
+
let i = this.cwd.resolve(e).fullpath();
|
|
121892
|
+
return this.#t.set(e, i), i;
|
|
121893
|
+
}
|
|
121894
|
+
resolvePosix(...t) {
|
|
121895
|
+
let e = "";
|
|
121896
|
+
for (let r = t.length - 1;r >= 0; r--) {
|
|
121897
|
+
let o = t[r];
|
|
121898
|
+
if (!(!o || o === ".") && (e = e ? `${o}/${e}` : o, this.isAbsolute(o)))
|
|
121899
|
+
break;
|
|
121900
|
+
}
|
|
121901
|
+
let s = this.#s.get(e);
|
|
121902
|
+
if (s !== undefined)
|
|
121903
|
+
return s;
|
|
121904
|
+
let i = this.cwd.resolve(e).fullpathPosix();
|
|
121905
|
+
return this.#s.set(e, i), i;
|
|
121906
|
+
}
|
|
121907
|
+
relative(t = this.cwd) {
|
|
121908
|
+
return typeof t == "string" && (t = this.cwd.resolve(t)), t.relative();
|
|
121909
|
+
}
|
|
121910
|
+
relativePosix(t = this.cwd) {
|
|
121911
|
+
return typeof t == "string" && (t = this.cwd.resolve(t)), t.relativePosix();
|
|
121912
|
+
}
|
|
121913
|
+
basename(t = this.cwd) {
|
|
121914
|
+
return typeof t == "string" && (t = this.cwd.resolve(t)), t.name;
|
|
121915
|
+
}
|
|
121916
|
+
dirname(t = this.cwd) {
|
|
121917
|
+
return typeof t == "string" && (t = this.cwd.resolve(t)), (t.parent || t).fullpath();
|
|
121918
|
+
}
|
|
121919
|
+
async readdir(t = this.cwd, e = { withFileTypes: true }) {
|
|
121920
|
+
typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof R || (e = t, t = this.cwd);
|
|
121921
|
+
let { withFileTypes: s } = e;
|
|
121922
|
+
if (t.canReaddir()) {
|
|
121923
|
+
let i = await t.readdir();
|
|
121924
|
+
return s ? i : i.map((r) => r.name);
|
|
121925
|
+
} else
|
|
121926
|
+
return [];
|
|
121927
|
+
}
|
|
121928
|
+
readdirSync(t = this.cwd, e = { withFileTypes: true }) {
|
|
121929
|
+
typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof R || (e = t, t = this.cwd);
|
|
121930
|
+
let { withFileTypes: s = true } = e;
|
|
121931
|
+
return t.canReaddir() ? s ? t.readdirSync() : t.readdirSync().map((i) => i.name) : [];
|
|
121932
|
+
}
|
|
121933
|
+
async lstat(t = this.cwd) {
|
|
121934
|
+
return typeof t == "string" && (t = this.cwd.resolve(t)), t.lstat();
|
|
121935
|
+
}
|
|
121936
|
+
lstatSync(t = this.cwd) {
|
|
121937
|
+
return typeof t == "string" && (t = this.cwd.resolve(t)), t.lstatSync();
|
|
121938
|
+
}
|
|
121939
|
+
async readlink(t = this.cwd, { withFileTypes: e } = { withFileTypes: false }) {
|
|
121940
|
+
typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof R || (e = t.withFileTypes, t = this.cwd);
|
|
121941
|
+
let s = await t.readlink();
|
|
121942
|
+
return e ? s : s?.fullpath();
|
|
121943
|
+
}
|
|
121944
|
+
readlinkSync(t = this.cwd, { withFileTypes: e } = { withFileTypes: false }) {
|
|
121945
|
+
typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof R || (e = t.withFileTypes, t = this.cwd);
|
|
121946
|
+
let s = t.readlinkSync();
|
|
121947
|
+
return e ? s : s?.fullpath();
|
|
121948
|
+
}
|
|
121949
|
+
async realpath(t = this.cwd, { withFileTypes: e } = { withFileTypes: false }) {
|
|
121950
|
+
typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof R || (e = t.withFileTypes, t = this.cwd);
|
|
121951
|
+
let s = await t.realpath();
|
|
121952
|
+
return e ? s : s?.fullpath();
|
|
121953
|
+
}
|
|
121954
|
+
realpathSync(t = this.cwd, { withFileTypes: e } = { withFileTypes: false }) {
|
|
121955
|
+
typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof R || (e = t.withFileTypes, t = this.cwd);
|
|
121956
|
+
let s = t.realpathSync();
|
|
121957
|
+
return e ? s : s?.fullpath();
|
|
121958
|
+
}
|
|
121959
|
+
async walk(t = this.cwd, e = {}) {
|
|
121960
|
+
typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof R || (e = t, t = this.cwd);
|
|
121961
|
+
let { withFileTypes: s = true, follow: i = false, filter: r, walkFilter: o } = e, h = [];
|
|
121962
|
+
(!r || r(t)) && h.push(s ? t : t.fullpath());
|
|
121963
|
+
let a = new Set, l = (c, d) => {
|
|
121964
|
+
a.add(c), c.readdirCB((f, m) => {
|
|
121965
|
+
if (f)
|
|
121966
|
+
return d(f);
|
|
121967
|
+
let p = m.length;
|
|
121968
|
+
if (!p)
|
|
121969
|
+
return d();
|
|
121970
|
+
let w = () => {
|
|
121971
|
+
--p === 0 && d();
|
|
121972
|
+
};
|
|
121973
|
+
for (let g of m)
|
|
121974
|
+
(!r || r(g)) && h.push(s ? g : g.fullpath()), i && g.isSymbolicLink() ? g.realpath().then((S) => S?.isUnknown() ? S.lstat() : S).then((S) => S?.shouldWalk(a, o) ? l(S, w) : w()) : g.shouldWalk(a, o) ? l(g, w) : w();
|
|
121975
|
+
}, true);
|
|
121976
|
+
}, u = t;
|
|
121977
|
+
return new Promise((c, d) => {
|
|
121978
|
+
l(u, (f) => {
|
|
121979
|
+
if (f)
|
|
121980
|
+
return d(f);
|
|
121981
|
+
c(h);
|
|
121982
|
+
});
|
|
121983
|
+
});
|
|
121984
|
+
}
|
|
121985
|
+
walkSync(t = this.cwd, e = {}) {
|
|
121986
|
+
typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof R || (e = t, t = this.cwd);
|
|
121987
|
+
let { withFileTypes: s = true, follow: i = false, filter: r, walkFilter: o } = e, h = [];
|
|
121988
|
+
(!r || r(t)) && h.push(s ? t : t.fullpath());
|
|
121989
|
+
let a = new Set([t]);
|
|
121990
|
+
for (let l of a) {
|
|
121991
|
+
let u = l.readdirSync();
|
|
121992
|
+
for (let c of u) {
|
|
121993
|
+
(!r || r(c)) && h.push(s ? c : c.fullpath());
|
|
121994
|
+
let d = c;
|
|
121995
|
+
if (c.isSymbolicLink()) {
|
|
121996
|
+
if (!(i && (d = c.realpathSync())))
|
|
121997
|
+
continue;
|
|
121998
|
+
d.isUnknown() && d.lstatSync();
|
|
121999
|
+
}
|
|
122000
|
+
d.shouldWalk(a, o) && a.add(d);
|
|
122001
|
+
}
|
|
122002
|
+
}
|
|
122003
|
+
return h;
|
|
122004
|
+
}
|
|
122005
|
+
[Symbol.asyncIterator]() {
|
|
122006
|
+
return this.iterate();
|
|
122007
|
+
}
|
|
122008
|
+
iterate(t = this.cwd, e = {}) {
|
|
122009
|
+
return typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof R || (e = t, t = this.cwd), this.stream(t, e)[Symbol.asyncIterator]();
|
|
122010
|
+
}
|
|
122011
|
+
[Symbol.iterator]() {
|
|
122012
|
+
return this.iterateSync();
|
|
122013
|
+
}
|
|
122014
|
+
*iterateSync(t = this.cwd, e = {}) {
|
|
122015
|
+
typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof R || (e = t, t = this.cwd);
|
|
122016
|
+
let { withFileTypes: s = true, follow: i = false, filter: r, walkFilter: o } = e;
|
|
122017
|
+
(!r || r(t)) && (yield s ? t : t.fullpath());
|
|
122018
|
+
let h = new Set([t]);
|
|
122019
|
+
for (let a of h) {
|
|
122020
|
+
let l = a.readdirSync();
|
|
122021
|
+
for (let u of l) {
|
|
122022
|
+
(!r || r(u)) && (yield s ? u : u.fullpath());
|
|
122023
|
+
let c = u;
|
|
122024
|
+
if (u.isSymbolicLink()) {
|
|
122025
|
+
if (!(i && (c = u.realpathSync())))
|
|
122026
|
+
continue;
|
|
122027
|
+
c.isUnknown() && c.lstatSync();
|
|
122028
|
+
}
|
|
122029
|
+
c.shouldWalk(h, o) && h.add(c);
|
|
122030
|
+
}
|
|
122031
|
+
}
|
|
122032
|
+
}
|
|
122033
|
+
stream(t = this.cwd, e = {}) {
|
|
122034
|
+
typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof R || (e = t, t = this.cwd);
|
|
122035
|
+
let { withFileTypes: s = true, follow: i = false, filter: r, walkFilter: o } = e, h = new V({ objectMode: true });
|
|
122036
|
+
(!r || r(t)) && h.write(s ? t : t.fullpath());
|
|
122037
|
+
let a = new Set, l = [t], u = 0, c = () => {
|
|
122038
|
+
let d = false;
|
|
122039
|
+
for (;!d; ) {
|
|
122040
|
+
let f = l.shift();
|
|
122041
|
+
if (!f) {
|
|
122042
|
+
u === 0 && h.end();
|
|
122043
|
+
return;
|
|
122044
|
+
}
|
|
122045
|
+
u++, a.add(f);
|
|
122046
|
+
let m = (w, g, S = false) => {
|
|
122047
|
+
if (w)
|
|
122048
|
+
return h.emit("error", w);
|
|
122049
|
+
if (i && !S) {
|
|
122050
|
+
let E = [];
|
|
122051
|
+
for (let y of g)
|
|
122052
|
+
y.isSymbolicLink() && E.push(y.realpath().then((b) => b?.isUnknown() ? b.lstat() : b));
|
|
122053
|
+
if (E.length) {
|
|
122054
|
+
Promise.all(E).then(() => m(null, g, true));
|
|
122055
|
+
return;
|
|
122056
|
+
}
|
|
122057
|
+
}
|
|
122058
|
+
for (let E of g)
|
|
122059
|
+
E && (!r || r(E)) && (h.write(s ? E : E.fullpath()) || (d = true));
|
|
122060
|
+
u--;
|
|
122061
|
+
for (let E of g) {
|
|
122062
|
+
let y = E.realpathCached() || E;
|
|
122063
|
+
y.shouldWalk(a, o) && l.push(y);
|
|
122064
|
+
}
|
|
122065
|
+
d && !h.flowing ? h.once("drain", c) : p || c();
|
|
122066
|
+
}, p = true;
|
|
122067
|
+
f.readdirCB(m, true), p = false;
|
|
122068
|
+
}
|
|
122069
|
+
};
|
|
122070
|
+
return c(), h;
|
|
122071
|
+
}
|
|
122072
|
+
streamSync(t = this.cwd, e = {}) {
|
|
122073
|
+
typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof R || (e = t, t = this.cwd);
|
|
122074
|
+
let { withFileTypes: s = true, follow: i = false, filter: r, walkFilter: o } = e, h = new V({ objectMode: true }), a = new Set;
|
|
122075
|
+
(!r || r(t)) && h.write(s ? t : t.fullpath());
|
|
122076
|
+
let l = [t], u = 0, c = () => {
|
|
122077
|
+
let d = false;
|
|
122078
|
+
for (;!d; ) {
|
|
122079
|
+
let f = l.shift();
|
|
122080
|
+
if (!f) {
|
|
122081
|
+
u === 0 && h.end();
|
|
122082
|
+
return;
|
|
122083
|
+
}
|
|
122084
|
+
u++, a.add(f);
|
|
122085
|
+
let m = f.readdirSync();
|
|
122086
|
+
for (let p of m)
|
|
122087
|
+
(!r || r(p)) && (h.write(s ? p : p.fullpath()) || (d = true));
|
|
122088
|
+
u--;
|
|
122089
|
+
for (let p of m) {
|
|
122090
|
+
let w = p;
|
|
122091
|
+
if (p.isSymbolicLink()) {
|
|
122092
|
+
if (!(i && (w = p.realpathSync())))
|
|
122093
|
+
continue;
|
|
122094
|
+
w.isUnknown() && w.lstatSync();
|
|
122095
|
+
}
|
|
122096
|
+
w.shouldWalk(a, o) && l.push(w);
|
|
122097
|
+
}
|
|
122098
|
+
}
|
|
122099
|
+
d && !h.flowing && h.once("drain", c);
|
|
122100
|
+
};
|
|
122101
|
+
return c(), h;
|
|
122102
|
+
}
|
|
122103
|
+
chdir(t = this.cwd) {
|
|
122104
|
+
let e = this.cwd;
|
|
122105
|
+
this.cwd = typeof t == "string" ? this.cwd.resolve(t) : t, this.cwd[Ye](e);
|
|
122106
|
+
}
|
|
122107
|
+
};
|
|
122108
|
+
var it = class extends It {
|
|
122109
|
+
sep = "\\";
|
|
122110
|
+
constructor(t = process.cwd(), e = {}) {
|
|
122111
|
+
let { nocase: s = true } = e;
|
|
122112
|
+
super(t, re, "\\", { ...e, nocase: s }), this.nocase = s;
|
|
122113
|
+
for (let i = this.cwd;i; i = i.parent)
|
|
122114
|
+
i.nocase = this.nocase;
|
|
122115
|
+
}
|
|
122116
|
+
parseRootPath(t) {
|
|
122117
|
+
return re.parse(t).root.toUpperCase();
|
|
122118
|
+
}
|
|
122119
|
+
newRoot(t) {
|
|
122120
|
+
return new Pt(this.rootPath, U, undefined, this.roots, this.nocase, this.childrenCache(), { fs: t });
|
|
122121
|
+
}
|
|
122122
|
+
isAbsolute(t) {
|
|
122123
|
+
return t.startsWith("/") || t.startsWith("\\") || /^[a-z]:(\/|\\)/i.test(t);
|
|
122124
|
+
}
|
|
122125
|
+
};
|
|
122126
|
+
var rt = class extends It {
|
|
122127
|
+
sep = "/";
|
|
122128
|
+
constructor(t = process.cwd(), e = {}) {
|
|
122129
|
+
let { nocase: s = false } = e;
|
|
122130
|
+
super(t, mi, "/", { ...e, nocase: s }), this.nocase = s;
|
|
122131
|
+
}
|
|
122132
|
+
parseRootPath(t) {
|
|
122133
|
+
return "/";
|
|
122134
|
+
}
|
|
122135
|
+
newRoot(t) {
|
|
122136
|
+
return new jt(this.rootPath, U, undefined, this.roots, this.nocase, this.childrenCache(), { fs: t });
|
|
122137
|
+
}
|
|
122138
|
+
isAbsolute(t) {
|
|
122139
|
+
return t.startsWith("/");
|
|
122140
|
+
}
|
|
122141
|
+
};
|
|
122142
|
+
var St = class extends rt {
|
|
122143
|
+
constructor(t = process.cwd(), e = {}) {
|
|
122144
|
+
let { nocase: s = true } = e;
|
|
122145
|
+
super(t, { ...e, nocase: s });
|
|
122146
|
+
}
|
|
122147
|
+
};
|
|
122148
|
+
var Cr = process.platform === "win32" ? Pt : jt;
|
|
122149
|
+
var Xe = process.platform === "win32" ? it : process.platform === "darwin" ? St : rt;
|
|
122150
|
+
var Di = (n4) => n4.length >= 1;
|
|
122151
|
+
var Mi = (n4) => n4.length >= 1;
|
|
122152
|
+
var Ni = Symbol.for("nodejs.util.inspect.custom");
|
|
122153
|
+
var nt = class n4 {
|
|
122154
|
+
#t;
|
|
122155
|
+
#s;
|
|
122156
|
+
#n;
|
|
122157
|
+
length;
|
|
122158
|
+
#r;
|
|
122159
|
+
#o;
|
|
122160
|
+
#S;
|
|
122161
|
+
#w;
|
|
122162
|
+
#c;
|
|
122163
|
+
#h;
|
|
122164
|
+
#u = true;
|
|
122165
|
+
constructor(t, e, s, i) {
|
|
122166
|
+
if (!Di(t))
|
|
122167
|
+
throw new TypeError("empty pattern list");
|
|
122168
|
+
if (!Mi(e))
|
|
122169
|
+
throw new TypeError("empty glob list");
|
|
122170
|
+
if (e.length !== t.length)
|
|
122171
|
+
throw new TypeError("mismatched pattern list and glob list lengths");
|
|
122172
|
+
if (this.length = t.length, s < 0 || s >= this.length)
|
|
122173
|
+
throw new TypeError("index out of range");
|
|
122174
|
+
if (this.#t = t, this.#s = e, this.#n = s, this.#r = i, this.#n === 0) {
|
|
122175
|
+
if (this.isUNC()) {
|
|
122176
|
+
let [r, o, h, a, ...l] = this.#t, [u, c, d, f, ...m] = this.#s;
|
|
122177
|
+
l[0] === "" && (l.shift(), m.shift());
|
|
122178
|
+
let p = [r, o, h, a, ""].join("/"), w = [u, c, d, f, ""].join("/");
|
|
122179
|
+
this.#t = [p, ...l], this.#s = [w, ...m], this.length = this.#t.length;
|
|
122180
|
+
} else if (this.isDrive() || this.isAbsolute()) {
|
|
122181
|
+
let [r, ...o] = this.#t, [h, ...a] = this.#s;
|
|
122182
|
+
o[0] === "" && (o.shift(), a.shift());
|
|
122183
|
+
let l = r + "/", u = h + "/";
|
|
122184
|
+
this.#t = [l, ...o], this.#s = [u, ...a], this.length = this.#t.length;
|
|
122185
|
+
}
|
|
122186
|
+
}
|
|
122187
|
+
}
|
|
122188
|
+
[Ni]() {
|
|
122189
|
+
return "Pattern <" + this.#s.slice(this.#n).join("/") + ">";
|
|
122190
|
+
}
|
|
122191
|
+
pattern() {
|
|
122192
|
+
return this.#t[this.#n];
|
|
122193
|
+
}
|
|
122194
|
+
isString() {
|
|
122195
|
+
return typeof this.#t[this.#n] == "string";
|
|
122196
|
+
}
|
|
122197
|
+
isGlobstar() {
|
|
122198
|
+
return this.#t[this.#n] === A;
|
|
122199
|
+
}
|
|
122200
|
+
isRegExp() {
|
|
122201
|
+
return this.#t[this.#n] instanceof RegExp;
|
|
122202
|
+
}
|
|
122203
|
+
globString() {
|
|
122204
|
+
return this.#S = this.#S || (this.#n === 0 ? this.isAbsolute() ? this.#s[0] + this.#s.slice(1).join("/") : this.#s.join("/") : this.#s.slice(this.#n).join("/"));
|
|
122205
|
+
}
|
|
122206
|
+
hasMore() {
|
|
122207
|
+
return this.length > this.#n + 1;
|
|
122208
|
+
}
|
|
122209
|
+
rest() {
|
|
122210
|
+
return this.#o !== undefined ? this.#o : this.hasMore() ? (this.#o = new n4(this.#t, this.#s, this.#n + 1, this.#r), this.#o.#h = this.#h, this.#o.#c = this.#c, this.#o.#w = this.#w, this.#o) : this.#o = null;
|
|
122211
|
+
}
|
|
122212
|
+
isUNC() {
|
|
122213
|
+
let t = this.#t;
|
|
122214
|
+
return this.#c !== undefined ? this.#c : this.#c = this.#r === "win32" && this.#n === 0 && t[0] === "" && t[1] === "" && typeof t[2] == "string" && !!t[2] && typeof t[3] == "string" && !!t[3];
|
|
122215
|
+
}
|
|
122216
|
+
isDrive() {
|
|
122217
|
+
let t = this.#t;
|
|
122218
|
+
return this.#w !== undefined ? this.#w : this.#w = this.#r === "win32" && this.#n === 0 && this.length > 1 && typeof t[0] == "string" && /^[a-z]:$/i.test(t[0]);
|
|
122219
|
+
}
|
|
122220
|
+
isAbsolute() {
|
|
122221
|
+
let t = this.#t;
|
|
122222
|
+
return this.#h !== undefined ? this.#h : this.#h = t[0] === "" && t.length > 1 || this.isDrive() || this.isUNC();
|
|
122223
|
+
}
|
|
122224
|
+
root() {
|
|
122225
|
+
let t = this.#t[0];
|
|
122226
|
+
return typeof t == "string" && this.isAbsolute() && this.#n === 0 ? t : "";
|
|
122227
|
+
}
|
|
122228
|
+
checkFollowGlobstar() {
|
|
122229
|
+
return !(this.#n === 0 || !this.isGlobstar() || !this.#u);
|
|
122230
|
+
}
|
|
122231
|
+
markFollowGlobstar() {
|
|
122232
|
+
return this.#n === 0 || !this.isGlobstar() || !this.#u ? false : (this.#u = false, true);
|
|
122233
|
+
}
|
|
122234
|
+
};
|
|
122235
|
+
var _i = typeof process == "object" && process && typeof process.platform == "string" ? process.platform : "linux";
|
|
122236
|
+
var ot = class {
|
|
122237
|
+
relative;
|
|
122238
|
+
relativeChildren;
|
|
122239
|
+
absolute;
|
|
122240
|
+
absoluteChildren;
|
|
122241
|
+
platform;
|
|
122242
|
+
mmopts;
|
|
122243
|
+
constructor(t, { nobrace: e, nocase: s, noext: i, noglobstar: r, platform: o = _i }) {
|
|
122244
|
+
this.relative = [], this.absolute = [], this.relativeChildren = [], this.absoluteChildren = [], this.platform = o, this.mmopts = { dot: true, nobrace: e, nocase: s, noext: i, noglobstar: r, optimizationLevel: 2, platform: o, nocomment: true, nonegate: true };
|
|
122245
|
+
for (let h of t)
|
|
122246
|
+
this.add(h);
|
|
122247
|
+
}
|
|
122248
|
+
add(t) {
|
|
122249
|
+
let e = new D(t, this.mmopts);
|
|
122250
|
+
for (let s = 0;s < e.set.length; s++) {
|
|
122251
|
+
let i = e.set[s], r = e.globParts[s];
|
|
122252
|
+
if (!i || !r)
|
|
122253
|
+
throw new Error("invalid pattern object");
|
|
122254
|
+
for (;i[0] === "." && r[0] === "."; )
|
|
122255
|
+
i.shift(), r.shift();
|
|
122256
|
+
let o = new nt(i, r, 0, this.platform), h = new D(o.globString(), this.mmopts), a = r[r.length - 1] === "**", l = o.isAbsolute();
|
|
122257
|
+
l ? this.absolute.push(h) : this.relative.push(h), a && (l ? this.absoluteChildren.push(h) : this.relativeChildren.push(h));
|
|
122258
|
+
}
|
|
122259
|
+
}
|
|
122260
|
+
ignored(t) {
|
|
122261
|
+
let e = t.fullpath(), s = `${e}/`, i = t.relative() || ".", r = `${i}/`;
|
|
122262
|
+
for (let o of this.relative)
|
|
122263
|
+
if (o.match(i) || o.match(r))
|
|
122264
|
+
return true;
|
|
122265
|
+
for (let o of this.absolute)
|
|
122266
|
+
if (o.match(e) || o.match(s))
|
|
122267
|
+
return true;
|
|
122268
|
+
return false;
|
|
122269
|
+
}
|
|
122270
|
+
childrenIgnored(t) {
|
|
122271
|
+
let e = t.fullpath() + "/", s = (t.relative() || ".") + "/";
|
|
122272
|
+
for (let i of this.relativeChildren)
|
|
122273
|
+
if (i.match(s))
|
|
122274
|
+
return true;
|
|
122275
|
+
for (let i of this.absoluteChildren)
|
|
122276
|
+
if (i.match(e))
|
|
122277
|
+
return true;
|
|
122278
|
+
return false;
|
|
122279
|
+
}
|
|
122280
|
+
};
|
|
122281
|
+
var oe = class n5 {
|
|
122282
|
+
store;
|
|
122283
|
+
constructor(t = new Map) {
|
|
122284
|
+
this.store = t;
|
|
122285
|
+
}
|
|
122286
|
+
copy() {
|
|
122287
|
+
return new n5(new Map(this.store));
|
|
122288
|
+
}
|
|
122289
|
+
hasWalked(t, e) {
|
|
122290
|
+
return this.store.get(t.fullpath())?.has(e.globString());
|
|
122291
|
+
}
|
|
122292
|
+
storeWalked(t, e) {
|
|
122293
|
+
let s = t.fullpath(), i = this.store.get(s);
|
|
122294
|
+
i ? i.add(e.globString()) : this.store.set(s, new Set([e.globString()]));
|
|
122295
|
+
}
|
|
122296
|
+
};
|
|
122297
|
+
var he = class {
|
|
122298
|
+
store = new Map;
|
|
122299
|
+
add(t, e, s) {
|
|
122300
|
+
let i = (e ? 2 : 0) | (s ? 1 : 0), r = this.store.get(t);
|
|
122301
|
+
this.store.set(t, r === undefined ? i : i & r);
|
|
122302
|
+
}
|
|
122303
|
+
entries() {
|
|
122304
|
+
return [...this.store.entries()].map(([t, e]) => [t, !!(e & 2), !!(e & 1)]);
|
|
122305
|
+
}
|
|
122306
|
+
};
|
|
122307
|
+
var ae = class {
|
|
122308
|
+
store = new Map;
|
|
122309
|
+
add(t, e) {
|
|
122310
|
+
if (!t.canReaddir())
|
|
122311
|
+
return;
|
|
122312
|
+
let s = this.store.get(t);
|
|
122313
|
+
s ? s.find((i) => i.globString() === e.globString()) || s.push(e) : this.store.set(t, [e]);
|
|
122314
|
+
}
|
|
122315
|
+
get(t) {
|
|
122316
|
+
let e = this.store.get(t);
|
|
122317
|
+
if (!e)
|
|
122318
|
+
throw new Error("attempting to walk unknown path");
|
|
122319
|
+
return e;
|
|
122320
|
+
}
|
|
122321
|
+
entries() {
|
|
122322
|
+
return this.keys().map((t) => [t, this.store.get(t)]);
|
|
122323
|
+
}
|
|
122324
|
+
keys() {
|
|
122325
|
+
return [...this.store.keys()].filter((t) => t.canReaddir());
|
|
122326
|
+
}
|
|
122327
|
+
};
|
|
122328
|
+
var Et = class n6 {
|
|
122329
|
+
hasWalkedCache;
|
|
122330
|
+
matches = new he;
|
|
122331
|
+
subwalks = new ae;
|
|
122332
|
+
patterns;
|
|
122333
|
+
follow;
|
|
122334
|
+
dot;
|
|
122335
|
+
opts;
|
|
122336
|
+
constructor(t, e) {
|
|
122337
|
+
this.opts = t, this.follow = !!t.follow, this.dot = !!t.dot, this.hasWalkedCache = e ? e.copy() : new oe;
|
|
122338
|
+
}
|
|
122339
|
+
processPatterns(t, e) {
|
|
122340
|
+
this.patterns = e;
|
|
122341
|
+
let s = e.map((i) => [t, i]);
|
|
122342
|
+
for (let [i, r] of s) {
|
|
122343
|
+
this.hasWalkedCache.storeWalked(i, r);
|
|
122344
|
+
let o = r.root(), h = r.isAbsolute() && this.opts.absolute !== false;
|
|
122345
|
+
if (o) {
|
|
122346
|
+
i = i.resolve(o === "/" && this.opts.root !== undefined ? this.opts.root : o);
|
|
122347
|
+
let c = r.rest();
|
|
122348
|
+
if (c)
|
|
122349
|
+
r = c;
|
|
122350
|
+
else {
|
|
122351
|
+
this.matches.add(i, true, false);
|
|
122352
|
+
continue;
|
|
122353
|
+
}
|
|
122354
|
+
}
|
|
122355
|
+
if (i.isENOENT())
|
|
122356
|
+
continue;
|
|
122357
|
+
let a, l, u = false;
|
|
122358
|
+
for (;typeof (a = r.pattern()) == "string" && (l = r.rest()); )
|
|
122359
|
+
i = i.resolve(a), r = l, u = true;
|
|
122360
|
+
if (a = r.pattern(), l = r.rest(), u) {
|
|
122361
|
+
if (this.hasWalkedCache.hasWalked(i, r))
|
|
122362
|
+
continue;
|
|
122363
|
+
this.hasWalkedCache.storeWalked(i, r);
|
|
122364
|
+
}
|
|
122365
|
+
if (typeof a == "string") {
|
|
122366
|
+
let c = a === ".." || a === "" || a === ".";
|
|
122367
|
+
this.matches.add(i.resolve(a), h, c);
|
|
122368
|
+
continue;
|
|
122369
|
+
} else if (a === A) {
|
|
122370
|
+
(!i.isSymbolicLink() || this.follow || r.checkFollowGlobstar()) && this.subwalks.add(i, r);
|
|
122371
|
+
let c = l?.pattern(), d = l?.rest();
|
|
122372
|
+
if (!l || (c === "" || c === ".") && !d)
|
|
122373
|
+
this.matches.add(i, h, c === "" || c === ".");
|
|
122374
|
+
else if (c === "..") {
|
|
122375
|
+
let f = i.parent || i;
|
|
122376
|
+
d ? this.hasWalkedCache.hasWalked(f, d) || this.subwalks.add(f, d) : this.matches.add(f, h, true);
|
|
122377
|
+
}
|
|
122378
|
+
} else
|
|
122379
|
+
a instanceof RegExp && this.subwalks.add(i, r);
|
|
122380
|
+
}
|
|
122381
|
+
return this;
|
|
122382
|
+
}
|
|
122383
|
+
subwalkTargets() {
|
|
122384
|
+
return this.subwalks.keys();
|
|
122385
|
+
}
|
|
122386
|
+
child() {
|
|
122387
|
+
return new n6(this.opts, this.hasWalkedCache);
|
|
122388
|
+
}
|
|
122389
|
+
filterEntries(t, e) {
|
|
122390
|
+
let s = this.subwalks.get(t), i = this.child();
|
|
122391
|
+
for (let r of e)
|
|
122392
|
+
for (let o of s) {
|
|
122393
|
+
let h = o.isAbsolute(), a = o.pattern(), l = o.rest();
|
|
122394
|
+
a === A ? i.testGlobstar(r, o, l, h) : a instanceof RegExp ? i.testRegExp(r, a, l, h) : i.testString(r, a, l, h);
|
|
122395
|
+
}
|
|
122396
|
+
return i;
|
|
122397
|
+
}
|
|
122398
|
+
testGlobstar(t, e, s, i) {
|
|
122399
|
+
if ((this.dot || !t.name.startsWith(".")) && (e.hasMore() || this.matches.add(t, i, false), t.canReaddir() && (this.follow || !t.isSymbolicLink() ? this.subwalks.add(t, e) : t.isSymbolicLink() && (s && e.checkFollowGlobstar() ? this.subwalks.add(t, s) : e.markFollowGlobstar() && this.subwalks.add(t, e)))), s) {
|
|
122400
|
+
let r = s.pattern();
|
|
122401
|
+
if (typeof r == "string" && r !== ".." && r !== "" && r !== ".")
|
|
122402
|
+
this.testString(t, r, s.rest(), i);
|
|
122403
|
+
else if (r === "..") {
|
|
122404
|
+
let o = t.parent || t;
|
|
122405
|
+
this.subwalks.add(o, s);
|
|
122406
|
+
} else
|
|
122407
|
+
r instanceof RegExp && this.testRegExp(t, r, s.rest(), i);
|
|
122408
|
+
}
|
|
122409
|
+
}
|
|
122410
|
+
testRegExp(t, e, s, i) {
|
|
122411
|
+
e.test(t.name) && (s ? this.subwalks.add(t, s) : this.matches.add(t, i, false));
|
|
122412
|
+
}
|
|
122413
|
+
testString(t, e, s, i) {
|
|
122414
|
+
t.isNamed(e) && (s ? this.subwalks.add(t, s) : this.matches.add(t, i, false));
|
|
122415
|
+
}
|
|
122416
|
+
};
|
|
122417
|
+
var Li = (n7, t) => typeof n7 == "string" ? new ot([n7], t) : Array.isArray(n7) ? new ot(n7, t) : n7;
|
|
122418
|
+
var zt = class {
|
|
122419
|
+
path;
|
|
122420
|
+
patterns;
|
|
122421
|
+
opts;
|
|
122422
|
+
seen = new Set;
|
|
122423
|
+
paused = false;
|
|
122424
|
+
aborted = false;
|
|
122425
|
+
#t = [];
|
|
122426
|
+
#s;
|
|
122427
|
+
#n;
|
|
122428
|
+
signal;
|
|
122429
|
+
maxDepth;
|
|
122430
|
+
includeChildMatches;
|
|
122431
|
+
constructor(t, e, s) {
|
|
122432
|
+
if (this.patterns = t, this.path = e, this.opts = s, this.#n = !s.posix && s.platform === "win32" ? "\\" : "/", this.includeChildMatches = s.includeChildMatches !== false, (s.ignore || !this.includeChildMatches) && (this.#s = Li(s.ignore ?? [], s), !this.includeChildMatches && typeof this.#s.add != "function")) {
|
|
122433
|
+
let i = "cannot ignore child matches, ignore lacks add() method.";
|
|
122434
|
+
throw new Error(i);
|
|
122435
|
+
}
|
|
122436
|
+
this.maxDepth = s.maxDepth || 1 / 0, s.signal && (this.signal = s.signal, this.signal.addEventListener("abort", () => {
|
|
122437
|
+
this.#t.length = 0;
|
|
122438
|
+
}));
|
|
122439
|
+
}
|
|
122440
|
+
#r(t) {
|
|
122441
|
+
return this.seen.has(t) || !!this.#s?.ignored?.(t);
|
|
122442
|
+
}
|
|
122443
|
+
#o(t) {
|
|
122444
|
+
return !!this.#s?.childrenIgnored?.(t);
|
|
122445
|
+
}
|
|
122446
|
+
pause() {
|
|
122447
|
+
this.paused = true;
|
|
122448
|
+
}
|
|
122449
|
+
resume() {
|
|
122450
|
+
if (this.signal?.aborted)
|
|
122451
|
+
return;
|
|
122452
|
+
this.paused = false;
|
|
122453
|
+
let t;
|
|
122454
|
+
for (;!this.paused && (t = this.#t.shift()); )
|
|
122455
|
+
t();
|
|
122456
|
+
}
|
|
122457
|
+
onResume(t) {
|
|
122458
|
+
this.signal?.aborted || (this.paused ? this.#t.push(t) : t());
|
|
122459
|
+
}
|
|
122460
|
+
async matchCheck(t, e) {
|
|
122461
|
+
if (e && this.opts.nodir)
|
|
122462
|
+
return;
|
|
122463
|
+
let s;
|
|
122464
|
+
if (this.opts.realpath) {
|
|
122465
|
+
if (s = t.realpathCached() || await t.realpath(), !s)
|
|
122466
|
+
return;
|
|
122467
|
+
t = s;
|
|
122468
|
+
}
|
|
122469
|
+
let r = t.isUnknown() || this.opts.stat ? await t.lstat() : t;
|
|
122470
|
+
if (this.opts.follow && this.opts.nodir && r?.isSymbolicLink()) {
|
|
122471
|
+
let o = await r.realpath();
|
|
122472
|
+
o && (o.isUnknown() || this.opts.stat) && await o.lstat();
|
|
122473
|
+
}
|
|
122474
|
+
return this.matchCheckTest(r, e);
|
|
122475
|
+
}
|
|
122476
|
+
matchCheckTest(t, e) {
|
|
122477
|
+
return t && (this.maxDepth === 1 / 0 || t.depth() <= this.maxDepth) && (!e || t.canReaddir()) && (!this.opts.nodir || !t.isDirectory()) && (!this.opts.nodir || !this.opts.follow || !t.isSymbolicLink() || !t.realpathCached()?.isDirectory()) && !this.#r(t) ? t : undefined;
|
|
122478
|
+
}
|
|
122479
|
+
matchCheckSync(t, e) {
|
|
122480
|
+
if (e && this.opts.nodir)
|
|
122481
|
+
return;
|
|
122482
|
+
let s;
|
|
122483
|
+
if (this.opts.realpath) {
|
|
122484
|
+
if (s = t.realpathCached() || t.realpathSync(), !s)
|
|
122485
|
+
return;
|
|
122486
|
+
t = s;
|
|
122487
|
+
}
|
|
122488
|
+
let r = t.isUnknown() || this.opts.stat ? t.lstatSync() : t;
|
|
122489
|
+
if (this.opts.follow && this.opts.nodir && r?.isSymbolicLink()) {
|
|
122490
|
+
let o = r.realpathSync();
|
|
122491
|
+
o && (o?.isUnknown() || this.opts.stat) && o.lstatSync();
|
|
122492
|
+
}
|
|
122493
|
+
return this.matchCheckTest(r, e);
|
|
122494
|
+
}
|
|
122495
|
+
matchFinish(t, e) {
|
|
122496
|
+
if (this.#r(t))
|
|
122497
|
+
return;
|
|
122498
|
+
if (!this.includeChildMatches && this.#s?.add) {
|
|
122499
|
+
let r = `${t.relativePosix()}/**`;
|
|
122500
|
+
this.#s.add(r);
|
|
122501
|
+
}
|
|
122502
|
+
let s = this.opts.absolute === undefined ? e : this.opts.absolute;
|
|
122503
|
+
this.seen.add(t);
|
|
122504
|
+
let i = this.opts.mark && t.isDirectory() ? this.#n : "";
|
|
122505
|
+
if (this.opts.withFileTypes)
|
|
122506
|
+
this.matchEmit(t);
|
|
122507
|
+
else if (s) {
|
|
122508
|
+
let r = this.opts.posix ? t.fullpathPosix() : t.fullpath();
|
|
122509
|
+
this.matchEmit(r + i);
|
|
122510
|
+
} else {
|
|
122511
|
+
let r = this.opts.posix ? t.relativePosix() : t.relative(), o = this.opts.dotRelative && !r.startsWith(".." + this.#n) ? "." + this.#n : "";
|
|
122512
|
+
this.matchEmit(r ? o + r + i : "." + i);
|
|
122513
|
+
}
|
|
122514
|
+
}
|
|
122515
|
+
async match(t, e, s) {
|
|
122516
|
+
let i = await this.matchCheck(t, s);
|
|
122517
|
+
i && this.matchFinish(i, e);
|
|
122518
|
+
}
|
|
122519
|
+
matchSync(t, e, s) {
|
|
122520
|
+
let i = this.matchCheckSync(t, s);
|
|
122521
|
+
i && this.matchFinish(i, e);
|
|
122522
|
+
}
|
|
122523
|
+
walkCB(t, e, s) {
|
|
122524
|
+
this.signal?.aborted && s(), this.walkCB2(t, e, new Et(this.opts), s);
|
|
122525
|
+
}
|
|
122526
|
+
walkCB2(t, e, s, i) {
|
|
122527
|
+
if (this.#o(t))
|
|
122528
|
+
return i();
|
|
122529
|
+
if (this.signal?.aborted && i(), this.paused) {
|
|
122530
|
+
this.onResume(() => this.walkCB2(t, e, s, i));
|
|
122531
|
+
return;
|
|
122532
|
+
}
|
|
122533
|
+
s.processPatterns(t, e);
|
|
122534
|
+
let r = 1, o = () => {
|
|
122535
|
+
--r === 0 && i();
|
|
122536
|
+
};
|
|
122537
|
+
for (let [h, a, l] of s.matches.entries())
|
|
122538
|
+
this.#r(h) || (r++, this.match(h, a, l).then(() => o()));
|
|
122539
|
+
for (let h of s.subwalkTargets()) {
|
|
122540
|
+
if (this.maxDepth !== 1 / 0 && h.depth() >= this.maxDepth)
|
|
122541
|
+
continue;
|
|
122542
|
+
r++;
|
|
122543
|
+
let a = h.readdirCached();
|
|
122544
|
+
h.calledReaddir() ? this.walkCB3(h, a, s, o) : h.readdirCB((l, u) => this.walkCB3(h, u, s, o), true);
|
|
122545
|
+
}
|
|
122546
|
+
o();
|
|
122547
|
+
}
|
|
122548
|
+
walkCB3(t, e, s, i) {
|
|
122549
|
+
s = s.filterEntries(t, e);
|
|
122550
|
+
let r = 1, o = () => {
|
|
122551
|
+
--r === 0 && i();
|
|
122552
|
+
};
|
|
122553
|
+
for (let [h, a, l] of s.matches.entries())
|
|
122554
|
+
this.#r(h) || (r++, this.match(h, a, l).then(() => o()));
|
|
122555
|
+
for (let [h, a] of s.subwalks.entries())
|
|
122556
|
+
r++, this.walkCB2(h, a, s.child(), o);
|
|
122557
|
+
o();
|
|
122558
|
+
}
|
|
122559
|
+
walkCBSync(t, e, s) {
|
|
122560
|
+
this.signal?.aborted && s(), this.walkCB2Sync(t, e, new Et(this.opts), s);
|
|
122561
|
+
}
|
|
122562
|
+
walkCB2Sync(t, e, s, i) {
|
|
122563
|
+
if (this.#o(t))
|
|
122564
|
+
return i();
|
|
122565
|
+
if (this.signal?.aborted && i(), this.paused) {
|
|
122566
|
+
this.onResume(() => this.walkCB2Sync(t, e, s, i));
|
|
122567
|
+
return;
|
|
122568
|
+
}
|
|
122569
|
+
s.processPatterns(t, e);
|
|
122570
|
+
let r = 1, o = () => {
|
|
122571
|
+
--r === 0 && i();
|
|
122572
|
+
};
|
|
122573
|
+
for (let [h, a, l] of s.matches.entries())
|
|
122574
|
+
this.#r(h) || this.matchSync(h, a, l);
|
|
122575
|
+
for (let h of s.subwalkTargets()) {
|
|
122576
|
+
if (this.maxDepth !== 1 / 0 && h.depth() >= this.maxDepth)
|
|
122577
|
+
continue;
|
|
122578
|
+
r++;
|
|
122579
|
+
let a = h.readdirSync();
|
|
122580
|
+
this.walkCB3Sync(h, a, s, o);
|
|
122581
|
+
}
|
|
122582
|
+
o();
|
|
122583
|
+
}
|
|
122584
|
+
walkCB3Sync(t, e, s, i) {
|
|
122585
|
+
s = s.filterEntries(t, e);
|
|
122586
|
+
let r = 1, o = () => {
|
|
122587
|
+
--r === 0 && i();
|
|
122588
|
+
};
|
|
122589
|
+
for (let [h, a, l] of s.matches.entries())
|
|
122590
|
+
this.#r(h) || this.matchSync(h, a, l);
|
|
122591
|
+
for (let [h, a] of s.subwalks.entries())
|
|
122592
|
+
r++, this.walkCB2Sync(h, a, s.child(), o);
|
|
122593
|
+
o();
|
|
122594
|
+
}
|
|
122595
|
+
};
|
|
122596
|
+
var xt = class extends zt {
|
|
122597
|
+
matches = new Set;
|
|
122598
|
+
constructor(t, e, s) {
|
|
122599
|
+
super(t, e, s);
|
|
122600
|
+
}
|
|
122601
|
+
matchEmit(t) {
|
|
122602
|
+
this.matches.add(t);
|
|
122603
|
+
}
|
|
122604
|
+
async walk() {
|
|
122605
|
+
if (this.signal?.aborted)
|
|
122606
|
+
throw this.signal.reason;
|
|
122607
|
+
return this.path.isUnknown() && await this.path.lstat(), await new Promise((t, e) => {
|
|
122608
|
+
this.walkCB(this.path, this.patterns, () => {
|
|
122609
|
+
this.signal?.aborted ? e(this.signal.reason) : t(this.matches);
|
|
122610
|
+
});
|
|
122611
|
+
}), this.matches;
|
|
122612
|
+
}
|
|
122613
|
+
walkSync() {
|
|
122614
|
+
if (this.signal?.aborted)
|
|
122615
|
+
throw this.signal.reason;
|
|
122616
|
+
return this.path.isUnknown() && this.path.lstatSync(), this.walkCBSync(this.path, this.patterns, () => {
|
|
122617
|
+
if (this.signal?.aborted)
|
|
122618
|
+
throw this.signal.reason;
|
|
122619
|
+
}), this.matches;
|
|
122620
|
+
}
|
|
122621
|
+
};
|
|
122622
|
+
var vt = class extends zt {
|
|
122623
|
+
results;
|
|
122624
|
+
constructor(t, e, s) {
|
|
122625
|
+
super(t, e, s), this.results = new V({ signal: this.signal, objectMode: true }), this.results.on("drain", () => this.resume()), this.results.on("resume", () => this.resume());
|
|
122626
|
+
}
|
|
122627
|
+
matchEmit(t) {
|
|
122628
|
+
this.results.write(t), this.results.flowing || this.pause();
|
|
122629
|
+
}
|
|
122630
|
+
stream() {
|
|
122631
|
+
let t = this.path;
|
|
122632
|
+
return t.isUnknown() ? t.lstat().then(() => {
|
|
122633
|
+
this.walkCB(t, this.patterns, () => this.results.end());
|
|
122634
|
+
}) : this.walkCB(t, this.patterns, () => this.results.end()), this.results;
|
|
122635
|
+
}
|
|
122636
|
+
streamSync() {
|
|
122637
|
+
return this.path.isUnknown() && this.path.lstatSync(), this.walkCBSync(this.path, this.patterns, () => this.results.end()), this.results;
|
|
122638
|
+
}
|
|
122639
|
+
};
|
|
122640
|
+
var Pi = typeof process == "object" && process && typeof process.platform == "string" ? process.platform : "linux";
|
|
122641
|
+
var I = class {
|
|
122642
|
+
absolute;
|
|
122643
|
+
cwd;
|
|
122644
|
+
root;
|
|
122645
|
+
dot;
|
|
122646
|
+
dotRelative;
|
|
122647
|
+
follow;
|
|
122648
|
+
ignore;
|
|
122649
|
+
magicalBraces;
|
|
122650
|
+
mark;
|
|
122651
|
+
matchBase;
|
|
122652
|
+
maxDepth;
|
|
122653
|
+
nobrace;
|
|
122654
|
+
nocase;
|
|
122655
|
+
nodir;
|
|
122656
|
+
noext;
|
|
122657
|
+
noglobstar;
|
|
122658
|
+
pattern;
|
|
122659
|
+
platform;
|
|
122660
|
+
realpath;
|
|
122661
|
+
scurry;
|
|
122662
|
+
stat;
|
|
122663
|
+
signal;
|
|
122664
|
+
windowsPathsNoEscape;
|
|
122665
|
+
withFileTypes;
|
|
122666
|
+
includeChildMatches;
|
|
122667
|
+
opts;
|
|
122668
|
+
patterns;
|
|
122669
|
+
constructor(t, e) {
|
|
122670
|
+
if (!e)
|
|
122671
|
+
throw new TypeError("glob options required");
|
|
122672
|
+
if (this.withFileTypes = !!e.withFileTypes, this.signal = e.signal, this.follow = !!e.follow, this.dot = !!e.dot, this.dotRelative = !!e.dotRelative, this.nodir = !!e.nodir, this.mark = !!e.mark, e.cwd ? (e.cwd instanceof URL || e.cwd.startsWith("file://")) && (e.cwd = Wi(e.cwd)) : this.cwd = "", this.cwd = e.cwd || "", this.root = e.root, this.magicalBraces = !!e.magicalBraces, this.nobrace = !!e.nobrace, this.noext = !!e.noext, this.realpath = !!e.realpath, this.absolute = e.absolute, this.includeChildMatches = e.includeChildMatches !== false, this.noglobstar = !!e.noglobstar, this.matchBase = !!e.matchBase, this.maxDepth = typeof e.maxDepth == "number" ? e.maxDepth : 1 / 0, this.stat = !!e.stat, this.ignore = e.ignore, this.withFileTypes && this.absolute !== undefined)
|
|
122673
|
+
throw new Error("cannot set absolute and withFileTypes:true");
|
|
122674
|
+
if (typeof t == "string" && (t = [t]), this.windowsPathsNoEscape = !!e.windowsPathsNoEscape || e.allowWindowsEscape === false, this.windowsPathsNoEscape && (t = t.map((a) => a.replace(/\\/g, "/"))), this.matchBase) {
|
|
122675
|
+
if (e.noglobstar)
|
|
122676
|
+
throw new TypeError("base matching requires globstar");
|
|
122677
|
+
t = t.map((a) => a.includes("/") ? a : `./**/${a}`);
|
|
122678
|
+
}
|
|
122679
|
+
if (this.pattern = t, this.platform = e.platform || Pi, this.opts = { ...e, platform: this.platform }, e.scurry) {
|
|
122680
|
+
if (this.scurry = e.scurry, e.nocase !== undefined && e.nocase !== e.scurry.nocase)
|
|
122681
|
+
throw new Error("nocase option contradicts provided scurry option");
|
|
122682
|
+
} else {
|
|
122683
|
+
let a = e.platform === "win32" ? it : e.platform === "darwin" ? St : e.platform ? rt : Xe;
|
|
122684
|
+
this.scurry = new a(this.cwd, { nocase: e.nocase, fs: e.fs });
|
|
122685
|
+
}
|
|
122686
|
+
this.nocase = this.scurry.nocase;
|
|
122687
|
+
let s = this.platform === "darwin" || this.platform === "win32", i = { braceExpandMax: 1e4, ...e, dot: this.dot, matchBase: this.matchBase, nobrace: this.nobrace, nocase: this.nocase, nocaseMagicOnly: s, nocomment: true, noext: this.noext, nonegate: true, optimizationLevel: 2, platform: this.platform, windowsPathsNoEscape: this.windowsPathsNoEscape, debug: !!this.opts.debug }, r = this.pattern.map((a) => new D(a, i)), [o, h] = r.reduce((a, l) => (a[0].push(...l.set), a[1].push(...l.globParts), a), [[], []]);
|
|
122688
|
+
this.patterns = o.map((a, l) => {
|
|
122689
|
+
let u = h[l];
|
|
122690
|
+
if (!u)
|
|
122691
|
+
throw new Error("invalid pattern object");
|
|
122692
|
+
return new nt(a, u, 0, this.platform);
|
|
122693
|
+
});
|
|
122694
|
+
}
|
|
122695
|
+
async walk() {
|
|
122696
|
+
return [...await new xt(this.patterns, this.scurry.cwd, { ...this.opts, maxDepth: this.maxDepth !== 1 / 0 ? this.maxDepth + this.scurry.cwd.depth() : 1 / 0, platform: this.platform, nocase: this.nocase, includeChildMatches: this.includeChildMatches }).walk()];
|
|
122697
|
+
}
|
|
122698
|
+
walkSync() {
|
|
122699
|
+
return [...new xt(this.patterns, this.scurry.cwd, { ...this.opts, maxDepth: this.maxDepth !== 1 / 0 ? this.maxDepth + this.scurry.cwd.depth() : 1 / 0, platform: this.platform, nocase: this.nocase, includeChildMatches: this.includeChildMatches }).walkSync()];
|
|
122700
|
+
}
|
|
122701
|
+
stream() {
|
|
122702
|
+
return new vt(this.patterns, this.scurry.cwd, { ...this.opts, maxDepth: this.maxDepth !== 1 / 0 ? this.maxDepth + this.scurry.cwd.depth() : 1 / 0, platform: this.platform, nocase: this.nocase, includeChildMatches: this.includeChildMatches }).stream();
|
|
122703
|
+
}
|
|
122704
|
+
streamSync() {
|
|
122705
|
+
return new vt(this.patterns, this.scurry.cwd, { ...this.opts, maxDepth: this.maxDepth !== 1 / 0 ? this.maxDepth + this.scurry.cwd.depth() : 1 / 0, platform: this.platform, nocase: this.nocase, includeChildMatches: this.includeChildMatches }).streamSync();
|
|
122706
|
+
}
|
|
122707
|
+
iterateSync() {
|
|
122708
|
+
return this.streamSync()[Symbol.iterator]();
|
|
122709
|
+
}
|
|
122710
|
+
[Symbol.iterator]() {
|
|
122711
|
+
return this.iterateSync();
|
|
122712
|
+
}
|
|
122713
|
+
iterate() {
|
|
122714
|
+
return this.stream()[Symbol.asyncIterator]();
|
|
122715
|
+
}
|
|
122716
|
+
[Symbol.asyncIterator]() {
|
|
122717
|
+
return this.iterate();
|
|
122718
|
+
}
|
|
122719
|
+
};
|
|
122720
|
+
var le = (n7, t = {}) => {
|
|
122721
|
+
Array.isArray(n7) || (n7 = [n7]);
|
|
122722
|
+
for (let e of n7)
|
|
122723
|
+
if (new D(e, t).hasMagic())
|
|
122724
|
+
return true;
|
|
122725
|
+
return false;
|
|
122726
|
+
};
|
|
122727
|
+
function Bt(n7, t = {}) {
|
|
122728
|
+
return new I(n7, t).streamSync();
|
|
122729
|
+
}
|
|
122730
|
+
function Qe(n7, t = {}) {
|
|
122731
|
+
return new I(n7, t).stream();
|
|
122732
|
+
}
|
|
122733
|
+
function ts(n7, t = {}) {
|
|
122734
|
+
return new I(n7, t).walkSync();
|
|
122735
|
+
}
|
|
122736
|
+
async function Je(n7, t = {}) {
|
|
122737
|
+
return new I(n7, t).walk();
|
|
122738
|
+
}
|
|
122739
|
+
function Ut(n7, t = {}) {
|
|
122740
|
+
return new I(n7, t).iterateSync();
|
|
122741
|
+
}
|
|
122742
|
+
function es(n7, t = {}) {
|
|
122743
|
+
return new I(n7, t).iterate();
|
|
122744
|
+
}
|
|
122745
|
+
var ji = Bt;
|
|
122746
|
+
var Ii = Object.assign(Qe, { sync: Bt });
|
|
122747
|
+
var zi = Ut;
|
|
122748
|
+
var Bi = Object.assign(es, { sync: Ut });
|
|
122749
|
+
var Ui = Object.assign(ts, { stream: Bt, iterate: Ut });
|
|
122750
|
+
var Ze = Object.assign(Je, { glob: Je, globSync: ts, sync: Ui, globStream: Qe, stream: Ii, globStreamSync: Bt, streamSync: ji, globIterate: es, iterate: Bi, globIterateSync: Ut, iterateSync: zi, Glob: I, hasMagic: le, escape: tt, unescape: W });
|
|
122751
|
+
Ze.glob = Ze;
|
|
122752
|
+
|
|
122753
|
+
// src/core/agents/offSecAgent/tools/glob.ts
|
|
122754
|
+
init_zod();
|
|
122755
|
+
var DEFAULT_IGNORE = [
|
|
122756
|
+
"**/node_modules/**",
|
|
122757
|
+
"**/.git/**",
|
|
122758
|
+
"**/dist/**",
|
|
122759
|
+
"**/build/**",
|
|
122760
|
+
"**/.next/**",
|
|
122761
|
+
"**/coverage/**",
|
|
122762
|
+
"**/__pycache__/**",
|
|
122763
|
+
"**/.venv/**",
|
|
122764
|
+
"**/venv/**"
|
|
122765
|
+
];
|
|
122766
|
+
var MAX_RESULTS = 200;
|
|
122767
|
+
var globInputSchema = exports_external.object({
|
|
122768
|
+
pattern: exports_external.string().describe('Glob pattern to match files (e.g. "**/*.ts", "src/**/*.tsx", "**/package.json")'),
|
|
122769
|
+
path: exports_external.string().optional().describe("Directory to search from (absolute or relative to agent cwd). Defaults to agent cwd."),
|
|
122770
|
+
toolCallDescription: exports_external.string().describe("A concise, human-readable description of what this tool call is doing (e.g., 'Find all TypeScript source files')")
|
|
122771
|
+
});
|
|
122772
|
+
function resolveGlobRoot(agentCwd, path) {
|
|
122773
|
+
const root = path ? isAbsolute9(path) ? path : resolve10(agentCwd, path) : agentCwd;
|
|
122774
|
+
const rel = relative7(agentCwd, root);
|
|
122775
|
+
if (rel.startsWith("..") || isAbsolute9(rel)) {
|
|
122776
|
+
throw new Error(`Path escapes agent working directory: ${path ?? root}`);
|
|
122777
|
+
}
|
|
122778
|
+
return root;
|
|
122779
|
+
}
|
|
122780
|
+
function globFiles(ctx) {
|
|
122781
|
+
return tool({
|
|
122782
|
+
description: `Find files by glob pattern under the agent working directory.
|
|
122783
|
+
|
|
122784
|
+
Examples:
|
|
122785
|
+
- "**/*.ts" — all TypeScript files
|
|
122786
|
+
- "src/**/*.{ts,tsx}" — sources under src/
|
|
122787
|
+
- "**/package.json" — package manifests
|
|
122788
|
+
|
|
122789
|
+
Skips common junk directories (node_modules, .git, dist, build, .next, coverage, venv).
|
|
122790
|
+
Results are capped at ${MAX_RESULTS}; narrow the pattern if truncated.`,
|
|
122791
|
+
inputSchema: globInputSchema,
|
|
122792
|
+
execute: async ({ pattern, path }) => {
|
|
122793
|
+
let root;
|
|
122794
|
+
try {
|
|
122795
|
+
root = resolveGlobRoot(ctx.agentCwd, path);
|
|
122796
|
+
} catch (err) {
|
|
122797
|
+
return {
|
|
122798
|
+
success: false,
|
|
122799
|
+
error: err instanceof Error ? err.message : String(err),
|
|
122800
|
+
files: [],
|
|
122801
|
+
count: 0,
|
|
122802
|
+
pattern,
|
|
122803
|
+
cwd: ctx.agentCwd
|
|
122804
|
+
};
|
|
122805
|
+
}
|
|
122806
|
+
try {
|
|
122807
|
+
if (ctx.sandbox) {
|
|
122808
|
+
const escapedPattern = pattern.replace(/"/g, "\\\"");
|
|
122809
|
+
const cmd = `shopt -s globstar nullglob 2>/dev/null; cd "${root}" && compgen -G "${escapedPattern}" | head -n ${MAX_RESULTS + 1}`;
|
|
122810
|
+
const result = await ctx.sandbox.execute(cmd, { timeout: 30 });
|
|
122811
|
+
const lines = result.stdout.split(`
|
|
122812
|
+
`).map((l) => l.trim()).filter(Boolean);
|
|
122813
|
+
const truncated2 = lines.length > MAX_RESULTS;
|
|
122814
|
+
const files2 = lines.slice(0, MAX_RESULTS);
|
|
122815
|
+
return {
|
|
122816
|
+
success: true,
|
|
122817
|
+
error: truncated2 ? `Showing ${MAX_RESULTS} of at least ${lines.length} matches — narrow the pattern` : "",
|
|
122818
|
+
files: files2,
|
|
122819
|
+
count: files2.length,
|
|
122820
|
+
totalFound: truncated2 ? lines.length : undefined,
|
|
122821
|
+
pattern,
|
|
122822
|
+
cwd: root
|
|
122823
|
+
};
|
|
122824
|
+
}
|
|
122825
|
+
const matches = await Ze(pattern, {
|
|
122826
|
+
cwd: root,
|
|
122827
|
+
nodir: true,
|
|
122828
|
+
dot: false,
|
|
122829
|
+
ignore: DEFAULT_IGNORE,
|
|
122830
|
+
absolute: false
|
|
122831
|
+
});
|
|
122832
|
+
const truncated = matches.length > MAX_RESULTS;
|
|
122833
|
+
const files = matches.slice(0, MAX_RESULTS).sort();
|
|
122834
|
+
return {
|
|
122835
|
+
success: true,
|
|
122836
|
+
error: truncated ? `Showing ${MAX_RESULTS} of ${matches.length} matches — narrow the pattern` : "",
|
|
122837
|
+
files,
|
|
122838
|
+
count: files.length,
|
|
122839
|
+
totalFound: truncated ? matches.length : undefined,
|
|
122840
|
+
pattern,
|
|
122841
|
+
cwd: root
|
|
122842
|
+
};
|
|
122843
|
+
} catch (err) {
|
|
122844
|
+
return {
|
|
122845
|
+
success: false,
|
|
122846
|
+
error: err instanceof Error ? err.message : String(err),
|
|
122847
|
+
files: [],
|
|
122848
|
+
count: 0,
|
|
122849
|
+
pattern,
|
|
122850
|
+
cwd: root
|
|
122851
|
+
};
|
|
122852
|
+
}
|
|
122853
|
+
}
|
|
122854
|
+
});
|
|
122855
|
+
}
|
|
118941
122856
|
// src/core/agents/offSecAgent/tools/listPromptInjections.ts
|
|
118942
122857
|
init_dist();
|
|
118943
122858
|
init_zod();
|
|
@@ -119151,7 +123066,7 @@ Use this instead of asking for the whole playbook. Examples:
|
|
|
119151
123066
|
// src/core/agents/offSecAgent/tools/runCodeQuery.ts
|
|
119152
123067
|
init_dist();
|
|
119153
123068
|
init_zod();
|
|
119154
|
-
import { relative as
|
|
123069
|
+
import { relative as relative8 } from "node:path";
|
|
119155
123070
|
var MAX_INLINE_MATCHES = 40;
|
|
119156
123071
|
var MAX_QUERY_CAPTURE_BYTES = 2 * 1024 * 1024;
|
|
119157
123072
|
var QueryEngineSchema = exports_external.enum(["rg", "grep", "ast-grep", "comby"]);
|
|
@@ -119222,7 +123137,7 @@ instead of flooding context with every match. Output size and runtime are bounde
|
|
|
119222
123137
|
let targetPathForEngine = ".";
|
|
119223
123138
|
try {
|
|
119224
123139
|
const absTarget = resolvePathWithinCodebaseRoot(rootPath, query.path ?? ".");
|
|
119225
|
-
targetPathForEngine =
|
|
123140
|
+
targetPathForEngine = relative8(rootPath, absTarget) || ".";
|
|
119226
123141
|
} catch (error) {
|
|
119227
123142
|
results.push({
|
|
119228
123143
|
engine,
|
|
@@ -119587,10 +123502,10 @@ function listWhiteboxCandidates2(ctx) {
|
|
|
119587
123502
|
// src/core/agents/offSecAgent/tools/whiteboxJobs.ts
|
|
119588
123503
|
init_dist();
|
|
119589
123504
|
init_zod();
|
|
119590
|
-
import { isAbsolute as
|
|
123505
|
+
import { isAbsolute as isAbsolute10, relative as relative9, sep as sep2 } from "node:path";
|
|
119591
123506
|
function displayPath(ctx, path) {
|
|
119592
123507
|
const prefix = ctx.session.rootPath.endsWith(sep2) ? ctx.session.rootPath : `${ctx.session.rootPath}${sep2}`;
|
|
119593
|
-
return path === ctx.session.rootPath || path.startsWith(prefix) ?
|
|
123508
|
+
return path === ctx.session.rootPath || path.startsWith(prefix) ? relative9(ctx.session.rootPath, path) : path;
|
|
119594
123509
|
}
|
|
119595
123510
|
function startWhiteboxJob2(ctx) {
|
|
119596
123511
|
return tool({
|
|
@@ -119725,9 +123640,9 @@ function stopWhiteboxJob2(ctx) {
|
|
|
119725
123640
|
});
|
|
119726
123641
|
}
|
|
119727
123642
|
function normalizeArtifactRelativePath(ctx, userPath) {
|
|
119728
|
-
if (
|
|
119729
|
-
const rel =
|
|
119730
|
-
if (rel.startsWith("..") || rel === ".." ||
|
|
123643
|
+
if (isAbsolute10(userPath)) {
|
|
123644
|
+
const rel = relative9(ctx.session.rootPath, userPath);
|
|
123645
|
+
if (rel.startsWith("..") || rel === ".." || isAbsolute10(rel)) {
|
|
119731
123646
|
throw new Error("Artifact path must be inside the session directory.");
|
|
119732
123647
|
}
|
|
119733
123648
|
return rel.replace(/\\/g, "/");
|
|
@@ -119825,12 +123740,17 @@ function createAllTools(ctx) {
|
|
|
119825
123740
|
document_vulnerability: documentVulnerability(ctx),
|
|
119826
123741
|
read_file: readFile2(ctx),
|
|
119827
123742
|
list_files: listFiles(ctx),
|
|
123743
|
+
glob: globFiles(ctx),
|
|
119828
123744
|
grep: grep(ctx),
|
|
119829
123745
|
profile_codebase: profileCodebase2(ctx),
|
|
119830
123746
|
query_whitebox_catalog: queryWhiteboxCatalog2(ctx),
|
|
119831
123747
|
run_code_query: runCodeQuery(ctx),
|
|
119832
123748
|
create_file: createFile(ctx),
|
|
119833
123749
|
update_file: updateFile(ctx),
|
|
123750
|
+
delete_file: deleteFile(ctx),
|
|
123751
|
+
apply_patch: applyPatch(ctx),
|
|
123752
|
+
git_status: gitStatus(ctx),
|
|
123753
|
+
git_diff: gitDiff(ctx),
|
|
119834
123754
|
document_app: documentApp(ctx),
|
|
119835
123755
|
document_endpoint: documentEndpoint(ctx),
|
|
119836
123756
|
delegate_to_auth_subagent: delegateAuth(ctx),
|
|
@@ -119893,12 +123813,17 @@ var ALL_TOOL_NAMES = [
|
|
|
119893
123813
|
"document_vulnerability",
|
|
119894
123814
|
"read_file",
|
|
119895
123815
|
"list_files",
|
|
123816
|
+
"glob",
|
|
119896
123817
|
"grep",
|
|
119897
123818
|
"profile_codebase",
|
|
119898
123819
|
"query_whitebox_catalog",
|
|
119899
123820
|
"run_code_query",
|
|
119900
123821
|
"create_file",
|
|
119901
123822
|
"update_file",
|
|
123823
|
+
"delete_file",
|
|
123824
|
+
"apply_patch",
|
|
123825
|
+
"git_status",
|
|
123826
|
+
"git_diff",
|
|
119902
123827
|
"document_app",
|
|
119903
123828
|
"document_endpoint",
|
|
119904
123829
|
"delegate_to_auth_subagent",
|
|
@@ -119976,8 +123901,11 @@ var PLAN_MODE_TOOL_NAMES = [
|
|
|
119976
123901
|
"http_request",
|
|
119977
123902
|
"read_file",
|
|
119978
123903
|
"list_files",
|
|
123904
|
+
"glob",
|
|
119979
123905
|
"grep",
|
|
119980
123906
|
"query_whitebox_catalog",
|
|
123907
|
+
"git_status",
|
|
123908
|
+
"git_diff",
|
|
119981
123909
|
"delegate_to_auth_subagent",
|
|
119982
123910
|
"complete_authentication",
|
|
119983
123911
|
"extract_js_endpoints",
|
|
@@ -120010,7 +123938,7 @@ var SKILL_TOOL_NAMES = ["read_skill"];
|
|
|
120010
123938
|
// src/core/agents/offSecAgent/trace.ts
|
|
120011
123939
|
import { createHash as createHash2 } from "node:crypto";
|
|
120012
123940
|
import { appendFileSync as appendFileSync3, mkdirSync as mkdirSync13 } from "node:fs";
|
|
120013
|
-
import { dirname as
|
|
123941
|
+
import { dirname as dirname8 } from "node:path";
|
|
120014
123942
|
var OUTPUT_PREVIEW_LIMIT = 2000;
|
|
120015
123943
|
var INPUT_PREVIEW_LIMIT = 1000;
|
|
120016
123944
|
var SYSTEM_PROMPT_HASH_PREFIX_LENGTH = 12;
|
|
@@ -120071,7 +123999,7 @@ class StepTraceWriter {
|
|
|
120071
123999
|
const now = Date.now();
|
|
120072
124000
|
this.agentStartTime = now;
|
|
120073
124001
|
this.lastStepTime = now;
|
|
120074
|
-
mkdirSync13(
|
|
124002
|
+
mkdirSync13(dirname8(this.tracePath), { recursive: true });
|
|
120075
124003
|
}
|
|
120076
124004
|
writeInit(data) {
|
|
120077
124005
|
const { systemPrompt, ...rest } = data;
|
|
@@ -120211,7 +124139,7 @@ class StepTraceWriter {
|
|
|
120211
124139
|
init_dist();
|
|
120212
124140
|
init_ai();
|
|
120213
124141
|
import { existsSync as existsSync18, mkdirSync as mkdirSync14, readFileSync as readFileSync8 } from "node:fs";
|
|
120214
|
-
import { writeFile as
|
|
124142
|
+
import { writeFile as writeFile7 } from "node:fs/promises";
|
|
120215
124143
|
import { join as join27 } from "node:path";
|
|
120216
124144
|
init_id();
|
|
120217
124145
|
init_structured();
|
|
@@ -120264,8 +124192,8 @@ class ApprovalGate extends EventEmitter3 {
|
|
|
120264
124192
|
tier: 1,
|
|
120265
124193
|
timestamp: Date.now()
|
|
120266
124194
|
};
|
|
120267
|
-
return new Promise((
|
|
120268
|
-
const deferred = { approval, resolve:
|
|
124195
|
+
return new Promise((resolve11, reject) => {
|
|
124196
|
+
const deferred = { approval, resolve: resolve11, reject };
|
|
120269
124197
|
this.pendingApprovals.set(approval.id, deferred);
|
|
120270
124198
|
const timeoutMs = this.config.decisionTimeoutMs;
|
|
120271
124199
|
if (timeoutMs !== undefined && timeoutMs > 0) {
|
|
@@ -120521,8 +124449,8 @@ class OffensiveSecurityAgent {
|
|
|
120521
124449
|
_responseToolFired = false;
|
|
120522
124450
|
_resolveResponseCaptured;
|
|
120523
124451
|
_rejectResponseCaptured;
|
|
120524
|
-
responseCaptured = new Promise((
|
|
120525
|
-
this._resolveResponseCaptured =
|
|
124452
|
+
responseCaptured = new Promise((resolve11, reject) => {
|
|
124453
|
+
this._resolveResponseCaptured = resolve11;
|
|
120526
124454
|
this._rejectResponseCaptured = reject;
|
|
120527
124455
|
});
|
|
120528
124456
|
_drainRejection = new Promise(() => {});
|
|
@@ -120741,7 +124669,7 @@ class OffensiveSecurityAgent {
|
|
|
120741
124669
|
if (this.latestMessages) {
|
|
120742
124670
|
const toWrite = this.latestMessages;
|
|
120743
124671
|
this.latestMessages = null;
|
|
120744
|
-
|
|
124672
|
+
writeFile7(messagesPath, JSON.stringify(toWrite)).catch(() => {});
|
|
120745
124673
|
}
|
|
120746
124674
|
}, PERSIST_INTERVAL_MS);
|
|
120747
124675
|
};
|
|
@@ -120809,7 +124737,7 @@ class OffensiveSecurityAgent {
|
|
|
120809
124737
|
...initialMessagesRef.current,
|
|
120810
124738
|
...event.response.messages
|
|
120811
124739
|
];
|
|
120812
|
-
await
|
|
124740
|
+
await writeFile7(messagesPath, JSON.stringify(finalMessages)).catch(() => {});
|
|
120813
124741
|
}
|
|
120814
124742
|
await input.onFinish?.(event);
|
|
120815
124743
|
},
|
|
@@ -120922,7 +124850,7 @@ class OffensiveSecurityAgent {
|
|
|
120922
124850
|
const fr = c.finishReason;
|
|
120923
124851
|
rlog.warn(`[response-debug] finish-step finishReason=${fr} responseInFlight=${[
|
|
120924
124852
|
...inFlightTools.entries()
|
|
120925
|
-
].filter(([,
|
|
124853
|
+
].filter(([, n7]) => n7 === RESPONSE_TOOL_NAME).map(([id]) => id).join(",")} responseToolFired=${this._responseToolFired}`);
|
|
120926
124854
|
}
|
|
120927
124855
|
}
|
|
120928
124856
|
}
|
|
@@ -120951,20 +124879,20 @@ class OffensiveSecurityAgent {
|
|
|
120951
124879
|
inFlightTools.set(chunk.toolCallId, chunk.toolName);
|
|
120952
124880
|
break;
|
|
120953
124881
|
case "tool-error": {
|
|
120954
|
-
const
|
|
120955
|
-
inFlightTools.delete(
|
|
120956
|
-
const errMsg =
|
|
124882
|
+
const te2 = chunk;
|
|
124883
|
+
inFlightTools.delete(te2.toolCallId);
|
|
124884
|
+
const errMsg = te2.error instanceof Error ? te2.error.message : typeof te2.error === "string" ? te2.error : (() => {
|
|
120957
124885
|
try {
|
|
120958
|
-
return JSON.stringify(
|
|
124886
|
+
return JSON.stringify(te2.error);
|
|
120959
124887
|
} catch {
|
|
120960
|
-
return String(
|
|
124888
|
+
return String(te2.error);
|
|
120961
124889
|
}
|
|
120962
124890
|
})();
|
|
120963
|
-
const partialArgs =
|
|
120964
|
-
toolErrors.set(
|
|
124891
|
+
const partialArgs = te2.input !== undefined && te2.input !== null && responseArgBytes(te2.input) > 2 ? te2.input : streamedArgText.get(te2.toolCallId) ?? "";
|
|
124892
|
+
toolErrors.set(te2.toolCallId, {
|
|
120965
124893
|
message: errMsg,
|
|
120966
124894
|
input: partialArgs,
|
|
120967
|
-
toolName:
|
|
124895
|
+
toolName: te2.toolName
|
|
120968
124896
|
});
|
|
120969
124897
|
break;
|
|
120970
124898
|
}
|
|
@@ -121092,7 +125020,7 @@ class OffensiveSecurityAgent {
|
|
|
121092
125020
|
}
|
|
121093
125021
|
}));
|
|
121094
125022
|
let rejectDrain;
|
|
121095
|
-
this._drainRejection = new Promise((
|
|
125023
|
+
this._drainRejection = new Promise((_2, reject) => {
|
|
121096
125024
|
rejectDrain = reject;
|
|
121097
125025
|
});
|
|
121098
125026
|
this._drainRejection.catch(() => {});
|
|
@@ -121137,7 +125065,7 @@ class OffensiveSecurityAgent {
|
|
|
121137
125065
|
};
|
|
121138
125066
|
const syntheticParts = [];
|
|
121139
125067
|
if (RESPONSE_DEBUG) {
|
|
121140
|
-
const responseInFlight = [...inFlightTools.entries()].filter(([,
|
|
125068
|
+
const responseInFlight = [...inFlightTools.entries()].filter(([, n7]) => n7 === RESPONSE_TOOL_NAME);
|
|
121141
125069
|
if (responseInFlight.length > 0) {
|
|
121142
125070
|
rlog.warn(`[response-debug] emitSyntheticToolResults closing ${responseInFlight.length} response call(s) ` + `ids=${responseInFlight.map(([id]) => id).join(",")} reason="${reason}" ` + `aborted=${this.abortSignal?.aborted === true} responseToolFired=${this._responseToolFired}`);
|
|
121143
125071
|
}
|
|
@@ -121195,7 +125123,7 @@ class OffensiveSecurityAgent {
|
|
|
121195
125123
|
}
|
|
121196
125124
|
};
|
|
121197
125125
|
if (RESPONSE_DEBUG) {
|
|
121198
|
-
const responseReconstructed = stepTools.filter(([,
|
|
125126
|
+
const responseReconstructed = stepTools.filter(([, n7]) => n7 === RESPONSE_TOOL_NAME).map(([id]) => id);
|
|
121199
125127
|
if (responseReconstructed.length > 0) {
|
|
121200
125128
|
rlog.warn(`[response-debug] step-reconstruction for response call(s) ` + `ids=${responseReconstructed.join(",")} ` + `preservedArgChars=${responseReconstructed.map((id) => streamedArgText?.get(id)?.length ?? 0).join(",")}`);
|
|
121201
125129
|
}
|
|
@@ -121215,7 +125143,7 @@ class OffensiveSecurityAgent {
|
|
|
121215
125143
|
const next = [...base, ...appended];
|
|
121216
125144
|
this.latestMessages = next;
|
|
121217
125145
|
try {
|
|
121218
|
-
await
|
|
125146
|
+
await writeFile7(this.messagesPath, JSON.stringify(next));
|
|
121219
125147
|
this.syntheticsPersisted = true;
|
|
121220
125148
|
} catch {}
|
|
121221
125149
|
}
|