@heal-dev/heal-playwright-tracer 1.0.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/LICENSE +661 -0
- package/README.md +245 -0
- package/dist/application/babel-playwright-tracer-plugin/index.d.ts +16 -0
- package/dist/application/babel-playwright-tracer-plugin/index.js +111 -0
- package/dist/application/heal-config/index.d.ts +8 -0
- package/dist/application/heal-config/index.js +22 -0
- package/dist/application/heal-config/registry.d.ts +37 -0
- package/dist/application/heal-config/registry.js +64 -0
- package/dist/application/heal-config/types.d.ts +73 -0
- package/dist/application/heal-config/types.js +7 -0
- package/dist/application/playwright-fixture/index.d.ts +14 -0
- package/dist/application/playwright-fixture/index.js +234 -0
- package/dist/application/trace-event-recorder-runtime/index.d.ts +15 -0
- package/dist/application/trace-event-recorder-runtime/index.js +68 -0
- package/dist/domain/code-hook-injector/service/meta-fields/enclosing-scope-labeler.d.ts +12 -0
- package/dist/domain/code-hook-injector/service/meta-fields/enclosing-scope-labeler.js +53 -0
- package/dist/domain/code-hook-injector/service/meta-fields/leading-comment-extractor.d.ts +14 -0
- package/dist/domain/code-hook-injector/service/meta-fields/leading-comment-extractor.js +20 -0
- package/dist/domain/code-hook-injector/service/meta-fields/relative-file-path.d.ts +6 -0
- package/dist/domain/code-hook-injector/service/meta-fields/relative-file-path.js +57 -0
- package/dist/domain/code-hook-injector/service/meta-fields/source-snippet-extractor.d.ts +12 -0
- package/dist/domain/code-hook-injector/service/meta-fields/source-snippet-extractor.js +28 -0
- package/dist/domain/code-hook-injector/service/playwright-import-rewriter.d.ts +10 -0
- package/dist/domain/code-hook-injector/service/playwright-import-rewriter.js +21 -0
- package/dist/domain/code-hook-injector/service/statement-analysis/cjs-artifact-detector.d.ts +14 -0
- package/dist/domain/code-hook-injector/service/statement-analysis/cjs-artifact-detector.js +30 -0
- package/dist/domain/code-hook-injector/service/statement-analysis/for-head-declaration-detector.d.ts +10 -0
- package/dist/domain/code-hook-injector/service/statement-analysis/for-head-declaration-detector.js +18 -0
- package/dist/domain/code-hook-injector/service/statement-analysis/leaf-statement-classifier.d.ts +15 -0
- package/dist/domain/code-hook-injector/service/statement-analysis/leaf-statement-classifier.js +66 -0
- package/dist/domain/code-hook-injector/service/statement-analysis/non-wrappable-statement.d.ts +11 -0
- package/dist/domain/code-hook-injector/service/statement-analysis/non-wrappable-statement.js +20 -0
- package/dist/domain/code-hook-injector/service/trace-hook/enter-meta-literal.d.ts +20 -0
- package/dist/domain/code-hook-injector/service/trace-hook/enter-meta-literal.js +34 -0
- package/dist/domain/code-hook-injector/service/trace-hook/global-trace-call.d.ts +10 -0
- package/dist/domain/code-hook-injector/service/trace-hook/global-trace-call.js +16 -0
- package/dist/domain/code-hook-injector/service/trace-hook/try-finally-wrapper.d.ts +18 -0
- package/dist/domain/code-hook-injector/service/trace-hook/try-finally-wrapper.js +44 -0
- package/dist/domain/code-hook-injector/service/trace-hook/variable-declaration-hoister.d.ts +20 -0
- package/dist/domain/code-hook-injector/service/trace-hook/variable-declaration-hoister.js +27 -0
- package/dist/domain/code-hook-injector/service/traced-file-matcher.d.ts +10 -0
- package/dist/domain/code-hook-injector/service/traced-file-matcher.js +26 -0
- package/dist/domain/trace-event-recorder/model/enter-meta.d.ts +24 -0
- package/dist/domain/trace-event-recorder/model/enter-meta.js +7 -0
- package/dist/domain/trace-event-recorder/model/global-names.d.ts +8 -0
- package/dist/domain/trace-event-recorder/model/global-names.js +20 -0
- package/dist/domain/trace-event-recorder/model/serialized-error.d.ts +16 -0
- package/dist/domain/trace-event-recorder/model/serialized-error.js +7 -0
- package/dist/domain/trace-event-recorder/model/statement-trace-schema.d.ts +171 -0
- package/dist/domain/trace-event-recorder/model/statement-trace-schema.js +33 -0
- package/dist/domain/trace-event-recorder/model/trace-schema.d.ts +114 -0
- package/dist/domain/trace-event-recorder/model/trace-schema.js +16 -0
- package/dist/domain/trace-event-recorder/port/clock.d.ts +9 -0
- package/dist/domain/trace-event-recorder/port/clock.js +7 -0
- package/dist/domain/trace-event-recorder/port/heal-trace-exporter.d.ts +11 -0
- package/dist/domain/trace-event-recorder/port/heal-trace-exporter.js +7 -0
- package/dist/domain/trace-event-recorder/port/system-info-provider.d.ts +18 -0
- package/dist/domain/trace-event-recorder/port/system-info-provider.js +7 -0
- package/dist/domain/trace-event-recorder/port/trace-event-consumer.d.ts +11 -0
- package/dist/domain/trace-event-recorder/port/trace-event-consumer.js +7 -0
- package/dist/domain/trace-event-recorder/service/active-enter-stack.d.ts +15 -0
- package/dist/domain/trace-event-recorder/service/active-enter-stack.js +34 -0
- package/dist/domain/trace-event-recorder/service/event-builders/enter-event-builder.d.ts +8 -0
- package/dist/domain/trace-event-recorder/service/event-builders/enter-event-builder.js +37 -0
- package/dist/domain/trace-event-recorder/service/event-builders/meta-event-builder.d.ts +7 -0
- package/dist/domain/trace-event-recorder/service/event-builders/meta-event-builder.js +19 -0
- package/dist/domain/trace-event-recorder/service/event-builders/ok-event-builder.d.ts +7 -0
- package/dist/domain/trace-event-recorder/service/event-builders/ok-event-builder.js +27 -0
- package/dist/domain/trace-event-recorder/service/event-builders/throw-event-builder.d.ts +7 -0
- package/dist/domain/trace-event-recorder/service/event-builders/throw-event-builder.js +23 -0
- package/dist/domain/trace-event-recorder/service/exporters/composite-heal-trace-exporter.d.ts +12 -0
- package/dist/domain/trace-event-recorder/service/exporters/composite-heal-trace-exporter.js +32 -0
- package/dist/domain/trace-event-recorder/service/index.d.ts +10 -0
- package/dist/domain/trace-event-recorder/service/index.js +15 -0
- package/dist/domain/trace-event-recorder/service/projectors/index.d.ts +6 -0
- package/dist/domain/trace-event-recorder/service/projectors/index.js +10 -0
- package/dist/domain/trace-event-recorder/service/projectors/statement-projector.d.ts +26 -0
- package/dist/domain/trace-event-recorder/service/projectors/statement-projector.js +183 -0
- package/dist/domain/trace-event-recorder/service/serializers/error-serializer.d.ts +8 -0
- package/dist/domain/trace-event-recorder/service/serializers/error-serializer.js +49 -0
- package/dist/domain/trace-event-recorder/service/serializers/variable-snapshot-serializer.d.ts +7 -0
- package/dist/domain/trace-event-recorder/service/serializers/variable-snapshot-serializer.js +102 -0
- package/dist/domain/trace-event-recorder/service/trace-event-recorder-state.d.ts +19 -0
- package/dist/domain/trace-event-recorder/service/trace-event-recorder-state.js +7 -0
- package/dist/domain/trace-event-recorder/service/trace-event-recorder.d.ts +56 -0
- package/dist/domain/trace-event-recorder/service/trace-event-recorder.js +80 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +43 -0
- package/dist/infrastructure/ndjson-exporter-adapter/index.d.ts +6 -0
- package/dist/infrastructure/ndjson-exporter-adapter/index.js +10 -0
- package/dist/infrastructure/ndjson-exporter-adapter/ndjson-exporter.d.ts +13 -0
- package/dist/infrastructure/ndjson-exporter-adapter/ndjson-exporter.js +77 -0
- package/dist/infrastructure/perf-hooks-clock-adapter/index.d.ts +6 -0
- package/dist/infrastructure/perf-hooks-clock-adapter/index.js +10 -0
- package/dist/infrastructure/perf-hooks-clock-adapter/perf-hooks-clock.d.ts +11 -0
- package/dist/infrastructure/perf-hooks-clock-adapter/perf-hooks-clock.js +22 -0
- package/dist/infrastructure/playwright-locator-screenshot-adapter/assertion-wrapper.d.ts +6 -0
- package/dist/infrastructure/playwright-locator-screenshot-adapter/assertion-wrapper.js +109 -0
- package/dist/infrastructure/playwright-locator-screenshot-adapter/index.d.ts +9 -0
- package/dist/infrastructure/playwright-locator-screenshot-adapter/index.js +21 -0
- package/dist/infrastructure/playwright-locator-screenshot-adapter/locator-patch.d.ts +11 -0
- package/dist/infrastructure/playwright-locator-screenshot-adapter/locator-patch.js +79 -0
- package/dist/infrastructure/playwright-locator-screenshot-adapter/overlay-helpers.d.ts +15 -0
- package/dist/infrastructure/playwright-locator-screenshot-adapter/overlay-helpers.js +33 -0
- package/dist/infrastructure/playwright-locator-screenshot-adapter/screenshot-capture-session.d.ts +26 -0
- package/dist/infrastructure/playwright-locator-screenshot-adapter/screenshot-capture-session.js +125 -0
- package/dist/infrastructure/playwright-step-tracking-adapter/index.d.ts +7 -0
- package/dist/infrastructure/playwright-step-tracking-adapter/index.js +10 -0
- package/dist/infrastructure/playwright-step-tracking-adapter/playwright-step-tracking-adapter.d.ts +14 -0
- package/dist/infrastructure/playwright-step-tracking-adapter/playwright-step-tracking-adapter.js +51 -0
- package/dist/infrastructure/playwright-test-context-adapter/heal-tag-prefix.d.ts +25 -0
- package/dist/infrastructure/playwright-test-context-adapter/heal-tag-prefix.js +28 -0
- package/dist/infrastructure/playwright-test-context-adapter/index.d.ts +8 -0
- package/dist/infrastructure/playwright-test-context-adapter/index.js +12 -0
- package/dist/infrastructure/playwright-test-context-adapter/playwright-test-context-adapter.d.ts +19 -0
- package/dist/infrastructure/playwright-test-context-adapter/playwright-test-context-adapter.js +43 -0
- package/dist/infrastructure/stdout-capture-adapter/index.d.ts +7 -0
- package/dist/infrastructure/stdout-capture-adapter/index.js +10 -0
- package/dist/infrastructure/stdout-capture-adapter/stdout-capture-session.d.ts +20 -0
- package/dist/infrastructure/stdout-capture-adapter/stdout-capture-session.js +47 -0
- package/dist/infrastructure/system-info-adapter/index.d.ts +6 -0
- package/dist/infrastructure/system-info-adapter/index.js +10 -0
- package/dist/infrastructure/system-info-adapter/system-info-adapter.d.ts +12 -0
- package/dist/infrastructure/system-info-adapter/system-info-adapter.js +83 -0
- package/package.json +95 -0
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright: (c) Myia SAS 2026.
|
|
3
|
+
* This file and its contents are licensed under the AGPLv3 License.
|
|
4
|
+
* Please see the LICENSE file at the root of this repository
|
|
5
|
+
*/
|
|
6
|
+
import type { SerializedError } from './serialized-error';
|
|
7
|
+
export type { SerializedError };
|
|
8
|
+
/** Fields common to every trace event. */
|
|
9
|
+
export interface TraceEventBase {
|
|
10
|
+
seq: number;
|
|
11
|
+
/** Milliseconds since the recorder's `startedAt` origin. */
|
|
12
|
+
t: number;
|
|
13
|
+
/** `Date.now()` at emit time. */
|
|
14
|
+
wallTime: number;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Emitted once per test at the top of the trace by `reset()`. Merges
|
|
18
|
+
* the per-process static context (pid, gitSha, platform, …) and the
|
|
19
|
+
* per-test dynamic context (workerIndex, testId, testTitle, …) as
|
|
20
|
+
* extra keys. Known keys are listed explicitly; the index signature
|
|
21
|
+
* is the escape hatch for context fields we haven't modelled yet.
|
|
22
|
+
*/
|
|
23
|
+
export interface MetaEvent extends TraceEventBase {
|
|
24
|
+
type: 'meta';
|
|
25
|
+
t: 0;
|
|
26
|
+
schemaVersion?: number;
|
|
27
|
+
pid?: number;
|
|
28
|
+
nodeVersion?: string;
|
|
29
|
+
platform?: string;
|
|
30
|
+
arch?: string;
|
|
31
|
+
hostname?: string;
|
|
32
|
+
isCI?: boolean;
|
|
33
|
+
cwd?: string;
|
|
34
|
+
gitSha?: string;
|
|
35
|
+
workerIndex?: number;
|
|
36
|
+
parallelIndex?: number;
|
|
37
|
+
testId?: string;
|
|
38
|
+
testTitle?: string;
|
|
39
|
+
titlePath?: string[];
|
|
40
|
+
projectName?: string;
|
|
41
|
+
testFile?: string;
|
|
42
|
+
retry?: number;
|
|
43
|
+
attempt?: number;
|
|
44
|
+
testCaseId?: number;
|
|
45
|
+
[key: string]: unknown;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Emitted when a traced statement is about to run. Pushed onto the
|
|
49
|
+
* active-enter stack and later paired with an ok or throw event.
|
|
50
|
+
*
|
|
51
|
+
* `screenshot` is mutated post-emit by
|
|
52
|
+
* `setCurrentStatementScreenshot(filename)` — the locator-screenshots
|
|
53
|
+
* feature calls that after capturing a highlight PNG, which stamps
|
|
54
|
+
* the filename onto whichever enter event is currently on top of the
|
|
55
|
+
* stack. The exporter stores events by reference, so the mutation is
|
|
56
|
+
* visible when the builder reads snapshot() at teardown.
|
|
57
|
+
*/
|
|
58
|
+
export interface EnterEvent extends TraceEventBase {
|
|
59
|
+
type: 'enter';
|
|
60
|
+
parentSeq: number | null;
|
|
61
|
+
depth: number;
|
|
62
|
+
file: string;
|
|
63
|
+
startLine: number;
|
|
64
|
+
startCol: number;
|
|
65
|
+
endLine: number;
|
|
66
|
+
endCol: number;
|
|
67
|
+
/** 'expression' | 'variable' | 'return' | 'throw' | 'break' | 'continue' | 'debugger' */
|
|
68
|
+
kind: string;
|
|
69
|
+
/** Enclosing function name or `test: <title>`. */
|
|
70
|
+
scope: string;
|
|
71
|
+
hasAwait: boolean;
|
|
72
|
+
source: string;
|
|
73
|
+
/**
|
|
74
|
+
* User-written comments attached to this statement's source node.
|
|
75
|
+
* See `Statement.leadingComment` for the attachment-ambiguity
|
|
76
|
+
* caveats callers should know about.
|
|
77
|
+
*/
|
|
78
|
+
leadingComment?: string;
|
|
79
|
+
step: string | null;
|
|
80
|
+
stepPath: string[] | null;
|
|
81
|
+
pageUrl?: string;
|
|
82
|
+
/** Highlight screenshot filename captured by locator-screenshots, if any. */
|
|
83
|
+
screenshot?: string;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Emitted when a traced statement finished without throwing. Matches
|
|
87
|
+
* the topmost enter event on the stack.
|
|
88
|
+
*/
|
|
89
|
+
export interface OkEvent extends TraceEventBase {
|
|
90
|
+
type: 'ok';
|
|
91
|
+
enterSeq: number;
|
|
92
|
+
duration: number;
|
|
93
|
+
vars?: Record<string, unknown>;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Emitted when a traced statement threw. `enterSeq` and `duration`
|
|
97
|
+
* are zeroed out for the orphan case (error escaping the very first
|
|
98
|
+
* instrumented statement, with no matching enter on the stack).
|
|
99
|
+
*/
|
|
100
|
+
export interface ThrowEvent extends TraceEventBase {
|
|
101
|
+
type: 'throw';
|
|
102
|
+
enterSeq: number | null;
|
|
103
|
+
duration: number;
|
|
104
|
+
error: SerializedError;
|
|
105
|
+
}
|
|
106
|
+
export type TraceEvent = MetaEvent | EnterEvent | OkEvent | ThrowEvent;
|
|
107
|
+
/**
|
|
108
|
+
* Version stamped on every `MetaEvent.schemaVersion`. Bumped whenever
|
|
109
|
+
* the raw trace-event stream shape changes in a backwards-incompatible
|
|
110
|
+
* way. Separate from `HEAL_TRACE_SCHEMA_VERSION` in
|
|
111
|
+
* `./statement-trace-schema.ts`, which versions the projected record
|
|
112
|
+
* stream.
|
|
113
|
+
*/
|
|
114
|
+
export declare const SCHEMA_VERSION = 1;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright: (c) Myia SAS 2026.
|
|
4
|
+
* This file and its contents are licensed under the AGPLv3 License.
|
|
5
|
+
* Please see the LICENSE file at the root of this repository
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.SCHEMA_VERSION = void 0;
|
|
9
|
+
/**
|
|
10
|
+
* Version stamped on every `MetaEvent.schemaVersion`. Bumped whenever
|
|
11
|
+
* the raw trace-event stream shape changes in a backwards-incompatible
|
|
12
|
+
* way. Separate from `HEAL_TRACE_SCHEMA_VERSION` in
|
|
13
|
+
* `./statement-trace-schema.ts`, which versions the projected record
|
|
14
|
+
* stream.
|
|
15
|
+
*/
|
|
16
|
+
exports.SCHEMA_VERSION = 1;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright: (c) Myia SAS 2026.
|
|
3
|
+
* This file and its contents are licensed under the AGPLv3 License.
|
|
4
|
+
* Please see the LICENSE file at the root of this repository
|
|
5
|
+
*/
|
|
6
|
+
import type { HealTraceRecord } from '../model/statement-trace-schema';
|
|
7
|
+
export type { HealTraceRecord };
|
|
8
|
+
export interface HealTraceExporter {
|
|
9
|
+
write(record: HealTraceRecord): void;
|
|
10
|
+
close(): Promise<void>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright: (c) Myia SAS 2026.
|
|
3
|
+
* This file and its contents are licensed under the AGPLv3 License.
|
|
4
|
+
* Please see the LICENSE file at the root of this repository
|
|
5
|
+
*/
|
|
6
|
+
export interface SystemInfo {
|
|
7
|
+
pid: number;
|
|
8
|
+
nodeVersion: string;
|
|
9
|
+
platform: string;
|
|
10
|
+
arch: string;
|
|
11
|
+
hostname: string;
|
|
12
|
+
isCI: boolean;
|
|
13
|
+
cwd: string;
|
|
14
|
+
gitSha?: string;
|
|
15
|
+
}
|
|
16
|
+
export interface SystemInfoProvider {
|
|
17
|
+
getStaticContext(): SystemInfo;
|
|
18
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright: (c) Myia SAS 2026.
|
|
3
|
+
* This file and its contents are licensed under the AGPLv3 License.
|
|
4
|
+
* Please see the LICENSE file at the root of this repository
|
|
5
|
+
*/
|
|
6
|
+
import type { TraceEvent } from '../model/trace-schema';
|
|
7
|
+
export type { TraceEvent };
|
|
8
|
+
export interface TraceEventConsumer {
|
|
9
|
+
write(event: TraceEvent): void;
|
|
10
|
+
clear(): void;
|
|
11
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright: (c) Myia SAS 2026.
|
|
3
|
+
* This file and its contents are licensed under the AGPLv3 License.
|
|
4
|
+
* Please see the LICENSE file at the root of this repository
|
|
5
|
+
*/
|
|
6
|
+
import type { EnterEvent } from '../model/trace-schema';
|
|
7
|
+
export declare class ActiveEnterStack {
|
|
8
|
+
private readonly stack;
|
|
9
|
+
push(event: EnterEvent): void;
|
|
10
|
+
pop(): EnterEvent | undefined;
|
|
11
|
+
peek(): EnterEvent | undefined;
|
|
12
|
+
depth(): number;
|
|
13
|
+
parentSeq(): number | null;
|
|
14
|
+
clear(): void;
|
|
15
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright: (c) Myia SAS 2026.
|
|
4
|
+
* This file and its contents are licensed under the AGPLv3 License.
|
|
5
|
+
* Please see the LICENSE file at the root of this repository
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.ActiveEnterStack = void 0;
|
|
9
|
+
class ActiveEnterStack {
|
|
10
|
+
constructor() {
|
|
11
|
+
this.stack = [];
|
|
12
|
+
}
|
|
13
|
+
push(event) {
|
|
14
|
+
this.stack.push(event);
|
|
15
|
+
}
|
|
16
|
+
pop() {
|
|
17
|
+
return this.stack.pop();
|
|
18
|
+
}
|
|
19
|
+
peek() {
|
|
20
|
+
return this.stack[this.stack.length - 1];
|
|
21
|
+
}
|
|
22
|
+
depth() {
|
|
23
|
+
return this.stack.length;
|
|
24
|
+
}
|
|
25
|
+
parentSeq() {
|
|
26
|
+
if (this.stack.length === 0)
|
|
27
|
+
return null;
|
|
28
|
+
return this.stack[this.stack.length - 1].seq;
|
|
29
|
+
}
|
|
30
|
+
clear() {
|
|
31
|
+
this.stack.length = 0;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.ActiveEnterStack = ActiveEnterStack;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright: (c) Myia SAS 2026.
|
|
3
|
+
* This file and its contents are licensed under the AGPLv3 License.
|
|
4
|
+
* Please see the LICENSE file at the root of this repository
|
|
5
|
+
*/
|
|
6
|
+
import type { TraceEventRecorderState } from '../trace-event-recorder-state';
|
|
7
|
+
import type { EnterMeta } from '../../model/enter-meta';
|
|
8
|
+
export declare function buildEnterEvent(state: TraceEventRecorderState, meta: EnterMeta): void;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright: (c) Myia SAS 2026.
|
|
4
|
+
* This file and its contents are licensed under the AGPLv3 License.
|
|
5
|
+
* Please see the LICENSE file at the root of this repository
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.buildEnterEvent = buildEnterEvent;
|
|
9
|
+
// Tolerant page.url() read. Playwright pages throw on closed/detached
|
|
10
|
+
// contexts, and any such failure here must not corrupt the trace.
|
|
11
|
+
function safePageUrl(currentPage) {
|
|
12
|
+
const pg = currentPage;
|
|
13
|
+
if (!pg || typeof pg.url !== 'function')
|
|
14
|
+
return undefined;
|
|
15
|
+
try {
|
|
16
|
+
return pg.url();
|
|
17
|
+
}
|
|
18
|
+
catch (_) {
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
function buildEnterEvent(state, meta) {
|
|
23
|
+
const event = {
|
|
24
|
+
type: 'enter',
|
|
25
|
+
seq: ++state.seq,
|
|
26
|
+
parentSeq: state.enterStack.parentSeq(),
|
|
27
|
+
depth: state.enterStack.depth(),
|
|
28
|
+
t: state.clock.now() - state.startedAt,
|
|
29
|
+
wallTime: Date.now(),
|
|
30
|
+
...meta,
|
|
31
|
+
step: state.stepStack.length ? state.stepStack[state.stepStack.length - 1] : null,
|
|
32
|
+
stepPath: state.stepStack.length ? state.stepStack.slice() : null,
|
|
33
|
+
pageUrl: safePageUrl(state.currentPage),
|
|
34
|
+
};
|
|
35
|
+
state.enterStack.push(event);
|
|
36
|
+
state.exporter.write(event);
|
|
37
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright: (c) Myia SAS 2026.
|
|
3
|
+
* This file and its contents are licensed under the AGPLv3 License.
|
|
4
|
+
* Please see the LICENSE file at the root of this repository
|
|
5
|
+
*/
|
|
6
|
+
import type { TraceEventRecorderState } from '../trace-event-recorder-state';
|
|
7
|
+
export declare function buildMetaEvent(state: TraceEventRecorderState): void;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright: (c) Myia SAS 2026.
|
|
4
|
+
* This file and its contents are licensed under the AGPLv3 License.
|
|
5
|
+
* Please see the LICENSE file at the root of this repository
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.buildMetaEvent = buildMetaEvent;
|
|
9
|
+
function buildMetaEvent(state) {
|
|
10
|
+
const event = {
|
|
11
|
+
...state.staticContext,
|
|
12
|
+
...(state.dynamicContext ?? {}),
|
|
13
|
+
type: 'meta',
|
|
14
|
+
seq: ++state.seq,
|
|
15
|
+
t: 0,
|
|
16
|
+
wallTime: state.clock.wallNow(),
|
|
17
|
+
};
|
|
18
|
+
state.exporter.write(event);
|
|
19
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright: (c) Myia SAS 2026.
|
|
3
|
+
* This file and its contents are licensed under the AGPLv3 License.
|
|
4
|
+
* Please see the LICENSE file at the root of this repository
|
|
5
|
+
*/
|
|
6
|
+
import type { TraceEventRecorderState } from '../trace-event-recorder-state';
|
|
7
|
+
export declare function buildOkEvent(state: TraceEventRecorderState, vars?: unknown): void;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright: (c) Myia SAS 2026.
|
|
4
|
+
* This file and its contents are licensed under the AGPLv3 License.
|
|
5
|
+
* Please see the LICENSE file at the root of this repository
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.buildOkEvent = buildOkEvent;
|
|
9
|
+
const variable_snapshot_serializer_1 = require("../serializers/variable-snapshot-serializer");
|
|
10
|
+
function buildOkEvent(state, vars) {
|
|
11
|
+
const enter = state.enterStack.pop();
|
|
12
|
+
if (!enter)
|
|
13
|
+
return;
|
|
14
|
+
const n = state.clock.now() - state.startedAt;
|
|
15
|
+
const event = {
|
|
16
|
+
type: 'ok',
|
|
17
|
+
seq: ++state.seq,
|
|
18
|
+
enterSeq: enter.seq,
|
|
19
|
+
t: n,
|
|
20
|
+
wallTime: Date.now(),
|
|
21
|
+
duration: n - enter.t,
|
|
22
|
+
};
|
|
23
|
+
const serialized = (0, variable_snapshot_serializer_1.safeVars)(vars);
|
|
24
|
+
if (serialized)
|
|
25
|
+
event.vars = serialized;
|
|
26
|
+
state.exporter.write(event);
|
|
27
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright: (c) Myia SAS 2026.
|
|
3
|
+
* This file and its contents are licensed under the AGPLv3 License.
|
|
4
|
+
* Please see the LICENSE file at the root of this repository
|
|
5
|
+
*/
|
|
6
|
+
import type { TraceEventRecorderState } from '../trace-event-recorder-state';
|
|
7
|
+
export declare function buildThrowEvent(state: TraceEventRecorderState, err: unknown): void;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright: (c) Myia SAS 2026.
|
|
4
|
+
* This file and its contents are licensed under the AGPLv3 License.
|
|
5
|
+
* Please see the LICENSE file at the root of this repository
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.buildThrowEvent = buildThrowEvent;
|
|
9
|
+
const error_serializer_1 = require("../serializers/error-serializer");
|
|
10
|
+
function buildThrowEvent(state, err) {
|
|
11
|
+
const enter = state.enterStack.pop();
|
|
12
|
+
const n = state.clock.now() - state.startedAt;
|
|
13
|
+
const event = {
|
|
14
|
+
type: 'throw',
|
|
15
|
+
seq: ++state.seq,
|
|
16
|
+
enterSeq: enter ? enter.seq : null,
|
|
17
|
+
t: n,
|
|
18
|
+
wallTime: Date.now(),
|
|
19
|
+
duration: enter ? n - enter.t : 0,
|
|
20
|
+
error: (0, error_serializer_1.serializeError)(err),
|
|
21
|
+
};
|
|
22
|
+
state.exporter.write(event);
|
|
23
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright: (c) Myia SAS 2026.
|
|
3
|
+
* This file and its contents are licensed under the AGPLv3 License.
|
|
4
|
+
* Please see the LICENSE file at the root of this repository
|
|
5
|
+
*/
|
|
6
|
+
import type { HealTraceExporter, HealTraceRecord } from '../../port/heal-trace-exporter';
|
|
7
|
+
export declare class CompositeHealTraceExporter implements HealTraceExporter {
|
|
8
|
+
private readonly children;
|
|
9
|
+
constructor(children: HealTraceExporter[]);
|
|
10
|
+
write(record: HealTraceRecord): void;
|
|
11
|
+
close(): Promise<void>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright: (c) Myia SAS 2026.
|
|
4
|
+
* This file and its contents are licensed under the AGPLv3 License.
|
|
5
|
+
* Please see the LICENSE file at the root of this repository
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.CompositeHealTraceExporter = void 0;
|
|
9
|
+
class CompositeHealTraceExporter {
|
|
10
|
+
constructor(children) {
|
|
11
|
+
this.children = children;
|
|
12
|
+
}
|
|
13
|
+
write(record) {
|
|
14
|
+
for (const child of this.children) {
|
|
15
|
+
try {
|
|
16
|
+
child.write(record);
|
|
17
|
+
}
|
|
18
|
+
catch (err) {
|
|
19
|
+
console.warn('[heal-playwright-tracer] composite-exporter child write failed:', err);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
async close() {
|
|
24
|
+
const results = await Promise.allSettled(this.children.map((c) => c.close()));
|
|
25
|
+
for (const r of results) {
|
|
26
|
+
if (r.status === 'rejected') {
|
|
27
|
+
console.warn('[heal-playwright-tracer] composite-exporter child close failed:', r.reason);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.CompositeHealTraceExporter = CompositeHealTraceExporter;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright: (c) Myia SAS 2026.
|
|
3
|
+
* This file and its contents are licensed under the AGPLv3 License.
|
|
4
|
+
* Please see the LICENSE file at the root of this repository
|
|
5
|
+
*/
|
|
6
|
+
export { TraceEventRecorder, SCHEMA_VERSION } from './trace-event-recorder';
|
|
7
|
+
export type { CreateTraceEventRecorderOptions, Clock, EnterMeta } from './trace-event-recorder';
|
|
8
|
+
export { ActiveEnterStack } from './active-enter-stack';
|
|
9
|
+
export { CompositeHealTraceExporter } from './exporters/composite-heal-trace-exporter';
|
|
10
|
+
export type { TraceEventRecorderState } from './trace-event-recorder-state';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright: (c) Myia SAS 2026.
|
|
4
|
+
* This file and its contents are licensed under the AGPLv3 License.
|
|
5
|
+
* Please see the LICENSE file at the root of this repository
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.CompositeHealTraceExporter = exports.ActiveEnterStack = exports.SCHEMA_VERSION = exports.TraceEventRecorder = void 0;
|
|
9
|
+
var trace_event_recorder_1 = require("./trace-event-recorder");
|
|
10
|
+
Object.defineProperty(exports, "TraceEventRecorder", { enumerable: true, get: function () { return trace_event_recorder_1.TraceEventRecorder; } });
|
|
11
|
+
Object.defineProperty(exports, "SCHEMA_VERSION", { enumerable: true, get: function () { return trace_event_recorder_1.SCHEMA_VERSION; } });
|
|
12
|
+
var active_enter_stack_1 = require("./active-enter-stack");
|
|
13
|
+
Object.defineProperty(exports, "ActiveEnterStack", { enumerable: true, get: function () { return active_enter_stack_1.ActiveEnterStack; } });
|
|
14
|
+
var composite_heal_trace_exporter_1 = require("./exporters/composite-heal-trace-exporter");
|
|
15
|
+
Object.defineProperty(exports, "CompositeHealTraceExporter", { enumerable: true, get: function () { return composite_heal_trace_exporter_1.CompositeHealTraceExporter; } });
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright: (c) Myia SAS 2026.
|
|
4
|
+
* This file and its contents are licensed under the AGPLv3 License.
|
|
5
|
+
* Please see the LICENSE file at the root of this repository
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.StatementProjector = void 0;
|
|
9
|
+
var statement_projector_1 = require("./statement-projector");
|
|
10
|
+
Object.defineProperty(exports, "StatementProjector", { enumerable: true, get: function () { return statement_projector_1.StatementProjector; } });
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright: (c) Myia SAS 2026.
|
|
3
|
+
* This file and its contents are licensed under the AGPLv3 License.
|
|
4
|
+
* Please see the LICENSE file at the root of this repository
|
|
5
|
+
*/
|
|
6
|
+
import type { TraceEvent, TraceEventConsumer } from '../../port/trace-event-consumer';
|
|
7
|
+
import type { HealTraceExporter } from '../../port/heal-trace-exporter';
|
|
8
|
+
import { type TestResultRecord } from '../../model/statement-trace-schema';
|
|
9
|
+
export declare class StatementProjector implements TraceEventConsumer {
|
|
10
|
+
private readonly output;
|
|
11
|
+
private readonly allBySeq;
|
|
12
|
+
private readonly rootsBySeq;
|
|
13
|
+
private headerEmitted;
|
|
14
|
+
private finalized;
|
|
15
|
+
constructor(output: HealTraceExporter);
|
|
16
|
+
write(event: TraceEvent): void;
|
|
17
|
+
clear(): void;
|
|
18
|
+
/**
|
|
19
|
+
* Emit the final `test-result` record and close the underlying
|
|
20
|
+
* exporter. Called once at test teardown; the projector is unusable
|
|
21
|
+
* afterwards.
|
|
22
|
+
*/
|
|
23
|
+
finalize(result: Omit<TestResultRecord, 'kind'>): Promise<void>;
|
|
24
|
+
private maybeEmitRoot;
|
|
25
|
+
private dropSubtree;
|
|
26
|
+
}
|