@@ -15,10 +15,11 @@ import type {HandlerName} from './types.js';
1515
1616export interface ScriptsData {
1717 /** Note: this is only populated when the "Enhanced Traces" feature is enabled. */
18- scripts : Map < Protocol . Runtime . ScriptId , Script > ;
18+ scripts : Script [ ] ;
1919}
2020
2121export interface Script {
22+ isolate : string ;
2223 scriptId : Protocol . Runtime . ScriptId ;
2324 frame : string ;
2425 ts : Types . Timing . Micro ;
@@ -31,7 +32,7 @@ export interface Script {
3132 request ?: Types . Events . SyntheticNetworkRequest ;
3233}
3334
34- const scriptById = new Map < Protocol . Runtime . ScriptId , Script > ( ) ;
35+ const scriptById = new Map < string , Script > ( ) ;
3536
3637export function deps ( ) : HandlerName [ ] {
3738 return [ 'Meta' , 'NetworkRequests' ] ;
@@ -42,23 +43,25 @@ export function reset(): void {
4243}
4344
4445export function handleEvent ( event : Types . Events . Event ) : void {
45- const getOrMakeScript = ( scriptIdAsNumber : number ) : Script => {
46+ const getOrMakeScript = ( isolate : string , scriptIdAsNumber : number ) : Script => {
4647 const scriptId = String ( scriptIdAsNumber ) as Protocol . Runtime . ScriptId ;
47- return Platform . MapUtilities . getWithDefault ( scriptById , scriptId , ( ) => ( { scriptId, frame : '' , ts : 0 } as Script ) ) ;
48+ const key = `${ isolate } .${ scriptId } ` ;
49+ return Platform . MapUtilities . getWithDefault (
50+ scriptById , key , ( ) => ( { isolate, scriptId, frame : '' , ts : 0 } as Script ) ) ;
4851 } ;
4952
5053 if ( Types . Events . isTargetRundownEvent ( event ) && event . args . data ) {
51- const { scriptId, frame} = event . args . data ;
52- const script = getOrMakeScript ( scriptId ) ;
54+ const { isolate , scriptId, frame} = event . args . data ;
55+ const script = getOrMakeScript ( isolate , scriptId ) ;
5356 script . frame = frame ;
5457 script . ts = event . ts ;
5558
5659 return ;
5760 }
5861
5962 if ( Types . Events . isV8SourceRundownEvent ( event ) ) {
60- const { scriptId, url, sourceUrl, sourceMapUrl} = event . args . data ;
61- const script = getOrMakeScript ( scriptId ) ;
63+ const { isolate , scriptId, url, sourceUrl, sourceMapUrl} = event . args . data ;
64+ const script = getOrMakeScript ( isolate , scriptId ) ;
6265 script . url = url ;
6366 if ( sourceUrl ) {
6467 script . sourceUrl = sourceUrl ;
@@ -70,15 +73,15 @@ export function handleEvent(event: Types.Events.Event): void {
7073 }
7174
7275 if ( Types . Events . isV8SourceRundownSourcesScriptCatchupEvent ( event ) ) {
73- const { scriptId, sourceText} = event . args . data ;
74- const script = getOrMakeScript ( scriptId ) ;
76+ const { isolate , scriptId, sourceText} = event . args . data ;
77+ const script = getOrMakeScript ( isolate , scriptId ) ;
7578 script . content = sourceText ;
7679 return ;
7780 }
7881
7982 if ( Types . Events . isV8SourceRundownSourcesLargeScriptCatchupEvent ( event ) ) {
80- const { scriptId, sourceText} = event . args . data ;
81- const script = getOrMakeScript ( scriptId ) ;
83+ const { isolate , scriptId, sourceText} = event . args . data ;
84+ const script = getOrMakeScript ( isolate , scriptId ) ;
8285 script . content = ( script . content ?? '' ) + sourceText ;
8386 return ;
8487 }
@@ -161,6 +164,6 @@ export async function finalize(options: Types.Configuration.ParseOptions): Promi
161164
162165export function data ( ) : ScriptsData {
163166 return {
164- scripts : scriptById ,
167+ scripts : [ ... scriptById . values ( ) ] ,
165168 } ;
166169}
0 commit comments