[chore]: pull stringified JS into TS file#1622
Conversation
|
There was a problem hiding this comment.
No issues found across 5 files
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Architecture diagram
sequenceDiagram
participant Build as Build Script<br/>(genScreenshotScripts.ts)
participant Source as Source Code<br/>(resolveMaskRect.ts)
participant Artifact as Generated Output<br/>(screenshotScripts.generated.ts)
participant Runtime as ScreenshotUtils<br/>(Node.js)
participant Browser as Browser Page<br/>(Chrome DevTools Protocol)
Note over Build,Artifact: NEW: Build-Time Compilation Phase
Build->>Source: Read TypeScript source
Build->>Build: Bundle, Minify (esbuild), & Serialize
Build->>Artifact: Write "screenshotScriptSources"<br/>(Contains stringified functions)
Note over Runtime,Browser: Run-Time Execution Phase
Runtime->>Artifact: Import screenshotScriptSources
Note right of Runtime: CHANGED: Function string is now<br/>imported vs hardcoded
Runtime->>Browser: CDP: Runtime.callFunctionOn
Note right of Runtime: Payload includes:<br/>functionDeclaration: screenshotScriptSources.resolveMaskRect
Browser->>Browser: Execute injected JS inside DOM context
Browser-->>Runtime: Return {x, y, width, height}
Greptile OverviewGreptile SummaryExtracted stringified JavaScript from Key changes:
The approach preserves Confidence Score: 5/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant Dev as Developer
participant Build as Build Process
participant Gen as genScreenshotScripts.ts
participant ESB as esbuild
participant Src as screenshotScripts/
participant Out as build/screenshotScripts.generated.ts
participant Utils as screenshotUtils.ts
participant CDP as Chrome DevTools Protocol
Dev->>Build: npm run build-dom-scripts
Build->>Gen: tsx genScreenshotScripts.ts
Gen->>ESB: Bundle screenshotScripts/index.ts
ESB->>Src: Read resolveMaskRect.ts
ESB-->>Gen: Return minified module
Gen->>Gen: Import compiled module
Gen->>Gen: Extract functions & call .toString()
Gen->>Out: Write screenshotScriptSources object
Note over Utils,CDP: Runtime Usage
Utils->>Out: Import screenshotScriptSources
Utils->>CDP: callFunctionOn with functionDeclaration
CDP->>CDP: Execute function string in browser context
CDP-->>Utils: Return result
|
…tils # Conflicts: # packages/core/lib/v3/understudy/screenshotUtils.ts
why
what changed
screenshotUtils.tsinto its ownresolveMaskRect.tsfilepackages/core/lib/v3/dom/genScreenshotScripts.tstest plan
Summary by cubic
Replace stringified screenshot DOM code with typed TS functions and generate function strings at build time. This makes screenshot scripts easier to maintain and debug.
Written for commit 8ce9a91. Summary will update on new commits. Review in cubic