@reticlehq/engine 3.9.0 → 3.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/disagreement/body-failures.js +16 -2
- package/dist/disagreement/contradiction-evidence.d.ts +119 -0
- package/dist/disagreement/contradiction-evidence.js +360 -48
- package/dist/disagreement/contradiction-types.d.ts +25 -0
- package/dist/disagreement/contradictions.d.ts +17 -1
- package/dist/disagreement/contradictions.js +146 -78
- package/dist/disagreement/echo-mismatch.js +205 -32
- package/dist/disagreement/stale-response.d.ts +10 -1
- package/dist/disagreement/stale-response.js +122 -47
- package/dist/evidence/already-true.d.ts +1 -1
- package/dist/evidence/already-true.js +13 -7
- package/dist/evidence/baseline.d.ts +1 -0
- package/dist/evidence/baseline.js +27 -16
- package/dist/evidence/blind-spots.d.ts +20 -3
- package/dist/evidence/blind-spots.js +127 -21
- package/dist/evidence/step-effect.d.ts +5 -0
- package/dist/evidence/step-effect.js +5 -2
- package/dist/evidence/verified.d.ts +23 -0
- package/dist/evidence/verified.js +53 -2
- package/dist/question/declared.d.ts +27 -0
- package/dist/question/declared.js +64 -13
- package/dist/question/predicate/net-blind-spots.d.ts +37 -1
- package/dist/question/predicate/net-blind-spots.js +72 -1
- package/dist/question/predicate/predicate-animation.d.ts +52 -0
- package/dist/question/predicate/predicate-animation.js +258 -0
- package/dist/question/predicate/predicate-element.d.ts +5 -2
- package/dist/question/predicate/predicate-element.js +103 -33
- package/dist/question/predicate/predicate-eval-kit.d.ts +2 -0
- package/dist/question/predicate/predicate-eval-kit.js +19 -0
- package/dist/question/predicate/predicate-eval.d.ts +1 -4
- package/dist/question/predicate/predicate-eval.js +38 -46
- package/dist/question/predicate/predicate-route.js +81 -27
- package/dist/question/predicate/predicate-schema.js +11 -2
- package/dist/question/predicate/predicate.js +79 -40
- package/dist/question/predicate/truncated-body-advice.d.ts +5 -0
- package/dist/question/predicate/truncated-body-advice.js +25 -0
- package/dist/state-bookkeeping.d.ts +24 -0
- package/dist/state-bookkeeping.js +31 -0
- package/dist/window/event-filters.d.ts +64 -0
- package/dist/window/event-filters.js +149 -20
- package/dist/window/network-detail-merge.d.ts +6 -0
- package/dist/window/network-detail-merge.js +43 -2
- package/package.json +2 -2
|
@@ -159,13 +159,22 @@ function matchesRole(actual, queried) {
|
|
|
159
159
|
* adapter, and moving the rule into core would move the wire contract for two lines.
|
|
160
160
|
*/
|
|
161
161
|
function normaliseName(value) {
|
|
162
|
-
return value.replace(/\s+/g, ' ').trim().normalize('NFC');
|
|
162
|
+
return withoutInvisibleFormat(value).replace(/\s+/g, ' ').trim().normalize('NFC');
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* The format characters a screen does not paint, the same set as `INVISIBLE_FORMAT` in the
|
|
166
|
+
* browser's `text-match.ts`. Keep the two in step for the reason above: a name or text the browser
|
|
167
|
+
* matched without them must not miss here.
|
|
168
|
+
*/
|
|
169
|
+
const INVISIBLE_FORMAT = /[\u00ad\u200b-\u200f\u202a-\u202e\u2060-\u2064\u2066-\u2069\ufeff]/g;
|
|
170
|
+
function withoutInvisibleFormat(value) {
|
|
171
|
+
return value.replace(INVISIBLE_FORMAT, '');
|
|
163
172
|
}
|
|
164
173
|
const RESIDUAL_CHECKS = {
|
|
165
174
|
value: (element, want) => (element.value ?? '').trim() === want.trim(),
|
|
166
175
|
role: (element, want) => matchesRole(element.role, want),
|
|
167
176
|
name: (element, want) => normaliseName(element.name) === normaliseName(want),
|
|
168
|
-
text: (element, want) => (element.text ?? element.name).includes(want),
|
|
177
|
+
text: (element, want) => withoutInvisibleFormat(element.text ?? element.name).includes(withoutInvisibleFormat(want)),
|
|
169
178
|
[ALT_FIELD]: (element, want) => {
|
|
170
179
|
const alt = element.attrs?.[ALT_FIELD];
|
|
171
180
|
return isImage(element) && alt !== undefined && alt.trim() === want.trim();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ElementState, EventType, MUTATING_METHODS, PredicateKind, THROTTLED_STARVED_NOTE, isSameDocument, } from '@reticlehq/core';
|
|
1
|
+
import { ElementState, EventType, MUTATING_METHODS, PredicateKind, ReticleCommand, THROTTLED_STARVED_NOTE, isSameDocument, } from '@reticlehq/core';
|
|
2
2
|
import { predicateToExpectedLinks } from './predicate-to-links.js';
|
|
3
3
|
import { isAmbient, ambientKeyOf } from '../../window/ambient.js';
|
|
4
4
|
import { evalRoute } from './predicate-route.js';
|
|
@@ -6,9 +6,16 @@ import { describeSuperseded } from './observed-in-window.js';
|
|
|
6
6
|
import { evalElement, textPredicateQuery, withTextProperty } from './predicate-element.js';
|
|
7
7
|
import { evalState } from './predicate-state.js';
|
|
8
8
|
import { evalCompare } from './predicate-compare.js';
|
|
9
|
-
import { PredicateSchema, evalNet, evalConsole,
|
|
9
|
+
import { PredicateSchema, evalNet, evalConsole, evalSignal, evalSettled, } from './predicate-eval.js';
|
|
10
|
+
import { evalAnimationPredicate } from './predicate-animation.js';
|
|
10
11
|
export { PredicateSchema, PredicateKind };
|
|
11
12
|
import { withinBudget } from './predicate-session.js';
|
|
13
|
+
const ANIMATION_RUNTIME = {
|
|
14
|
+
startEventType: EventType.ANIM_START,
|
|
15
|
+
endEventType: EventType.ANIM_END,
|
|
16
|
+
animationsCommand: ReticleCommand.ANIMATIONS,
|
|
17
|
+
targetArg: 'target',
|
|
18
|
+
};
|
|
12
19
|
/**
|
|
13
20
|
* A composite result that carries a child's "nobody could evaluate this" up to the verdict rule.
|
|
14
21
|
*
|
|
@@ -32,7 +39,6 @@ function unreadableComposite(child, evidence) {
|
|
|
32
39
|
const WINDOW_ONLY_KINDS = new Set([
|
|
33
40
|
PredicateKind.NET,
|
|
34
41
|
PredicateKind.CONSOLE,
|
|
35
|
-
PredicateKind.ANIMATION,
|
|
36
42
|
PredicateKind.SIGNAL,
|
|
37
43
|
PredicateKind.SETTLED,
|
|
38
44
|
]);
|
|
@@ -76,22 +82,28 @@ function predicateSince(predicate) {
|
|
|
76
82
|
* overwritten.
|
|
77
83
|
*/
|
|
78
84
|
function annotateThrottledMiss(session, predicate, result) {
|
|
79
|
-
if (result.pass)
|
|
85
|
+
if (result.pass) {
|
|
80
86
|
return result;
|
|
81
|
-
|
|
87
|
+
}
|
|
88
|
+
if (result.inconclusive !== undefined) {
|
|
82
89
|
return result;
|
|
90
|
+
}
|
|
83
91
|
const preconditionFailure = session.preconditionFailure?.();
|
|
84
92
|
if (preconditionFailure !== undefined) {
|
|
85
93
|
return { ...result, inconclusive: preconditionFailure };
|
|
86
94
|
}
|
|
87
|
-
if (true !== session.throttled?.())
|
|
95
|
+
if (true !== session.throttled?.()) {
|
|
88
96
|
return result;
|
|
89
|
-
|
|
97
|
+
}
|
|
98
|
+
if (decidedByAnAlreadyAnnotatedClause(predicate)) {
|
|
90
99
|
return result;
|
|
91
|
-
|
|
100
|
+
}
|
|
101
|
+
if (failureRestsOnSeeing(predicate)) {
|
|
92
102
|
return result;
|
|
93
|
-
|
|
103
|
+
}
|
|
104
|
+
if (evidenceProvesPageRendered(result)) {
|
|
94
105
|
return result;
|
|
106
|
+
}
|
|
95
107
|
return { ...result, inconclusive: THROTTLED_STARVED_NOTE };
|
|
96
108
|
}
|
|
97
109
|
/**
|
|
@@ -114,12 +126,15 @@ function annotateThrottledMiss(session, predicate, result) {
|
|
|
114
126
|
*/
|
|
115
127
|
function evidenceProvesPageRendered(result) {
|
|
116
128
|
const evidence = result.evidence;
|
|
117
|
-
if ('object' !== typeof evidence || null === evidence)
|
|
129
|
+
if ('object' !== typeof evidence || null === evidence) {
|
|
118
130
|
return false;
|
|
119
|
-
|
|
131
|
+
}
|
|
132
|
+
if ('splitText' in evidence || 'caseMiss' in evidence) {
|
|
120
133
|
return true;
|
|
121
|
-
|
|
134
|
+
}
|
|
135
|
+
if ('nearMiss' in evidence && 'element.state' === result.assertion) {
|
|
122
136
|
return true;
|
|
137
|
+
}
|
|
123
138
|
return false;
|
|
124
139
|
}
|
|
125
140
|
/**
|
|
@@ -153,10 +168,12 @@ function decidedByAnAlreadyAnnotatedClause(predicate) {
|
|
|
153
168
|
* Composites recurse: a passing `allOf` proves a render if any of its own arms did.
|
|
154
169
|
*/
|
|
155
170
|
function provesRender(predicate, result) {
|
|
156
|
-
if (!result.pass)
|
|
171
|
+
if (!result.pass) {
|
|
157
172
|
return false;
|
|
158
|
-
|
|
173
|
+
}
|
|
174
|
+
if (PredicateKind.ELEMENT === predicate.kind) {
|
|
159
175
|
return true !== predicate.absent;
|
|
176
|
+
}
|
|
160
177
|
if (PredicateKind.ALL_OF === predicate.kind || PredicateKind.ANY_OF === predicate.kind) {
|
|
161
178
|
return predicate.predicates.some((p) => provesRender(p, result));
|
|
162
179
|
}
|
|
@@ -183,8 +200,9 @@ function clearStarvedWhenSiblingsSaw(predicates, results) {
|
|
|
183
200
|
const p = predicates[i];
|
|
184
201
|
return p !== undefined && provesRender(p, r);
|
|
185
202
|
});
|
|
186
|
-
if (!rendered)
|
|
203
|
+
if (!rendered) {
|
|
187
204
|
return results;
|
|
205
|
+
}
|
|
188
206
|
return results.map((r, i) => {
|
|
189
207
|
const p = predicates[i];
|
|
190
208
|
return p === undefined ? r : clearStarved(p, r);
|
|
@@ -199,8 +217,9 @@ function clearStarvedWhenSiblingsSaw(predicates, results) {
|
|
|
199
217
|
* negates it again. Nested `not` recurses.
|
|
200
218
|
*/
|
|
201
219
|
function clearStarved(predicate, result) {
|
|
202
|
-
if (THROTTLED_STARVED_NOTE !== result.inconclusive)
|
|
220
|
+
if (THROTTLED_STARVED_NOTE !== result.inconclusive) {
|
|
203
221
|
return result;
|
|
222
|
+
}
|
|
204
223
|
const child = result.evidence;
|
|
205
224
|
if (PredicateKind.NOT === predicate.kind && isEvalResult(child)) {
|
|
206
225
|
const inner = clearStarved(predicate.predicate, child);
|
|
@@ -247,13 +266,15 @@ function negate(negated, inner) {
|
|
|
247
266
|
* missing one costs a wrong verdict.
|
|
248
267
|
*/
|
|
249
268
|
function failureRestsOnSeeing(predicate) {
|
|
250
|
-
if (PredicateKind.NOT === predicate.kind)
|
|
269
|
+
if (PredicateKind.NOT === predicate.kind) {
|
|
251
270
|
return !failureRestsOnSeeing(predicate.predicate);
|
|
271
|
+
}
|
|
252
272
|
if (PredicateKind.ALL_OF === predicate.kind || PredicateKind.ANY_OF === predicate.kind) {
|
|
253
273
|
return predicate.predicates.some(failureRestsOnSeeing);
|
|
254
274
|
}
|
|
255
|
-
if ('absent' in predicate && true === predicate.absent)
|
|
275
|
+
if ('absent' in predicate && true === predicate.absent) {
|
|
256
276
|
return true;
|
|
277
|
+
}
|
|
257
278
|
// `count: 0` is absence written as arithmetic, and fails the same way: by matching something.
|
|
258
279
|
return 'count' in predicate && 0 === predicate.count;
|
|
259
280
|
}
|
|
@@ -317,21 +338,25 @@ diagnose = true, baselines) {
|
|
|
317
338
|
// only `text` filled in, so scoping it needs the field, not a second code path.
|
|
318
339
|
const query = textPredicateQuery(predicate, session.sdkVersion);
|
|
319
340
|
const found = await evalElement(session, query, true === predicate.visible ? ElementState.VISIBLE : undefined, predicate.absent ?? false, diagnose,
|
|
320
|
-
// A property is judged on the whole text
|
|
321
|
-
//
|
|
322
|
-
undefined !== predicate.satisfies
|
|
323
|
-
|
|
341
|
+
// A property is judged on the whole text, for an absence too: there only a match that
|
|
342
|
+
// satisfies it fails the check, and the matches come back re-bounded.
|
|
343
|
+
undefined !== predicate.satisfies, true === predicate.absent ? predicate.satisfies : undefined);
|
|
344
|
+
// An absence judged its property above, on each match.
|
|
345
|
+
if (undefined === predicate.satisfies || true === predicate.absent) {
|
|
324
346
|
return found;
|
|
347
|
+
}
|
|
325
348
|
return withTextProperty(found, predicate.satisfies, JSON.stringify(query), baselines?.get(predicate));
|
|
326
349
|
}
|
|
327
350
|
case PredicateKind.NET: {
|
|
328
|
-
const result = evalNet(events, predicate);
|
|
329
|
-
if (result.pass || keepsAnswers || result.inconclusive !== undefined)
|
|
351
|
+
const result = evalNet(events, predicate, session.sdkVersion);
|
|
352
|
+
if (result.pass || keepsAnswers || result.inconclusive !== undefined) {
|
|
330
353
|
return result;
|
|
354
|
+
}
|
|
331
355
|
// No floor, so a replaced page's answers were left out. If one would have satisfied the
|
|
332
356
|
// predicate, nothing here can say whether it was this action's: unknown, never a plain no.
|
|
333
357
|
const withAnswers = raw.filter((e) => onScreen(e) || isServerAnswer(e));
|
|
334
|
-
if (withAnswers.length === events.length ||
|
|
358
|
+
if (withAnswers.length === events.length ||
|
|
359
|
+
!evalNet(withAnswers, predicate, session.sdkVersion).pass) {
|
|
335
360
|
return result;
|
|
336
361
|
}
|
|
337
362
|
return {
|
|
@@ -347,7 +372,7 @@ diagnose = true, baselines) {
|
|
|
347
372
|
case PredicateKind.CONSOLE:
|
|
348
373
|
return evalConsole(events, predicate);
|
|
349
374
|
case PredicateKind.ANIMATION:
|
|
350
|
-
return
|
|
375
|
+
return evalAnimationPredicate(session, events, predicate, floor, ANIMATION_RUNTIME);
|
|
351
376
|
case PredicateKind.SIGNAL:
|
|
352
377
|
return evalSignal(events, predicate);
|
|
353
378
|
case PredicateKind.STATE:
|
|
@@ -387,20 +412,23 @@ diagnose = true, baselines) {
|
|
|
387
412
|
};
|
|
388
413
|
}
|
|
389
414
|
const unreadable = results.find((r) => r.inconclusive !== undefined);
|
|
390
|
-
if (unreadable !== undefined)
|
|
415
|
+
if (unreadable !== undefined) {
|
|
391
416
|
return unreadableComposite(unreadable, results);
|
|
417
|
+
}
|
|
392
418
|
return { pass: true, evidence: results.map((r) => r.evidence) };
|
|
393
419
|
}
|
|
394
420
|
case PredicateKind.ANY_OF: {
|
|
395
421
|
const results = clearStarvedWhenSiblingsSaw(predicate.predicates, await Promise.all(predicate.predicates.map((p) => evaluatePredicate(session, p, since, diagnose, baselines))));
|
|
396
422
|
const passed = results.find((r) => r.pass);
|
|
397
|
-
if (passed !== undefined)
|
|
423
|
+
if (passed !== undefined) {
|
|
398
424
|
return { pass: true, evidence: passed.evidence };
|
|
425
|
+
}
|
|
399
426
|
// "No sub-predicate matched" is a claim anyOf is not entitled to make while one of them was
|
|
400
427
|
// never read: the unreadable clause might have been the one that would have matched.
|
|
401
428
|
const unreadable = results.find((r) => r.inconclusive !== undefined);
|
|
402
|
-
if (unreadable !== undefined)
|
|
429
|
+
if (unreadable !== undefined) {
|
|
403
430
|
return unreadableComposite(unreadable, results);
|
|
431
|
+
}
|
|
404
432
|
// A disjunction is decided when EVERY clause is permanently false: no branch can
|
|
405
433
|
// ever become true, so waiting out the budget buys nothing. By this point every
|
|
406
434
|
// result is a non-inconclusive failure (passing and inconclusive returned above).
|
|
@@ -418,8 +446,9 @@ diagnose = true, baselines) {
|
|
|
418
446
|
// child's `pass: false` as "the inner predicate did not hold" and passed — so an assertion
|
|
419
447
|
// nobody could evaluate became a verdict of verified, manufactured out of a missing reading.
|
|
420
448
|
// You cannot negate an answer nobody had.
|
|
421
|
-
if (inner.inconclusive !== undefined)
|
|
449
|
+
if (inner.inconclusive !== undefined) {
|
|
422
450
|
return unreadableComposite(inner, inner);
|
|
451
|
+
}
|
|
423
452
|
return negate(predicate.predicate, inner);
|
|
424
453
|
}
|
|
425
454
|
default:
|
|
@@ -478,8 +507,9 @@ function assertsExactCount(predicate) {
|
|
|
478
507
|
if (PredicateKind.ALL_OF === predicate.kind || PredicateKind.ANY_OF === predicate.kind) {
|
|
479
508
|
return predicate.predicates.some(assertsExactCount);
|
|
480
509
|
}
|
|
481
|
-
if (PredicateKind.NOT === predicate.kind)
|
|
510
|
+
if (PredicateKind.NOT === predicate.kind) {
|
|
482
511
|
return assertsExactCount(predicate.predicate);
|
|
512
|
+
}
|
|
483
513
|
// `signal` carries `count` for the same reason `net` does, and for the same defect: its schema
|
|
484
514
|
// calls the double-fire "the defect no state-only oracle can see", because a handler wired twice
|
|
485
515
|
// leaves the store in the right shape and a presence check green on both. Reading `net` alone
|
|
@@ -497,8 +527,9 @@ function assertsExactCount(predicate) {
|
|
|
497
527
|
* once the page ran slower. It holds until the page goes quiet; see ABSENCE_HOLD_MS.
|
|
498
528
|
*/
|
|
499
529
|
function claimsAbsence(predicate) {
|
|
500
|
-
if (PredicateKind.NOT === predicate.kind)
|
|
530
|
+
if (PredicateKind.NOT === predicate.kind) {
|
|
501
531
|
return true;
|
|
532
|
+
}
|
|
502
533
|
if (PredicateKind.ALL_OF === predicate.kind || PredicateKind.ANY_OF === predicate.kind) {
|
|
503
534
|
return predicate.predicates.some(claimsAbsence);
|
|
504
535
|
}
|
|
@@ -558,20 +589,24 @@ baselines) {
|
|
|
558
589
|
});
|
|
559
590
|
};
|
|
560
591
|
const finish = (result) => {
|
|
561
|
-
if (done)
|
|
592
|
+
if (done) {
|
|
562
593
|
return;
|
|
594
|
+
}
|
|
563
595
|
done = true;
|
|
564
596
|
releaseWindow?.();
|
|
565
597
|
unsub();
|
|
566
598
|
unsubDisconnect?.();
|
|
567
599
|
clearInterval(interval);
|
|
568
600
|
clearTimeout(timer);
|
|
569
|
-
if (cooldownTimer !== undefined)
|
|
601
|
+
if (cooldownTimer !== undefined) {
|
|
570
602
|
clearTimeout(cooldownTimer);
|
|
571
|
-
|
|
603
|
+
}
|
|
604
|
+
if (hintTimer !== undefined) {
|
|
572
605
|
clearTimeout(hintTimer);
|
|
573
|
-
|
|
606
|
+
}
|
|
607
|
+
if (confirmTimer !== undefined) {
|
|
574
608
|
clearTimeout(confirmTimer);
|
|
609
|
+
}
|
|
575
610
|
resolve(result);
|
|
576
611
|
};
|
|
577
612
|
// Coalesce re-checks: at most ONE evaluatePredicate is ever in flight (each can be a browser
|
|
@@ -588,8 +623,9 @@ baselines) {
|
|
|
588
623
|
let cooling = false;
|
|
589
624
|
let pendingRecheck = false;
|
|
590
625
|
const check = () => {
|
|
591
|
-
if (done)
|
|
626
|
+
if (done) {
|
|
592
627
|
return;
|
|
628
|
+
}
|
|
593
629
|
if (inFlight || cooling) {
|
|
594
630
|
pendingRecheck = true;
|
|
595
631
|
return;
|
|
@@ -627,8 +663,9 @@ baselines) {
|
|
|
627
663
|
finish(r);
|
|
628
664
|
return;
|
|
629
665
|
}
|
|
630
|
-
if (confirming)
|
|
666
|
+
if (confirming) {
|
|
631
667
|
return;
|
|
668
|
+
}
|
|
632
669
|
confirming = true;
|
|
633
670
|
const confirm = () => {
|
|
634
671
|
void evaluatePredicate(reader, predicate, since, true, baselines)
|
|
@@ -646,8 +683,9 @@ baselines) {
|
|
|
646
683
|
const holdUntilQuiet = () => {
|
|
647
684
|
void evaluatePredicate(reader, SETTLED_PROBE, since, false)
|
|
648
685
|
.then((settled) => {
|
|
649
|
-
if (done)
|
|
686
|
+
if (done) {
|
|
650
687
|
return;
|
|
688
|
+
}
|
|
651
689
|
if (settled.pass) {
|
|
652
690
|
confirm();
|
|
653
691
|
return;
|
|
@@ -663,8 +701,9 @@ baselines) {
|
|
|
663
701
|
})
|
|
664
702
|
.finally(() => {
|
|
665
703
|
inFlight = false;
|
|
666
|
-
if (done)
|
|
704
|
+
if (done) {
|
|
667
705
|
return;
|
|
706
|
+
}
|
|
668
707
|
// Enter a short cooldown; process a coalesced recheck when it ends. The 150ms poll is the
|
|
669
708
|
// backstop, so a missed trailing edge is caught within one interval regardless.
|
|
670
709
|
cooling = true;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How to keep more of a truncated body. On an SDK that predates the option, raising it changes
|
|
3
|
+
* nothing, so the only advice that works is updating the SDK: say that instead (#2031).
|
|
4
|
+
*/
|
|
5
|
+
export declare function truncatedBodyAdvice(sdkVersion: string | undefined, missedMatch: boolean): string;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What to do about a response body that was truncated before it was recorded, for the inconclusive
|
|
3
|
+
* verdict `evalNet` gives when the wanted body is not in the kept part.
|
|
4
|
+
*/
|
|
5
|
+
import { sdkPredates } from './predicate-eval-kit.js';
|
|
6
|
+
/** A truncated body missed a `bodyContains`: the kept prefix can still answer a substring. */
|
|
7
|
+
const TRUNCATED_PREFIX_REMEDY = "Raise it past this response's size and re-run, or assert on something inside the recorded prefix";
|
|
8
|
+
/**
|
|
9
|
+
* A truncated body missed a `bodyMatches`. That clause parses the whole body and a JSON prefix never
|
|
10
|
+
* parses, so "assert inside the prefix" changes nothing for it (#1417): name what can work instead.
|
|
11
|
+
*/
|
|
12
|
+
const TRUNCATED_MATCHES_REMEDY = "Raise it past this response's size and re-run. `bodyMatches` parses the whole body, and a JSON prefix never parses, so it cannot be judged on the kept part: to assert on what was kept, use `bodyContains` with a substring from it";
|
|
13
|
+
/** The first SDK release that reads `networkBodyMaxChars`; an older one caps every body at 8192 (#2031). */
|
|
14
|
+
const BODY_MAX_CHARS_SINCE = '3.3.0';
|
|
15
|
+
/**
|
|
16
|
+
* How to keep more of a truncated body. On an SDK that predates the option, raising it changes
|
|
17
|
+
* nothing, so the only advice that works is updating the SDK: say that instead (#2031).
|
|
18
|
+
*/
|
|
19
|
+
export function truncatedBodyAdvice(sdkVersion, missedMatch) {
|
|
20
|
+
const remedy = missedMatch ? TRUNCATED_MATCHES_REMEDY : TRUNCATED_PREFIX_REMEDY;
|
|
21
|
+
if (sdkPredates(sdkVersion, BODY_MAX_CHARS_SINCE)) {
|
|
22
|
+
return `This page's SDK ${String(sdkVersion)} caps every recorded body at 8192 characters and ignores \`networkBodyMaxChars\`, which arrived in ${BODY_MAX_CHARS_SINCE}, so raising it changes nothing yet. Run \`reticle update\` in the app's folder, then restart its dev server. After that the cap is \`networkBodyMaxChars\`, set where the app calls connect(). ${remedy}`;
|
|
23
|
+
}
|
|
24
|
+
return `The cap is per-body and set where the app calls connect(): \`reticle.connect({ captureNetworkBodies: true, networkBodyMaxChars: 65536 })\`, or for the Vite plugin \`reticle({ networkBodyMaxChars: 65536 })\` / VITE_RETICLE_BODY_MAX_CHARS=65536 (default 8192, max 262144). An SDK older than this daemon ignores the option; a version skew on the session says so. ${remedy}`;
|
|
25
|
+
}
|
|
@@ -25,3 +25,27 @@ export declare function isCacheBookkeepingDiff(from: unknown, to: unknown): bool
|
|
|
25
25
|
export declare function isMeaningfulStateChange(event: ReticleEvent): boolean;
|
|
26
26
|
/** True for a signal or store that Reticle sends about itself. It says nothing about the app. */
|
|
27
27
|
export declare const isReticleVoice: (name: string) => boolean;
|
|
28
|
+
/** What the rule needs to know about an event. The caller supplies it, so this file reads no wire shape. */
|
|
29
|
+
interface AppReaction<E> {
|
|
30
|
+
/** Which store path or signal the event moved, or undefined when it moved neither. */
|
|
31
|
+
keyOf: (event: E) => string | undefined;
|
|
32
|
+
/** Whether the caller's predicate named this change. */
|
|
33
|
+
isNamed: (event: E) => boolean;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* A store change or an app signal that can be TIED to the action (#1531).
|
|
37
|
+
*
|
|
38
|
+
* The app's own state moving is a reaction, the same as a request, even when the DOM update it
|
|
39
|
+
* drives lands after the window was read: a Pause button whose store changes on the media `pause`
|
|
40
|
+
* event. But being in the window is not enough. The session stamps the active action's id on every
|
|
41
|
+
* event between dispatch and settle, so a busy page's background store updates look attributed
|
|
42
|
+
* too, and a dead click among them must still be reported ("no-effect under ambient churn").
|
|
43
|
+
*
|
|
44
|
+
* So a change counts only when it is tied to the action in one of two ways:
|
|
45
|
+
* - the caller's predicate named it (a `state` path or a `signal` name), so it is the consequence
|
|
46
|
+
* they expected; or
|
|
47
|
+
* - it was quiet before the action: `prior` holds observations, and none of them moved this path
|
|
48
|
+
* or fired this signal. Churn that was already moving is the background, not this click.
|
|
49
|
+
*/
|
|
50
|
+
export declare function tiedReaction<E>(prior: readonly E[], { keyOf, isNamed }: AppReaction<E>): (event: E) => boolean;
|
|
51
|
+
export {};
|
|
@@ -72,3 +72,34 @@ export function isMeaningfulStateChange(event) {
|
|
|
72
72
|
const RETICLE_VOICE = /^(?:reticle:|__reticle)/;
|
|
73
73
|
/** True for a signal or store that Reticle sends about itself. It says nothing about the app. */
|
|
74
74
|
export const isReticleVoice = (name) => RETICLE_VOICE.test(name);
|
|
75
|
+
/**
|
|
76
|
+
* A store change or an app signal that can be TIED to the action (#1531).
|
|
77
|
+
*
|
|
78
|
+
* The app's own state moving is a reaction, the same as a request, even when the DOM update it
|
|
79
|
+
* drives lands after the window was read: a Pause button whose store changes on the media `pause`
|
|
80
|
+
* event. But being in the window is not enough. The session stamps the active action's id on every
|
|
81
|
+
* event between dispatch and settle, so a busy page's background store updates look attributed
|
|
82
|
+
* too, and a dead click among them must still be reported ("no-effect under ambient churn").
|
|
83
|
+
*
|
|
84
|
+
* So a change counts only when it is tied to the action in one of two ways:
|
|
85
|
+
* - the caller's predicate named it (a `state` path or a `signal` name), so it is the consequence
|
|
86
|
+
* they expected; or
|
|
87
|
+
* - it was quiet before the action: `prior` holds observations, and none of them moved this path
|
|
88
|
+
* or fired this signal. Churn that was already moving is the background, not this click.
|
|
89
|
+
*/
|
|
90
|
+
export function tiedReaction(prior, { keyOf, isNamed }) {
|
|
91
|
+
const movedBefore = new Set();
|
|
92
|
+
for (const event of prior) {
|
|
93
|
+
const key = keyOf(event);
|
|
94
|
+
if (key !== undefined) {
|
|
95
|
+
movedBefore.add(key);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return (event) => {
|
|
99
|
+
const key = keyOf(event);
|
|
100
|
+
if (key === undefined) {
|
|
101
|
+
return false;
|
|
102
|
+
}
|
|
103
|
+
return isNamed(event) || (prior.length > 0 && !movedBefore.has(key));
|
|
104
|
+
};
|
|
105
|
+
}
|
|
@@ -64,6 +64,13 @@ interface NetCallView {
|
|
|
64
64
|
* which is the reading that turns an unverifiable call into an assumed success.
|
|
65
65
|
*/
|
|
66
66
|
oneWay?: boolean;
|
|
67
|
+
/**
|
|
68
|
+
* The document before this one made this request, and the daemon carried it here (#1944). Its
|
|
69
|
+
* place in the list is when this document connected, not when the request happened.
|
|
70
|
+
*/
|
|
71
|
+
fromDepartedDocument?: boolean;
|
|
72
|
+
/** Its page unloaded before the answer arrived: the outcome is unknown, not failed (#1944). */
|
|
73
|
+
pageUnloaded?: boolean;
|
|
67
74
|
}
|
|
68
75
|
export declare function projectNetCall(e: ReticleEvent, includeBodies?: boolean): NetCallView;
|
|
69
76
|
/**
|
|
@@ -118,4 +125,61 @@ interface ConsoleEmptyHint {
|
|
|
118
125
|
byLevel: ConsoleLevelCounts;
|
|
119
126
|
}
|
|
120
127
|
export declare function consoleEmptyHint(allConsole: ReticleEvent[]): ConsoleEmptyHint;
|
|
128
|
+
/**
|
|
129
|
+
* Did the browser leave for a URL this filter names, inside the window (#1936)?
|
|
130
|
+
*
|
|
131
|
+
* A click on `<a download>`, or on a link that the server answers as an attachment, is recorded as a
|
|
132
|
+
* navigation `NET_PENDING`. The response goes to the download manager. The page never sees its
|
|
133
|
+
* status, and no `NET_REQUEST` can close the record. A miss over this window is unobservable, not a
|
|
134
|
+
* failure: the file can be on disk while the net channel shows only the pending record.
|
|
135
|
+
*
|
|
136
|
+
* An ordinary link records the same navigation `NET_PENDING`, and there the page DID leave, so a
|
|
137
|
+
* miss stays a real `no`. A record counts only when it is a download (`download: true`), or when no
|
|
138
|
+
* later event comes from a different document. A later event with another `documentId` proves that
|
|
139
|
+
* a new document loaded, so the old page's request did not go to a download.
|
|
140
|
+
*/
|
|
141
|
+
export declare function departedInWindow(events: readonly ReticleEvent[], since: number, method: string | undefined, urlContains: string | undefined): boolean;
|
|
142
|
+
/**
|
|
143
|
+
* Did a request to this URL leave through a `fetch` that Reticle did not patch, in the window?
|
|
144
|
+
*
|
|
145
|
+
* The SDK reports such a call as `net.unpatched`: the browser recorded it in resource timing, and no
|
|
146
|
+
* patched transport saw it. It has no method, so only the URL filter can match it.
|
|
147
|
+
*/
|
|
148
|
+
export declare function unpatchedInWindow(events: readonly ReticleEvent[], since: number, urlContains: string | undefined): boolean;
|
|
149
|
+
/**
|
|
150
|
+
* Did the page send a request this filter names, inside the window, and unload before its answer
|
|
151
|
+
* arrived (#1944)? The daemon marks such a carried `NET_PENDING` `pageUnloaded`. Its outcome is
|
|
152
|
+
* unknown, so a miss over it is unobservable, not a failure.
|
|
153
|
+
*/
|
|
154
|
+
export declare function unloadedInWindow(events: readonly ReticleEvent[], since: number, method: string | undefined, urlContains: string | undefined): boolean;
|
|
155
|
+
/**
|
|
156
|
+
* The media entry that matches this filter and was recorded BEFORE the window opened, if any.
|
|
157
|
+
*
|
|
158
|
+
* The browser observer reports only the first resource timing entry for a URL: its seen-set
|
|
159
|
+
* (`reportedNetUrls` in adapters/realm/browser/src/observers/network.ts) drops every later entry
|
|
160
|
+
* for a URL it has already reported. For a media element load that first entry is also the only
|
|
161
|
+
* kind of record there is, so once it lands before `since`, a repeat load inside the window
|
|
162
|
+
* leaves no record at all and the window reads empty. The empty window is then not evidence the
|
|
163
|
+
* file did not load in it — a missing entry is not evidence there (#2069).
|
|
164
|
+
*
|
|
165
|
+
* A `fetch` or XHR record before the window impeaches nothing and is not returned here: the
|
|
166
|
+
* patched transports report every call, so a repeat would have been seen. Only the clauses that
|
|
167
|
+
* identify the request are read — `urlContains` and `method`. A status clause is not read: the
|
|
168
|
+
* entry's status is the unreadable thing this blind spot is about. Resource timing carries no
|
|
169
|
+
* method; the observer stamps `GET` for exactly that reason, so a record with no method counts
|
|
170
|
+
* as the `GET` a media element only ever issues.
|
|
171
|
+
*/
|
|
172
|
+
export declare function mediaEntryBeforeWindow(events: readonly ReticleEvent[], since: number, method: string | undefined, urlContains: string | undefined): ReticleEvent | undefined;
|
|
173
|
+
/** A `confirm` or `prompt` that Reticle answered for the app, as the window recorded it. */
|
|
174
|
+
export interface DeclinedDialog {
|
|
175
|
+
readonly kind: string;
|
|
176
|
+
readonly message?: string;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* The first dialog in the window that Reticle answered on the app's behalf, or undefined.
|
|
180
|
+
*
|
|
181
|
+
* Only a dialog that carries `answered` counts. An `alert` has no answer, so it cannot change which
|
|
182
|
+
* path the app took. The SDK and the leased-tab pool both record the answer in this one event.
|
|
183
|
+
*/
|
|
184
|
+
export declare function declinedDialogIn(events: readonly ReticleEvent[]): DeclinedDialog | undefined;
|
|
121
185
|
export {};
|