This site uses cookies for analytics. By continuing to browse this site, you agree to this use.
A JS Foundation Project

Events

Events

Information is shared internally via events. connectors and parsers can create them, while parsers and rules consume them. The following is a list of all the events common to all connectors, with their signature, and the interface they implement.

element::<element-type>

Event is emitted when the connector visits an element in the DOM when traversing it. <element-type> is the nodeName lower cased.

Format:

type ElementFound = {
/** The URI of the resource firing this event. */
resource: string;
/** The visited element. */
element: IAsyncHTMLElement;
}

fetch::end::<resource-type>

Event is emitted when the content of a resource (js, css, image, etc.) has finished downloading.

Format:

type FetchEnd {
/** The element that initiated the request. */
element: IAsyncHTMLElement;
/** The URL of the target */
resource: string;
/** The request made to fetch the target. */
request: Request;
/** The response sent while fetching the target. */
response: Response;
}

fetch::error::<resource-type>

Event is emitted when a problem downloading the content of a resource was encountered.

Format:

type FetchError {
/** The URL of the target. */
resource: string;
/** The element that initiated the request. */
element: IAsyncHTMLElement;
/** The error found. */
error: any;
/** The redirects performed for the url. */
hops: Array<string>
}

fetch::start::<resource-type>

Event is emitted when the request to fetch the target is about to start

Format:

type FetchStart {
/** The URL to download */
resource: string;
}

parse::javascript

Event is emitted when the JavaScript parser has finished parsing a JavaScript resource (a file or a <script> tag).

Format:

type ScriptParse {
/** The URL of the resource. */
resource: string;
/** The source code parsed */
sourceCode: any;
}

scan::end

Event is emitted when the connector has finished sending all events and its about to return. This is the last event to be emitted.

Format:

type ScanEnd {
/** The final URL analyzed. */
resource: string;
}

scan::start

Event is emitted when the connector is about to start the analysis. This is the first event to be emitted.

Format:

type ScanStart {
/** The URL to analyze. */
resource: string;
}

Note: This event is fired synchronously. You should not return a Promise because it will not wait for it to be resolved. If you need to perform an async operation you should combine it with scan::end. You can find more information in how to interact with other services.

traverse::down

Event is emitted when the connector is traversing and starts visiting the children of a node. element is the parent node that is to be traversed.

Format:

type TraverseDown {
/** The parent element to be traversed. */
element: IAsyncHTMLElement;
/** The URL of the target. */
resource: string;
}

traverse::end

Event is emitted when the connector has finished traversing the DOM entirely.

Format:

type TraverseEnd {
/** The URL of the target. */
resource: string;
}

traverse::start

Event is emitted when the connector is going to start traversing the DOM.

Format:

type TraverseStart {
/** The URL of the target. */
resource: string;
}

traverse::up

Event is emitted when the connector has finsihed visiting the children of a node and goes to the next one. element is the parent node that was traversed.

Format:

type TraverseUp {
/** The parent element that was traversed. */
element: IAsyncHTMLElement;
/** The URL of the target. */
resource: string;
}