@fairfox/polly 0.88.1 → 0.89.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/cli/polly.js +4 -4
- package/dist/cli/polly.js.map +2 -2
- package/dist/gallery/gallery.css +51 -59
- package/dist/gallery/gallery.js +1155 -1047
- package/dist/src/actions/index.js +5 -78
- package/dist/src/actions/index.js.map +2 -2
- package/dist/src/background/index.js +126 -152
- package/dist/src/background/index.js.map +4 -4
- package/dist/src/background/message-router.js +126 -152
- package/dist/src/background/message-router.js.map +4 -4
- package/dist/src/client/index.js +186 -259
- package/dist/src/client/index.js.map +5 -5
- package/dist/src/elysia/index.js +21 -35
- package/dist/src/elysia/index.js.map +2 -2
- package/dist/src/index.js +218 -246
- package/dist/src/index.js.map +10 -10
- package/dist/src/mesh.js +49 -61
- package/dist/src/mesh.js.map +4 -4
- package/dist/src/peer.js +23 -52
- package/dist/src/peer.js.map +2 -2
- package/dist/src/polly-ui/Button.d.ts +7 -0
- package/dist/src/polly-ui/Collapsible.d.ts +3 -1
- package/dist/src/polly-ui/Layout.d.ts +16 -1
- package/dist/src/polly-ui/index.css +47 -59
- package/dist/src/polly-ui/index.js +112 -124
- package/dist/src/polly-ui/index.js.map +13 -13
- package/dist/src/polly-ui/markdown.js +72 -145
- package/dist/src/polly-ui/markdown.js.map +2 -2
- package/dist/src/polly-ui/styles.css +47 -59
- package/dist/src/polly-ui/theme.css +10 -0
- package/dist/src/shared/adapters/index.js +31 -44
- package/dist/src/shared/adapters/index.js.map +2 -2
- package/dist/src/shared/lib/context-helpers.js +126 -152
- package/dist/src/shared/lib/context-helpers.js.map +4 -4
- package/dist/src/shared/lib/errors.js +1 -74
- package/dist/src/shared/lib/errors.js.map +2 -2
- package/dist/src/shared/lib/guards.js +1 -74
- package/dist/src/shared/lib/guards.js.map +2 -2
- package/dist/src/shared/lib/message-bus.js +126 -152
- package/dist/src/shared/lib/message-bus.js.map +4 -4
- package/dist/src/shared/lib/resource.js +16 -27
- package/dist/src/shared/lib/resource.js.map +5 -5
- package/dist/src/shared/lib/state.js +13 -26
- package/dist/src/shared/lib/state.js.map +2 -2
- package/dist/src/shared/lib/test-helpers.js +1 -74
- package/dist/src/shared/lib/test-helpers.js.map +2 -2
- package/dist/src/shared/state/app-state.js +35 -46
- package/dist/src/shared/state/app-state.js.map +5 -5
- package/dist/src/shared/types/messages.js +1 -74
- package/dist/src/shared/types/messages.js.map +2 -2
- package/dist/tools/bdd/src/cli.js +11 -15
- package/dist/tools/bdd/src/cli.js.map +2 -2
- package/dist/tools/bdd/src/index.js +11 -19
- package/dist/tools/bdd/src/index.js.map +2 -2
- package/dist/tools/gallery/src/cli.js +1 -18
- package/dist/tools/gallery/src/cli.js.map +2 -2
- package/dist/tools/init/src/cli.js +1 -18
- package/dist/tools/init/src/cli.js.map +2 -2
- package/dist/tools/mutate/src/cli.js +8 -25
- package/dist/tools/mutate/src/cli.js.map +2 -2
- package/dist/tools/mutate/src/index.js +8 -26
- package/dist/tools/mutate/src/index.js.map +2 -2
- package/dist/tools/quality/src/cli.js +39 -46
- package/dist/tools/quality/src/cli.js.map +3 -3
- package/dist/tools/quality/src/css/check-layout.d.ts +5 -3
- package/dist/tools/quality/src/index.js +39 -47
- package/dist/tools/quality/src/index.js.map +3 -3
- package/dist/tools/test/src/adapters/index.js +4 -77
- package/dist/tools/test/src/adapters/index.js.map +2 -2
- package/dist/tools/test/src/browser/index.js +1 -74
- package/dist/tools/test/src/browser/index.js.map +2 -2
- package/dist/tools/test/src/browser/run.js +5 -22
- package/dist/tools/test/src/browser/run.js.map +2 -2
- package/dist/tools/test/src/contrast/index.js +1 -74
- package/dist/tools/test/src/contrast/index.js.map +2 -2
- package/dist/tools/test/src/coverage-policy/cli.js +13 -25
- package/dist/tools/test/src/coverage-policy/cli.js.map +2 -2
- package/dist/tools/test/src/coverage-policy/index.js +11 -23
- package/dist/tools/test/src/coverage-policy/index.js.map +2 -2
- package/dist/tools/test/src/e2e-mesh/index.js +18 -43
- package/dist/tools/test/src/e2e-mesh/index.js.map +2 -2
- package/dist/tools/test/src/e2e-relay/index.js +615 -623
- package/dist/tools/test/src/e2e-relay/index.js.map +2 -2
- package/dist/tools/test/src/index.js +30 -103
- package/dist/tools/test/src/index.js.map +5 -5
- package/dist/tools/test/src/test-utils.js +1 -74
- package/dist/tools/test/src/test-utils.js.map +2 -2
- package/dist/tools/test/src/tiers/cli.js +1 -18
- package/dist/tools/test/src/tiers/cli.js.map +2 -2
- package/dist/tools/test/src/tiers/worker.js +11 -15
- package/dist/tools/test/src/tiers/worker.js.map +2 -2
- package/dist/tools/test/src/visual/index.js +1112 -1134
- package/dist/tools/test/src/visual/index.js.map +3 -3
- package/dist/tools/verify/src/cli.js +103 -169
- package/dist/tools/verify/src/cli.js.map +2 -2
- package/dist/tools/verify/src/config.js +1 -74
- package/dist/tools/verify/src/config.js.map +2 -2
- package/dist/tools/verify/src/stryker/index.js +1 -19
- package/dist/tools/verify/src/stryker/index.js.map +2 -2
- package/dist/tools/visualize/src/cli.js +69 -85
- package/dist/tools/visualize/src/cli.js.map +2 -2
- package/package.json +1 -1
|
@@ -1,76 +1,3 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
function __accessProp(key) {
|
|
8
|
-
return this[key];
|
|
9
|
-
}
|
|
10
|
-
var __toESMCache_node;
|
|
11
|
-
var __toESMCache_esm;
|
|
12
|
-
var __toESM = (mod, isNodeMode, target) => {
|
|
13
|
-
var canCache = mod != null && typeof mod === "object";
|
|
14
|
-
if (canCache) {
|
|
15
|
-
var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
|
|
16
|
-
var cached = cache.get(mod);
|
|
17
|
-
if (cached)
|
|
18
|
-
return cached;
|
|
19
|
-
}
|
|
20
|
-
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
21
|
-
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
22
|
-
if (mod && typeof mod === "object" || typeof mod === "function") {
|
|
23
|
-
for (let key of __getOwnPropNames(mod))
|
|
24
|
-
if (!__hasOwnProp.call(to, key))
|
|
25
|
-
__defProp(to, key, {
|
|
26
|
-
get: __accessProp.bind(mod, key),
|
|
27
|
-
enumerable: true
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
if (canCache)
|
|
31
|
-
cache.set(mod, to);
|
|
32
|
-
return to;
|
|
33
|
-
};
|
|
34
|
-
var __toCommonJS = (from) => {
|
|
35
|
-
var entry = (__moduleCache ??= new WeakMap).get(from), desc;
|
|
36
|
-
if (entry)
|
|
37
|
-
return entry;
|
|
38
|
-
entry = __defProp({}, "__esModule", { value: true });
|
|
39
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
40
|
-
for (var key of __getOwnPropNames(from))
|
|
41
|
-
if (!__hasOwnProp.call(entry, key))
|
|
42
|
-
__defProp(entry, key, {
|
|
43
|
-
get: __accessProp.bind(from, key),
|
|
44
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
__moduleCache.set(from, entry);
|
|
48
|
-
return entry;
|
|
49
|
-
};
|
|
50
|
-
var __moduleCache;
|
|
51
|
-
var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
52
|
-
var __returnValue = (v) => v;
|
|
53
|
-
function __exportSetter(name, newValue) {
|
|
54
|
-
this[name] = __returnValue.bind(null, newValue);
|
|
55
|
-
}
|
|
56
|
-
var __export = (target, all) => {
|
|
57
|
-
for (var name in all)
|
|
58
|
-
__defProp(target, name, {
|
|
59
|
-
get: all[name],
|
|
60
|
-
enumerable: true,
|
|
61
|
-
configurable: true,
|
|
62
|
-
set: __exportSetter.bind(all, name)
|
|
63
|
-
});
|
|
64
|
-
};
|
|
65
|
-
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
66
|
-
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
67
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
68
|
-
}) : x)(function(x) {
|
|
69
|
-
if (typeof require !== "undefined")
|
|
70
|
-
return require.apply(this, arguments);
|
|
71
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
72
|
-
});
|
|
73
|
-
|
|
74
1
|
// tools/verify/src/primitives/index.ts
|
|
75
2
|
function requires(condition, message) {}
|
|
76
3
|
function ensures(condition, message) {}
|
|
@@ -136,4 +63,4 @@ export {
|
|
|
136
63
|
stateConstraint
|
|
137
64
|
};
|
|
138
65
|
|
|
139
|
-
//# debugId=
|
|
66
|
+
//# debugId=EB2A6F997258A60464756E2164756E21
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"// Verification primitives for formal verification\n// These are runtime no-ops but extracted during verification\n\n/**\n * Assert a precondition that must be true when the handler executes.\n *\n * In production: No-op (compiled away)\n * In verification: Translated to TLA+ assertion\n *\n * @example\n * messageBus.on(\"USER_LOGIN\", (payload) => {\n * requires(state.user.loggedIn === false, \"User must not be logged in\")\n * state.user.loggedIn = true\n * })\n */\nexport function requires(condition: boolean, message?: string): void {\n // Runtime no-op - only used during verification\n // Condition and message are checked during static analysis only\n void condition;\n void message;\n}\n\n/**\n * Assert a postcondition that must be true after the handler completes.\n *\n * In production: No-op (compiled away)\n * In verification: Translated to TLA+ assertion\n *\n * @example\n * messageBus.on(\"USER_LOGIN\", (payload) => {\n * state.user.loggedIn = true\n * ensures(state.user.loggedIn === true, \"User must be logged in\")\n * })\n */\nexport function ensures(condition: boolean, message?: string): void {\n // Runtime no-op - only used during verification\n // Condition and message are checked during static analysis only\n void condition;\n void message;\n}\n\n/**\n * Define a global invariant that must always hold.\n *\n * In production: No-op (compiled away)\n * In verification: Translated to TLA+ invariant\n *\n * @example\n * invariant(\"UserIdConsistent\", () =>\n * state.user.loggedIn === false || state.user.id !== null\n * )\n */\nexport function invariant(_name: string, condition: () => boolean): void {\n // Runtime no-op - only used during verification\n // Name and condition are checked during static analysis only\n void condition;\n}\n\n/**\n * Assert that a value is within a valid range.\n *\n * @example\n * requires(inRange(todoCount, 0, 100), \"Todo count must be 0-100\")\n */\nexport function inRange(value: number, min: number, max: number): boolean {\n return value >= min && value <= max;\n}\n\n/**\n * Assert that a value is one of the allowed values.\n *\n * @example\n * requires(oneOf(state.user.role, [\"admin\", \"user\"]), \"Role must be admin or user\")\n */\nexport function oneOf<T>(value: T, allowed: T[]): boolean {\n return allowed.includes(value);\n}\n\n/**\n * Assert that an array has a specific length constraint.\n *\n * @example\n * requires(hasLength(state.todos, { max: 10 }), \"Too many todos\")\n */\nexport function hasLength(array: unknown[], constraint: { min?: number; max?: number }): boolean {\n if (constraint.min !== undefined && array.length < constraint.min) return false;\n if (constraint.max !== undefined && array.length > constraint.max) return false;\n return true;\n}\n\n/**\n * Declare state-level constraints for verification and optional runtime checking.\n * Maps message types to preconditions on state fields.\n *\n * The parser automatically wires these constraints to handlers during verification.\n * Optionally, constraints can be enforced at runtime by passing `{ runtime: true }`.\n *\n * @example\n * // Verification only (TLA+ generation)\n * const state = { loggedIn: false };\n *\n * $constraints(\"loggedIn\", {\n * USER_LOGOUT: { requires: \"state.loggedIn === true\", message: \"Must be logged in\" },\n * BOOKMARK_ADD: { requires: \"state.loggedIn === true\", message: \"Must be logged in\" },\n * });\n *\n * @example\n * // Runtime enforcement (function predicates)\n * $constraints(\"loggedIn\", {\n * USER_LOGOUT: {\n * requires: (state) => state.loggedIn === true,\n * message: \"Must be logged in to logout\"\n * },\n * }, { runtime: true });\n */\nexport function $constraints(\n stateField: string,\n constraints: Record<\n string,\n {\n requires?: string | ((state: unknown) => boolean);\n ensures?: string | ((state: unknown) => boolean);\n message?: string;\n }\n >,\n options?: { runtime?: boolean }\n): void {\n // Register constraints for runtime checking if enabled\n if (options?.runtime) {\n // Import dynamically to avoid circular dependencies\n // This is safe because it only happens at runtime, not during static analysis\n // @ts-expect-error - Dynamic import path resolves correctly at runtime\n import(\"../../../src/shared/lib/constraints.js\")\n .then(({ registerConstraints }) => {\n registerConstraints(stateField, constraints);\n })\n .catch(() => {\n // Silently ignore - constraints module may not be available during static analysis\n });\n }\n\n // For verification: Still a no-op at runtime\n // Parser extracts these and wires them to TLA+ handlers\n}\n\n/**\n * Declare a global state constraint that prunes structurally impossible states.\n *\n * In production: No-op (compiled away)\n * In verification: Translated to TLC CONSTRAINT clause, discarding states\n * that violate the predicate from the exploration queue entirely.\n *\n * Unlike `invariant()` (which checks but still explores), `stateConstraint()`\n * prevents the model checker from ever reaching the pruned states.\n *\n * @example\n * stateConstraint(\"LeaderRequiresConnection\", () =>\n * !connectionState.value.isLeader || connectionState.value.status === \"connected\"\n * )\n */\nexport function stateConstraint(\n name: string,\n predicate: () => boolean,\n options?: { message?: string }\n): void {\n void name;\n void predicate;\n void options;\n}\n\n/**\n * Cross-peer universal quantifier for use inside `requires` and\n * `ensures` predicates. The runtime is a no-op that simply runs the\n * predicate against a single dummy context (so the assertion never\n * triggers at runtime); the verifier recognizes the wrapper in\n * predicate source and emits a `\\A peer \\in Contexts \\ {ctx} : (...)`\n * clause that asks TLC to check the inner predicate against every\n * other context.\n *\n * @example\n * ensures(\n * forAllPeers(peer => peer.todos.value.length === todos.value.length),\n * \"every peer agrees on todo count\"\n * );\n */\nexport function forAllPeers<TPeer>(predicate: (peer: TPeer) => boolean): boolean {\n void predicate;\n return true;\n}\n\n/**\n * Cross-peer existential quantifier for use inside `requires` and\n * `ensures` predicates. Runtime no-op; the verifier emits a\n * `\\E peer \\in Contexts \\ {ctx} : (...)` clause.\n *\n * @example\n * ensures(\n * somePeer(peer => peer.user.value.loggedIn === true),\n * \"at least one peer has a logged-in user\"\n * );\n */\nexport function somePeer<TPeer>(predicate: (peer: TPeer) => boolean): boolean {\n void predicate;\n return true;\n}\n\n// Re-export for convenience\nexport const verify = {\n requires,\n ensures,\n invariant,\n inRange,\n oneOf,\n hasLength,\n $constraints,\n stateConstraint,\n forAllPeers,\n somePeer,\n};\n",
|
|
6
6
|
"// Configuration Helper for @fairfox/polly/verify\n//\n// Lightweight entry point for user configuration files.\n// Does NOT include heavy dependencies (ts-morph, analysis, etc.)\n// which are only needed by the CLI tool.\n\n// Configuration Types (inlined to avoid heavy dependencies)\n\n// polly#160: a directional capability whose grant requires a precondition.\n// Desugars to a TLA+ safety invariant `(enabledBy) => (requires)`. enabledBy /\n// requires are TS boolean expressions in the requires()/ensures() dialect\n// referencing state via `state.` / signal `.value` form (e.g. \"state.authReady\").\n// Inlined here (like SubsystemConfig) so this authoring entry point stays\n// dependency-light; the canonical type is CapabilityConfig in config/types.ts.\ninterface CapabilityConfig {\n name: string;\n enabledBy: string;\n requires: string;\n message?: string;\n}\n\n// Subsystem configuration for compositional verification\ninterface SubsystemConfig {\n state: string[]; // Field names from parent state config\n handlers: string[]; // Message type names\n // Per-subsystem message bounds; override messages.maxInFlight and merge\n // into messages.perMessageBounds for this subsystem only.\n bounds?: {\n maxInFlight?: number;\n perMessageBounds?: Record<string, number>;\n };\n /** polly#171: check message-resolution liveness for this subsystem only. */\n liveness?: boolean;\n}\n\n// Point a subsystem's reachability witnesses at a hand-written TLA+ spec instead\n// of the generated UserApp_<subsystem>. Inlined here (like SubsystemConfig) to\n// keep this authoring entry point dependency-light; canonical type is\n// CustomTLAPath in config/types.ts.\ninterface CustomTLAPath {\n tla: string; // path (relative to cwd) to the hand-written .tla the witness EXTENDS\n cfg: string; // path (relative to cwd) to its .cfg\n module?: string; // module to EXTEND; defaults to the MODULE name parsed from `tla`\n fields?: Record<string, string>; // BDD field name → this spec's TLA+ variable name\n}\n\n// Legacy verification configuration\ninterface LegacyVerificationConfig {\n state: Record<string, unknown>;\n /**\n * polly#117: optional mesh-document declarations. When present, each\n * key names a `$meshState` document and its value declares the\n * field-level state schema for that document. The verifier emits a\n * separate slot in `contextStates[ctx].mesh[<docId>]` for these\n * fields and adds a `PropagateMeshOp` action that allows the doc's\n * value on one context to flow to another — modelling Automerge\n * sync between peers. Mesh references inside `forAllPeers` quantifiers\n * route through this slot so cross-peer convergence claims are\n * actually checked.\n *\n * @example\n * ```ts\n * defineVerification({\n * state: { localCounter: { type: \"number\", min: 0, max: 3 } },\n * mesh: {\n * todos: {\n * entries: { type: \"enum\", values: [\"empty\", \"one\", \"many\"] },\n * },\n * },\n * messages: { maxInFlight: 2 },\n * });\n * ```\n */\n mesh?: Record<string, Record<string, unknown>>;\n messages: {\n // Basic bounds\n maxInFlight?: number;\n maxTabs?: number;\n maxClients?: number;\n maxRenderers?: number;\n maxWorkers?: number;\n maxContexts?: number;\n\n // Tier 1 Optimizations (no precision loss)\n include?: string[]; // Only verify these message types\n exclude?: string[]; // Exclude these message types (mutually exclusive with include)\n symmetry?: string[][]; // Groups of symmetric message types [[type1, type2], [type3, type4]]\n perMessageBounds?: Record<string, number>; // Different maxInFlight per message type\n };\n onBuild?: \"warn\" | \"error\" | \"off\";\n onRelease?: \"warn\" | \"error\" | \"off\";\n\n // Verification engine options\n verification?: {\n timeout?: number; // Timeout in seconds (0 = no timeout)\n workers?: number; // Number of TLC workers\n };\n\n /**\n * polly#171: check that nothing sent stays pending for ever.\n *\n * Off by default because it is expensive: it adds a temporal property and the\n * routing fairness it needs, and TLC must then explore behaviours rather than\n * only reachable states. Measured on an 11-subsystem consumer model, the full\n * verify gate went from ~110s to ~512s.\n *\n * Every property the generator emits without this is a SAFETY property, and a\n * safety property is true of a system that does nothing at all — so a spec in\n * which routing has stopped verifies identically to one in which it works.\n * Turn this on for the subsystems whose progress actually matters.\n *\n * LIMITATION, and it is Lamport's own warning (Specifying Systems 14.3.5):\n * generated specs also declare a CONSTRAINT to bound the state space, and TLC\n * prints \"Declaring state or action constraints during liveness checking is\n * dangerous\" when both are present. A constraint truncates behaviours at its\n * boundary, so a liveness violation reachable only beyond that boundary is not\n * found. Treat a green liveness run as \"no wedge within the bounds\", not as a\n * proof of progress — the same reading every bounded model-checking result\n * deserves.\n */\n liveness?: boolean;\n\n // Subsystem-scoped verification (compositional)\n subsystems?: Record<string, SubsystemConfig>;\n\n // Bind a subsystem's witnesses to a hand-written .tla/.cfg (read only by the\n // --witness pass; a custom subsystem is skipped during generated-spec verify).\n customTLAPaths?: Record<string, CustomTLAPath>;\n\n // Tier 2 Optimizations (controlled approximations)\n tier2?: {\n // Temporal constraints: ordering requirements between messages\n temporalConstraints?: Array<{\n before: string; // Message type that must occur first\n after: string; // Message type that must occur after\n description?: string; // Human-readable description\n }>;\n\n // Bounded exploration: limit depth for specific scenarios\n boundedExploration?: {\n maxDepth?: number; // Maximum state depth to explore\n criticalPaths?: string[][]; // Sequences of message types that must be fully explored\n };\n };\n\n // polly#160: directional capability invariants + write-coupling lint groups\n capabilities?: CapabilityConfig[];\n coupledFields?: string[][];\n}\n\n// Adapter-based configuration (for future use)\ninterface AdapterVerificationConfig {\n adapter: unknown; // Adapter interface not exported to avoid heavy deps\n state: Record<string, unknown>;\n bounds?: {\n maxInFlight?: number;\n [key: string]: unknown;\n };\n onBuild?: \"warn\" | \"error\" | \"off\";\n\n // polly#160: directional capability invariants + write-coupling lint groups\n capabilities?: CapabilityConfig[];\n coupledFields?: string[][];\n}\n\n// Union type for both config formats\ntype UnifiedVerificationConfig = LegacyVerificationConfig | AdapterVerificationConfig;\n\n/**\n * Define verification configuration with type checking\n *\n * Used in generated verification.config.ts files.\n *\n * @example\n * ```typescript\n * import { defineVerification } from '@fairfox/polly/verify'\n *\n * export default defineVerification({\n * state: {\n * \"user.role\": { type: \"enum\", values: [\"admin\", \"user\", \"guest\"] },\n * },\n * messages: {\n * maxInFlight: 6,\n * maxTabs: 2,\n * },\n * })\n * ```\n */\nexport function defineVerification<T extends UnifiedVerificationConfig>(config: T): T {\n // Validate configuration structure\n if (\"adapter\" in config) {\n // New adapter-based format\n if (!config.adapter) {\n throw new Error(\"Configuration must include an adapter\");\n }\n if (!config.state) {\n throw new Error(\"Configuration must include state bounds\");\n }\n } else if (\"messages\" in config) {\n // Legacy format\n if (!config.state) {\n throw new Error(\"Configuration must include state bounds\");\n }\n if (!config.messages) {\n throw new Error(\"Legacy configuration must include messages bounds\");\n }\n } else {\n throw new Error(\n \"Invalid configuration format. Must include either 'adapter' (new format) or 'messages' (legacy format)\"\n );\n }\n\n return config;\n}\n\n// Re-export verification primitives for user code\nexport {\n $constraints,\n ensures,\n forAllPeers,\n hasLength,\n inRange,\n oneOf,\n requires,\n somePeer,\n stateConstraint,\n} from \"./primitives/index.js\";\n"
|
|
7
7
|
],
|
|
8
|
-
"mappings": "
|
|
9
|
-
"debugId": "
|
|
8
|
+
"mappings": ";AAeO,SAAS,QAAQ,CAAC,WAAoB,SAAwB;AAmB9D,SAAS,OAAO,CAAC,WAAoB,SAAwB;AA8B7D,SAAS,OAAO,CAAC,OAAe,KAAa,KAAsB;AAAA,EACxE,OAAO,SAAS,OAAO,SAAS;AAAA;AAS3B,SAAS,KAAQ,CAAC,OAAU,SAAuB;AAAA,EACxD,OAAO,QAAQ,SAAS,KAAK;AAAA;AASxB,SAAS,SAAS,CAAC,OAAkB,YAAqD;AAAA,EAC/F,IAAI,WAAW,QAAQ,aAAa,MAAM,SAAS,WAAW;AAAA,IAAK,OAAO;AAAA,EAC1E,IAAI,WAAW,QAAQ,aAAa,MAAM,SAAS,WAAW;AAAA,IAAK,OAAO;AAAA,EAC1E,OAAO;AAAA;AA4BF,SAAS,YAAY,CAC1B,YACA,aAQA,SACM;AAAA,EAEN,IAAI,SAAS,SAAS;AAAA,IAIb,iDACJ,KAAK,GAAG,0BAA0B;AAAA,MACjC,oBAAoB,YAAY,WAAW;AAAA,KAC5C,EACA,MAAM,MAAM,EAEZ;AAAA,EACL;AAAA;AAqBK,SAAS,eAAe,CAC7B,MACA,WACA,SACM;AAqBD,SAAS,WAAkB,CAAC,WAA8C;AAAA,EAE/E,OAAO;AAAA;AAcF,SAAS,QAAe,CAAC,WAA8C;AAAA,EAE5E,OAAO;AAAA;;;ACfF,SAAS,kBAAuD,CAAC,QAAc;AAAA,EAEpF,IAAI,aAAa,QAAQ;AAAA,IAEvB,IAAI,CAAC,OAAO,SAAS;AAAA,MACnB,MAAM,IAAI,MAAM,uCAAuC;AAAA,IACzD;AAAA,IACA,IAAI,CAAC,OAAO,OAAO;AAAA,MACjB,MAAM,IAAI,MAAM,yCAAyC;AAAA,IAC3D;AAAA,EACF,EAAO,SAAI,cAAc,QAAQ;AAAA,IAE/B,IAAI,CAAC,OAAO,OAAO;AAAA,MACjB,MAAM,IAAI,MAAM,yCAAyC;AAAA,IAC3D;AAAA,IACA,IAAI,CAAC,OAAO,UAAU;AAAA,MACpB,MAAM,IAAI,MAAM,mDAAmD;AAAA,IACrE;AAAA,EACF,EAAO;AAAA,IACL,MAAM,IAAI,MACR,wGACF;AAAA;AAAA,EAGF,OAAO;AAAA;",
|
|
9
|
+
"debugId": "EB2A6F997258A60464756E2164756E21",
|
|
10
10
|
"names": []
|
|
11
11
|
}
|
|
@@ -1,21 +1,3 @@
|
|
|
1
|
-
import { createRequire } from "node:module";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __returnValue = (v) => v;
|
|
4
|
-
function __exportSetter(name, newValue) {
|
|
5
|
-
this[name] = __returnValue.bind(null, newValue);
|
|
6
|
-
}
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, {
|
|
10
|
-
get: all[name],
|
|
11
|
-
enumerable: true,
|
|
12
|
-
configurable: true,
|
|
13
|
-
set: __exportSetter.bind(all, name)
|
|
14
|
-
});
|
|
15
|
-
};
|
|
16
|
-
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
17
|
-
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
18
|
-
|
|
19
1
|
// tools/verify/src/stryker/index.ts
|
|
20
2
|
import {
|
|
21
3
|
commonTokens,
|
|
@@ -101,4 +83,4 @@ export {
|
|
|
101
83
|
strykerPlugins
|
|
102
84
|
};
|
|
103
85
|
|
|
104
|
-
//# debugId=
|
|
86
|
+
//# debugId=E1FCF7B89389BBE564756E2164756E21
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"sourcesContent": [
|
|
5
5
|
"// Stryker mutation-testing ignorer for polly's verify primitives (polly#143).\n//\n// `requires`, `ensures`, `invariant`, `stateConstraint`, `forAllPeers`, and\n// `somePeer` are runtime no-ops: in production they compile away, in\n// verification they translate to TLA+ assertions. Nothing observes their\n// condition or message argument at test runtime, so EVERY mutation inside one\n// of these callsites is guaranteed to survive — a string-literal flip in an\n// `ensures(...)` message, an `===` → equality mutation in a `requires(...)`\n// condition. On a downstream project mutating six state-machine specs this\n// dragged the mutation score down to 21%, all of it noise rather than real\n// test-coverage gaps.\n//\n// Polly is the right place to ship this knowledge: it knows which of its\n// primitives are no-ops. This module is a Stryker `Ignore` plugin that marks\n// every mutant inside a verify callsite as ignored, plus a small config preset\n// consumers can spread into their `stryker.conf.*`.\n//\n// Usage (stryker.conf.json):\n//\n// {\n// \"plugins\": [\"@fairfox/polly/stryker\"],\n// \"ignorers\": [\"polly-verify\"]\n// }\n//\n// Or, in stryker.conf.mjs:\n//\n// import pollyStrykerPreset from \"@fairfox/polly/stryker\";\n// export default { ...pollyStrykerPreset, mutate: [\"src/**/*.ts\"] };\n//\n// Set `\"polly\": { \"excludeVerifyCallsites\": false }` to keep the plugin listed\n// but disable the ignoring (e.g. in a shared base config).\n\nimport type { StrykerOptions } from \"@stryker-mutator/api/core\";\nimport type { Ignorer, NodePath } from \"@stryker-mutator/api/ignore\";\nimport {\n commonTokens,\n declareFactoryPlugin,\n PluginKind,\n tokens,\n} from \"@stryker-mutator/api/plugin\";\n\n/**\n * The polly verify primitives whose argument expressions are runtime no-ops.\n * A mutation anywhere inside a call to one of these cannot be killed by a test,\n * so its mutants are excluded from scoring.\n */\nexport const VERIFY_PRIMITIVES: ReadonlySet<string> = new Set([\n \"requires\",\n \"ensures\",\n \"invariant\",\n \"stateConstraint\",\n \"forAllPeers\",\n \"somePeer\",\n]);\n\n/** The Stryker plugin name consumers reference in `ignorers`. */\nexport const POLLY_VERIFY_IGNORER_NAME = \"polly-verify\";\n\n// The Stryker API types `NodePath` as an empty interface; at runtime it is a\n// Babel NodePath. We narrow only the surface we touch — `isCallExpression()`\n// and `node.callee` — without pulling in @babel/types as a dependency.\ninterface BabelIdentifier {\n type: \"Identifier\";\n name: string;\n}\ninterface BabelMemberExpression {\n type: \"MemberExpression\";\n computed: boolean;\n property: { type: string; name?: string };\n}\ntype BabelCallee = BabelIdentifier | BabelMemberExpression | { type: string };\ninterface CallExpressionPath extends NodePath {\n isCallExpression(): boolean;\n node: { callee?: BabelCallee };\n}\n\n/** Narrow the opaque `NodePath` to the Babel surface we touch. */\nfunction isCallExpressionPath(path: NodePath): path is CallExpressionPath {\n return \"isCallExpression\" in path && typeof path.isCallExpression === \"function\";\n}\n\n/**\n * Resolve the simple name of a call's callee, covering both a bare call\n * (`ensures(...)`) and a member call (`verify.ensures(...)` / `polly.ensures(...)`).\n * Computed member access (`obj[\"ensures\"](...)`) is intentionally not matched —\n * it cannot be resolved statically and is not a pattern polly emits.\n */\nfunction isBabelIdentifier(callee: BabelCallee): callee is BabelIdentifier {\n return callee.type === \"Identifier\";\n}\n\nfunction isBabelMemberExpression(callee: BabelCallee): callee is BabelMemberExpression {\n return callee.type === \"MemberExpression\";\n}\n\nfunction calleeName(callee: BabelCallee | undefined): string | undefined {\n if (!callee) return undefined;\n if (isBabelIdentifier(callee)) {\n return callee.name;\n }\n if (isBabelMemberExpression(callee)) {\n if (!callee.computed && callee.property.type === \"Identifier\") {\n return callee.property.name;\n }\n }\n return undefined;\n}\n\n/**\n * A Stryker `Ignore` plugin. Stryker calls `shouldIgnore` on entering each AST\n * node; returning a message marks that node — and every descendant, until the\n * node is left — as ignored. So matching the verify `CallExpression` itself\n * covers its condition and message arguments in one shot.\n */\nexport class PollyVerifyIgnorer implements Ignorer {\n constructor(private readonly primitives: ReadonlySet<string> = VERIFY_PRIMITIVES) {}\n\n shouldIgnore(path: NodePath): string | undefined {\n if (!isCallExpressionPath(path) || !path.isCallExpression()) {\n return undefined;\n }\n const name = calleeName(path.node.callee);\n if (name && this.primitives.has(name)) {\n return (\n `Inside polly's ${name}(...) — a runtime no-op (compiled away in production, ` +\n `translated to a TLA+ assertion in verification). No test can observe or kill ` +\n `mutations here, so they are excluded from the score (polly#143).`\n );\n }\n return undefined;\n }\n}\n\n/** Reads `polly.excludeVerifyCallsites` (default: enabled) off Stryker options. */\nfunction isEnabled(options: StrykerOptions): boolean {\n const polly = options[\"polly\"];\n if (typeof polly !== \"object\" || polly === null) return true;\n return !(\"excludeVerifyCallsites\" in polly) || polly.excludeVerifyCallsites !== false;\n}\n\n// When disabled the plugin still loads but ignores nothing, so a shared config\n// can list it unconditionally and individual projects opt out via options.\nconst NOOP_IGNORER: Ignorer = { shouldIgnore: () => undefined };\n\nfunction pollyVerifyIgnorerFactory(options: StrykerOptions): Ignorer {\n return isEnabled(options) ? new PollyVerifyIgnorer() : NOOP_IGNORER;\n}\npollyVerifyIgnorerFactory.inject = tokens(commonTokens.options);\n\n/** The plugin array Stryker reads when this module is listed in `plugins`. */\nexport const strykerPlugins = [\n declareFactoryPlugin(PluginKind.Ignore, POLLY_VERIFY_IGNORER_NAME, pollyVerifyIgnorerFactory),\n];\n\n/**\n * A partial Stryker config that wires up the ignorer. Spread it into a\n * `stryker.conf.mjs` default export, or replicate its two keys in JSON.\n */\nexport const pollyStrykerPreset = {\n plugins: [\"@fairfox/polly/stryker\"],\n ignorers: [POLLY_VERIFY_IGNORER_NAME],\n} as const;\n\n// biome-ignore lint/style/noDefaultExport: ergonomic `import preset from \"@fairfox/polly/stryker\"`\nexport default pollyStrykerPreset;\n"
|
|
6
6
|
],
|
|
7
|
-
"mappings": "
|
|
8
|
-
"debugId": "
|
|
7
|
+
"mappings": ";AAkCA;AAAA;AAAA;AAAA;AAAA;AAAA;AAYO,IAAM,oBAAyC,IAAI,IAAI;AAAA,EAC5D;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAGM,IAAM,4BAA4B;AAqBzC,SAAS,oBAAoB,CAAC,MAA4C;AAAA,EACxE,OAAO,sBAAsB,QAAQ,OAAO,KAAK,qBAAqB;AAAA;AASxE,SAAS,iBAAiB,CAAC,QAAgD;AAAA,EACzE,OAAO,OAAO,SAAS;AAAA;AAGzB,SAAS,uBAAuB,CAAC,QAAsD;AAAA,EACrF,OAAO,OAAO,SAAS;AAAA;AAGzB,SAAS,UAAU,CAAC,QAAqD;AAAA,EACvE,IAAI,CAAC;AAAA,IAAQ;AAAA,EACb,IAAI,kBAAkB,MAAM,GAAG;AAAA,IAC7B,OAAO,OAAO;AAAA,EAChB;AAAA,EACA,IAAI,wBAAwB,MAAM,GAAG;AAAA,IACnC,IAAI,CAAC,OAAO,YAAY,OAAO,SAAS,SAAS,cAAc;AAAA,MAC7D,OAAO,OAAO,SAAS;AAAA,IACzB;AAAA,EACF;AAAA,EACA;AAAA;AAAA;AASK,MAAM,mBAAsC;AAAA,EACpB;AAAA,EAA7B,WAAW,CAAkB,aAAkC,mBAAmB;AAAA,IAArD;AAAA;AAAA,EAE7B,YAAY,CAAC,MAAoC;AAAA,IAC/C,IAAI,CAAC,qBAAqB,IAAI,KAAK,CAAC,KAAK,iBAAiB,GAAG;AAAA,MAC3D;AAAA,IACF;AAAA,IACA,MAAM,OAAO,WAAW,KAAK,KAAK,MAAM;AAAA,IACxC,IAAI,QAAQ,KAAK,WAAW,IAAI,IAAI,GAAG;AAAA,MACrC,OACE,kBAAkB,+DAClB,kFACA;AAAA,IAEJ;AAAA,IACA;AAAA;AAEJ;AAGA,SAAS,SAAS,CAAC,SAAkC;AAAA,EACnD,MAAM,QAAQ,QAAQ;AAAA,EACtB,IAAI,OAAO,UAAU,YAAY,UAAU;AAAA,IAAM,OAAO;AAAA,EACxD,OAAO,EAAE,4BAA4B,UAAU,MAAM,2BAA2B;AAAA;AAKlF,IAAM,eAAwB,EAAE,cAAc,MAAG;AAAA,EAAG;AAAA,EAAU;AAE9D,SAAS,yBAAyB,CAAC,SAAkC;AAAA,EACnE,OAAO,UAAU,OAAO,IAAI,IAAI,qBAAuB;AAAA;AAEzD,0BAA0B,SAAS,OAAO,aAAa,OAAO;AAGvD,IAAM,iBAAiB;AAAA,EAC5B,qBAAqB,WAAW,QAAQ,2BAA2B,yBAAyB;AAC9F;AAMO,IAAM,qBAAqB;AAAA,EAChC,SAAS,CAAC,wBAAwB;AAAA,EAClC,UAAU,CAAC,yBAAyB;AACtC;AAGA,IAAe;",
|
|
8
|
+
"debugId": "E1FCF7B89389BBE564756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|
|
@@ -1,28 +1,19 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
configurable: true,
|
|
14
|
-
set: __exportSetter.bind(all, name)
|
|
15
|
-
});
|
|
3
|
+
var __esm = (fn, res, err) => () => {
|
|
4
|
+
if (fn)
|
|
5
|
+
try {
|
|
6
|
+
res = fn(fn = 0);
|
|
7
|
+
} catch (e) {
|
|
8
|
+
err = [e];
|
|
9
|
+
}
|
|
10
|
+
if (err)
|
|
11
|
+
throw err[0];
|
|
12
|
+
return res;
|
|
16
13
|
};
|
|
17
|
-
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
18
14
|
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
19
15
|
|
|
20
16
|
// tools/analysis/src/extract/project-detector.ts
|
|
21
|
-
var exports_project_detector = {};
|
|
22
|
-
__export(exports_project_detector, {
|
|
23
|
-
ProjectDetector: () => ProjectDetector,
|
|
24
|
-
detectProjectConfig: () => detectProjectConfig
|
|
25
|
-
});
|
|
26
17
|
import * as fs3 from "node:fs";
|
|
27
18
|
import * as path3 from "node:path";
|
|
28
19
|
|
|
@@ -679,13 +670,6 @@ function sanitizeKind(kind) {
|
|
|
679
670
|
var CONTAINER_NAME_PREFIX = "polly-tla-", counter = 0;
|
|
680
671
|
|
|
681
672
|
// tools/verify/src/runner/docker.ts
|
|
682
|
-
var exports_docker = {};
|
|
683
|
-
__export(exports_docker, {
|
|
684
|
-
DockerRunner: () => DockerRunner,
|
|
685
|
-
removeContainer: () => removeContainer,
|
|
686
|
-
sweepOrphanedContainers: () => sweepOrphanedContainers,
|
|
687
|
-
sweepOrphanedContainersOnce: () => sweepOrphanedContainersOnce
|
|
688
|
-
});
|
|
689
673
|
import { spawn, spawnSync } from "node:child_process";
|
|
690
674
|
import * as fs6 from "node:fs";
|
|
691
675
|
import * as path5 from "node:path";
|
|
@@ -867,7 +851,7 @@ class DockerRunner {
|
|
|
867
851
|
return "Unknown error occurred during model checking";
|
|
868
852
|
}
|
|
869
853
|
runCommand(command, args, options) {
|
|
870
|
-
return new Promise((
|
|
854
|
+
return new Promise((resolve, reject) => {
|
|
871
855
|
const proc = spawn(command, args);
|
|
872
856
|
let stdout = "";
|
|
873
857
|
let stderr = "";
|
|
@@ -888,7 +872,7 @@ class DockerRunner {
|
|
|
888
872
|
proc.on("close", (exitCode) => {
|
|
889
873
|
if (timeout)
|
|
890
874
|
clearTimeout(timeout);
|
|
891
|
-
|
|
875
|
+
resolve({
|
|
892
876
|
exitCode: exitCode || 0,
|
|
893
877
|
stdout,
|
|
894
878
|
stderr
|
|
@@ -902,7 +886,7 @@ class DockerRunner {
|
|
|
902
886
|
});
|
|
903
887
|
}
|
|
904
888
|
runCommandStreaming(command, args, onOutput, timeout) {
|
|
905
|
-
return new Promise((
|
|
889
|
+
return new Promise((resolve, reject) => {
|
|
906
890
|
const proc = spawn(command, args);
|
|
907
891
|
const timeoutHandle = timeout && timeout > 0 ? setTimeout(() => {
|
|
908
892
|
proc.kill();
|
|
@@ -934,7 +918,7 @@ class DockerRunner {
|
|
|
934
918
|
if (timeoutHandle)
|
|
935
919
|
clearTimeout(timeoutHandle);
|
|
936
920
|
if (exitCode === 0) {
|
|
937
|
-
|
|
921
|
+
resolve();
|
|
938
922
|
} else {
|
|
939
923
|
reject(new Error(`Command failed with exit code ${exitCode}`));
|
|
940
924
|
}
|
|
@@ -1585,7 +1569,7 @@ class FlowAnalyzer {
|
|
|
1585
1569
|
if (filePath.startsWith(pathPrefix))
|
|
1586
1570
|
return context;
|
|
1587
1571
|
}
|
|
1588
|
-
const
|
|
1572
|
+
const path = filePath.toLowerCase();
|
|
1589
1573
|
const contextPatterns = [
|
|
1590
1574
|
{ context: "background", patterns: ["/background/", "\\background\\"] },
|
|
1591
1575
|
{ context: "content", patterns: ["/content/", "\\content\\"] },
|
|
@@ -1598,7 +1582,7 @@ class FlowAnalyzer {
|
|
|
1598
1582
|
{ context: "worker", patterns: ["/worker/", "\\worker\\", "service-worker"] }
|
|
1599
1583
|
];
|
|
1600
1584
|
for (const { context, patterns } of contextPatterns) {
|
|
1601
|
-
if (patterns.some((pattern) =>
|
|
1585
|
+
if (patterns.some((pattern) => path.includes(pattern))) {
|
|
1602
1586
|
return context;
|
|
1603
1587
|
}
|
|
1604
1588
|
}
|
|
@@ -1655,9 +1639,9 @@ class RelationshipExtractor {
|
|
|
1655
1639
|
return;
|
|
1656
1640
|
}
|
|
1657
1641
|
if (Node3.isPropertyAccessExpression(expr)) {
|
|
1658
|
-
const
|
|
1659
|
-
if (
|
|
1660
|
-
relationships.push(
|
|
1642
|
+
const rel = this.extractFromPropertyAccess(expr, handlerName);
|
|
1643
|
+
if (rel) {
|
|
1644
|
+
relationships.push(rel);
|
|
1661
1645
|
return;
|
|
1662
1646
|
}
|
|
1663
1647
|
}
|
|
@@ -2985,9 +2969,9 @@ class HandlerExtractor {
|
|
|
2985
2969
|
return;
|
|
2986
2970
|
}
|
|
2987
2971
|
if (Node4.isIdentifier(initializer)) {
|
|
2988
|
-
const
|
|
2989
|
-
if (this.currentFunctionParams.includes(
|
|
2990
|
-
assignments.push({ field, value: `param:${
|
|
2972
|
+
const paramName = initializer.getText();
|
|
2973
|
+
if (this.currentFunctionParams.includes(paramName)) {
|
|
2974
|
+
assignments.push({ field, value: `param:${paramName}` });
|
|
2991
2975
|
return;
|
|
2992
2976
|
}
|
|
2993
2977
|
}
|
|
@@ -3825,56 +3809,56 @@ class HandlerExtractor {
|
|
|
3825
3809
|
if (filePath.startsWith(pathPrefix))
|
|
3826
3810
|
return context;
|
|
3827
3811
|
}
|
|
3828
|
-
const
|
|
3829
|
-
return this.inferElectronContext(
|
|
3812
|
+
const path = filePath.toLowerCase();
|
|
3813
|
+
return this.inferElectronContext(path) || this.inferWorkerContext(path) || this.inferServerAppContext(path) || this.inferChromeExtensionContext(path) || "unknown";
|
|
3830
3814
|
}
|
|
3831
|
-
inferElectronContext(
|
|
3832
|
-
if (
|
|
3815
|
+
inferElectronContext(path) {
|
|
3816
|
+
if (path.includes("main.ts") || path.includes("main.js") || path.includes("/main/") || path.includes("\\main\\")) {
|
|
3833
3817
|
return "main";
|
|
3834
3818
|
}
|
|
3835
|
-
if (
|
|
3819
|
+
if (path.includes("/renderer/") || path.includes("\\renderer\\") || path.includes("renderer.ts") || path.includes("renderer.js")) {
|
|
3836
3820
|
return "renderer";
|
|
3837
3821
|
}
|
|
3838
|
-
if (
|
|
3822
|
+
if (path.includes("preload.ts") || path.includes("preload.js")) {
|
|
3839
3823
|
return "preload";
|
|
3840
3824
|
}
|
|
3841
3825
|
return null;
|
|
3842
3826
|
}
|
|
3843
|
-
inferWorkerContext(
|
|
3844
|
-
if (
|
|
3827
|
+
inferWorkerContext(path) {
|
|
3828
|
+
if (path.includes("service-worker") || path.includes("sw.ts") || path.includes("sw.js")) {
|
|
3845
3829
|
return "worker";
|
|
3846
3830
|
}
|
|
3847
|
-
if (
|
|
3831
|
+
if (path.includes("/worker/") || path.includes("\\worker\\")) {
|
|
3848
3832
|
return "worker";
|
|
3849
3833
|
}
|
|
3850
3834
|
return null;
|
|
3851
3835
|
}
|
|
3852
|
-
inferServerAppContext(
|
|
3853
|
-
if (
|
|
3836
|
+
inferServerAppContext(path) {
|
|
3837
|
+
if (path.includes("/server/") || path.includes("\\server\\") || path.includes("/server.") || path.includes("server.ts") || path.includes("server.js")) {
|
|
3854
3838
|
return "server";
|
|
3855
3839
|
}
|
|
3856
|
-
if (
|
|
3840
|
+
if (path.includes("/client/") || path.includes("\\client\\") || path.includes("/client.")) {
|
|
3857
3841
|
return "client";
|
|
3858
3842
|
}
|
|
3859
3843
|
return null;
|
|
3860
3844
|
}
|
|
3861
|
-
inferChromeExtensionContext(
|
|
3862
|
-
if (
|
|
3845
|
+
inferChromeExtensionContext(path) {
|
|
3846
|
+
if (path.includes("/background/") || path.includes("\\background\\")) {
|
|
3863
3847
|
return "background";
|
|
3864
3848
|
}
|
|
3865
|
-
if (
|
|
3849
|
+
if (path.includes("/content/") || path.includes("\\content\\")) {
|
|
3866
3850
|
return "content";
|
|
3867
3851
|
}
|
|
3868
|
-
if (
|
|
3852
|
+
if (path.includes("/popup/") || path.includes("\\popup\\")) {
|
|
3869
3853
|
return "popup";
|
|
3870
3854
|
}
|
|
3871
|
-
if (
|
|
3855
|
+
if (path.includes("/devtools/") || path.includes("\\devtools\\")) {
|
|
3872
3856
|
return "devtools";
|
|
3873
3857
|
}
|
|
3874
|
-
if (
|
|
3858
|
+
if (path.includes("/options/") || path.includes("\\options\\")) {
|
|
3875
3859
|
return "options";
|
|
3876
3860
|
}
|
|
3877
|
-
if (
|
|
3861
|
+
if (path.includes("/offscreen/") || path.includes("\\offscreen\\")) {
|
|
3878
3862
|
return "offscreen";
|
|
3879
3863
|
}
|
|
3880
3864
|
return null;
|
|
@@ -4254,9 +4238,9 @@ class HandlerExtractor {
|
|
|
4254
4238
|
const left = node.getLeft();
|
|
4255
4239
|
if (!Node4.isPropertyAccessExpression(left))
|
|
4256
4240
|
return;
|
|
4257
|
-
const
|
|
4241
|
+
const path = this.getPropertyPath(left);
|
|
4258
4242
|
for (const varName of stateVarNames) {
|
|
4259
|
-
if (
|
|
4243
|
+
if (path === `${varName}.value`) {
|
|
4260
4244
|
const right = node.getRight();
|
|
4261
4245
|
if (Node4.isObjectLiteralExpression(right)) {
|
|
4262
4246
|
this.extractObjectLiteralAssignments(right, mutations, varName);
|
|
@@ -4264,8 +4248,8 @@ class HandlerExtractor {
|
|
|
4264
4248
|
break;
|
|
4265
4249
|
}
|
|
4266
4250
|
const fieldPrefix = `${varName}.value.`;
|
|
4267
|
-
if (
|
|
4268
|
-
const fieldName =
|
|
4251
|
+
if (path.startsWith(fieldPrefix)) {
|
|
4252
|
+
const fieldName = path.substring(fieldPrefix.length);
|
|
4269
4253
|
const value = this.extractValue(node.getRight());
|
|
4270
4254
|
mutations.push({ field: `${varName}_${fieldName}`, value: value ?? "@" });
|
|
4271
4255
|
break;
|
|
@@ -4350,13 +4334,13 @@ class HandlerExtractor {
|
|
|
4350
4334
|
return [{ field: match.signal, ...base }];
|
|
4351
4335
|
return fields.map((f) => ({ field: `${match.signal}_${f}`, ...base }));
|
|
4352
4336
|
}
|
|
4353
|
-
matchVerifiedStateWrite(
|
|
4337
|
+
matchVerifiedStateWrite(path, stateVarNames) {
|
|
4354
4338
|
for (const varName of stateVarNames) {
|
|
4355
|
-
if (
|
|
4339
|
+
if (path === `${varName}.value`)
|
|
4356
4340
|
return { signal: varName };
|
|
4357
4341
|
const prefix = `${varName}.value.`;
|
|
4358
|
-
if (
|
|
4359
|
-
return { signal: varName, field:
|
|
4342
|
+
if (path.startsWith(prefix))
|
|
4343
|
+
return { signal: varName, field: path.substring(prefix.length) };
|
|
4360
4344
|
}
|
|
4361
4345
|
return null;
|
|
4362
4346
|
}
|
|
@@ -5073,8 +5057,8 @@ class ArchitectureAnalyzer {
|
|
|
5073
5057
|
}
|
|
5074
5058
|
};
|
|
5075
5059
|
}
|
|
5076
|
-
|
|
5077
|
-
const projectConfig =
|
|
5060
|
+
await Promise.resolve().then(() => init_project_detector());
|
|
5061
|
+
const projectConfig = detectProjectConfig(this.options.projectRoot);
|
|
5078
5062
|
return {
|
|
5079
5063
|
projectConfig,
|
|
5080
5064
|
entryPoints: projectConfig.entryPoints,
|
|
@@ -5175,47 +5159,47 @@ function isObject(value) {
|
|
|
5175
5159
|
function isStringArray(value) {
|
|
5176
5160
|
return Array.isArray(value) && value.every((v) => typeof v === "string");
|
|
5177
5161
|
}
|
|
5178
|
-
function requireStringArray(value,
|
|
5162
|
+
function requireStringArray(value, path) {
|
|
5179
5163
|
if (!isStringArray(value)) {
|
|
5180
|
-
throw new MeshSnapshotError(`${
|
|
5164
|
+
throw new MeshSnapshotError(`${path} must be an array of strings`);
|
|
5181
5165
|
}
|
|
5182
5166
|
return value;
|
|
5183
5167
|
}
|
|
5184
|
-
function validateHandle(value,
|
|
5168
|
+
function validateHandle(value, path) {
|
|
5185
5169
|
if (!isObject(value)) {
|
|
5186
|
-
throw new MeshSnapshotError(`${
|
|
5170
|
+
throw new MeshSnapshotError(`${path} must be an object`);
|
|
5187
5171
|
}
|
|
5188
5172
|
if (typeof value["docSynchronizerExists"] !== "boolean") {
|
|
5189
|
-
throw new MeshSnapshotError(`${
|
|
5173
|
+
throw new MeshSnapshotError(`${path}.docSynchronizerExists must be a boolean`);
|
|
5190
5174
|
}
|
|
5191
5175
|
const knowsPeer = value["docSynchronizerKnowsPeer"];
|
|
5192
5176
|
if (knowsPeer !== undefined && typeof knowsPeer !== "boolean") {
|
|
5193
|
-
throw new MeshSnapshotError(`${
|
|
5177
|
+
throw new MeshSnapshotError(`${path}.docSynchronizerKnowsPeer must be a boolean or absent`);
|
|
5194
5178
|
}
|
|
5195
5179
|
const status = value["peerDocumentStatus"];
|
|
5196
5180
|
if (status !== undefined && typeof status !== "string") {
|
|
5197
|
-
throw new MeshSnapshotError(`${
|
|
5181
|
+
throw new MeshSnapshotError(`${path}.peerDocumentStatus must be a string or absent`);
|
|
5198
5182
|
}
|
|
5199
5183
|
return value;
|
|
5200
5184
|
}
|
|
5201
|
-
function validatePeer(value,
|
|
5185
|
+
function validatePeer(value, path) {
|
|
5202
5186
|
if (!isObject(value)) {
|
|
5203
|
-
throw new MeshSnapshotError(`${
|
|
5187
|
+
throw new MeshSnapshotError(`${path} must be an object`);
|
|
5204
5188
|
}
|
|
5205
5189
|
if (typeof value["peerId"] !== "string") {
|
|
5206
|
-
throw new MeshSnapshotError(`${
|
|
5190
|
+
throw new MeshSnapshotError(`${path}.peerId must be a string`);
|
|
5207
5191
|
}
|
|
5208
5192
|
const slot = value["slot"];
|
|
5209
5193
|
if (slot !== undefined && slot !== null) {
|
|
5210
5194
|
if (!isObject(slot)) {
|
|
5211
|
-
throw new MeshSnapshotError(`${
|
|
5195
|
+
throw new MeshSnapshotError(`${path}.slot must be an object or absent`);
|
|
5212
5196
|
}
|
|
5213
5197
|
const handles = slot["handles"];
|
|
5214
5198
|
if (!isObject(handles)) {
|
|
5215
|
-
throw new MeshSnapshotError(`${
|
|
5199
|
+
throw new MeshSnapshotError(`${path}.slot.handles must be an object`);
|
|
5216
5200
|
}
|
|
5217
5201
|
for (const [docId, handle] of Object.entries(handles)) {
|
|
5218
|
-
validateHandle(handle, `${
|
|
5202
|
+
validateHandle(handle, `${path}.slot.handles[${docId}]`);
|
|
5219
5203
|
}
|
|
5220
5204
|
}
|
|
5221
5205
|
return value;
|
|
@@ -6964,7 +6948,7 @@ class DiagramExporter {
|
|
|
6964
6948
|
}
|
|
6965
6949
|
}
|
|
6966
6950
|
async pullImage(onProgress) {
|
|
6967
|
-
return new Promise((
|
|
6951
|
+
return new Promise((resolve, reject) => {
|
|
6968
6952
|
const proc = spawn2("docker", ["pull", DiagramExporter.DOCKER_IMAGE]);
|
|
6969
6953
|
proc.stdout.on("data", (data) => {
|
|
6970
6954
|
onProgress?.(data.toString().trim());
|
|
@@ -6974,7 +6958,7 @@ class DiagramExporter {
|
|
|
6974
6958
|
});
|
|
6975
6959
|
proc.on("close", (code) => {
|
|
6976
6960
|
if (code === 0) {
|
|
6977
|
-
|
|
6961
|
+
resolve();
|
|
6978
6962
|
} else {
|
|
6979
6963
|
reject(new Error(`Failed to pull image, exit code: ${code}`));
|
|
6980
6964
|
}
|
|
@@ -6988,7 +6972,7 @@ class DiagramExporter {
|
|
|
6988
6972
|
return this.runCommand("docker", args, timeout, containerName);
|
|
6989
6973
|
}
|
|
6990
6974
|
async runCommand(command, args, timeout, containerName) {
|
|
6991
|
-
return new Promise((
|
|
6975
|
+
return new Promise((resolve, reject) => {
|
|
6992
6976
|
const proc = spawn2(command, args);
|
|
6993
6977
|
let stdout = "";
|
|
6994
6978
|
let stderr = "";
|
|
@@ -7008,7 +6992,7 @@ class DiagramExporter {
|
|
|
7008
6992
|
proc.on("close", (code) => {
|
|
7009
6993
|
clearTimeout(timer);
|
|
7010
6994
|
if (code === 0) {
|
|
7011
|
-
|
|
6995
|
+
resolve(stdout);
|
|
7012
6996
|
} else {
|
|
7013
6997
|
reject(new Error(`Command failed with exit code ${code}: ${stderr}`));
|
|
7014
6998
|
}
|
|
@@ -7381,4 +7365,4 @@ main().catch((_error) => {
|
|
|
7381
7365
|
process.exit(1);
|
|
7382
7366
|
});
|
|
7383
7367
|
|
|
7384
|
-
//# debugId=
|
|
7368
|
+
//# debugId=811B37412DDADF3664756E2164756E21
|