@mantaq/inspect 0.2.1 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.mjs +1 -1
- package/dist/index.d.mts +1 -0
- package/dist/index.mjs +1 -1
- package/dist/{load-DOwsxTyL.mjs → load-Dw5KOFuM.mjs} +24 -3
- package/dist/vite.mjs +1 -1
- package/package.json +7 -7
package/dist/cli.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { l as vizDocument, r as inspectFile } from "./load-
|
|
2
|
+
import { l as vizDocument, r as inspectFile } from "./load-Dw5KOFuM.mjs";
|
|
3
3
|
import { t as htmlPage } from "./page-rr9IQ-4k.mjs";
|
|
4
4
|
import { serializeViz } from "@mantaq/viz";
|
|
5
5
|
import { Either } from "@mantaq/utils";
|
package/dist/index.d.mts
CHANGED
|
@@ -123,6 +123,7 @@ interface ModuleAnalysis {
|
|
|
123
123
|
sites: HandlerSite[];
|
|
124
124
|
stateDocs: ReadonlyMap<string, string>;
|
|
125
125
|
eventDocs: ReadonlyMap<string, string>;
|
|
126
|
+
effectDocs: ReadonlyMap<string, ReadonlyArray<string>>;
|
|
126
127
|
payloads: Record<string, VizJson[]>;
|
|
127
128
|
machines: MachineExport[];
|
|
128
129
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { S as toVizMachine, _ as fuzzedMachine, a as inspect, b as shrink, d as analyzeSource, f as annotateMachine, g as literalPool, h as guidance, l as vizDocument, m as branchDistanceGuide, o as inspectModule, p as branchDistance, r as inspectFile, s as machineId, u as analyzeModule, v as withTestCoverage, x as toViz, y as fuzz } from "./load-
|
|
1
|
+
import { S as toVizMachine, _ as fuzzedMachine, a as inspect, b as shrink, d as analyzeSource, f as annotateMachine, g as literalPool, h as guidance, l as vizDocument, m as branchDistanceGuide, o as inspectModule, p as branchDistance, r as inspectFile, s as machineId, u as analyzeModule, v as withTestCoverage, x as toViz, y as fuzz } from "./load-Dw5KOFuM.mjs";
|
|
2
2
|
import { i as execute, r as eventCatalog } from "./run-B5huYj_r.mjs";
|
|
3
3
|
import { t as htmlPage } from "./page-rr9IQ-4k.mjs";
|
|
4
4
|
export { analyzeModule, analyzeSource, annotateMachine, branchDistance, branchDistanceGuide, eventCatalog, execute, fuzz, fuzzedMachine, guidance, htmlPage, inspect, inspectFile, inspectModule, literalPool, machineId, shrink, toViz, toVizMachine, vizDocument, withTestCoverage };
|
|
@@ -793,6 +793,15 @@ function callDoc(call) {
|
|
|
793
793
|
while (ts.isPropertyAccessExpression(top.parent) || ts.isCallExpression(top.parent)) top = top.parent;
|
|
794
794
|
return docOf(ts.isExpressionStatement(top.parent) ? top.parent : call);
|
|
795
795
|
}
|
|
796
|
+
function collectEffectDoc(checker, call, effectDocs) {
|
|
797
|
+
if (!ts.isPropertyAccessExpression(call.expression) || call.expression.name.text !== "effect") return;
|
|
798
|
+
const [stateArg] = call.arguments;
|
|
799
|
+
if (stateArg === void 0) return;
|
|
800
|
+
const state = literalProperty(checker, stateArg, "name");
|
|
801
|
+
const doc = callDoc(call);
|
|
802
|
+
if (state === null || doc === null) return;
|
|
803
|
+
effectDocs.set(state, [...effectDocs.get(state) ?? [], doc]);
|
|
804
|
+
}
|
|
796
805
|
function compilerOptions(source) {
|
|
797
806
|
const configPath = source.tsconfig ?? ts.findConfigFile(dirname(source.file), (path) => ts.sys.fileExists(path));
|
|
798
807
|
if (configPath === void 0) return {
|
|
@@ -880,6 +889,7 @@ function loadSource(source) {
|
|
|
880
889
|
const registrations = [];
|
|
881
890
|
const stateDocs = /* @__PURE__ */ new Map();
|
|
882
891
|
const eventDocs = /* @__PURE__ */ new Map();
|
|
892
|
+
const effectDocs = /* @__PURE__ */ new Map();
|
|
883
893
|
const visit = (node) => {
|
|
884
894
|
const found = ts.isCallExpression(node) ? toRegistration(checker, node) : null;
|
|
885
895
|
if (found) registrations.push(found);
|
|
@@ -888,6 +898,7 @@ function loadSource(source) {
|
|
|
888
898
|
eventDocs
|
|
889
899
|
});
|
|
890
900
|
ts.forEachChild(node, visit);
|
|
901
|
+
if (ts.isCallExpression(node)) collectEffectDoc(checker, node, effectDocs);
|
|
891
902
|
};
|
|
892
903
|
visit(sourceFile);
|
|
893
904
|
return {
|
|
@@ -896,7 +907,8 @@ function loadSource(source) {
|
|
|
896
907
|
root: source.root,
|
|
897
908
|
registrations,
|
|
898
909
|
stateDocs,
|
|
899
|
-
eventDocs
|
|
910
|
+
eventDocs,
|
|
911
|
+
effectDocs
|
|
900
912
|
};
|
|
901
913
|
});
|
|
902
914
|
if (Either.isLeft(loaded)) return Either.left(`compiler failed: ${String(loaded[0])}`);
|
|
@@ -1444,7 +1456,8 @@ function docsOf(loaded) {
|
|
|
1444
1456
|
return {
|
|
1445
1457
|
sites: sitesOf(loaded),
|
|
1446
1458
|
stateDocs: loaded.stateDocs,
|
|
1447
|
-
eventDocs: loaded.eventDocs
|
|
1459
|
+
eventDocs: loaded.eventDocs,
|
|
1460
|
+
effectDocs: loaded.effectDocs
|
|
1448
1461
|
};
|
|
1449
1462
|
}
|
|
1450
1463
|
/** Handlers, payload samples and machine exports of a file, from one TypeScript program. */
|
|
@@ -1460,10 +1473,17 @@ function localState(id) {
|
|
|
1460
1473
|
return id.slice(id.lastIndexOf(".") + 1);
|
|
1461
1474
|
}
|
|
1462
1475
|
function explain(edge, context) {
|
|
1463
|
-
if (edge.kind === "initial"
|
|
1476
|
+
if (edge.kind === "initial") return {
|
|
1464
1477
|
explanation: null,
|
|
1465
1478
|
doc: null
|
|
1466
1479
|
};
|
|
1480
|
+
if (edge.kind === "effect") {
|
|
1481
|
+
const docs = context.effectDocs.get(localState(edge.from));
|
|
1482
|
+
return {
|
|
1483
|
+
explanation: null,
|
|
1484
|
+
doc: docs === void 0 ? null : docs.join("\n\n")
|
|
1485
|
+
};
|
|
1486
|
+
}
|
|
1467
1487
|
const state = localState(edge.from);
|
|
1468
1488
|
const site = context.sites.find((candidate) => candidate.state === state && candidate.event === edge.event) ?? context.sites.find((candidate) => candidate.state === null && candidate.event === edge.event);
|
|
1469
1489
|
if (site) return {
|
|
@@ -1513,6 +1533,7 @@ function annotateWith(machine, context) {
|
|
|
1513
1533
|
...edge,
|
|
1514
1534
|
...explain(edge, {
|
|
1515
1535
|
sites: analysis[1].sites,
|
|
1536
|
+
effectDocs: analysis[1].effectDocs,
|
|
1516
1537
|
file
|
|
1517
1538
|
})
|
|
1518
1539
|
};
|
package/dist/vite.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as projectRoot, i as runOf, l as vizDocument, n as inspectEntry, s as machineId, t as entryId, u as analyzeModule } from "./load-
|
|
1
|
+
import { c as projectRoot, i as runOf, l as vizDocument, n as inspectEntry, s as machineId, t as entryId, u as analyzeModule } from "./load-Dw5KOFuM.mjs";
|
|
2
2
|
import { UPDATE_EVENT, livePageHtml, serializeViz } from "@mantaq/viz";
|
|
3
3
|
import { Either } from "@mantaq/utils";
|
|
4
4
|
import { dirname, isAbsolute, resolve } from "node:path";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mantaq/inspect",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"description": "Turn a Mantaq machine into a viz document: structure, handler explanations (AST), fuzz and test coverage. CLI and Vite plugin included.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -27,11 +27,11 @@
|
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"typescript": "6.0.3",
|
|
30
|
-
"@mantaq/
|
|
31
|
-
"@mantaq/
|
|
32
|
-
"@mantaq/
|
|
33
|
-
"@mantaq/viz": "0.2.
|
|
34
|
-
"@mantaq/
|
|
30
|
+
"@mantaq/core": "0.5.3",
|
|
31
|
+
"@mantaq/pbt": "0.0.4",
|
|
32
|
+
"@mantaq/utils": "0.0.5",
|
|
33
|
+
"@mantaq/viz": "0.2.3",
|
|
34
|
+
"@mantaq/traversal": "0.3.3"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@types/node": "^26.2.0",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"happy-dom": "^21.0.4",
|
|
40
40
|
"vite": "npm:@voidzero-dev/vite-plus-core@1.4.0",
|
|
41
41
|
"vite-plus": "1.4.0",
|
|
42
|
-
"@mantaq/sugar": "2.0.
|
|
42
|
+
"@mantaq/sugar": "2.0.3"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"vite": "*"
|