@fairfox/polly 0.75.3 → 0.77.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/src/client/index.js +2 -2
- package/dist/src/client/index.js.map +2 -2
- package/dist/src/polly-ui/Button.d.ts +4 -0
- package/dist/src/polly-ui/index.css +37 -9
- package/dist/src/polly-ui/index.js +15 -5
- package/dist/src/polly-ui/index.js.map +5 -5
- package/dist/src/polly-ui/markdown.js +3 -3
- package/dist/src/polly-ui/markdown.js.map +2 -2
- package/dist/src/polly-ui/styles.css +37 -9
- package/dist/src/polly-ui/theme.css +19 -0
- package/dist/tools/test/src/visual/index.js +24 -24
- package/dist/tools/test/src/visual/index.js.map +2 -2
- package/dist/tools/verify/src/cli.js +60 -51
- package/dist/tools/verify/src/cli.js.map +5 -5
- package/dist/tools/verify/src/stryker/index.d.ts +32 -0
- package/dist/tools/verify/src/stryker/index.js +95 -0
- package/dist/tools/verify/src/stryker/index.js.map +10 -0
- package/dist/tools/visualize/src/cli.js +6 -9
- package/dist/tools/visualize/src/cli.js.map +3 -3
- package/package.json +14 -2
|
@@ -811,6 +811,9 @@ var init_tla = __esm(() => {
|
|
|
811
811
|
}
|
|
812
812
|
return /^[a-zA-Z][a-zA-Z0-9_]*$/.test(s);
|
|
813
813
|
}
|
|
814
|
+
canRepresentAsTLAAction(s) {
|
|
815
|
+
return typeof s === "string" && /[a-zA-Z]/.test(s) && !/[{}();<>=]/.test(s);
|
|
816
|
+
}
|
|
814
817
|
async generate(config, analysis, moduleName) {
|
|
815
818
|
if (moduleName) {
|
|
816
819
|
this.moduleName = moduleName;
|
|
@@ -917,8 +920,8 @@ var init_tla = __esm(() => {
|
|
|
917
920
|
}
|
|
918
921
|
validateInputs(_config, analysis) {
|
|
919
922
|
for (const messageType of analysis.messageTypes) {
|
|
920
|
-
if (!this.
|
|
921
|
-
throw new Error(`
|
|
923
|
+
if (!this.canRepresentAsTLAAction(messageType)) {
|
|
924
|
+
throw new Error(`Unrepresentable message type '${messageType}'. A message type must contain at least one letter so it can be sanitized into a TLA+ action name.`);
|
|
922
925
|
}
|
|
923
926
|
}
|
|
924
927
|
}
|
|
@@ -1346,16 +1349,16 @@ var init_tla = __esm(() => {
|
|
|
1346
1349
|
let validMessageTypes = [];
|
|
1347
1350
|
const invalidMessageTypes = [];
|
|
1348
1351
|
for (const msgType of analysis.messageTypes) {
|
|
1349
|
-
if (this.
|
|
1352
|
+
if (this.canRepresentAsTLAAction(msgType)) {
|
|
1350
1353
|
validMessageTypes.push(msgType);
|
|
1351
1354
|
} else {
|
|
1352
1355
|
invalidMessageTypes.push(msgType);
|
|
1353
1356
|
}
|
|
1354
1357
|
}
|
|
1355
1358
|
if (invalidMessageTypes.length > 0 && process.env["POLLY_DEBUG"]) {
|
|
1356
|
-
console.log(`[WARN] [TLAGenerator]
|
|
1359
|
+
console.log(`[WARN] [TLAGenerator] Dropped ${invalidMessageTypes.length} unrepresentable message type(s):`);
|
|
1357
1360
|
for (const invalid of invalidMessageTypes) {
|
|
1358
|
-
console.log(`[WARN] - "${invalid}" (
|
|
1361
|
+
console.log(`[WARN] - "${invalid}" (no letter to form a TLA+ action name)`);
|
|
1359
1362
|
}
|
|
1360
1363
|
}
|
|
1361
1364
|
if (process.env["POLLY_DEBUG"]) {
|
|
@@ -1762,7 +1765,7 @@ var init_tla = __esm(() => {
|
|
|
1762
1765
|
const validHandlers = [];
|
|
1763
1766
|
const invalidHandlers = [];
|
|
1764
1767
|
for (const handler of handlers) {
|
|
1765
|
-
if (this.
|
|
1768
|
+
if (this.canRepresentAsTLAAction(handler.messageType)) {
|
|
1766
1769
|
validHandlers.push(handler);
|
|
1767
1770
|
} else {
|
|
1768
1771
|
invalidHandlers.push(handler);
|
|
@@ -1773,7 +1776,7 @@ var init_tla = __esm(() => {
|
|
|
1773
1776
|
logInvalidHandlers(invalidHandlers) {
|
|
1774
1777
|
if (invalidHandlers.length === 0 || !process.env["POLLY_DEBUG"])
|
|
1775
1778
|
return;
|
|
1776
|
-
console.log(`[WARN] [TLAGenerator]
|
|
1779
|
+
console.log(`[WARN] [TLAGenerator] Dropped ${invalidHandlers.length} handler(s) with unrepresentable message types:`);
|
|
1777
1780
|
for (const handler of invalidHandlers) {
|
|
1778
1781
|
console.log(`[WARN] - "${handler.messageType}" at ${handler.location.file}:${handler.location.line}`);
|
|
1779
1782
|
}
|
|
@@ -2488,19 +2491,31 @@ var init_tla = __esm(() => {
|
|
|
2488
2491
|
}
|
|
2489
2492
|
resolveCollisions(actionNameToMessageTypes) {
|
|
2490
2493
|
for (const [baseActionName, messageTypes] of actionNameToMessageTypes.entries()) {
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
this.resolvedActionNames.set(entry.messageType, baseActionName);
|
|
2495
|
-
}
|
|
2494
|
+
const single = messageTypes.length === 1 ? messageTypes[0] : undefined;
|
|
2495
|
+
if (single) {
|
|
2496
|
+
this.resolvedActionNames.set(single.messageType, baseActionName);
|
|
2496
2497
|
continue;
|
|
2497
2498
|
}
|
|
2498
|
-
|
|
2499
|
-
const resolvedName = entry.origin === "stateHandler" ? baseActionName.replace(/^Handle/, "HandleFn") : baseActionName;
|
|
2500
|
-
this.resolvedActionNames.set(entry.messageType, resolvedName);
|
|
2501
|
-
}
|
|
2499
|
+
this.resolveCollidingGroup(baseActionName, messageTypes);
|
|
2502
2500
|
}
|
|
2503
2501
|
}
|
|
2502
|
+
resolveCollidingGroup(baseActionName, messageTypes) {
|
|
2503
|
+
const usedNames = new Set;
|
|
2504
|
+
for (const entry of messageTypes) {
|
|
2505
|
+
const originName = entry.origin === "stateHandler" ? baseActionName.replace(/^Handle/, "HandleFn") : baseActionName;
|
|
2506
|
+
this.resolvedActionNames.set(entry.messageType, this.uniquify(originName, usedNames));
|
|
2507
|
+
}
|
|
2508
|
+
}
|
|
2509
|
+
uniquify(name, used) {
|
|
2510
|
+
let candidate = name;
|
|
2511
|
+
let suffix = 2;
|
|
2512
|
+
while (used.has(candidate)) {
|
|
2513
|
+
candidate = `${name}_${suffix}`;
|
|
2514
|
+
suffix++;
|
|
2515
|
+
}
|
|
2516
|
+
used.add(candidate);
|
|
2517
|
+
return candidate;
|
|
2518
|
+
}
|
|
2504
2519
|
getResolvedActionName(messageType) {
|
|
2505
2520
|
const resolved = this.resolvedActionNames.get(messageType);
|
|
2506
2521
|
if (resolved) {
|
|
@@ -2618,7 +2633,7 @@ var init_tla = __esm(() => {
|
|
|
2618
2633
|
this.line("\\* Next state relation (extends MessageRouter)");
|
|
2619
2634
|
this.line("UserNext ==");
|
|
2620
2635
|
this.indent++;
|
|
2621
|
-
const hasValidHandlers = analysis.handlers.some((h) => this.
|
|
2636
|
+
const hasValidHandlers = analysis.handlers.some((h) => this.canRepresentAsTLAAction(h.messageType));
|
|
2622
2637
|
if (hasValidHandlers) {
|
|
2623
2638
|
const userPayload = this.unchangedUserStates(undefined, ["payload"]);
|
|
2624
2639
|
this.line(`\\/ \\E c \\in Contexts : ConnectPort(c) /\\ ${userPayload}`);
|
|
@@ -4947,7 +4962,7 @@ class HandlerExtractor {
|
|
|
4947
4962
|
const exists = handlers.some((h) => h.messageType === handler.messageType && h.location.file === handler.location.file);
|
|
4948
4963
|
if (!exists) {
|
|
4949
4964
|
handlers.push(handler);
|
|
4950
|
-
if (this.
|
|
4965
|
+
if (this.canRepresentAsTLAAction(handler.messageType)) {
|
|
4951
4966
|
messageTypes.add(handler.messageType);
|
|
4952
4967
|
} else {
|
|
4953
4968
|
invalidMessageTypes.add(handler.messageType);
|
|
@@ -5057,7 +5072,7 @@ class HandlerExtractor {
|
|
|
5057
5072
|
const syntheticHandlers = this.createResourceHandlers(resource, context);
|
|
5058
5073
|
for (const handler of syntheticHandlers) {
|
|
5059
5074
|
handlers.push(handler);
|
|
5060
|
-
if (this.
|
|
5075
|
+
if (this.canRepresentAsTLAAction(handler.messageType)) {
|
|
5061
5076
|
messageTypes.add(handler.messageType);
|
|
5062
5077
|
} else {
|
|
5063
5078
|
invalidMessageTypes.add(handler.messageType);
|
|
@@ -5119,7 +5134,7 @@ class HandlerExtractor {
|
|
|
5119
5134
|
}
|
|
5120
5135
|
categorizeHandlerMessageTypes(handlers, messageTypes, invalidMessageTypes) {
|
|
5121
5136
|
for (const handler of handlers) {
|
|
5122
|
-
if (this.
|
|
5137
|
+
if (this.canRepresentAsTLAAction(handler.messageType)) {
|
|
5123
5138
|
messageTypes.add(handler.messageType);
|
|
5124
5139
|
} else {
|
|
5125
5140
|
invalidMessageTypes.add(handler.messageType);
|
|
@@ -5134,11 +5149,8 @@ class HandlerExtractor {
|
|
|
5134
5149
|
console.log(`[DEBUG] Filtered ${invalidCount} invalid message type(s) from handlers`);
|
|
5135
5150
|
}
|
|
5136
5151
|
}
|
|
5137
|
-
|
|
5138
|
-
|
|
5139
|
-
return false;
|
|
5140
|
-
}
|
|
5141
|
-
return /^[a-zA-Z][a-zA-Z0-9_]*$/.test(s);
|
|
5152
|
+
canRepresentAsTLAAction(s) {
|
|
5153
|
+
return typeof s === "string" && /[a-zA-Z]/.test(s) && !/[{}();<>=]/.test(s);
|
|
5142
5154
|
}
|
|
5143
5155
|
extractFromFile(sourceFile) {
|
|
5144
5156
|
const handlers = [];
|
|
@@ -7163,47 +7175,44 @@ class TypeExtractor {
|
|
|
7163
7175
|
}
|
|
7164
7176
|
filterAndLogMessageTypes(messageTypes, handlerMessageTypes) {
|
|
7165
7177
|
const allMessageTypes = Array.from(new Set([...messageTypes, ...handlerMessageTypes]));
|
|
7166
|
-
const
|
|
7167
|
-
const
|
|
7178
|
+
const keptMessageTypes = [];
|
|
7179
|
+
const droppedMessageTypes = [];
|
|
7168
7180
|
for (const msgType of allMessageTypes) {
|
|
7169
|
-
if (this.
|
|
7170
|
-
|
|
7181
|
+
if (this.canRepresentAsTLAAction(msgType)) {
|
|
7182
|
+
keptMessageTypes.push(msgType);
|
|
7171
7183
|
} else {
|
|
7172
|
-
|
|
7184
|
+
droppedMessageTypes.push(msgType);
|
|
7173
7185
|
}
|
|
7174
7186
|
}
|
|
7175
|
-
this.
|
|
7176
|
-
return
|
|
7187
|
+
this.logDroppedMessageTypes(droppedMessageTypes);
|
|
7188
|
+
return keptMessageTypes;
|
|
7177
7189
|
}
|
|
7178
|
-
|
|
7179
|
-
if (
|
|
7190
|
+
logDroppedMessageTypes(droppedMessageTypes) {
|
|
7191
|
+
if (droppedMessageTypes.length === 0)
|
|
7180
7192
|
return;
|
|
7181
|
-
console.log(`[WARN]
|
|
7182
|
-
for (const
|
|
7183
|
-
console.log(`[WARN] - "${
|
|
7193
|
+
console.log(`[WARN] Dropped ${droppedMessageTypes.length} unrepresentable message type(s) (no letter to form a TLA+ action name):`);
|
|
7194
|
+
for (const dropped of droppedMessageTypes) {
|
|
7195
|
+
console.log(`[WARN] - "${dropped}"`);
|
|
7184
7196
|
}
|
|
7185
7197
|
}
|
|
7186
7198
|
filterAndLogHandlers(handlers) {
|
|
7187
|
-
const
|
|
7188
|
-
this.
|
|
7189
|
-
return
|
|
7199
|
+
const keptHandlers = handlers.filter((h) => this.canRepresentAsTLAAction(h.messageType));
|
|
7200
|
+
this.logDroppedHandlers(handlers, keptHandlers);
|
|
7201
|
+
return keptHandlers;
|
|
7190
7202
|
}
|
|
7191
|
-
|
|
7192
|
-
const
|
|
7193
|
-
if (
|
|
7203
|
+
logDroppedHandlers(allHandlers, keptHandlers) {
|
|
7204
|
+
const droppedHandlerCount = allHandlers.length - keptHandlers.length;
|
|
7205
|
+
if (droppedHandlerCount === 0)
|
|
7194
7206
|
return;
|
|
7195
|
-
console.log(`[WARN]
|
|
7207
|
+
console.log(`[WARN] Dropped ${droppedHandlerCount} handler(s) with unrepresentable message types:`);
|
|
7196
7208
|
for (const handler of allHandlers) {
|
|
7197
|
-
if (!this.
|
|
7209
|
+
if (!this.canRepresentAsTLAAction(handler.messageType)) {
|
|
7198
7210
|
console.log(`[WARN] - Handler for "${handler.messageType}" at ${handler.location.file}:${handler.location.line}`);
|
|
7199
7211
|
}
|
|
7200
7212
|
}
|
|
7201
7213
|
}
|
|
7202
|
-
|
|
7203
|
-
|
|
7204
|
-
return false;
|
|
7205
|
-
}
|
|
7206
|
-
return /^[a-zA-Z][a-zA-Z0-9_]*$/.test(s);
|
|
7214
|
+
canRepresentAsTLAAction(s) {
|
|
7215
|
+
return typeof s === "string" && /[a-zA-Z]/.test(s) && !/[{}();<>=]/.test(s);
|
|
7207
7216
|
}
|
|
7208
7217
|
extractStateType(filePath) {
|
|
7209
7218
|
const sourceFile = this.project.getSourceFile(filePath);
|
|
@@ -8364,4 +8373,4 @@ main().catch((error) => {
|
|
|
8364
8373
|
process.exit(1);
|
|
8365
8374
|
});
|
|
8366
8375
|
|
|
8367
|
-
//# debugId=
|
|
8376
|
+
//# debugId=CD834265BD94F24164756E2164756E21
|