@fairfox/polly 0.12.4 → 0.13.1
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/src/background/index.js +118 -1
- package/dist/src/background/index.js.map +5 -4
- package/dist/src/background/message-router.js +118 -1
- package/dist/src/background/message-router.js.map +5 -4
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.js +203 -3
- package/dist/src/index.js.map +9 -6
- package/dist/src/shared/lib/constraints.d.ts +61 -0
- package/dist/src/shared/lib/context-helpers.js +118 -1
- package/dist/src/shared/lib/context-helpers.js.map +5 -4
- package/dist/src/shared/lib/message-bus.d.ts +22 -0
- package/dist/src/shared/lib/message-bus.js +118 -1
- package/dist/src/shared/lib/message-bus.js.map +5 -4
- package/dist/src/shared/lib/state.d.ts +8 -2
- package/dist/src/shared/lib/state.js +140 -3
- package/dist/src/shared/lib/state.js.map +6 -5
- package/dist/src/shared/lib/validation.d.ts +94 -0
- package/dist/src/shared/state/app-state.d.ts +4 -1
- package/dist/src/shared/state/app-state.js +140 -3
- package/dist/src/shared/state/app-state.js.map +6 -5
- package/dist/tools/analysis/src/extract/handlers.d.ts +19 -2
- package/dist/tools/teach/src/cli.js +83 -18
- package/dist/tools/teach/src/cli.js.map +3 -3
- package/dist/tools/teach/src/index.js +83 -18
- package/dist/tools/teach/src/index.js.map +3 -3
- package/dist/tools/verify/src/cli.js +88 -18
- package/dist/tools/verify/src/cli.js.map +4 -4
- package/dist/tools/verify/src/config.js +8 -2
- package/dist/tools/verify/src/config.js.map +3 -3
- package/dist/tools/verify/src/primitives/index.d.ts +21 -8
- package/dist/tools/visualize/src/cli.js +83 -18
- package/dist/tools/visualize/src/cli.js.map +3 -3
- package/package.json +1 -1
|
@@ -236860,17 +236860,25 @@ class HandlerExtractor {
|
|
|
236860
236860
|
const assignments = [];
|
|
236861
236861
|
const preconditions = [];
|
|
236862
236862
|
const postconditions = [];
|
|
236863
|
+
let actualHandler = null;
|
|
236863
236864
|
if (import_ts_morph4.Node.isArrowFunction(handlerArg) || import_ts_morph4.Node.isFunctionExpression(handlerArg)) {
|
|
236864
|
-
|
|
236865
|
-
|
|
236866
|
-
this.
|
|
236865
|
+
actualHandler = handlerArg;
|
|
236866
|
+
} else if (import_ts_morph4.Node.isIdentifier(handlerArg)) {
|
|
236867
|
+
actualHandler = this.resolveFunctionReference(handlerArg);
|
|
236868
|
+
}
|
|
236869
|
+
if (actualHandler) {
|
|
236870
|
+
this.extractAssignments(actualHandler, assignments);
|
|
236871
|
+
this.extractVerificationConditions(actualHandler, preconditions, postconditions);
|
|
236872
|
+
if (import_ts_morph4.Node.isArrowFunction(actualHandler) || import_ts_morph4.Node.isFunctionExpression(actualHandler)) {
|
|
236873
|
+
this.checkAsyncMutations(actualHandler, messageType);
|
|
236874
|
+
}
|
|
236867
236875
|
}
|
|
236868
236876
|
const line = callExpr.getStartLineNumber();
|
|
236869
236877
|
const sourceFile = callExpr.getSourceFile();
|
|
236870
236878
|
const handlerName = `${messageType}_handler`;
|
|
236871
236879
|
let relationships;
|
|
236872
|
-
if (
|
|
236873
|
-
const detectedRelationships = this.relationshipExtractor.extractFromHandler(
|
|
236880
|
+
if (actualHandler) {
|
|
236881
|
+
const detectedRelationships = this.relationshipExtractor.extractFromHandler(actualHandler, sourceFile, handlerName);
|
|
236874
236882
|
if (detectedRelationships.length > 0) {
|
|
236875
236883
|
relationships = detectedRelationships;
|
|
236876
236884
|
}
|
|
@@ -236974,11 +236982,24 @@ class HandlerExtractor {
|
|
|
236974
236982
|
}
|
|
236975
236983
|
}
|
|
236976
236984
|
}
|
|
236985
|
+
getUnaryOperatorText(operator) {
|
|
236986
|
+
if (typeof operator === "number") {
|
|
236987
|
+
if (operator === import_ts_morph4.SyntaxKind.PlusPlusToken)
|
|
236988
|
+
return "++";
|
|
236989
|
+
if (operator === import_ts_morph4.SyntaxKind.MinusMinusToken)
|
|
236990
|
+
return "--";
|
|
236991
|
+
return null;
|
|
236992
|
+
}
|
|
236993
|
+
if (operator && typeof operator === "object" && "getText" in operator) {
|
|
236994
|
+
return operator.getText();
|
|
236995
|
+
}
|
|
236996
|
+
return null;
|
|
236997
|
+
}
|
|
236977
236998
|
extractUnaryExpressionAssignment(node, assignments) {
|
|
236978
236999
|
if (!import_ts_morph4.Node.isPostfixUnaryExpression(node) && !import_ts_morph4.Node.isPrefixUnaryExpression(node))
|
|
236979
237000
|
return;
|
|
236980
237001
|
const operator = node.getOperatorToken();
|
|
236981
|
-
const operatorText =
|
|
237002
|
+
const operatorText = this.getUnaryOperatorText(operator);
|
|
236982
237003
|
if (operatorText !== "++" && operatorText !== "--")
|
|
236983
237004
|
return;
|
|
236984
237005
|
const operand = node.getOperand();
|
|
@@ -237070,7 +237091,7 @@ class HandlerExtractor {
|
|
|
237070
237091
|
}
|
|
237071
237092
|
extractVerificationConditions(funcNode, preconditions, postconditions) {
|
|
237072
237093
|
const body = funcNode.getBody();
|
|
237073
|
-
const statements = import_ts_morph4.Node.isBlock(body) ? body.getStatements() : [body];
|
|
237094
|
+
const statements = import_ts_morph4.Node.isBlock(body) ? body.getStatements() : body ? [body] : [];
|
|
237074
237095
|
for (const statement of statements) {
|
|
237075
237096
|
this.processStatementForConditions(statement, preconditions, postconditions);
|
|
237076
237097
|
}
|
|
@@ -237190,10 +237211,14 @@ class HandlerExtractor {
|
|
|
237190
237211
|
const handlers = [];
|
|
237191
237212
|
try {
|
|
237192
237213
|
const initializer = varDecl.getInitializer();
|
|
237193
|
-
if (!
|
|
237214
|
+
if (!initializer) {
|
|
237215
|
+
return handlers;
|
|
237216
|
+
}
|
|
237217
|
+
const objectLiteral = this.getHandlerMapObject(initializer, varDecl);
|
|
237218
|
+
if (!objectLiteral) {
|
|
237194
237219
|
return handlers;
|
|
237195
237220
|
}
|
|
237196
|
-
const properties =
|
|
237221
|
+
const properties = objectLiteral.getProperties();
|
|
237197
237222
|
for (const prop of properties) {
|
|
237198
237223
|
const handler = this.extractHandlerFromProperty(prop, context, filePath);
|
|
237199
237224
|
if (handler) {
|
|
@@ -237203,12 +237228,16 @@ class HandlerExtractor {
|
|
|
237203
237228
|
} catch (_error) {}
|
|
237204
237229
|
return handlers;
|
|
237205
237230
|
}
|
|
237206
|
-
|
|
237207
|
-
if (
|
|
237208
|
-
|
|
237231
|
+
getHandlerMapObject(initializer, varDecl) {
|
|
237232
|
+
if (import_ts_morph4.Node.isObjectLiteralExpression(initializer)) {
|
|
237233
|
+
if (this.isHandlerMapName(varDecl.getName())) {
|
|
237234
|
+
return initializer;
|
|
237235
|
+
}
|
|
237209
237236
|
}
|
|
237210
|
-
|
|
237211
|
-
|
|
237237
|
+
return null;
|
|
237238
|
+
}
|
|
237239
|
+
isHandlerMapName(varName) {
|
|
237240
|
+
return /(handler|listener|callback|event)s?/.test(varName.toLowerCase());
|
|
237212
237241
|
}
|
|
237213
237242
|
extractHandlerFromProperty(prop, context, filePath) {
|
|
237214
237243
|
if (!import_ts_morph4.Node.isPropertyAssignment(prop)) {
|
|
@@ -237219,13 +237248,29 @@ class HandlerExtractor {
|
|
|
237219
237248
|
if (!messageType) {
|
|
237220
237249
|
return null;
|
|
237221
237250
|
}
|
|
237251
|
+
const value = prop.getInitializer();
|
|
237252
|
+
const assignments = [];
|
|
237253
|
+
const preconditions = [];
|
|
237254
|
+
const postconditions = [];
|
|
237255
|
+
if (value) {
|
|
237256
|
+
if (import_ts_morph4.Node.isArrowFunction(value) || import_ts_morph4.Node.isFunctionExpression(value)) {
|
|
237257
|
+
this.extractAssignments(value, assignments);
|
|
237258
|
+
this.extractVerificationConditions(value, preconditions, postconditions);
|
|
237259
|
+
} else if (import_ts_morph4.Node.isIdentifier(value)) {
|
|
237260
|
+
const referencedFunction = this.resolveFunctionReference(value);
|
|
237261
|
+
if (referencedFunction) {
|
|
237262
|
+
this.extractAssignments(referencedFunction, assignments);
|
|
237263
|
+
this.extractVerificationConditions(referencedFunction, preconditions, postconditions);
|
|
237264
|
+
}
|
|
237265
|
+
}
|
|
237266
|
+
}
|
|
237222
237267
|
const line = prop.getStartLineNumber();
|
|
237223
237268
|
return {
|
|
237224
237269
|
messageType,
|
|
237225
237270
|
node: context,
|
|
237226
|
-
assignments
|
|
237227
|
-
preconditions
|
|
237228
|
-
postconditions
|
|
237271
|
+
assignments,
|
|
237272
|
+
preconditions,
|
|
237273
|
+
postconditions,
|
|
237229
237274
|
location: { file: filePath, line }
|
|
237230
237275
|
};
|
|
237231
237276
|
}
|
|
@@ -237238,6 +237283,26 @@ class HandlerExtractor {
|
|
|
237238
237283
|
}
|
|
237239
237284
|
return null;
|
|
237240
237285
|
}
|
|
237286
|
+
resolveFunctionReference(identifier) {
|
|
237287
|
+
if (!import_ts_morph4.Node.isIdentifier(identifier)) {
|
|
237288
|
+
return null;
|
|
237289
|
+
}
|
|
237290
|
+
try {
|
|
237291
|
+
const definitions = identifier.getDefinitionNodes();
|
|
237292
|
+
for (const def of definitions) {
|
|
237293
|
+
if (import_ts_morph4.Node.isFunctionDeclaration(def)) {
|
|
237294
|
+
return def;
|
|
237295
|
+
}
|
|
237296
|
+
if (import_ts_morph4.Node.isVariableDeclaration(def)) {
|
|
237297
|
+
const initializer = def.getInitializer();
|
|
237298
|
+
if (initializer && (import_ts_morph4.Node.isArrowFunction(initializer) || import_ts_morph4.Node.isFunctionExpression(initializer))) {
|
|
237299
|
+
return initializer;
|
|
237300
|
+
}
|
|
237301
|
+
}
|
|
237302
|
+
}
|
|
237303
|
+
} catch (_error) {}
|
|
237304
|
+
return null;
|
|
237305
|
+
}
|
|
237241
237306
|
extractTypeGuardHandlers(ifNode, context, filePath) {
|
|
237242
237307
|
const handlers = [];
|
|
237243
237308
|
try {
|
|
@@ -240688,4 +240753,4 @@ export {
|
|
|
240688
240753
|
generateTeachingMaterial
|
|
240689
240754
|
};
|
|
240690
240755
|
|
|
240691
|
-
//# debugId=
|
|
240756
|
+
//# debugId=555FA35403EDF64764756E2164756E21
|