@skillstech/thunderlang 1.4.3 → 1.5.0
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/CHANGELOG.md +23 -0
- package/dist/core.cjs +402 -159
- package/dist/index.cjs +490 -170
- package/dist/learn.cjs +398 -155
- package/package.json +1 -1
- package/src/cli.mjs +1 -1
- package/src/emit.mjs +1 -1
- package/src/mcp.mjs +2 -2
- package/src/passport.mjs +9 -2
- package/src/read-repo-fs.mjs +3 -2
- package/src/trace-cli.mjs +3 -3
- package/src/trace-data.mjs +219 -0
- package/src/trace-fs.mjs +10 -3
- package/src/trace.mjs +207 -16
package/dist/core.cjs
CHANGED
|
@@ -6529,8 +6529,8 @@ function exactText(inner, code3) {
|
|
|
6529
6529
|
function exactIn(inner, code3, open) {
|
|
6530
6530
|
if (!/«|…/.test(inner) && inner.length && [`'${inner}'`, `"${inner}"`, `\`${inner}\``].some((q2) => String(code3).includes(q2))) return true;
|
|
6531
6531
|
if (!/«|…/.test(inner) && inner.trim().length) {
|
|
6532
|
-
const
|
|
6533
|
-
if (new RegExp(`(?:^|[\\s#%/:+=(\\-{"'])${
|
|
6532
|
+
const esc3 = inner.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
6533
|
+
if (new RegExp(`(?:^|[\\s#%/:+=(\\-{"'])${esc3}(?=$|[\\s}/)"';|])`).test(String(code3))) return true;
|
|
6534
6534
|
}
|
|
6535
6535
|
const cut = /…$/.test(inner);
|
|
6536
6536
|
const w = textSkeleton(inner.replace(/…$/, ""), true);
|
|
@@ -6546,10 +6546,10 @@ function exactIn(inner, code3, open) {
|
|
|
6546
6546
|
for (let i = 0; i < parts.length; i++) {
|
|
6547
6547
|
const f = parts[i].trim();
|
|
6548
6548
|
if (!f) continue;
|
|
6549
|
-
const
|
|
6549
|
+
const esc3 = f.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
6550
6550
|
const lead = i === 0 ? B : "[\"'`\\s,|]";
|
|
6551
6551
|
const tail = i === parts.length - 1 ? cut ? "" : E : "[\"'`\\s,]";
|
|
6552
|
-
const src = `${lead}${
|
|
6552
|
+
const src = `${lead}${esc3}${tail ? `(?=${tail})` : ""}`;
|
|
6553
6553
|
let re = FRAG_RE.get(src);
|
|
6554
6554
|
if (!re) {
|
|
6555
6555
|
if (FRAG_RE.size > 5e3) FRAG_RE.clear();
|
|
@@ -7889,10 +7889,10 @@ function lexSql(src, from = 0, to = src.length, dialect = "pg") {
|
|
|
7889
7889
|
}
|
|
7890
7890
|
const pre = /[EeNnBbXx]/.test(c) && src[i + 1] === "'" && !/[\w$]/.test(src[i - 1] || "");
|
|
7891
7891
|
if (c === "'" || pre) {
|
|
7892
|
-
const
|
|
7892
|
+
const esc3 = dialect === "mysql" || pre && /[Ee]/.test(c);
|
|
7893
7893
|
let j = i + (pre ? 2 : 1);
|
|
7894
7894
|
for (; j < to; j++) {
|
|
7895
|
-
if (
|
|
7895
|
+
if (esc3 && src[j] === "\\") {
|
|
7896
7896
|
j++;
|
|
7897
7897
|
continue;
|
|
7898
7898
|
}
|
|
@@ -8434,12 +8434,12 @@ function bodySteps(toks2, ctx, opts = {}) {
|
|
|
8434
8434
|
const n = toks2.length;
|
|
8435
8435
|
const labels = [];
|
|
8436
8436
|
const peek = (k = 0) => toks2[i + k];
|
|
8437
|
-
const
|
|
8438
|
-
const baseOf = (a, b) => ({ line:
|
|
8437
|
+
const lineOf7 = (tok) => ctx.lineAt(tok.s);
|
|
8438
|
+
const baseOf = (a, b) => ({ line: lineOf7(toks2[a]), span: { startLine: lineOf7(toks2[a]), endLine: lineOf7(toks2[Math.max(a, b - 1)]) } });
|
|
8439
8439
|
const textOf3 = (a, b) => ctx.src.slice(toks2[a].s, toks2[b - 1].e);
|
|
8440
8440
|
const semi = ctx.dialect !== "tsql";
|
|
8441
8441
|
const expect = (cond, what) => {
|
|
8442
|
-
if (!cond) throw new Unmatched(`${what} (line ${peek() ?
|
|
8442
|
+
if (!cond) throw new Unmatched(`${what} (line ${peek() ? lineOf7(peek()) : "end"})`);
|
|
8443
8443
|
};
|
|
8444
8444
|
const skipSemis = () => {
|
|
8445
8445
|
while (isP(peek(), ";")) i++;
|
|
@@ -8635,19 +8635,19 @@ function bodySteps(toks2, ctx, opts = {}) {
|
|
|
8635
8635
|
const [c0, c1] = condUntil((x) => isW(x, "THEN"));
|
|
8636
8636
|
i++;
|
|
8637
8637
|
const step2 = branch(c0, c1, block(endsWith("ELSIF", "ELSEIF", "ELSE", "END")));
|
|
8638
|
-
step2.line =
|
|
8638
|
+
step2.line = lineOf7(toks2[a]);
|
|
8639
8639
|
let tail = step2;
|
|
8640
8640
|
while (isW(peek(), "ELSIF", "ELSEIF")) {
|
|
8641
8641
|
const at2 = i;
|
|
8642
8642
|
i++;
|
|
8643
8643
|
const [e0, e1] = condUntil((x) => isW(x, "THEN"));
|
|
8644
8644
|
i++;
|
|
8645
|
-
const next = branch(e0, e1, block(endsWith("ELSIF", "ELSEIF", "ELSE", "END")), null,
|
|
8645
|
+
const next = branch(e0, e1, block(endsWith("ELSIF", "ELSEIF", "ELSE", "END")), null, lineOf7(toks2[at2]));
|
|
8646
8646
|
tail.otherwise = [next];
|
|
8647
8647
|
tail = next;
|
|
8648
8648
|
}
|
|
8649
8649
|
if (isW(peek(), "ELSE")) {
|
|
8650
|
-
tail.otherwiseLine =
|
|
8650
|
+
tail.otherwiseLine = lineOf7(peek());
|
|
8651
8651
|
i++;
|
|
8652
8652
|
tail.otherwise = block(endsWith("END"));
|
|
8653
8653
|
}
|
|
@@ -8660,9 +8660,9 @@ function bodySteps(toks2, ctx, opts = {}) {
|
|
|
8660
8660
|
const kids2 = tsqlBody();
|
|
8661
8661
|
skipSemis();
|
|
8662
8662
|
const step2 = branch(c0, c1, kids2);
|
|
8663
|
-
step2.line =
|
|
8663
|
+
step2.line = lineOf7(toks2[a]);
|
|
8664
8664
|
if (isW(peek(), "ELSE")) {
|
|
8665
|
-
step2.otherwiseLine =
|
|
8665
|
+
step2.otherwiseLine = lineOf7(peek());
|
|
8666
8666
|
i++;
|
|
8667
8667
|
step2.otherwise = tsqlBody();
|
|
8668
8668
|
}
|
|
@@ -8686,7 +8686,7 @@ function bodySteps(toks2, ctx, opts = {}) {
|
|
|
8686
8686
|
expect(arms.length, "CASE without WHEN");
|
|
8687
8687
|
let elseKids = null, elseLine = null;
|
|
8688
8688
|
if (isW(peek(), "ELSE")) {
|
|
8689
|
-
elseLine =
|
|
8689
|
+
elseLine = lineOf7(peek());
|
|
8690
8690
|
i++;
|
|
8691
8691
|
elseKids = block(endsWith("END"));
|
|
8692
8692
|
}
|
|
@@ -8699,14 +8699,14 @@ function bodySteps(toks2, ctx, opts = {}) {
|
|
|
8699
8699
|
text2 = vals.length === 1 ? `${subj} = ${vals[0]}` : `${subj} IN (${vals.join(", ")})`;
|
|
8700
8700
|
} else text2 = code2(textOf3(arm.w0, arm.w1));
|
|
8701
8701
|
const w = condWords(text2, ctx);
|
|
8702
|
-
return { kind: "branch", says: `If ${w ?? asCodeWords(text2, 400)}`, code: text2, cond: text2, line:
|
|
8702
|
+
return { kind: "branch", says: `If ${w ?? asCodeWords(text2, 400)}`, code: text2, cond: text2, line: lineOf7(toks2[arm.at]), span: { startLine: lineOf7(toks2[arm.at]), endLine: lineOf7(toks2[arm.w1 - 1]) }, children: arm.kids };
|
|
8703
8703
|
});
|
|
8704
8704
|
for (let k = 0; k < steps.length - 1; k++) steps[k].otherwise = [steps[k + 1]];
|
|
8705
8705
|
const last = steps.at(-1);
|
|
8706
8706
|
if (elseKids) {
|
|
8707
8707
|
last.otherwise = elseKids;
|
|
8708
8708
|
last.otherwiseLine = elseLine;
|
|
8709
|
-
} else last.otherwise = [{ kind: "fail", says: "Fails with an error: no WHEN matched and there is no ELSE (case not found)", error: "case not found", code: code2(textOf3(a, i)), line:
|
|
8709
|
+
} else last.otherwise = [{ kind: "fail", says: "Fails with an error: no WHEN matched and there is no ELSE (case not found)", error: "case not found", code: code2(textOf3(a, i)), line: lineOf7(toks2[a]) }];
|
|
8710
8710
|
return [steps[0]];
|
|
8711
8711
|
}
|
|
8712
8712
|
if (up === "LOOP" && semi) {
|
|
@@ -8802,7 +8802,7 @@ function bodySteps(toks2, ctx, opts = {}) {
|
|
|
8802
8802
|
closeWith("TRY", "BEGIN TRY");
|
|
8803
8803
|
skipSemis();
|
|
8804
8804
|
expect(isW(peek(), "BEGIN") && isW(peek(1), "CATCH"), "BEGIN TRY without BEGIN CATCH");
|
|
8805
|
-
const hLine =
|
|
8805
|
+
const hLine = lineOf7(peek());
|
|
8806
8806
|
i += 2;
|
|
8807
8807
|
const handler = block(endsWith("END"));
|
|
8808
8808
|
closeWith("CATCH", "BEGIN CATCH");
|
|
@@ -8825,7 +8825,7 @@ function bodySteps(toks2, ctx, opts = {}) {
|
|
|
8825
8825
|
i++;
|
|
8826
8826
|
const names = toks2.slice(c0, c1).filter((x) => !isW(x, "OR", "SQLSTATE")).map((x) => x.t === "str" ? `error ${strText(x)}` : words2(x.v));
|
|
8827
8827
|
const any = toks2.slice(c0, c1).some((x) => isW(x, "OTHERS"));
|
|
8828
|
-
handlers.push({ says: any ? "If anything goes wrong" : `If ${names.join(" or ")} goes wrong`, line:
|
|
8828
|
+
handlers.push({ says: any ? "If anything goes wrong" : `If ${names.join(" or ")} goes wrong`, line: lineOf7(toks2[hAt]), steps: block(endsWith("WHEN", "END")) });
|
|
8829
8829
|
}
|
|
8830
8830
|
}
|
|
8831
8831
|
ctx.depth--;
|
|
@@ -8943,9 +8943,9 @@ function bodySteps(toks2, ctx, opts = {}) {
|
|
|
8943
8943
|
if (isP(peek(), ";")) i++;
|
|
8944
8944
|
return [{ kind: "call", says: `Jumps to ${toks2[a + 1]?.v ?? "a label"}`, code: code2(textOf3(a, e2)), jump: "break", ...baseOf(a, e2) }];
|
|
8945
8945
|
}
|
|
8946
|
-
if (!semi && (up === "ELSE" || up === "END")) throw new Unmatched(`${up} without its IF or BEGIN (line ${
|
|
8947
|
-
if (semi && (up === "ELSE" || up === "ELSIF" || up === "ELSEIF" || up === "WHEN" || up === "UNTIL" || up === "EXCEPTION")) throw new Unmatched(`${up} outside its block (line ${
|
|
8948
|
-
if (semi && up === "END" && !ctx.allowEnd) throw new Unmatched(`END without its BEGIN (line ${
|
|
8946
|
+
if (!semi && (up === "ELSE" || up === "END")) throw new Unmatched(`${up} without its IF or BEGIN (line ${lineOf7(t)})`);
|
|
8947
|
+
if (semi && (up === "ELSE" || up === "ELSIF" || up === "ELSEIF" || up === "WHEN" || up === "UNTIL" || up === "EXCEPTION")) throw new Unmatched(`${up} outside its block (line ${lineOf7(t)})`);
|
|
8948
|
+
if (semi && up === "END" && !ctx.allowEnd) throw new Unmatched(`END without its BEGIN (line ${lineOf7(t)})`);
|
|
8949
8949
|
const e = Math.max(simpleEnd(a), a + 1);
|
|
8950
8950
|
i = e;
|
|
8951
8951
|
if (isP(peek(), ";")) i++;
|
|
@@ -8967,10 +8967,10 @@ function sqlDialect(src) {
|
|
|
8967
8967
|
return "pg";
|
|
8968
8968
|
}
|
|
8969
8969
|
var ROUTINE_WORDS = ["FUNCTION", "PROCEDURE", "PROC"];
|
|
8970
|
-
function sqlRoutines(src,
|
|
8970
|
+
function sqlRoutines(src, lineAt5, dialect = sqlDialect(src)) {
|
|
8971
8971
|
const toks2 = lexSql(src, 0, src.length, dialect);
|
|
8972
8972
|
const out = [];
|
|
8973
|
-
const
|
|
8973
|
+
const lineOf7 = (k) => lineAt5(toks2[Math.min(k, toks2.length - 1)].s);
|
|
8974
8974
|
for (let k = 0; k < toks2.length; k++) {
|
|
8975
8975
|
const start = k;
|
|
8976
8976
|
let j = k;
|
|
@@ -9116,7 +9116,7 @@ function sqlRoutines(src, lineAt4, dialect = sqlDialect(src)) {
|
|
|
9116
9116
|
}
|
|
9117
9117
|
}
|
|
9118
9118
|
let steps = [], bodyEnd3 = end2;
|
|
9119
|
-
const ctx = { src, lineAt:
|
|
9119
|
+
const ctx = { src, lineAt: lineAt5, dialect: bodyDialect, routine, setof, trigger, depth: 0 };
|
|
9120
9120
|
try {
|
|
9121
9121
|
if (dialect === "pg") {
|
|
9122
9122
|
if (bodyToks && language !== "c" && language !== "internal") {
|
|
@@ -9155,8 +9155,8 @@ function sqlRoutines(src, lineAt4, dialect = sqlDialect(src)) {
|
|
|
9155
9155
|
steps = [];
|
|
9156
9156
|
}
|
|
9157
9157
|
if (dialect === "tsql" || dialect === "mysql") end2 = bodyEnd3;
|
|
9158
|
-
const endLine =
|
|
9159
|
-
out.push({ name, line:
|
|
9158
|
+
const endLine = lineOf7(Math.max(end2, start));
|
|
9159
|
+
out.push({ name, line: lineOf7(start), endLine, kind: routine, inputs, outs, returns, setof, trigger, steps, ...unreadWhy ? { unreadWhy } : {}, headerEnd: lineOf7(Math.max(start, j - 1)) });
|
|
9160
9160
|
k = Math.max(k, Math.min(end2, toks2.length - 1));
|
|
9161
9161
|
}
|
|
9162
9162
|
return out;
|
|
@@ -9322,7 +9322,7 @@ function sqlCondition(cond, { aliases = {}, vars = false, keepAt = true, raw = f
|
|
|
9322
9322
|
}
|
|
9323
9323
|
function readSchema(src) {
|
|
9324
9324
|
const m = mask(src);
|
|
9325
|
-
const
|
|
9325
|
+
const lineAt5 = lineFinder(src);
|
|
9326
9326
|
const tables = [], choices = [], rules = [];
|
|
9327
9327
|
const docs = /* @__PURE__ */ new Map();
|
|
9328
9328
|
for (const c of src.matchAll(/COMMENT\s+ON\s+TABLE\s+([\w."]+)\s+IS\s+'((?:[^']|'')*)'/gi)) docs.set(bare(c[1]).toLowerCase(), c[2].replace(/''/g, "'"));
|
|
@@ -9331,10 +9331,10 @@ function readSchema(src) {
|
|
|
9331
9331
|
const close = parenEnd(m, open);
|
|
9332
9332
|
if (close < 0) continue;
|
|
9333
9333
|
const name = bare(src.slice(t.index, open).match(/([\w."[\]`]+)\s*$/)[1]);
|
|
9334
|
-
const table = { name, lines: [
|
|
9334
|
+
const table = { name, lines: [lineAt5(t.index), lineAt5(close)], doc: docs.get(name.toLowerCase()) ?? docAbove(src, t.index), columns: [], checks: [], uniques: [], refs: [] };
|
|
9335
9335
|
for (const part of splitTop(src.slice(open + 1, close), m.slice(open + 1, close))) {
|
|
9336
9336
|
const text2 = part.text.trim().replace(/\s+/g, " ");
|
|
9337
|
-
const line =
|
|
9337
|
+
const line = lineAt5(open + 1 + part.at + (part.text.length - part.text.trimStart().length));
|
|
9338
9338
|
let x;
|
|
9339
9339
|
if (x = text2.match(/^(?:CONSTRAINT\s+([\w"]+)\s+)?CHECK\s*\((.*)\)$/i)) {
|
|
9340
9340
|
table.checks.push({ name: x[1] && unquote(x[1]), cond: x[2], line });
|
|
@@ -9367,7 +9367,7 @@ function readSchema(src) {
|
|
|
9367
9367
|
const close = parenEnd(m, open);
|
|
9368
9368
|
if (close < 0) continue;
|
|
9369
9369
|
const values = [...src.slice(open + 1, close).matchAll(/'((?:[^']|'')*)'/g)].map((v) => v[1].replace(/''/g, "'").replace(/_/g, " "));
|
|
9370
|
-
choices.push({ name: bare(e[1]), lines: [
|
|
9370
|
+
choices.push({ name: bare(e[1]), lines: [lineAt5(e.index), lineAt5(close)], doc: docAbove(src, e.index), values });
|
|
9371
9371
|
}
|
|
9372
9372
|
for (const t of tables) {
|
|
9373
9373
|
for (const c of t.checks) rules.push({ table: t.name, kind: "check", ...c });
|
|
@@ -9470,7 +9470,7 @@ function sqlTemplateReason(src) {
|
|
|
9470
9470
|
}
|
|
9471
9471
|
function sqlItems(src) {
|
|
9472
9472
|
const m = mask(src);
|
|
9473
|
-
const
|
|
9473
|
+
const lineAt5 = lineFinder(src);
|
|
9474
9474
|
const items = [];
|
|
9475
9475
|
const push = (name, line, steps, extra = {}) => {
|
|
9476
9476
|
const code3 = steps.filter((s) => s.kind === "other").length;
|
|
@@ -9500,9 +9500,9 @@ function sqlItems(src) {
|
|
|
9500
9500
|
const end2 = m.indexOf(";", v.index);
|
|
9501
9501
|
const query = src.slice(v.index + v[0].length, end2 < 0 ? src.length : end2);
|
|
9502
9502
|
const name = bare(v[1]);
|
|
9503
|
-
push(name,
|
|
9503
|
+
push(name, lineAt5(v.index), selectSteps(query, lineAt5(v.index + v[0].length)), { doc: docAbove(src, v.index), endLine: lineAt5(end2 < 0 ? src.length : end2), says: `${words2(name)} is a saved query.`, headline: `${words2(name)}: a saved query.` });
|
|
9504
9504
|
}
|
|
9505
|
-
for (const r of sqlRoutines(src,
|
|
9505
|
+
for (const r of sqlRoutines(src, lineAt5)) {
|
|
9506
9506
|
const inputs = r.inputs.map(({ name, type }) => ({ name, type }));
|
|
9507
9507
|
const returns = r.returns ?? (r.outs.length ? listWords(r.outs.map((o) => words2(o.name))) : null);
|
|
9508
9508
|
const steps = r.unreadWhy ? [] : r.steps;
|
|
@@ -9520,7 +9520,7 @@ function sqlItems(src) {
|
|
|
9520
9520
|
const events = t[3].split(/\s+OR\s+/i).map((e) => ({ INSERT: "added", UPDATE: "changed", DELETE: "removed", TRUNCATE: "emptied" })[e.trim().split(/\s+/)[0].toUpperCase()] || words2(e)).filter(Boolean);
|
|
9521
9521
|
const what = article(singular(words2(bare(t[4]))));
|
|
9522
9522
|
const when = `${t[2].toUpperCase() === "BEFORE" ? "Before" : t[2].toUpperCase() === "AFTER" ? "After" : "Instead of when"} ${what} is ${events.join(" or ")}`;
|
|
9523
|
-
push(bare(t[1]),
|
|
9523
|
+
push(bare(t[1]), lineAt5(t.index), [{ kind: "call", says: `${when}, runs ${words2(bare(t[5]))}`, code: t[0].replace(/\s+/g, " "), line: lineAt5(t.index) }], { says: `${when}, the database runs ${words2(bare(t[5]))}.`, headline: `${when}.`, doc: docAbove(src, t.index) });
|
|
9524
9524
|
}
|
|
9525
9525
|
for (const r of readSchema(src).rules) {
|
|
9526
9526
|
const table = words2(r.table);
|
|
@@ -11954,7 +11954,7 @@ function scanInterp(src, j, dialect) {
|
|
|
11954
11954
|
}
|
|
11955
11955
|
return j;
|
|
11956
11956
|
}
|
|
11957
|
-
function tokenize2(src, dialect, from = 0, to = src.length,
|
|
11957
|
+
function tokenize2(src, dialect, from = 0, to = src.length, lineAt5 = lineIndex(src)) {
|
|
11958
11958
|
const hcl = dialect === "hcl";
|
|
11959
11959
|
const toks2 = [], comments = [];
|
|
11960
11960
|
let i = from;
|
|
@@ -11972,14 +11972,14 @@ function tokenize2(src, dialect, from = 0, to = src.length, lineAt4 = lineIndex(
|
|
|
11972
11972
|
if (c === "#" || c === "/" && src[i + 1] === "/") {
|
|
11973
11973
|
let j = i;
|
|
11974
11974
|
while (j < to && src[j] !== "\n") j++;
|
|
11975
|
-
comments.push({ line:
|
|
11975
|
+
comments.push({ line: lineAt5(i), endLine: lineAt5(i), text: src.slice(i, j).replace(/^(#|\/\/)\s?/, "").trim(), s: i });
|
|
11976
11976
|
i = j;
|
|
11977
11977
|
continue;
|
|
11978
11978
|
}
|
|
11979
11979
|
if (c === "/" && src[i + 1] === "*") {
|
|
11980
11980
|
let j = src.indexOf("*/", i + 2);
|
|
11981
11981
|
if (j < 0 || j > to) j = to - 2;
|
|
11982
|
-
comments.push({ line:
|
|
11982
|
+
comments.push({ line: lineAt5(i), endLine: lineAt5(j), text: src.slice(i + 2, j).replace(/^\s*\*+/gm, "").trim(), s: i });
|
|
11983
11983
|
i = j + 2;
|
|
11984
11984
|
continue;
|
|
11985
11985
|
}
|
|
@@ -12054,12 +12054,12 @@ function tokenize2(src, dialect, from = 0, to = src.length, lineAt4 = lineIndex(
|
|
|
12054
12054
|
}
|
|
12055
12055
|
var BIN = { "??": 1, "||": 2, "&&": 3, "==": 4, "!=": 4, "=~": 4, "!~": 4, "<": 5, ">": 5, "<=": 5, ">=": 5, "+": 6, "-": 6, "*": 7, "/": 7, "%": 7 };
|
|
12056
12056
|
var Parser2 = class _Parser {
|
|
12057
|
-
constructor(src, toks2, dialect,
|
|
12057
|
+
constructor(src, toks2, dialect, lineAt5, hooks = {}) {
|
|
12058
12058
|
this.src = src;
|
|
12059
12059
|
this.toks = toks2;
|
|
12060
12060
|
this.i = 0;
|
|
12061
12061
|
this.dialect = dialect;
|
|
12062
|
-
this.lineAt =
|
|
12062
|
+
this.lineAt = lineAt5;
|
|
12063
12063
|
this.hooks = hooks;
|
|
12064
12064
|
this.skipNl = [false];
|
|
12065
12065
|
}
|
|
@@ -12572,9 +12572,9 @@ function docAbove2(comments, line) {
|
|
|
12572
12572
|
}
|
|
12573
12573
|
function parseHcl(src) {
|
|
12574
12574
|
const text2 = String(src ?? "").replace(/^/, "");
|
|
12575
|
-
const
|
|
12576
|
-
const { toks: toks2, comments } = tokenize2(text2, "hcl", 0, text2.length,
|
|
12577
|
-
const p = new Parser2(text2, toks2, "hcl",
|
|
12575
|
+
const lineAt5 = lineIndex(text2);
|
|
12576
|
+
const { toks: toks2, comments } = tokenize2(text2, "hcl", 0, text2.length, lineAt5);
|
|
12577
|
+
const p = new Parser2(text2, toks2, "hcl", lineAt5);
|
|
12578
12578
|
const errors = [];
|
|
12579
12579
|
const body2 = [];
|
|
12580
12580
|
for (; ; ) {
|
|
@@ -12589,7 +12589,7 @@ function parseHcl(src) {
|
|
|
12589
12589
|
p.i = resync(toks2, start);
|
|
12590
12590
|
}
|
|
12591
12591
|
}
|
|
12592
|
-
return { body: body2, comments, errors, lineAt:
|
|
12592
|
+
return { body: body2, comments, errors, lineAt: lineAt5, src: text2 };
|
|
12593
12593
|
}
|
|
12594
12594
|
function resync(toks2, i) {
|
|
12595
12595
|
let depth = 0, seen = false;
|
|
@@ -13584,9 +13584,9 @@ function ingressFacts(d, fact) {
|
|
|
13584
13584
|
// src/bicep.mjs
|
|
13585
13585
|
function parseBicep(src) {
|
|
13586
13586
|
const text2 = String(src ?? "").replace(/^/, "");
|
|
13587
|
-
const
|
|
13588
|
-
const { toks: toks2, comments } = tokenize2(text2, "bicep", 0, text2.length,
|
|
13589
|
-
const p = new Parser2(text2, toks2, "bicep",
|
|
13587
|
+
const lineAt5 = lineIndex(text2);
|
|
13588
|
+
const { toks: toks2, comments } = tokenize2(text2, "bicep", 0, text2.length, lineAt5);
|
|
13589
|
+
const p = new Parser2(text2, toks2, "bicep", lineAt5, { objectKey: nestedResource });
|
|
13590
13590
|
const decls = [], errors = [];
|
|
13591
13591
|
let decorators = [];
|
|
13592
13592
|
for (; ; ) {
|
|
@@ -13615,7 +13615,7 @@ function parseBicep(src) {
|
|
|
13615
13615
|
decorators = [];
|
|
13616
13616
|
}
|
|
13617
13617
|
}
|
|
13618
|
-
return { decls, comments, errors, lineAt:
|
|
13618
|
+
return { decls, comments, errors, lineAt: lineAt5, src: text2 };
|
|
13619
13619
|
}
|
|
13620
13620
|
function resync2(toks2, i) {
|
|
13621
13621
|
let depth = 0;
|
|
@@ -19407,7 +19407,7 @@ function notesSummary(ast) {
|
|
|
19407
19407
|
byLens
|
|
19408
19408
|
};
|
|
19409
19409
|
}
|
|
19410
|
-
var COMPILER_VERSION = "1.
|
|
19410
|
+
var COMPILER_VERSION = "1.5.0";
|
|
19411
19411
|
var PROOF_SCHEMA_VERSION = "0.1.0";
|
|
19412
19412
|
var SOURCE_PRODUCT = "skillstech-compiler";
|
|
19413
19413
|
function buildContractGraph(ast, generatedAt) {
|
|
@@ -22902,7 +22902,7 @@ function sayNode(n) {
|
|
|
22902
22902
|
}
|
|
22903
22903
|
var CODE_MAX = 160;
|
|
22904
22904
|
function makeStepper(src) {
|
|
22905
|
-
const
|
|
22905
|
+
const lineAt5 = lineFinder2(src);
|
|
22906
22906
|
const codeOf = (n) => {
|
|
22907
22907
|
const t = src.slice(n.at, n.end).replace(/\s+/g, " ").trim();
|
|
22908
22908
|
return t.length > CODE_MAX ? `${t.slice(0, CODE_MAX - 1)}\u2026` : t;
|
|
@@ -22911,8 +22911,8 @@ function makeStepper(src) {
|
|
|
22911
22911
|
const t = src.slice(n.at, n.end).split("\n")[0].trim();
|
|
22912
22912
|
return t.length > CODE_MAX ? `${t.slice(0, CODE_MAX - 1)}\u2026` : t;
|
|
22913
22913
|
};
|
|
22914
|
-
const span = (n) => ({ startLine:
|
|
22915
|
-
const base2 = (n, code3 = codeOf(n)) => ({ code: code3, line:
|
|
22914
|
+
const span = (n) => ({ startLine: lineAt5(n.at), endLine: lineAt5(Math.max(n.at, n.end - 1)) });
|
|
22915
|
+
const base2 = (n, code3 = codeOf(n)) => ({ code: code3, line: lineAt5(n.at), span: span(n) });
|
|
22916
22916
|
function steps(nodes2) {
|
|
22917
22917
|
const out = [];
|
|
22918
22918
|
for (let k = 0; k < nodes2.length; k++) {
|
|
@@ -22924,7 +22924,7 @@ function makeStepper(src) {
|
|
|
22924
22924
|
if (ex && (ex.kind === "fail" || ex.failCode) && !ex.message) {
|
|
22925
22925
|
const code3 = ex.exitCode ?? ex.failCode;
|
|
22926
22926
|
const what = ex.exitCode ? `exit code ${code3}` : `return code ${code3}`;
|
|
22927
|
-
out.push({ kind: "fail", says: `Fails with ${what}: "${got[0].stderr}"`, error: what, message: got[0].stderr, code: `${codeOf(n)}; ${codeOf(next)}`, line:
|
|
22927
|
+
out.push({ kind: "fail", says: `Fails with ${what}: "${got[0].stderr}"`, error: what, message: got[0].stderr, code: `${codeOf(n)}; ${codeOf(next)}`, line: lineAt5(n.at), span: { startLine: lineAt5(n.at), endLine: lineAt5(next.end - 1) } });
|
|
22928
22928
|
k++;
|
|
22929
22929
|
continue;
|
|
22930
22930
|
}
|
|
@@ -22977,7 +22977,7 @@ function makeStepper(src) {
|
|
|
22977
22977
|
case "if": {
|
|
22978
22978
|
let first = null, tail = null;
|
|
22979
22979
|
for (const c of n.clauses) {
|
|
22980
|
-
const b = { kind: "branch", says: `If ${condWords2(c.cond)}`, code: src.slice(c.at, src.indexOf("\n", c.at) < 0 ? void 0 : src.indexOf("\n", c.at)).trim().slice(0, CODE_MAX), line:
|
|
22980
|
+
const b = { kind: "branch", says: `If ${condWords2(c.cond)}`, code: src.slice(c.at, src.indexOf("\n", c.at) < 0 ? void 0 : src.indexOf("\n", c.at)).trim().slice(0, CODE_MAX), line: lineAt5(c.at), span: first ? { startLine: lineAt5(c.at), endLine: lineAt5(n.end - 1) } : span(n) };
|
|
22981
22981
|
const kids2 = steps(c.body);
|
|
22982
22982
|
if (kids2.length) b.children = kids2;
|
|
22983
22983
|
if (!first) first = b;
|
|
@@ -22990,7 +22990,7 @@ function makeStepper(src) {
|
|
|
22990
22990
|
if (n.otherwise) {
|
|
22991
22991
|
const kids2 = steps(n.otherwise);
|
|
22992
22992
|
tail.otherwise = kids2;
|
|
22993
|
-
tail.otherwiseLine =
|
|
22993
|
+
tail.otherwiseLine = lineAt5(n.elseAt);
|
|
22994
22994
|
}
|
|
22995
22995
|
return [first];
|
|
22996
22996
|
}
|
|
@@ -23039,7 +23039,7 @@ function makeStepper(src) {
|
|
|
23039
23039
|
says = `When it is ${ws.length > 1 ? `${ws.slice(0, -1).join(", ")} or ${ws.at(-1)}` : ws[0]}`;
|
|
23040
23040
|
} else says = `When it matches ${pats.map((p) => asCode3(p)).join(" or ")}`;
|
|
23041
23041
|
const kids2 = steps(a.body);
|
|
23042
|
-
return { kind: "check", says, caseLabel: true, code: src.slice(a.at, src.indexOf(")", a.at) + 1).trim().slice(0, 90), line:
|
|
23042
|
+
return { kind: "check", says, caseLabel: true, code: src.slice(a.at, src.indexOf(")", a.at) + 1).trim().slice(0, 90), line: lineAt5(a.at), span: { startLine: lineAt5(a.at), endLine: lineAt5(Math.max(a.at, a.end - 1)) }, ...kids2.length ? { children: kids2 } : {} };
|
|
23043
23043
|
});
|
|
23044
23044
|
return [{ kind: "branch", says: `Chooses by ${sayWord(n.word)}`, ...base2(n, headOf2(n)), ...arms.length ? { children: arms } : {} }];
|
|
23045
23045
|
}
|
|
@@ -23098,7 +23098,7 @@ function makeStepper(src) {
|
|
|
23098
23098
|
};
|
|
23099
23099
|
return build(0);
|
|
23100
23100
|
}
|
|
23101
|
-
return { steps, lineAt:
|
|
23101
|
+
return { steps, lineAt: lineAt5, codeOf, headOf: headOf2 };
|
|
23102
23102
|
}
|
|
23103
23103
|
function docAbove3(lines, line) {
|
|
23104
23104
|
const run = [];
|
|
@@ -23219,7 +23219,7 @@ function shellReading(src, file = "") {
|
|
|
23219
23219
|
const last = f.body[f.body.length - 1];
|
|
23220
23220
|
if (last?.type === "simple" && last.words[0] === "exit" && /^[1-9]\d*$/.test(last.words[1] ?? "")) DIES.set(f.name, last.words[1]);
|
|
23221
23221
|
}
|
|
23222
|
-
const { steps, lineAt:
|
|
23222
|
+
const { steps, lineAt: lineAt5 } = makeStepper(src);
|
|
23223
23223
|
const errors = /* @__PURE__ */ new Map();
|
|
23224
23224
|
const noteErrors = (list3) => {
|
|
23225
23225
|
for (const s of list3 || []) {
|
|
@@ -23229,19 +23229,19 @@ function shellReading(src, file = "") {
|
|
|
23229
23229
|
}
|
|
23230
23230
|
};
|
|
23231
23231
|
for (const f of all) {
|
|
23232
|
-
const line =
|
|
23232
|
+
const line = lineAt5(f.at);
|
|
23233
23233
|
const st = steps(f.body);
|
|
23234
|
-
if (!st.length) st.push({ kind: "return", says: "Does nothing", code: src.slice(f.at, f.end).replace(/\s+/g, " ").trim().slice(0, 160), line, span: { startLine: line, endLine:
|
|
23234
|
+
if (!st.length) st.push({ kind: "return", says: "Does nothing", code: src.slice(f.at, f.end).replace(/\s+/g, " ").trim().slice(0, 160), line, span: { startLine: line, endLine: lineAt5(f.end - 1) } });
|
|
23235
23235
|
noteErrors(st);
|
|
23236
23236
|
const first = f.body[0], lastN = f.body[f.body.length - 1];
|
|
23237
|
-
fns.push({ name: f.name, line, params: inputsOf(f.body, src), doc: docAbove3(lines, line), steps: st, body: first ? [
|
|
23237
|
+
fns.push({ name: f.name, line, params: inputsOf(f.body, src), doc: docAbove3(lines, line), steps: st, body: first ? [lineAt5(first.at), lineAt5(lastN.end - 1)] : null });
|
|
23238
23238
|
}
|
|
23239
23239
|
const top = nodes2.filter((n) => n.type !== "function");
|
|
23240
23240
|
if (top.length) {
|
|
23241
23241
|
const st = steps(top);
|
|
23242
23242
|
noteErrors(st);
|
|
23243
23243
|
const name = file ? String(file).split(/[\\/]/).pop() : "script";
|
|
23244
|
-
fns.push({ name, line:
|
|
23244
|
+
fns.push({ name, line: lineAt5(top[0].at), params: inputsOf(top, src), doc: headerDoc(lines), steps: st, body: [lineAt5(top[0].at), lineAt5(top[top.length - 1].end - 1)], topLevel: true, headline: `Runs ${name}, from top to bottom.` });
|
|
23245
23245
|
}
|
|
23246
23246
|
fns.sort((a, b) => a.line - b.line);
|
|
23247
23247
|
KNOWN_FNS = /* @__PURE__ */ new Set();
|
|
@@ -24293,7 +24293,7 @@ function docBefore(toks2, idx) {
|
|
|
24293
24293
|
}
|
|
24294
24294
|
function makeReader(src) {
|
|
24295
24295
|
const toks2 = tokenize3(src);
|
|
24296
|
-
const
|
|
24296
|
+
const lineAt5 = lineFinder3(src);
|
|
24297
24297
|
const fns = [], things = [], errors = /* @__PURE__ */ new Map(), tests = [];
|
|
24298
24298
|
const code3 = (s, e) => {
|
|
24299
24299
|
const t = src.slice(toks2[s].at, toks2[e - 1].end).replace(/\s+/g, " ").trim();
|
|
@@ -24303,8 +24303,8 @@ function makeReader(src) {
|
|
|
24303
24303
|
const t = src.slice(toks2[s].at, toks2[e - 1].end).split("\n")[0].trim();
|
|
24304
24304
|
return t.length > 160 ? `${t.slice(0, 159)}\u2026` : t;
|
|
24305
24305
|
};
|
|
24306
|
-
const spanOf2 = (s, e) => ({ startLine:
|
|
24307
|
-
const base2 = (s, e, c = code3(s, e)) => ({ code: c, line:
|
|
24306
|
+
const spanOf2 = (s, e) => ({ startLine: lineAt5(toks2[s].at), endLine: lineAt5(toks2[e - 1].end - 1) });
|
|
24307
|
+
const base2 = (s, e, c = code3(s, e)) => ({ code: c, line: lineAt5(toks2[s].at), span: spanOf2(s, e) });
|
|
24308
24308
|
const nextTok = (i, to) => {
|
|
24309
24309
|
while (i < to && (toks2[i].t === "nl" || toks2[i].t === "comment")) i++;
|
|
24310
24310
|
return i;
|
|
@@ -24343,7 +24343,7 @@ function makeReader(src) {
|
|
|
24343
24343
|
const blk = blockAt(toks2[p].match + 1, e);
|
|
24344
24344
|
if (!blk) break;
|
|
24345
24345
|
const cond = toks2.slice(p + 1, toks2[p].match);
|
|
24346
|
-
const b = { kind: "branch", says: `If ${gated(cond, condWords3(cond, false)) ?? asCodeWords(code3(p + 1, toks2[p].match))}`, cond: condJs(cond), code: head(i, blk[1] + 1), line:
|
|
24346
|
+
const b = { kind: "branch", says: `If ${gated(cond, condWords3(cond, false)) ?? asCodeWords(code3(p + 1, toks2[p].match))}`, cond: condJs(cond), code: head(i, blk[1] + 1), line: lineAt5(toks2[i].at), span: first ? spanOf2(i, e) : spanOf2(s, e) };
|
|
24347
24347
|
const kids2 = stepsIn(blk[0], blk[1], ctx);
|
|
24348
24348
|
if (kids2.length) b.children = kids2;
|
|
24349
24349
|
if (!first) first = b;
|
|
@@ -24359,7 +24359,7 @@ function makeReader(src) {
|
|
|
24359
24359
|
const blk = blockAt(i + 1, e);
|
|
24360
24360
|
if (!blk) break;
|
|
24361
24361
|
tail.otherwise = stepsIn(blk[0], blk[1], ctx);
|
|
24362
|
-
tail.otherwiseLine =
|
|
24362
|
+
tail.otherwiseLine = lineAt5(toks2[i].at);
|
|
24363
24363
|
i = blk[1] + 1;
|
|
24364
24364
|
continue;
|
|
24365
24365
|
}
|
|
@@ -24440,7 +24440,7 @@ function makeReader(src) {
|
|
|
24440
24440
|
if (!body2) break;
|
|
24441
24441
|
const kids2 = stepsIn(body2[0], body2[1], ctx);
|
|
24442
24442
|
const label = /^default$/i.test(pat.text) ? "Otherwise" : pat.text === "{" ? `When ${gated(toks2.slice(patStart + 1, pat.match), condWords3(toks2.slice(patStart + 1, pat.match), false)) ?? asCodeWords(code3(patStart + 1, pat.match))}` : flags2.includes("-regex") ? `When it matches the pattern ${sayValue2([pat])}` : flags2.includes("-wildcard") ? `When it matches ${sayValue2([pat])}` : `When it is ${sayValue2(toks2.slice(patStart, k)) ?? pat.text}`;
|
|
24443
|
-
arms.push({ kind: "check", says: label, caseLabel: true, code: head(patStart, body2[1] + 1).slice(0, 90), line:
|
|
24443
|
+
arms.push({ kind: "check", says: label, caseLabel: true, code: head(patStart, body2[1] + 1).slice(0, 90), line: lineAt5(pat.at), span: spanOf2(patStart, body2[1] + 1), ...kids2.length ? { children: kids2 } : {}, _pat: pat });
|
|
24444
24444
|
k = body2[1] + 1;
|
|
24445
24445
|
}
|
|
24446
24446
|
for (const a of arms) delete a._pat;
|
|
@@ -24471,14 +24471,14 @@ function makeReader(src) {
|
|
|
24471
24471
|
} finally {
|
|
24472
24472
|
IN_CATCH--;
|
|
24473
24473
|
}
|
|
24474
|
-
(step.handlers ||= []).push({ says: types.length ? `If ${types.join(" or ")} goes wrong` : "If anything goes wrong", line:
|
|
24474
|
+
(step.handlers ||= []).push({ says: types.length ? `If ${types.join(" or ")} goes wrong` : "If anything goes wrong", line: lineAt5(toks2[i].at), steps: hs });
|
|
24475
24475
|
i = nextTok(b[1] + 1, e);
|
|
24476
24476
|
continue;
|
|
24477
24477
|
}
|
|
24478
24478
|
if (w === "finally") {
|
|
24479
24479
|
const b = blockAt(i + 1, e);
|
|
24480
24480
|
if (!b) break;
|
|
24481
|
-
step.always = { line:
|
|
24481
|
+
step.always = { line: lineAt5(toks2[i].at), steps: stepsIn(b[0], b[1], ctx) };
|
|
24482
24482
|
i = nextTok(b[1] + 1, e);
|
|
24483
24483
|
continue;
|
|
24484
24484
|
}
|
|
@@ -24514,8 +24514,8 @@ function makeReader(src) {
|
|
|
24514
24514
|
msg = null;
|
|
24515
24515
|
name = varWords2(rest2[0].name);
|
|
24516
24516
|
} else if (!rest2.length) return [{ kind: "fail", says: "Fails again with the same error", error: "the same error", ...base2(s, e) }];
|
|
24517
|
-
if (msg) errors.set(msg, errors.get(msg) ??
|
|
24518
|
-
else if (name !== "an error") errors.set(name, errors.get(name) ??
|
|
24517
|
+
if (msg) errors.set(msg, errors.get(msg) ?? lineAt5(t.at));
|
|
24518
|
+
else if (name !== "an error") errors.set(name, errors.get(name) ?? lineAt5(t.at));
|
|
24519
24519
|
return [{ kind: "fail", says: `Fails with ${name}${msg ? `: "${msg}"` : ""}`, error: name, ...msg ? { message: msg } : {}, ...base2(s, e) }];
|
|
24520
24520
|
}
|
|
24521
24521
|
case "return": {
|
|
@@ -24575,7 +24575,7 @@ function makeReader(src) {
|
|
|
24575
24575
|
if (/^(describe|context|it)$/i.test(t.text) && toks2[nextTok(s + 1, e)]?.t === "str") {
|
|
24576
24576
|
const name = stringText(toks2[nextTok(s + 1, e)]);
|
|
24577
24577
|
const blk = toks2.slice(s, e).find((x) => x.text === "{" && x.match != null);
|
|
24578
|
-
if (/^it$/i.test(t.text)) tests.push({ name, line:
|
|
24578
|
+
if (/^it$/i.test(t.text)) tests.push({ name, line: lineAt5(t.at) });
|
|
24579
24579
|
else if (blk) stepsIn(blk.i + 1, blk.match, ctx);
|
|
24580
24580
|
return [];
|
|
24581
24581
|
}
|
|
@@ -24640,7 +24640,7 @@ function makeReader(src) {
|
|
|
24640
24640
|
const msg = a.named.message ? sayValue2(a.named.message) : a.pos[0] ? sayValue2(a.pos[0]) : null;
|
|
24641
24641
|
const text2 = msg ? msg.replace(/^"|"$/g, "") : null;
|
|
24642
24642
|
const stops = STOP_ON_ERROR || /stop/i.test(a.named.erroraction?.map((x) => x.text).join("") ?? "");
|
|
24643
|
-
if (text2) errors.set(text2, errors.get(text2) ??
|
|
24643
|
+
if (text2) errors.set(text2, errors.get(text2) ?? lineAt5(head0.at));
|
|
24644
24644
|
return [stops ? { kind: "fail", says: `Fails with an error${text2 ? `: "${text2}"` : ""}`, error: "an error", ...text2 ? { message: text2 } : {}, ...base2(s, e) } : { kind: "call", says: `Reports an error${text2 ? `: "${text2}"` : ""} and carries on`, ...base2(s, e) }];
|
|
24645
24645
|
}
|
|
24646
24646
|
const lg = groups(list3);
|
|
@@ -24728,7 +24728,7 @@ function makeReader(src) {
|
|
|
24728
24728
|
if (!steps.length) steps.push({ kind: "return", says: "Does nothing", ...base2(s, e, head(s, e)) });
|
|
24729
24729
|
lastValueToReturn(steps);
|
|
24730
24730
|
const first = nextTok(parts.from, blk[1]);
|
|
24731
|
-
fns.push({ name, line:
|
|
24731
|
+
fns.push({ name, line: lineAt5(nameTok.at), params, doc, steps, body: first < blk[1] ? [lineAt5(toks2[first].at), lineAt5(toks2[blk[1]].at)] : null, _range: [parts.from, blk[1]] });
|
|
24732
24732
|
}
|
|
24733
24733
|
function podeRoute(s, e) {
|
|
24734
24734
|
const a = argsOf(toks2.slice(s + 1, e));
|
|
@@ -24738,14 +24738,14 @@ function makeReader(src) {
|
|
|
24738
24738
|
const sb = a.named.scriptblock;
|
|
24739
24739
|
if (!sb || sb[0].text !== "{") return;
|
|
24740
24740
|
const open = sb[0].i;
|
|
24741
|
-
fns.push({ name: `${method} ${path}`, line:
|
|
24741
|
+
fns.push({ name: `${method} ${path}`, line: lineAt5(toks2[s].at), params: [], route: { method, path }, steps: stepsIn(open + 1, sb[0].match), body: [lineAt5(toks2[nextTok(open + 1, sb[0].match)]?.at ?? toks2[open].at), lineAt5(toks2[sb[0].match].at)] });
|
|
24742
24742
|
}
|
|
24743
24743
|
function defineType(s, e, kw) {
|
|
24744
24744
|
const nameTok = toks2[nextTok(s + 1, e)];
|
|
24745
24745
|
const blk = toks2.slice(s, e).find((x) => x.text === "{" && x.match != null);
|
|
24746
24746
|
if (!nameTok || !blk) return;
|
|
24747
24747
|
const open = blk.i, close = blk.match;
|
|
24748
|
-
const lines = [
|
|
24748
|
+
const lines = [lineAt5(toks2[s].at), lineAt5(toks2[close].at)];
|
|
24749
24749
|
const doc = docBefore(toks2, s);
|
|
24750
24750
|
if (kw === "enum") {
|
|
24751
24751
|
const choices = [];
|
|
@@ -24762,7 +24762,7 @@ function makeReader(src) {
|
|
|
24762
24762
|
const type = st.slice(0, v).reverse().find((x) => x.t === "type");
|
|
24763
24763
|
const eq2 = st.findIndex((x, i) => i > v && x.text === "=");
|
|
24764
24764
|
const def = eq2 > 0 ? st.slice(eq2 + 1) : null;
|
|
24765
|
-
thing.knows.push({ name: st[v].name, type: type?.name ?? null, start: def ? def.map((x) => x.text).join(" ") : null, line:
|
|
24765
|
+
thing.knows.push({ name: st[v].name, type: type?.name ?? null, start: def ? def.map((x) => x.text).join(" ") : null, line: lineAt5(st[v].at) });
|
|
24766
24766
|
continue;
|
|
24767
24767
|
}
|
|
24768
24768
|
const nameAt = st.findIndex((x, i) => x.t === "word" && st[i + 1]?.text === "(");
|
|
@@ -24778,7 +24778,7 @@ function makeReader(src) {
|
|
|
24778
24778
|
const first = nextTok(bOpen + 1, body2.match);
|
|
24779
24779
|
const ret = st.slice(0, nameAt).reverse().find((x) => x.t === "type");
|
|
24780
24780
|
if (mTok.text !== nameTok.text) thing.methods++;
|
|
24781
|
-
fns.push({ name: mTok.text, line:
|
|
24781
|
+
fns.push({ name: mTok.text, line: lineAt5(mTok.at), params, returns: ret && !/^void$/i.test(ret.name) ? ret.name : null, doc: docBefore(toks2, st[0].i), steps, body: first < body2.match ? [lineAt5(toks2[first].at), lineAt5(toks2[body2.match].at)] : null, _range: [bOpen + 1, body2.match] });
|
|
24782
24782
|
if (mTok.text === nameTok.text) {
|
|
24783
24783
|
for (const [x, y] of splitStatements(toks2, bOpen + 1, body2.match)) {
|
|
24784
24784
|
const st2 = at0(toks2.slice(x, y));
|
|
@@ -24789,7 +24789,7 @@ function makeReader(src) {
|
|
|
24789
24789
|
const start = param ? param.default ? { param: param.default } : { given: true } : val.map((q2) => q2.text).join(" ");
|
|
24790
24790
|
if (k2) {
|
|
24791
24791
|
if (k2.start == null || param) k2.start = start;
|
|
24792
|
-
} else thing.knows.push({ name: st2[2].text, type: null, start, line:
|
|
24792
|
+
} else thing.knows.push({ name: st2[2].text, type: null, start, line: lineAt5(st2[0].at) });
|
|
24793
24793
|
}
|
|
24794
24794
|
}
|
|
24795
24795
|
}
|
|
@@ -24797,7 +24797,7 @@ function makeReader(src) {
|
|
|
24797
24797
|
delete thing.methods;
|
|
24798
24798
|
things.push(thing);
|
|
24799
24799
|
}
|
|
24800
|
-
return { toks: toks2, fns, things, errors, tests, stepsIn, lineAt:
|
|
24800
|
+
return { toks: toks2, fns, things, errors, tests, stepsIn, lineAt: lineAt5, splitStatements: () => splitStatements(toks2, 0, toks2.length), statement: statement2, nextTok, code: code3, cleanSteps };
|
|
24801
24801
|
}
|
|
24802
24802
|
var fixedOf = (toks2) => {
|
|
24803
24803
|
const v = at0(toks2 || []);
|
|
@@ -25876,7 +25876,7 @@ var KNOWN_FNS3 = /* @__PURE__ */ new Set();
|
|
|
25876
25876
|
function makeReader2(src) {
|
|
25877
25877
|
SRC = src;
|
|
25878
25878
|
const toks2 = tokenize4(src);
|
|
25879
|
-
const
|
|
25879
|
+
const lineAt5 = lineFinder4(src);
|
|
25880
25880
|
const fns = [], things = [], errors = /* @__PURE__ */ new Map(), tests = [], defs = [];
|
|
25881
25881
|
const code3 = (s, e) => {
|
|
25882
25882
|
const t = src.slice(toks2[s].at, toks2[e - 1].end).replace(/\s+/g, " ").trim();
|
|
@@ -25886,8 +25886,8 @@ function makeReader2(src) {
|
|
|
25886
25886
|
const t = src.slice(toks2[s].at, toks2[e - 1].end).split("\n")[0].trim();
|
|
25887
25887
|
return t.length > 160 ? `${t.slice(0, 159)}\u2026` : t;
|
|
25888
25888
|
};
|
|
25889
|
-
const spanOf2 = (s, e) => ({ startLine:
|
|
25890
|
-
const base2 = (s, e, c = code3(s, e)) => ({ code: c, line:
|
|
25889
|
+
const spanOf2 = (s, e) => ({ startLine: lineAt5(toks2[s].at), endLine: lineAt5(toks2[e - 1].end - 1) });
|
|
25890
|
+
const base2 = (s, e, c = code3(s, e)) => ({ code: c, line: lineAt5(toks2[s].at), span: spanOf2(s, e) });
|
|
25891
25891
|
const next = (i, to) => {
|
|
25892
25892
|
while (i < to && (toks2[i].t === "nl" || toks2[i].t === "comment")) i++;
|
|
25893
25893
|
return i;
|
|
@@ -25939,7 +25939,7 @@ function makeReader2(src) {
|
|
|
25939
25939
|
thenTo = elseAt >= 0 ? elseAt : e;
|
|
25940
25940
|
}
|
|
25941
25941
|
const c = condSaid(condT);
|
|
25942
|
-
const step = { kind: "branch", says: `If ${c ?? `\`${code3(open + 1, close)}\``}`, cond: condJs2(condT), code: head(s, e), line:
|
|
25942
|
+
const step = { kind: "branch", says: `If ${c ?? `\`${code3(open + 1, close)}\``}`, cond: condJs2(condT), code: head(s, e), line: lineAt5(toks2[s].at), span: spanOf2(s, e) };
|
|
25943
25943
|
const kids2 = stepsOfBody(close + 1, thenTo, ctx);
|
|
25944
25944
|
if (kids2.length) step.children = kids2;
|
|
25945
25945
|
if (elseAt >= 0) {
|
|
@@ -25953,7 +25953,7 @@ function makeReader2(src) {
|
|
|
25953
25953
|
}
|
|
25954
25954
|
} else {
|
|
25955
25955
|
step.otherwise = stepsOfBody(elseAt + 1, e, ctx);
|
|
25956
|
-
step.otherwiseLine =
|
|
25956
|
+
step.otherwiseLine = lineAt5(toks2[elseAt].at);
|
|
25957
25957
|
}
|
|
25958
25958
|
}
|
|
25959
25959
|
return step;
|
|
@@ -26046,7 +26046,7 @@ function makeReader2(src) {
|
|
|
26046
26046
|
const fnSteps = stepsOfBody(fv.from, fv.to, { last: true, fn: true });
|
|
26047
26047
|
if (!fnSteps.length) fnSteps.push({ kind: "return", says: "Does nothing", ...base2(nameTok.i, fv.to, head(nameTok.i, fv.to)) });
|
|
26048
26048
|
const [a, b] = bodyRange2(fv.from, fv.to);
|
|
26049
|
-
const f = { name: route && !name ? `${route.method} ${route.path}` : name, line:
|
|
26049
|
+
const f = { name: route && !name ? `${route.method} ${route.path}` : name, line: lineAt5(nameTok.at), params, doc, steps: fnSteps, body: a < b && next(a, b) < b ? [lineAt5(toks2[next(a, b)].at), lineAt5(toks2[b - 1].end - 1)] : null, ...route ? { route } : {}, _fv: fv, ...owner ? { owner } : {} };
|
|
26050
26050
|
fns.push(f);
|
|
26051
26051
|
return f;
|
|
26052
26052
|
}
|
|
@@ -26202,11 +26202,11 @@ function makeReader2(src) {
|
|
|
26202
26202
|
const fv = fnValue(a.toks);
|
|
26203
26203
|
const r = at02(a.toks).length ? range(at02(a.toks)) : null;
|
|
26204
26204
|
if (a.name === "finally") {
|
|
26205
|
-
step.always = { line:
|
|
26205
|
+
step.always = { line: lineAt5(at02(a.toks)[0]?.at ?? toks2[s].at), steps: r ? stepsOfBody(r[0], r[1], { ...ctx, last: false }) : [] };
|
|
26206
26206
|
continue;
|
|
26207
26207
|
}
|
|
26208
26208
|
const says = a.name === "error" ? "If anything goes wrong" : a.name === "warning" ? "If there is a warning" : a.name === "message" ? "If a message is written" : a.name === "interrupt" ? "If it is stopped" : `If ${a.name} goes wrong`;
|
|
26209
|
-
(step.handlers ||= []).push({ says, line:
|
|
26209
|
+
(step.handlers ||= []).push({ says, line: lineAt5(at02(a.toks)[0]?.at ?? toks2[s].at), steps: fv ? stepsOfBody(fv.from, fv.to, { ...ctx, last: !!target || ctx.last, fn: true }) : [] });
|
|
26210
26210
|
}
|
|
26211
26211
|
if (target) {
|
|
26212
26212
|
for (const list3 of [step.children, ...(step.handlers || []).map((h) => h.steps)]) if (list3?.length) giveValue2({ kind: "branch", children: list3 }, target);
|
|
@@ -26227,7 +26227,7 @@ function makeReader2(src) {
|
|
|
26227
26227
|
pending = [];
|
|
26228
26228
|
const r = vtoks.length ? range(vtoks) : null;
|
|
26229
26229
|
const kids2 = r ? stepsOfBody(r[0], r[1], ctx) : [];
|
|
26230
|
-
arms.push({ kind: "check", says: names ? `When it is ${list2(names.map((n) => `"${n}"`)).replace(/,? and ([^,]*)$/, " or $1")}` : "Otherwise", caseLabel: true, code: names ? `${names.join(", ")} =` : "(default)", line:
|
|
26230
|
+
arms.push({ kind: "check", says: names ? `When it is ${list2(names.map((n) => `"${n}"`)).replace(/,? and ([^,]*)$/, " or $1")}` : "Otherwise", caseLabel: true, code: names ? `${names.join(", ")} =` : "(default)", line: lineAt5(vtoks[0]?.at ?? toks2[s].at), span: r ? spanOf2(r[0], r[1]) : spanOf2(s, e), ...kids2.length ? { children: kids2 } : {} });
|
|
26231
26231
|
}
|
|
26232
26232
|
return { kind: "branch", says: `Chooses by ${sayValue3(subject?.toks ?? []) ?? "value"}`, ...base2(s, e, head(s, e)), ...arms.length ? { children: arms } : {} };
|
|
26233
26233
|
}
|
|
@@ -26253,7 +26253,7 @@ function makeReader2(src) {
|
|
|
26253
26253
|
const isVar = parts.length === 1 && one.length === 1 && one[0].t === "id";
|
|
26254
26254
|
const single = !isVar && oneValue(parts) ? sayValue3(parts[0].toks) : null;
|
|
26255
26255
|
const msg = isVar || single || !parts.length ? null : textOf2(parts, "", bare2 === "cli_abort" || bare2 === "ui_abort");
|
|
26256
|
-
if (msg) errors.set(msg, errors.get(msg) ??
|
|
26256
|
+
if (msg) errors.set(msg, errors.get(msg) ?? lineAt5(toks2[s].at));
|
|
26257
26257
|
const cls = args.find((a) => a.name === "class");
|
|
26258
26258
|
const name = cls ? at02(cls.toks)[0]?.value ?? "an error" : "an error";
|
|
26259
26259
|
const says = isVar ? `Fails with the error in ${rWords(one[0].text)}` : single ? `Fails with the error ${/^the result of /.test(single) ? single.replace(/^the result of /, "made by ") : `in ${single}`}` : `Fails with ${name}${msg ? `: "${msg}"` : ""}`;
|
|
@@ -26281,7 +26281,7 @@ function makeReader2(src) {
|
|
|
26281
26281
|
if (bare2 === "try") {
|
|
26282
26282
|
const r = args[0] && at02(args[0].toks).length ? range(at02(args[0].toks)) : null;
|
|
26283
26283
|
const kids2 = r ? stepsOfBody(r[0], r[1], { ...ctx, last: false }) : [];
|
|
26284
|
-
return [{ kind: "try", says: "Tries these steps, and carries on if they fail", ...base2(s, e, head(s, e)), ...kids2.length ? { children: kids2 } : {}, handlers: [{ says: "If anything goes wrong", line:
|
|
26284
|
+
return [{ kind: "try", says: "Tries these steps, and carries on if they fail", ...base2(s, e, head(s, e)), ...kids2.length ? { children: kids2 } : {}, handlers: [{ says: "If anything goes wrong", line: lineAt5(toks2[s].at), steps: [] }] }];
|
|
26285
26285
|
}
|
|
26286
26286
|
if (bare2 === "on.exit") {
|
|
26287
26287
|
const r = args[0] && at02(args[0].toks).length ? range(at02(args[0].toks)) : null;
|
|
@@ -26295,7 +26295,7 @@ function makeReader2(src) {
|
|
|
26295
26295
|
}
|
|
26296
26296
|
if (bare2 === "test_that") {
|
|
26297
26297
|
const name = at02(args[0]?.toks ?? [])[0]?.value;
|
|
26298
|
-
if (name) tests.push({ name, line:
|
|
26298
|
+
if (name) tests.push({ name, line: lineAt5(toks2[s].at) });
|
|
26299
26299
|
return [];
|
|
26300
26300
|
}
|
|
26301
26301
|
if (bare2 === "return" || bare2 === "invisible") {
|
|
@@ -26332,7 +26332,7 @@ function makeReader2(src) {
|
|
|
26332
26332
|
return [val ? { kind: "call", says: `Works out ${val}`, ...base2(s, e) } : { kind: "other", says: code3(s, e), ...base2(s, e) }];
|
|
26333
26333
|
}
|
|
26334
26334
|
function defineThing(name, call2, s, e) {
|
|
26335
|
-
const lines = [
|
|
26335
|
+
const lines = [lineAt5(toks2[s].at), lineAt5(toks2[e - 1].end - 1)];
|
|
26336
26336
|
const className = at02(call2.args[0]?.toks ?? [])[0]?.value ?? at02(call2.args.find((a) => a.name === "Classname")?.toks ?? [])[0]?.value ?? name;
|
|
26337
26337
|
const { doc } = docAbove5(s);
|
|
26338
26338
|
const thing = { kind: "record", name: className || name, lines, ...doc ? { doc } : {}, knows: [], choices: [], memberRanges: [] };
|
|
@@ -26345,13 +26345,13 @@ function makeReader2(src) {
|
|
|
26345
26345
|
for (const a of args || []) {
|
|
26346
26346
|
if (!a.name) {
|
|
26347
26347
|
const sv = at02(a.toks)[0];
|
|
26348
|
-
if (sv?.t === "str") thing.knows.push({ name: sv.value, type: null, start: null, line:
|
|
26348
|
+
if (sv?.t === "str") thing.knows.push({ name: sv.value, type: null, start: null, line: lineAt5(sv.at) });
|
|
26349
26349
|
continue;
|
|
26350
26350
|
}
|
|
26351
26351
|
const vt = at02(a.toks);
|
|
26352
26352
|
if (fnValue(vt)) continue;
|
|
26353
26353
|
const tv = typed && vt.length === 1 && vt[0].t === "str" ? vt[0].value : null;
|
|
26354
|
-
thing.knows.push({ name: a.name, type: tv ? R_TYPE[tv] ?? tv : null, start: typed ? null : vt.map((x) => x.text).join(""), line:
|
|
26354
|
+
thing.knows.push({ name: a.name, type: tv ? R_TYPE[tv] ?? tv : null, start: typed ? null : vt.map((x) => x.text).join(""), line: lineAt5(vt[0]?.at ?? toks2[s].at) });
|
|
26355
26355
|
}
|
|
26356
26356
|
};
|
|
26357
26357
|
let methods = 0;
|
|
@@ -26360,7 +26360,7 @@ function makeReader2(src) {
|
|
|
26360
26360
|
const fv = a.name ? fnValue(a.toks) : null;
|
|
26361
26361
|
if (!fv) continue;
|
|
26362
26362
|
const f = defineFunction(a.name, fv, at02(a.toks)[0].i, toks2[at02(a.toks)[0].i - 2] ?? toks2[s]);
|
|
26363
|
-
f.line =
|
|
26363
|
+
f.line = lineAt5(toks2[at02(a.toks)[0].i - 2]?.at ?? toks2[s].at);
|
|
26364
26364
|
if (a.name !== "initialize") methods++;
|
|
26365
26365
|
if (a.name === "initialize") {
|
|
26366
26366
|
const byName = new Map(fv.params.map((p) => [p.name, p.default ? at02(p.default).map((x) => x.text).join("") : null]));
|
|
@@ -26374,7 +26374,7 @@ function makeReader2(src) {
|
|
|
26374
26374
|
const start = val.length === 1 && byName.has(val[0].text) ? { param: byName.get(val[0].text) } : val.map((q2) => q2.text).join("");
|
|
26375
26375
|
if (k) {
|
|
26376
26376
|
if (k.start == null || typeof start === "object") k.start = start;
|
|
26377
|
-
} else thing.knows.push({ name: field, type: null, start, line:
|
|
26377
|
+
} else thing.knows.push({ name: field, type: null, start, line: lineAt5(st[0].at) });
|
|
26378
26378
|
}
|
|
26379
26379
|
}
|
|
26380
26380
|
}
|
|
@@ -26399,7 +26399,7 @@ function makeReader2(src) {
|
|
|
26399
26399
|
thing._methods = methods;
|
|
26400
26400
|
things.push(thing);
|
|
26401
26401
|
}
|
|
26402
|
-
return { toks: toks2, fns, things, errors, tests, stepsIn, lineAt:
|
|
26402
|
+
return { toks: toks2, fns, things, errors, tests, stepsIn, lineAt: lineAt5, next, statement: statement2, code: code3, base: base2 };
|
|
26403
26403
|
}
|
|
26404
26404
|
function decisionOf2(r, fv) {
|
|
26405
26405
|
const { toks: toks2 } = r;
|
|
@@ -28292,7 +28292,7 @@ function swiftImplicitResult(text2, returns) {
|
|
|
28292
28292
|
var rebind = (guard, name, subject) => guard.replace(new RegExp(`\\b${name}\\b`, "g"), subject);
|
|
28293
28293
|
function switchArms(body2, language, baseLine) {
|
|
28294
28294
|
const arms = [];
|
|
28295
|
-
const
|
|
28295
|
+
const lineOf7 = (idx) => baseLine + lineAt(body2, idx) - 1;
|
|
28296
28296
|
if (language === "rust" || language === "csharp-expr") {
|
|
28297
28297
|
let i = 0;
|
|
28298
28298
|
while (i < body2.length) {
|
|
@@ -28315,7 +28315,7 @@ function switchArms(body2, language, baseLine) {
|
|
|
28315
28315
|
value = body2.slice(j, end2).trim();
|
|
28316
28316
|
}
|
|
28317
28317
|
const g = head.match(/^(.*?)\s+(?:if|when)\s+(.+)$/s);
|
|
28318
|
-
arms.push({ pattern: (g ? g[1] : head).trim(), guard: g ? g[2].trim() : null, value, line:
|
|
28318
|
+
arms.push({ pattern: (g ? g[1] : head).trim(), guard: g ? g[2].trim() : null, value, line: lineOf7(i) });
|
|
28319
28319
|
i = end2 + 1;
|
|
28320
28320
|
}
|
|
28321
28321
|
return arms;
|
|
@@ -28354,8 +28354,8 @@ function switchArms(body2, language, baseLine) {
|
|
|
28354
28354
|
}
|
|
28355
28355
|
const patterns = [...pending, pattern2];
|
|
28356
28356
|
pending = [];
|
|
28357
|
-
if (patterns.includes(null)) arms.push({ pattern: null, guard: null, value, line:
|
|
28358
|
-
else arms.push({ pattern: patterns.join(language === "go" && patterns.length === 1 ? "" : ", ") || patterns[0], guard: g ? g[2].trim() : null, value, line:
|
|
28357
|
+
if (patterns.includes(null)) arms.push({ pattern: null, guard: null, value, line: lineOf7(starts[k]) });
|
|
28358
|
+
else arms.push({ pattern: patterns.join(language === "go" && patterns.length === 1 ? "" : ", ") || patterns[0], guard: g ? g[2].trim() : null, value, line: lineOf7(starts[k]) });
|
|
28359
28359
|
}
|
|
28360
28360
|
return arms;
|
|
28361
28361
|
}
|
|
@@ -28648,12 +28648,12 @@ function readBraceStatements(stmts, language, inputs) {
|
|
|
28648
28648
|
}
|
|
28649
28649
|
let rest2 = t;
|
|
28650
28650
|
let ok = true;
|
|
28651
|
-
const
|
|
28651
|
+
const lineOf7 = (part) => {
|
|
28652
28652
|
const at2 = t.lastIndexOf(part);
|
|
28653
28653
|
return st.line + (at2 > 0 ? (t.slice(0, at2).match(/\n/g) || []).length : 0);
|
|
28654
28654
|
};
|
|
28655
28655
|
while (rest2) {
|
|
28656
|
-
const here =
|
|
28656
|
+
const here = lineOf7(rest2);
|
|
28657
28657
|
const head2 = rest2.match(/^(?:else\s+)?if\b\s*/);
|
|
28658
28658
|
if (!head2) break;
|
|
28659
28659
|
rest2 = rest2.slice(head2[0].length);
|
|
@@ -28706,9 +28706,9 @@ function readBraceStatements(stmts, language, inputs) {
|
|
|
28706
28706
|
const elseBody = remaining.replace(/^else\s*/, "");
|
|
28707
28707
|
const v = elseBody.startsWith("{") ? blockValue(elseBody) : elseBody.startsWith("return ") ? elseBody.slice(7).replace(/;$/, "") : null;
|
|
28708
28708
|
if (v == null) {
|
|
28709
|
-
unread.push({ line:
|
|
28709
|
+
unread.push({ line: lineOf7(remaining), text: "else", reason: "The fallback branch does more than choose an answer." });
|
|
28710
28710
|
ok = false;
|
|
28711
|
-
} else take(null, v,
|
|
28711
|
+
} else take(null, v, lineOf7(remaining));
|
|
28712
28712
|
}
|
|
28713
28713
|
rest2 = "";
|
|
28714
28714
|
}
|
|
@@ -30253,7 +30253,7 @@ function writeRule({ source, language, file = "", decision: name, line = null, r
|
|
|
30253
30253
|
});
|
|
30254
30254
|
if (problems.length) return fail4(...problems);
|
|
30255
30255
|
const starts = lineStartsOf(source);
|
|
30256
|
-
const
|
|
30256
|
+
const lineOf7 = (off) => {
|
|
30257
30257
|
let lo = 0, hi = starts.length - 1;
|
|
30258
30258
|
while (lo < hi) {
|
|
30259
30259
|
const m = lo + hi + 1 >> 1;
|
|
@@ -30262,7 +30262,7 @@ function writeRule({ source, language, file = "", decision: name, line = null, r
|
|
|
30262
30262
|
}
|
|
30263
30263
|
return lo + 1;
|
|
30264
30264
|
};
|
|
30265
|
-
const change = real.slice().reverse().map((e) => ({ line:
|
|
30265
|
+
const change = real.slice().reverse().map((e) => ({ line: lineOf7(e.start), column: e.start - starts[lineOf7(e.start) - 1] + 1, before: e.was, after: e.text }));
|
|
30266
30266
|
const label = (r) => r === "otherwise" ? "Otherwise" : `If ${sayCondition(r.when)}`;
|
|
30267
30267
|
const beforeRule = index === "otherwise" ? `Otherwise, the answer is ${target.result}` : `${label(target)}, the answer is ${target.result}`;
|
|
30268
30268
|
const afterRule = index === "otherwise" ? `Otherwise, the answer is ${wantResult}` : `If ${sayCondition(newWhen)}, the answer is ${wantResult}`;
|
|
@@ -30768,12 +30768,12 @@ function plainFromReading(item4) {
|
|
|
30768
30768
|
const whens = (item4.rules ?? []).map((r) => r.when ?? "").join(" and ");
|
|
30769
30769
|
const typed = (item4.inputs ?? []).map((i) => {
|
|
30770
30770
|
if (i.type) return i;
|
|
30771
|
-
const
|
|
30772
|
-
if (new RegExp(`\\b${
|
|
30771
|
+
const esc3 = i.name.replace(/[$]/g, "\\$");
|
|
30772
|
+
if (new RegExp(`\\b${esc3}\\s*(>=|<=|<|>|==)\\s*-?\\d`).test(whens)) {
|
|
30773
30773
|
inferred.push(i.name);
|
|
30774
30774
|
return { ...i, type: "number" };
|
|
30775
30775
|
}
|
|
30776
|
-
if (new RegExp(`(^|\\s|not\\s+|!)${
|
|
30776
|
+
if (new RegExp(`(^|\\s|not\\s+|!)${esc3}(\\s|$)`).test(whens)) {
|
|
30777
30777
|
inferred.push(i.name);
|
|
30778
30778
|
return { ...i, type: "boolean" };
|
|
30779
30779
|
}
|
|
@@ -31471,11 +31471,11 @@ function jsxChildren(src, j, tag) {
|
|
|
31471
31471
|
}
|
|
31472
31472
|
var VOID = /* @__PURE__ */ new Set(["area", "base", "br", "col", "embed", "hr", "img", "input", "link", "meta", "source", "track", "wbr"]);
|
|
31473
31473
|
function parseTemplate(html, fileSrc = null, offset = 0) {
|
|
31474
|
-
const
|
|
31474
|
+
const lineOf7 = (i2) => fileSrc ? lineAt2(fileSrc, offset + i2) : lineAt2(html, i2);
|
|
31475
31475
|
let i = 0;
|
|
31476
31476
|
const parseNodes = (stopTag, stopBrace) => {
|
|
31477
31477
|
const out = [];
|
|
31478
|
-
let text2 = "", tl =
|
|
31478
|
+
let text2 = "", tl = lineOf7(i);
|
|
31479
31479
|
const flush = () => {
|
|
31480
31480
|
if (text2.trim()) out.push(textNode(text2, tl));
|
|
31481
31481
|
text2 = "";
|
|
@@ -31502,17 +31502,17 @@ function parseTemplate(html, fileSrc = null, offset = 0) {
|
|
|
31502
31502
|
flush();
|
|
31503
31503
|
const b = parseBlock();
|
|
31504
31504
|
if (b) out.push(b);
|
|
31505
|
-
tl =
|
|
31505
|
+
tl = lineOf7(i);
|
|
31506
31506
|
continue;
|
|
31507
31507
|
}
|
|
31508
31508
|
if (html[i] === "<" && /[A-Za-z]/.test(html[i + 1] ?? "")) {
|
|
31509
31509
|
flush();
|
|
31510
31510
|
const el = parseElement();
|
|
31511
31511
|
if (el) out.push(el);
|
|
31512
|
-
tl =
|
|
31512
|
+
tl = lineOf7(i);
|
|
31513
31513
|
continue;
|
|
31514
31514
|
}
|
|
31515
|
-
if (!text2) tl =
|
|
31515
|
+
if (!text2) tl = lineOf7(i);
|
|
31516
31516
|
text2 += html[i];
|
|
31517
31517
|
i++;
|
|
31518
31518
|
}
|
|
@@ -31531,7 +31531,7 @@ function parseTemplate(html, fileSrc = null, offset = 0) {
|
|
|
31531
31531
|
return { type: "text", parts, line };
|
|
31532
31532
|
};
|
|
31533
31533
|
const parseElement = () => {
|
|
31534
|
-
const line =
|
|
31534
|
+
const line = lineOf7(i);
|
|
31535
31535
|
const tm = /^<([A-Za-z][\w:-]*)/.exec(html.slice(i));
|
|
31536
31536
|
const tag = tm[1];
|
|
31537
31537
|
i += tm[0].length;
|
|
@@ -31577,7 +31577,7 @@ function parseTemplate(html, fileSrc = null, offset = 0) {
|
|
|
31577
31577
|
return { type: "el", tag, attrs, kids: kids2, line };
|
|
31578
31578
|
};
|
|
31579
31579
|
const parseBlock = () => {
|
|
31580
|
-
const line =
|
|
31580
|
+
const line = lineOf7(i);
|
|
31581
31581
|
const m = /^@(\w+)\s*(?:\(([^)]*(?:\([^)]*\)[^)]*)*)\))?\s*\{/.exec(html.slice(i));
|
|
31582
31582
|
if (!m) {
|
|
31583
31583
|
const e = html.indexOf("\n", i);
|
|
@@ -32555,7 +32555,7 @@ function makeThingReaders({ words: words15, kindWords: kindWords3, startValue: s
|
|
|
32555
32555
|
return { name, label: words15(name.replace(/^[_$]+|_$/g, "")), kind, start: said, line };
|
|
32556
32556
|
};
|
|
32557
32557
|
function curlyThings(src, file, language) {
|
|
32558
|
-
const
|
|
32558
|
+
const lineAt5 = lineFinder5(src);
|
|
32559
32559
|
const out = [];
|
|
32560
32560
|
const kw = {
|
|
32561
32561
|
java: /(?:^|\n)[ \t]*(?:@\w+(?:\([^)]*\))?\s*)*(?:(?:public|private|protected|static|final|abstract|sealed|non-sealed)\s+)*(class|enum|record)\s+(\w+)\s*(?:<[^>{]*>)?\s*(\([^)]*\))?[^{;]*\{/g,
|
|
@@ -32582,7 +32582,7 @@ function makeThingReaders({ words: words15, kindWords: kindWords3, startValue: s
|
|
|
32582
32582
|
kind: isEnum ? "choices" : isRecord ? "record" : "thing",
|
|
32583
32583
|
name,
|
|
32584
32584
|
file,
|
|
32585
|
-
lines: [
|
|
32585
|
+
lines: [lineAt5(declAt), lineAt5(close >= 0 ? close : m.index + head.length)],
|
|
32586
32586
|
...docAbove4(src, declAt) ? { doc: docAbove4(src, declAt) } : {},
|
|
32587
32587
|
knows: [],
|
|
32588
32588
|
choices: []
|
|
@@ -32650,7 +32650,7 @@ function makeThingReaders({ words: words15, kindWords: kindWords3, startValue: s
|
|
|
32650
32650
|
return out;
|
|
32651
32651
|
}
|
|
32652
32652
|
function goThings(src, file) {
|
|
32653
|
-
const
|
|
32653
|
+
const lineAt5 = lineFinder5(src);
|
|
32654
32654
|
const out = [];
|
|
32655
32655
|
const byName = /* @__PURE__ */ new Map();
|
|
32656
32656
|
for (const m of src.matchAll(/(?:^|\n)type\s+(\w+)\s+struct\s*\{/g)) {
|
|
@@ -32658,7 +32658,7 @@ function makeThingReaders({ words: words15, kindWords: kindWords3, startValue: s
|
|
|
32658
32658
|
const open = m.index + m[0].length - 1;
|
|
32659
32659
|
const close = braceEnd(src, open);
|
|
32660
32660
|
if (close < 0) continue;
|
|
32661
|
-
const t = { kind: "record", name: m[1], file, lines: [
|
|
32661
|
+
const t = { kind: "record", name: m[1], file, lines: [lineAt5(at2), lineAt5(close)], ...goDoc(src, at2, m[1]) ? { doc: goDoc(src, at2, m[1]) } : {}, knows: [], choices: [], memberRanges: [] };
|
|
32662
32662
|
for (const raw of src.slice(open + 1, close).split("\n")) {
|
|
32663
32663
|
const f = raw.replace(/\/\/.*$/, "").replace(/`[^`]*`/g, "").trim().match(/^([A-Za-z_]\w*(?:\s*,\s*[A-Za-z_]\w*)*)\s+(\S.*)$/);
|
|
32664
32664
|
if (f) for (const n of f[1].split(",")) t.knows.push(know(n.trim(), f[2].trim(), null, {}));
|
|
@@ -32673,7 +32673,7 @@ function makeThingReaders({ words: words15, kindWords: kindWords3, startValue: s
|
|
|
32673
32673
|
const open = src.indexOf("{", at2);
|
|
32674
32674
|
const close = open >= 0 ? braceEnd(src, open) : -1;
|
|
32675
32675
|
t.kind = "thing";
|
|
32676
|
-
t.memberRanges.push([
|
|
32676
|
+
t.memberRanges.push([lineAt5(at2), lineAt5(close >= 0 ? close : at2)]);
|
|
32677
32677
|
}
|
|
32678
32678
|
for (const m of src.matchAll(/func\s+New(\w+)\s*\(([^)]*)\)[^{]*\{/g)) {
|
|
32679
32679
|
const t = byName.get(m[1]);
|
|
@@ -32707,19 +32707,19 @@ function makeThingReaders({ words: words15, kindWords: kindWords3, startValue: s
|
|
|
32707
32707
|
const label = f[3] && /^"/.test(f[3].trim()) ? f[3].trim().slice(1, -1) : words15(f[1].replace(new RegExp(`^${name}`), "") || f[1]);
|
|
32708
32708
|
choices.push(label);
|
|
32709
32709
|
}
|
|
32710
|
-
if (choices.length) out.push({ kind: "choices", name, file, lines: [
|
|
32710
|
+
if (choices.length) out.push({ kind: "choices", name, file, lines: [lineAt5(at2), lineAt5(at2)], ...goDoc(src, at2, name) ? { doc: goDoc(src, at2, name) } : {}, knows: [], choices });
|
|
32711
32711
|
}
|
|
32712
32712
|
return out;
|
|
32713
32713
|
}
|
|
32714
32714
|
function rustThings(src, file) {
|
|
32715
|
-
const
|
|
32715
|
+
const lineAt5 = lineFinder5(src);
|
|
32716
32716
|
const out = [];
|
|
32717
32717
|
const byName = /* @__PURE__ */ new Map();
|
|
32718
32718
|
for (const m of src.matchAll(/(?:^|\n)[ \t]*(?:#\[[^\]]*\]\s*)*(?:pub(?:\([^)]*\))?\s+)?(struct|enum)\s+(\w+)\s*(?:<[^>{]*>)?\s*(?:where[^{]*)?(\{|\(|;)/g)) {
|
|
32719
32719
|
const at2 = m.index + (m[0].startsWith("\n") ? 1 : 0);
|
|
32720
32720
|
const doc = docAbove4(src, at2);
|
|
32721
32721
|
if (m[3] !== "{") {
|
|
32722
|
-
const t2 = { kind: "record", name: m[2], file, lines: [
|
|
32722
|
+
const t2 = { kind: "record", name: m[2], file, lines: [lineAt5(at2), lineAt5(at2)], ...doc ? { doc } : {}, knows: [], choices: [], memberRanges: [] };
|
|
32723
32723
|
out.push(t2);
|
|
32724
32724
|
byName.set(m[2], t2);
|
|
32725
32725
|
continue;
|
|
@@ -32728,7 +32728,7 @@ function makeThingReaders({ words: words15, kindWords: kindWords3, startValue: s
|
|
|
32728
32728
|
const close = braceEnd(src, open);
|
|
32729
32729
|
if (close < 0) continue;
|
|
32730
32730
|
const body2 = ownLevel(src.slice(open + 1, close));
|
|
32731
|
-
const t = { kind: m[1] === "enum" ? "choices" : "record", name: m[2], file, lines: [
|
|
32731
|
+
const t = { kind: m[1] === "enum" ? "choices" : "record", name: m[2], file, lines: [lineAt5(at2), lineAt5(close)], ...doc ? { doc } : {}, knows: [], choices: [], memberRanges: [] };
|
|
32732
32732
|
if (m[1] === "enum") {
|
|
32733
32733
|
for (const v of splitParams2(body2.replace(/\/\/[^\n]*/g, "").replace(/#\[[^\]]*\]/g, ""))) {
|
|
32734
32734
|
const n = v.trim().match(/^(\w+)/);
|
|
@@ -32752,7 +32752,7 @@ function makeThingReaders({ words: words15, kindWords: kindWords3, startValue: s
|
|
|
32752
32752
|
if (/\bfn\s+\w+\s*(?:<[^>]*>)?\s*\(\s*&?(?:mut\s+)?self\b/.test(src.slice(at2, close))) {
|
|
32753
32753
|
if (t.kind === "record") t.kind = "thing";
|
|
32754
32754
|
}
|
|
32755
|
-
t.memberRanges.push([
|
|
32755
|
+
t.memberRanges.push([lineAt5(at2), lineAt5(close)]);
|
|
32756
32756
|
const block = src.slice(at2, close);
|
|
32757
32757
|
const fnNew = block.match(/fn\s+new\s*\(([^)]*)\)[^{;]*\{/);
|
|
32758
32758
|
const fnOpen = fnNew ? fnNew.index + fnNew[0].length - 1 : -1;
|
|
@@ -32904,7 +32904,7 @@ function makeThingReaders({ words: words15, kindWords: kindWords3, startValue: s
|
|
|
32904
32904
|
}
|
|
32905
32905
|
function cThings(src, file) {
|
|
32906
32906
|
const code3 = src.replace(/^[ \t]*#.*(?:\\\r?\n.*)*$/gm, (m) => m.replace(/[^\n]/g, " "));
|
|
32907
|
-
const
|
|
32907
|
+
const lineAt5 = lineFinder5(code3);
|
|
32908
32908
|
const out = [];
|
|
32909
32909
|
for (const m of code3.matchAll(/(?:^|\n)[ \t]*(typedef\s+)?(struct|union|enum)\b\s*(\w+)?\s*\{/g)) {
|
|
32910
32910
|
const at2 = m.index + (m[0].startsWith("\n") ? 1 : 0);
|
|
@@ -32915,7 +32915,7 @@ function makeThingReaders({ words: words15, kindWords: kindWords3, startValue: s
|
|
|
32915
32915
|
const name = alias || m[3];
|
|
32916
32916
|
if (!name) continue;
|
|
32917
32917
|
const doc = cDocAbove(code3, at2);
|
|
32918
|
-
const t = { kind: m[2] === "enum" ? "choices" : "record", name, ...m[3] && m[3] !== name ? { tag: m[3] } : {}, file, lines: [
|
|
32918
|
+
const t = { kind: m[2] === "enum" ? "choices" : "record", name, ...m[3] && m[3] !== name ? { tag: m[3] } : {}, file, lines: [lineAt5(at2), lineAt5(close)], ...doc ? { doc } : {}, knows: [], choices: [] };
|
|
32919
32919
|
const body2 = code3.slice(open + 1, close);
|
|
32920
32920
|
if (m[2] === "enum") {
|
|
32921
32921
|
t.choices = enumNames(splitParams2(body2.replace(/\/\*[\s\S]*?\*\//g, "").replace(/\/\/[^\n]*/g, "")).map((x) => (x.trim().match(/^(\w+)/) || [])[1]).filter(Boolean)).map((n) => words15(n));
|
|
@@ -32965,7 +32965,7 @@ function makeThingReaders({ words: words15, kindWords: kindWords3, startValue: s
|
|
|
32965
32965
|
}
|
|
32966
32966
|
function cppThings(src, file) {
|
|
32967
32967
|
const code3 = src.replace(/^[ \t]*#.*(?:\\\r?\n.*)*$/gm, (m) => m.replace(/[^\n]/g, " "));
|
|
32968
|
-
const
|
|
32968
|
+
const lineAt5 = lineFinder5(code3);
|
|
32969
32969
|
const out = [];
|
|
32970
32970
|
const byName = /* @__PURE__ */ new Map();
|
|
32971
32971
|
for (const m of code3.matchAll(/(?:^|\n)[ \t]*(?:template\s*<[^>{;]*>\s*)?(?:(class|struct|union)\s+(?:alignas\([^)]*\)\s*)?(?:[A-Z_][A-Z0-9_]*\s+)*(\w+)(?:\s+final)?\s*(?::[^{;]*)?|enum(?:\s+(?:class|struct))?\s+(\w+)(?:\s*:\s*[\w:]+)?\s*)\{/g)) {
|
|
@@ -32978,10 +32978,10 @@ function makeThingReaders({ words: words15, kindWords: kindWords3, startValue: s
|
|
|
32978
32978
|
const body2 = code3.slice(open + 1, close);
|
|
32979
32979
|
if (m[3]) {
|
|
32980
32980
|
const vals = splitParams2(body2.replace(/\/\*[\s\S]*?\*\//g, "").replace(/\/\/[^\n]*/g, "")).map((x) => (x.trim().match(/^(\w+)/) || [])[1]).filter(Boolean);
|
|
32981
|
-
out.push({ kind: "choices", name, file, lines: [
|
|
32981
|
+
out.push({ kind: "choices", name, file, lines: [lineAt5(at2), lineAt5(close)], ...doc ? { doc } : {}, knows: [], choices: enumNames(vals).map((n) => words15(n)) });
|
|
32982
32982
|
continue;
|
|
32983
32983
|
}
|
|
32984
|
-
const t = { kind: "record", name, file, lines: [
|
|
32984
|
+
const t = { kind: "record", name, file, lines: [lineAt5(at2), lineAt5(close)], ...doc ? { doc } : {}, knows: [], choices: [], memberRanges: [] };
|
|
32985
32985
|
let methods = false;
|
|
32986
32986
|
const inits = {}, params = {};
|
|
32987
32987
|
for (const mem of members(body2)) {
|
|
@@ -33020,7 +33020,7 @@ function makeThingReaders({ words: words15, kindWords: kindWords3, startValue: s
|
|
|
33020
33020
|
if (brace < 0 || semi >= 0 && semi < brace || /[()]/.test(code3.slice(pClose + 1, brace).replace(/:\s*[\s\S]*$/, ""))) continue;
|
|
33021
33021
|
methods = true;
|
|
33022
33022
|
const bClose = braceEnd(code3, brace);
|
|
33023
|
-
t.memberRanges.push([
|
|
33023
|
+
t.memberRanges.push([lineAt5(d.index), lineAt5(bClose >= 0 ? bClose : brace)]);
|
|
33024
33024
|
if (d[1] === name) cppCtor(code3.slice(pOpen + 1, pClose), (code3.slice(pClose + 1, brace).match(/^\s*(?:noexcept\s*)?:\s*([\s\S]+)$/) || [])[1], bClose > 0 ? code3.slice(brace + 1, bClose) : "", params, inits);
|
|
33025
33025
|
}
|
|
33026
33026
|
for (const k of t.knows) {
|
|
@@ -33051,7 +33051,7 @@ function makeThingReaders({ words: words15, kindWords: kindWords3, startValue: s
|
|
|
33051
33051
|
for (const a of String(bodyText || "").matchAll(/(?:this->)?(\w+)\s*=\s*([^;\n]+);/g)) if (inits[a[1]] == null) inits[a[1]] = a[2];
|
|
33052
33052
|
}
|
|
33053
33053
|
function swiftThings(src, file) {
|
|
33054
|
-
const
|
|
33054
|
+
const lineAt5 = lineFinder5(src);
|
|
33055
33055
|
const out = [];
|
|
33056
33056
|
const byName = /* @__PURE__ */ new Map();
|
|
33057
33057
|
for (const m of src.matchAll(/(?:^|\n)[ \t]*(?:@\w+(?:\([^)\n]*\))?\s+)*(?:(?:public|private|internal|fileprivate|open|final|indirect|nonisolated)\s+)*(class|struct|enum|actor|protocol)\s+(\w+)(?:<[^>{\n]*>)?[ \t]*(?::[ \t]*([^{\n]+?))?[ \t]*\{/g)) {
|
|
@@ -33062,7 +33062,7 @@ function makeThingReaders({ words: words15, kindWords: kindWords3, startValue: s
|
|
|
33062
33062
|
if (close < 0) continue;
|
|
33063
33063
|
const doc = docAbove4(src, at2);
|
|
33064
33064
|
const body2 = src.slice(open + 1, close);
|
|
33065
|
-
const t = { kind: m[1] === "enum" ? "choices" : "record", name: m[2], file, lines: [
|
|
33065
|
+
const t = { kind: m[1] === "enum" ? "choices" : "record", name: m[2], file, lines: [lineAt5(at2), lineAt5(close)], ...doc ? { doc } : {}, knows: [], choices: [], memberRanges: [] };
|
|
33066
33066
|
const mems = members(body2, { newlines: true });
|
|
33067
33067
|
if (m[1] === "enum") {
|
|
33068
33068
|
for (const { head } of mems) {
|
|
@@ -33111,7 +33111,7 @@ function makeThingReaders({ words: words15, kindWords: kindWords3, startValue: s
|
|
|
33111
33111
|
const at2 = m.index + (m[0].startsWith("\n") ? 1 : 0);
|
|
33112
33112
|
const close = braceEnd(src, m.index + m[0].length - 1);
|
|
33113
33113
|
if (close < 0) continue;
|
|
33114
|
-
t.memberRanges.push([
|
|
33114
|
+
t.memberRanges.push([lineAt5(at2), lineAt5(close)]);
|
|
33115
33115
|
if (t.kind === "record" && /(?:^|\s)func\s/.test(src.slice(at2, close))) t.kind = "thing";
|
|
33116
33116
|
}
|
|
33117
33117
|
return out;
|
|
@@ -36397,13 +36397,13 @@ var Analyzer = class {
|
|
|
36397
36397
|
const sawRecord = data.some((a) => a.recs?.length || a.recFields?.length);
|
|
36398
36398
|
const sawCaller = data.some((a) => a.ident?.length);
|
|
36399
36399
|
const sawInput = data.some((a) => a.input?.length || a.unknown?.length);
|
|
36400
|
-
const
|
|
36401
|
-
if ((sawRecord || sawCaller) && (GUARDISH.test(
|
|
36400
|
+
const baseName2 = String(name).split(".").pop();
|
|
36401
|
+
if ((sawRecord || sawCaller) && (GUARDISH.test(baseName2) || sawRecord && sawCaller)) st.unresolved = uniq(st.unresolved, [{ ...ev, says: `${name}(\u2026) might check who may see it` }]);
|
|
36402
36402
|
const out = joinAll(data.map(dataOf));
|
|
36403
|
-
if (sawCaller && !GUARDISH.test(
|
|
36403
|
+
if (sawCaller && !GUARDISH.test(baseName2)) out.clientFor = { says: `${name}(\u2026)`, file: ctx.file, line };
|
|
36404
36404
|
const parts = String(name).split(".");
|
|
36405
36405
|
const ownerName = parts.length > 1 ? parts[parts.length - 2] : "";
|
|
36406
|
-
const dataLike = name !== "fetch" && !NOT_DATA_PACKAGE.test(calleeVal?.pkg ?? "") && !["path", "fs", "os", "url", "crypto", "util", "process", "console", "JSON", "Math", "Date", BUF].includes(parts[0]) && (LOOKUP_NAME.test(
|
|
36406
|
+
const dataLike = name !== "fetch" && !NOT_DATA_PACKAGE.test(calleeVal?.pkg ?? "") && !["path", "fs", "os", "url", "crypto", "util", "process", "console", "JSON", "Math", "Date", BUF].includes(parts[0]) && (LOOKUP_NAME.test(baseName2) || parts.length > 1 && LOOKUP_OWNER.test(ownerName) && !/^(set|add|log|emit|send|push|on|use)$/.test(baseName2));
|
|
36407
36407
|
if ((sawInput || calleeVal?.recs?.length) && dataLike) out.unknown = uniq(out.unknown, [{ ...ev, says: `${name}(\u2026)` }]);
|
|
36408
36408
|
if (calleeVal && hasData(calleeVal)) return join2(out, dataOf(calleeVal));
|
|
36409
36409
|
return out;
|
|
@@ -40038,9 +40038,181 @@ function planOnly(original, list3) {
|
|
|
40038
40038
|
return plans;
|
|
40039
40039
|
}
|
|
40040
40040
|
|
|
40041
|
+
// src/trace-data.mjs
|
|
40042
|
+
var lineAt4 = (text2, index) => {
|
|
40043
|
+
let n = 1;
|
|
40044
|
+
for (let i = 0; i < index && i < text2.length; i++) if (text2.charCodeAt(i) === 10) n++;
|
|
40045
|
+
return n;
|
|
40046
|
+
};
|
|
40047
|
+
var lineOf6 = (text2, re) => {
|
|
40048
|
+
const lines = text2.split("\n");
|
|
40049
|
+
for (let i = 0; i < lines.length; i++) if (re.test(lines[i])) return i + 1;
|
|
40050
|
+
return null;
|
|
40051
|
+
};
|
|
40052
|
+
var esc = (s) => s.replace(/[.*+?^${}()|[\]\\/]/g, "\\$&");
|
|
40053
|
+
var baseName = (path) => path.split("/").pop();
|
|
40054
|
+
var dirOf4 = (path) => path.includes("/") ? path.slice(0, path.lastIndexOf("/")) : "";
|
|
40055
|
+
function isManifest(path) {
|
|
40056
|
+
const n = baseName(path);
|
|
40057
|
+
return n === "package.json" || n === "go.mod" || n === "requirements.txt" || /\.csproj$/i.test(n);
|
|
40058
|
+
}
|
|
40059
|
+
function packagesIn(files) {
|
|
40060
|
+
const publishes = [], depends = [];
|
|
40061
|
+
for (const f of files) {
|
|
40062
|
+
if (!isManifest(f.path)) continue;
|
|
40063
|
+
const text2 = String(f.source ?? "");
|
|
40064
|
+
const n = baseName(f.path);
|
|
40065
|
+
try {
|
|
40066
|
+
if (n === "package.json") {
|
|
40067
|
+
const j = JSON.parse(text2);
|
|
40068
|
+
if (typeof j.name === "string" && j.name.trim()) publishes.push({ package: j.name, ...j.version ? { version: String(j.version) } : {}, file: f.path, line: lineOf6(text2, /^\s*"name"\s*:/), root: dirOf4(f.path) });
|
|
40069
|
+
for (const k of ["dependencies", "devDependencies", "peerDependencies", "optionalDependencies"]) {
|
|
40070
|
+
for (const [name, version] of Object.entries(j[k] ?? {})) {
|
|
40071
|
+
depends.push({ package: name, version: String(version), ...k === "devDependencies" ? { dev: true } : {}, ...k === "peerDependencies" ? { peer: true } : {}, file: f.path, line: lineOf6(text2, new RegExp(`^\\s*"${esc(name)}"\\s*:`)) });
|
|
40072
|
+
}
|
|
40073
|
+
}
|
|
40074
|
+
} else if (n === "go.mod") {
|
|
40075
|
+
const lines = text2.split("\n");
|
|
40076
|
+
let inRequire = false;
|
|
40077
|
+
lines.forEach((raw, i) => {
|
|
40078
|
+
const line = raw.replace(/\/\/.*$/, "").trim();
|
|
40079
|
+
let m;
|
|
40080
|
+
if (m = line.match(/^module\s+(\S+)/)) publishes.push({ package: m[1], file: f.path, line: i + 1, root: dirOf4(f.path) });
|
|
40081
|
+
else if (/^require\s*\($/.test(line)) inRequire = true;
|
|
40082
|
+
else if (inRequire && line === ")") inRequire = false;
|
|
40083
|
+
else if (m = inRequire ? line.match(/^(\S+)\s+(v\S+)/) : line.match(/^require\s+(\S+)\s+(v\S+)/)) depends.push({ package: m[1], version: m[2], file: f.path, line: i + 1 });
|
|
40084
|
+
});
|
|
40085
|
+
} else if (n === "requirements.txt") {
|
|
40086
|
+
text2.split("\n").forEach((raw, i) => {
|
|
40087
|
+
const line = raw.replace(/#.*/, "").trim();
|
|
40088
|
+
if (!line || line.startsWith("-")) return;
|
|
40089
|
+
const m = line.match(/^([A-Za-z0-9][A-Za-z0-9_.-]*)(?:\[[^\]]*\])?\s*(.*)$/);
|
|
40090
|
+
if (m) depends.push({ package: m[1].toLowerCase().replace(/_/g, "-"), ...m[2] ? { version: m[2].replace(/\s*;.*$/, "").trim() } : {}, file: f.path, line: i + 1 });
|
|
40091
|
+
});
|
|
40092
|
+
} else {
|
|
40093
|
+
for (const m of text2.matchAll(/<PackageReference\s+Include="([^"]+)"(?:\s+Version="([^"]+)")?/g)) depends.push({ package: m[1], ...m[2] ? { version: m[2] } : {}, file: f.path, line: lineAt4(text2, m.index) });
|
|
40094
|
+
const id2 = text2.match(/<PackageId>\s*([^<\s]+)\s*<\/PackageId>/);
|
|
40095
|
+
if (id2) publishes.push({ package: id2[1], file: f.path, line: lineAt4(text2, id2.index), root: dirOf4(f.path) });
|
|
40096
|
+
}
|
|
40097
|
+
} catch {
|
|
40098
|
+
}
|
|
40099
|
+
}
|
|
40100
|
+
return { publishes, depends };
|
|
40101
|
+
}
|
|
40102
|
+
var LOCAL_VERSION = /^(workspace:|file:|link:|portal:|\.{0,2}\/|git\+|github:|https?:)/;
|
|
40103
|
+
var KEY = "([A-Za-z_][A-Za-z0-9_]*)";
|
|
40104
|
+
var Q = `["'\`]`;
|
|
40105
|
+
var SETTING_READS = [
|
|
40106
|
+
new RegExp(`\\bprocess\\.env\\.${KEY}`, "g"),
|
|
40107
|
+
new RegExp(`\\bprocess\\.env\\[\\s*${Q}${KEY}${Q}\\s*\\]`, "g"),
|
|
40108
|
+
new RegExp(`\\bimport\\.meta\\.env\\.${KEY}`, "g"),
|
|
40109
|
+
new RegExp(`\\bDeno\\.env\\.get\\(\\s*${Q}${KEY}${Q}`, "g"),
|
|
40110
|
+
new RegExp(`\\b(?:os\\.)?environ(?:\\.get)?\\s*[\\[(]\\s*${Q}${KEY}${Q}`, "g"),
|
|
40111
|
+
new RegExp(`\\bos\\.getenv\\(\\s*${Q}${KEY}${Q}`, "g"),
|
|
40112
|
+
new RegExp(`\\bos\\.(?:Getenv|LookupEnv)\\(\\s*"${KEY}"`, "g"),
|
|
40113
|
+
new RegExp(`\\bSystem\\.getenv\\(\\s*"${KEY}"`, "g"),
|
|
40114
|
+
new RegExp(`\\bEnvironment\\.GetEnvironmentVariable\\(\\s*"${KEY}"`, "g"),
|
|
40115
|
+
new RegExp(`\\bENV(?:\\.fetch\\(\\s*|\\[\\s*)${Q}${KEY}${Q}`, "g"),
|
|
40116
|
+
new RegExp(`\\benv::var(?:_os)?\\(\\s*"${KEY}"`, "g"),
|
|
40117
|
+
new RegExp(`\\bgetenv\\(\\s*${Q}${KEY}${Q}`, "g"),
|
|
40118
|
+
new RegExp(`\\$_ENV\\[\\s*${Q}${KEY}${Q}`, "g")
|
|
40119
|
+
];
|
|
40120
|
+
var isGenericSetting = (key) => GENERIC_SETTINGS.has(key) || /^(VERCEL_|EAS_BUILD|GITHUB_|RUNNER_|npm_|NETLIFY|RENDER_|RAILWAY_|FLY_|HEROKU_|AWS_LAMBDA_|K_SERVICE|KUBERNETES_)/.test(key);
|
|
40121
|
+
var GENERIC_SETTINGS = /* @__PURE__ */ new Set(["NODE_ENV", "PORT", "HOST", "HOSTNAME", "HOME", "PATH", "PWD", "USER", "SHELL", "TMPDIR", "TEMP", "TMP", "TZ", "LANG", "CI", "DEBUG", "ENV", "ENVIRONMENT", "APP_ENV", "LOG_LEVEL", "LOGLEVEL", "VERBOSE", "GITHUB_ACTIONS", "npm_package_version", "ASPNETCORE_ENVIRONMENT", "DOTNET_ENVIRONMENT", "PYTHONPATH", "GOPATH", "JAVA_HOME", "NODE_OPTIONS", "CI_COMMIT_SHA"]);
|
|
40122
|
+
function settingsIn(files) {
|
|
40123
|
+
const out = [];
|
|
40124
|
+
for (const f of files) {
|
|
40125
|
+
if (isManifest(f.path) || /\.sql$/i.test(f.path)) continue;
|
|
40126
|
+
const text2 = String(f.source ?? "");
|
|
40127
|
+
if (!/env/i.test(text2)) continue;
|
|
40128
|
+
const seen = /* @__PURE__ */ new Set();
|
|
40129
|
+
for (const re of SETTING_READS) {
|
|
40130
|
+
for (const m of text2.matchAll(re)) {
|
|
40131
|
+
const line = lineAt4(text2, m.index);
|
|
40132
|
+
const k = `${m[1]}|${line}`;
|
|
40133
|
+
if (seen.has(k)) continue;
|
|
40134
|
+
seen.add(k);
|
|
40135
|
+
out.push({ key: m[1], file: f.path, line });
|
|
40136
|
+
}
|
|
40137
|
+
}
|
|
40138
|
+
}
|
|
40139
|
+
return out.sort((a, b) => a.file.localeCompare(b.file) || a.line - b.line || a.key.localeCompare(b.key));
|
|
40140
|
+
}
|
|
40141
|
+
var NAME = '((?:[`"\\[]?[A-Za-z_][\\w$]*[`"\\]]?\\.){0,2}[`"\\[]?[A-Za-z_][\\w$]*[`"\\]]?)';
|
|
40142
|
+
var NOT_TABLES = /* @__PURE__ */ new Set(["select", "set", "where", "values", "dual", "lateral", "unnest", "only", "table", "if", "exists", "not", "the", "a", "an", "my", "your", "this", "that", "each", "all", "json_table", "information_schema", "pg_catalog", "sys"]);
|
|
40143
|
+
function tableName(raw) {
|
|
40144
|
+
const name = raw.replace(/[`"[\]]/g, "");
|
|
40145
|
+
return { table: name.split(".").pop().toLowerCase(), name };
|
|
40146
|
+
}
|
|
40147
|
+
function usesIn(sql, offsetOf, push) {
|
|
40148
|
+
const re = new RegExp(`\\b(DELETE\\s+FROM|INSERT\\s+(?:OR\\s+\\w+\\s+)?INTO|MERGE\\s+INTO|UPDATE|FROM|JOIN)\\s+${NAME}(\\s*\\()?`, "gi");
|
|
40149
|
+
for (const m of sql.matchAll(re)) {
|
|
40150
|
+
const kw = m[1].toUpperCase().replace(/\s+/g, " ");
|
|
40151
|
+
if (m[3] && (kw === "FROM" || kw === "JOIN")) continue;
|
|
40152
|
+
const { table, name } = tableName(m[2]);
|
|
40153
|
+
if (NOT_TABLES.has(table) || NOT_TABLES.has(name.toLowerCase())) continue;
|
|
40154
|
+
if (kw === "UPDATE" && (/\b(DO|FOR|KEY)\s*$/i.test(sql.slice(Math.max(0, m.index - 12), m.index)) || !/^\s*(?:(?:AS\s+)?\w+\s+)?SET\b/i.test(sql.slice(m.index + m[0].length)))) continue;
|
|
40155
|
+
push({ table, name, access: kw === "FROM" || kw === "JOIN" ? "reads" : "writes", at: offsetOf(m.index) });
|
|
40156
|
+
}
|
|
40157
|
+
}
|
|
40158
|
+
var SQL_SHAPES = [
|
|
40159
|
+
/^\s*SELECT\b[\s\S]*?\bFROM\s/i,
|
|
40160
|
+
/^\s*INSERT\s+(?:OR\s+\w+\s+)?INTO\s/i,
|
|
40161
|
+
/^\s*UPDATE\s+[\w."`[\]]+\s+(?:(?:AS\s+)?\w+\s+)?SET\s/i,
|
|
40162
|
+
/^\s*DELETE\s+FROM\s/i,
|
|
40163
|
+
/^\s*WITH\s+(?:RECURSIVE\s+)?\w+\s+AS\s*\(/i,
|
|
40164
|
+
/^\s*MERGE\s+INTO\s/i
|
|
40165
|
+
];
|
|
40166
|
+
var isSql = (text2) => SQL_SHAPES.some((re) => re.test(text2));
|
|
40167
|
+
var CODE_STRINGS = /"""([\s\S]*?)"""|'''([\s\S]*?)'''|`((?:\\[\s\S]|[^`\\])*)`|"((?:\\.|[^"\\\n])*)"|'((?:\\.|[^'\\\n])*)'/g;
|
|
40168
|
+
function tablesIn(files) {
|
|
40169
|
+
const out = [];
|
|
40170
|
+
for (const f of files) {
|
|
40171
|
+
if (isManifest(f.path)) continue;
|
|
40172
|
+
const text2 = String(f.source ?? "");
|
|
40173
|
+
const push = (u) => out.push({ table: u.table, name: u.name, access: u.access, file: f.path, line: lineAt4(text2, u.at), ...u.end != null ? { lines: [lineAt4(text2, u.at), lineAt4(text2, u.end)] } : {} });
|
|
40174
|
+
if (/\.sql$/i.test(f.path)) {
|
|
40175
|
+
const clean = text2.replace(/--[^\n]*/g, (s) => " ".repeat(s.length)).replace(/\/\*[\s\S]*?\*\//g, (s) => s.replace(/[^\n]/g, " "));
|
|
40176
|
+
const ddl = new RegExp(`\\b(CREATE(?:\\s+OR\\s+REPLACE)?(?:\\s+(?:TEMP|TEMPORARY|UNLOGGED|GLOBAL|LOCAL))*\\s+TABLE|ALTER\\s+TABLE|DROP\\s+TABLE)(?:\\s+IF\\s+(?:NOT\\s+)?EXISTS)?(?:\\s+ONLY)?\\s+${NAME}`, "gi");
|
|
40177
|
+
const ddlSpans = [];
|
|
40178
|
+
for (const m of clean.matchAll(ddl)) {
|
|
40179
|
+
const { table, name } = tableName(m[2]);
|
|
40180
|
+
if (NOT_TABLES.has(table)) continue;
|
|
40181
|
+
const kw = m[1].toUpperCase();
|
|
40182
|
+
if (/TEMP/.test(kw)) continue;
|
|
40183
|
+
const end2 = clean.indexOf(";", m.index);
|
|
40184
|
+
const stop = end2 < 0 ? clean.length : end2;
|
|
40185
|
+
ddlSpans.push([m.index, stop]);
|
|
40186
|
+
push({ table, name, access: kw.startsWith("CREATE") ? "creates" : kw.startsWith("ALTER") ? "alters" : "drops", at: m.index, end: stop });
|
|
40187
|
+
}
|
|
40188
|
+
const roles = [...clean.matchAll(/\b(?:GRANT|REVOKE)\b[^;]*/gi)].map((m) => [m.index, m.index + m[0].length]);
|
|
40189
|
+
const skip = [...ddlSpans, ...roles];
|
|
40190
|
+
usesIn(clean, (i) => i, (u) => {
|
|
40191
|
+
if (!skip.some(([a, b]) => u.at >= a && u.at <= b)) push(u);
|
|
40192
|
+
});
|
|
40193
|
+
continue;
|
|
40194
|
+
}
|
|
40195
|
+
if (!/\b(SELECT|INSERT|UPDATE|DELETE|MERGE)\b/i.test(text2)) continue;
|
|
40196
|
+
for (const m of text2.matchAll(CODE_STRINGS)) {
|
|
40197
|
+
const body2 = m[1] ?? m[2] ?? m[3] ?? m[4] ?? m[5] ?? "";
|
|
40198
|
+
if (!isSql(body2)) continue;
|
|
40199
|
+
const start = m.index + m[0].indexOf(body2);
|
|
40200
|
+
usesIn(body2, (i) => start + i, push);
|
|
40201
|
+
}
|
|
40202
|
+
}
|
|
40203
|
+
const seen = /* @__PURE__ */ new Set();
|
|
40204
|
+
return out.filter((t) => {
|
|
40205
|
+
const k = `${t.file}|${t.line}|${t.table}|${t.access}`;
|
|
40206
|
+
if (seen.has(k)) return false;
|
|
40207
|
+
seen.add(k);
|
|
40208
|
+
return true;
|
|
40209
|
+
}).sort((a, b) => a.file.localeCompare(b.file) || a.line - b.line || a.table.localeCompare(b.table));
|
|
40210
|
+
}
|
|
40211
|
+
var DEFINES = /* @__PURE__ */ new Set(["creates", "alters", "drops"]);
|
|
40212
|
+
|
|
40041
40213
|
// src/trace.mjs
|
|
40042
40214
|
var TRACE_SCHEMA = "thunder-trace-v1";
|
|
40043
|
-
var TRACE_RULES_VERSION = "
|
|
40215
|
+
var TRACE_RULES_VERSION = "2";
|
|
40044
40216
|
function isTestFile(file) {
|
|
40045
40217
|
return /(^|\/)(tests?|__tests__|specs?|__mocks__|mocks?|fixtures?|__fixtures__|e2e|testdata|test-data)\//i.test(file) || /\.(test|spec|e2e)\.[a-z0-9]+$/i.test(file) || /(^|\/)test_[^/]+\.py$/.test(file) || /_test\.(go|py|rb|exs?)$/.test(file) || /(Tests?|Spec|IT)\.(cs|java|kt|scala)$/.test(file);
|
|
40046
40218
|
}
|
|
@@ -40060,7 +40232,8 @@ function buildTrace(repos) {
|
|
|
40060
40232
|
const model = thunderModel(r.files, { name: r.name });
|
|
40061
40233
|
const facts = serviceFacts(model, r.files);
|
|
40062
40234
|
const real = (x) => !isTestFile(x.file);
|
|
40063
|
-
const
|
|
40235
|
+
const data = dataFacts(r.files, model);
|
|
40236
|
+
const testItems = ["routes", "listeners", "requests", "publishes"].reduce((n, k) => n + facts[k].filter((x) => !real(x)).length, 0) + data.testItems;
|
|
40064
40237
|
return {
|
|
40065
40238
|
name: r.name,
|
|
40066
40239
|
sha: r.sha ?? null,
|
|
@@ -40072,11 +40245,35 @@ function buildTrace(repos) {
|
|
|
40072
40245
|
requests: facts.requests.filter(real),
|
|
40073
40246
|
publishes: facts.publishes.filter(real),
|
|
40074
40247
|
unknown: facts.unknown.filter(real),
|
|
40248
|
+
packages: data.packages,
|
|
40249
|
+
settings: data.settings,
|
|
40250
|
+
tables: data.tables,
|
|
40075
40251
|
testItems
|
|
40076
40252
|
};
|
|
40077
40253
|
});
|
|
40078
40254
|
return linkRepos(read);
|
|
40079
40255
|
}
|
|
40256
|
+
function memberAt(model, file, line) {
|
|
40257
|
+
let best = null;
|
|
40258
|
+
for (const m of model.members) {
|
|
40259
|
+
if (m.file !== file || !m.lines || line < m.lines[0] || line > m.lines[1]) continue;
|
|
40260
|
+
if (!best || m.lines[1] - m.lines[0] < best.lines[1] - best.lines[0]) best = m;
|
|
40261
|
+
}
|
|
40262
|
+
return best ? { member: best.id, label: best.label } : { member: null, label: file.split("/").pop() };
|
|
40263
|
+
}
|
|
40264
|
+
function dataFacts(files, model) {
|
|
40265
|
+
const real = (x) => !isTestFile(x.file);
|
|
40266
|
+
const pk = packagesIn(files), settings = settingsIn(files), tables = tablesIn(files);
|
|
40267
|
+
const place = (x) => ({ ...x, ...memberAt(model, x.file, x.line) });
|
|
40268
|
+
const manifest = (x) => ({ ...x, member: null, label: x.file });
|
|
40269
|
+
const testItems = [...pk.publishes, ...pk.depends, ...settings, ...tables].filter((x) => !real(x)).length;
|
|
40270
|
+
return {
|
|
40271
|
+
packages: { publishes: pk.publishes.filter(real).map(manifest), depends: pk.depends.filter(real).map(manifest) },
|
|
40272
|
+
settings: settings.filter(real).map(place),
|
|
40273
|
+
tables: tables.filter(real).map((t) => /\.sql$/i.test(t.file) ? { ...t, member: null, label: t.file } : place(t)),
|
|
40274
|
+
testItems
|
|
40275
|
+
};
|
|
40276
|
+
}
|
|
40080
40277
|
function linkRepos(read) {
|
|
40081
40278
|
const links = [], notLinked = [];
|
|
40082
40279
|
for (const repo of read) {
|
|
@@ -40118,7 +40315,33 @@ function linkRepos(read) {
|
|
|
40118
40315
|
if (!found) notLinked.push({ kind: "event", call: `event ${p.event}`, from, why: `no listener Thunder read in the traced repositories waits for ${p.event}` });
|
|
40119
40316
|
}
|
|
40120
40317
|
}
|
|
40121
|
-
const
|
|
40318
|
+
const pk = (r) => r.packages ?? { publishes: [], depends: [] };
|
|
40319
|
+
const publishers = /* @__PURE__ */ new Map();
|
|
40320
|
+
for (const repo of read) for (const p of pk(repo).publishes) (publishers.get(p.package) ?? publishers.set(p.package, []).get(p.package)).push({ repo, p });
|
|
40321
|
+
for (const repo of read) {
|
|
40322
|
+
const own = new Set(pk(repo).publishes.map((p) => p.package));
|
|
40323
|
+
for (const d of pk(repo).depends) {
|
|
40324
|
+
if (own.has(d.package)) continue;
|
|
40325
|
+
const pubs = (publishers.get(d.package) ?? []).filter((x) => x.repo !== repo);
|
|
40326
|
+
const byRepo = [...new Map(pubs.map((x) => [x.repo.name, x])).values()];
|
|
40327
|
+
if (byRepo.length === 1) links.push({ kind: "package", package: d.package, version: d.version ?? null, ...d.dev ? { dev: true } : {}, from: end(repo, d), to: end(byRepo[0].repo, byRepo[0].p) });
|
|
40328
|
+
else if (byRepo.length > 1) notLinked.push({ kind: "package", call: `package ${d.package}`, from: end(repo, d), why: `${byRepo.length} repositories publish ${d.package} (${byRepo.map((x) => x.repo.name).join(", ")}), so none is chosen` });
|
|
40329
|
+
}
|
|
40330
|
+
}
|
|
40331
|
+
const tb = (r) => r.tables ?? [];
|
|
40332
|
+
const creators = /* @__PURE__ */ new Map();
|
|
40333
|
+
for (const repo of read) for (const t of tb(repo)) if (t.access === "creates") (creators.get(t.table) ?? creators.set(t.table, []).get(t.table)).push({ repo, t });
|
|
40334
|
+
for (const repo of read) {
|
|
40335
|
+
const own = new Set(tb(repo).filter((t) => t.access === "creates").map((t) => t.table));
|
|
40336
|
+
for (const t of tb(repo)) {
|
|
40337
|
+
if (DEFINES.has(t.access) || own.has(t.table)) continue;
|
|
40338
|
+
const owners = [...new Map((creators.get(t.table) ?? []).filter((x) => x.repo !== repo).map((x) => [x.repo.name, x])).values()];
|
|
40339
|
+
if (owners.length === 1) links.push({ kind: "data", table: t.table, access: t.access, from: end(repo, t), to: end(owners[0].repo, owners[0].t) });
|
|
40340
|
+
else if (owners.length > 1) notLinked.push({ kind: "data", call: `table ${t.name}`, from: end(repo, t), why: `${owners.length} repositories create a table named ${t.table} (${owners.map((x) => x.repo.name).join(", ")}), so none is chosen` });
|
|
40341
|
+
}
|
|
40342
|
+
}
|
|
40343
|
+
const shared = sharedFacts(read);
|
|
40344
|
+
const sortKey = (l) => `${l.from.cite}|${l.to?.cite ?? ""}|${l.kind}|${l.call ?? l.event ?? l.path ?? l.package ?? l.table ?? ""}`;
|
|
40122
40345
|
const once = (xs) => {
|
|
40123
40346
|
const seen = /* @__PURE__ */ new Set();
|
|
40124
40347
|
return xs.filter((x) => {
|
|
@@ -40130,10 +40353,29 @@ function linkRepos(read) {
|
|
|
40130
40353
|
};
|
|
40131
40354
|
links.splice(0, links.length, ...once(links).sort((a, b) => sortKey(a).localeCompare(sortKey(b))));
|
|
40132
40355
|
notLinked.splice(0, notLinked.length, ...once(notLinked).sort((a, b) => sortKey(a).localeCompare(sortKey(b))));
|
|
40133
|
-
const repos = read.map(({ unknown, ...r }) => ({ ...r, unknown: unknown ?? [] }));
|
|
40134
|
-
const body2 = { schema: TRACE_SCHEMA, rulesVersion: TRACE_RULES_VERSION, repos, links, notLinked };
|
|
40356
|
+
const repos = read.map(({ unknown, ...r }) => ({ ...r, unknown: unknown ?? [], packages: pk(r), settings: r.settings ?? [], tables: tb(r) }));
|
|
40357
|
+
const body2 = { schema: TRACE_SCHEMA, rulesVersion: TRACE_RULES_VERSION, repos, links, notLinked, shared };
|
|
40135
40358
|
return { ...body2, fingerprint: sha256(JSON.stringify(body2)) };
|
|
40136
40359
|
}
|
|
40360
|
+
function sharedFacts(read) {
|
|
40361
|
+
const group = (items) => {
|
|
40362
|
+
const m = /* @__PURE__ */ new Map();
|
|
40363
|
+
for (const [k, repo, x] of items) (m.get(k) ?? m.set(k, []).get(k)).push({ repo, x });
|
|
40364
|
+
return m;
|
|
40365
|
+
};
|
|
40366
|
+
const manyRepos = (xs) => new Set(xs.map((y) => y.repo.name)).size > 1;
|
|
40367
|
+
const byKey = (a, b) => a[0] < b[0] ? -1 : a[0] > b[0] ? 1 : 0;
|
|
40368
|
+
const settings = [...group(read.flatMap((r) => (r.settings ?? []).filter((x) => !isGenericSetting(x.key)).map((x) => [x.key, r, x]))).entries()].filter(([, xs]) => manyRepos(xs)).sort(byKey).map(([key, xs]) => ({ key, readers: xs.map(({ repo, x }) => end(repo, x)) }));
|
|
40369
|
+
const tables = [...group(read.flatMap((r) => (r.tables ?? []).map((x) => [x.table, r, x]))).entries()].filter(([, xs]) => manyRepos(xs)).sort(byKey).map(([table, xs]) => ({ table, users: xs.map(({ repo, x }) => ({ ...end(repo, x), access: x.access })) }));
|
|
40370
|
+
const drift = [];
|
|
40371
|
+
for (const [name, xs] of [...group(read.flatMap((r) => (r.packages?.depends ?? []).filter((d) => d.version && !d.peer && !LOCAL_VERSION.test(d.version)).map((d) => [d.package, r, d]))).entries()].sort(byKey)) {
|
|
40372
|
+
const versions = group(xs.map(({ repo, x }) => [x.version, repo, x]));
|
|
40373
|
+
const perRepo = new Set([...group(xs.map(({ repo, x }) => [repo.name, repo, x])).values()].map((ys) => [...new Set(ys.map((y) => y.x.version))].sort().join("|")));
|
|
40374
|
+
if (!manyRepos(xs) || versions.size < 2 || perRepo.size < 2) continue;
|
|
40375
|
+
drift.push({ package: name, versions: [...versions.entries()].sort(byKey).map(([version, ys]) => ({ version, at: ys.map(({ repo, x }) => end(repo, x)) })) });
|
|
40376
|
+
}
|
|
40377
|
+
return { settings, tables, drift };
|
|
40378
|
+
}
|
|
40137
40379
|
var methodOk = (route, req) => route === req || route === "ANY" || route === "ALL";
|
|
40138
40380
|
|
|
40139
40381
|
// src/write-across.mjs
|
|
@@ -40650,7 +40892,7 @@ function fileMatcher(model) {
|
|
|
40650
40892
|
return { file: found[0] };
|
|
40651
40893
|
};
|
|
40652
40894
|
}
|
|
40653
|
-
function
|
|
40895
|
+
function memberAt2(model, file, line) {
|
|
40654
40896
|
const hits = model.members.filter((m) => m.file === file && line >= m.lines[0] && line <= m.lines[1]);
|
|
40655
40897
|
return hits.sort((a, b) => a.lines[1] - a.lines[0] - (b.lines[1] - b.lines[0]))[0] ?? null;
|
|
40656
40898
|
}
|
|
@@ -40769,7 +41011,7 @@ function runtimeOverlay(model, evidence2 = []) {
|
|
|
40769
41011
|
file = got.file;
|
|
40770
41012
|
line = f.line ?? null;
|
|
40771
41013
|
if (ev.fnLine != null) member = model.members.filter((m) => m.file === file && m.lines[0] <= ev.fnLine && ev.fnLine <= Math.min(m.lines[1], m.lines[0] + 3) && (m.lines[0] === ev.fnLine || !fnStarts.has(`${file}|${m.lines[0]}`))).sort((a, b) => b.lines[0] - a.lines[0])[0] ?? null;
|
|
40772
|
-
else if (line != null && ev.kind !== "call") member =
|
|
41014
|
+
else if (line != null && ev.kind !== "call") member = memberAt2(model, file, line);
|
|
40773
41015
|
else if (ev.kind === "call" && ev.fnLine == null) {
|
|
40774
41016
|
if (line != null) {
|
|
40775
41017
|
const starts = model.members.filter((m) => m.file === file && m.lines[0] <= line && line <= m.lines[0] + 3).sort((a, b) => a.lines[0] - b.lines[0]);
|
|
@@ -40778,7 +41020,7 @@ function runtimeOverlay(model, evidence2 = []) {
|
|
|
40778
41020
|
const named2 = membersNamed(model, f.function, { file, namespace: ev.namespace });
|
|
40779
41021
|
if (named2.length === 1) member = named2[0];
|
|
40780
41022
|
}
|
|
40781
|
-
if (!member) member =
|
|
41023
|
+
if (!member) member = memberAt2(model, file, line);
|
|
40782
41024
|
} else if (f.function) {
|
|
40783
41025
|
const named2 = membersNamed(model, f.function, { file, namespace: ev.namespace });
|
|
40784
41026
|
if (named2.length === 1) member = named2[0];
|
|
@@ -41024,7 +41266,7 @@ function explainError(model, stack) {
|
|
|
41024
41266
|
placed.push({ frame: f });
|
|
41025
41267
|
continue;
|
|
41026
41268
|
}
|
|
41027
|
-
const m3 =
|
|
41269
|
+
const m3 = memberAt2(model, got.file, f.line);
|
|
41028
41270
|
if (!m3) {
|
|
41029
41271
|
reason ??= `line ${f.line} of ${got.file} is not inside any action or rule Thunder read`;
|
|
41030
41272
|
placed.push({ frame: f, file: got.file });
|
|
@@ -42025,7 +42267,7 @@ function countsLine(c) {
|
|
|
42025
42267
|
if (c.notRead) parts.push(`${plural5(c.notRead, "file")} Thunder does not read`);
|
|
42026
42268
|
return `${parts.join(" \xB7 ")}.`;
|
|
42027
42269
|
}
|
|
42028
|
-
var
|
|
42270
|
+
var esc2 = (s) => String(s).replace(/[<>]/g, (ch) => ch === "<" ? "<" : ">");
|
|
42029
42271
|
var fence2 = (lines) => ["```", ...lines.map((l) => l.replace(/```/g, "'''")), "```"];
|
|
42030
42272
|
var cutLines = (lines, max) => lines.length > max ? [...lines.slice(0, max), `\u2026 ${lines.length - max} more lines`] : lines;
|
|
42031
42273
|
function evidence(ev, maxLines) {
|
|
@@ -42043,7 +42285,7 @@ var HEADINGS = {
|
|
|
42043
42285
|
};
|
|
42044
42286
|
function renderReviewComment(r, { maxChars = 6e4, fileUrl = null, notes = [], footer = "", evidenceLines = 40 } = {}) {
|
|
42045
42287
|
const where2 = (w) => {
|
|
42046
|
-
const label = `\`${
|
|
42288
|
+
const label = `\`${esc2(w.file)}:${w.line}\``;
|
|
42047
42289
|
const url = fileUrl?.(w.file, w.line);
|
|
42048
42290
|
return url ? `[${label}](${url})` : label;
|
|
42049
42291
|
};
|
|
@@ -42064,12 +42306,12 @@ function renderReviewComment(r, { maxChars = 6e4, fileUrl = null, notes = [], fo
|
|
|
42064
42306
|
const close = sev === "form" ? ["</details>", ""] : [];
|
|
42065
42307
|
const memberBlocks = [...members.values()].map((xs) => {
|
|
42066
42308
|
const render = (compact2) => {
|
|
42067
|
-
const lines = [`- **${
|
|
42309
|
+
const lines = [`- **${esc2(xs[0].subject)}** \xB7 ${where2(xs[0].where)}`];
|
|
42068
42310
|
const list4 = compact2 ? xs.slice(0, COMPACT_SENTENCES) : xs;
|
|
42069
42311
|
for (const x of list4) {
|
|
42070
42312
|
const ev = sev === "form" ? [] : evidence(x.evidence, evidenceLines);
|
|
42071
42313
|
const at2 = x.where.line !== xs[0].where.line || x.where.file !== xs[0].where.file ? ` (${where2(x.where)})` : "";
|
|
42072
|
-
lines.push(` - ${
|
|
42314
|
+
lines.push(` - ${esc2(x.says)}${at2}${compact2 && (ev.length || x.also?.length) ? " _(Before and after, and other places: in the job summary.)_" : ""}`);
|
|
42073
42315
|
if (compact2) continue;
|
|
42074
42316
|
if (ev.length) lines.push("", ` <details><summary>Before and after</summary>`, "", ...ev.map((l) => l ? ` ${l}` : ""), "", " </details>", "");
|
|
42075
42317
|
if (x.also?.length) {
|
|
@@ -42077,7 +42319,7 @@ function renderReviewComment(r, { maxChars = 6e4, fileUrl = null, notes = [], fo
|
|
|
42077
42319
|
"",
|
|
42078
42320
|
` <details><summary>The same in ${x.also.length} more</summary>`,
|
|
42079
42321
|
"",
|
|
42080
|
-
...x.also.slice(0, 50).map((a) => ` - **${
|
|
42322
|
+
...x.also.slice(0, 50).map((a) => ` - **${esc2(a.subject)}** \xB7 ${where2(a.where)}`),
|
|
42081
42323
|
...x.also.length > 50 ? [` - and ${x.also.length - 50} more`] : [],
|
|
42082
42324
|
"",
|
|
42083
42325
|
" </details>",
|
|
@@ -42093,7 +42335,7 @@ function renderReviewComment(r, { maxChars = 6e4, fileUrl = null, notes = [], fo
|
|
|
42093
42335
|
blocks2.push({ open, close, members: memberBlocks });
|
|
42094
42336
|
}
|
|
42095
42337
|
const tail = [];
|
|
42096
|
-
if (r.notRead?.length) tail.push(`Also changed, not read by Thunder (check ${r.notRead.length === 1 ? "it" : "them"} yourself if ${r.notRead.length === 1 ? "it matters" : "they matter"}): ${r.notRead.slice(0, 20).map((f) => `\`${
|
|
42338
|
+
if (r.notRead?.length) tail.push(`Also changed, not read by Thunder (check ${r.notRead.length === 1 ? "it" : "them"} yourself if ${r.notRead.length === 1 ? "it matters" : "they matter"}): ${r.notRead.slice(0, 20).map((f) => `\`${esc2(f.path)}\``).join(", ")}${r.notRead.length > 20 ? `, and ${r.notRead.length - 20} more` : ""}.`, "");
|
|
42097
42339
|
const foot = ["---", `<sub>Read from the code by the Thunder compiler, with no AI and without running the code. "Only the form changed" is said only when it is shown. Thunder describes the change; a person still decides whether it is right. [How this works](${DOCS_URL}) \xB7 [thunderlang.dev](${SITE_URL})${footer ? ` \xB7 ${footer}` : ""}</sub>`, ""];
|
|
42098
42340
|
const size = (lines) => lines.join("\n").length + 1;
|
|
42099
42341
|
const total = r.items.length;
|
|
@@ -46016,7 +46258,8 @@ function assemblePassport({ parts, change = null, runs = [], purpose = null, ext
|
|
|
46016
46258
|
}
|
|
46017
46259
|
const shownBehavior = behavior.slice(0, MAX_BEHAVIOR);
|
|
46018
46260
|
const trace = buildTrace(parts.map((p) => ({ name: p.name, sha: p.sha ?? null, dirty: !!p.dirty, files: p.files.filter((f) => !f.manifest) })));
|
|
46019
|
-
const
|
|
46261
|
+
const linkSays = (l) => l.kind === "http" ? `${l.from.repo} calls ${l.to.repo}: ${l.method} ${l.path} (handled by ${l.to.label ?? l.route})` : l.kind === "event" ? `${l.from.repo} publishes ${l.event}, and ${l.to.repo} listens` : l.kind === "data" ? `${l.from.repo} ${l.access} the ${l.table} table, which ${l.to.repo} creates` : `${l.from.repo} depends on the package ${l.package}, which ${l.to.repo} publishes`;
|
|
46262
|
+
const links = trace.links.map((l) => ({ kind: l.kind, says: linkSays(l), from: l.from.cite, to: l.to.cite }));
|
|
46020
46263
|
const services = [];
|
|
46021
46264
|
for (const r of trace.repos) for (const q2 of r.requests ?? []) if (q2.base && q2.base !== "this app") services.push({ part: r.name, calls: `${q2.method} ${q2.base}${q2.path}`, at: `${r.name}:${q2.file}:${q2.line}` });
|
|
46022
46265
|
const evidence2 = [];
|
|
@@ -46037,7 +46280,7 @@ function assemblePassport({ parts, change = null, runs = [], purpose = null, ext
|
|
|
46037
46280
|
add({
|
|
46038
46281
|
kind: "trace-link",
|
|
46039
46282
|
status: "read",
|
|
46040
|
-
claim: l.kind === "http" ? `${l.from.repo} calls ${l.to.repo} with ${l.method} ${l.path}, and ${l.to.repo} handles it.` : `${l.from.repo} publishes "${l.event}", and ${l.to.repo} listens for it.`,
|
|
46283
|
+
claim: l.kind === "http" ? `${l.from.repo} calls ${l.to.repo} with ${l.method} ${l.path}, and ${l.to.repo} handles it.` : l.kind === "event" ? `${l.from.repo} publishes "${l.event}", and ${l.to.repo} listens for it.` : l.kind === "data" ? `${l.from.repo} ${l.access} the ${l.table} table, and ${l.to.repo} creates it.` : `${l.from.repo} depends on the package ${l.package}, and ${l.to.repo} publishes it.`,
|
|
46041
46284
|
basis: { from: l.from.cite, to: l.to.cite, rules: `thunder-trace rules v${trace.rulesVersion}` },
|
|
46042
46285
|
scope: "Read from code; nothing was run. It does not show that the call succeeds or what it answers.",
|
|
46043
46286
|
inputs: [inputOf(l.from.repo, l.from.file), inputOf(l.to.repo, l.to.file)]
|