mark action with pageSymbol

This commit is contained in:
Simon Knott 2024-09-06 13:32:34 +02:00
parent 21fb8d84a0
commit 9fbf0ded35
No known key found for this signature in database
GPG key ID: 8CEDC00028084AEC
2 changed files with 4 additions and 1 deletions

View file

@ -43,6 +43,7 @@ export type ContextEntry = {
export type PageEntry = { export type PageEntry = {
screencastFrames: { screencastFrames: {
sha1: string, sha1: string,
pageId: string,
timestamp: number, timestamp: number,
width: number, width: number,
height: number, height: number,

View file

@ -22,6 +22,7 @@ import type { ContextEntry, PageEntry } from '../entries';
import type { StackFrame } from '@protocol/channels'; import type { StackFrame } from '@protocol/channels';
const contextSymbol = Symbol('context'); const contextSymbol = Symbol('context');
const pageSymbol = Symbol('page');
const nextInContextSymbol = Symbol('next'); const nextInContextSymbol = Symbol('next');
const prevInListSymbol = Symbol('prev'); const prevInListSymbol = Symbol('prev');
const eventsSymbol = Symbol('events'); const eventsSymbol = Symbol('events');
@ -148,6 +149,7 @@ function indexModel(context: ContextEntry) {
for (let i = 0; i < context.actions.length; ++i) { for (let i = 0; i < context.actions.length; ++i) {
const action = context.actions[i] as any; const action = context.actions[i] as any;
action[contextSymbol] = context; action[contextSymbol] = context;
action[pageSymbol] = context.pages.find(page => page.screencastFrames.find(frame => frame.pageId === action.pageId));
} }
let lastNonRouteAction = undefined; let lastNonRouteAction = undefined;
for (let i = context.actions.length - 1; i >= 0; i--) { for (let i = context.actions.length - 1; i >= 0; i--) {
@ -357,7 +359,7 @@ export function prevInList(action: ActionTraceEvent): ActionTraceEvent {
} }
export function pageForAction(action: ActionTraceEvent): PageEntry { export function pageForAction(action: ActionTraceEvent): PageEntry {
return context(action).pages[0]; // TODO: figure out what to do about multiple pages. return (action as any)[pageSymbol];
} }
export function stats(action: ActionTraceEvent): { errors: number, warnings: number } { export function stats(action: ActionTraceEvent): { errors: number, warnings: number } {