@specter-automation/test 1.0.149 → 1.0.151

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.
@@ -0,0 +1,522 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RotatorUtils = exports.VectorUtils = void 0;
4
+ exports.resolveVector3 = resolveVector3;
5
+ exports.resolveRotator = resolveRotator;
6
+ exports.normalizeAxis = normalizeAxis;
7
+ exports.findLookAtRotation = findLookAtRotation;
8
+ exports.getRotationBetween = getRotationBetween;
9
+ exports.calculateDistance = calculateDistance;
10
+ exports.calculateDistance2D = calculateDistance2D;
11
+ exports.normalizeRotator = normalizeRotator;
12
+ exports.deltaRotator = deltaRotator;
13
+ const DEG_TO_RAD = Math.PI / 180.0;
14
+ const RAD_TO_DEG = 180.0 / Math.PI;
15
+ const EPSILON = 1e-7;
16
+ function cleanFloat(val) {
17
+ return Math.abs(val) < EPSILON ? 0 : val;
18
+ }
19
+ /**
20
+ * Resolves a partial or complete Vector3, defaulting undefined components (x, y, z) to 0.
21
+ */
22
+ function resolveVector3(v) {
23
+ return {
24
+ x: v?.x ?? 0,
25
+ y: v?.y ?? 0,
26
+ z: v?.z ?? 0
27
+ };
28
+ }
29
+ /**
30
+ * Resolves a partial or complete Rotator, defaulting undefined components (pitch, yaw, roll) to 0.
31
+ */
32
+ function resolveRotator(r) {
33
+ return {
34
+ pitch: r?.pitch ?? 0,
35
+ yaw: r?.yaw ?? 0,
36
+ roll: r?.roll ?? 0
37
+ };
38
+ }
39
+ /**
40
+ * Normalizes an angle in degrees to the [-180, 180) range, matching Unreal's FRotator::NormalizeAxis.
41
+ */
42
+ function normalizeAxis(angleDeg) {
43
+ let a = angleDeg % 360;
44
+ if (a > 180)
45
+ a -= 360;
46
+ if (a <= -180)
47
+ a += 360;
48
+ return cleanFloat(a);
49
+ }
50
+ /**
51
+ * Utilities for 3D vectors matching Unreal Engine coordinate math.
52
+ */
53
+ exports.VectorUtils = {
54
+ /**
55
+ * Creates a Vector3 at (0, 0, 0).
56
+ */
57
+ zero: () => ({ x: 0, y: 0, z: 0 }),
58
+ /**
59
+ * Resolves a partial or complete Vector3, defaulting undefined components to 0.
60
+ */
61
+ resolve: resolveVector3,
62
+ /**
63
+ * Adds an offset in a given direction vector: location + (direction * offset).
64
+ * Undefined x, y, z components default to 0.
65
+ */
66
+ addOffset: (location, direction, offset) => {
67
+ const loc = resolveVector3(location);
68
+ const dir = resolveVector3(direction);
69
+ return {
70
+ x: loc.x + (dir.x * offset),
71
+ y: loc.y + (dir.y * offset),
72
+ z: loc.z + (dir.z * offset)
73
+ };
74
+ },
75
+ /**
76
+ * Adds two vectors (A + B). Undefined components default to 0.
77
+ */
78
+ add: (a, b) => {
79
+ const va = resolveVector3(a);
80
+ const vb = resolveVector3(b);
81
+ return {
82
+ x: va.x + vb.x,
83
+ y: va.y + vb.y,
84
+ z: va.z + vb.z
85
+ };
86
+ },
87
+ /**
88
+ * Subtracts vector B from vector A (A - B). Undefined components default to 0.
89
+ */
90
+ subtract: (a, b) => {
91
+ const va = resolveVector3(a);
92
+ const vb = resolveVector3(b);
93
+ return {
94
+ x: va.x - vb.x,
95
+ y: va.y - vb.y,
96
+ z: va.z - vb.z
97
+ };
98
+ },
99
+ /** `a - b`: alias for subtract */
100
+ sub: (a, b) => {
101
+ const va = resolveVector3(a);
102
+ const vb = resolveVector3(b);
103
+ return {
104
+ x: va.x - vb.x,
105
+ y: va.y - vb.y,
106
+ z: va.z - vb.z
107
+ };
108
+ },
109
+ /**
110
+ * Multiplies a vector by a scalar. Undefined components default to 0.
111
+ */
112
+ multiply: (v, scalar) => {
113
+ const res = resolveVector3(v);
114
+ return {
115
+ x: res.x * scalar,
116
+ y: res.y * scalar,
117
+ z: res.z * scalar
118
+ };
119
+ },
120
+ /** `v * scalar`: alias for multiply */
121
+ scale: (v, scalar) => {
122
+ const res = resolveVector3(v);
123
+ return {
124
+ x: res.x * scalar,
125
+ y: res.y * scalar,
126
+ z: res.z * scalar
127
+ };
128
+ },
129
+ /**
130
+ * Divides a vector by a scalar. Returns (0, 0, 0) if scalar is 0.
131
+ */
132
+ divide: (v, scalar) => {
133
+ if (scalar === 0)
134
+ return { x: 0, y: 0, z: 0 };
135
+ const res = resolveVector3(v);
136
+ return {
137
+ x: res.x / scalar,
138
+ y: res.y / scalar,
139
+ z: res.z / scalar
140
+ };
141
+ },
142
+ /**
143
+ * Calculates the Euclidean distance between two 3D vectors. Undefined components default to 0.
144
+ */
145
+ distance: (a, b) => {
146
+ const va = resolveVector3(a);
147
+ const vb = resolveVector3(b);
148
+ const dx = vb.x - va.x;
149
+ const dy = vb.y - va.y;
150
+ const dz = vb.z - va.z;
151
+ return Math.sqrt(dx * dx + dy * dy + dz * dz);
152
+ },
153
+ /**
154
+ * Calculates the 2D Euclidean distance on the ground plane (XY only). Undefined components default to 0.
155
+ */
156
+ distance2D: (a, b) => {
157
+ const va = resolveVector3(a);
158
+ const vb = resolveVector3(b);
159
+ const dx = vb.x - va.x;
160
+ const dy = vb.y - va.y;
161
+ return Math.sqrt(dx * dx + dy * dy);
162
+ },
163
+ /**
164
+ * Returns the magnitude / length of a 3D vector. Undefined components default to 0.
165
+ */
166
+ length: (v) => {
167
+ const res = resolveVector3(v);
168
+ return Math.sqrt(res.x * res.x + res.y * res.y + res.z * res.z);
169
+ },
170
+ /**
171
+ * Returns the 2D magnitude on the XY plane. Undefined components default to 0.
172
+ */
173
+ length2D: (v) => {
174
+ const res = resolveVector3(v);
175
+ return Math.sqrt(res.x * res.x + res.y * res.y);
176
+ },
177
+ /**
178
+ * Returns the squared length of a 3D vector. Undefined components default to 0.
179
+ */
180
+ lengthSquared: (v) => {
181
+ const res = resolveVector3(v);
182
+ return res.x * res.x + res.y * res.y + res.z * res.z;
183
+ },
184
+ /**
185
+ * Returns a normalized unit vector (length = 1). Returns (0, 0, 0) if length is 0.
186
+ */
187
+ normalize: (v) => {
188
+ const res = resolveVector3(v);
189
+ const len = Math.sqrt(res.x * res.x + res.y * res.y + res.z * res.z);
190
+ if (len === 0)
191
+ return { x: 0, y: 0, z: 0 };
192
+ return {
193
+ x: res.x / len,
194
+ y: res.y / len,
195
+ z: res.z / len
196
+ };
197
+ },
198
+ /**
199
+ * Returns the normalized direction vector from point `from` to point `to`.
200
+ * Undefined components default to 0.
201
+ */
202
+ direction: (from, to) => {
203
+ const vf = resolveVector3(from);
204
+ const vt = resolveVector3(to);
205
+ const dx = vt.x - vf.x;
206
+ const dy = vt.y - vf.y;
207
+ const dz = vt.z - vf.z;
208
+ const len = Math.sqrt(dx * dx + dy * dy + dz * dz);
209
+ if (len === 0)
210
+ return { x: 0, y: 0, z: 0 };
211
+ return { x: dx / len, y: dy / len, z: dz / len };
212
+ },
213
+ /**
214
+ * Computes the dot product of two vectors (A · B). Undefined components default to 0.
215
+ */
216
+ dot: (a, b) => {
217
+ const va = resolveVector3(a);
218
+ const vb = resolveVector3(b);
219
+ return va.x * vb.x + va.y * vb.y + va.z * vb.z;
220
+ },
221
+ /**
222
+ * Computes the cross product of two vectors (A × B) in Unreal's left-handed coordinate system.
223
+ * Undefined components default to 0.
224
+ */
225
+ cross: (a, b) => {
226
+ const va = resolveVector3(a);
227
+ const vb = resolveVector3(b);
228
+ return {
229
+ x: va.y * vb.z - va.z * vb.y,
230
+ y: va.z * vb.x - va.x * vb.z,
231
+ z: va.x * vb.y - va.y * vb.x
232
+ };
233
+ },
234
+ /**
235
+ * Linearly interpolates between vector A and B by alpha. Undefined components default to 0.
236
+ */
237
+ lerp: (a, b, alpha) => {
238
+ const va = resolveVector3(a);
239
+ const vb = resolveVector3(b);
240
+ return {
241
+ x: va.x + (vb.x - va.x) * alpha,
242
+ y: va.y + (vb.y - va.y) * alpha,
243
+ z: va.z + (vb.z - va.z) * alpha
244
+ };
245
+ },
246
+ /**
247
+ * Checks if two vectors are approximately equal within a tolerance distance.
248
+ * Undefined components default to 0.
249
+ */
250
+ isNearlyEqual: (a, b, tolerance = 0.01) => {
251
+ return exports.VectorUtils.distance(a, b) <= tolerance;
252
+ },
253
+ /**
254
+ * Converts a direction vector into an Unreal Engine FRotator (Roll = 0).
255
+ * Matches Unreal's `FVector::Rotation()` / `FRotationMatrix::MakeFromX()`.
256
+ */
257
+ toRotator: (direction) => {
258
+ return exports.RotatorUtils.fromDirection(direction);
259
+ },
260
+ /**
261
+ * Calculates the FRotator required to face from point `from` towards point `to`.
262
+ * Identical to Unreal Engine's `UKismetMathLibrary::FindLookAtRotation`.
263
+ * Undefined components default to 0.
264
+ */
265
+ findLookAtRotation: (from, to) => {
266
+ return exports.RotatorUtils.fromVectors(from, to);
267
+ },
268
+ /**
269
+ * Rotates a 3D vector by an Unreal FRotator.
270
+ * Matches Unreal Engine's `FRotator::RotateVector`.
271
+ * Undefined components default to 0.
272
+ */
273
+ rotate: (v, rot) => {
274
+ const { fwd, right, up } = exports.RotatorUtils.getAxes(rot);
275
+ const res = resolveVector3(v);
276
+ return {
277
+ x: cleanFloat(fwd.x * res.x + right.x * res.y + up.x * res.z),
278
+ y: cleanFloat(fwd.y * res.x + right.y * res.y + up.y * res.z),
279
+ z: cleanFloat(fwd.z * res.x + right.z * res.y + up.z * res.z)
280
+ };
281
+ }
282
+ };
283
+ /**
284
+ * Utilities for Euler rotations (Pitch, Yaw, Roll in degrees) matching Unreal Engine's FRotator.
285
+ */
286
+ exports.RotatorUtils = {
287
+ /**
288
+ * Creates a Rotator at (pitch: 0, yaw: 0, roll: 0).
289
+ */
290
+ zero: () => ({ pitch: 0, yaw: 0, roll: 0 }),
291
+ /**
292
+ * Resolves a partial or complete Rotator, defaulting undefined components (pitch, yaw, roll) to 0.
293
+ */
294
+ resolve: resolveRotator,
295
+ /**
296
+ * Constructs a Rotator from pitch, yaw, and optional roll. Defaults omitted parameters to 0.
297
+ */
298
+ make: (pitch = 0, yaw = 0, roll = 0) => ({
299
+ pitch: normalizeAxis(pitch),
300
+ yaw: normalizeAxis(yaw),
301
+ roll: normalizeAxis(roll)
302
+ }),
303
+ /**
304
+ * Constructs a flat yaw-only Rotator (pitch: 0, roll: 0).
305
+ */
306
+ fromYaw: (yaw = 0) => ({
307
+ pitch: 0,
308
+ yaw: normalizeAxis(yaw),
309
+ roll: 0
310
+ }),
311
+ /**
312
+ * Calculates the look-at rotation from a direction vector.
313
+ * Matches Unreal's `FVector::Rotation()`. Undefined components default to 0.
314
+ */
315
+ fromDirection: (dir) => {
316
+ const d = resolveVector3(dir);
317
+ const dist2D = Math.sqrt(d.x * d.x + d.y * d.y);
318
+ if (dist2D === 0 && d.z === 0) {
319
+ return { pitch: 0, yaw: 0, roll: 0 };
320
+ }
321
+ const yaw = Math.atan2(d.y, d.x) * RAD_TO_DEG;
322
+ const pitch = Math.atan2(d.z, dist2D) * RAD_TO_DEG;
323
+ return {
324
+ pitch: normalizeAxis(pitch),
325
+ yaw: normalizeAxis(yaw),
326
+ roll: 0
327
+ };
328
+ },
329
+ /**
330
+ * Calculates the rotation required to look from `from` towards `to`.
331
+ * Identical to Unreal Engine's `UKismetMathLibrary::FindLookAtRotation(Start, Target)`.
332
+ * Undefined components default to 0.
333
+ */
334
+ fromVectors: (from, to) => {
335
+ const vf = resolveVector3(from);
336
+ const vt = resolveVector3(to);
337
+ return exports.RotatorUtils.fromDirection({
338
+ x: vt.x - vf.x,
339
+ y: vt.y - vf.y,
340
+ z: vt.z - vf.z
341
+ });
342
+ },
343
+ /**
344
+ * Alias for `fromVectors`: finds the look-at rotation from `start` to `target`.
345
+ */
346
+ findLookAtRotation: (start, target) => {
347
+ return exports.RotatorUtils.fromVectors(start, target);
348
+ },
349
+ /**
350
+ * Computes the three unit axis vectors (Forward, Right, Up) for a given Rotator.
351
+ * Matches Unreal Engine's `FRotationMatrix(Rotator)`.
352
+ * Undefined components default to 0.
353
+ */
354
+ getAxes: (rot) => {
355
+ const r = resolveRotator(rot);
356
+ const p = r.pitch * DEG_TO_RAD;
357
+ const y = r.yaw * DEG_TO_RAD;
358
+ const roll = r.roll * DEG_TO_RAD;
359
+ const sp = Math.sin(p), cp = Math.cos(p);
360
+ const sy = Math.sin(y), cy = Math.cos(y);
361
+ const sr = Math.sin(roll), cr = Math.cos(roll);
362
+ const fwd = {
363
+ x: cleanFloat(cp * cy),
364
+ y: cleanFloat(cp * sy),
365
+ z: cleanFloat(sp)
366
+ };
367
+ const right = {
368
+ x: cleanFloat(sr * sp * cy - cr * sy),
369
+ y: cleanFloat(sr * sp * sy + cr * cy),
370
+ z: cleanFloat(-sr * cp)
371
+ };
372
+ const up = {
373
+ x: cleanFloat(-(cr * sp * cy + sr * sy)),
374
+ y: cleanFloat(-(cr * sp * sy - sr * cy)),
375
+ z: cleanFloat(cr * cp)
376
+ };
377
+ return { fwd, right, up };
378
+ },
379
+ /**
380
+ * Returns the unit forward vector (+X) for this rotation.
381
+ * Matches Unreal Engine's `FRotator::Vector()`.
382
+ * Undefined components default to 0.
383
+ */
384
+ getForwardVector: (rot) => {
385
+ const r = resolveRotator(rot);
386
+ const p = r.pitch * DEG_TO_RAD;
387
+ const y = r.yaw * DEG_TO_RAD;
388
+ const cp = Math.cos(p);
389
+ return {
390
+ x: cleanFloat(cp * Math.cos(y)),
391
+ y: cleanFloat(cp * Math.sin(y)),
392
+ z: cleanFloat(Math.sin(p))
393
+ };
394
+ },
395
+ /**
396
+ * Returns the unit right vector (+Y) for this rotation.
397
+ */
398
+ getRightVector: (rot) => {
399
+ return exports.RotatorUtils.getAxes(rot).right;
400
+ },
401
+ /**
402
+ * Returns the unit up vector (+Z) for this rotation.
403
+ */
404
+ getUpVector: (rot) => {
405
+ return exports.RotatorUtils.getAxes(rot).up;
406
+ },
407
+ /**
408
+ * Normalizes all components (Pitch, Yaw, Roll) to [-180, 180) degrees.
409
+ * Matches Unreal's `FRotator::GetNormalized()`. Undefined components default to 0.
410
+ */
411
+ normalize: (rot) => {
412
+ const r = resolveRotator(rot);
413
+ return {
414
+ pitch: normalizeAxis(r.pitch),
415
+ yaw: normalizeAxis(r.yaw),
416
+ roll: normalizeAxis(r.roll)
417
+ };
418
+ },
419
+ /**
420
+ * Calculates the angular difference (to - from) with all components normalized to [-180, 180).
421
+ * Undefined components default to 0.
422
+ */
423
+ delta: (from, to) => {
424
+ const rf = resolveRotator(from);
425
+ const rt = resolveRotator(to);
426
+ return {
427
+ pitch: normalizeAxis(rt.pitch - rf.pitch),
428
+ yaw: normalizeAxis(rt.yaw - rf.yaw),
429
+ roll: normalizeAxis(rt.roll - rf.roll)
430
+ };
431
+ },
432
+ /**
433
+ * Calculates the absolute angular distance in degrees between two 3D orientations (0° to 180°).
434
+ * Undefined components default to 0.
435
+ */
436
+ angularDistance: (a, b) => {
437
+ const fwdA = exports.RotatorUtils.getForwardVector(a);
438
+ const fwdB = exports.RotatorUtils.getForwardVector(b);
439
+ const dot = Math.max(-1, Math.min(1, fwdA.x * fwdB.x + fwdA.y * fwdB.y + fwdA.z * fwdB.z));
440
+ return cleanFloat(Math.acos(dot) * RAD_TO_DEG);
441
+ },
442
+ /**
443
+ * Calculates the absolute difference between two yaw angles in degrees (0° to 180°).
444
+ * Undefined components default to 0.
445
+ */
446
+ yawDifference: (a, b) => {
447
+ const yawA = typeof a === 'number' ? a : (a?.yaw ?? 0);
448
+ const yawB = typeof b === 'number' ? b : (b?.yaw ?? 0);
449
+ return Math.abs(normalizeAxis(yawA - yawB));
450
+ },
451
+ /**
452
+ * Checks if two Rotators are approximately equal within a tolerance in degrees.
453
+ * Handles 360-degree wrapping (e.g. 179° and -179° are within 2° of each other).
454
+ * Undefined components default to 0.
455
+ */
456
+ isNearlyEqual: (a, b, toleranceDegrees = 0.5) => {
457
+ const ra = resolveRotator(a);
458
+ const rb = resolveRotator(b);
459
+ return Math.abs(normalizeAxis(ra.pitch - rb.pitch)) <= toleranceDegrees &&
460
+ Math.abs(normalizeAxis(ra.yaw - rb.yaw)) <= toleranceDegrees &&
461
+ Math.abs(normalizeAxis(ra.roll - rb.roll)) <= toleranceDegrees;
462
+ },
463
+ /**
464
+ * Interpolates smoothly from Rotator A to B taking the shortest angular path.
465
+ * Undefined components default to 0.
466
+ */
467
+ lerp: (from, to, alpha) => {
468
+ const rf = resolveRotator(from);
469
+ const d = exports.RotatorUtils.delta(from, to);
470
+ return {
471
+ pitch: normalizeAxis(rf.pitch + d.pitch * alpha),
472
+ yaw: normalizeAxis(rf.yaw + d.yaw * alpha),
473
+ roll: normalizeAxis(rf.roll + d.roll * alpha)
474
+ };
475
+ }
476
+ };
477
+ // ==========================================
478
+ // TOP-LEVEL CONVENIENCE HELPERS
479
+ // ==========================================
480
+ /**
481
+ * Calculates the FRotator required to face from point `from` towards point `to`.
482
+ * Identical to Unreal Engine's `UKismetMathLibrary::FindLookAtRotation`.
483
+ * Undefined components default to 0.
484
+ */
485
+ function findLookAtRotation(from, to) {
486
+ return exports.RotatorUtils.fromVectors(from, to);
487
+ }
488
+ /**
489
+ * Alias for `findLookAtRotation`: calculates the rotation between two 3D positions.
490
+ * Undefined components default to 0.
491
+ */
492
+ function getRotationBetween(from, to) {
493
+ return exports.RotatorUtils.fromVectors(from, to);
494
+ }
495
+ /**
496
+ * Calculates the Euclidean distance between two 3D points.
497
+ * Undefined components default to 0.
498
+ */
499
+ function calculateDistance(a, b) {
500
+ return exports.VectorUtils.distance(a, b);
501
+ }
502
+ /**
503
+ * Calculates the 2D Euclidean distance on the ground plane (XY only).
504
+ * Undefined components default to 0.
505
+ */
506
+ function calculateDistance2D(a, b) {
507
+ return exports.VectorUtils.distance2D(a, b);
508
+ }
509
+ /**
510
+ * Normalizes all components of a Rotator to [-180, 180) degrees.
511
+ * Undefined components default to 0.
512
+ */
513
+ function normalizeRotator(rot) {
514
+ return exports.RotatorUtils.normalize(rot);
515
+ }
516
+ /**
517
+ * Calculates the angular delta between two Rotators (to - from), wrapping shortest-path to [-180, 180).
518
+ * Undefined components default to 0.
519
+ */
520
+ function deltaRotator(from, to) {
521
+ return exports.RotatorUtils.delta(from, to);
522
+ }
@@ -45,7 +45,8 @@ class SpecterPreview {
45
45
  * Shows a fixed place: a sphere of `radius` (default 1500) around `location`, from above at an angle.
46
46
  */
47
47
  async at(location, options) {
48
- return this.send({ mode: 'at', location, radius: options?.radius ?? 0 }, `at (${Math.round(location.x)}, ${Math.round(location.y)}, ${Math.round(location.z)})`);
48
+ const loc = { x: location.x ?? 0, y: location.y ?? 0, z: location.z ?? 0 };
49
+ return this.send({ mode: 'at', location: loc, radius: options?.radius ?? 0 }, `at (${Math.round(loc.x)}, ${Math.round(loc.y)}, ${Math.round(loc.z)})`);
49
50
  }
50
51
  /** Shows the player's view, as the game draws it. */
51
52
  async player() {
@@ -270,7 +270,8 @@ class SpecterReporter {
270
270
  recordedEvents = new Map();
271
271
  send(payload) {
272
272
  const msg = JSON.stringify(payload);
273
- console.log(`[REPORTER WEBSOCKET SEND]: ${msg}`);
273
+ if (process.env.SPECTER_REPORTER_DEBUG)
274
+ console.log(`[REPORTER WEBSOCKET SEND]: ${msg}`);
274
275
  const testName = payload.payload?.testName;
275
276
  if (testName) {
276
277
  let events = this.recordedEvents.get(testName);
@@ -367,7 +368,8 @@ class SpecterReporter {
367
368
  return ''; // Return empty string if no valid parent is found (makes it a Root node)
368
369
  }
369
370
  onStepBegin(test, result, step) {
370
- console.log(`[REPORTER DEBUG] Step Begin: "${step.title}" | Category: "${step.category}" | Parent: "${step.parent ? step.parent.title : 'None'}" ("${step.parent ? step.parent.category : ''}")`);
371
+ if (process.env.SPECTER_REPORTER_DEBUG)
372
+ console.log(`[REPORTER DEBUG] Step Begin: "${step.title}" | Category: "${step.category}" | Parent: "${step.parent ? step.parent.title : 'None'}" ("${step.parent ? step.parent.category : ''}")`);
371
373
  // 1. Playwright's outer expect step for a Specter matcher: announced by its wrapper step below,
372
374
  // which carries the locator in its title.
373
375
  if (step.category === 'expect' && (0, specter_matcher_report_1.parseSpecterExpectTitle)(step.title)) {
@@ -40,5 +40,6 @@ type CreateWorldOptions = {
40
40
  autoJoinHost?: boolean;
41
41
  launchClient?: boolean;
42
42
  };
43
- export declare const test: import("playwright/test").TestType<import("playwright/test").PlaywrightTestArgs & import("playwright/test").PlaywrightTestOptions & SpecterTestFixtures & SpecterTestOptions, import("playwright/test").PlaywrightWorkerArgs & import("playwright/test").PlaywrightWorkerOptions & SpecterWorkerFixtures>;
43
+ declare const extendedTest: import("playwright/test").TestType<import("playwright/test").PlaywrightTestArgs & import("playwright/test").PlaywrightTestOptions & SpecterTestFixtures & SpecterTestOptions, import("playwright/test").PlaywrightWorkerArgs & import("playwright/test").PlaywrightWorkerOptions & SpecterWorkerFixtures>;
44
+ export declare const test: typeof extendedTest;
44
45
  export {};
@@ -44,9 +44,10 @@ const material_matchers_1 = require("../matchers/material-matchers");
44
44
  const ai_matchers_1 = require("../matchers/ai-matchers");
45
45
  const performance_matchers_1 = require("../matchers/performance-matchers");
46
46
  const visual_matchers_1 = require("../matchers/visual-matchers");
47
+ const failure_capture_1 = require("./failure-capture");
47
48
  exports.expect = (0, test_1.mergeExpects)(gas_matchers_1.gasExpect, actor_matchers_1.actorExpect, locator_matchers_1.locatorExpect, widget_matchers_1.widgetExpect, material_matchers_1.materialExpect, ai_matchers_1.aiExpect, performance_matchers_1.performanceExpect, visual_matchers_1.visualExpect);
48
49
  // 2. Define the scopes in the extend block
49
- exports.test = test_1.test.extend({
50
+ const extendedTest = test_1.test.extend({
50
51
  // OPTIONS FIXTURES: Configurable via playwright.config.ts `use: { ... }` or `test.use({ ... })`
51
52
  timeDilation: [1.0, { option: true }],
52
53
  fixedDeltaSeconds: [0, { option: true }],
@@ -70,22 +71,29 @@ exports.test = test_1.test.extend({
70
71
  const activeDilation = (envDilation !== undefined && !isNaN(envDilation) && envDilation > 0) ? envDilation : (timeDilation || 1.0);
71
72
  const world = new specter_client_1.SpecterWorld(specter);
72
73
  world.timeDilation = activeDilation;
74
+ testInfo._specterWorld = world;
75
+ (0, failure_capture_1.setActiveWorld)(world);
73
76
  if (activeDilation !== 1.0) {
74
77
  await world.setTimeScale(activeDilation);
75
78
  }
76
79
  if (fixedDeltaSeconds && fixedDeltaSeconds > 0) {
77
80
  await world.console(`r.FixedDeltaTime ${fixedDeltaSeconds}`);
78
81
  }
79
- await use(world);
80
- // Teardown: Reset fixed delta time if configured
81
- if (fixedDeltaSeconds && fixedDeltaSeconds > 0) {
82
- try {
83
- await world.console(`r.FixedDeltaTime 0`);
82
+ try {
83
+ await use(world);
84
+ }
85
+ finally {
86
+ (0, failure_capture_1.setActiveWorld)(null);
87
+ // Teardown: Reset fixed delta time if configured
88
+ if (fixedDeltaSeconds && fixedDeltaSeconds > 0) {
89
+ try {
90
+ await world.console(`r.FixedDeltaTime 0`);
91
+ }
92
+ catch (e) { }
84
93
  }
85
- catch (e) { }
94
+ // Wipe the level clean for the next test in the queue (also restores slomo 1.0 if dilated)
95
+ await world.cleanup();
86
96
  }
87
- // Wipe the level clean for the next test in the queue (also restores slomo 1.0 if dilated)
88
- await world.cleanup();
89
97
  },
90
98
  // THE MULTIPLAYER FACTORY FIXTURE
91
99
  createWorld: async ({ timeDilation }, use) => {
@@ -210,41 +218,18 @@ exports.test = test_1.test.extend({
210
218
  }
211
219
  },
212
220
  autoScreenshot: [async ({ world }, use, testInfo) => {
213
- // Yield control to run the actual test
214
- await use();
215
- // FIX: Catch 'failed', 'timedOut', and 'interrupted' statuses
216
- if (testInfo.status !== 'passed' && testInfo.status !== 'skipped') {
217
- const safeName = `Specter_Fail_${testInfo.title.replace(/[^a-zA-Z0-9]/g, '_')}`;
218
- try {
219
- // Attached by takeScreenshot itself
220
- await world.takeScreenshot(safeName, true, { attachmentName: 'Unreal Engine Viewport' });
221
- }
222
- catch (e) {
223
- console.error("[Specter] Failed to capture error screenshot:", e);
224
- }
225
- try {
226
- const diagnostics = await world.getDiagnostics({ limit: 35 });
227
- if (diagnostics) {
228
- const formattedSummary = (0, gas_matchers_1.formatAiDiagnostics)(diagnostics);
229
- console.log('\n' + formattedSummary + '\n');
230
- const alreadyAttached = testInfo.attachments.some(a => a.name.includes('Specter AI Diagnostics'));
231
- if (!alreadyAttached) {
232
- testInfo.attachments.push({
233
- name: 'Specter AI Diagnostics (JSON)',
234
- contentType: 'application/json',
235
- body: Buffer.from(JSON.stringify(diagnostics, null, 2))
236
- });
237
- testInfo.attachments.push({
238
- name: 'Specter AI Diagnostics (Markdown)',
239
- contentType: 'text/markdown',
240
- body: Buffer.from(formattedSummary)
241
- });
242
- }
221
+ try {
222
+ await use();
223
+ }
224
+ finally {
225
+ // FIX: Catch 'failed', 'timedOut', and 'interrupted' statuses if not already captured earlier
226
+ if (testInfo.status !== 'passed' && testInfo.status !== 'skipped') {
227
+ if (!testInfo._specterFailureCaptured) {
228
+ await (0, failure_capture_1.captureSpecterFailure)(world, testInfo, 'autoScreenshot-fallback');
243
229
  }
244
230
  }
245
- catch (e) {
246
- console.error("[Specter] Failed to capture AI diagnostics on test failure:", e);
247
- }
248
231
  }
249
232
  }, { auto: true }]
250
233
  });
234
+ (0, failure_capture_1.setAiDiagnosticsFormatter)(gas_matchers_1.formatAiDiagnostics);
235
+ exports.test = (0, failure_capture_1.wrapTestInstance)(extendedTest);
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { test, expect, type SpecterTestOptions } from './core/test-wrapper';
2
- export { SpecterTransport, SpecterWorld, VectorUtils } from './core/specter-client';
2
+ export { SpecterTransport, SpecterWorld, VectorUtils, RotatorUtils, resolveVector3, resolveRotator, normalizeAxis, findLookAtRotation, getRotationBetween, calculateDistance, calculateDistance2D, normalizeRotator, deltaRotator } from './core/specter-client';
3
3
  export type { SpecterPayload, SpawnOptions, Vector3, Rotator, Transform, HitResult, LinearColor, Color, Vector2D, SpecterRegistry, SpecterFunctionRegistry, LoadMapOptions, SpecterGrantedAbility, SpecterActiveEffect, SpecterActorSnapshot, RegisteredGameplayTags } from './core/specter-client';
4
4
  export { SpecterLocator, WidgetLocator, ActorLocator, AiControllerLocator, type WidgetGeometry, type WidgetFilterOptions } from './core/locators';
5
5
  export { default as SpecterReporter } from './core/specter-reporter';
@@ -9,6 +9,7 @@ export type { SpecterMatcherReport } from './core/specter-matcher-report';
9
9
  export { SPECTER_PERF_ATTACHMENT, describeHitch, describeHitches, summarizeCapture } from './core/specter-perf';
10
10
  export type { PerformanceCapture, PerformanceHitch, PerformanceStat, MeasurePerformanceOptions } from './core/specter-perf';
11
11
  export { describeBehaviorTrail, describeNodePath } from './core/specter-ai-trail';
12
+ export { formatDebugDiagnostics, type CollisionDescription, type CollisionResponse, type TraceResult, type PerceptionResult, type NavPathResult, type OverlapResult, type EngineLog, type EngineLogEntry, type StateHistory, type StateSample, type ActorStateSample, type StuckAI } from './core/specter-debug';
12
13
  export type { BehaviorTrail, BehaviorTrailEvent, DescribeBehaviorTrailOptions } from './core/specter-ai-trail';
13
14
  export type { UnrealKey } from './core/specter-keys';
14
15
  export type { SpecterActorEvents, SpecterWidgetEvents, SpecterWorldEvents, CustomActorEvents, CustomWidgetEvents, CustomWorldEvents, ActorEventMap, WidgetEventMap, WorldEventMap, EventPredicate, WaitForEventOptions } from './core/events';