Это ide на основе vs code(code oss), в ней будет встроенный умный апи роутинг, свой маркет с плагинами(агент харнесс, поддержка java/kotlin/мобильной разработки, командная разработка проектов, orca, оркестратор агентов
/**
* Preload script for pages loaded in Integrated Browser
*
* It runs in an isolated context that Electron calls an "isolated world".
* Specifically the isolated world with worldId 999, which shows in DevTools as "Electron Isolated Context".
* Despite being isolated, it still runs on the same page as the JS from the actual loaded website
* which runs on the so-called "main world" (worldId 0. In DevTools as "top").
*
* Learn more: see Electron docs for Security, contextBridge, and Context Isolation.
*/
/** Opaque token exposed for CDP-side frame matching. */
getFrameToken
(
)
:
string
{
return
;
}
}
;
try
{
// Use `contextBridge` APIs to expose globals to the same isolated world where this preload script runs (worldId 999).
// The isolatedHelpers object will be recursively frozen (and for functions also proxied) by Electron to prevent
// modification within the given context.
.
exposeInIsolatedWorld
(
999
,
'browserViewAPI'
,
)
;
// Expose helpers on `window.__vscode_helpers` in the page's main world
// for CDP `Runtime.evaluate` (which runs against the main world) to use.
.
exposeInMainWorld
(
'__vscode_helpers'
,
)
;
}
catch
(
)
{
console
.
error
(
)
;
}
.
send
(
'vscode:browserView:preloadReady'
,
)
;
}
/**
* Find the deepest element that contains every element in `candidates`.
* Walks up `parentElement` from each candidate to build chains, then
* returns the last shared element. Returns `undefined` if the chains
* don't overlap (shouldn't happen for elements in the same document).
*/
function
findCommonVisibleAncestor
(
:
readonly
(
|
null
|
undefined
)
[
]
)
:
|
undefined
{
const
=
.
filter
(
=>
!
!
)
as
[
]
;
const
=
[
...
new
Set
(
.
map
(
=>
instanceof
Element
?
:
.
)
.
filter
(
=>
!
!
)
)
]
as
[
]
;
if
(
.
===
0
)
{
return
undefined
;
}
// Find the nearest visible ancestor of a single element.
const
=
(
:
)
:
=>
{
for
(
let
:
|
null
=
;
;
=
.
)
{
const
=
instanceof
HTMLElement
?
.
:
.
;
const
=
instanceof
HTMLElement
?
.
:
.
;
if
(
>
0
&&
>
0
)
{
return
;
}
}
return
;
}
;
if
(
.
===
1
)
{
return
findVisible
(
[
0
]
)
;
}
// Build the ancestor chain for the first candidate (root → element).
const
:
[
]
=
[
]
;
for
(
let
:
|
null
=
[
0
]
;
;
=
.
)
{
.
unshift
(
)
;
}
// Reduce to chain prefix shared with every other candidate.
let
=
;
for
(
let
=
1
;
<
.
;
++
)
{
const
:
[
]
=
[
]
;
for
(
let
:
|
null
=
[
]
;
;
=
.
)
{
.
unshift
(
)
;
}
let
=
0
;
const
=
.
min
(
.
,
.
)
;
while
(
<
&&
[
]
===
[
]
)
{
++
;
}
=
.
slice
(
0
,
)
;
if
(
.
===
0
)
{
return
undefined
;
}
}
return
findVisible
(
[
.
-
1
]
)
;
}
type
ElementComment
=
{
:
;
:
;
:
;
:
string
;
:
number
;
:
{
:
number
;
:
number
}
;
}
;
type
PendingElementComment
=
{
:
;
:
{
:
number
;
:
number
}
;
:
string
;
:
boolean
;
}
;
type
ScheduledCommentPin
=
{
:
string
;
:
number
;
:
number
;
:
number
;
}
;
type
CommentAnimation
=
{
:
;
:
[
]
;
}
;
/**
* Element-pick controller used by the "Add Element to Chat" flow.
*
* `start({ theme })` mounts a transparent overlay on the page that
* highlights the element under the pointer (click) or finds the deepest
* common ancestor of the elements covered by a click+drag rectangle. On
* selection the picked `Element` is registered with the shared `track()`
* helper and the host is notified with the resulting id; the overlay is
* then torn down. `stop()` tears down without picking.
*/
// Inject a stylesheet into the page to override all cursors while element selection is active,
// so the cursor always appears as a normal pointer even when over e.g. links.
// Updated to crosshair in _onPointerDown, reset in _onPointerUp.
const
=
.
createElement
(
'style'
)
;
.
=
.
;
.
.
appendChild
(
)
;
this
.
=
;
// Register high-frequency listeners only while selection is active.
.
addEventListener
(
'pointermove'
,
this
.
,
true
)
;
.
addEventListener
(
'pointerleave'
,
this
.
,
true
)
;
.
addEventListener
(
'pointerdown'
,
this
.
,
true
)
;
.
addEventListener
(
'pointerup'
,
this
.
,
true
)
;
.
addEventListener
(
'click'
,
this
.
,
true
)
;
.
addEventListener
(
'contextmenu'
,
this
.
,
true
)
;
.
addEventListener
(
'focusin'
,
this
.
,
true
)
;
.
addEventListener
(
'blur'
,
this
.
)
;
.
addEventListener
(
'keydown'
,
this
.
,
true
)
;
if
(
!
this
.
)
{
const
=
this
.
_getFocusedElement
(
)
;
this
.
=
.
?
:
undefined
;
this
.
_updateHighlight
(
this
.
)
;
}
return
true
;
}
private
_updateSelectionOptions
(
:
)
:
void
{
const
=
this
.
;
this
.
=
.
===
;
this
.
=
.
??
false
;
if
(
&&
!
this
.
&&
this
.
)
{
this
.
_closeCommentComposer
(
)
;
}
if
(
.
&&
!
this
.
&&
!
this
.
&&
!
this
.
)
{
this
.
=
this
.
_getFocusedElement
(
)
;
this
.
_updateHighlight
(
this
.
)
;
}
}
stop
(
)
:
void
{
if
(
!
this
.
)
{
return
;
}
this
.
_hideActiveCommentPreview
(
)
;
this
.
=
false
;
this
.
_closeCommentComposer
(
)
;
this
.
.
.
=
'none'
;
this
.
?.
remove
(
)
;
this
.
=
undefined
;
// Remove high-frequency listeners.
.
removeEventListener
(
'pointermove'
,
this
.
,
true
)
;
.
removeEventListener
(
'pointerleave'
,
this
.
,
true
)
;
.
removeEventListener
(
'pointerdown'
,
this
.
,
true
)
;
.
removeEventListener
(
'pointerup'
,
this
.
,
true
)
;
.
removeEventListener
(
'click'
,
this
.
,
true
)
;
.
removeEventListener
(
'contextmenu'
,
this
.
,
true
)
;
.
removeEventListener
(
'focusin'
,
this
.
,
true
)
;
.
removeEventListener
(
'blur'
,
this
.
)
;
.
removeEventListener
(
'keydown'
,
this
.
,
true
)
;
this
.
.
.
=
'none'
;
this
.
.
.
=
'none'
;
this
.
.
.
=
'none'
;
this
.
=
undefined
;
this
.
=
undefined
;
this
.
=
false
;
this
.
=
undefined
;
this
.
=
undefined
;
if
(
this
.
)
{
this
.
_updateHighlight
(
this
.
)
;
}
this
.
_onStopped
(
)
;
this
.
_unmountWhenIdle
(
)
;
}
/**
* Update the theme colors applied to the overlay.
* Can be called at any time; takes effect immediately.
*/
setTheme
(
:
)
:
void
{
.
_applyTheme
(
this
.
,
)
;
this
.
=
.
??
false
;
this
.
.
.
toggle
(
'reduce-motion'
,
this
.
)
;
}
updateLocalizedStrings
(
)
:
void
{
this
.
_applyLocalizedStrings
(
)
;
}
resolveContextMenuTarget
(
:
)
:
|
undefined
{
if
(
this
.
&&
.
composedPath
(
)
.
includes
(
this
.
)
)
{
this
.
_hideActiveCommentPreview
(
)
;
return
this
.
_pickElementAt
(
.
,
.
)
;
}
return
.
instanceof
Element
?
.
:
undefined
;
}
/**
* Highlight a specific element without starting a pick session.
* Mounts the shadow host if not already in the document.
*/
highlight
(
:
)
:
void
{
this
.
_ensureMounted
(
)
;
this
.
=
;
this
.
_hideActiveCommentPreview
(
)
;
this
.
_updateHighlight
(
)
;
}
/**
* Hide any current highlight. If no pick session is active, also
* removes the shadow host from the document.
*/
hideHighlight
(
)
:
void
{
this
.
=
undefined
;
if
(
this
.
)
{
return
;
}
this
.
_updateHighlight
(
undefined
)
;
this
.
_unmountWhenIdle
(
)
;
}
comment
(
:
,
:
{
:
number
;
:
number
}
)
:
void
{
this
.
=
undefined
;
if
(
this
.
)
{
this
.
stop
(
)
;
}
this
.
start
(
{
:
}
)
;
this
.
_showCommentComposer
(
,
,
true
)
;
}
updateComments
(
:
)
:
void
{
if
(
.
)
{
const
=
new
Map
(
.
.
map
(
(
,
)
=>
[
.
,
{
:
.
,
:
+
1
}
]
)
)
;
for
(
const
[
,
]
of
this
.
)
{
const
=
.
get
(
)
;
if
(
!
)
{
if
(
this
.
===
)
{
this
.
_hideActiveCommentPreview
(
)
;
}
.
.
remove
(
)
;
this
.
.
delete
(
)
;
}
else
{
.
=
.
;
if
(
.
===
.
)
{
continue
;
}
.
=
.
;
if
(
this
.
===
)
{
this
.
_setCommentPreviewBody
(
.
)
;
this
.
_renderHighlight
(
.
)
;
}
}
}
for
(
const
[
,
]
of
)
{
if
(
this
.
.
has
(
)
)
{
continue
;
}
const
=
this
.
.
get
(
)
;
if
(
)
{
this
.
_scheduleCommentPin
(
,
.
,
.
)
;
}
}
for
(
const
of
this
.
.
keys
(
)
)
{
if
(
!
.
has
(
)
)
{
this
.
_discardPendingComment
(
)
;
}
}
}
for
(
const
of
.
??
[
]
)
{
this
.
_discardPendingComment
(
)
;
}
this
.
_updateCommentPinNumbers
(
)
;
this
.
_unmountWhenIdle
(
)
;
}
// --- Event handlers ---
private
=
(
:
)
:
void
=>
{
if
(
!
this
.
)
{
return
;
}
const
=
.
composedPath
(
)
.
includes
(
this
.
)
;
if
(
this
.
)
{
if
(
!
)
{
this
.
=
true
;
}
return
;
}
const
=
this
.
?
this
.
.
get
(
this
.
)
:
undefined
;
if
(
)
{
if
(
!
)
{
.
=
true
;
}
return
;
}
if
(
this
.
||
this
.
||
)
{
return
;
}
.
preventDefault
(
)
;
.
stopPropagation
(
)
;
if
(
!
this
.
)
{
this
.
_updateHighlight
(
this
.
_pickElementAt
(
.
,
.
)
)
;
return
;
}
const
=
.
abs
(
.
-
this
.
.
)
;
const
=
.
abs
(
.
-
this
.
.
)
;
if
(
<
.
&&
<
.
)
{
return
;
}
const
=
.
min
(
this
.
.
,
.
)
;
const
=
.
min
(
this
.
.
,
.
)
;
this
.
.
.
=
'block'
;
this
.
.
.
=
`${left}px`
;
this
.
.
.
=
`${top}px`
;
this
.
.
.
=
`${dx}px`
;
this
.
.
.
=
`${dy}px`
;
// Live preview of the deepest common ancestor that the region
// currently resolves to, so the user sees exactly what will be
// selected if they release the drag now.
this
.
_updateHighlight
(
this
.
_pickRegionAncestor
(
{
:
,
:
,
:
,
:
}
)
)
;
}
;
private
=
(
)
:
void
=>
{
if
(
!
this
.
)
{
return
;
}
if
(
this
.
)
{
this
.
=
true
;
return
;
}
const
=
this
.
?
this
.
.
get
(
this
.
)
:
undefined
;
if
(
)
{
.
=
true
;
return
;
}
if
(
this
.
||
this
.
)
{
return
;
}
if
(
!
this
.
)
{
this
.
_updateHighlight
(
this
.
)
;
}
}
;
private
=
(
:
)
:
void
=>
{
if
(
!
this
.
)
{
return
;
}
this
.
=
false
;
if
(
.
composedPath
(
)
.
includes
(
this
.
)
)
{
return
;
}
if
(
this
.
)
{
.
preventDefault
(
)
;
.
stopPropagation
(
)
;
return
;
}
if
(
this
.
)
{
this
.
=
true
;
.
preventDefault
(
)
;
.
stopPropagation
(
)
;
return
;
}
this
.
=
{
:
.
,
:
.
}
;
this
.
=
this
.
_pickElementAt
(
.
,
.
)
;
if
(
this
.
)
{
this
.
.
=
.
;
}
.
preventDefault
(
)
;
.
stopPropagation
(
)
;
}
;
private
=
(
:
)
:
void
=>
{
if
(
!
this
.
)
{
return
;
}
if
(
this
.
)
{
.
preventDefault
(
)
;
.
stopPropagation
(
)
;
const
=
this
.
;
if
(
)
{
.
setTimeout
(
(
)
=>
{
if
(
this
.
===
)
{
this
.
_finishCommentInteraction
(
)
;
}
}
)
;
}
return
;
}
if
(
.
composedPath
(
)
.
includes
(
this
.
)
)
{
return
;
}
if
(
!
this
.
)
{
return
;
}
const
=
.
abs
(
.
-
this
.
.
)
;
const
=
.
abs
(
.
-
this
.
.
)
;
const
=
this
.
;
this
.
=
undefined
;
if
(
this
.
)
{
this
.
.
=
.
;
}
if
(
<
.
&&
<
.
)
{
// Click → pick the element under the pointer.
const
=
this
.
??
this
.
_pickElementAt
(
.
,
.
)
;
this
.
=
undefined
;
if
(
)
{
this
.
_commit
(
,
{
:
.
,
:
.
}
)
;
}
}
else
{
// Drag → pick the deepest common ancestor of the region.
this
.
=
undefined
;
this
.
.
.
=
'none'
;
this
.
_updateHighlight
(
undefined
)
;
const
=
.
min
(
.
,
.
)
;
const
=
.
min
(
.
,
.
)
;
const
=
this
.
_pickRegionAncestor
(
{
:
,
:
,
:
,
:
}
)
;
if
(
)
{
this
.
_commit
(
,
{
:
.
,
:
.
}
)
;
}
}
.
preventDefault
(
)
;
.
stopPropagation
(
)
;
}
;
private
=
(
:
)
:
void
=>
{
if
(
!
this
.
)
{
return
;
}
if
(
this
.
)
{
this
.
=
false
;
.
preventDefault
(
)
;
.
stopPropagation
(
)
;
this
.
_finishCommentInteraction
(
)
;
return
;
}
if
(
.
composedPath
(
)
.
includes
(
this
.
)
)
{
return
;
}
.
preventDefault
(
)
;
.
stopPropagation
(
)
;
}
;
private
=
(
:
)
:
void
=>
{
if
(
!
this
.
||
this
.
||
this
.
||
this
.
)
{
return
;
}
if
(
.
composedPath
(
)
.
includes
(
this
.
)
)
{
return
;
}
const
=
this
.
_getFocusedElement
(
)
;
this
.
=
?.
matches
(
':focus-visible'
)
?
:
undefined
;
this
.
_updateHighlight
(
this
.
)
;
}
;
private
=
(
)
:
void
=>
{
if
(
!
this
.
||
this
.
||
this
.
)
{
return
;
}
this
.
=
undefined
;
this
.
_updateHighlight
(
undefined
)
;
}
;
private
=
(
:
)
:
void
=>
{
if
(
!
this
.
)
{
return
;
}
if
(
.
===
'Escape'
)
{
if
(
this
.
)
{
const
=
this
.
;
this
.
_focusCommentTarget
(
)
;
this
.
_finishCommentInteraction
(
)
;
.
preventDefault
(
)
;
.
stopPropagation
(
)
;
return
;
}
this
.
stop
(
)
;
.
preventDefault
(
)
;
.
stopPropagation
(
)
;
}
else
if
(
.
===
'Enter'
&&
!
.
)
{
if
(
this
.
)
{
.
preventDefault
(
)
;
.
stopPropagation
(
)
;
return
;
}
const
=
this
.
_getFocusedElement
(
)
;
if
(
)
{
.
preventDefault
(
)
;
.
stopPropagation
(
)
;
this
.
_commit
(
)
;
}
}
}
;
private
_onScrollOrResize
(
)
:
void
{
if
(
this
.
)
{
this
.
_hideActiveCommentPreview
(
)
;
}
this
.
_cancelCommentAnimations
(
)
;
if
(
this
.
)
{
this
.
_renderHighlight
(
this
.
)
;
}
if
(
this
.
)
{
this
.
_layoutCommentBackdrop
(
this
.
)
;
}
for
(
const
of
this
.
.
values
(
)
)
{
this
.
_layoutCommentPin
(
)
;
}
}
// --- Picking helpers ---
private
_getFocusedElement
(
)
:
|
undefined
{
if
(
!
.
hasFocus
(
)
)
{
return
undefined
;
}
let
=
.
;
while
(
?.
?.
)
{
=
.
.
;
}
if
(
!
||
===
.
||
===
.
||
===
this
.
||
instanceof
HTMLIFrameElement
)
{
return
undefined
;
}
return
;
}
/** Return the page element under a viewport point, skipping our own overlay host. */
private
_pickElementAt
(
:
number
,
:
number
)
:
|
undefined
{
const
=
.
elementsFromPoint
(
,
)
;
for
(
const
of
)
{
if
(
===
this
.
||
this
.
.
contains
(
)
)
{
continue
;
}
return
;
}
return
undefined
;
}
/**
* Resolve the element that "covers" a drag rectangle.
*
* Samples `elementFromPoint` at the 4 corners, 4 edge midpoints, and
* center, then returns their deepest common ancestor.
*/
private
_pickRegionAncestor
(
:
)
:
|
undefined
{
const
{
,
,
,
}
=
;
const
=
+
;
const
=
+
;
const
=
+
/
2
;
const
=
+
/
2
;
const
:
[
]
=
[
]
;
for
(
const
[
,
]
of
[
[
,
]
,
[
,
]
,
[
,
]
,
[
,
]
,
// corners
[
,
]
,
[
,
]
,
[
,
]
,
[
,
]
,
// edge midpoints
[
,
]
// center
]
)
{
const
=
this
.
_pickElementAt
(
,
)
;
if
(
)
{
.
push
(
)
;
}
}
return
findCommonVisibleAncestor
(
)
;
}
// --- Highlight ---
private
_renderHighlight
(
:
)
:
void
{
const
=
this
.
;
const
=
this
.
;
const
=
.
getBoundingClientRect
(
)
;
const
=
.
||
0
;
const
=
.
||
0
;
const
=
.
;
const
=
.
.
;
const
=
this
.
_getVisibleTargetBounds
(
)
;
const
=
22
;
// label height (20) + 2px gap above the box.
// Highlight box is in *page* coordinates so it scrolls with the document.
.
.
=
'block'
;
.
.
=
`${rect.left + scrollX}px`
;
.
.
=
`${rect.top + scrollY}px`
;
.
.
=
`${rect.width}px`
;
.
.
=
`${rect.height}px`
;
this
.
.
.
=
'block'
;
this
.
.
setAttribute
(
'x'
,
`${visibleRect.x}`
)
;
this
.
.
setAttribute
(
'y'
,
`${visibleRect.y}`
)
;
this
.
.
setAttribute
(
'width'
,
`${visibleRect.width}`
)
;
this
.
.
setAttribute
(
'height'
,
`${visibleRect.height}`
)
;
this
.
.
setAttribute
(
'rx'
,
'2'
)
;
// Label is in *viewport* coordinates and sticky-clamped to the viewport.
/**
* Inject the shadow-root stylesheet. Custom properties on the host
* element drive the colors so the workbench can theme them.
*
* We deliberately do **not** use a `*` selector with `all: initial` —
* that would also reset `<style>`'s default `display: none`, causing
* the literal CSS source to render as page text.
*/
/**
* Drag-to-select rectangle picker used by the "Add Area Screenshot to Chat"
* flow. Mounts a transparent shadow overlay that captures pointer
* events, draws a dotted rubber-band rectangle while dragging, and on pointer
* up reports the selected region in **viewport coordinates**. ESC or a
* zero-area drag cancels the pick.
*/
// A fixed full-viewport layer below the dragbox so the page underneath
// doesn't receive hover/click events while we're picking. The layer is
// transparent — the actual page is still visible.
const
=
.
createElement
(
'div'
)
;
.
=
'overlay'
;
.
appendChild
(
)
;
const
=
.
createElement
(
'div'
)
;
.
=
'dragbox'
;
.
.
=
'none'
;
.
appendChild
(
)
;
this
.
=
;
}
start
(
)
:
void
{
if
(
this
.
)
{
return
;
}
this
.
=
undefined
;
.
.
appendChild
(
this
.
)
;
this
.
=
true
;
// Force a crosshair cursor across the whole page while picking.
const
=
.
createElement
(
'style'
)
;
.
setAttribute
(
'data-vscode-area-pick-cursor'
,
''
)
;
.
=
.
;
.
.
appendChild
(
)
;
this
.
=
;
.
addEventListener
(
'pointermove'
,
this
.
,
true
)
;
.
addEventListener
(
'pointerdown'
,
this
.
,
true
)
;
.
addEventListener
(
'pointerup'
,
this
.
,
true
)
;
.
addEventListener
(
'click'
,
this
.
,
true
)
;
.
addEventListener
(
'contextmenu'
,
this
.
,
true
)
;
.
addEventListener
(
'keydown'
,
this
.
,
true
)
;
}
stop
(
)
:
void
{
if
(
!
this
.
)
{
return
;
}
this
.
_teardown
(
)
;
this
.
_onStopped
(
)
;
}
/**
* Synchronous teardown of the overlay, cursor style, and event listeners.
* Used by both {@link stop} (which then fires `_onStopped`) and `_onPointerUp`
* (which fires `_onPicked` or `_onStopped` after teardown completes, so the
* IPC consumer can capture the page without our overlay in the frame).
*/
private
_teardown
(
)
:
void
{
this
.
=
false
;
this
.
.
remove
(
)
;
this
.
?.
remove
(
)
;
this
.
=
undefined
;
.
removeEventListener
(
'pointermove'
,
this
.
,
true
)
;
.
removeEventListener
(
'pointerdown'
,
this
.
,
true
)
;
.
removeEventListener
(
'pointerup'
,
this
.
,
true
)
;
.
removeEventListener
(
'click'
,
this
.
,
true
)
;
.
removeEventListener
(
'contextmenu'
,
this
.
,
true
)
;
.
removeEventListener
(
'keydown'
,
this
.
,
true
)
;
this
.
.
.
=
'none'
;
this
.
.
.
=
'0px'
;
this
.
.
.
=
'0px'
;
this
.
.
.
=
'0px'
;
this
.
.
.
=
'0px'
;
this
.
=
undefined
;
}
setTheme
(
:
)
:
void
{
this
.
.
.
setProperty
(
'--vscode-focusBorder'
,
?.
??
null
)
;
}
private
=
(
:
)
:
void
=>
{
if
(
!
this
.
||
.
!==
0
)
{
return
;
}
this
.
=
{
:
.
,
:
.
}
;
this
.
.
.
=
'block'
;
this
.
.
.
=
`${e.clientX}px`
;
this
.
.
.
=
`${e.clientY}px`
;
this
.
.
.
=
'0px'
;
this
.
.
.
=
'0px'
;
.
preventDefault
(
)
;
.
stopPropagation
(
)
;
}
;
private
=
(
:
)
:
void
=>
{
if
(
!
this
.
||
!
this
.
)
{
return
;
}
.
preventDefault
(
)
;
.
stopPropagation
(
)
;
const
=
.
min
(
this
.
.
,
.
)
;
const
=
.
min
(
this
.
.
,
.
)
;
const
=
.
abs
(
.
-
this
.
.
)
;
const
=
.
abs
(
.
-
this
.
.
)
;
this
.
.
.
=
`${left}px`
;
this
.
.
.
=
`${top}px`
;
this
.
.
.
=
`${width}px`
;
this
.
.
.
=
`${height}px`
;
}
;
private
=
(
:
)
:
void
=>
{
if
(
!
this
.
||
!
this
.
)
{
return
;
}
const
=
this
.
;
const
=
.
min
(
.
,
.
)
;
const
=
.
min
(
.
,
.
)
;
const
=
.
abs
(
.
-
.
)
;
const
=
.
abs
(
.
-
.
)
;
// Tear down the overlay before committing so the IPC consumer can
// immediately start a screenshot without our dragbox being in the way.
this
.
_teardown
(
)
;
.
preventDefault
(
)
;
.
stopPropagation
(
)
;
if
(
<
.
||
<
.
)
{
this
.
_onStopped
(
)
;
return
;
}
// Keep rectangle in viewport (client) coordinates to match other screenshot
// capture call sites that pass viewport-space bounds as pageRect. The
// main-process clip math (`pageRect * visualViewportScale * zoomFactor`)
// measures from the visual viewport origin, so subtract the visual
// viewport's offset (non-zero only when pinch-panned) to convert layout-
// viewport client coords into the same coord space that Add Element to
// Chat's CDP box-model bounds use.
const
=
.
;
const
=
?.
??
0
;
const
=
?.
??
0
;
const
=
{
:
-
,
:
-
,
,
}
;
// The synchronous DOM teardown above is the prerequisite — the next compositor
// frame won't contain the overlay. Waiting for that frame to actually land
// before reading the GPU surface is the consumer's responsibility (see
// `awaitNextPaint` in `BrowserView.captureScreenshot`).
this
.
_onPicked
(
)
;
}
;
private
=
(
:
)
:
void
=>
{
if
(
!
this
.
)
{
return
;
}
.
preventDefault
(
)
;
.
stopPropagation
(
)
;
}
;
private
=
(
:
)
:
void
=>
{
if
(
!
this
.
)
{
return
;
}
if
(
.
===
'Escape'
)
{
this
.
stop
(
)
;
.
preventDefault
(
)
;
.
stopPropagation
(
)
;
}
}
;
private
static
_buildStyle
(
)
:
{
const
=
.
createElement
(
'style'
)
;
.
=
`
:host {
all: initial;
pointer-events: none !important;
}
.overlay {
position: fixed; inset: 0;
background: transparent;
z-index: 1;
/* Capture hit-testing so pointer events don't reach the underlying
* page during a pick — otherwise hover/:hover styles would
* fire on elements beneath the cursor while we're dragging. */
pointer-events: auto;
}
.dragbox {
position: fixed; box-sizing: border-box;
border: 1px dashed var(--vscode-focusBorder, #0078d4);
background: color-mix(in srgb, var(--vscode-focusBorder, #0078d4) 12%, transparent);
z-index: 2;
pointer-events: auto;
}
`