-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
28 changed files
with
203 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export * from './dist/debug.js'; | ||
export * from './dist/debug/index.js'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/metadata/__utils__/plant/PlantLink.ts → src/debug/plant/PlantLink.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/metadata/__utils__/plant/PlantObject.ts → src/debug/plant/PlantObject.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...tadata/__utils__/plant/PlantSerializer.ts → src/debug/plant/PlantSerializer.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import fs from 'node:fs/promises'; | ||
import { | ||
GlobalMetadataRegistry, | ||
type MetadataEvent, | ||
MetadataEventHandler, | ||
MetadataFactoryImpl, | ||
type WriteMetadataEventEmitter, | ||
} from '../metadata'; | ||
import { SerialEmitter } from '../utils'; | ||
import { PlantSerializer } from './plant'; | ||
|
||
export async function visualize(traceJsonFile: string | MetadataEvent[]) { | ||
const events: MetadataEvent[] = Array.isArray(traceJsonFile) | ||
? traceJsonFile | ||
: await readEvents(traceJsonFile); | ||
|
||
return replayEvents(events); | ||
} | ||
|
||
async function readEvents(traceJsonFile: string): Promise<MetadataEvent[]> { | ||
const raw = await fs.readFile(traceJsonFile, 'utf8'); | ||
const json = JSON.parse(raw) as any[]; | ||
const mainPID = json[0].pid; | ||
const events: MetadataEvent[] = []; | ||
for (const event of json) { | ||
const { cat, pid, args } = event; | ||
if (pid === mainPID && args?.event?.type && cat?.includes('emitter-events')) { | ||
events.push(args.event as MetadataEvent); | ||
} | ||
} | ||
|
||
return events; | ||
} | ||
|
||
function replayEvents(events: MetadataEvent[]) { | ||
const emitter: WriteMetadataEventEmitter = new SerialEmitter('set'); | ||
const metadataRegistry = new GlobalMetadataRegistry(); | ||
const metadataFactory = new MetadataFactoryImpl(metadataRegistry, emitter); | ||
const globalMetadata = metadataFactory.createGlobalMetadata(); | ||
const eventHandler = new MetadataEventHandler({ | ||
globalMetadata, | ||
metadataRegistry, | ||
}); | ||
|
||
for (const event of events) { | ||
eventHandler.handle(event); | ||
} | ||
|
||
return PlantSerializer.serialize(metadataFactory.checker, metadataRegistry); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.