add JSDoc types to ctx

This commit is contained in:
David Reed 2022-11-23 12:52:56 -05:00
parent d6ce4ff0cd
commit 71e7a4e48f
No known key found for this signature in database
GPG key ID: 2211691D8A1EE72F
21 changed files with 200 additions and 0 deletions

View file

@ -1,7 +1,15 @@
import EventEmitter from 'events';
import HookEvent from '../hook.js';
/**
* @typedef {import('../index').default} UVClient
*/
class AttrApi extends EventEmitter {
/**
*
* @param {UVClient} ctx
*/
constructor(ctx) {
super();
this.ctx = ctx;

View file

@ -1,7 +1,15 @@
import EventEmitter from 'events';
import HookEvent from '../hook.js';
/**
* @typedef {import('../index').default} UVClient
*/
class DocumentHook extends EventEmitter {
/**
*
* @param {UVClient} ctx
*/
constructor(ctx) {
super();
this.ctx = ctx;

View file

@ -1,7 +1,15 @@
import EventEmitter from 'events';
import HookEvent from '../hook.js';
/**
* @typedef {import('../index').default} UVClient
*/
class ElementApi extends EventEmitter {
/**
*
* @param {UVClient} ctx
*/
constructor(ctx) {
super();
this.ctx = ctx;

View file

@ -1,7 +1,15 @@
import EventEmitter from 'events';
import HookEvent from '../hook.js';
/**
* @typedef {import('../index').default} UVClient
*/
class NodeApi extends EventEmitter {
/**
*
* @param {UVClient} ctx
*/
constructor(ctx) {
super();
this.ctx = ctx;

View file

@ -1,7 +1,15 @@
import EventEmitter from 'events';
import HookEvent from '../hook.js';
/**
* @typedef {import('../index').default} UVClient
*/
class StyleApi extends EventEmitter {
/**
*
* @param {UVClient} ctx
*/
constructor(ctx) {
super();
this.ctx = ctx;

View file

@ -1,7 +1,15 @@
import EventEmitter from 'events';
import HookEvent from './hook.js';
/**
* @typedef {import('./index').default} UVClient
*/
class History extends EventEmitter {
/**
*
* @param {UVClient} ctx
*/
constructor(ctx) {
super();
this.ctx = ctx;

View file

@ -1,6 +1,14 @@
import EventEmitter from 'events';
/**
* @typedef {import('./index').default} UVClient
*/
class LocationApi extends EventEmitter {
/**
*
* @param {UVClient} ctx
*/
constructor(ctx) {
super();
this.ctx = ctx;

View file

@ -1,7 +1,15 @@
import EventEmitter from 'events';
import HookEvent from './hook.js';
/**
* @typedef {import('./index').default} Ultraviolet
*/
class MessageApi extends EventEmitter {
/**
*
* @param {Ultraviolet} ctx
*/
constructor(ctx) {
super();
this.ctx = ctx;

View file

@ -1,7 +1,15 @@
import EventEmitter from 'events';
import HookEvent from '../hook.js';
/**
* @typedef {import('../index').default} UVClient
*/
class FunctionHook extends EventEmitter {
/**
*
* @param {UVClient} ctx
*/
constructor(ctx) {
super();
this.ctx = ctx;

View file

@ -1,7 +1,15 @@
import EventEmitter from 'events';
import HookEvent from '../hook.js';
/**
* @typedef {import('../index').default} UVClient
*/
class ObjectHook extends EventEmitter {
/**
*
* @param {UVClient} ctx
*/
constructor(ctx) {
super();
this.ctx = ctx;

View file

@ -1,7 +1,15 @@
import EventEmitter from 'events';
import HookEvent from './hook.js';
/**
* @typedef {import('./index').default} UVClient
*/
class NavigatorApi extends EventEmitter {
/**
*
* @param {UVClient} ctx
*/
constructor(ctx) {
super();
this.ctx = ctx;

View file

@ -1,7 +1,15 @@
import EventEmitter from 'events';
import HookEvent from '../hook.js';
/**
* @typedef {import('../index').default} UVClient
*/
class EventSourceApi extends EventEmitter {
/**
*
* @param {UVClient} ctx
*/
constructor(ctx) {
super();
this.ctx = ctx;

View file

@ -1,7 +1,15 @@
import EventEmitter from 'events';
import HookEvent from '../hook.js';
/**
* @typedef {import('../index').default} UVClient
*/
class Fetch extends EventEmitter {
/**
*
* @param {UVClient} ctx
*/
constructor(ctx) {
super();
this.ctx = ctx;

View file

@ -1,7 +1,15 @@
import EventEmitter from 'events';
import HookEvent from '../hook.js';
/**
* @typedef {import('../index').default} UVClient
*/
class Xhr extends EventEmitter {
/**
*
* @param {UVClient} ctx
*/
constructor(ctx) {
super();
this.ctx = ctx;

View file

@ -1,7 +1,15 @@
import EventEmitter from 'events';
import HookEvent from './hook.js';
/**
* @typedef {import('./index').default} UVClient
*/
class StorageApi extends EventEmitter {
/**
*
* @param {UVClient} ctx
*/
constructor(ctx) {
super();
this.ctx = ctx;

View file

@ -1,7 +1,15 @@
import EventEmitter from 'events';
import HookEvent from './hook.js';
/**
* @typedef {import('./index').default} UVClient
*/
class URLApi extends EventEmitter {
/**
*
* @param {UVClient} ctx
*/
constructor(ctx) {
super();
this.ctx = ctx;

View file

@ -1,7 +1,15 @@
import EventEmitter from 'events';
import HookEvent from './hook.js';
/**
* @typedef {import('./index').default} UVClient
*/
class Workers extends EventEmitter {
/**
*
* @param {UVClient} ctx
*/
constructor(ctx) {
super();
this.ctx = ctx;

View file

@ -1,7 +1,15 @@
import EventEmitter from 'events';
import { parse, parseFragment, serialize } from 'parse5';
/**
* @typedef {import('./index').default} Ultraviolet
*/
class HTML extends EventEmitter {
/**
*
* @param {Ultraviolet} ctx
*/
constructor(ctx) {
super();
this.ctx = ctx;

View file

@ -1,3 +1,11 @@
/**
* @typedef {import('./index').default} Ultraviolet
*/
/**
*
* @param {Ultraviolet} ctx
*/
function url(ctx) {
const { css } = ctx;
css.on('Url', (node, data, type) => {
@ -8,6 +16,10 @@ function url(ctx) {
});
}
/**
*
* @param {Ultraviolet} ctx
*/
function importStyle(ctx) {
const { css } = ctx;
css.on('Atrule', (node, data, type) => {

View file

@ -1,3 +1,11 @@
/**
* @typedef {import('./index').default} Ultraviolet
*/
/**
*
* @param {Ultraviolet} ctx
*/
function attributes(ctx, meta = ctx.meta) {
const { html, js, attributePrefix } = ctx;
const origPrefix = attributePrefix + '-attr-';
@ -68,6 +76,10 @@ function attributes(ctx, meta = ctx.meta) {
});
}
/**
*
* @param {Ultraviolet} ctx
*/
function text(ctx) {
const { html, js, css } = ctx;
@ -180,6 +192,10 @@ function isEvent(name) {
);
}
/**
*
* @param {Ultraviolet} ctx
*/
function injectHead(ctx) {
const { html } = ctx;
html.on('element', (element, type) => {

View file

@ -1,5 +1,13 @@
import { Syntax } from 'esotope-hammerhead';
/**
* @typedef {import('./index').default} Ultraviolet
*/
/**
*
* @param {Ultraviolet} ctx
*/
function property(ctx) {
const { js } = ctx;
js.on('MemberExpression', (node, data, type) => {
@ -118,6 +126,10 @@ function property(ctx) {
});
}
/**
*
* @param {Ultraviolet} ctx
*/
function identifier(ctx) {
const { js } = ctx;
js.on('Identifier', (node, data, type) => {
@ -185,6 +197,10 @@ function identifier(ctx) {
});
}
/**
*
* @param {Ultraviolet} ctx
*/
function wrapEval(ctx) {
const { js } = ctx;
js.on('CallExpression', (node, data, type) => {
@ -210,6 +226,10 @@ function wrapEval(ctx) {
});
}
/**
*
* @param {Ultraviolet} ctx
*/
function importDeclaration(ctx) {
const { js } = ctx;
js.on(Syntax.Literal, (node, data, type) => {
@ -234,6 +254,10 @@ function importDeclaration(ctx) {
});
}
/**
*
* @param {Ultraviolet} ctx
*/
function dynamicImport(ctx) {
const { js } = ctx;
js.on(Syntax.ImportExpression, (node, data, type) => {
@ -253,6 +277,10 @@ function dynamicImport(ctx) {
});
}
/**
*
* @param {Ultraviolet} ctx
*/
function unwrap(ctx) {
const { js } = ctx;
js.on('CallExpression', (node, data, type) => {