@skillstech/thunderlang 1.4.2 → 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 +36 -0
- package/dist/core.cjs +411 -163
- 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/core.d.ts +1 -1
- package/src/emit.mjs +1 -1
- package/src/mcp.mjs +2 -2
- package/src/passport.mjs +9 -2
- package/src/react/reading.css +6 -3
- package/src/react/reading.d.mts +1 -1
- package/src/react/reading.mjs +13 -1
- package/src/read-repo-fs.mjs +3 -2
- package/src/reading-layout.d.mts +4 -2
- package/src/reading-layout.mjs +12 -4
- 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/learn.cjs
CHANGED
|
@@ -3810,8 +3810,8 @@ function exactText(inner, code3) {
|
|
|
3810
3810
|
function exactIn(inner, code3, open) {
|
|
3811
3811
|
if (!/«|…/.test(inner) && inner.length && [`'${inner}'`, `"${inner}"`, `\`${inner}\``].some((q) => String(code3).includes(q))) return true;
|
|
3812
3812
|
if (!/«|…/.test(inner) && inner.trim().length) {
|
|
3813
|
-
const
|
|
3814
|
-
if (new RegExp(`(?:^|[\\s#%/:+=(\\-{"'])${
|
|
3813
|
+
const esc2 = inner.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
3814
|
+
if (new RegExp(`(?:^|[\\s#%/:+=(\\-{"'])${esc2}(?=$|[\\s}/)"';|])`).test(String(code3))) return true;
|
|
3815
3815
|
}
|
|
3816
3816
|
const cut = /…$/.test(inner);
|
|
3817
3817
|
const w = textSkeleton(inner.replace(/…$/, ""), true);
|
|
@@ -3827,10 +3827,10 @@ function exactIn(inner, code3, open) {
|
|
|
3827
3827
|
for (let i = 0; i < parts.length; i++) {
|
|
3828
3828
|
const f = parts[i].trim();
|
|
3829
3829
|
if (!f) continue;
|
|
3830
|
-
const
|
|
3830
|
+
const esc2 = f.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
3831
3831
|
const lead = i === 0 ? B : "[\"'`\\s,|]";
|
|
3832
3832
|
const tail = i === parts.length - 1 ? cut ? "" : E : "[\"'`\\s,]";
|
|
3833
|
-
const src = `${lead}${
|
|
3833
|
+
const src = `${lead}${esc2}${tail ? `(?=${tail})` : ""}`;
|
|
3834
3834
|
let re = FRAG_RE.get(src);
|
|
3835
3835
|
if (!re) {
|
|
3836
3836
|
if (FRAG_RE.size > 5e3) FRAG_RE.clear();
|
|
@@ -5170,10 +5170,10 @@ function lexSql(src, from = 0, to = src.length, dialect = "pg") {
|
|
|
5170
5170
|
}
|
|
5171
5171
|
const pre = /[EeNnBbXx]/.test(c) && src[i + 1] === "'" && !/[\w$]/.test(src[i - 1] || "");
|
|
5172
5172
|
if (c === "'" || pre) {
|
|
5173
|
-
const
|
|
5173
|
+
const esc2 = dialect === "mysql" || pre && /[Ee]/.test(c);
|
|
5174
5174
|
let j = i + (pre ? 2 : 1);
|
|
5175
5175
|
for (; j < to; j++) {
|
|
5176
|
-
if (
|
|
5176
|
+
if (esc2 && src[j] === "\\") {
|
|
5177
5177
|
j++;
|
|
5178
5178
|
continue;
|
|
5179
5179
|
}
|
|
@@ -5715,12 +5715,12 @@ function bodySteps(toks2, ctx, opts = {}) {
|
|
|
5715
5715
|
const n = toks2.length;
|
|
5716
5716
|
const labels = [];
|
|
5717
5717
|
const peek = (k = 0) => toks2[i + k];
|
|
5718
|
-
const
|
|
5719
|
-
const baseOf = (a, b) => ({ line:
|
|
5718
|
+
const lineOf7 = (tok) => ctx.lineAt(tok.s);
|
|
5719
|
+
const baseOf = (a, b) => ({ line: lineOf7(toks2[a]), span: { startLine: lineOf7(toks2[a]), endLine: lineOf7(toks2[Math.max(a, b - 1)]) } });
|
|
5720
5720
|
const textOf4 = (a, b) => ctx.src.slice(toks2[a].s, toks2[b - 1].e);
|
|
5721
5721
|
const semi = ctx.dialect !== "tsql";
|
|
5722
5722
|
const expect = (cond, what) => {
|
|
5723
|
-
if (!cond) throw new Unmatched(`${what} (line ${peek() ?
|
|
5723
|
+
if (!cond) throw new Unmatched(`${what} (line ${peek() ? lineOf7(peek()) : "end"})`);
|
|
5724
5724
|
};
|
|
5725
5725
|
const skipSemis = () => {
|
|
5726
5726
|
while (isP(peek(), ";")) i++;
|
|
@@ -5916,19 +5916,19 @@ function bodySteps(toks2, ctx, opts = {}) {
|
|
|
5916
5916
|
const [c0, c1] = condUntil((x) => isW(x, "THEN"));
|
|
5917
5917
|
i++;
|
|
5918
5918
|
const step2 = branch(c0, c1, block(endsWith("ELSIF", "ELSEIF", "ELSE", "END")));
|
|
5919
|
-
step2.line =
|
|
5919
|
+
step2.line = lineOf7(toks2[a]);
|
|
5920
5920
|
let tail = step2;
|
|
5921
5921
|
while (isW(peek(), "ELSIF", "ELSEIF")) {
|
|
5922
5922
|
const at2 = i;
|
|
5923
5923
|
i++;
|
|
5924
5924
|
const [e0, e1] = condUntil((x) => isW(x, "THEN"));
|
|
5925
5925
|
i++;
|
|
5926
|
-
const next = branch(e0, e1, block(endsWith("ELSIF", "ELSEIF", "ELSE", "END")), null,
|
|
5926
|
+
const next = branch(e0, e1, block(endsWith("ELSIF", "ELSEIF", "ELSE", "END")), null, lineOf7(toks2[at2]));
|
|
5927
5927
|
tail.otherwise = [next];
|
|
5928
5928
|
tail = next;
|
|
5929
5929
|
}
|
|
5930
5930
|
if (isW(peek(), "ELSE")) {
|
|
5931
|
-
tail.otherwiseLine =
|
|
5931
|
+
tail.otherwiseLine = lineOf7(peek());
|
|
5932
5932
|
i++;
|
|
5933
5933
|
tail.otherwise = block(endsWith("END"));
|
|
5934
5934
|
}
|
|
@@ -5941,9 +5941,9 @@ function bodySteps(toks2, ctx, opts = {}) {
|
|
|
5941
5941
|
const kids2 = tsqlBody();
|
|
5942
5942
|
skipSemis();
|
|
5943
5943
|
const step2 = branch(c0, c1, kids2);
|
|
5944
|
-
step2.line =
|
|
5944
|
+
step2.line = lineOf7(toks2[a]);
|
|
5945
5945
|
if (isW(peek(), "ELSE")) {
|
|
5946
|
-
step2.otherwiseLine =
|
|
5946
|
+
step2.otherwiseLine = lineOf7(peek());
|
|
5947
5947
|
i++;
|
|
5948
5948
|
step2.otherwise = tsqlBody();
|
|
5949
5949
|
}
|
|
@@ -5967,7 +5967,7 @@ function bodySteps(toks2, ctx, opts = {}) {
|
|
|
5967
5967
|
expect(arms.length, "CASE without WHEN");
|
|
5968
5968
|
let elseKids = null, elseLine = null;
|
|
5969
5969
|
if (isW(peek(), "ELSE")) {
|
|
5970
|
-
elseLine =
|
|
5970
|
+
elseLine = lineOf7(peek());
|
|
5971
5971
|
i++;
|
|
5972
5972
|
elseKids = block(endsWith("END"));
|
|
5973
5973
|
}
|
|
@@ -5980,14 +5980,14 @@ function bodySteps(toks2, ctx, opts = {}) {
|
|
|
5980
5980
|
text2 = vals.length === 1 ? `${subj} = ${vals[0]}` : `${subj} IN (${vals.join(", ")})`;
|
|
5981
5981
|
} else text2 = code2(textOf4(arm.w0, arm.w1));
|
|
5982
5982
|
const w = condWords(text2, ctx);
|
|
5983
|
-
return { kind: "branch", says: `If ${w ?? asCodeWords(text2, 400)}`, code: text2, cond: text2, line:
|
|
5983
|
+
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 };
|
|
5984
5984
|
});
|
|
5985
5985
|
for (let k = 0; k < steps.length - 1; k++) steps[k].otherwise = [steps[k + 1]];
|
|
5986
5986
|
const last = steps.at(-1);
|
|
5987
5987
|
if (elseKids) {
|
|
5988
5988
|
last.otherwise = elseKids;
|
|
5989
5989
|
last.otherwiseLine = elseLine;
|
|
5990
|
-
} 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(textOf4(a, i)), line:
|
|
5990
|
+
} 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(textOf4(a, i)), line: lineOf7(toks2[a]) }];
|
|
5991
5991
|
return [steps[0]];
|
|
5992
5992
|
}
|
|
5993
5993
|
if (up === "LOOP" && semi) {
|
|
@@ -6083,7 +6083,7 @@ function bodySteps(toks2, ctx, opts = {}) {
|
|
|
6083
6083
|
closeWith("TRY", "BEGIN TRY");
|
|
6084
6084
|
skipSemis();
|
|
6085
6085
|
expect(isW(peek(), "BEGIN") && isW(peek(1), "CATCH"), "BEGIN TRY without BEGIN CATCH");
|
|
6086
|
-
const hLine =
|
|
6086
|
+
const hLine = lineOf7(peek());
|
|
6087
6087
|
i += 2;
|
|
6088
6088
|
const handler = block(endsWith("END"));
|
|
6089
6089
|
closeWith("CATCH", "BEGIN CATCH");
|
|
@@ -6106,7 +6106,7 @@ function bodySteps(toks2, ctx, opts = {}) {
|
|
|
6106
6106
|
i++;
|
|
6107
6107
|
const names = toks2.slice(c0, c1).filter((x) => !isW(x, "OR", "SQLSTATE")).map((x) => x.t === "str" ? `error ${strText(x)}` : words(x.v));
|
|
6108
6108
|
const any = toks2.slice(c0, c1).some((x) => isW(x, "OTHERS"));
|
|
6109
|
-
handlers.push({ says: any ? "If anything goes wrong" : `If ${names.join(" or ")} goes wrong`, line:
|
|
6109
|
+
handlers.push({ says: any ? "If anything goes wrong" : `If ${names.join(" or ")} goes wrong`, line: lineOf7(toks2[hAt]), steps: block(endsWith("WHEN", "END")) });
|
|
6110
6110
|
}
|
|
6111
6111
|
}
|
|
6112
6112
|
ctx.depth--;
|
|
@@ -6224,9 +6224,9 @@ function bodySteps(toks2, ctx, opts = {}) {
|
|
|
6224
6224
|
if (isP(peek(), ";")) i++;
|
|
6225
6225
|
return [{ kind: "call", says: `Jumps to ${toks2[a + 1]?.v ?? "a label"}`, code: code2(textOf4(a, e2)), jump: "break", ...baseOf(a, e2) }];
|
|
6226
6226
|
}
|
|
6227
|
-
if (!semi && (up === "ELSE" || up === "END")) throw new Unmatched(`${up} without its IF or BEGIN (line ${
|
|
6228
|
-
if (semi && (up === "ELSE" || up === "ELSIF" || up === "ELSEIF" || up === "WHEN" || up === "UNTIL" || up === "EXCEPTION")) throw new Unmatched(`${up} outside its block (line ${
|
|
6229
|
-
if (semi && up === "END" && !ctx.allowEnd) throw new Unmatched(`END without its BEGIN (line ${
|
|
6227
|
+
if (!semi && (up === "ELSE" || up === "END")) throw new Unmatched(`${up} without its IF or BEGIN (line ${lineOf7(t)})`);
|
|
6228
|
+
if (semi && (up === "ELSE" || up === "ELSIF" || up === "ELSEIF" || up === "WHEN" || up === "UNTIL" || up === "EXCEPTION")) throw new Unmatched(`${up} outside its block (line ${lineOf7(t)})`);
|
|
6229
|
+
if (semi && up === "END" && !ctx.allowEnd) throw new Unmatched(`END without its BEGIN (line ${lineOf7(t)})`);
|
|
6230
6230
|
const e = Math.max(simpleEnd(a), a + 1);
|
|
6231
6231
|
i = e;
|
|
6232
6232
|
if (isP(peek(), ";")) i++;
|
|
@@ -6248,10 +6248,10 @@ function sqlDialect(src) {
|
|
|
6248
6248
|
return "pg";
|
|
6249
6249
|
}
|
|
6250
6250
|
var ROUTINE_WORDS = ["FUNCTION", "PROCEDURE", "PROC"];
|
|
6251
|
-
function sqlRoutines(src,
|
|
6251
|
+
function sqlRoutines(src, lineAt5, dialect = sqlDialect(src)) {
|
|
6252
6252
|
const toks2 = lexSql(src, 0, src.length, dialect);
|
|
6253
6253
|
const out = [];
|
|
6254
|
-
const
|
|
6254
|
+
const lineOf7 = (k) => lineAt5(toks2[Math.min(k, toks2.length - 1)].s);
|
|
6255
6255
|
for (let k = 0; k < toks2.length; k++) {
|
|
6256
6256
|
const start = k;
|
|
6257
6257
|
let j = k;
|
|
@@ -6397,7 +6397,7 @@ function sqlRoutines(src, lineAt4, dialect = sqlDialect(src)) {
|
|
|
6397
6397
|
}
|
|
6398
6398
|
}
|
|
6399
6399
|
let steps = [], bodyEnd2 = end2;
|
|
6400
|
-
const ctx = { src, lineAt:
|
|
6400
|
+
const ctx = { src, lineAt: lineAt5, dialect: bodyDialect, routine, setof, trigger, depth: 0 };
|
|
6401
6401
|
try {
|
|
6402
6402
|
if (dialect === "pg") {
|
|
6403
6403
|
if (bodyToks && language !== "c" && language !== "internal") {
|
|
@@ -6436,8 +6436,8 @@ function sqlRoutines(src, lineAt4, dialect = sqlDialect(src)) {
|
|
|
6436
6436
|
steps = [];
|
|
6437
6437
|
}
|
|
6438
6438
|
if (dialect === "tsql" || dialect === "mysql") end2 = bodyEnd2;
|
|
6439
|
-
const endLine =
|
|
6440
|
-
out.push({ name, line:
|
|
6439
|
+
const endLine = lineOf7(Math.max(end2, start));
|
|
6440
|
+
out.push({ name, line: lineOf7(start), endLine, kind: routine, inputs, outs, returns, setof, trigger, steps, ...unreadWhy ? { unreadWhy } : {}, headerEnd: lineOf7(Math.max(start, j - 1)) });
|
|
6441
6441
|
k = Math.max(k, Math.min(end2, toks2.length - 1));
|
|
6442
6442
|
}
|
|
6443
6443
|
return out;
|
|
@@ -6603,7 +6603,7 @@ function sqlCondition(cond, { aliases = {}, vars = false, keepAt = true, raw = f
|
|
|
6603
6603
|
}
|
|
6604
6604
|
function readSchema(src) {
|
|
6605
6605
|
const m = mask(src);
|
|
6606
|
-
const
|
|
6606
|
+
const lineAt5 = lineFinder(src);
|
|
6607
6607
|
const tables = [], choices = [], rules = [];
|
|
6608
6608
|
const docs = /* @__PURE__ */ new Map();
|
|
6609
6609
|
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, "'"));
|
|
@@ -6612,10 +6612,10 @@ function readSchema(src) {
|
|
|
6612
6612
|
const close = parenEnd(m, open);
|
|
6613
6613
|
if (close < 0) continue;
|
|
6614
6614
|
const name = bare(src.slice(t.index, open).match(/([\w."[\]`]+)\s*$/)[1]);
|
|
6615
|
-
const table = { name, lines: [
|
|
6615
|
+
const table = { name, lines: [lineAt5(t.index), lineAt5(close)], doc: docs.get(name.toLowerCase()) ?? docAbove(src, t.index), columns: [], checks: [], uniques: [], refs: [] };
|
|
6616
6616
|
for (const part of splitTop(src.slice(open + 1, close), m.slice(open + 1, close))) {
|
|
6617
6617
|
const text2 = part.text.trim().replace(/\s+/g, " ");
|
|
6618
|
-
const line =
|
|
6618
|
+
const line = lineAt5(open + 1 + part.at + (part.text.length - part.text.trimStart().length));
|
|
6619
6619
|
let x;
|
|
6620
6620
|
if (x = text2.match(/^(?:CONSTRAINT\s+([\w"]+)\s+)?CHECK\s*\((.*)\)$/i)) {
|
|
6621
6621
|
table.checks.push({ name: x[1] && unquote(x[1]), cond: x[2], line });
|
|
@@ -6648,7 +6648,7 @@ function readSchema(src) {
|
|
|
6648
6648
|
const close = parenEnd(m, open);
|
|
6649
6649
|
if (close < 0) continue;
|
|
6650
6650
|
const values = [...src.slice(open + 1, close).matchAll(/'((?:[^']|'')*)'/g)].map((v) => v[1].replace(/''/g, "'").replace(/_/g, " "));
|
|
6651
|
-
choices.push({ name: bare(e[1]), lines: [
|
|
6651
|
+
choices.push({ name: bare(e[1]), lines: [lineAt5(e.index), lineAt5(close)], doc: docAbove(src, e.index), values });
|
|
6652
6652
|
}
|
|
6653
6653
|
for (const t of tables) {
|
|
6654
6654
|
for (const c of t.checks) rules.push({ table: t.name, kind: "check", ...c });
|
|
@@ -6751,7 +6751,7 @@ function sqlTemplateReason(src) {
|
|
|
6751
6751
|
}
|
|
6752
6752
|
function sqlItems(src) {
|
|
6753
6753
|
const m = mask(src);
|
|
6754
|
-
const
|
|
6754
|
+
const lineAt5 = lineFinder(src);
|
|
6755
6755
|
const items = [];
|
|
6756
6756
|
const push = (name, line, steps, extra = {}) => {
|
|
6757
6757
|
const code3 = steps.filter((s) => s.kind === "other").length;
|
|
@@ -6781,9 +6781,9 @@ function sqlItems(src) {
|
|
|
6781
6781
|
const end2 = m.indexOf(";", v.index);
|
|
6782
6782
|
const query = src.slice(v.index + v[0].length, end2 < 0 ? src.length : end2);
|
|
6783
6783
|
const name = bare(v[1]);
|
|
6784
|
-
push(name,
|
|
6784
|
+
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: `${words(name)} is a saved query.`, headline: `${words(name)}: a saved query.` });
|
|
6785
6785
|
}
|
|
6786
|
-
for (const r of sqlRoutines(src,
|
|
6786
|
+
for (const r of sqlRoutines(src, lineAt5)) {
|
|
6787
6787
|
const inputs = r.inputs.map(({ name, type }) => ({ name, type }));
|
|
6788
6788
|
const returns = r.returns ?? (r.outs.length ? listWords(r.outs.map((o) => words(o.name))) : null);
|
|
6789
6789
|
const steps = r.unreadWhy ? [] : r.steps;
|
|
@@ -6801,7 +6801,7 @@ function sqlItems(src) {
|
|
|
6801
6801
|
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()] || words(e)).filter(Boolean);
|
|
6802
6802
|
const what = article(singular(words(bare(t[4]))));
|
|
6803
6803
|
const when = `${t[2].toUpperCase() === "BEFORE" ? "Before" : t[2].toUpperCase() === "AFTER" ? "After" : "Instead of when"} ${what} is ${events.join(" or ")}`;
|
|
6804
|
-
push(bare(t[1]),
|
|
6804
|
+
push(bare(t[1]), lineAt5(t.index), [{ kind: "call", says: `${when}, runs ${words(bare(t[5]))}`, code: t[0].replace(/\s+/g, " "), line: lineAt5(t.index) }], { says: `${when}, the database runs ${words(bare(t[5]))}.`, headline: `${when}.`, doc: docAbove(src, t.index) });
|
|
6805
6805
|
}
|
|
6806
6806
|
for (const r of readSchema(src).rules) {
|
|
6807
6807
|
const table = words(r.table);
|
|
@@ -9235,7 +9235,7 @@ function scanInterp(src, j, dialect) {
|
|
|
9235
9235
|
}
|
|
9236
9236
|
return j;
|
|
9237
9237
|
}
|
|
9238
|
-
function tokenize(src, dialect, from = 0, to = src.length,
|
|
9238
|
+
function tokenize(src, dialect, from = 0, to = src.length, lineAt5 = lineIndex(src)) {
|
|
9239
9239
|
const hcl = dialect === "hcl";
|
|
9240
9240
|
const toks2 = [], comments = [];
|
|
9241
9241
|
let i = from;
|
|
@@ -9253,14 +9253,14 @@ function tokenize(src, dialect, from = 0, to = src.length, lineAt4 = lineIndex(s
|
|
|
9253
9253
|
if (c === "#" || c === "/" && src[i + 1] === "/") {
|
|
9254
9254
|
let j = i;
|
|
9255
9255
|
while (j < to && src[j] !== "\n") j++;
|
|
9256
|
-
comments.push({ line:
|
|
9256
|
+
comments.push({ line: lineAt5(i), endLine: lineAt5(i), text: src.slice(i, j).replace(/^(#|\/\/)\s?/, "").trim(), s: i });
|
|
9257
9257
|
i = j;
|
|
9258
9258
|
continue;
|
|
9259
9259
|
}
|
|
9260
9260
|
if (c === "/" && src[i + 1] === "*") {
|
|
9261
9261
|
let j = src.indexOf("*/", i + 2);
|
|
9262
9262
|
if (j < 0 || j > to) j = to - 2;
|
|
9263
|
-
comments.push({ line:
|
|
9263
|
+
comments.push({ line: lineAt5(i), endLine: lineAt5(j), text: src.slice(i + 2, j).replace(/^\s*\*+/gm, "").trim(), s: i });
|
|
9264
9264
|
i = j + 2;
|
|
9265
9265
|
continue;
|
|
9266
9266
|
}
|
|
@@ -9335,12 +9335,12 @@ function tokenize(src, dialect, from = 0, to = src.length, lineAt4 = lineIndex(s
|
|
|
9335
9335
|
}
|
|
9336
9336
|
var BIN = { "??": 1, "||": 2, "&&": 3, "==": 4, "!=": 4, "=~": 4, "!~": 4, "<": 5, ">": 5, "<=": 5, ">=": 5, "+": 6, "-": 6, "*": 7, "/": 7, "%": 7 };
|
|
9337
9337
|
var Parser2 = class _Parser {
|
|
9338
|
-
constructor(src, toks2, dialect,
|
|
9338
|
+
constructor(src, toks2, dialect, lineAt5, hooks = {}) {
|
|
9339
9339
|
this.src = src;
|
|
9340
9340
|
this.toks = toks2;
|
|
9341
9341
|
this.i = 0;
|
|
9342
9342
|
this.dialect = dialect;
|
|
9343
|
-
this.lineAt =
|
|
9343
|
+
this.lineAt = lineAt5;
|
|
9344
9344
|
this.hooks = hooks;
|
|
9345
9345
|
this.skipNl = [false];
|
|
9346
9346
|
}
|
|
@@ -9853,9 +9853,9 @@ function docAbove2(comments, line) {
|
|
|
9853
9853
|
}
|
|
9854
9854
|
function parseHcl(src) {
|
|
9855
9855
|
const text2 = String(src ?? "").replace(/^/, "");
|
|
9856
|
-
const
|
|
9857
|
-
const { toks: toks2, comments } = tokenize(text2, "hcl", 0, text2.length,
|
|
9858
|
-
const p = new Parser2(text2, toks2, "hcl",
|
|
9856
|
+
const lineAt5 = lineIndex(text2);
|
|
9857
|
+
const { toks: toks2, comments } = tokenize(text2, "hcl", 0, text2.length, lineAt5);
|
|
9858
|
+
const p = new Parser2(text2, toks2, "hcl", lineAt5);
|
|
9859
9859
|
const errors = [];
|
|
9860
9860
|
const body2 = [];
|
|
9861
9861
|
for (; ; ) {
|
|
@@ -9870,7 +9870,7 @@ function parseHcl(src) {
|
|
|
9870
9870
|
p.i = resync(toks2, start);
|
|
9871
9871
|
}
|
|
9872
9872
|
}
|
|
9873
|
-
return { body: body2, comments, errors, lineAt:
|
|
9873
|
+
return { body: body2, comments, errors, lineAt: lineAt5, src: text2 };
|
|
9874
9874
|
}
|
|
9875
9875
|
function resync(toks2, i) {
|
|
9876
9876
|
let depth = 0, seen = false;
|
|
@@ -10865,9 +10865,9 @@ function ingressFacts(d, fact) {
|
|
|
10865
10865
|
// src/bicep.mjs
|
|
10866
10866
|
function parseBicep(src) {
|
|
10867
10867
|
const text2 = String(src ?? "").replace(/^/, "");
|
|
10868
|
-
const
|
|
10869
|
-
const { toks: toks2, comments } = tokenize(text2, "bicep", 0, text2.length,
|
|
10870
|
-
const p = new Parser2(text2, toks2, "bicep",
|
|
10868
|
+
const lineAt5 = lineIndex(text2);
|
|
10869
|
+
const { toks: toks2, comments } = tokenize(text2, "bicep", 0, text2.length, lineAt5);
|
|
10870
|
+
const p = new Parser2(text2, toks2, "bicep", lineAt5, { objectKey: nestedResource });
|
|
10871
10871
|
const decls = [], errors = [];
|
|
10872
10872
|
let decorators = [];
|
|
10873
10873
|
for (; ; ) {
|
|
@@ -10896,7 +10896,7 @@ function parseBicep(src) {
|
|
|
10896
10896
|
decorators = [];
|
|
10897
10897
|
}
|
|
10898
10898
|
}
|
|
10899
|
-
return { decls, comments, errors, lineAt:
|
|
10899
|
+
return { decls, comments, errors, lineAt: lineAt5, src: text2 };
|
|
10900
10900
|
}
|
|
10901
10901
|
function resync2(toks2, i) {
|
|
10902
10902
|
let depth = 0;
|
|
@@ -17250,7 +17250,7 @@ var SEMANTIC_TYPES = Object.keys(SEMANTIC);
|
|
|
17250
17250
|
var PRIMITIVE_TYPES = Object.keys(PRIMITIVE);
|
|
17251
17251
|
|
|
17252
17252
|
// src/emit.mjs
|
|
17253
|
-
var COMPILER_VERSION = "1.
|
|
17253
|
+
var COMPILER_VERSION = "1.5.0";
|
|
17254
17254
|
|
|
17255
17255
|
// src/lift.mjs
|
|
17256
17256
|
var IR_SCHEMA_VERSION = "0.1.0";
|
|
@@ -19911,7 +19911,7 @@ function sayNode(n) {
|
|
|
19911
19911
|
}
|
|
19912
19912
|
var CODE_MAX = 160;
|
|
19913
19913
|
function makeStepper(src) {
|
|
19914
|
-
const
|
|
19914
|
+
const lineAt5 = lineFinder2(src);
|
|
19915
19915
|
const codeOf2 = (n) => {
|
|
19916
19916
|
const t = src.slice(n.at, n.end).replace(/\s+/g, " ").trim();
|
|
19917
19917
|
return t.length > CODE_MAX ? `${t.slice(0, CODE_MAX - 1)}\u2026` : t;
|
|
@@ -19920,8 +19920,8 @@ function makeStepper(src) {
|
|
|
19920
19920
|
const t = src.slice(n.at, n.end).split("\n")[0].trim();
|
|
19921
19921
|
return t.length > CODE_MAX ? `${t.slice(0, CODE_MAX - 1)}\u2026` : t;
|
|
19922
19922
|
};
|
|
19923
|
-
const span = (n) => ({ startLine:
|
|
19924
|
-
const base2 = (n, code3 = codeOf2(n)) => ({ code: code3, line:
|
|
19923
|
+
const span = (n) => ({ startLine: lineAt5(n.at), endLine: lineAt5(Math.max(n.at, n.end - 1)) });
|
|
19924
|
+
const base2 = (n, code3 = codeOf2(n)) => ({ code: code3, line: lineAt5(n.at), span: span(n) });
|
|
19925
19925
|
function steps(nodes) {
|
|
19926
19926
|
const out = [];
|
|
19927
19927
|
for (let k = 0; k < nodes.length; k++) {
|
|
@@ -19933,7 +19933,7 @@ function makeStepper(src) {
|
|
|
19933
19933
|
if (ex && (ex.kind === "fail" || ex.failCode) && !ex.message) {
|
|
19934
19934
|
const code3 = ex.exitCode ?? ex.failCode;
|
|
19935
19935
|
const what = ex.exitCode ? `exit code ${code3}` : `return code ${code3}`;
|
|
19936
|
-
out.push({ kind: "fail", says: `Fails with ${what}: "${got[0].stderr}"`, error: what, message: got[0].stderr, code: `${codeOf2(n)}; ${codeOf2(next)}`, line:
|
|
19936
|
+
out.push({ kind: "fail", says: `Fails with ${what}: "${got[0].stderr}"`, error: what, message: got[0].stderr, code: `${codeOf2(n)}; ${codeOf2(next)}`, line: lineAt5(n.at), span: { startLine: lineAt5(n.at), endLine: lineAt5(next.end - 1) } });
|
|
19937
19937
|
k++;
|
|
19938
19938
|
continue;
|
|
19939
19939
|
}
|
|
@@ -19986,7 +19986,7 @@ function makeStepper(src) {
|
|
|
19986
19986
|
case "if": {
|
|
19987
19987
|
let first = null, tail = null;
|
|
19988
19988
|
for (const c of n.clauses) {
|
|
19989
|
-
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:
|
|
19989
|
+
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) };
|
|
19990
19990
|
const kids2 = steps(c.body);
|
|
19991
19991
|
if (kids2.length) b.children = kids2;
|
|
19992
19992
|
if (!first) first = b;
|
|
@@ -19999,7 +19999,7 @@ function makeStepper(src) {
|
|
|
19999
19999
|
if (n.otherwise) {
|
|
20000
20000
|
const kids2 = steps(n.otherwise);
|
|
20001
20001
|
tail.otherwise = kids2;
|
|
20002
|
-
tail.otherwiseLine =
|
|
20002
|
+
tail.otherwiseLine = lineAt5(n.elseAt);
|
|
20003
20003
|
}
|
|
20004
20004
|
return [first];
|
|
20005
20005
|
}
|
|
@@ -20048,7 +20048,7 @@ function makeStepper(src) {
|
|
|
20048
20048
|
says = `When it is ${ws.length > 1 ? `${ws.slice(0, -1).join(", ")} or ${ws.at(-1)}` : ws[0]}`;
|
|
20049
20049
|
} else says = `When it matches ${pats.map((p) => asCode3(p)).join(" or ")}`;
|
|
20050
20050
|
const kids2 = steps(a.body);
|
|
20051
|
-
return { kind: "check", says, caseLabel: true, code: src.slice(a.at, src.indexOf(")", a.at) + 1).trim().slice(0, 90), line:
|
|
20051
|
+
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 } : {} };
|
|
20052
20052
|
});
|
|
20053
20053
|
return [{ kind: "branch", says: `Chooses by ${sayWord(n.word)}`, ...base2(n, headOf2(n)), ...arms.length ? { children: arms } : {} }];
|
|
20054
20054
|
}
|
|
@@ -20107,7 +20107,7 @@ function makeStepper(src) {
|
|
|
20107
20107
|
};
|
|
20108
20108
|
return build(0);
|
|
20109
20109
|
}
|
|
20110
|
-
return { steps, lineAt:
|
|
20110
|
+
return { steps, lineAt: lineAt5, codeOf: codeOf2, headOf: headOf2 };
|
|
20111
20111
|
}
|
|
20112
20112
|
function docAbove3(lines, line) {
|
|
20113
20113
|
const run = [];
|
|
@@ -20228,7 +20228,7 @@ function shellReading(src, file = "") {
|
|
|
20228
20228
|
const last = f.body[f.body.length - 1];
|
|
20229
20229
|
if (last?.type === "simple" && last.words[0] === "exit" && /^[1-9]\d*$/.test(last.words[1] ?? "")) DIES.set(f.name, last.words[1]);
|
|
20230
20230
|
}
|
|
20231
|
-
const { steps, lineAt:
|
|
20231
|
+
const { steps, lineAt: lineAt5 } = makeStepper(src);
|
|
20232
20232
|
const errors = /* @__PURE__ */ new Map();
|
|
20233
20233
|
const noteErrors = (list3) => {
|
|
20234
20234
|
for (const s of list3 || []) {
|
|
@@ -20238,19 +20238,19 @@ function shellReading(src, file = "") {
|
|
|
20238
20238
|
}
|
|
20239
20239
|
};
|
|
20240
20240
|
for (const f of all) {
|
|
20241
|
-
const line =
|
|
20241
|
+
const line = lineAt5(f.at);
|
|
20242
20242
|
const st = steps(f.body);
|
|
20243
|
-
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:
|
|
20243
|
+
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) } });
|
|
20244
20244
|
noteErrors(st);
|
|
20245
20245
|
const first = f.body[0], lastN = f.body[f.body.length - 1];
|
|
20246
|
-
fns.push({ name: f.name, line, params: inputsOf(f.body, src), doc: docAbove3(lines, line), steps: st, body: first ? [
|
|
20246
|
+
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 });
|
|
20247
20247
|
}
|
|
20248
20248
|
const top = nodes.filter((n) => n.type !== "function");
|
|
20249
20249
|
if (top.length) {
|
|
20250
20250
|
const st = steps(top);
|
|
20251
20251
|
noteErrors(st);
|
|
20252
20252
|
const name = file ? String(file).split(/[\\/]/).pop() : "script";
|
|
20253
|
-
fns.push({ name, line:
|
|
20253
|
+
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.` });
|
|
20254
20254
|
}
|
|
20255
20255
|
fns.sort((a, b) => a.line - b.line);
|
|
20256
20256
|
KNOWN_FNS = /* @__PURE__ */ new Set();
|
|
@@ -21302,7 +21302,7 @@ function docBefore(toks2, idx) {
|
|
|
21302
21302
|
}
|
|
21303
21303
|
function makeReader(src) {
|
|
21304
21304
|
const toks2 = tokenize3(src);
|
|
21305
|
-
const
|
|
21305
|
+
const lineAt5 = lineFinder3(src);
|
|
21306
21306
|
const fns = [], things = [], errors = /* @__PURE__ */ new Map(), tests = [];
|
|
21307
21307
|
const code3 = (s, e) => {
|
|
21308
21308
|
const t = src.slice(toks2[s].at, toks2[e - 1].end).replace(/\s+/g, " ").trim();
|
|
@@ -21312,8 +21312,8 @@ function makeReader(src) {
|
|
|
21312
21312
|
const t = src.slice(toks2[s].at, toks2[e - 1].end).split("\n")[0].trim();
|
|
21313
21313
|
return t.length > 160 ? `${t.slice(0, 159)}\u2026` : t;
|
|
21314
21314
|
};
|
|
21315
|
-
const spanOf2 = (s, e) => ({ startLine:
|
|
21316
|
-
const base2 = (s, e, c = code3(s, e)) => ({ code: c, line:
|
|
21315
|
+
const spanOf2 = (s, e) => ({ startLine: lineAt5(toks2[s].at), endLine: lineAt5(toks2[e - 1].end - 1) });
|
|
21316
|
+
const base2 = (s, e, c = code3(s, e)) => ({ code: c, line: lineAt5(toks2[s].at), span: spanOf2(s, e) });
|
|
21317
21317
|
const nextTok = (i, to) => {
|
|
21318
21318
|
while (i < to && (toks2[i].t === "nl" || toks2[i].t === "comment")) i++;
|
|
21319
21319
|
return i;
|
|
@@ -21352,7 +21352,7 @@ function makeReader(src) {
|
|
|
21352
21352
|
const blk = blockAt(toks2[p].match + 1, e);
|
|
21353
21353
|
if (!blk) break;
|
|
21354
21354
|
const cond = toks2.slice(p + 1, toks2[p].match);
|
|
21355
|
-
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:
|
|
21355
|
+
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) };
|
|
21356
21356
|
const kids2 = stepsIn(blk[0], blk[1], ctx);
|
|
21357
21357
|
if (kids2.length) b.children = kids2;
|
|
21358
21358
|
if (!first) first = b;
|
|
@@ -21368,7 +21368,7 @@ function makeReader(src) {
|
|
|
21368
21368
|
const blk = blockAt(i + 1, e);
|
|
21369
21369
|
if (!blk) break;
|
|
21370
21370
|
tail.otherwise = stepsIn(blk[0], blk[1], ctx);
|
|
21371
|
-
tail.otherwiseLine =
|
|
21371
|
+
tail.otherwiseLine = lineAt5(toks2[i].at);
|
|
21372
21372
|
i = blk[1] + 1;
|
|
21373
21373
|
continue;
|
|
21374
21374
|
}
|
|
@@ -21449,7 +21449,7 @@ function makeReader(src) {
|
|
|
21449
21449
|
if (!body2) break;
|
|
21450
21450
|
const kids2 = stepsIn(body2[0], body2[1], ctx);
|
|
21451
21451
|
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}`;
|
|
21452
|
-
arms.push({ kind: "check", says: label, caseLabel: true, code: head(patStart, body2[1] + 1).slice(0, 90), line:
|
|
21452
|
+
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 });
|
|
21453
21453
|
k = body2[1] + 1;
|
|
21454
21454
|
}
|
|
21455
21455
|
for (const a of arms) delete a._pat;
|
|
@@ -21480,14 +21480,14 @@ function makeReader(src) {
|
|
|
21480
21480
|
} finally {
|
|
21481
21481
|
IN_CATCH--;
|
|
21482
21482
|
}
|
|
21483
|
-
(step.handlers ||= []).push({ says: types.length ? `If ${types.join(" or ")} goes wrong` : "If anything goes wrong", line:
|
|
21483
|
+
(step.handlers ||= []).push({ says: types.length ? `If ${types.join(" or ")} goes wrong` : "If anything goes wrong", line: lineAt5(toks2[i].at), steps: hs });
|
|
21484
21484
|
i = nextTok(b[1] + 1, e);
|
|
21485
21485
|
continue;
|
|
21486
21486
|
}
|
|
21487
21487
|
if (w === "finally") {
|
|
21488
21488
|
const b = blockAt(i + 1, e);
|
|
21489
21489
|
if (!b) break;
|
|
21490
|
-
step.always = { line:
|
|
21490
|
+
step.always = { line: lineAt5(toks2[i].at), steps: stepsIn(b[0], b[1], ctx) };
|
|
21491
21491
|
i = nextTok(b[1] + 1, e);
|
|
21492
21492
|
continue;
|
|
21493
21493
|
}
|
|
@@ -21523,8 +21523,8 @@ function makeReader(src) {
|
|
|
21523
21523
|
msg = null;
|
|
21524
21524
|
name = varWords2(rest2[0].name);
|
|
21525
21525
|
} else if (!rest2.length) return [{ kind: "fail", says: "Fails again with the same error", error: "the same error", ...base2(s, e) }];
|
|
21526
|
-
if (msg) errors.set(msg, errors.get(msg) ??
|
|
21527
|
-
else if (name !== "an error") errors.set(name, errors.get(name) ??
|
|
21526
|
+
if (msg) errors.set(msg, errors.get(msg) ?? lineAt5(t.at));
|
|
21527
|
+
else if (name !== "an error") errors.set(name, errors.get(name) ?? lineAt5(t.at));
|
|
21528
21528
|
return [{ kind: "fail", says: `Fails with ${name}${msg ? `: "${msg}"` : ""}`, error: name, ...msg ? { message: msg } : {}, ...base2(s, e) }];
|
|
21529
21529
|
}
|
|
21530
21530
|
case "return": {
|
|
@@ -21584,7 +21584,7 @@ function makeReader(src) {
|
|
|
21584
21584
|
if (/^(describe|context|it)$/i.test(t.text) && toks2[nextTok(s + 1, e)]?.t === "str") {
|
|
21585
21585
|
const name = stringText(toks2[nextTok(s + 1, e)]);
|
|
21586
21586
|
const blk = toks2.slice(s, e).find((x) => x.text === "{" && x.match != null);
|
|
21587
|
-
if (/^it$/i.test(t.text)) tests.push({ name, line:
|
|
21587
|
+
if (/^it$/i.test(t.text)) tests.push({ name, line: lineAt5(t.at) });
|
|
21588
21588
|
else if (blk) stepsIn(blk.i + 1, blk.match, ctx);
|
|
21589
21589
|
return [];
|
|
21590
21590
|
}
|
|
@@ -21649,7 +21649,7 @@ function makeReader(src) {
|
|
|
21649
21649
|
const msg = a.named.message ? sayValue2(a.named.message) : a.pos[0] ? sayValue2(a.pos[0]) : null;
|
|
21650
21650
|
const text2 = msg ? msg.replace(/^"|"$/g, "") : null;
|
|
21651
21651
|
const stops = STOP_ON_ERROR || /stop/i.test(a.named.erroraction?.map((x) => x.text).join("") ?? "");
|
|
21652
|
-
if (text2) errors.set(text2, errors.get(text2) ??
|
|
21652
|
+
if (text2) errors.set(text2, errors.get(text2) ?? lineAt5(head0.at));
|
|
21653
21653
|
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) }];
|
|
21654
21654
|
}
|
|
21655
21655
|
const lg = groups(list3);
|
|
@@ -21737,7 +21737,7 @@ function makeReader(src) {
|
|
|
21737
21737
|
if (!steps.length) steps.push({ kind: "return", says: "Does nothing", ...base2(s, e, head(s, e)) });
|
|
21738
21738
|
lastValueToReturn(steps);
|
|
21739
21739
|
const first = nextTok(parts.from, blk[1]);
|
|
21740
|
-
fns.push({ name, line:
|
|
21740
|
+
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]] });
|
|
21741
21741
|
}
|
|
21742
21742
|
function podeRoute(s, e) {
|
|
21743
21743
|
const a = argsOf(toks2.slice(s + 1, e));
|
|
@@ -21747,14 +21747,14 @@ function makeReader(src) {
|
|
|
21747
21747
|
const sb = a.named.scriptblock;
|
|
21748
21748
|
if (!sb || sb[0].text !== "{") return;
|
|
21749
21749
|
const open = sb[0].i;
|
|
21750
|
-
fns.push({ name: `${method} ${path}`, line:
|
|
21750
|
+
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)] });
|
|
21751
21751
|
}
|
|
21752
21752
|
function defineType(s, e, kw) {
|
|
21753
21753
|
const nameTok = toks2[nextTok(s + 1, e)];
|
|
21754
21754
|
const blk = toks2.slice(s, e).find((x) => x.text === "{" && x.match != null);
|
|
21755
21755
|
if (!nameTok || !blk) return;
|
|
21756
21756
|
const open = blk.i, close = blk.match;
|
|
21757
|
-
const lines = [
|
|
21757
|
+
const lines = [lineAt5(toks2[s].at), lineAt5(toks2[close].at)];
|
|
21758
21758
|
const doc = docBefore(toks2, s);
|
|
21759
21759
|
if (kw === "enum") {
|
|
21760
21760
|
const choices = [];
|
|
@@ -21771,7 +21771,7 @@ function makeReader(src) {
|
|
|
21771
21771
|
const type = st.slice(0, v).reverse().find((x) => x.t === "type");
|
|
21772
21772
|
const eq3 = st.findIndex((x, i) => i > v && x.text === "=");
|
|
21773
21773
|
const def = eq3 > 0 ? st.slice(eq3 + 1) : null;
|
|
21774
|
-
thing.knows.push({ name: st[v].name, type: type?.name ?? null, start: def ? def.map((x) => x.text).join(" ") : null, line:
|
|
21774
|
+
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) });
|
|
21775
21775
|
continue;
|
|
21776
21776
|
}
|
|
21777
21777
|
const nameAt = st.findIndex((x, i) => x.t === "word" && st[i + 1]?.text === "(");
|
|
@@ -21787,7 +21787,7 @@ function makeReader(src) {
|
|
|
21787
21787
|
const first = nextTok(bOpen + 1, body2.match);
|
|
21788
21788
|
const ret = st.slice(0, nameAt).reverse().find((x) => x.t === "type");
|
|
21789
21789
|
if (mTok.text !== nameTok.text) thing.methods++;
|
|
21790
|
-
fns.push({ name: mTok.text, line:
|
|
21790
|
+
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] });
|
|
21791
21791
|
if (mTok.text === nameTok.text) {
|
|
21792
21792
|
for (const [x, y] of splitStatements(toks2, bOpen + 1, body2.match)) {
|
|
21793
21793
|
const st2 = at0(toks2.slice(x, y));
|
|
@@ -21798,7 +21798,7 @@ function makeReader(src) {
|
|
|
21798
21798
|
const start = param ? param.default ? { param: param.default } : { given: true } : val.map((q) => q.text).join(" ");
|
|
21799
21799
|
if (k2) {
|
|
21800
21800
|
if (k2.start == null || param) k2.start = start;
|
|
21801
|
-
} else thing.knows.push({ name: st2[2].text, type: null, start, line:
|
|
21801
|
+
} else thing.knows.push({ name: st2[2].text, type: null, start, line: lineAt5(st2[0].at) });
|
|
21802
21802
|
}
|
|
21803
21803
|
}
|
|
21804
21804
|
}
|
|
@@ -21806,7 +21806,7 @@ function makeReader(src) {
|
|
|
21806
21806
|
delete thing.methods;
|
|
21807
21807
|
things.push(thing);
|
|
21808
21808
|
}
|
|
21809
|
-
return { toks: toks2, fns, things, errors, tests, stepsIn, lineAt:
|
|
21809
|
+
return { toks: toks2, fns, things, errors, tests, stepsIn, lineAt: lineAt5, splitStatements: () => splitStatements(toks2, 0, toks2.length), statement: statement2, nextTok, code: code3, cleanSteps };
|
|
21810
21810
|
}
|
|
21811
21811
|
var fixedOf = (toks2) => {
|
|
21812
21812
|
const v = at0(toks2 || []);
|
|
@@ -22885,7 +22885,7 @@ var KNOWN_FNS3 = /* @__PURE__ */ new Set();
|
|
|
22885
22885
|
function makeReader2(src) {
|
|
22886
22886
|
SRC = src;
|
|
22887
22887
|
const toks2 = tokenize4(src);
|
|
22888
|
-
const
|
|
22888
|
+
const lineAt5 = lineFinder4(src);
|
|
22889
22889
|
const fns = [], things = [], errors = /* @__PURE__ */ new Map(), tests = [], defs = [];
|
|
22890
22890
|
const code3 = (s, e) => {
|
|
22891
22891
|
const t = src.slice(toks2[s].at, toks2[e - 1].end).replace(/\s+/g, " ").trim();
|
|
@@ -22895,8 +22895,8 @@ function makeReader2(src) {
|
|
|
22895
22895
|
const t = src.slice(toks2[s].at, toks2[e - 1].end).split("\n")[0].trim();
|
|
22896
22896
|
return t.length > 160 ? `${t.slice(0, 159)}\u2026` : t;
|
|
22897
22897
|
};
|
|
22898
|
-
const spanOf2 = (s, e) => ({ startLine:
|
|
22899
|
-
const base2 = (s, e, c = code3(s, e)) => ({ code: c, line:
|
|
22898
|
+
const spanOf2 = (s, e) => ({ startLine: lineAt5(toks2[s].at), endLine: lineAt5(toks2[e - 1].end - 1) });
|
|
22899
|
+
const base2 = (s, e, c = code3(s, e)) => ({ code: c, line: lineAt5(toks2[s].at), span: spanOf2(s, e) });
|
|
22900
22900
|
const next = (i, to) => {
|
|
22901
22901
|
while (i < to && (toks2[i].t === "nl" || toks2[i].t === "comment")) i++;
|
|
22902
22902
|
return i;
|
|
@@ -22948,7 +22948,7 @@ function makeReader2(src) {
|
|
|
22948
22948
|
thenTo = elseAt >= 0 ? elseAt : e;
|
|
22949
22949
|
}
|
|
22950
22950
|
const c = condSaid(condT);
|
|
22951
|
-
const step = { kind: "branch", says: `If ${c ?? `\`${code3(open + 1, close)}\``}`, cond: condJs2(condT), code: head(s, e), line:
|
|
22951
|
+
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) };
|
|
22952
22952
|
const kids2 = stepsOfBody(close + 1, thenTo, ctx);
|
|
22953
22953
|
if (kids2.length) step.children = kids2;
|
|
22954
22954
|
if (elseAt >= 0) {
|
|
@@ -22962,7 +22962,7 @@ function makeReader2(src) {
|
|
|
22962
22962
|
}
|
|
22963
22963
|
} else {
|
|
22964
22964
|
step.otherwise = stepsOfBody(elseAt + 1, e, ctx);
|
|
22965
|
-
step.otherwiseLine =
|
|
22965
|
+
step.otherwiseLine = lineAt5(toks2[elseAt].at);
|
|
22966
22966
|
}
|
|
22967
22967
|
}
|
|
22968
22968
|
return step;
|
|
@@ -23055,7 +23055,7 @@ function makeReader2(src) {
|
|
|
23055
23055
|
const fnSteps = stepsOfBody(fv.from, fv.to, { last: true, fn: true });
|
|
23056
23056
|
if (!fnSteps.length) fnSteps.push({ kind: "return", says: "Does nothing", ...base2(nameTok.i, fv.to, head(nameTok.i, fv.to)) });
|
|
23057
23057
|
const [a, b] = bodyRange2(fv.from, fv.to);
|
|
23058
|
-
const f = { name: route && !name ? `${route.method} ${route.path}` : name, line:
|
|
23058
|
+
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 } : {} };
|
|
23059
23059
|
fns.push(f);
|
|
23060
23060
|
return f;
|
|
23061
23061
|
}
|
|
@@ -23211,11 +23211,11 @@ function makeReader2(src) {
|
|
|
23211
23211
|
const fv = fnValue(a.toks);
|
|
23212
23212
|
const r = at02(a.toks).length ? range(at02(a.toks)) : null;
|
|
23213
23213
|
if (a.name === "finally") {
|
|
23214
|
-
step.always = { line:
|
|
23214
|
+
step.always = { line: lineAt5(at02(a.toks)[0]?.at ?? toks2[s].at), steps: r ? stepsOfBody(r[0], r[1], { ...ctx, last: false }) : [] };
|
|
23215
23215
|
continue;
|
|
23216
23216
|
}
|
|
23217
23217
|
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`;
|
|
23218
|
-
(step.handlers ||= []).push({ says, line:
|
|
23218
|
+
(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 }) : [] });
|
|
23219
23219
|
}
|
|
23220
23220
|
if (target) {
|
|
23221
23221
|
for (const list3 of [step.children, ...(step.handlers || []).map((h) => h.steps)]) if (list3?.length) giveValue2({ kind: "branch", children: list3 }, target);
|
|
@@ -23236,7 +23236,7 @@ function makeReader2(src) {
|
|
|
23236
23236
|
pending = [];
|
|
23237
23237
|
const r = vtoks.length ? range(vtoks) : null;
|
|
23238
23238
|
const kids2 = r ? stepsOfBody(r[0], r[1], ctx) : [];
|
|
23239
|
-
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:
|
|
23239
|
+
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 } : {} });
|
|
23240
23240
|
}
|
|
23241
23241
|
return { kind: "branch", says: `Chooses by ${sayValue3(subject?.toks ?? []) ?? "value"}`, ...base2(s, e, head(s, e)), ...arms.length ? { children: arms } : {} };
|
|
23242
23242
|
}
|
|
@@ -23262,7 +23262,7 @@ function makeReader2(src) {
|
|
|
23262
23262
|
const isVar = parts.length === 1 && one.length === 1 && one[0].t === "id";
|
|
23263
23263
|
const single = !isVar && oneValue(parts) ? sayValue3(parts[0].toks) : null;
|
|
23264
23264
|
const msg = isVar || single || !parts.length ? null : textOf2(parts, "", bare2 === "cli_abort" || bare2 === "ui_abort");
|
|
23265
|
-
if (msg) errors.set(msg, errors.get(msg) ??
|
|
23265
|
+
if (msg) errors.set(msg, errors.get(msg) ?? lineAt5(toks2[s].at));
|
|
23266
23266
|
const cls = args.find((a) => a.name === "class");
|
|
23267
23267
|
const name = cls ? at02(cls.toks)[0]?.value ?? "an error" : "an error";
|
|
23268
23268
|
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}"` : ""}`;
|
|
@@ -23290,7 +23290,7 @@ function makeReader2(src) {
|
|
|
23290
23290
|
if (bare2 === "try") {
|
|
23291
23291
|
const r = args[0] && at02(args[0].toks).length ? range(at02(args[0].toks)) : null;
|
|
23292
23292
|
const kids2 = r ? stepsOfBody(r[0], r[1], { ...ctx, last: false }) : [];
|
|
23293
|
-
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:
|
|
23293
|
+
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: [] }] }];
|
|
23294
23294
|
}
|
|
23295
23295
|
if (bare2 === "on.exit") {
|
|
23296
23296
|
const r = args[0] && at02(args[0].toks).length ? range(at02(args[0].toks)) : null;
|
|
@@ -23304,7 +23304,7 @@ function makeReader2(src) {
|
|
|
23304
23304
|
}
|
|
23305
23305
|
if (bare2 === "test_that") {
|
|
23306
23306
|
const name = at02(args[0]?.toks ?? [])[0]?.value;
|
|
23307
|
-
if (name) tests.push({ name, line:
|
|
23307
|
+
if (name) tests.push({ name, line: lineAt5(toks2[s].at) });
|
|
23308
23308
|
return [];
|
|
23309
23309
|
}
|
|
23310
23310
|
if (bare2 === "return" || bare2 === "invisible") {
|
|
@@ -23341,7 +23341,7 @@ function makeReader2(src) {
|
|
|
23341
23341
|
return [val ? { kind: "call", says: `Works out ${val}`, ...base2(s, e) } : { kind: "other", says: code3(s, e), ...base2(s, e) }];
|
|
23342
23342
|
}
|
|
23343
23343
|
function defineThing(name, call2, s, e) {
|
|
23344
|
-
const lines = [
|
|
23344
|
+
const lines = [lineAt5(toks2[s].at), lineAt5(toks2[e - 1].end - 1)];
|
|
23345
23345
|
const className = at02(call2.args[0]?.toks ?? [])[0]?.value ?? at02(call2.args.find((a) => a.name === "Classname")?.toks ?? [])[0]?.value ?? name;
|
|
23346
23346
|
const { doc } = docAbove5(s);
|
|
23347
23347
|
const thing = { kind: "record", name: className || name, lines, ...doc ? { doc } : {}, knows: [], choices: [], memberRanges: [] };
|
|
@@ -23354,13 +23354,13 @@ function makeReader2(src) {
|
|
|
23354
23354
|
for (const a of args || []) {
|
|
23355
23355
|
if (!a.name) {
|
|
23356
23356
|
const sv = at02(a.toks)[0];
|
|
23357
|
-
if (sv?.t === "str") thing.knows.push({ name: sv.value, type: null, start: null, line:
|
|
23357
|
+
if (sv?.t === "str") thing.knows.push({ name: sv.value, type: null, start: null, line: lineAt5(sv.at) });
|
|
23358
23358
|
continue;
|
|
23359
23359
|
}
|
|
23360
23360
|
const vt = at02(a.toks);
|
|
23361
23361
|
if (fnValue(vt)) continue;
|
|
23362
23362
|
const tv = typed && vt.length === 1 && vt[0].t === "str" ? vt[0].value : null;
|
|
23363
|
-
thing.knows.push({ name: a.name, type: tv ? R_TYPE[tv] ?? tv : null, start: typed ? null : vt.map((x) => x.text).join(""), line:
|
|
23363
|
+
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) });
|
|
23364
23364
|
}
|
|
23365
23365
|
};
|
|
23366
23366
|
let methods = 0;
|
|
@@ -23369,7 +23369,7 @@ function makeReader2(src) {
|
|
|
23369
23369
|
const fv = a.name ? fnValue(a.toks) : null;
|
|
23370
23370
|
if (!fv) continue;
|
|
23371
23371
|
const f = defineFunction(a.name, fv, at02(a.toks)[0].i, toks2[at02(a.toks)[0].i - 2] ?? toks2[s]);
|
|
23372
|
-
f.line =
|
|
23372
|
+
f.line = lineAt5(toks2[at02(a.toks)[0].i - 2]?.at ?? toks2[s].at);
|
|
23373
23373
|
if (a.name !== "initialize") methods++;
|
|
23374
23374
|
if (a.name === "initialize") {
|
|
23375
23375
|
const byName = new Map(fv.params.map((p) => [p.name, p.default ? at02(p.default).map((x) => x.text).join("") : null]));
|
|
@@ -23383,7 +23383,7 @@ function makeReader2(src) {
|
|
|
23383
23383
|
const start = val.length === 1 && byName.has(val[0].text) ? { param: byName.get(val[0].text) } : val.map((q) => q.text).join("");
|
|
23384
23384
|
if (k) {
|
|
23385
23385
|
if (k.start == null || typeof start === "object") k.start = start;
|
|
23386
|
-
} else thing.knows.push({ name: field, type: null, start, line:
|
|
23386
|
+
} else thing.knows.push({ name: field, type: null, start, line: lineAt5(st[0].at) });
|
|
23387
23387
|
}
|
|
23388
23388
|
}
|
|
23389
23389
|
}
|
|
@@ -23408,7 +23408,7 @@ function makeReader2(src) {
|
|
|
23408
23408
|
thing._methods = methods;
|
|
23409
23409
|
things.push(thing);
|
|
23410
23410
|
}
|
|
23411
|
-
return { toks: toks2, fns, things, errors, tests, stepsIn, lineAt:
|
|
23411
|
+
return { toks: toks2, fns, things, errors, tests, stepsIn, lineAt: lineAt5, next, statement: statement2, code: code3, base: base2 };
|
|
23412
23412
|
}
|
|
23413
23413
|
function decisionOf2(r, fv) {
|
|
23414
23414
|
const { toks: toks2 } = r;
|
|
@@ -25301,7 +25301,7 @@ function swiftImplicitResult(text2, returns) {
|
|
|
25301
25301
|
var rebind = (guard, name, subject) => guard.replace(new RegExp(`\\b${name}\\b`, "g"), subject);
|
|
25302
25302
|
function switchArms(body2, language, baseLine) {
|
|
25303
25303
|
const arms = [];
|
|
25304
|
-
const
|
|
25304
|
+
const lineOf7 = (idx) => baseLine + lineAt(body2, idx) - 1;
|
|
25305
25305
|
if (language === "rust" || language === "csharp-expr") {
|
|
25306
25306
|
let i = 0;
|
|
25307
25307
|
while (i < body2.length) {
|
|
@@ -25324,7 +25324,7 @@ function switchArms(body2, language, baseLine) {
|
|
|
25324
25324
|
value = body2.slice(j, end2).trim();
|
|
25325
25325
|
}
|
|
25326
25326
|
const g = head.match(/^(.*?)\s+(?:if|when)\s+(.+)$/s);
|
|
25327
|
-
arms.push({ pattern: (g ? g[1] : head).trim(), guard: g ? g[2].trim() : null, value, line:
|
|
25327
|
+
arms.push({ pattern: (g ? g[1] : head).trim(), guard: g ? g[2].trim() : null, value, line: lineOf7(i) });
|
|
25328
25328
|
i = end2 + 1;
|
|
25329
25329
|
}
|
|
25330
25330
|
return arms;
|
|
@@ -25363,8 +25363,8 @@ function switchArms(body2, language, baseLine) {
|
|
|
25363
25363
|
}
|
|
25364
25364
|
const patterns = [...pending, pattern2];
|
|
25365
25365
|
pending = [];
|
|
25366
|
-
if (patterns.includes(null)) arms.push({ pattern: null, guard: null, value, line:
|
|
25367
|
-
else arms.push({ pattern: patterns.join(language === "go" && patterns.length === 1 ? "" : ", ") || patterns[0], guard: g ? g[2].trim() : null, value, line:
|
|
25366
|
+
if (patterns.includes(null)) arms.push({ pattern: null, guard: null, value, line: lineOf7(starts[k]) });
|
|
25367
|
+
else arms.push({ pattern: patterns.join(language === "go" && patterns.length === 1 ? "" : ", ") || patterns[0], guard: g ? g[2].trim() : null, value, line: lineOf7(starts[k]) });
|
|
25368
25368
|
}
|
|
25369
25369
|
return arms;
|
|
25370
25370
|
}
|
|
@@ -25657,12 +25657,12 @@ function readBraceStatements(stmts, language, inputs) {
|
|
|
25657
25657
|
}
|
|
25658
25658
|
let rest2 = t;
|
|
25659
25659
|
let ok = true;
|
|
25660
|
-
const
|
|
25660
|
+
const lineOf7 = (part) => {
|
|
25661
25661
|
const at2 = t.lastIndexOf(part);
|
|
25662
25662
|
return st.line + (at2 > 0 ? (t.slice(0, at2).match(/\n/g) || []).length : 0);
|
|
25663
25663
|
};
|
|
25664
25664
|
while (rest2) {
|
|
25665
|
-
const here =
|
|
25665
|
+
const here = lineOf7(rest2);
|
|
25666
25666
|
const head2 = rest2.match(/^(?:else\s+)?if\b\s*/);
|
|
25667
25667
|
if (!head2) break;
|
|
25668
25668
|
rest2 = rest2.slice(head2[0].length);
|
|
@@ -25715,9 +25715,9 @@ function readBraceStatements(stmts, language, inputs) {
|
|
|
25715
25715
|
const elseBody = remaining.replace(/^else\s*/, "");
|
|
25716
25716
|
const v = elseBody.startsWith("{") ? blockValue(elseBody) : elseBody.startsWith("return ") ? elseBody.slice(7).replace(/;$/, "") : null;
|
|
25717
25717
|
if (v == null) {
|
|
25718
|
-
unread.push({ line:
|
|
25718
|
+
unread.push({ line: lineOf7(remaining), text: "else", reason: "The fallback branch does more than choose an answer." });
|
|
25719
25719
|
ok = false;
|
|
25720
|
-
} else take(null, v,
|
|
25720
|
+
} else take(null, v, lineOf7(remaining));
|
|
25721
25721
|
}
|
|
25722
25722
|
rest2 = "";
|
|
25723
25723
|
}
|
|
@@ -26919,12 +26919,12 @@ function plainFromReading(item3) {
|
|
|
26919
26919
|
const whens = (item3.rules ?? []).map((r) => r.when ?? "").join(" and ");
|
|
26920
26920
|
const typed = (item3.inputs ?? []).map((i) => {
|
|
26921
26921
|
if (i.type) return i;
|
|
26922
|
-
const
|
|
26923
|
-
if (new RegExp(`\\b${
|
|
26922
|
+
const esc2 = i.name.replace(/[$]/g, "\\$");
|
|
26923
|
+
if (new RegExp(`\\b${esc2}\\s*(>=|<=|<|>|==)\\s*-?\\d`).test(whens)) {
|
|
26924
26924
|
inferred.push(i.name);
|
|
26925
26925
|
return { ...i, type: "number" };
|
|
26926
26926
|
}
|
|
26927
|
-
if (new RegExp(`(^|\\s|not\\s+|!)${
|
|
26927
|
+
if (new RegExp(`(^|\\s|not\\s+|!)${esc2}(\\s|$)`).test(whens)) {
|
|
26928
26928
|
inferred.push(i.name);
|
|
26929
26929
|
return { ...i, type: "boolean" };
|
|
26930
26930
|
}
|
|
@@ -27305,11 +27305,11 @@ function jsxChildren(src, j, tag) {
|
|
|
27305
27305
|
}
|
|
27306
27306
|
var VOID = /* @__PURE__ */ new Set(["area", "base", "br", "col", "embed", "hr", "img", "input", "link", "meta", "source", "track", "wbr"]);
|
|
27307
27307
|
function parseTemplate(html, fileSrc = null, offset = 0) {
|
|
27308
|
-
const
|
|
27308
|
+
const lineOf7 = (i2) => fileSrc ? lineAt2(fileSrc, offset + i2) : lineAt2(html, i2);
|
|
27309
27309
|
let i = 0;
|
|
27310
27310
|
const parseNodes = (stopTag, stopBrace) => {
|
|
27311
27311
|
const out = [];
|
|
27312
|
-
let text2 = "", tl =
|
|
27312
|
+
let text2 = "", tl = lineOf7(i);
|
|
27313
27313
|
const flush = () => {
|
|
27314
27314
|
if (text2.trim()) out.push(textNode(text2, tl));
|
|
27315
27315
|
text2 = "";
|
|
@@ -27336,17 +27336,17 @@ function parseTemplate(html, fileSrc = null, offset = 0) {
|
|
|
27336
27336
|
flush();
|
|
27337
27337
|
const b = parseBlock2();
|
|
27338
27338
|
if (b) out.push(b);
|
|
27339
|
-
tl =
|
|
27339
|
+
tl = lineOf7(i);
|
|
27340
27340
|
continue;
|
|
27341
27341
|
}
|
|
27342
27342
|
if (html[i] === "<" && /[A-Za-z]/.test(html[i + 1] ?? "")) {
|
|
27343
27343
|
flush();
|
|
27344
27344
|
const el = parseElement2();
|
|
27345
27345
|
if (el) out.push(el);
|
|
27346
|
-
tl =
|
|
27346
|
+
tl = lineOf7(i);
|
|
27347
27347
|
continue;
|
|
27348
27348
|
}
|
|
27349
|
-
if (!text2) tl =
|
|
27349
|
+
if (!text2) tl = lineOf7(i);
|
|
27350
27350
|
text2 += html[i];
|
|
27351
27351
|
i++;
|
|
27352
27352
|
}
|
|
@@ -27365,7 +27365,7 @@ function parseTemplate(html, fileSrc = null, offset = 0) {
|
|
|
27365
27365
|
return { type: "text", parts, line };
|
|
27366
27366
|
};
|
|
27367
27367
|
const parseElement2 = () => {
|
|
27368
|
-
const line =
|
|
27368
|
+
const line = lineOf7(i);
|
|
27369
27369
|
const tm = /^<([A-Za-z][\w:-]*)/.exec(html.slice(i));
|
|
27370
27370
|
const tag = tm[1];
|
|
27371
27371
|
i += tm[0].length;
|
|
@@ -27411,7 +27411,7 @@ function parseTemplate(html, fileSrc = null, offset = 0) {
|
|
|
27411
27411
|
return { type: "el", tag, attrs, kids: kids2, line };
|
|
27412
27412
|
};
|
|
27413
27413
|
const parseBlock2 = () => {
|
|
27414
|
-
const line =
|
|
27414
|
+
const line = lineOf7(i);
|
|
27415
27415
|
const m = /^@(\w+)\s*(?:\(([^)]*(?:\([^)]*\)[^)]*)*)\))?\s*\{/.exec(html.slice(i));
|
|
27416
27416
|
if (!m) {
|
|
27417
27417
|
const e = html.indexOf("\n", i);
|
|
@@ -28460,7 +28460,7 @@ function makeThingReaders({ words: words13, kindWords: kindWords3, startValue: s
|
|
|
28460
28460
|
return { name, label: words13(name.replace(/^[_$]+|_$/g, "")), kind, start: said, line };
|
|
28461
28461
|
};
|
|
28462
28462
|
function curlyThings(src, file, language) {
|
|
28463
|
-
const
|
|
28463
|
+
const lineAt5 = lineFinder5(src);
|
|
28464
28464
|
const out = [];
|
|
28465
28465
|
const kw = {
|
|
28466
28466
|
java: /(?:^|\n)[ \t]*(?:@\w+(?:\([^)]*\))?\s*)*(?:(?:public|private|protected|static|final|abstract|sealed|non-sealed)\s+)*(class|enum|record)\s+(\w+)\s*(?:<[^>{]*>)?\s*(\([^)]*\))?[^{;]*\{/g,
|
|
@@ -28487,7 +28487,7 @@ function makeThingReaders({ words: words13, kindWords: kindWords3, startValue: s
|
|
|
28487
28487
|
kind: isEnum ? "choices" : isRecord ? "record" : "thing",
|
|
28488
28488
|
name,
|
|
28489
28489
|
file,
|
|
28490
|
-
lines: [
|
|
28490
|
+
lines: [lineAt5(declAt), lineAt5(close >= 0 ? close : m.index + head.length)],
|
|
28491
28491
|
...docAbove4(src, declAt) ? { doc: docAbove4(src, declAt) } : {},
|
|
28492
28492
|
knows: [],
|
|
28493
28493
|
choices: []
|
|
@@ -28555,7 +28555,7 @@ function makeThingReaders({ words: words13, kindWords: kindWords3, startValue: s
|
|
|
28555
28555
|
return out;
|
|
28556
28556
|
}
|
|
28557
28557
|
function goThings(src, file) {
|
|
28558
|
-
const
|
|
28558
|
+
const lineAt5 = lineFinder5(src);
|
|
28559
28559
|
const out = [];
|
|
28560
28560
|
const byName = /* @__PURE__ */ new Map();
|
|
28561
28561
|
for (const m of src.matchAll(/(?:^|\n)type\s+(\w+)\s+struct\s*\{/g)) {
|
|
@@ -28563,7 +28563,7 @@ function makeThingReaders({ words: words13, kindWords: kindWords3, startValue: s
|
|
|
28563
28563
|
const open = m.index + m[0].length - 1;
|
|
28564
28564
|
const close = braceEnd(src, open);
|
|
28565
28565
|
if (close < 0) continue;
|
|
28566
|
-
const t = { kind: "record", name: m[1], file, lines: [
|
|
28566
|
+
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: [] };
|
|
28567
28567
|
for (const raw of src.slice(open + 1, close).split("\n")) {
|
|
28568
28568
|
const f = raw.replace(/\/\/.*$/, "").replace(/`[^`]*`/g, "").trim().match(/^([A-Za-z_]\w*(?:\s*,\s*[A-Za-z_]\w*)*)\s+(\S.*)$/);
|
|
28569
28569
|
if (f) for (const n of f[1].split(",")) t.knows.push(know(n.trim(), f[2].trim(), null, {}));
|
|
@@ -28578,7 +28578,7 @@ function makeThingReaders({ words: words13, kindWords: kindWords3, startValue: s
|
|
|
28578
28578
|
const open = src.indexOf("{", at2);
|
|
28579
28579
|
const close = open >= 0 ? braceEnd(src, open) : -1;
|
|
28580
28580
|
t.kind = "thing";
|
|
28581
|
-
t.memberRanges.push([
|
|
28581
|
+
t.memberRanges.push([lineAt5(at2), lineAt5(close >= 0 ? close : at2)]);
|
|
28582
28582
|
}
|
|
28583
28583
|
for (const m of src.matchAll(/func\s+New(\w+)\s*\(([^)]*)\)[^{]*\{/g)) {
|
|
28584
28584
|
const t = byName.get(m[1]);
|
|
@@ -28612,19 +28612,19 @@ function makeThingReaders({ words: words13, kindWords: kindWords3, startValue: s
|
|
|
28612
28612
|
const label = f[3] && /^"/.test(f[3].trim()) ? f[3].trim().slice(1, -1) : words13(f[1].replace(new RegExp(`^${name}`), "") || f[1]);
|
|
28613
28613
|
choices.push(label);
|
|
28614
28614
|
}
|
|
28615
|
-
if (choices.length) out.push({ kind: "choices", name, file, lines: [
|
|
28615
|
+
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 });
|
|
28616
28616
|
}
|
|
28617
28617
|
return out;
|
|
28618
28618
|
}
|
|
28619
28619
|
function rustThings(src, file) {
|
|
28620
|
-
const
|
|
28620
|
+
const lineAt5 = lineFinder5(src);
|
|
28621
28621
|
const out = [];
|
|
28622
28622
|
const byName = /* @__PURE__ */ new Map();
|
|
28623
28623
|
for (const m of src.matchAll(/(?:^|\n)[ \t]*(?:#\[[^\]]*\]\s*)*(?:pub(?:\([^)]*\))?\s+)?(struct|enum)\s+(\w+)\s*(?:<[^>{]*>)?\s*(?:where[^{]*)?(\{|\(|;)/g)) {
|
|
28624
28624
|
const at2 = m.index + (m[0].startsWith("\n") ? 1 : 0);
|
|
28625
28625
|
const doc = docAbove4(src, at2);
|
|
28626
28626
|
if (m[3] !== "{") {
|
|
28627
|
-
const t2 = { kind: "record", name: m[2], file, lines: [
|
|
28627
|
+
const t2 = { kind: "record", name: m[2], file, lines: [lineAt5(at2), lineAt5(at2)], ...doc ? { doc } : {}, knows: [], choices: [], memberRanges: [] };
|
|
28628
28628
|
out.push(t2);
|
|
28629
28629
|
byName.set(m[2], t2);
|
|
28630
28630
|
continue;
|
|
@@ -28633,7 +28633,7 @@ function makeThingReaders({ words: words13, kindWords: kindWords3, startValue: s
|
|
|
28633
28633
|
const close = braceEnd(src, open);
|
|
28634
28634
|
if (close < 0) continue;
|
|
28635
28635
|
const body2 = ownLevel(src.slice(open + 1, close));
|
|
28636
|
-
const t = { kind: m[1] === "enum" ? "choices" : "record", name: m[2], file, lines: [
|
|
28636
|
+
const t = { kind: m[1] === "enum" ? "choices" : "record", name: m[2], file, lines: [lineAt5(at2), lineAt5(close)], ...doc ? { doc } : {}, knows: [], choices: [], memberRanges: [] };
|
|
28637
28637
|
if (m[1] === "enum") {
|
|
28638
28638
|
for (const v of splitParams2(body2.replace(/\/\/[^\n]*/g, "").replace(/#\[[^\]]*\]/g, ""))) {
|
|
28639
28639
|
const n = v.trim().match(/^(\w+)/);
|
|
@@ -28657,7 +28657,7 @@ function makeThingReaders({ words: words13, kindWords: kindWords3, startValue: s
|
|
|
28657
28657
|
if (/\bfn\s+\w+\s*(?:<[^>]*>)?\s*\(\s*&?(?:mut\s+)?self\b/.test(src.slice(at2, close))) {
|
|
28658
28658
|
if (t.kind === "record") t.kind = "thing";
|
|
28659
28659
|
}
|
|
28660
|
-
t.memberRanges.push([
|
|
28660
|
+
t.memberRanges.push([lineAt5(at2), lineAt5(close)]);
|
|
28661
28661
|
const block = src.slice(at2, close);
|
|
28662
28662
|
const fnNew = block.match(/fn\s+new\s*\(([^)]*)\)[^{;]*\{/);
|
|
28663
28663
|
const fnOpen = fnNew ? fnNew.index + fnNew[0].length - 1 : -1;
|
|
@@ -28809,7 +28809,7 @@ function makeThingReaders({ words: words13, kindWords: kindWords3, startValue: s
|
|
|
28809
28809
|
}
|
|
28810
28810
|
function cThings(src, file) {
|
|
28811
28811
|
const code3 = src.replace(/^[ \t]*#.*(?:\\\r?\n.*)*$/gm, (m) => m.replace(/[^\n]/g, " "));
|
|
28812
|
-
const
|
|
28812
|
+
const lineAt5 = lineFinder5(code3);
|
|
28813
28813
|
const out = [];
|
|
28814
28814
|
for (const m of code3.matchAll(/(?:^|\n)[ \t]*(typedef\s+)?(struct|union|enum)\b\s*(\w+)?\s*\{/g)) {
|
|
28815
28815
|
const at2 = m.index + (m[0].startsWith("\n") ? 1 : 0);
|
|
@@ -28820,7 +28820,7 @@ function makeThingReaders({ words: words13, kindWords: kindWords3, startValue: s
|
|
|
28820
28820
|
const name = alias || m[3];
|
|
28821
28821
|
if (!name) continue;
|
|
28822
28822
|
const doc = cDocAbove(code3, at2);
|
|
28823
|
-
const t = { kind: m[2] === "enum" ? "choices" : "record", name, ...m[3] && m[3] !== name ? { tag: m[3] } : {}, file, lines: [
|
|
28823
|
+
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: [] };
|
|
28824
28824
|
const body2 = code3.slice(open + 1, close);
|
|
28825
28825
|
if (m[2] === "enum") {
|
|
28826
28826
|
t.choices = enumNames(splitParams2(body2.replace(/\/\*[\s\S]*?\*\//g, "").replace(/\/\/[^\n]*/g, "")).map((x) => (x.trim().match(/^(\w+)/) || [])[1]).filter(Boolean)).map((n) => words13(n));
|
|
@@ -28870,7 +28870,7 @@ function makeThingReaders({ words: words13, kindWords: kindWords3, startValue: s
|
|
|
28870
28870
|
}
|
|
28871
28871
|
function cppThings(src, file) {
|
|
28872
28872
|
const code3 = src.replace(/^[ \t]*#.*(?:\\\r?\n.*)*$/gm, (m) => m.replace(/[^\n]/g, " "));
|
|
28873
|
-
const
|
|
28873
|
+
const lineAt5 = lineFinder5(code3);
|
|
28874
28874
|
const out = [];
|
|
28875
28875
|
const byName = /* @__PURE__ */ new Map();
|
|
28876
28876
|
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)) {
|
|
@@ -28883,10 +28883,10 @@ function makeThingReaders({ words: words13, kindWords: kindWords3, startValue: s
|
|
|
28883
28883
|
const body2 = code3.slice(open + 1, close);
|
|
28884
28884
|
if (m[3]) {
|
|
28885
28885
|
const vals = splitParams2(body2.replace(/\/\*[\s\S]*?\*\//g, "").replace(/\/\/[^\n]*/g, "")).map((x) => (x.trim().match(/^(\w+)/) || [])[1]).filter(Boolean);
|
|
28886
|
-
out.push({ kind: "choices", name, file, lines: [
|
|
28886
|
+
out.push({ kind: "choices", name, file, lines: [lineAt5(at2), lineAt5(close)], ...doc ? { doc } : {}, knows: [], choices: enumNames(vals).map((n) => words13(n)) });
|
|
28887
28887
|
continue;
|
|
28888
28888
|
}
|
|
28889
|
-
const t = { kind: "record", name, file, lines: [
|
|
28889
|
+
const t = { kind: "record", name, file, lines: [lineAt5(at2), lineAt5(close)], ...doc ? { doc } : {}, knows: [], choices: [], memberRanges: [] };
|
|
28890
28890
|
let methods = false;
|
|
28891
28891
|
const inits = {}, params = {};
|
|
28892
28892
|
for (const mem of members(body2)) {
|
|
@@ -28925,7 +28925,7 @@ function makeThingReaders({ words: words13, kindWords: kindWords3, startValue: s
|
|
|
28925
28925
|
if (brace < 0 || semi >= 0 && semi < brace || /[()]/.test(code3.slice(pClose + 1, brace).replace(/:\s*[\s\S]*$/, ""))) continue;
|
|
28926
28926
|
methods = true;
|
|
28927
28927
|
const bClose = braceEnd(code3, brace);
|
|
28928
|
-
t.memberRanges.push([
|
|
28928
|
+
t.memberRanges.push([lineAt5(d.index), lineAt5(bClose >= 0 ? bClose : brace)]);
|
|
28929
28929
|
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);
|
|
28930
28930
|
}
|
|
28931
28931
|
for (const k of t.knows) {
|
|
@@ -28956,7 +28956,7 @@ function makeThingReaders({ words: words13, kindWords: kindWords3, startValue: s
|
|
|
28956
28956
|
for (const a of String(bodyText || "").matchAll(/(?:this->)?(\w+)\s*=\s*([^;\n]+);/g)) if (inits[a[1]] == null) inits[a[1]] = a[2];
|
|
28957
28957
|
}
|
|
28958
28958
|
function swiftThings(src, file) {
|
|
28959
|
-
const
|
|
28959
|
+
const lineAt5 = lineFinder5(src);
|
|
28960
28960
|
const out = [];
|
|
28961
28961
|
const byName = /* @__PURE__ */ new Map();
|
|
28962
28962
|
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)) {
|
|
@@ -28967,7 +28967,7 @@ function makeThingReaders({ words: words13, kindWords: kindWords3, startValue: s
|
|
|
28967
28967
|
if (close < 0) continue;
|
|
28968
28968
|
const doc = docAbove4(src, at2);
|
|
28969
28969
|
const body2 = src.slice(open + 1, close);
|
|
28970
|
-
const t = { kind: m[1] === "enum" ? "choices" : "record", name: m[2], file, lines: [
|
|
28970
|
+
const t = { kind: m[1] === "enum" ? "choices" : "record", name: m[2], file, lines: [lineAt5(at2), lineAt5(close)], ...doc ? { doc } : {}, knows: [], choices: [], memberRanges: [] };
|
|
28971
28971
|
const mems = members(body2, { newlines: true });
|
|
28972
28972
|
if (m[1] === "enum") {
|
|
28973
28973
|
for (const { head } of mems) {
|
|
@@ -29016,7 +29016,7 @@ function makeThingReaders({ words: words13, kindWords: kindWords3, startValue: s
|
|
|
29016
29016
|
const at2 = m.index + (m[0].startsWith("\n") ? 1 : 0);
|
|
29017
29017
|
const close = braceEnd(src, m.index + m[0].length - 1);
|
|
29018
29018
|
if (close < 0) continue;
|
|
29019
|
-
t.memberRanges.push([
|
|
29019
|
+
t.memberRanges.push([lineAt5(at2), lineAt5(close)]);
|
|
29020
29020
|
if (t.kind === "record" && /(?:^|\s)func\s/.test(src.slice(at2, close))) t.kind = "thing";
|
|
29021
29021
|
}
|
|
29022
29022
|
return out;
|
|
@@ -32302,13 +32302,13 @@ var Analyzer = class {
|
|
|
32302
32302
|
const sawRecord = data.some((a) => a.recs?.length || a.recFields?.length);
|
|
32303
32303
|
const sawCaller = data.some((a) => a.ident?.length);
|
|
32304
32304
|
const sawInput = data.some((a) => a.input?.length || a.unknown?.length);
|
|
32305
|
-
const
|
|
32306
|
-
if ((sawRecord || sawCaller) && (GUARDISH.test(
|
|
32305
|
+
const baseName2 = String(name).split(".").pop();
|
|
32306
|
+
if ((sawRecord || sawCaller) && (GUARDISH.test(baseName2) || sawRecord && sawCaller)) st.unresolved = uniq(st.unresolved, [{ ...ev, says: `${name}(\u2026) might check who may see it` }]);
|
|
32307
32307
|
const out = joinAll(data.map(dataOf));
|
|
32308
|
-
if (sawCaller && !GUARDISH.test(
|
|
32308
|
+
if (sawCaller && !GUARDISH.test(baseName2)) out.clientFor = { says: `${name}(\u2026)`, file: ctx.file, line };
|
|
32309
32309
|
const parts = String(name).split(".");
|
|
32310
32310
|
const ownerName = parts.length > 1 ? parts[parts.length - 2] : "";
|
|
32311
|
-
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(
|
|
32311
|
+
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));
|
|
32312
32312
|
if ((sawInput || calleeVal?.recs?.length) && dataLike) out.unknown = uniq(out.unknown, [{ ...ev, says: `${name}(\u2026)` }]);
|
|
32313
32313
|
if (calleeVal && hasData(calleeVal)) return join2(out, dataOf(calleeVal));
|
|
32314
32314
|
return out;
|
|
@@ -40076,14 +40076,14 @@ function jsonParse(text2) {
|
|
|
40076
40076
|
continue;
|
|
40077
40077
|
}
|
|
40078
40078
|
if (i + 1 >= n) throw new JsonError("Unterminated string starting at", begin);
|
|
40079
|
-
const
|
|
40080
|
-
const simple = { '"': '"', "\\": "\\", "/": "/", b: "\b", f: "\f", n: "\n", r: "\r", t: " " }[
|
|
40079
|
+
const esc2 = s[i + 1];
|
|
40080
|
+
const simple = { '"': '"', "\\": "\\", "/": "/", b: "\b", f: "\f", n: "\n", r: "\r", t: " " }[esc2];
|
|
40081
40081
|
if (simple !== void 0) {
|
|
40082
40082
|
out += simple;
|
|
40083
40083
|
i += 2;
|
|
40084
40084
|
continue;
|
|
40085
40085
|
}
|
|
40086
|
-
if (
|
|
40086
|
+
if (esc2 !== "u") throw new JsonError("Invalid \\escape", i);
|
|
40087
40087
|
const hex = s.slice(i + 2, i + 6);
|
|
40088
40088
|
if (!/^[0-9a-fA-F]{4}$/.test(hex)) throw new JsonError("Invalid \\uXXXX escape", i + 1);
|
|
40089
40089
|
let cp = parseInt(hex, 16);
|
|
@@ -42033,12 +42033,12 @@ function calleePath2(e) {
|
|
|
42033
42033
|
// src/why.mjs
|
|
42034
42034
|
function jsonObjects(text2) {
|
|
42035
42035
|
const out = [];
|
|
42036
|
-
let depth = 0, start = -1, inStr = false,
|
|
42036
|
+
let depth = 0, start = -1, inStr = false, esc2 = false;
|
|
42037
42037
|
for (let i = 0; i < text2.length; i++) {
|
|
42038
42038
|
const c = text2[i];
|
|
42039
42039
|
if (inStr) {
|
|
42040
|
-
if (
|
|
42041
|
-
else if (c === "\\")
|
|
42040
|
+
if (esc2) esc2 = false;
|
|
42041
|
+
else if (c === "\\") esc2 = true;
|
|
42042
42042
|
else if (c === '"') inStr = false;
|
|
42043
42043
|
continue;
|
|
42044
42044
|
}
|
|
@@ -42838,7 +42838,7 @@ function writeRule({ source, language, file = "", decision: name, line = null, r
|
|
|
42838
42838
|
});
|
|
42839
42839
|
if (problems.length) return fail2(...problems);
|
|
42840
42840
|
const starts = lineStartsOf(source);
|
|
42841
|
-
const
|
|
42841
|
+
const lineOf7 = (off) => {
|
|
42842
42842
|
let lo = 0, hi = starts.length - 1;
|
|
42843
42843
|
while (lo < hi) {
|
|
42844
42844
|
const m = lo + hi + 1 >> 1;
|
|
@@ -42847,7 +42847,7 @@ function writeRule({ source, language, file = "", decision: name, line = null, r
|
|
|
42847
42847
|
}
|
|
42848
42848
|
return lo + 1;
|
|
42849
42849
|
};
|
|
42850
|
-
const change = real.slice().reverse().map((e) => ({ line:
|
|
42850
|
+
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 }));
|
|
42851
42851
|
const label = (r) => r === "otherwise" ? "Otherwise" : `If ${sayCondition(r.when)}`;
|
|
42852
42852
|
const beforeRule = index === "otherwise" ? `Otherwise, the answer is ${target.result}` : `${label(target)}, the answer is ${target.result}`;
|
|
42853
42853
|
const afterRule = index === "otherwise" ? `Otherwise, the answer is ${wantResult}` : `If ${sayCondition(newWhen)}, the answer is ${wantResult}`;
|
|
@@ -42868,9 +42868,181 @@ function changedCases(before, after) {
|
|
|
42868
42868
|
var CMP_WORDS = { "<=": "at most", "<": "less than", ">=": "at least", ">": "more than", "==": "is", "!=": "is not" };
|
|
42869
42869
|
var COMPARISON_CHOICES = Object.entries(CMP_WORDS).map(([op, words13]) => ({ op, words: words13 }));
|
|
42870
42870
|
|
|
42871
|
+
// src/trace-data.mjs
|
|
42872
|
+
var lineAt4 = (text2, index) => {
|
|
42873
|
+
let n = 1;
|
|
42874
|
+
for (let i = 0; i < index && i < text2.length; i++) if (text2.charCodeAt(i) === 10) n++;
|
|
42875
|
+
return n;
|
|
42876
|
+
};
|
|
42877
|
+
var lineOf6 = (text2, re) => {
|
|
42878
|
+
const lines = text2.split("\n");
|
|
42879
|
+
for (let i = 0; i < lines.length; i++) if (re.test(lines[i])) return i + 1;
|
|
42880
|
+
return null;
|
|
42881
|
+
};
|
|
42882
|
+
var esc = (s) => s.replace(/[.*+?^${}()|[\]\\/]/g, "\\$&");
|
|
42883
|
+
var baseName = (path) => path.split("/").pop();
|
|
42884
|
+
var dirOf4 = (path) => path.includes("/") ? path.slice(0, path.lastIndexOf("/")) : "";
|
|
42885
|
+
function isManifest(path) {
|
|
42886
|
+
const n = baseName(path);
|
|
42887
|
+
return n === "package.json" || n === "go.mod" || n === "requirements.txt" || /\.csproj$/i.test(n);
|
|
42888
|
+
}
|
|
42889
|
+
function packagesIn(files) {
|
|
42890
|
+
const publishes = [], depends = [];
|
|
42891
|
+
for (const f of files) {
|
|
42892
|
+
if (!isManifest(f.path)) continue;
|
|
42893
|
+
const text2 = String(f.source ?? "");
|
|
42894
|
+
const n = baseName(f.path);
|
|
42895
|
+
try {
|
|
42896
|
+
if (n === "package.json") {
|
|
42897
|
+
const j = JSON.parse(text2);
|
|
42898
|
+
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) });
|
|
42899
|
+
for (const k of ["dependencies", "devDependencies", "peerDependencies", "optionalDependencies"]) {
|
|
42900
|
+
for (const [name, version] of Object.entries(j[k] ?? {})) {
|
|
42901
|
+
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*:`)) });
|
|
42902
|
+
}
|
|
42903
|
+
}
|
|
42904
|
+
} else if (n === "go.mod") {
|
|
42905
|
+
const lines = text2.split("\n");
|
|
42906
|
+
let inRequire = false;
|
|
42907
|
+
lines.forEach((raw, i) => {
|
|
42908
|
+
const line = raw.replace(/\/\/.*$/, "").trim();
|
|
42909
|
+
let m;
|
|
42910
|
+
if (m = line.match(/^module\s+(\S+)/)) publishes.push({ package: m[1], file: f.path, line: i + 1, root: dirOf4(f.path) });
|
|
42911
|
+
else if (/^require\s*\($/.test(line)) inRequire = true;
|
|
42912
|
+
else if (inRequire && line === ")") inRequire = false;
|
|
42913
|
+
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 });
|
|
42914
|
+
});
|
|
42915
|
+
} else if (n === "requirements.txt") {
|
|
42916
|
+
text2.split("\n").forEach((raw, i) => {
|
|
42917
|
+
const line = raw.replace(/#.*/, "").trim();
|
|
42918
|
+
if (!line || line.startsWith("-")) return;
|
|
42919
|
+
const m = line.match(/^([A-Za-z0-9][A-Za-z0-9_.-]*)(?:\[[^\]]*\])?\s*(.*)$/);
|
|
42920
|
+
if (m) depends.push({ package: m[1].toLowerCase().replace(/_/g, "-"), ...m[2] ? { version: m[2].replace(/\s*;.*$/, "").trim() } : {}, file: f.path, line: i + 1 });
|
|
42921
|
+
});
|
|
42922
|
+
} else {
|
|
42923
|
+
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) });
|
|
42924
|
+
const id = text2.match(/<PackageId>\s*([^<\s]+)\s*<\/PackageId>/);
|
|
42925
|
+
if (id) publishes.push({ package: id[1], file: f.path, line: lineAt4(text2, id.index), root: dirOf4(f.path) });
|
|
42926
|
+
}
|
|
42927
|
+
} catch {
|
|
42928
|
+
}
|
|
42929
|
+
}
|
|
42930
|
+
return { publishes, depends };
|
|
42931
|
+
}
|
|
42932
|
+
var LOCAL_VERSION = /^(workspace:|file:|link:|portal:|\.{0,2}\/|git\+|github:|https?:)/;
|
|
42933
|
+
var KEY = "([A-Za-z_][A-Za-z0-9_]*)";
|
|
42934
|
+
var Q = `["'\`]`;
|
|
42935
|
+
var SETTING_READS = [
|
|
42936
|
+
new RegExp(`\\bprocess\\.env\\.${KEY}`, "g"),
|
|
42937
|
+
new RegExp(`\\bprocess\\.env\\[\\s*${Q}${KEY}${Q}\\s*\\]`, "g"),
|
|
42938
|
+
new RegExp(`\\bimport\\.meta\\.env\\.${KEY}`, "g"),
|
|
42939
|
+
new RegExp(`\\bDeno\\.env\\.get\\(\\s*${Q}${KEY}${Q}`, "g"),
|
|
42940
|
+
new RegExp(`\\b(?:os\\.)?environ(?:\\.get)?\\s*[\\[(]\\s*${Q}${KEY}${Q}`, "g"),
|
|
42941
|
+
new RegExp(`\\bos\\.getenv\\(\\s*${Q}${KEY}${Q}`, "g"),
|
|
42942
|
+
new RegExp(`\\bos\\.(?:Getenv|LookupEnv)\\(\\s*"${KEY}"`, "g"),
|
|
42943
|
+
new RegExp(`\\bSystem\\.getenv\\(\\s*"${KEY}"`, "g"),
|
|
42944
|
+
new RegExp(`\\bEnvironment\\.GetEnvironmentVariable\\(\\s*"${KEY}"`, "g"),
|
|
42945
|
+
new RegExp(`\\bENV(?:\\.fetch\\(\\s*|\\[\\s*)${Q}${KEY}${Q}`, "g"),
|
|
42946
|
+
new RegExp(`\\benv::var(?:_os)?\\(\\s*"${KEY}"`, "g"),
|
|
42947
|
+
new RegExp(`\\bgetenv\\(\\s*${Q}${KEY}${Q}`, "g"),
|
|
42948
|
+
new RegExp(`\\$_ENV\\[\\s*${Q}${KEY}${Q}`, "g")
|
|
42949
|
+
];
|
|
42950
|
+
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);
|
|
42951
|
+
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"]);
|
|
42952
|
+
function settingsIn(files) {
|
|
42953
|
+
const out = [];
|
|
42954
|
+
for (const f of files) {
|
|
42955
|
+
if (isManifest(f.path) || /\.sql$/i.test(f.path)) continue;
|
|
42956
|
+
const text2 = String(f.source ?? "");
|
|
42957
|
+
if (!/env/i.test(text2)) continue;
|
|
42958
|
+
const seen = /* @__PURE__ */ new Set();
|
|
42959
|
+
for (const re of SETTING_READS) {
|
|
42960
|
+
for (const m of text2.matchAll(re)) {
|
|
42961
|
+
const line = lineAt4(text2, m.index);
|
|
42962
|
+
const k = `${m[1]}|${line}`;
|
|
42963
|
+
if (seen.has(k)) continue;
|
|
42964
|
+
seen.add(k);
|
|
42965
|
+
out.push({ key: m[1], file: f.path, line });
|
|
42966
|
+
}
|
|
42967
|
+
}
|
|
42968
|
+
}
|
|
42969
|
+
return out.sort((a, b) => a.file.localeCompare(b.file) || a.line - b.line || a.key.localeCompare(b.key));
|
|
42970
|
+
}
|
|
42971
|
+
var NAME = '((?:[`"\\[]?[A-Za-z_][\\w$]*[`"\\]]?\\.){0,2}[`"\\[]?[A-Za-z_][\\w$]*[`"\\]]?)';
|
|
42972
|
+
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"]);
|
|
42973
|
+
function tableName(raw) {
|
|
42974
|
+
const name = raw.replace(/[`"[\]]/g, "");
|
|
42975
|
+
return { table: name.split(".").pop().toLowerCase(), name };
|
|
42976
|
+
}
|
|
42977
|
+
function usesIn(sql, offsetOf, push) {
|
|
42978
|
+
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");
|
|
42979
|
+
for (const m of sql.matchAll(re)) {
|
|
42980
|
+
const kw = m[1].toUpperCase().replace(/\s+/g, " ");
|
|
42981
|
+
if (m[3] && (kw === "FROM" || kw === "JOIN")) continue;
|
|
42982
|
+
const { table, name } = tableName(m[2]);
|
|
42983
|
+
if (NOT_TABLES.has(table) || NOT_TABLES.has(name.toLowerCase())) continue;
|
|
42984
|
+
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;
|
|
42985
|
+
push({ table, name, access: kw === "FROM" || kw === "JOIN" ? "reads" : "writes", at: offsetOf(m.index) });
|
|
42986
|
+
}
|
|
42987
|
+
}
|
|
42988
|
+
var SQL_SHAPES = [
|
|
42989
|
+
/^\s*SELECT\b[\s\S]*?\bFROM\s/i,
|
|
42990
|
+
/^\s*INSERT\s+(?:OR\s+\w+\s+)?INTO\s/i,
|
|
42991
|
+
/^\s*UPDATE\s+[\w."`[\]]+\s+(?:(?:AS\s+)?\w+\s+)?SET\s/i,
|
|
42992
|
+
/^\s*DELETE\s+FROM\s/i,
|
|
42993
|
+
/^\s*WITH\s+(?:RECURSIVE\s+)?\w+\s+AS\s*\(/i,
|
|
42994
|
+
/^\s*MERGE\s+INTO\s/i
|
|
42995
|
+
];
|
|
42996
|
+
var isSql = (text2) => SQL_SHAPES.some((re) => re.test(text2));
|
|
42997
|
+
var CODE_STRINGS = /"""([\s\S]*?)"""|'''([\s\S]*?)'''|`((?:\\[\s\S]|[^`\\])*)`|"((?:\\.|[^"\\\n])*)"|'((?:\\.|[^'\\\n])*)'/g;
|
|
42998
|
+
function tablesIn(files) {
|
|
42999
|
+
const out = [];
|
|
43000
|
+
for (const f of files) {
|
|
43001
|
+
if (isManifest(f.path)) continue;
|
|
43002
|
+
const text2 = String(f.source ?? "");
|
|
43003
|
+
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)] } : {} });
|
|
43004
|
+
if (/\.sql$/i.test(f.path)) {
|
|
43005
|
+
const clean = text2.replace(/--[^\n]*/g, (s) => " ".repeat(s.length)).replace(/\/\*[\s\S]*?\*\//g, (s) => s.replace(/[^\n]/g, " "));
|
|
43006
|
+
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");
|
|
43007
|
+
const ddlSpans = [];
|
|
43008
|
+
for (const m of clean.matchAll(ddl)) {
|
|
43009
|
+
const { table, name } = tableName(m[2]);
|
|
43010
|
+
if (NOT_TABLES.has(table)) continue;
|
|
43011
|
+
const kw = m[1].toUpperCase();
|
|
43012
|
+
if (/TEMP/.test(kw)) continue;
|
|
43013
|
+
const end2 = clean.indexOf(";", m.index);
|
|
43014
|
+
const stop = end2 < 0 ? clean.length : end2;
|
|
43015
|
+
ddlSpans.push([m.index, stop]);
|
|
43016
|
+
push({ table, name, access: kw.startsWith("CREATE") ? "creates" : kw.startsWith("ALTER") ? "alters" : "drops", at: m.index, end: stop });
|
|
43017
|
+
}
|
|
43018
|
+
const roles = [...clean.matchAll(/\b(?:GRANT|REVOKE)\b[^;]*/gi)].map((m) => [m.index, m.index + m[0].length]);
|
|
43019
|
+
const skip = [...ddlSpans, ...roles];
|
|
43020
|
+
usesIn(clean, (i) => i, (u) => {
|
|
43021
|
+
if (!skip.some(([a, b]) => u.at >= a && u.at <= b)) push(u);
|
|
43022
|
+
});
|
|
43023
|
+
continue;
|
|
43024
|
+
}
|
|
43025
|
+
if (!/\b(SELECT|INSERT|UPDATE|DELETE|MERGE)\b/i.test(text2)) continue;
|
|
43026
|
+
for (const m of text2.matchAll(CODE_STRINGS)) {
|
|
43027
|
+
const body2 = m[1] ?? m[2] ?? m[3] ?? m[4] ?? m[5] ?? "";
|
|
43028
|
+
if (!isSql(body2)) continue;
|
|
43029
|
+
const start = m.index + m[0].indexOf(body2);
|
|
43030
|
+
usesIn(body2, (i) => start + i, push);
|
|
43031
|
+
}
|
|
43032
|
+
}
|
|
43033
|
+
const seen = /* @__PURE__ */ new Set();
|
|
43034
|
+
return out.filter((t) => {
|
|
43035
|
+
const k = `${t.file}|${t.line}|${t.table}|${t.access}`;
|
|
43036
|
+
if (seen.has(k)) return false;
|
|
43037
|
+
seen.add(k);
|
|
43038
|
+
return true;
|
|
43039
|
+
}).sort((a, b) => a.file.localeCompare(b.file) || a.line - b.line || a.table.localeCompare(b.table));
|
|
43040
|
+
}
|
|
43041
|
+
var DEFINES = /* @__PURE__ */ new Set(["creates", "alters", "drops"]);
|
|
43042
|
+
|
|
42871
43043
|
// src/trace.mjs
|
|
42872
43044
|
var TRACE_SCHEMA = "thunder-trace-v1";
|
|
42873
|
-
var TRACE_RULES_VERSION = "
|
|
43045
|
+
var TRACE_RULES_VERSION = "2";
|
|
42874
43046
|
function isTestFile(file) {
|
|
42875
43047
|
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);
|
|
42876
43048
|
}
|
|
@@ -42890,7 +43062,8 @@ function buildTrace(repos) {
|
|
|
42890
43062
|
const model = thunderModel(r.files, { name: r.name });
|
|
42891
43063
|
const facts = serviceFacts(model, r.files);
|
|
42892
43064
|
const real = (x) => !isTestFile(x.file);
|
|
42893
|
-
const
|
|
43065
|
+
const data = dataFacts(r.files, model);
|
|
43066
|
+
const testItems = ["routes", "listeners", "requests", "publishes"].reduce((n, k) => n + facts[k].filter((x) => !real(x)).length, 0) + data.testItems;
|
|
42894
43067
|
return {
|
|
42895
43068
|
name: r.name,
|
|
42896
43069
|
sha: r.sha ?? null,
|
|
@@ -42902,11 +43075,35 @@ function buildTrace(repos) {
|
|
|
42902
43075
|
requests: facts.requests.filter(real),
|
|
42903
43076
|
publishes: facts.publishes.filter(real),
|
|
42904
43077
|
unknown: facts.unknown.filter(real),
|
|
43078
|
+
packages: data.packages,
|
|
43079
|
+
settings: data.settings,
|
|
43080
|
+
tables: data.tables,
|
|
42905
43081
|
testItems
|
|
42906
43082
|
};
|
|
42907
43083
|
});
|
|
42908
43084
|
return linkRepos(read);
|
|
42909
43085
|
}
|
|
43086
|
+
function memberAt(model, file, line) {
|
|
43087
|
+
let best = null;
|
|
43088
|
+
for (const m of model.members) {
|
|
43089
|
+
if (m.file !== file || !m.lines || line < m.lines[0] || line > m.lines[1]) continue;
|
|
43090
|
+
if (!best || m.lines[1] - m.lines[0] < best.lines[1] - best.lines[0]) best = m;
|
|
43091
|
+
}
|
|
43092
|
+
return best ? { member: best.id, label: best.label } : { member: null, label: file.split("/").pop() };
|
|
43093
|
+
}
|
|
43094
|
+
function dataFacts(files, model) {
|
|
43095
|
+
const real = (x) => !isTestFile(x.file);
|
|
43096
|
+
const pk = packagesIn(files), settings = settingsIn(files), tables = tablesIn(files);
|
|
43097
|
+
const place = (x) => ({ ...x, ...memberAt(model, x.file, x.line) });
|
|
43098
|
+
const manifest = (x) => ({ ...x, member: null, label: x.file });
|
|
43099
|
+
const testItems = [...pk.publishes, ...pk.depends, ...settings, ...tables].filter((x) => !real(x)).length;
|
|
43100
|
+
return {
|
|
43101
|
+
packages: { publishes: pk.publishes.filter(real).map(manifest), depends: pk.depends.filter(real).map(manifest) },
|
|
43102
|
+
settings: settings.filter(real).map(place),
|
|
43103
|
+
tables: tables.filter(real).map((t) => /\.sql$/i.test(t.file) ? { ...t, member: null, label: t.file } : place(t)),
|
|
43104
|
+
testItems
|
|
43105
|
+
};
|
|
43106
|
+
}
|
|
42910
43107
|
function linkRepos(read) {
|
|
42911
43108
|
const links = [], notLinked = [];
|
|
42912
43109
|
for (const repo of read) {
|
|
@@ -42948,7 +43145,33 @@ function linkRepos(read) {
|
|
|
42948
43145
|
if (!found) notLinked.push({ kind: "event", call: `event ${p.event}`, from, why: `no listener Thunder read in the traced repositories waits for ${p.event}` });
|
|
42949
43146
|
}
|
|
42950
43147
|
}
|
|
42951
|
-
const
|
|
43148
|
+
const pk = (r) => r.packages ?? { publishes: [], depends: [] };
|
|
43149
|
+
const publishers = /* @__PURE__ */ new Map();
|
|
43150
|
+
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 });
|
|
43151
|
+
for (const repo of read) {
|
|
43152
|
+
const own = new Set(pk(repo).publishes.map((p) => p.package));
|
|
43153
|
+
for (const d of pk(repo).depends) {
|
|
43154
|
+
if (own.has(d.package)) continue;
|
|
43155
|
+
const pubs = (publishers.get(d.package) ?? []).filter((x) => x.repo !== repo);
|
|
43156
|
+
const byRepo = [...new Map(pubs.map((x) => [x.repo.name, x])).values()];
|
|
43157
|
+
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) });
|
|
43158
|
+
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` });
|
|
43159
|
+
}
|
|
43160
|
+
}
|
|
43161
|
+
const tb = (r) => r.tables ?? [];
|
|
43162
|
+
const creators = /* @__PURE__ */ new Map();
|
|
43163
|
+
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 });
|
|
43164
|
+
for (const repo of read) {
|
|
43165
|
+
const own = new Set(tb(repo).filter((t) => t.access === "creates").map((t) => t.table));
|
|
43166
|
+
for (const t of tb(repo)) {
|
|
43167
|
+
if (DEFINES.has(t.access) || own.has(t.table)) continue;
|
|
43168
|
+
const owners = [...new Map((creators.get(t.table) ?? []).filter((x) => x.repo !== repo).map((x) => [x.repo.name, x])).values()];
|
|
43169
|
+
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) });
|
|
43170
|
+
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` });
|
|
43171
|
+
}
|
|
43172
|
+
}
|
|
43173
|
+
const shared = sharedFacts(read);
|
|
43174
|
+
const sortKey = (l) => `${l.from.cite}|${l.to?.cite ?? ""}|${l.kind}|${l.call ?? l.event ?? l.path ?? l.package ?? l.table ?? ""}`;
|
|
42952
43175
|
const once = (xs) => {
|
|
42953
43176
|
const seen = /* @__PURE__ */ new Set();
|
|
42954
43177
|
return xs.filter((x) => {
|
|
@@ -42960,10 +43183,29 @@ function linkRepos(read) {
|
|
|
42960
43183
|
};
|
|
42961
43184
|
links.splice(0, links.length, ...once(links).sort((a, b) => sortKey(a).localeCompare(sortKey(b))));
|
|
42962
43185
|
notLinked.splice(0, notLinked.length, ...once(notLinked).sort((a, b) => sortKey(a).localeCompare(sortKey(b))));
|
|
42963
|
-
const repos = read.map(({ unknown, ...r }) => ({ ...r, unknown: unknown ?? [] }));
|
|
42964
|
-
const body2 = { schema: TRACE_SCHEMA, rulesVersion: TRACE_RULES_VERSION, repos, links, notLinked };
|
|
43186
|
+
const repos = read.map(({ unknown, ...r }) => ({ ...r, unknown: unknown ?? [], packages: pk(r), settings: r.settings ?? [], tables: tb(r) }));
|
|
43187
|
+
const body2 = { schema: TRACE_SCHEMA, rulesVersion: TRACE_RULES_VERSION, repos, links, notLinked, shared };
|
|
42965
43188
|
return { ...body2, fingerprint: sha256(JSON.stringify(body2)) };
|
|
42966
43189
|
}
|
|
43190
|
+
function sharedFacts(read) {
|
|
43191
|
+
const group = (items) => {
|
|
43192
|
+
const m = /* @__PURE__ */ new Map();
|
|
43193
|
+
for (const [k, repo, x] of items) (m.get(k) ?? m.set(k, []).get(k)).push({ repo, x });
|
|
43194
|
+
return m;
|
|
43195
|
+
};
|
|
43196
|
+
const manyRepos = (xs) => new Set(xs.map((y) => y.repo.name)).size > 1;
|
|
43197
|
+
const byKey = (a, b) => a[0] < b[0] ? -1 : a[0] > b[0] ? 1 : 0;
|
|
43198
|
+
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)) }));
|
|
43199
|
+
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 })) }));
|
|
43200
|
+
const drift = [];
|
|
43201
|
+
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)) {
|
|
43202
|
+
const versions = group(xs.map(({ repo, x }) => [x.version, repo, x]));
|
|
43203
|
+
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("|")));
|
|
43204
|
+
if (!manyRepos(xs) || versions.size < 2 || perRepo.size < 2) continue;
|
|
43205
|
+
drift.push({ package: name, versions: [...versions.entries()].sort(byKey).map(([version, ys]) => ({ version, at: ys.map(({ repo, x }) => end(repo, x)) })) });
|
|
43206
|
+
}
|
|
43207
|
+
return { settings, tables, drift };
|
|
43208
|
+
}
|
|
42967
43209
|
var methodOk = (route, req) => route === req || route === "ANY" || route === "ALL";
|
|
42968
43210
|
|
|
42969
43211
|
// src/write-across.mjs
|
|
@@ -43935,7 +44177,8 @@ function assemblePassport({ parts, change = null, runs = [], purpose = null, ext
|
|
|
43935
44177
|
}
|
|
43936
44178
|
const shownBehavior = behavior.slice(0, MAX_BEHAVIOR);
|
|
43937
44179
|
const trace = buildTrace(parts.map((p) => ({ name: p.name, sha: p.sha ?? null, dirty: !!p.dirty, files: p.files.filter((f) => !f.manifest) })));
|
|
43938
|
-
const
|
|
44180
|
+
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`;
|
|
44181
|
+
const links = trace.links.map((l) => ({ kind: l.kind, says: linkSays(l), from: l.from.cite, to: l.to.cite }));
|
|
43939
44182
|
const services = [];
|
|
43940
44183
|
for (const r of trace.repos) for (const q of r.requests ?? []) if (q.base && q.base !== "this app") services.push({ part: r.name, calls: `${q.method} ${q.base}${q.path}`, at: `${r.name}:${q.file}:${q.line}` });
|
|
43941
44184
|
const evidence = [];
|
|
@@ -43956,7 +44199,7 @@ function assemblePassport({ parts, change = null, runs = [], purpose = null, ext
|
|
|
43956
44199
|
add2({
|
|
43957
44200
|
kind: "trace-link",
|
|
43958
44201
|
status: "read",
|
|
43959
|
-
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.`,
|
|
44202
|
+
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.`,
|
|
43960
44203
|
basis: { from: l.from.cite, to: l.to.cite, rules: `thunder-trace rules v${trace.rulesVersion}` },
|
|
43961
44204
|
scope: "Read from code; nothing was run. It does not show that the call succeeds or what it answers.",
|
|
43962
44205
|
inputs: [inputOf(l.from.repo, l.from.file), inputOf(l.to.repo, l.to.file)]
|