@fairfox/polly 0.2.0 → 0.3.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/dist/vendor/verify/specs/Dockerfile +13 -0
- package/dist/vendor/verify/specs/README.md +37 -0
- package/dist/vendor/verify/specs/docker-compose.yml +9 -0
- package/dist/vendor/verify/specs/tla/MessageRouter.cfg +24 -0
- package/dist/vendor/verify/specs/tla/MessageRouter.tla +221 -0
- package/dist/vendor/verify/specs/tla/README.md +179 -0
- package/dist/vendor/verify/specs/verification.config.ts +61 -0
- package/dist/vendor/verify/src/cli.js +109 -5
- package/dist/vendor/verify/src/cli.js.map +5 -5
- package/dist/vendor/visualize/src/cli.js +665 -55
- package/dist/vendor/visualize/src/cli.js.map +12 -11
- package/package.json +1 -1
|
@@ -757,7 +757,7 @@ class HandlerExtractor {
|
|
|
757
757
|
const expression = node.getExpression();
|
|
758
758
|
if (Node.isPropertyAccessExpression(expression)) {
|
|
759
759
|
const methodName = expression.getName();
|
|
760
|
-
if (methodName === "on") {
|
|
760
|
+
if (methodName === "on" || methodName === "addEventListener") {
|
|
761
761
|
const handler = this.extractHandler(node, context, filePath);
|
|
762
762
|
if (handler) {
|
|
763
763
|
handlers.push(handler);
|
|
@@ -765,6 +765,14 @@ class HandlerExtractor {
|
|
|
765
765
|
}
|
|
766
766
|
}
|
|
767
767
|
}
|
|
768
|
+
if (Node.isSwitchStatement(node)) {
|
|
769
|
+
const switchHandlers = this.extractSwitchCaseHandlers(node, context, filePath);
|
|
770
|
+
handlers.push(...switchHandlers);
|
|
771
|
+
}
|
|
772
|
+
if (Node.isVariableDeclaration(node)) {
|
|
773
|
+
const mapHandlers = this.extractHandlerMapPattern(node, context, filePath);
|
|
774
|
+
handlers.push(...mapHandlers);
|
|
775
|
+
}
|
|
768
776
|
});
|
|
769
777
|
return handlers;
|
|
770
778
|
}
|
|
@@ -906,6 +914,75 @@ class HandlerExtractor {
|
|
|
906
914
|
}
|
|
907
915
|
return;
|
|
908
916
|
}
|
|
917
|
+
extractSwitchCaseHandlers(switchNode, context, filePath) {
|
|
918
|
+
const handlers = [];
|
|
919
|
+
try {
|
|
920
|
+
const expression = switchNode.getExpression();
|
|
921
|
+
const expressionText = expression.getText();
|
|
922
|
+
if (!/\.(type|kind|event|action)/.test(expressionText)) {
|
|
923
|
+
return handlers;
|
|
924
|
+
}
|
|
925
|
+
const caseClauses = switchNode.getClauses();
|
|
926
|
+
for (const clause of caseClauses) {
|
|
927
|
+
if (Node.isCaseClause(clause)) {
|
|
928
|
+
const caseExpr = clause.getExpression();
|
|
929
|
+
let messageType = null;
|
|
930
|
+
if (Node.isStringLiteral(caseExpr)) {
|
|
931
|
+
messageType = caseExpr.getLiteralValue();
|
|
932
|
+
}
|
|
933
|
+
if (messageType) {
|
|
934
|
+
const line = clause.getStartLineNumber();
|
|
935
|
+
handlers.push({
|
|
936
|
+
messageType,
|
|
937
|
+
node: context,
|
|
938
|
+
assignments: [],
|
|
939
|
+
preconditions: [],
|
|
940
|
+
postconditions: [],
|
|
941
|
+
location: { file: filePath, line }
|
|
942
|
+
});
|
|
943
|
+
}
|
|
944
|
+
}
|
|
945
|
+
}
|
|
946
|
+
} catch (error) {}
|
|
947
|
+
return handlers;
|
|
948
|
+
}
|
|
949
|
+
extractHandlerMapPattern(varDecl, context, filePath) {
|
|
950
|
+
const handlers = [];
|
|
951
|
+
try {
|
|
952
|
+
const initializer = varDecl.getInitializer();
|
|
953
|
+
if (!initializer || !Node.isObjectLiteralExpression(initializer)) {
|
|
954
|
+
return handlers;
|
|
955
|
+
}
|
|
956
|
+
const varName = varDecl.getName().toLowerCase();
|
|
957
|
+
if (!/(handler|listener|callback|event)s?/.test(varName)) {
|
|
958
|
+
return handlers;
|
|
959
|
+
}
|
|
960
|
+
const properties = initializer.getProperties();
|
|
961
|
+
for (const prop of properties) {
|
|
962
|
+
if (Node.isPropertyAssignment(prop)) {
|
|
963
|
+
const nameNode = prop.getNameNode();
|
|
964
|
+
let messageType = null;
|
|
965
|
+
if (Node.isStringLiteral(nameNode)) {
|
|
966
|
+
messageType = nameNode.getLiteralValue();
|
|
967
|
+
} else if (Node.isIdentifier(nameNode)) {
|
|
968
|
+
messageType = nameNode.getText();
|
|
969
|
+
}
|
|
970
|
+
if (messageType) {
|
|
971
|
+
const line = prop.getStartLineNumber();
|
|
972
|
+
handlers.push({
|
|
973
|
+
messageType,
|
|
974
|
+
node: context,
|
|
975
|
+
assignments: [],
|
|
976
|
+
preconditions: [],
|
|
977
|
+
postconditions: [],
|
|
978
|
+
location: { file: filePath, line }
|
|
979
|
+
});
|
|
980
|
+
}
|
|
981
|
+
}
|
|
982
|
+
}
|
|
983
|
+
} catch (error) {}
|
|
984
|
+
return handlers;
|
|
985
|
+
}
|
|
909
986
|
inferContext(filePath) {
|
|
910
987
|
const path = filePath.toLowerCase();
|
|
911
988
|
if (path.includes("/background/") || path.includes("\\background\\")) {
|
|
@@ -926,6 +1003,15 @@ class HandlerExtractor {
|
|
|
926
1003
|
if (path.includes("/offscreen/") || path.includes("\\offscreen\\")) {
|
|
927
1004
|
return "offscreen";
|
|
928
1005
|
}
|
|
1006
|
+
if (path.includes("/server/") || path.includes("\\server\\") || path.includes("/server.")) {
|
|
1007
|
+
return "server";
|
|
1008
|
+
}
|
|
1009
|
+
if (path.includes("/client/") || path.includes("\\client\\") || path.includes("/client.")) {
|
|
1010
|
+
return "client";
|
|
1011
|
+
}
|
|
1012
|
+
if (path.includes("/worker/") || path.includes("\\worker\\") || path.includes("service-worker")) {
|
|
1013
|
+
return "worker";
|
|
1014
|
+
}
|
|
929
1015
|
return "unknown";
|
|
930
1016
|
}
|
|
931
1017
|
}
|
|
@@ -1172,7 +1258,6 @@ async function analyzeCodebase(options) {
|
|
|
1172
1258
|
const extractor = new TypeExtractor(options.tsConfigPath);
|
|
1173
1259
|
return extractor.analyzeCodebase(options.stateFilePath);
|
|
1174
1260
|
}
|
|
1175
|
-
|
|
1176
1261
|
// vendor/verify/src/codegen/config.ts
|
|
1177
1262
|
class ConfigGenerator {
|
|
1178
1263
|
lines = [];
|
|
@@ -1721,6 +1806,7 @@ function validateConfig(configPath) {
|
|
|
1721
1806
|
}
|
|
1722
1807
|
|
|
1723
1808
|
// vendor/verify/src/cli.ts
|
|
1809
|
+
var __dirname = "/Users/AJT/projects/polly/packages/polly/vendor/verify/src";
|
|
1724
1810
|
var COLORS = {
|
|
1725
1811
|
reset: "\x1B[0m",
|
|
1726
1812
|
red: "\x1B[31m",
|
|
@@ -1935,12 +2021,30 @@ async function runFullVerification(configPath) {
|
|
|
1935
2021
|
const cfgPath = path3.join(specDir, "UserApp.cfg");
|
|
1936
2022
|
fs3.writeFileSync(specPath, spec);
|
|
1937
2023
|
fs3.writeFileSync(cfgPath, cfg);
|
|
1938
|
-
const
|
|
1939
|
-
|
|
2024
|
+
const possiblePaths = [
|
|
2025
|
+
path3.join(process.cwd(), "specs", "tla", "MessageRouter.tla"),
|
|
2026
|
+
path3.join(__dirname, "..", "specs", "tla", "MessageRouter.tla"),
|
|
2027
|
+
path3.join(__dirname, "..", "..", "specs", "tla", "MessageRouter.tla"),
|
|
2028
|
+
path3.join(process.cwd(), "external", "polly", "packages", "verify", "specs", "tla", "MessageRouter.tla"),
|
|
2029
|
+
path3.join(process.cwd(), "node_modules", "@fairfox", "polly-verify", "specs", "tla", "MessageRouter.tla")
|
|
2030
|
+
];
|
|
2031
|
+
let baseSpecPath = null;
|
|
2032
|
+
for (const candidatePath of possiblePaths) {
|
|
2033
|
+
if (fs3.existsSync(candidatePath)) {
|
|
2034
|
+
baseSpecPath = candidatePath;
|
|
2035
|
+
break;
|
|
2036
|
+
}
|
|
2037
|
+
}
|
|
2038
|
+
if (baseSpecPath) {
|
|
1940
2039
|
const destSpecPath = path3.join(specDir, "MessageRouter.tla");
|
|
1941
2040
|
fs3.copyFileSync(baseSpecPath, destSpecPath);
|
|
2041
|
+
console.log(color("✓ Copied MessageRouter.tla", COLORS.green));
|
|
1942
2042
|
} else {
|
|
1943
2043
|
console.log(color("⚠️ Warning: MessageRouter.tla not found, verification may fail", COLORS.yellow));
|
|
2044
|
+
console.log(color(` Searched in:`, COLORS.gray));
|
|
2045
|
+
for (const searchPath of possiblePaths) {
|
|
2046
|
+
console.log(color(` - ${searchPath}`, COLORS.gray));
|
|
2047
|
+
}
|
|
1944
2048
|
}
|
|
1945
2049
|
console.log(color("✓ Specification generated", COLORS.green));
|
|
1946
2050
|
console.log(color(` ${specPath}`, COLORS.gray));
|
|
@@ -2071,4 +2175,4 @@ Stack trace:`, COLORS.gray));
|
|
|
2071
2175
|
process.exit(1);
|
|
2072
2176
|
});
|
|
2073
2177
|
|
|
2074
|
-
//# debugId=
|
|
2178
|
+
//# debugId=8C53367A419D15AA64756E2164756E21
|