"""
This file is generated by generator/run.py based on the Chrome DevTools Protocol.

Supports additional targets discovery and allows to attach to them.
https://chromedevtools.github.io/devtools-protocol/tot/Target/

***************************************************
                    Events
***************************************************
"""
from __future__ import annotations

from cdpkit.protocol._types import (
    Target,
)
from cdpkit.protocol.base import CDPEvent


class AttachedToTarget(CDPEvent):
    """ Issued when attached to target because of auto-attach or `attachToTarget` command. """

    sessionId: Target.SessionID
    targetInfo: Target.TargetInfo
    waitingForDebugger: bool


class DetachedFromTarget(CDPEvent):
    """ Issued when detached from target for any reason (including `detachFromTarget` command). Can be
    issued multiple times per target if multiple sessions have been attached to it. """

    sessionId: Target.SessionID
    targetId: Target.TargetID | None = None  # deprecated


class ReceivedMessageFromTarget(CDPEvent):
    """ Notifies about a new protocol message received from the session (as reported in
    `attachedToTarget` event). """

    sessionId: Target.SessionID
    message: str
    targetId: Target.TargetID | None = None  # deprecated


class TargetCreated(CDPEvent):
    """ Issued when a possible inspection target is created. """

    targetInfo: Target.TargetInfo


class TargetDestroyed(CDPEvent):
    """ Issued when a target is destroyed. """

    targetId: Target.TargetID


class TargetCrashed(CDPEvent):
    """ Issued when a target has crashed. """

    targetId: Target.TargetID
    status: str
    errorCode: int


class TargetInfoChanged(CDPEvent):
    """ Issued when some information about a target has changed. This only happens between
    `targetCreated` and `targetDestroyed`. """

    targetInfo: Target.TargetInfo
