瀏覽代碼

Move JSDoc typedefs to types.ts

JC Brand 7 月之前
父節點
當前提交
8754f03ee6
共有 43 個文件被更改,包括 501 次插入743 次删除
  1. 5 8
      src/headless/plugins/adhoc/api.js
  2. 23 0
      src/headless/plugins/adhoc/types.ts
  3. 2 27
      src/headless/plugins/adhoc/utils.js
  4. 2 32
      src/headless/plugins/mam/api.js
  5. 42 0
      src/headless/plugins/mam/types.ts
  6. 2 20
      src/headless/plugins/mam/utils.js
  7. 2 2
      src/headless/plugins/muc/message.js
  8. 3 3
      src/headless/plugins/muc/muc.js
  9. 4 4
      src/headless/plugins/muc/occupants.js
  10. 3 29
      src/headless/plugins/muc/parsers.js
  11. 30 0
      src/headless/plugins/muc/types.ts
  12. 13 13
      src/headless/shared/api/public.js
  13. 7 65
      src/headless/shared/parsers.js
  14. 4 14
      src/headless/shared/rsm.js
  15. 69 0
      src/headless/shared/types.ts
  16. 8 11
      src/headless/types/plugins/adhoc/api.d.ts
  17. 20 0
      src/headless/types/plugins/adhoc/types.d.ts
  18. 4 41
      src/headless/types/plugins/adhoc/utils.d.ts
  19. 3 31
      src/headless/types/plugins/mam/api.d.ts
  20. 32 0
      src/headless/types/plugins/mam/types.d.ts
  21. 2 23
      src/headless/types/plugins/mam/utils.d.ts
  22. 3 3
      src/headless/types/plugins/muc/message.d.ts
  23. 18 18
      src/headless/types/plugins/muc/muc.d.ts
  24. 4 4
      src/headless/types/plugins/muc/occupants.d.ts
  25. 5 53
      src/headless/types/plugins/muc/parsers.d.ts
  26. 27 0
      src/headless/types/plugins/muc/types.d.ts
  27. 4 67
      src/headless/types/shared/parsers.d.ts
  28. 2 23
      src/headless/types/shared/rsm.d.ts
  29. 51 0
      src/headless/types/shared/types.d.ts
  30. 5 15
      src/plugins/adhoc-views/adhoc-commands.js
  31. 1 1
      src/plugins/adhoc-views/templates/ad-hoc-command-form.js
  32. 2 7
      src/plugins/adhoc-views/templates/ad-hoc-command.js
  33. 11 0
      src/plugins/adhoc-views/types.ts
  34. 3 41
      src/shared/dom-navigator.js
  35. 32 0
      src/shared/types.ts
  36. 7 24
      src/types/plugins/adhoc-views/adhoc-commands.d.ts
  37. 1 1
      src/types/plugins/adhoc-views/templates/ad-hoc-command-form.d.ts
  38. 1 4
      src/types/plugins/adhoc-views/templates/ad-hoc-command.d.ts
  39. 10 0
      src/types/plugins/adhoc-views/types.d.ts
  40. 6 154
      src/types/shared/dom-navigator.d.ts
  41. 25 0
      src/types/shared/types.d.ts
  42. 2 3
      src/types/utils/html.d.ts
  43. 1 2
      src/utils/html.js

+ 5 - 8
src/headless/plugins/adhoc/api.js

@@ -1,7 +1,3 @@
-/**
- * @typedef {import('./utils').AdHocCommand} AdHocCommand
- * @typedef {import('./utils').AdHocCommandResult} AdHocCommandResult
- */
 import log from '../../log.js';
 import _converse from '../../shared/_converse.js';
 import api from '../../shared/api/index.js';
@@ -10,11 +6,12 @@ import { parseCommandResult, parseForCommands } from './utils.js';
 
 const { Strophe, $iq, u, stx } = converse.env;
 
-/**
- * @typedef {'execute'| 'cancel' |'prev'|'next'|'complete'} AdHocCommandAction
- */
 
 export default {
+    /**
+     * @typedef {import('./types').AdHocCommandResult} AdHocCommandResult
+     */
+
     /**
      * The XEP-0050 Ad-Hoc Commands API
      *
@@ -64,7 +61,7 @@ export default {
          * @method api.adhoc.runCommand
          * @param {String} jid
          * @param {String} sessionid
-         * @param {AdHocCommandAction} action
+         * @param {import('./types').AdHocCommandAction} action
          * @param {String} node
          * @param {Array<{ [k:string]: string }>} inputs
          */

+ 23 - 0
src/headless/plugins/adhoc/types.ts

@@ -0,0 +1,23 @@
+import { XForm } from '../../shared/types';
+
+export type AdHocCommand = {
+    action: string;
+    node: string;
+    sessionid: string;
+    status: string;
+}
+
+type AdHocCommandResultNote = {
+    text: string;
+    type: 'info'|'warn'|'error';
+}
+
+export type AdHocCommandAttrs = {
+    sessionid: string;
+    actions?: string[];
+    note?: AdHocCommandResultNote;
+}
+
+export type AdHocCommandResult = XForm & AdHocCommandAttrs;
+
+export type AdHocCommandAction = 'execute'| 'cancel' |'prev'|'next'|'complete';

+ 2 - 27
src/headless/plugins/adhoc/utils.js

@@ -1,50 +1,25 @@
-/**
- * @typedef {import('lit').TemplateResult} TemplateResult
- * @typedef {import('../../shared/parsers').XForm} XForm
- */
 import sizzle from 'sizzle';
 import converse from '../../shared/api/public.js';
 import { parseXForm } from '../../shared/parsers.js';
 
 const { Strophe, u } = converse.env;
 
-/**
- * @typedef {Object} AdHocCommand
- * @property {string} action
- * @property {string} node
- * @property {string} sessionid
- * @property {string} status
- */
-
 /**
  * Given a "result" IQ stanza that contains a list of ad-hoc commands, parse it
  * and return the list of commands as JSON objects.
  * @param {Element} stanza
- * @returns {AdHocCommand[]}
+ * @returns {import('./types').AdHocCommand[]}
  */
 export function parseForCommands(stanza) {
     const items = sizzle(`query[xmlns="${Strophe.NS.DISCO_ITEMS}"][node="${Strophe.NS.ADHOC}"] item`, stanza);
     return items.map(u.getAttributes);
 }
 
-/**
- * @typedef {Object} AdHocCommandResultNote
- * @property {string} text
- * @property {'info'|'warn'|'error'} type
- *
- * @typedef {Object} AdHocCommandAttrs
- * @property {string} sessionid
- * @property {string[]} [actions]
- * @property {AdHocCommandResultNote} [note]
- *
- * @typedef {XForm & AdHocCommandAttrs} AdHocCommandResult
- */
-
 /**
  * Given a "result" IQ stanza containing the outcome of an Ad-hoc command that
  * was executed, parse it and return the values as a JSON object.
  * @param {Element} iq
- * @returns {AdHocCommandResult}
+ * @returns {import('./types').AdHocCommandResult}
  */
 export function parseCommandResult(iq) {
     const cmd_el = sizzle(`command[xmlns="${Strophe.NS.ADHOC}"]`, iq).pop();

+ 2 - 32
src/headless/plugins/mam/api.js

@@ -1,6 +1,3 @@
-/**
- * @typedef {module:converse-rsm.RSMQueryParameters} RSMQueryParameters
- */
 import _converse from '../../shared/_converse.js';
 import api from '../../shared/api/index.js';
 import converse from '../../shared/api/public.js';
@@ -29,23 +26,6 @@ export default {
      * @memberOf _converse.api
      */
     archive: {
-         /**
-          * @typedef {RSMQueryParameters} MAMFilterParameters
-          * Filter parmeters which can be used to filter a MAM XEP-0313 archive
-          * @property String} [end] - A date string in ISO-8601 format, before which messages should be returned. Implies backward paging.
-          * @property {String} [start] - A date string in ISO-8601 format, after which messages should be returned. Implies forward paging.
-          * @property {String} [with] - A JID against which to match messages, according to either their `to` or `from` attributes.
-          *     An item in a MUC archive matches if the publisher of the item matches the JID.
-          *     If `with` is omitted, all messages that match the rest of the query will be returned, regardless of to/from
-          *     addresses of each message.
-          */
-
-         /**
-          * The options that can be passed in to the {@link _converse.api.archive.query } method
-          * @typedef {MAMFilterParameters} ArchiveQueryOptions
-          * @property {boolean} [groupchat=false] - Whether the MAM archive is for a groupchat.
-          */
-
          /**
           * Query for archived messages.
           *
@@ -53,9 +33,9 @@ export default {
           * RSM to enable easy querying between results pages.
           *
           * @method _converse.api.archive.query
-          * @param {ArchiveQueryOptions} options - An object containing query parameters
+          * @param {import('./types').ArchiveQueryOptions} options - An object containing query parameters
           * @throws {Error} An error is thrown if the XMPP server responds with an error.
-          * @returns {Promise<MAMQueryResult>} A promise which resolves to a {@link MAMQueryResult} object.
+          * @returns {Promise<import('./types').MAMQueryResult>}
           *
           * @example
           * // Requesting all archived messages
@@ -299,16 +279,6 @@ export default {
             if (set) {
                 rsm = new RSM({...options, 'xml': set});
             }
-            /**
-             * @typedef {Object} MAMQueryResult
-             * @property {Array} messages
-             * @property {RSM} [rsm] - An instance of {@link RSM}.
-             *  You can call `next()` or `previous()` on this instance,
-             *  to get the RSM query parameters for the next or previous
-             *  page in the result set.
-             * @property {boolean} [complete]
-             * @property {Error} [error]
-             */
             return { messages, rsm, complete };
         }
     }

+ 42 - 0
src/headless/plugins/mam/types.ts

@@ -0,0 +1,42 @@
+import { RSM } from '../../shared/rsm';
+
+export type MAMOptions = {
+    max?: number; // The maximum number of items to return. Defaults to "archived_messages_page_size"
+    after?: string; // The XEP-0359 stanza ID of a message after which messages should be returned. Implies forward paging.
+    before?: string; // The XEP-0359 stanza ID of a message before which messages should be returned. Implies backward paging.
+    end?: string; // A date string in ISO-8601 format, before which messages should be returned. Implies backward paging.
+    start?: string; // A date string in ISO-8601 format, after which messages should be returned. Implies forward paging.
+    with?: string; // The JID of the entity with which messages were exchanged.
+    groupchat?: boolean; // True if archive in groupchat.
+};
+
+// XEP-0059 RSM Attributes that can be used to filter query results
+type RSMQueryParameters = {
+    after?: string; // The XEP-0359 stanza ID of a message after which messages should be returned. Implies forward paging.
+    before?: string; // The XEP-0359 stanza ID of a message before which messages should be returned. Implies backward paging.
+    index?: number; // The index of the results page to return.
+    max?: number; // The maximum number of items to return.
+};
+
+// Filter parmeters which can be used to filter a MAM XEP-0313 archive
+export type MAMFilterParameters = RSMQueryParameters & {
+    end?: string; // A date string in ISO-8601 format, before which messages should be returned. Implies backward paging.
+    start?: string; // A date string in ISO-8601 format, after which messages should be returned. Implies forward paging.
+    with?: string; // A JID against which to match messages, according to either their `to` or `from` attributes.
+    // An item in a MUC archive matches if the publisher of the item matches the JID.
+    // If `with` is omitted, all messages that match the rest of the query will be returned, regardless of to/from
+    // addresses of each message.
+};
+
+// The options that can be passed in to the api.archive.query method
+export type ArchiveQueryOptions = MAMFilterParameters & {
+    groupchat?: boolean; // Whether the MAM archive is for a groupchat.
+};
+
+export type MAMQueryResult = {
+    messages: any[];
+    rsm?: RSM; // You can call `next()` or `previous()` on this,
+    // to get the RSM query parameters for the next or previous page in the result set.
+    complete?: boolean;
+    error?: Error;
+};

+ 2 - 20
src/headless/plugins/mam/utils.js

@@ -138,28 +138,10 @@ export async function handleMAMResult(model, result, query, options, should_page
     }
 }
 
-/**
- * @typedef {Object} MAMOptions
- * A map of MAM related options that may be passed to fetchArchivedMessages
- * @param {number} [options.max] - The maximum number of items to return.
- *  Defaults to "archived_messages_page_size"
- * @param {string} [options.after] - The XEP-0359 stanza ID of a message
- *  after which messages should be returned. Implies forward paging.
- * @param {string} [options.before] - The XEP-0359 stanza ID of a message
- *  before which messages should be returned. Implies backward paging.
- * @param {string} [options.end] - A date string in ISO-8601 format,
- *  before which messages should be returned. Implies backward paging.
- * @param {string} [options.start] - A date string in ISO-8601 format,
- *  after which messages should be returned. Implies forward paging.
- * @param {string} [options.with] - The JID of the entity with
- *  which messages were exchanged.
- * @param {boolean} [options.groupchat] - True if archive in groupchat.
- */
-
 /**
  * Fetch XEP-0313 archived messages based on the passed in criteria.
  * @param {ChatBox|MUC} model
- * @param {MAMOptions} [options]
+ * @param {import('./types').MAMOptions} [options]
  * @param {('forwards'|'backwards'|null)} [should_page=null] - Determines whether
  *  this function should recursively page through the entire result set if a limited
  *  number of results were returned.
@@ -205,7 +187,7 @@ export async function fetchArchivedMessages(model, options = {}, should_page = n
 /**
  * Create a placeholder message which is used to indicate gaps in the history.
  * @param {ChatBox|MUC} model
- * @param {MAMOptions} options
+ * @param {import('./types').MAMOptions} options
  * @param {object} result - The RSM result object
  */
 async function createPlaceholder(model, options, result) {

+ 2 - 2
src/headless/plugins/muc/message.js

@@ -6,7 +6,7 @@ import api from '../../shared/api/index.js';
 
 class MUCMessage extends Message {
     /**
-     * @typedef {import('plugins/vcard/utils.js').MUCOccupant} MUCOccupant
+     * @typedef {import('./occupant').default} MUCOccupant
      */
     async initialize () { // eslint-disable-line require-await
         if (!this.checkValidity()) return;
@@ -85,7 +85,7 @@ class MUCMessage extends Message {
     }
 
     /**
-     * @param {import('plugins/vcard/utils.js').MUCOccupant} [occupant]
+     * @param {MUCOccupant} [occupant]
      * @return {MUCOccupant}
      */
     setOccupant (occupant) {

+ 3 - 3
src/headless/plugins/muc/muc.js

@@ -47,9 +47,9 @@ class MUC extends ModelWithMessages(ColorAwareModel(ChatBoxBase)) {
      * @typedef {import('./message.js').default} MUCMessage
      * @typedef {import('./occupant.js').default} MUCOccupant
      * @typedef {import('./affiliations/utils.js').NonOutcastAffiliation} NonOutcastAffiliation
-     * @typedef {import('./parsers').MemberListItem} MemberListItem
-     * @typedef {import('../chat/types.ts').MessageAttributes} MessageAttributes
-     * @typedef {import('./types.ts').MUCMessageAttributes} MUCMessageAttributes
+     * @typedef {import('./types').MemberListItem} MemberListItem
+     * @typedef {import('../chat/types').MessageAttributes} MessageAttributes
+     * @typedef {import('./types').MUCMessageAttributes} MUCMessageAttributes
      * @typedef {module:shared.converse.UserMessage} UserMessage
      * @typedef {import('strophe.js').Builder} Builder
      * @typedef {import('../../shared/parsers').StanzaParseError} StanzaParseError

+ 4 - 4
src/headless/plugins/muc/occupants.js

@@ -126,10 +126,10 @@ class MUCOccupants extends Collection {
     }
 
     /**
-     * @typedef { Object} OccupantData
-     * @property { String } [jid]
-     * @property { String } [nick]
-     * @property { String } [occupant_id] - The XEP-0421 unique occupant id
+     * @typedef {Object} OccupantData
+     * @property {String} [jid]
+     * @property {String} [nick]
+     * @property {String} [occupant_id] - The XEP-0421 unique occupant id
      */
     /**
      * Try to find an existing occupant based on the provided

+ 3 - 29
src/headless/plugins/muc/parsers.js

@@ -1,7 +1,7 @@
 /**
  * @module:plugin-muc-parsers
  * @typedef {import('../muc/muc.js').default} MUC
- * @typedef {import('./types.ts').MUCMessageAttributes} MUCMessageAttributes
+ * @typedef {import('./types').MUCMessageAttributes} MUCMessageAttributes
  */
 import dayjs from 'dayjs';
 import _converse from '../../shared/_converse.js';
@@ -250,15 +250,8 @@ export async function parseMUCMessage (stanza, chatbox) {
  * Given an IQ stanza with a member list, create an array of objects containing
  * known member data (e.g. jid, nick, role, affiliation).
  *
- * @typedef {Object} MemberListItem
- * Either the JID or the nickname (or both) will be available.
- * @property {string} affiliation
- * @property {string} [role]
- * @property {string} [jid]
- * @property {string} [nick]
- *
  * @param {Element} iq
- * @returns {MemberListItem[]}
+ * @returns {import('./types').MemberListItem[]}
  */
 export function parseMemberListIQ (iq) {
     return sizzle(`query[xmlns="${Strophe.NS.MUC_ADMIN}"] item`, iq).map(
@@ -289,30 +282,11 @@ export function parseMemberListIQ (iq) {
 
 /**
  * Parses a passed in MUC presence stanza and returns an object of attributes.
- * @method parseMUCPresence
  * @param {Element} stanza - The presence stanza
  * @param {MUC} chatbox
- * @returns {MUCPresenceAttributes}
+ * @returns {import('./types').MUCPresenceAttributes}
  */
 export function parseMUCPresence (stanza, chatbox) {
-    /**
-     * Object representing a XEP-0371 Hat
-     * @typedef {Object} MUCHat
-     * @property {string} title
-     * @property {string} uri
-     *
-     * The object which {@link parseMUCPresence} returns
-     * @typedef {Object} MUCPresenceAttributes
-     * @property {string} show
-     * @property {Array<MUCHat>} hats - An array of XEP-0317 hats
-     * @property {Array<string>} states
-     * @property {String} from - The sender JID (${muc_jid}/${nick})
-     * @property {String} nick - The nickname of the sender
-     * @property {String} occupant_id - The XEP-0421 occupant ID
-     * @property {String} type - The type of presence
-     * @property {String} [jid]
-     * @property {boolean} [is_me]
-     */
     const from = stanza.getAttribute('from');
     const type = stanza.getAttribute('type');
     const data = {

+ 30 - 0
src/headless/plugins/muc/types.ts

@@ -12,3 +12,33 @@ type ExtraMUCAttributes = {
 };
 
 export type MUCMessageAttributes = MessageAttributes & ExtraMUCAttributes;
+
+/**
+ * Either the JID or the nickname (or both) will be available.
+ */
+export type MemberListItem = {
+    affiliation: string;
+    role?: string;
+    jid?: string;
+    nick?: string;
+};
+
+/**
+ * Object representing a XEP-0371 Hat
+ */
+export type MUCHat = {
+    title: string;
+    uri: string;
+};
+
+export type MUCPresenceAttributes = {
+    show: string;
+    hats: Array<MUCHat>; // An array of XEP-0317 hats
+    states: Array<string>;
+    from: string; // The sender JID (${muc_jid}/${nick})
+    nick: string; // The nickname of the sender
+    occupant_id: string; // The XEP-0421 occupant ID
+    type: string; // The type of presence
+    jid?: string;
+    is_me?: boolean;
+};

+ 13 - 13
src/headless/shared/api/public.js

@@ -166,19 +166,19 @@ const converse = Object.assign(/** @type {ConversePrivateGlobal} */(window).conv
     /**
      * Utility methods and globals from bundled 3rd party libraries.
      * @typedef ConverseEnv
-     * @property { Error } converse.env.TimeoutError
-     * @property { function } converse.env.$build    - Creates a Strophe.Builder, for creating stanza objects.
-     * @property { function } converse.env.$iq       - Creates a Strophe.Builder with an <iq/> element as the root.
-     * @property { function } converse.env.$msg      - Creates a Strophe.Builder with an <message/> element as the root.
-     * @property { function } converse.env.$pres     - Creates a Strophe.Builder with an <presence/> element as the root.
-     * @property { function } converse.env.Promise   - The Promise implementation used by Converse.
-     * @property { function } converse.env.Strophe   - The [Strophe](http://strophe.im/strophejs) XMPP library used by Converse.
-     * @property { function } converse.env.f         - And instance of Lodash with its methods wrapped to produce immutable auto-curried iteratee-first data-last methods.
-     * @property { function } converse.env.sizzle    - [Sizzle](https://sizzlejs.com) CSS selector engine.
-     * @property { function } converse.env.sprintf
-     * @property { object } converse.env._           - The instance of [lodash-es](http://lodash.com) used by Converse.
-     * @property { object } converse.env.dayjs       - [DayJS](https://github.com/iamkun/dayjs) date manipulation library.
-     * @property { object } converse.env.utils       - Module containing common utility methods used by Converse.
+     * @property {Error} converse.env.TimeoutError
+     * @property {function} converse.env.$build    - Creates a Strophe.Builder, for creating stanza objects.
+     * @property {function} converse.env.$iq       - Creates a Strophe.Builder with an <iq/> element as the root.
+     * @property {function} converse.env.$msg      - Creates a Strophe.Builder with an <message/> element as the root.
+     * @property {function} converse.env.$pres     - Creates a Strophe.Builder with an <presence/> element as the root.
+     * @property {function} converse.env.Promise   - The Promise implementation used by Converse.
+     * @property {function} converse.env.Strophe   - The [Strophe](http://strophe.im/strophejs) XMPP library used by Converse.
+     * @property {function} converse.env.f         - And instance of Lodash with its methods wrapped to produce immutable auto-curried iteratee-first data-last methods.
+     * @property {function} converse.env.sizzle    - [Sizzle](https://sizzlejs.com) CSS selector engine.
+     * @property {function} converse.env.sprintf
+     * @property {object} converse.env._           - The instance of [lodash-es](http://lodash.com) used by Converse.
+     * @property {object} converse.env.dayjs       - [DayJS](https://github.com/iamkun/dayjs) date manipulation library.
+     * @property {object} converse.env.utils       - Module containing common utility methods used by Converse.
      * @memberOf converse
      */
     'env': {

+ 7 - 65
src/headless/shared/parsers.js

@@ -208,20 +208,10 @@ export function getErrorAttributes (stanza) {
     return {};
 }
 
-/**
- * @typedef {Object} Reference
- * An object representing XEP-0372 reference data
- * @property {number} begin
- * @property {number} end
- * @property {string} type
- * @property {String} value
- * @property {String} uri
- */
-
 /**
  * Given a message stanza, find and return any XEP-0372 references
  * @param {Element} stanza - The message stanza
- * @returns {Reference[]}
+ * @returns {import('./types').XEP372Reference[]}
  */
 export function getReferences (stanza) {
     return sizzle(`reference[xmlns="${Strophe.NS.REFERENCE}"]`, stanza).map(ref => {
@@ -369,59 +359,11 @@ export function isArchived (original_stanza) {
     return !!sizzle(`message > result[xmlns="${Strophe.NS.MAM}"]`, original_stanza).pop();
 }
 
-/**
- * @typedef {Object} XFormReportedField
- * @property {string} var
- * @property {string} label
- *
- * @typedef {Object} XFormResultItemField
- * @property {string} var
- * @property {string} value
- *
- * @typedef {Object} XFormOption
- * @property {string} value
- * @property {string} label
- * @property {boolean} selected
- * @property {boolean} required
- *
- * @typedef {Object} XFormCaptchaURI
- * @property {string} type
- * @property {string} data
- *
- * @typedef {'list-single'|'list-multi'} XFormListTypes
- * @typedef {'jid-single'|'jid-multi'} XFormJIDTypes
- * @typedef {'text-multi'|'text-private'|'text-single'} XFormTextTypes
- * @typedef {'date'|'datetime'} XFormDateTypes
- * @typedef {XFormListTypes|XFormJIDTypes|XFormTextTypes|XFormDateTypes|'fixed'|'boolean'|'url'|'hidden'} XFormFieldTypes
- *
- * @typedef {Object} XFormField
- * @property {string} var
- * @property {string} label
- * @property {XFormFieldTypes} [type]
- * @property {string} [text]
- * @property {string} [value]
- * @property {boolean} [required]
- * @property {boolean} [checked]
- * @property {XFormOption[]} [options]
- * @property {XFormCaptchaURI} [uri]
- * @property {boolean} readonly
- *
- * @typedef {'result'|'form'} XFormResponseType
- *
- * @typedef {Object} XForm
- * @property {XFormResponseType} type
- * @property {string} [title]
- * @property {string} [instructions]
- * @property {XFormReportedField[]} [reported]
- * @property {XFormResultItemField[][]} [items]
- * @property {XFormField[]} [fields]
- */
-
 /**
  * @param {Element} field
  * @param {boolean} readonly
  * @param {Element} stanza
- * @return {XFormField}
+ * @return {import('./types').XFormField}
  */
 function parseXFormField(field, readonly, stanza) {
     const v = field.getAttribute('var');
@@ -539,7 +481,7 @@ export function getInputType(field) {
 
 /**
 * @param {Element} stanza
-* @returns {XForm}
+* @returns {import('./types').XForm}
 */
 export function parseXForm(stanza) {
     const xs = sizzle(`x[xmlns="${Strophe.NS.XFORM}"]`, stanza);
@@ -551,7 +493,7 @@ export function parseXForm(stanza) {
     }
 
     const x = xs[0];
-    const type = /** @type {XFormResponseType} */ (x.getAttribute('type'));
+    const type = /** @type {import('./types').XFormResponseType} */ (x.getAttribute('type'));
     const result = {
         type,
         title: x.querySelector('title')?.textContent,
@@ -562,12 +504,12 @@ export function parseXForm(stanza) {
         if (reported) {
             const reported_fields = reported ? Array.from(reported.querySelectorAll(':scope > field')) : [];
             const items = Array.from(x.querySelectorAll(':scope > item'));
-            return /** @type {XForm} */({
+            return /** @type {import('./types').XForm} */({
                 ...result,
-                reported: /** @type {XFormReportedField[]} */ (reported_fields.map(getAttributes)),
+                reported: /** @type {import('./types').XFormReportedField[]} */ (reported_fields.map(getAttributes)),
                 items: items.map((item) => {
                     return Array.from(item.querySelectorAll('field')).map((field) => {
-                        return /** @type {XFormResultItemField} */ ({
+                        return /** @type {import('./types').XFormResultItemField} */ ({
                             ...getAttributes(field),
                             value: field.querySelector('value')?.textContent ?? '',
                         });

+ 4 - 14
src/headless/shared/rsm.js

@@ -13,20 +13,10 @@ const { Strophe, $build } = converse.env;
 
 Strophe.addNamespace('RSM', 'http://jabber.org/protocol/rsm');
 
-
-/**
- * @typedef {Object} RSMQueryParameters
- * [XEP-0059 RSM](https://xmpp.org/extensions/xep-0059.html) Attributes that can be used to filter query results
- * @property {String} [after] - The XEP-0359 stanza ID of a message after which messages should be returned. Implies forward paging.
- * @property {String} [before] - The XEP-0359 stanza ID of a message before which messages should be returned. Implies backward paging.
- * @property {number} [index=0] - The index of the results page to return.
- * @property {number} [max] - The maximum number of items to return.
- */
-
 const RSM_QUERY_PARAMETERS = ['after', 'before', 'index', 'max'];
 
-const toNumber = v => Number(v);
-const toString = v => v.toString();
+const toNumber = (v) => Number(v);
+const toString = (v) => v.toString();
 
 export const RSM_TYPES = {
     'after': toString,
@@ -82,9 +72,9 @@ export class RSM {
 
     /**
      * Returns a `<set>` XML element that confirms to XEP-0059 Result Set Management.
-     * The element is constructed based on the {@link module:converse-rsm~RSMQueryParameters}
+     * The element is constructed based on the RSMQueryParameters
      * that are set on this RSM instance.
-     * @returns { Element }
+     * @returns {Element}
      */
     toXML () {
         const xml = $build('set', {xmlns: Strophe.NS.RSM});

+ 69 - 0
src/headless/shared/types.ts

@@ -18,3 +18,72 @@ export type EncryptionAttrs = {
     is_encrypted: boolean;
     encryption_namespace: string;
 };
+
+export type XFormReportedField = {
+    var: string;
+    label: string;
+};
+
+export type XFormResultItemField = {
+    var: string;
+    value: string;
+};
+
+export type XFormOption = {
+    value: string;
+    label: string;
+    selected: boolean;
+    required: boolean;
+};
+
+export type XFormCaptchaURI = {
+    type: string;
+    data: string;
+};
+
+type XFormListTypes = 'list-single' | 'list-multi';
+type XFormJIDTypes = 'jid-single' | 'jid-multi';
+type XFormTextTypes = 'text-multi' | 'text-private' | 'text-single';
+type XFormDateTypes = 'date' | 'datetime';
+type XFormFieldTypes =
+    | XFormListTypes
+    | XFormJIDTypes
+    | XFormTextTypes
+    | XFormDateTypes
+    | 'fixed'
+    | 'boolean'
+    | 'url'
+    | 'hidden';
+
+export type XFormField = {
+    var: string;
+    label: string;
+    type?: XFormFieldTypes;
+    text?: string;
+    value?: string;
+    required?: boolean;
+    checked?: boolean;
+    options?: XFormOption[];
+    uri?: XFormCaptchaURI;
+    readonly: boolean;
+};
+
+export type XFormResponseType = 'result' | 'form';
+
+export type XForm = {
+    type: XFormResponseType;
+    title?: string;
+    instructions?: string;
+    reported?: XFormReportedField[];
+    items?: XFormResultItemField[][];
+    fields?: XFormField[];
+};
+
+// An object representing XEP-0372 reference data
+export type XEP372Reference = {
+    begin: number;
+    end: number;
+    type: string;
+    value: string;
+    uri: string;
+};

+ 8 - 11
src/headless/types/plugins/adhoc/api.d.ts

@@ -4,32 +4,32 @@ declare namespace _default {
          * @method api.adhoc.getCommands
          * @param {string} to_jid
          */
-        function getCommands(to_jid: string): Promise<import("./utils.js").AdHocCommand[]>;
+        function getCommands(to_jid: string): Promise<import("./types").AdHocCommand[]>;
         /**
          * @method api.adhoc.fetchCommandForm
          * @param {string} jid
          * @param {string} node
          * @returns {Promise<AdHocCommandResult>}
          */
-        function fetchCommandForm(jid: string, node: string): Promise<AdHocCommandResult>;
+        function fetchCommandForm(jid: string, node: string): Promise<import("./types").AdHocCommandResult>;
         /**
          * @method api.adhoc.runCommand
          * @param {String} jid
          * @param {String} sessionid
-         * @param {AdHocCommandAction} action
+         * @param {import('./types').AdHocCommandAction} action
          * @param {String} node
          * @param {Array<{ [k:string]: string }>} inputs
          */
-        function runCommand(jid: string, sessionid: string, node: string, action: AdHocCommandAction, inputs: Array<{
+        function runCommand(jid: string, sessionid: string, node: string, action: import("./types").AdHocCommandAction, inputs: Array<{
             [k: string]: string;
         }>): Promise<{
             note: any;
-            type?: import("../../shared/parsers.js").XFormResponseType;
+            type?: import("../../shared/types.js").XFormResponseType;
             title?: string;
             instructions?: string;
-            reported?: import("../../shared/parsers.js").XFormReportedField[];
-            items?: import("../../shared/parsers.js").XFormResultItemField[][];
-            fields?: import("../../shared/parsers.js").XFormField[];
+            reported?: import("../../shared/types.js").XFormReportedField[];
+            items?: import("../../shared/types.js").XFormResultItemField[][];
+            fields?: import("../../shared/types.js").XFormField[];
             sessionid?: string;
             actions?: string[];
             status: any;
@@ -37,7 +37,4 @@ declare namespace _default {
     }
 }
 export default _default;
-export type AdHocCommand = import("./utils").AdHocCommand;
-export type AdHocCommandResult = import("./utils").AdHocCommandResult;
-export type AdHocCommandAction = "execute" | "cancel" | "prev" | "next" | "complete";
 //# sourceMappingURL=api.d.ts.map

+ 20 - 0
src/headless/types/plugins/adhoc/types.d.ts

@@ -0,0 +1,20 @@
+import { XForm } from '../../shared/types';
+export type AdHocCommand = {
+    action: string;
+    node: string;
+    sessionid: string;
+    status: string;
+};
+type AdHocCommandResultNote = {
+    text: string;
+    type: 'info' | 'warn' | 'error';
+};
+export type AdHocCommandAttrs = {
+    sessionid: string;
+    actions?: string[];
+    note?: AdHocCommandResultNote;
+};
+export type AdHocCommandResult = XForm & AdHocCommandAttrs;
+export type AdHocCommandAction = 'execute' | 'cancel' | 'prev' | 'next' | 'complete';
+export {};
+//# sourceMappingURL=types.d.ts.map

+ 4 - 41
src/headless/types/plugins/adhoc/utils.d.ts

@@ -1,52 +1,15 @@
-/**
- * @typedef {Object} AdHocCommand
- * @property {string} action
- * @property {string} node
- * @property {string} sessionid
- * @property {string} status
- */
 /**
  * Given a "result" IQ stanza that contains a list of ad-hoc commands, parse it
  * and return the list of commands as JSON objects.
  * @param {Element} stanza
- * @returns {AdHocCommand[]}
- */
-export function parseForCommands(stanza: Element): AdHocCommand[];
-/**
- * @typedef {Object} AdHocCommandResultNote
- * @property {string} text
- * @property {'info'|'warn'|'error'} type
- *
- * @typedef {Object} AdHocCommandAttrs
- * @property {string} sessionid
- * @property {string[]} [actions]
- * @property {AdHocCommandResultNote} [note]
- *
- * @typedef {XForm & AdHocCommandAttrs} AdHocCommandResult
+ * @returns {import('./types').AdHocCommand[]}
  */
+export function parseForCommands(stanza: Element): import("./types").AdHocCommand[];
 /**
  * Given a "result" IQ stanza containing the outcome of an Ad-hoc command that
  * was executed, parse it and return the values as a JSON object.
  * @param {Element} iq
- * @returns {AdHocCommandResult}
+ * @returns {import('./types').AdHocCommandResult}
  */
-export function parseCommandResult(iq: Element): AdHocCommandResult;
-export type AdHocCommand = {
-    action: string;
-    node: string;
-    sessionid: string;
-    status: string;
-};
-export type AdHocCommandResultNote = {
-    text: string;
-    type: "info" | "warn" | "error";
-};
-export type AdHocCommandAttrs = {
-    sessionid: string;
-    actions?: string[];
-    note?: AdHocCommandResultNote;
-};
-export type AdHocCommandResult = XForm & AdHocCommandAttrs;
-export type TemplateResult = import("lit").TemplateResult;
-export type XForm = import("../../shared/parsers").XForm;
+export function parseCommandResult(iq: Element): import("./types").AdHocCommandResult;
 //# sourceMappingURL=utils.d.ts.map

+ 3 - 31
src/headless/types/plugins/mam/api.d.ts

@@ -1,20 +1,5 @@
 declare namespace _default {
     namespace archive {
-        /**
-         * @typedef {RSMQueryParameters} MAMFilterParameters
-         * Filter parmeters which can be used to filter a MAM XEP-0313 archive
-         * @property String} [end] - A date string in ISO-8601 format, before which messages should be returned. Implies backward paging.
-         * @property {String} [start] - A date string in ISO-8601 format, after which messages should be returned. Implies forward paging.
-         * @property {String} [with] - A JID against which to match messages, according to either their `to` or `from` attributes.
-         *     An item in a MUC archive matches if the publisher of the item matches the JID.
-         *     If `with` is omitted, all messages that match the rest of the query will be returned, regardless of to/from
-         *     addresses of each message.
-         */
-        /**
-         * The options that can be passed in to the {@link _converse.api.archive.query } method
-         * @typedef {MAMFilterParameters} ArchiveQueryOptions
-         * @property {boolean} [groupchat=false] - Whether the MAM archive is for a groupchat.
-         */
         /**
          * Query for archived messages.
          *
@@ -22,9 +7,9 @@ declare namespace _default {
          * RSM to enable easy querying between results pages.
          *
          * @method _converse.api.archive.query
-         * @param {ArchiveQueryOptions} options - An object containing query parameters
+         * @param {import('./types').ArchiveQueryOptions} options - An object containing query parameters
          * @throws {Error} An error is thrown if the XMPP server responds with an error.
-         * @returns {Promise<MAMQueryResult>} A promise which resolves to a {@link MAMQueryResult} object.
+         * @returns {Promise<import('./types').MAMQueryResult>}
          *
          * @example
          * // Requesting all archived messages
@@ -169,21 +154,8 @@ declare namespace _default {
          * result.messages.forEach(m => this.showMessage(m));
          *
          */
-        function query(options: any): Promise<{
-            messages: any[];
-            /**
-             * - An instance of {@link RSM}.
-             * You can call `next()` or `previous()` on this instance,
-             * to get the RSM query parameters for the next or previous
-             * page in the result set.
-             */
-            rsm?: RSM;
-            complete?: boolean;
-            error?: Error;
-        }>;
+        function query(options: import("./types").ArchiveQueryOptions): Promise<import("./types").MAMQueryResult>;
     }
 }
 export default _default;
-export type RSMQueryParameters = any;
-import { RSM } from '../../shared/rsm';
 //# sourceMappingURL=api.d.ts.map

+ 32 - 0
src/headless/types/plugins/mam/types.d.ts

@@ -0,0 +1,32 @@
+import { RSM } from '../../shared/rsm';
+export type MAMOptions = {
+    max?: number;
+    after?: string;
+    before?: string;
+    end?: string;
+    start?: string;
+    with?: string;
+    groupchat?: boolean;
+};
+type RSMQueryParameters = {
+    after?: string;
+    before?: string;
+    index?: number;
+    max?: number;
+};
+export type MAMFilterParameters = RSMQueryParameters & {
+    end?: string;
+    start?: string;
+    with?: string;
+};
+export type ArchiveQueryOptions = MAMFilterParameters & {
+    groupchat?: boolean;
+};
+export type MAMQueryResult = {
+    messages: any[];
+    rsm?: RSM;
+    complete?: boolean;
+    error?: Error;
+};
+export {};
+//# sourceMappingURL=types.d.ts.map

+ 2 - 23
src/headless/types/plugins/mam/utils.d.ts

@@ -33,42 +33,21 @@ export function preMUCJoinMAMFetch(muc: MUC): void;
  * @param {('forwards'|'backwards'|null)} [should_page=null]
  */
 export function handleMAMResult(model: ChatBox | MUC, result: any, query: any, options: any, should_page?: ("forwards" | "backwards" | null)): Promise<void>;
-/**
- * @typedef {Object} MAMOptions
- * A map of MAM related options that may be passed to fetchArchivedMessages
- * @param {number} [options.max] - The maximum number of items to return.
- *  Defaults to "archived_messages_page_size"
- * @param {string} [options.after] - The XEP-0359 stanza ID of a message
- *  after which messages should be returned. Implies forward paging.
- * @param {string} [options.before] - The XEP-0359 stanza ID of a message
- *  before which messages should be returned. Implies backward paging.
- * @param {string} [options.end] - A date string in ISO-8601 format,
- *  before which messages should be returned. Implies backward paging.
- * @param {string} [options.start] - A date string in ISO-8601 format,
- *  after which messages should be returned. Implies forward paging.
- * @param {string} [options.with] - The JID of the entity with
- *  which messages were exchanged.
- * @param {boolean} [options.groupchat] - True if archive in groupchat.
- */
 /**
  * Fetch XEP-0313 archived messages based on the passed in criteria.
  * @param {ChatBox|MUC} model
- * @param {MAMOptions} [options]
+ * @param {import('./types').MAMOptions} [options]
  * @param {('forwards'|'backwards'|null)} [should_page=null] - Determines whether
  *  this function should recursively page through the entire result set if a limited
  *  number of results were returned.
  */
-export function fetchArchivedMessages(model: ChatBox | MUC, options?: MAMOptions, should_page?: ("forwards" | "backwards" | null)): Promise<void>;
+export function fetchArchivedMessages(model: ChatBox | MUC, options?: import("./types").MAMOptions, should_page?: ("forwards" | "backwards" | null)): Promise<void>;
 /**
  * Fetches messages that might have been archived *after*
  * the last archived message in our local cache.
  * @param {ChatBox|MUC} model
  */
 export function fetchNewestMessages(model: ChatBox | MUC): void;
-/**
- * A map of MAM related options that may be passed to fetchArchivedMessages
- */
-export type MAMOptions = any;
 export type MUC = import("../muc/muc.js").default;
 export type ChatBox = import("../chat/model.js").default;
 export type Model = import("@converse/skeletor/src/types/helpers.js").Model;

+ 3 - 3
src/headless/types/plugins/muc/message.d.ts

@@ -13,13 +13,13 @@ declare class MUCMessage extends Message {
     /**
      * @param {MUCOccupant} [occupant]
      */
-    onOccupantAdded(occupant?: import("./occupant.js").default): void;
+    onOccupantAdded(occupant?: import("./occupant").default): void;
     getOccupant(): any;
     /**
-     * @param {import('plugins/vcard/utils.js').MUCOccupant} [occupant]
+     * @param {MUCOccupant} [occupant]
      * @return {MUCOccupant}
      */
-    setOccupant(occupant?: import("plugins/vcard/utils.js").MUCOccupant): import("./occupant.js").default;
+    setOccupant(occupant?: import("./occupant").default): import("./occupant").default;
     occupant: any;
 }
 import Message from '../chat/message.js';

+ 18 - 18
src/headless/types/plugins/muc/muc.d.ts

@@ -17,13 +17,13 @@ declare const MUC_base: {
         messages: any;
         fetchMessages(): any;
         afterMessagesFetched(): void;
-        onMessage(attrs_or_error: import("../chat/types.ts").MessageAttributes | Error): Promise<void>;
-        getUpdatedMessageAttributes(message: import("../chat/message.js").default, attrs: import("../chat/types.ts").MessageAttributes): object;
-        updateMessage(message: import("../chat/message.js").default, attrs: import("../chat/types.ts").MessageAttributes): void;
-        handleCorrection(attrs: import("../chat/types.ts").MessageAttributes | import("./types.ts").MUCMessageAttributes): Promise<import("../chat/message.js").default | void>;
-        queueMessage(attrs: import("../chat/types.ts").MessageAttributes): any;
+        onMessage(attrs_or_error: import("../chat/types").MessageAttributes | Error): Promise<void>;
+        getUpdatedMessageAttributes(message: import("../chat/message.js").default, attrs: import("../chat/types").MessageAttributes): object;
+        updateMessage(message: import("../chat/message.js").default, attrs: import("../chat/types").MessageAttributes): void;
+        handleCorrection(attrs: import("../chat/types").MessageAttributes | import("./types").MUCMessageAttributes): Promise<import("../chat/message.js").default | void>;
+        queueMessage(attrs: import("../chat/types").MessageAttributes): any;
         msg_chain: any;
-        getOutgoingMessageAttributes(_attrs?: import("../chat/types.ts").MessageAttributes): Promise<import("../chat/types.ts").MessageAttributes>;
+        getOutgoingMessageAttributes(_attrs?: import("../chat/types").MessageAttributes): Promise<import("../chat/types").MessageAttributes>;
         sendMessage(attrs?: any): Promise<import("../chat/message.js").default>;
         retractOwnMessage(message: import("../chat/message.js").default): void;
         sendFiles(files: File[]): Promise<void>;
@@ -34,7 +34,7 @@ declare const MUC_base: {
         onMessageUploadChanged(message: import("../chat/message.js").default): Promise<void>;
         onScrolledChanged(): void;
         pruneHistoryWhenScrolledDown(): void;
-        shouldShowErrorMessage(attrs: import("../chat/types.ts").MessageAttributes): Promise<boolean>;
+        shouldShowErrorMessage(attrs: import("../chat/types").MessageAttributes): Promise<boolean>;
         clearMessages(): Promise<void>;
         editEarlierMessage(): void;
         editLaterMessage(): any;
@@ -57,8 +57,8 @@ declare const MUC_base: {
         handleErrorMessageStanza(stanza: Element): Promise<void>;
         incrementUnreadMsgsCounter(message: import("../chat/message.js").default): void;
         clearUnreadMsgCounter(): void;
-        handleRetraction(attrs: import("../chat/types.ts").MessageAttributes): Promise<boolean>;
-        handleReceipt(attrs: import("../chat/types.ts").MessageAttributes): boolean;
+        handleRetraction(attrs: import("../chat/types").MessageAttributes): Promise<boolean>;
+        handleReceipt(attrs: import("../chat/types").MessageAttributes): boolean;
         createMessageStanza(message: import("../chat/message.js").default): Promise<any>;
         pruneHistory(): void;
         debouncedPruneHistory: import("lodash").DebouncedFunc<() => void>;
@@ -206,9 +206,9 @@ declare class MUC extends MUC_base {
      * @typedef {import('./message.js').default} MUCMessage
      * @typedef {import('./occupant.js').default} MUCOccupant
      * @typedef {import('./affiliations/utils.js').NonOutcastAffiliation} NonOutcastAffiliation
-     * @typedef {import('./parsers').MemberListItem} MemberListItem
-     * @typedef {import('../chat/types.ts').MessageAttributes} MessageAttributes
-     * @typedef {import('./types.ts').MUCMessageAttributes} MUCMessageAttributes
+     * @typedef {import('./types').MemberListItem} MemberListItem
+     * @typedef {import('../chat/types').MessageAttributes} MessageAttributes
+     * @typedef {import('./types').MUCMessageAttributes} MUCMessageAttributes
      * @typedef {module:shared.converse.UserMessage} UserMessage
      * @typedef {import('strophe.js').Builder} Builder
      * @typedef {import('../../shared/parsers').StanzaParseError} StanzaParseError
@@ -430,7 +430,7 @@ declare class MUC extends MUC_base {
     /**
      * @param {MessageAttributes} [attrs] - A map of attributes to be saved on the message
      */
-    getOutgoingMessageAttributes(attrs?: import("../chat/types.ts").MessageAttributes): Promise<import("../chat/types.ts").MessageAttributes>;
+    getOutgoingMessageAttributes(attrs?: import("../chat/types").MessageAttributes): Promise<import("../chat/types").MessageAttributes>;
     /**
      * Utility method to construct the JID for the current user as occupant of the groupchat.
      * @returns {string} - The groupchat JID with the user's nickname added at the end.
@@ -664,7 +664,7 @@ declare class MUC extends MUC_base {
      * @param {MUCMessageAttributes} attrs
      * @return {object}
      */
-    getUpdatedMessageAttributes(message: import("./message.js").default, attrs: import("./types.ts").MUCMessageAttributes): object;
+    getUpdatedMessageAttributes(message: import("./message.js").default, attrs: import("./types").MUCMessageAttributes): object;
     /**
      * Send a MUC-0410 MUC Self-Ping stanza to room to determine
      * whether we're still joined.
@@ -727,19 +727,19 @@ declare class MUC extends MUC_base {
      * @param {MessageAttributes} attrs
      * @returns {boolean}
      */
-    handleMUCPrivateMessage(attrs: import("../chat/types.ts").MessageAttributes): boolean;
+    handleMUCPrivateMessage(attrs: import("../chat/types").MessageAttributes): boolean;
     /**
      * @param {MessageAttributes} attrs
      * @returns {boolean}
      */
-    handleMetadataFastening(attrs: import("../chat/types.ts").MessageAttributes): boolean;
+    handleMetadataFastening(attrs: import("../chat/types").MessageAttributes): boolean;
     /**
      * Given {@link MessageAttributes} look for XEP-0316 Room Notifications and create info
      * messages for them.
      * @param {MUCMessageAttributes} attrs
      * @returns {boolean}
      */
-    handleMEPNotification(attrs: import("./types.ts").MUCMessageAttributes): boolean;
+    handleMEPNotification(attrs: import("./types").MUCMessageAttributes): boolean;
     /**
      * Returns an already cached message (if it exists) based on the
      * passed in attributes map.
@@ -754,7 +754,7 @@ declare class MUC extends MUC_base {
      * should be called.
      * @param {MUCMessageAttributes|StanzaParseError} attrs_or_error - A promise which resolves to the message attributes.
      */
-    onMessage(attrs_or_error: import("./types.ts").MUCMessageAttributes | import("../../shared/parsers.js").StanzaParseError): Promise<void>;
+    onMessage(attrs_or_error: import("./types").MUCMessageAttributes | import("../../shared/parsers.js").StanzaParseError): Promise<void>;
     /**
      * @param {Element} pres
      */

+ 4 - 4
src/headless/types/plugins/muc/occupants.d.ts

@@ -15,10 +15,10 @@ declare class MUCOccupants extends Collection {
     get model(): typeof MUCOccupant;
     fetchMembers(): Promise<void>;
     /**
-     * @typedef { Object} OccupantData
-     * @property { String } [jid]
-     * @property { String } [nick]
-     * @property { String } [occupant_id] - The XEP-0421 unique occupant id
+     * @typedef {Object} OccupantData
+     * @property {String} [jid]
+     * @property {String} [nick]
+     * @property {String} [occupant_id] - The XEP-0421 unique occupant id
      */
     /**
      * Try to find an existing occupant based on the provided

+ 5 - 53
src/headless/types/plugins/muc/parsers.d.ts

@@ -15,66 +15,18 @@ export function parseMUCMessage(stanza: Element, chatbox: MUC): Promise<MUCMessa
  * Given an IQ stanza with a member list, create an array of objects containing
  * known member data (e.g. jid, nick, role, affiliation).
  *
- * @typedef {Object} MemberListItem
- * Either the JID or the nickname (or both) will be available.
- * @property {string} affiliation
- * @property {string} [role]
- * @property {string} [jid]
- * @property {string} [nick]
- *
  * @param {Element} iq
- * @returns {MemberListItem[]}
+ * @returns {import('./types').MemberListItem[]}
  */
-export function parseMemberListIQ(iq: Element): MemberListItem[];
+export function parseMemberListIQ(iq: Element): import("./types").MemberListItem[];
 /**
  * Parses a passed in MUC presence stanza and returns an object of attributes.
- * @method parseMUCPresence
  * @param {Element} stanza - The presence stanza
  * @param {MUC} chatbox
- * @returns {MUCPresenceAttributes}
- */
-export function parseMUCPresence(stanza: Element, chatbox: MUC): {
-    show: string;
-    /**
-     * - An array of XEP-0317 hats
-     */
-    hats: Array<{
-        title: string;
-        /**
-         * The object which {@link parseMUCPresence} returns
-         */
-        uri: string;
-    }>;
-    states: Array<string>;
-    /**
-     * - The sender JID (${muc_jid}/${nick})
-     */
-    from: string;
-    /**
-     * - The nickname of the sender
-     */
-    nick: string;
-    /**
-     * - The XEP-0421 occupant ID
-     */
-    occupant_id: string;
-    /**
-     * - The type of presence
-     */
-    type: string;
-    jid?: string;
-    is_me?: boolean;
-};
-/**
- * Either the JID or the nickname (or both) will be available.
+ * @returns {import('./types').MUCPresenceAttributes}
  */
-export type MemberListItem = {
-    affiliation: string;
-    role?: string;
-    jid?: string;
-    nick?: string;
-};
+export function parseMUCPresence(stanza: Element, chatbox: MUC): import("./types").MUCPresenceAttributes;
 export type MUC = import("../muc/muc.js").default;
-export type MUCMessageAttributes = import("./types.ts").MUCMessageAttributes;
+export type MUCMessageAttributes = import("./types").MUCMessageAttributes;
 import { StanzaParseError } from '../../shared/parsers';
 //# sourceMappingURL=parsers.d.ts.map

+ 27 - 0
src/headless/types/plugins/muc/types.d.ts

@@ -10,5 +10,32 @@ type ExtraMUCAttributes = {
     occupant_id: string;
 };
 export type MUCMessageAttributes = MessageAttributes & ExtraMUCAttributes;
+/**
+ * Either the JID or the nickname (or both) will be available.
+ */
+export type MemberListItem = {
+    affiliation: string;
+    role?: string;
+    jid?: string;
+    nick?: string;
+};
+/**
+ * Object representing a XEP-0371 Hat
+ */
+export type MUCHat = {
+    title: string;
+    uri: string;
+};
+export type MUCPresenceAttributes = {
+    show: string;
+    hats: Array<MUCHat>;
+    states: Array<string>;
+    from: string;
+    nick: string;
+    occupant_id: string;
+    type: string;
+    jid?: string;
+    is_me?: boolean;
+};
 export {};
 //# sourceMappingURL=types.d.ts.map

+ 4 - 67
src/headless/types/shared/parsers.d.ts

@@ -66,21 +66,12 @@ export function getErrorAttributes(stanza: Element): {
     error_type?: undefined;
     error_condition?: undefined;
 };
-/**
- * @typedef {Object} Reference
- * An object representing XEP-0372 reference data
- * @property {number} begin
- * @property {number} end
- * @property {string} type
- * @property {String} value
- * @property {String} uri
- */
 /**
  * Given a message stanza, find and return any XEP-0372 references
  * @param {Element} stanza - The message stanza
- * @returns {Reference[]}
+ * @returns {import('./types').XEP372Reference[]}
  */
-export function getReferences(stanza: Element): Reference[];
+export function getReferences(stanza: Element): import("./types").XEP372Reference[];
 /**
  * @param {Element} stanza
  */
@@ -142,9 +133,9 @@ export function isArchived(original_stanza: Element): boolean;
 export function getInputType(field: Element): any;
 /**
 * @param {Element} stanza
-* @returns {XForm}
+* @returns {import('./types').XForm}
 */
-export function parseXForm(stanza: Element): XForm;
+export function parseXForm(stanza: Element): import("./types").XForm;
 export class StanzaParseError extends Error {
     /**
      * @param {string} message
@@ -153,58 +144,4 @@ export class StanzaParseError extends Error {
     constructor(message: string, stanza: Element);
     stanza: Element;
 }
-/**
- * An object representing XEP-0372 reference data
- */
-export type Reference = {
-    begin: number;
-    end: number;
-    type: string;
-    value: string;
-    uri: string;
-};
-export type XFormReportedField = {
-    var: string;
-    label: string;
-};
-export type XFormResultItemField = {
-    var: string;
-    value: string;
-};
-export type XFormOption = {
-    value: string;
-    label: string;
-    selected: boolean;
-    required: boolean;
-};
-export type XFormCaptchaURI = {
-    type: string;
-    data: string;
-};
-export type XFormListTypes = "list-single" | "list-multi";
-export type XFormJIDTypes = "jid-single" | "jid-multi";
-export type XFormTextTypes = "text-multi" | "text-private" | "text-single";
-export type XFormDateTypes = "date" | "datetime";
-export type XFormFieldTypes = XFormListTypes | XFormJIDTypes | XFormTextTypes | XFormDateTypes | "fixed" | "boolean" | "url" | "hidden";
-export type XFormField = {
-    var: string;
-    label: string;
-    type?: XFormFieldTypes;
-    text?: string;
-    value?: string;
-    required?: boolean;
-    checked?: boolean;
-    options?: XFormOption[];
-    uri?: XFormCaptchaURI;
-    readonly: boolean;
-};
-export type XFormResponseType = "result" | "form";
-export type XForm = {
-    type: XFormResponseType;
-    title?: string;
-    instructions?: string;
-    reported?: XFormReportedField[];
-    items?: XFormResultItemField[][];
-    fields?: XFormField[];
-};
 //# sourceMappingURL=parsers.d.ts.map

+ 2 - 23
src/headless/types/shared/rsm.d.ts

@@ -27,35 +27,14 @@ export class RSM {
     result: {};
     /**
      * Returns a `<set>` XML element that confirms to XEP-0059 Result Set Management.
-     * The element is constructed based on the {@link module:converse-rsm~RSMQueryParameters}
+     * The element is constructed based on the RSMQueryParameters
      * that are set on this RSM instance.
-     * @returns { Element }
+     * @returns {Element}
      */
     toXML(): Element;
     next(max: any, before: any): RSM;
     previous(max: any, after: any): RSM;
 }
-/**
- * [XEP-0059 RSM](https://xmpp.org/extensions/xep-0059.html) Attributes that can be used to filter query results
- */
-export type RSMQueryParameters = {
-    /**
-     * - The XEP-0359 stanza ID of a message after which messages should be returned. Implies forward paging.
-     */
-    after?: string;
-    /**
-     * - The XEP-0359 stanza ID of a message before which messages should be returned. Implies backward paging.
-     */
-    before?: string;
-    /**
-     * - The index of the results page to return.
-     */
-    index?: number;
-    /**
-     * - The maximum number of items to return.
-     */
-    max?: number;
-};
 declare function toString(v: any): any;
 declare function toNumber(v: any): number;
 export {};

+ 51 - 0
src/headless/types/shared/types.d.ts

@@ -10,5 +10,56 @@ export type EncryptionAttrs = {
     is_encrypted: boolean;
     encryption_namespace: string;
 };
+export type XFormReportedField = {
+    var: string;
+    label: string;
+};
+export type XFormResultItemField = {
+    var: string;
+    value: string;
+};
+export type XFormOption = {
+    value: string;
+    label: string;
+    selected: boolean;
+    required: boolean;
+};
+export type XFormCaptchaURI = {
+    type: string;
+    data: string;
+};
+type XFormListTypes = 'list-single' | 'list-multi';
+type XFormJIDTypes = 'jid-single' | 'jid-multi';
+type XFormTextTypes = 'text-multi' | 'text-private' | 'text-single';
+type XFormDateTypes = 'date' | 'datetime';
+type XFormFieldTypes = XFormListTypes | XFormJIDTypes | XFormTextTypes | XFormDateTypes | 'fixed' | 'boolean' | 'url' | 'hidden';
+export type XFormField = {
+    var: string;
+    label: string;
+    type?: XFormFieldTypes;
+    text?: string;
+    value?: string;
+    required?: boolean;
+    checked?: boolean;
+    options?: XFormOption[];
+    uri?: XFormCaptchaURI;
+    readonly: boolean;
+};
+export type XFormResponseType = 'result' | 'form';
+export type XForm = {
+    type: XFormResponseType;
+    title?: string;
+    instructions?: string;
+    reported?: XFormReportedField[];
+    items?: XFormResultItemField[][];
+    fields?: XFormField[];
+};
+export type XEP372Reference = {
+    begin: number;
+    end: number;
+    type: string;
+    value: string;
+    uri: string;
+};
 export {};
 //# sourceMappingURL=types.d.ts.map

+ 5 - 15
src/plugins/adhoc-views/adhoc-commands.js

@@ -1,8 +1,3 @@
-/**
- * @typedef {import('@converse/headless/types/plugins/adhoc/utils').AdHocCommand} AdHocCommand
- * @typedef {import('@converse/headless/types/plugins/adhoc/utils').AdHocCommandResult} AdHocCommandResult
- * @typedef {import('@converse/headless/types/plugins/adhoc/api').AdHocCommandAction} AdHocCommandAction
- */
 import { api, converse, log } from '@converse/headless';
 import 'shared/autocomplete/index.js';
 import tplAdhoc from './templates/ad-hoc.js';
@@ -12,18 +7,13 @@ import { getNameAndValue } from 'utils/html.js';
 
 const { Strophe, sizzle } = converse.env;
 
-/**
- * @typedef {Object} UIProps
- * @property {string} instructions
- * @property {string} jid
- * @property {string} [alert]
- * @property {'danger'|'primary'} [alert_type]
- * @property {'cancel'|'complete'|'execute'|'next'|'prev'} name
- *
- * @typedef {AdHocCommand & AdHocCommandResult & UIProps} AdHocCommandUIProps
- */
 
 export default class AdHocCommands extends CustomElement {
+   /**
+    * @typedef {import('@converse/headless/types/plugins/adhoc/types').AdHocCommandAction} AdHocCommandAction
+    * @typedef {import('./types').AdHocCommandUIProps} AdHocCommandUIProps
+    */
+
     static get properties() {
         return {
             alert: { type: String },

+ 1 - 1
src/plugins/adhoc-views/templates/ad-hoc-command-form.js

@@ -1,7 +1,7 @@
 /**
  * @typedef {import('lit').TemplateResult} TemplateResult
  * @typedef {import('../adhoc-commands').default} AdHocCommands
- * @typedef {import('../adhoc-commands').AdHocCommandUIProps} AdHocCommandUIProps
+ * @typedef {import('../types').AdHocCommandUIProps} AdHocCommandUIProps
  */
 import { html } from 'lit';
 import { __ } from 'i18n';

+ 2 - 7
src/plugins/adhoc-views/templates/ad-hoc-command.js

@@ -1,14 +1,9 @@
-/**
- * @typedef {import('@converse/headless/types/plugins/adhoc/utils').AdHocCommand} AdHocCommand
- * @typedef {import('../adhoc-commands').default} AdHocCommands
- * @typedef {import('../adhoc-commands').AdHocCommandUIProps} AdHocCommandUIProps
- */
 import { html } from "lit";
 import tplCommandForm from './ad-hoc-command-form.js';
 
 /**
- * @param {AdHocCommands} el
- * @param {AdHocCommandUIProps} command
+ * @param {import('../adhoc-commands').default} el
+ * @param {import('../types').AdHocCommandUIProps} command
  */
 export default (el, command) => html`
     <li class="room-item list-group-item">

+ 11 - 0
src/plugins/adhoc-views/types.ts

@@ -0,0 +1,11 @@
+import { AdHocCommand, AdHocCommandResult } from '@converse/headless/plugins/adhoc/types';
+
+export type AdHocUIProps = {
+    instructions: string;
+    jid: string;
+    alert?: string;
+    alert_type: 'danger'|'primary';
+    name: 'cancel'|'complete'|'execute'|'next'|'prev';
+}
+
+export type AdHocCommandUIProps = AdHocCommand & AdHocCommandResult & AdHocUIProps;

+ 3 - 41
src/shared/dom-navigator.js

@@ -55,16 +55,6 @@ function absoluteOffsetLeft(el) {
     return offsetLeft;
 }
 
-/**
- * @typedef {Object} DOMNavigatorDirection
- * @property {string} down
- * @property {string} end
- * @property {string} home
- * @property {string} left
- * @property {string} right
- * @property {string} up
- */
-
 /**
  * Adds the ability to navigate the DOM with the arrow keys
  * @class DOMNavigator
@@ -72,7 +62,7 @@ function absoluteOffsetLeft(el) {
 class DOMNavigator {
     /**
      * Directions.
-     * @returns {DOMNavigatorDirection}
+     * @returns {import('./types').DOMNavigatorDirection}
      */
     static get DIRECTION () {
         return ({
@@ -140,45 +130,17 @@ class DOMNavigator {
         return next.element;
     }
 
-    /**
-     * @typedef {Object} DOMNavigatorOptions
-     * @property {Function} DOMNavigatorOptions.getSelector
-     * @property {string[]} [DOMNavigatorOptions.end]
-     * @property {string[]} [DOMNavigatorOptions.home]
-     * @property {number[]} [DOMNavigatorOptions.down] - The keycode for navigating down
-     * @property {number[]} [DOMNavigatorOptions.left] - The keycode for navigating left
-     * @property {number[]} [DOMNavigatorOptions.right] - The keycode for navigating right
-     * @property {number[]} [DOMNavigatorOptions.up] - The keycode for navigating up
-     * @property {String} [DOMNavigatorOptions.selector]
-     * @property {String} [DOMNavigatorOptions.selected] - The class that should be added
-     *  to the currently selected DOM element
-     * @property {String} [DOMNavigatorOptions.jump_to_picked] - A selector, which if
-     *  matched by the next element being navigated to, based on the direction
-     *  given by `jump_to_picked_direction`, will cause navigation
-     *  to jump to the element that matches the `jump_to_picked_selector`.
-     *  For example, this is useful when navigating to tabs. You want to
-     *  immediately navigate to the currently active tab instead of just
-     *  navigating to the first tab.
-     * @property {String} [DOMNavigatorOptions.jump_to_picked_selector=picked] - The selector
-     *  indicating the currently picked element to jump to.
-     * @property {String} [DOMNavigatorOptions.jump_to_picked_direction] - The direction for
-     *  which jumping to the picked element should be enabled.
-     * @property {Function} [DOMNavigatorOptions.onSelected] - The callback function which
-     *  should be called when en element gets selected.
-     * @property {HTMLElement} [DOMNavigatorOptions.scroll_container]
-     */
-
     /**
      * Create a new DOM Navigator.
      * @param {HTMLElement} container The container of the element to navigate.
-     * @param {DOMNavigatorOptions} options The options to configure the DOM navigator.
+     * @param {import('./types').DOMNavigatorOptions} options The options to configure the DOM navigator.
      */
     constructor (container, options) {
         this.doc = window.document;
         this.container = container;
         this.scroll_container = options.scroll_container || container;
 
-        /** @type {DOMNavigatorOptions} */
+        /** @type {import('./types').DOMNavigatorOptions} */
         this.options = Object.assign({}, DOMNavigator.DEFAULTS, options);
 
         this.init();

+ 32 - 0
src/shared/types.ts

@@ -0,0 +1,32 @@
+export type DOMNavigatorOptions = {
+    getSelector: Function;
+    end?: string[];
+    home?: string[];
+    down?: number[]; // The keycode for navigating down
+    left?: number[]; // The keycode for navigating left
+    right?: number[]; // The keycode for navigating right
+    up?: number[]; // The keycode for navigating up
+    selector?: string;
+    selected?: string; // The class that should be added to the currently selected DOM element
+    jump_to_picked?: string; // A selector, which if matched by the next
+    // element being navigated to, based on the direction
+    // given by `jump_to_picked_direction`, will cause navigation
+    // to jump to the element that matches the `jump_to_picked_selector`.
+    // For example, this is useful when navigating to tabs. You want to
+    // immediately navigate to the currently active tab instead of just
+    // navigating to the first tab.
+    jump_to_picked_selector?: string; // The direction for which jumping to the picked element should be enabled.
+    jump_to_picked_direction?: string; // The callback function which should be called when en element gets selected.
+    onSelected?: Function;
+    scroll_container?: HTMLElement;
+};
+
+export type DOMNavigatorDirection = {
+    down: string;
+    end: string;
+    home: string;
+    left: string;
+    right: string;
+    up: string;
+};
+

+ 7 - 24
src/types/plugins/adhoc-views/adhoc-commands.d.ts

@@ -1,14 +1,8 @@
-/**
- * @typedef {Object} UIProps
- * @property {string} instructions
- * @property {string} jid
- * @property {string} [alert]
- * @property {'danger'|'primary'} [alert_type]
- * @property {'cancel'|'complete'|'execute'|'next'|'prev'} name
- *
- * @typedef {AdHocCommand & AdHocCommandResult & UIProps} AdHocCommandUIProps
- */
 export default class AdHocCommands extends CustomElement {
+    /**
+     * @typedef {import('@converse/headless/types/plugins/adhoc/types').AdHocCommandAction} AdHocCommandAction
+     * @typedef {import('./types').AdHocCommandUIProps} AdHocCommandUIProps
+     */
     static get properties(): {
         alert: {
             type: StringConstructor;
@@ -32,7 +26,7 @@ export default class AdHocCommands extends CustomElement {
     view: string;
     fetching: boolean;
     showform: string;
-    commands: AdHocCommandUIProps[];
+    commands: import("./types").AdHocCommandUIProps[];
     render(): import("lit").TemplateResult<1>;
     /**
      * @param {SubmitEvent} ev
@@ -51,28 +45,17 @@ export default class AdHocCommands extends CustomElement {
     /**
      * @param {AdHocCommandUIProps} cmd
      */
-    clearCommand(cmd: AdHocCommandUIProps): void;
+    clearCommand(cmd: import("./types").AdHocCommandUIProps): void;
     /**
      * @param {HTMLFormElement} form
      * @param {AdHocCommandAction} action
      */
-    runCommand(form: HTMLFormElement, action: AdHocCommandAction): Promise<void>;
+    runCommand(form: HTMLFormElement, action: import("@converse/headless/types/plugins/adhoc/types").AdHocCommandAction): Promise<void>;
     note: any;
     /**
      * @param {MouseEvent} ev
      */
     cancel(ev: MouseEvent): Promise<void>;
 }
-export type AdHocCommand = import("@converse/headless/types/plugins/adhoc/utils").AdHocCommand;
-export type AdHocCommandResult = import("@converse/headless/types/plugins/adhoc/utils").AdHocCommandResult;
-export type AdHocCommandAction = import("@converse/headless/types/plugins/adhoc/api").AdHocCommandAction;
-export type UIProps = {
-    instructions: string;
-    jid: string;
-    alert?: string;
-    alert_type?: "danger" | "primary";
-    name: "cancel" | "complete" | "execute" | "next" | "prev";
-};
-export type AdHocCommandUIProps = AdHocCommand & AdHocCommandResult & UIProps;
 import { CustomElement } from 'shared/components/element.js';
 //# sourceMappingURL=adhoc-commands.d.ts.map

+ 1 - 1
src/types/plugins/adhoc-views/templates/ad-hoc-command-form.d.ts

@@ -2,5 +2,5 @@ declare function _default(el: AdHocCommands, command: AdHocCommandUIProps): impo
 export default _default;
 export type TemplateResult = import("lit").TemplateResult;
 export type AdHocCommands = import("../adhoc-commands").default;
-export type AdHocCommandUIProps = import("../adhoc-commands").AdHocCommandUIProps;
+export type AdHocCommandUIProps = import("../types").AdHocCommandUIProps;
 //# sourceMappingURL=ad-hoc-command-form.d.ts.map

+ 1 - 4
src/types/plugins/adhoc-views/templates/ad-hoc-command.d.ts

@@ -1,6 +1,3 @@
-declare function _default(el: AdHocCommands, command: AdHocCommandUIProps): import("lit").TemplateResult<1>;
+declare function _default(el: import("../adhoc-commands").default, command: import("../types").AdHocCommandUIProps): import("lit").TemplateResult<1>;
 export default _default;
-export type AdHocCommand = import("@converse/headless/types/plugins/adhoc/utils").AdHocCommand;
-export type AdHocCommands = import("../adhoc-commands").default;
-export type AdHocCommandUIProps = import("../adhoc-commands").AdHocCommandUIProps;
 //# sourceMappingURL=ad-hoc-command.d.ts.map

+ 10 - 0
src/types/plugins/adhoc-views/types.d.ts

@@ -0,0 +1,10 @@
+import { AdHocCommand, AdHocCommandResult } from '@converse/headless/plugins/adhoc/types';
+export type AdHocUIProps = {
+    instructions: string;
+    jid: string;
+    alert?: string;
+    alert_type: 'danger' | 'primary';
+    name: 'cancel' | 'complete' | 'execute' | 'next' | 'prev';
+};
+export type AdHocCommandUIProps = AdHocCommand & AdHocCommandResult & AdHocUIProps;
+//# sourceMappingURL=types.d.ts.map

+ 6 - 154
src/types/shared/dom-navigator.d.ts

@@ -1,21 +1,4 @@
 export default DOMNavigator;
-export type DOMNavigatorDirection = {
-    down: string;
-    end: string;
-    home: string;
-    left: string;
-    right: string;
-    up: string;
-};
-/**
- * @typedef {Object} DOMNavigatorDirection
- * @property {string} down
- * @property {string} end
- * @property {string} home
- * @property {string} left
- * @property {string} right
- * @property {string} up
- */
 /**
  * Adds the ability to navigate the DOM with the arrow keys
  * @class DOMNavigator
@@ -23,9 +6,9 @@ export type DOMNavigatorDirection = {
 declare class DOMNavigator {
     /**
      * Directions.
-     * @returns {DOMNavigatorDirection}
+     * @returns {import('./types').DOMNavigatorDirection}
      */
-    static get DIRECTION(): DOMNavigatorDirection;
+    static get DIRECTION(): import("./types").DOMNavigatorDirection;
     /**
      * The default options for the DOM navigator.
      * @returns {{
@@ -60,148 +43,17 @@ declare class DOMNavigator {
         up: number[];
     };
     static getClosestElement(els: any, getDistance: any): any;
-    /**
-     * @typedef {Object} DOMNavigatorOptions
-     * @property {Function} DOMNavigatorOptions.getSelector
-     * @property {string[]} [DOMNavigatorOptions.end]
-     * @property {string[]} [DOMNavigatorOptions.home]
-     * @property {number[]} [DOMNavigatorOptions.down] - The keycode for navigating down
-     * @property {number[]} [DOMNavigatorOptions.left] - The keycode for navigating left
-     * @property {number[]} [DOMNavigatorOptions.right] - The keycode for navigating right
-     * @property {number[]} [DOMNavigatorOptions.up] - The keycode for navigating up
-     * @property {String} [DOMNavigatorOptions.selector]
-     * @property {String} [DOMNavigatorOptions.selected] - The class that should be added
-     *  to the currently selected DOM element
-     * @property {String} [DOMNavigatorOptions.jump_to_picked] - A selector, which if
-     *  matched by the next element being navigated to, based on the direction
-     *  given by `jump_to_picked_direction`, will cause navigation
-     *  to jump to the element that matches the `jump_to_picked_selector`.
-     *  For example, this is useful when navigating to tabs. You want to
-     *  immediately navigate to the currently active tab instead of just
-     *  navigating to the first tab.
-     * @property {String} [DOMNavigatorOptions.jump_to_picked_selector=picked] - The selector
-     *  indicating the currently picked element to jump to.
-     * @property {String} [DOMNavigatorOptions.jump_to_picked_direction] - The direction for
-     *  which jumping to the picked element should be enabled.
-     * @property {Function} [DOMNavigatorOptions.onSelected] - The callback function which
-     *  should be called when en element gets selected.
-     * @property {HTMLElement} [DOMNavigatorOptions.scroll_container]
-     */
     /**
      * Create a new DOM Navigator.
      * @param {HTMLElement} container The container of the element to navigate.
-     * @param {DOMNavigatorOptions} options The options to configure the DOM navigator.
+     * @param {import('./types').DOMNavigatorOptions} options The options to configure the DOM navigator.
      */
-    constructor(container: HTMLElement, options: {
-        getSelector: Function;
-        end?: string[];
-        home?: string[];
-        /**
-         * - The keycode for navigating down
-         */
-        down?: number[];
-        /**
-         * - The keycode for navigating left
-         */
-        left?: number[];
-        /**
-         * - The keycode for navigating right
-         */
-        right?: number[];
-        /**
-         * - The keycode for navigating up
-         */
-        up?: number[];
-        selector?: string;
-        /**
-         * - The class that should be added
-         * to the currently selected DOM element
-         */
-        selected?: string;
-        /**
-         * - A selector, which if
-         * matched by the next element being navigated to, based on the direction
-         * given by `jump_to_picked_direction`, will cause navigation
-         * to jump to the element that matches the `jump_to_picked_selector`.
-         * For example, this is useful when navigating to tabs. You want to
-         * immediately navigate to the currently active tab instead of just
-         * navigating to the first tab.
-         */
-        jump_to_picked?: string;
-        /**
-         * - The selector
-         * indicating the currently picked element to jump to.
-         */
-        jump_to_picked_selector?: string;
-        /**
-         * - The direction for
-         * which jumping to the picked element should be enabled.
-         */
-        jump_to_picked_direction?: string;
-        /**
-         * - The callback function which
-         * should be called when en element gets selected.
-         */
-        onSelected?: Function;
-        scroll_container?: HTMLElement;
-    });
+    constructor(container: HTMLElement, options: import("./types").DOMNavigatorOptions);
     doc: Document;
     container: HTMLElement;
     scroll_container: HTMLElement;
-    /** @type {DOMNavigatorOptions} */
-    options: {
-        getSelector: Function;
-        end?: string[];
-        home?: string[];
-        /**
-         * - The keycode for navigating down
-         */
-        down?: number[];
-        /**
-         * - The keycode for navigating left
-         */
-        left?: number[];
-        /**
-         * - The keycode for navigating right
-         */
-        right?: number[];
-        /**
-         * - The keycode for navigating up
-         */
-        up?: number[];
-        selector?: string;
-        /**
-         * - The class that should be added
-         * to the currently selected DOM element
-         */
-        selected?: string;
-        /**
-         * - A selector, which if
-         * matched by the next element being navigated to, based on the direction
-         * given by `jump_to_picked_direction`, will cause navigation
-         * to jump to the element that matches the `jump_to_picked_selector`.
-         * For example, this is useful when navigating to tabs. You want to
-         * immediately navigate to the currently active tab instead of just
-         * navigating to the first tab.
-         */
-        jump_to_picked?: string;
-        /**
-         * - The selector
-         * indicating the currently picked element to jump to.
-         */
-        jump_to_picked_selector?: string;
-        /**
-         * - The direction for
-         * which jumping to the picked element should be enabled.
-         */
-        jump_to_picked_direction?: string;
-        /**
-         * - The callback function which
-         * should be called when en element gets selected.
-         */
-        onSelected?: Function;
-        scroll_container?: HTMLElement;
-    };
+    /** @type {import('./types').DOMNavigatorOptions} */
+    options: import("./types").DOMNavigatorOptions;
     /**
      * Initialize the navigator.
      */

+ 25 - 0
src/types/shared/types.d.ts

@@ -0,0 +1,25 @@
+export type DOMNavigatorOptions = {
+    getSelector: Function;
+    end?: string[];
+    home?: string[];
+    down?: number[];
+    left?: number[];
+    right?: number[];
+    up?: number[];
+    selector?: string;
+    selected?: string;
+    jump_to_picked?: string;
+    jump_to_picked_selector?: string;
+    jump_to_picked_direction?: string;
+    onSelected?: Function;
+    scroll_container?: HTMLElement;
+};
+export type DOMNavigatorDirection = {
+    down: string;
+    end: string;
+    home: string;
+    left: string;
+    right: string;
+    up: string;
+};
+//# sourceMappingURL=types.d.ts.map

+ 2 - 3
src/types/utils/html.d.ts

@@ -67,11 +67,11 @@ export function slideIn(el: HTMLElement, duration?: number): Promise<any>;
 /**
  * Takes an XML field in XMPP XForm (XEP-004: Data Forms) format returns a
  * [TemplateResult](https://lit.polymer-project.org/api/classes/_lit_html_.templateresult.html).
- * @param {XFormField} xfield - the field to convert
+ * @param {import('@converse/headless/shared/types').XFormField} xfield - the field to convert
  * @param {Object} options
  * @returns {TemplateResult}
  */
-export function xFormField2TemplateResult(xfield: XFormField, options?: any): TemplateResult;
+export function xFormField2TemplateResult(xfield: import("@converse/headless/shared/types").XFormField, options?: any): TemplateResult;
 /**
  * @param {HTMLElement} el
  * @param {boolean} include_margin
@@ -79,6 +79,5 @@ export function xFormField2TemplateResult(xfield: XFormField, options?: any): Te
 export function getOuterWidth(el: HTMLElement, include_margin?: boolean): number;
 export default u;
 export type TemplateResult = import("lit").TemplateResult;
-export type XFormField = import("@converse/headless/types/shared/parsers").XFormField;
 import { u } from '@converse/headless';
 //# sourceMappingURL=html.d.ts.map

+ 1 - 2
src/utils/html.js

@@ -3,7 +3,6 @@
  * @license Mozilla Public License (MPLv2)
  * @description This is the DOM/HTML utilities module.
  * @typedef {import('lit').TemplateResult} TemplateResult
- * @typedef {import('@converse/headless/types/shared/parsers').XFormField} XFormField
  */
 import { render } from 'lit';
 import { Builder, Stanza } from 'strophe.js';
@@ -461,7 +460,7 @@ function isVisible (el) {
 /**
  * Takes an XML field in XMPP XForm (XEP-004: Data Forms) format returns a
  * [TemplateResult](https://lit.polymer-project.org/api/classes/_lit_html_.templateresult.html).
- * @param {XFormField} xfield - the field to convert
+ * @param {import('@converse/headless/shared/types').XFormField} xfield - the field to convert
  * @param {Object} options
  * @returns {TemplateResult}
  */