瀏覽代碼

Remove tsc and fix type errors

Bugfix. `u.xForm2TemplateResult` is not defined
JC Brand 1 年之前
父節點
當前提交
62449caf42

+ 39 - 39
package-lock.json

@@ -63,7 +63,6 @@
         "sass": "^1.51.0",
         "sass-loader": "^13.1.0",
         "style-loader": "^3.1.0",
-        "tsc": "^2.0.4",
         "typescript": "^4.9.5",
         "typescript-eslint-parser": "^22.0.0",
         "uglify-js": "^3.17.4",
@@ -1873,9 +1872,9 @@
       }
     },
     "node_modules/@eslint-community/regexpp": {
-      "version": "4.9.1",
-      "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.9.1.tgz",
-      "integrity": "sha512-Y27x+MBLjXa+0JWDhykM3+JE+il3kHKAEqabfEWq3SDhZjLYb6/BHL/JKFnH3fe207JaXkyDo685Oc2Glt6ifA==",
+      "version": "4.10.0",
+      "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.10.0.tgz",
+      "integrity": "sha512-Cu96Sd2By9mCNTx2iyKOmq10v22jUVQv0lQnlGNy16oE9589yE+QADPbrMGCkA51cKZSg3Pu/aTJVTGfL/qjUA==",
       "dev": true,
       "engines": {
         "node": "^12.0.0 || ^14.0.0 || >=16.0.0"
@@ -2313,12 +2312,21 @@
       "dev": true
     },
     "node_modules/@types/node": {
-      "version": "20.8.7",
-      "resolved": "https://registry.npmjs.org/@types/node/-/node-20.8.7.tgz",
-      "integrity": "sha512-21TKHHh3eUHIi2MloeptJWALuCu5H7HQTdTrWIFReA8ad+aggoX+lRes3ex7/FtpC+sVUpFMQ+QTfYr74mruiQ==",
+      "version": "20.8.9",
+      "resolved": "https://registry.npmjs.org/@types/node/-/node-20.8.9.tgz",
+      "integrity": "sha512-UzykFsT3FhHb1h7yD4CA4YhBHq545JC0YnEz41xkipN88eKQtL6rSgocL5tbAP6Ola9Izm/Aw4Ora8He4x0BHg==",
       "devOptional": true,
       "dependencies": {
-        "undici-types": "~5.25.1"
+        "undici-types": "~5.26.4"
+      }
+    },
+    "node_modules/@types/node-forge": {
+      "version": "1.3.8",
+      "resolved": "https://registry.npmjs.org/@types/node-forge/-/node-forge-1.3.8.tgz",
+      "integrity": "sha512-vGXshY9vim9CJjrpcS5raqSjEfKlJcWy2HNdgUasR66fAnVEYarrf1ULV4nfvpC1nZq/moA9qyqBcu83x+Jlrg==",
+      "dev": true,
+      "dependencies": {
+        "@types/node": "*"
       }
     },
     "node_modules/@types/parse-json": {
@@ -2934,9 +2942,9 @@
       }
     },
     "node_modules/acorn": {
-      "version": "8.10.0",
-      "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.10.0.tgz",
-      "integrity": "sha512-F0SAmZ8iUtS//m8DmCTA0jlh6TDKkHQyK6xc6V4KDTyZKA9dnvX9/3sRTVQrWm79glUAZbnmmNcdYwUIHWVybw==",
+      "version": "8.11.2",
+      "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.11.2.tgz",
+      "integrity": "sha512-nc0Axzp/0FILLEVsm4fNwLCwMttvhEI263QtVPQcbpfZZ3ts0hLsZGOpE6czNlid7CJ9MlyH8reXkpsf3YUY4w==",
       "dev": true,
       "bin": {
         "acorn": "bin/acorn"
@@ -3206,13 +3214,13 @@
       }
     },
     "node_modules/babel-plugin-polyfill-corejs3": {
-      "version": "0.8.5",
-      "resolved": "https://registry.npmjs.org/babel-plugin-polyfill-corejs3/-/babel-plugin-polyfill-corejs3-0.8.5.tgz",
-      "integrity": "sha512-Q6CdATeAvbScWPNLB8lzSO7fgUVBkQt6zLgNlfyeCr/EQaEQR+bWiBYYPYAFyE528BMjRhL+1QBMOI4jc/c5TA==",
+      "version": "0.8.6",
+      "resolved": "https://registry.npmjs.org/babel-plugin-polyfill-corejs3/-/babel-plugin-polyfill-corejs3-0.8.6.tgz",
+      "integrity": "sha512-leDIc4l4tUgU7str5BWLS2h8q2N4Nf6lGZP6UrNDxdtfF2g69eJ5L0H7S8A5Ln/arfFAfHor5InAdZuIOwZdgQ==",
       "dev": true,
       "dependencies": {
         "@babel/helper-define-polyfill-provider": "^0.4.3",
-        "core-js-compat": "^3.32.2"
+        "core-js-compat": "^3.33.1"
       },
       "peerDependencies": {
         "@babel/core": "^7.4.0 || ^8.0.0-0 <8.0.0"
@@ -3514,9 +3522,9 @@
       }
     },
     "node_modules/caniuse-lite": {
-      "version": "1.0.30001551",
-      "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001551.tgz",
-      "integrity": "sha512-vtBAez47BoGMMzlbYhfXrMV1kvRF2WP/lqiMuDu1Sb4EE4LKEgjopFDSRtZfdVnslNRpOqV/woE+Xgrwj6VQlg==",
+      "version": "1.0.30001554",
+      "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001554.tgz",
+      "integrity": "sha512-A2E3U//MBwbJVzebddm1YfNp7Nud5Ip+IPn4BozBmn4KqVX7AvluoIDFWjsv5OkGnKUXQVmMSoMKLa3ScCblcQ==",
       "dev": true,
       "funding": [
         {
@@ -4548,9 +4556,9 @@
       "dev": true
     },
     "node_modules/electron-to-chromium": {
-      "version": "1.4.563",
-      "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.563.tgz",
-      "integrity": "sha512-dg5gj5qOgfZNkPNeyKBZQAQitIQ/xwfIDmEQJHCbXaD9ebTZxwJXUsDYcBlAvZGZLi+/354l35J1wkmP6CqYaw==",
+      "version": "1.4.568",
+      "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.568.tgz",
+      "integrity": "sha512-3TCOv8+BY6Ltpt1/CmGBMups2IdKOyfEmz4J8yIS4xLSeMm0Rf+psSaxLuswG9qMKt+XbNbmADybtXGpTFlbDg==",
       "dev": true
     },
     "node_modules/emoji-regex": {
@@ -9483,9 +9491,9 @@
       "dev": true
     },
     "node_modules/sass": {
-      "version": "1.69.4",
-      "resolved": "https://registry.npmjs.org/sass/-/sass-1.69.4.tgz",
-      "integrity": "sha512-+qEreVhqAy8o++aQfCJwp0sklr2xyEzkm9Pp/Igu9wNPoe7EZEQ8X/MBvvXggI2ql607cxKg/RKOwDj6pp2XDA==",
+      "version": "1.69.5",
+      "resolved": "https://registry.npmjs.org/sass/-/sass-1.69.5.tgz",
+      "integrity": "sha512-qg2+UCJibLr2LCVOt3OlPhr/dqVHWOa9XtZf2OjbLs/T4VPSJ00udtgJxH3neXZm+QqX8B+3cU7RaLqp1iVfcQ==",
       "dev": true,
       "dependencies": {
         "chokidar": ">=3.0.0 <4.0.0",
@@ -9602,11 +9610,12 @@
       "dev": true
     },
     "node_modules/selfsigned": {
-      "version": "2.1.1",
-      "resolved": "https://registry.npmjs.org/selfsigned/-/selfsigned-2.1.1.tgz",
-      "integrity": "sha512-GSL3aowiF7wa/WtSFwnUrludWFoNhftq8bUkH9pkzjpN2XSPOAYEgg6e0sS9s0rZwgJzJiQRPU18A6clnoW5wQ==",
+      "version": "2.4.1",
+      "resolved": "https://registry.npmjs.org/selfsigned/-/selfsigned-2.4.1.tgz",
+      "integrity": "sha512-th5B4L2U+eGLq1TVh7zNRGBapioSORUeymIydxgFpwww9d2qyKvtuPU2jJuHvYAwwqi2Y596QBL3eEqcPEYL8Q==",
       "dev": true,
       "dependencies": {
+        "@types/node-forge": "^1.3.0",
         "node-forge": "^1"
       },
       "engines": {
@@ -10336,15 +10345,6 @@
         "url": "https://github.com/sponsors/wooorm"
       }
     },
-    "node_modules/tsc": {
-      "version": "2.0.4",
-      "resolved": "https://registry.npmjs.org/tsc/-/tsc-2.0.4.tgz",
-      "integrity": "sha512-fzoSieZI5KKJVBYGvwbVZs/J5za84f2lSTLPYf6AGiIf43tZ3GNrI1QzTLcjtyDDP4aLxd46RTZq1nQxe7+k5Q==",
-      "dev": true,
-      "bin": {
-        "tsc": "bin/tsc"
-      }
-    },
     "node_modules/tslib": {
       "version": "2.6.2",
       "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz",
@@ -10537,9 +10537,9 @@
       "dev": true
     },
     "node_modules/undici-types": {
-      "version": "5.25.3",
-      "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.25.3.tgz",
-      "integrity": "sha512-Ga1jfYwRn7+cP9v8auvEXN1rX3sWqlayd4HP7OKk4mZWylEmu3KzXDUGrQUN6Ol7qo1gPvB2e5gX6udnyEPgdA==",
+      "version": "5.26.5",
+      "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz",
+      "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==",
       "devOptional": true
     },
     "node_modules/unherit": {

+ 0 - 1
package.json

@@ -103,7 +103,6 @@
     "sass": "^1.51.0",
     "sass-loader": "^13.1.0",
     "style-loader": "^3.1.0",
-    "tsc": "^2.0.4",
     "typescript": "^4.9.5",
     "typescript-eslint-parser": "^22.0.0",
     "uglify-js": "^3.17.4",

+ 9 - 1
src/entry.js

@@ -12,6 +12,9 @@
 //
 // Once the rest converse.js has been loaded, window.converse will be replaced
 // with the full-fledged public API.
+/**
+ * @typedef {module:shared_converse.ConversePrivateGlobal} ConversePrivateGlobal
+ */
 
 const plugins = {};
 
@@ -55,6 +58,8 @@ const converse = {
      */
     load (settings={}) {
         if (settings.assets_path) {
+            // eslint-disable-next-line @typescript-eslint/ban-ts-comment
+            // @ts-ignore
             __webpack_public_path__ = settings.assets_path; // eslint-disable-line no-undef
         }
         require('./index.js');
@@ -63,7 +68,10 @@ const converse = {
     }
 }
 
-window.converse = converse;
+/**
+ * @typedef {Window & {converse: ConversePrivateGlobal} } window
+ */
+window['converse'] = converse;
 
 /**
  * Once Converse.js has loaded, it'll dispatch a custom event with the name `converse-loaded`.

+ 2 - 1
src/headless/plugins/chat/messages.js

@@ -3,7 +3,6 @@ import { Collection } from '@converse/skeletor/src/collection';
 
 class Messages extends Collection {
 
-    // eslint-disable-next-line class-methods-use-this
     get comparator () {
         return 'time';
     }
@@ -11,6 +10,8 @@ class Messages extends Collection {
     constructor () {
         super();
         this.model = Message;
+        this.fetched = null;
+        this.chatbox = null;
     }
 }
 

+ 58 - 54
src/headless/plugins/chat/model.js

@@ -1,9 +1,16 @@
+/**
+ * @typedef {import('./message.js').default} Message
+ * @typedef {import('../muc/muc.js').default} MUC
+ * @typedef {import('../muc/message.js').default} MUCMessage
+ * @typedef {module:plugin-chat-parsers.MessageAttributes} MessageAttributes
+ * @typedef {import('strophe.js/src/builder.js').Builder} Strophe.Builder
+ */
 import ModelWithContact from './model-with-contact.js';
+import _converse from '../../shared/_converse.js';
+import api, { converse } from '../../shared/api/index.js';
 import isMatch from "lodash-es/isMatch";
 import log from '../../log.js';
 import pick from "lodash-es/pick";
-import _converse from '../../shared/_converse.js';
-import api, { converse } from '../../shared/api/index.js';
 import { Model } from '@converse/skeletor/src/model.js';
 import { PRIVATE_CHAT_TYPE, COMPOSING, INACTIVE, PAUSED, GONE } from '@converse/headless/shared/constants.js';
 import { TimeoutError } from '../../shared/errors.js';
@@ -18,13 +25,12 @@ import { isUniView } from '../../utils/session.js';
 import { parseMessage } from './parsers.js';
 import { sendMarker } from '../../shared/actions.js';
 
-const { Strophe, $msg } = converse.env;
+const { Strophe, $msg, u } = converse.env;
 
-const u = converse.env.utils;
 
 /**
  * Represents an open/ongoing chat conversation.
- * @namespace _converse.ChatBox
+ * @namespace ChatBox
  * @memberOf _converse
  */
 class ChatBox extends ModelWithContact {
@@ -73,9 +79,9 @@ class ChatBox extends ModelWithContact {
 
         await this.fetchMessages();
         /**
-         * Triggered once a {@link _converse.ChatBox} has been created and initialized.
+         * Triggered once a {@link ChatBox} has been created and initialized.
          * @event _converse#chatBoxInitialized
-         * @type { _converse.ChatBox}
+         * @type { ChatBox}
          * @example _converse.api.listen.on('chatBoxInitialized', model => { ... });
          */
         await api.trigger('chatBoxInitialized', this, {'Synchronous': true});
@@ -96,8 +102,8 @@ class ChatBox extends ModelWithContact {
         this.messages.chatbox = this;
         initStorage(this.messages, this.getMessagesCacheKey());
 
-        this.listenTo(this.messages, 'change:upload', this.onMessageUploadChanged, this);
-        this.listenTo(this.messages, 'add', this.onMessageAdded, this);
+        this.listenTo(this.messages, 'change:upload', m => this.onMessageUploadChanged(m));
+        this.listenTo(this.messages, 'add', m => this.onMessageAdded(m));
     }
 
     initUI () {
@@ -124,10 +130,10 @@ class ChatBox extends ModelWithContact {
     afterMessagesFetched () {
         this.pruneHistoryWhenScrolledDown();
         /**
-         * Triggered whenever a { @link _converse.ChatBox } or ${ @link _converse.ChatRoom }
+         * Triggered whenever a { @link ChatBox } or ${ @link MUC }
          * has fetched its messages from the local cache.
          * @event _converse#afterMessagesFetched
-         * @type { _converse.ChatBox| _converse.ChatRoom }
+         * @type { ChatBox| MUC }
          * @example _converse.api.listen.on('afterMessagesFetched', (chat) => { ... });
          */
         api.trigger('afterMessagesFetched', this);
@@ -190,7 +196,7 @@ class ChatBox extends ModelWithContact {
      * Queue an incoming `chat` message stanza for processing.
      * @async
      * @private
-     * @method _converse.ChatBox#queueMessage
+     * @method ChatBox#queueMessage
      * @param { Promise<MessageAttributes> } attrs - A promise which resolves to the message attributes
      */
     queueMessage (attrs) {
@@ -203,7 +209,7 @@ class ChatBox extends ModelWithContact {
     /**
      * @async
      * @private
-     * @method _converse.ChatBox#onMessage
+     * @method ChatBox#onMessage
      * @param { MessageAttributes } attrs_promse - A promise which resolves to the message attributes.
      */
     async onMessage (attrs) {
@@ -289,7 +295,7 @@ class ChatBox extends ModelWithContact {
         /**
          * Triggered once a chatbox has been closed.
          * @event _converse#chatBoxClosed
-         * @type {_converse.ChatBox | _converse.ChatRoom}
+         * @type {ChatBox | MUC}
          * @example _converse.api.listen.on('chatBoxClosed', chat => { ... });
          */
         api.trigger('chatBoxClosed', this);
@@ -297,9 +303,9 @@ class ChatBox extends ModelWithContact {
 
     announceReconnection () {
         /**
-         * Triggered whenever a `_converse.ChatBox` instance has reconnected after an outage
+         * Triggered whenever a `ChatBox` instance has reconnected after an outage
          * @event _converse#onChatReconnected
-         * @type {_converse.ChatBox | _converse.ChatRoom}
+         * @type {ChatBox | MUC}
          * @example _converse.api.listen.on('onChatReconnected', chat => { ... });
          */
         api.trigger('chatReconnected', this);
@@ -473,7 +479,7 @@ class ChatBox extends ModelWithContact {
      * After the timeout, COMPOSING will become PAUSED and PAUSED will become INACTIVE.
      * See XEP-0085 Chat State Notifications.
      * @private
-     * @method _converse.ChatBox#setChatState
+     * @method ChatBox#setChatState
      * @param { string } state - The chat state (consts ACTIVE, COMPOSING, PAUSED, INACTIVE, GONE)
      */
     setChatState (state, options) {
@@ -510,7 +516,7 @@ class ChatBox extends ModelWithContact {
 
     /**
      * @private
-     * @method _converse.ChatBox#shouldShowErrorMessage
+     * @method ChatBox#shouldShowErrorMessage
      * @returns {boolean}
      */
     shouldShowErrorMessage (attrs) {
@@ -522,7 +528,7 @@ class ChatBox extends ModelWithContact {
             // See https://github.com/conversejs/converse.js/issues/1317
             return;
         }
-        // Gets overridden in ChatRoom
+        // Gets overridden in MUC
         return true;
     }
 
@@ -536,10 +542,10 @@ class ChatBox extends ModelWithContact {
      * probably hasn't been applied to anything yet, given that the
      * relevant message is only coming in now.
      * @private
-     * @method _converse.ChatBox#findDanglingRetraction
+     * @method ChatBox#findDanglingRetraction
      * @param { object } attrs - Attributes representing a received
      *  message, as returned by {@link parseMessage}
-     * @returns { _converse.Message }
+     * @returns { Message }
      */
     findDanglingRetraction (attrs) {
         if (!attrs.origin_id || !this.messages.length) {
@@ -563,7 +569,7 @@ class ChatBox extends ModelWithContact {
     /**
      * Handles message retraction based on the passed in attributes.
      * @private
-     * @method _converse.ChatBox#handleRetraction
+     * @method ChatBox#handleRetraction
      * @param { object } attrs - Attributes representing a received
      *  message, as returned by {@link parseMessage}
      * @returns { Boolean } Returns `true` or `false` depending on
@@ -601,10 +607,10 @@ class ChatBox extends ModelWithContact {
      * Returns an already cached message (if it exists) based on the
      * passed in attributes map.
      * @private
-     * @method _converse.ChatBox#getDuplicateMessage
+     * @method ChatBox#getDuplicateMessage
      * @param {object} attrs - Attributes representing a received
      *  message, as returned by {@link parseMessage}
-     * @returns {Promise<_converse.Message>}
+     * @returns {Promise<Message>}
      */
     getDuplicateMessage (attrs) {
         const queries = [
@@ -649,8 +655,8 @@ class ChatBox extends ModelWithContact {
     /**
      * Retract one of your messages in this chat
      * @private
-     * @method _converse.ChatBoxView#retractOwnMessage
-     * @param { _converse.Message } message - The message which we're retracting.
+     * @method ChatBoxView#retractOwnMessage
+     * @param { Message } message - The message which we're retracting.
      */
     retractOwnMessage (message) {
         this.sendRetractionMessage(message)
@@ -666,8 +672,8 @@ class ChatBox extends ModelWithContact {
     /**
      * Sends a message stanza to retract a message in this chat
      * @private
-     * @method _converse.ChatBox#sendRetractionMessage
-     * @param { _converse.Message } message - The message which we're retracting.
+     * @method ChatBox#sendRetractionMessage
+     * @param { Message } message - The message which we're retracting.
      */
     sendRetractionMessage (message) {
         const origin_id = message.get('origin_id');
@@ -702,7 +708,7 @@ class ChatBox extends ModelWithContact {
 
     /**
      * Given the passed in message object, send a XEP-0333 chat marker.
-     * @param { _converse.Message } msg
+     * @param { Message } msg
      * @param { ('received'|'displayed'|'acknowledged') } [type='displayed']
      * @param { Boolean } force - Whether a marker should be sent for the
      *  message, even if it didn't include a `markable` element.
@@ -764,9 +770,9 @@ class ChatBox extends ModelWithContact {
     }
 
     /**
-     * Given a {@link _converse.Message} return the XML stanza that represents it.
+     * Given a {@link Message} return the XML stanza that represents it.
      * @private
-     * @method _converse.ChatBox#createMessageStanza
+     * @method ChatBox#createMessageStanza
      * @param { Message } message - The message object
      */
     async createMessageStanza (message) {
@@ -822,10 +828,10 @@ class ChatBox extends ModelWithContact {
         /**
          * *Hook* which allows plugins to update an outgoing message stanza
          * @event _converse#createMessageStanza
-         * @param { _converse.ChatBox | _converse.ChatRoom } - The chat from
+         * @param { ChatBox | MUC } chat - The chat from
          *      which this message stanza is being sent.
          * @param { Object } data - Message data
-         * @param { _converse.Message | _converse.ChatRoomMessage } data.message
+         * @param { Message | MUCMessage } data.message
          *      The message object from which the stanza is created and which gets persisted to storage.
          * @param { Strophe.Builder } data.stanza
          *      The stanza that will be sent out, as a Strophe.Builder object.
@@ -861,12 +867,12 @@ class ChatBox extends ModelWithContact {
 
         /**
          * *Hook* which allows plugins to update the attributes of an outgoing message.
-         * These attributes get set on the { @link _converse.Message } or
-         * { @link _converse.ChatRoomMessage } and persisted to storage.
+         * These attributes get set on the {@link Message} or
+         * {@link MUCMessage} and persisted to storage.
          * @event _converse#getOutgoingMessageAttributes
-         * @param { _converse.ChatBox | _converse.ChatRoom } chat
+         * @param {ChatBox|MUC} chat
          *      The chat from which this message will be sent.
-         * @param { MessageAttributes } attrs
+         * @param {MessageAttributes} attrs
          *      The message attributes, from which the stanza will be created.
          */
         attrs = await api.hook('getOutgoingMessageAttributes', this, attrs);
@@ -878,8 +884,8 @@ class ChatBox extends ModelWithContact {
      * If api.settings.get('allow_message_corrections') is "last", then only the last
      * message sent from me will be editable. If set to "all" all messages
      * will be editable. Otherwise no messages will be editable.
-     * @method _converse.ChatBox#setEditable
-     * @memberOf _converse.ChatBox
+     * @method ChatBox#setEditable
+     * @memberOf ChatBox
      * @param { Object } attrs An object containing message attributes.
      * @param { String } send_time - time when the message was sent
      */
@@ -902,7 +908,7 @@ class ChatBox extends ModelWithContact {
      * before the collection has been fetched.
      * @async
      * @private
-     * @method _converse.ChatBox#createMessage
+     * @method ChatBox#createMessage
      * @param { Object } attrs
      */
     async createMessage (attrs, options) {
@@ -914,10 +920,10 @@ class ChatBox extends ModelWithContact {
     /**
      * Responsible for sending off a text message inside an ongoing chat conversation.
      * @private
-     * @method _converse.ChatBox#sendMessage
-     * @memberOf _converse.ChatBox
+     * @method ChatBox#sendMessage
+     * @memberOf ChatBox
      * @param { Object } [attrs] - A map of attributes to be saved on the message
-     * @returns { _converse.Message }
+     * @returns { Promise<Message> }
      * @example
      * const chat = api.chats.get('buddy1@example.org');
      * chat.sendMessage({'body': 'hello world'});
@@ -962,8 +968,8 @@ class ChatBox extends ModelWithContact {
         * @event _converse#sendMessage
         * @type { Object }
         * @param { Object } data
-        * @property { (_converse.ChatBox | _converse.ChatRoom) } data.chatbox
-        * @property { (_converse.Message | _converse.ChatRoomMessage) } data.message
+        * @property { (ChatBox | MUC) } data.chatbox
+        * @property { (Message | MUCMessage) } data.message
         */
         api.trigger('sendMessage', {'chatbox': this, message});
         return message;
@@ -971,9 +977,9 @@ class ChatBox extends ModelWithContact {
 
     /**
      * Sends a message with the current XEP-0085 chat state of the user
-     * as taken from the `chat_state` attribute of the {@link _converse.ChatBox}.
+     * as taken from the `chat_state` attribute of the {@link ChatBox}.
      * @private
-     * @method _converse.ChatBox#sendChatState
+     * @method ChatBox#sendChatState
      */
     sendChatState () {
         if (api.settings.get('send_chat_state_notifications') && this.get('chat_state')) {
@@ -1023,10 +1029,8 @@ class ChatBox extends ModelWithContact {
              * *Hook* which allows plugins to transform files before they'll be
              * uploaded. The main use-case is to encrypt the files.
              * @event _converse#beforeFileUpload
-             * @param { _converse.ChatBox | _converse.ChatRoom } chat
-             *      The chat from which this file will be uploaded.
-             * @param { File } file
-             *      The file that will be uploaded
+             * @param {ChatBox|MUC} chat - The chat from which this file will be uploaded.
+             * @param {File} file - The file that will be uploaded
              */
             file = await api.hook('beforeFileUpload', this, file);
 
@@ -1084,11 +1088,11 @@ class ChatBox extends ModelWithContact {
     }
 
     /**
-     * Given a newly received {@link _converse.Message} instance,
+     * Given a newly received {@link Message} instance,
      * update the unread counter if necessary.
      * @private
-     * @method _converse.ChatBox#handleUnreadMessage
-     * @param {_converse.Message} message
+     * @method ChatBox#handleUnreadMessage
+     * @param {Message} message
      */
     handleUnreadMessage (message) {
         if (!message?.get('body')) {

+ 5 - 1
src/headless/plugins/chat/parsers.js

@@ -1,3 +1,7 @@
+/**
+ * @module:plugin-chat-parsers
+ * @typedef {module:plugin-chat-parsers.MessageAttributes} MessageAttributes
+ */
 import _converse from '../../shared/_converse.js';
 import api, { converse } from '../../shared/api/index.js';
 import dayjs from 'dayjs';
@@ -102,8 +106,8 @@ export async function parseMessage (stanza) {
         }
     }
     /**
-     * @typedef { Object } MessageAttributes
      * The object which {@link parseMessage} returns
+     * @typedef {Object} module:plugin-chat-parsers.MessageAttributes
      * @property { ('me'|'them') } sender - Whether the message was sent by the current user or someone else
      * @property { Array<Object> } references - A list of objects representing XEP-0372 references
      * @property { Boolean } editable - Is this message editable via XEP-0308?

+ 86 - 82
src/headless/plugins/muc/muc.js

@@ -1,3 +1,8 @@
+/**
+ * @typedef {import('../muc/message.js').default} MUCMessage
+ * @typedef {module:plugin-chat-parsers.MessageAttributes} MessageAttributes
+ * @typedef {import('strophe.js/src/builder.js').Builder} Strophe.Builder
+ */
 import _converse from '../../shared/_converse.js';
 import api, { converse } from '../../shared/api/index.js';
 import ChatBox from '../chat/model';
@@ -51,7 +56,7 @@ const METADATA_ATTRIBUTES = [
 const ACTION_INFO_CODES = ['301', '303', '333', '307', '321', '322'];
 
 class MUCSession extends Model {
-    defaults () { // eslint-disable-line class-methods-use-this
+    defaults () {
         return {
             'connection_status': ROOMSTATUS.DISCONNECTED
         };
@@ -60,12 +65,12 @@ class MUCSession extends Model {
 
 /**
  * Represents an open/ongoing groupchat conversation.
- * @namespace _converse.ChatRoom
+ * @namespace MUC
  * @memberOf _converse
  */
 class MUC extends ChatBox {
 
-    defaults () { // eslint-disable-line class-methods-use-this
+    defaults () {
         return {
             'bookmarked': false,
             'chat_state': undefined,
@@ -122,9 +127,9 @@ class MUC extends ChatBox {
             this.join();
         }
         /**
-         * Triggered once a {@link _converse.ChatRoom} has been created and initialized.
+         * Triggered once a {@link MUC} has been created and initialized.
          * @event _converse#chatRoomInitialized
-         * @type { _converse.ChatRoom }
+         * @type { MUC }
          * @example _converse.api.listen.on('chatRoomInitialized', model => { ... });
          */
         await api.trigger('chatRoomInitialized', this, { 'Synchronous': true });
@@ -137,7 +142,7 @@ class MUC extends ChatBox {
 
     /**
      * Checks whether this MUC qualifies for subscribing to XEP-0437 Room Activity Indicators (RAI)
-     * @method _converse.ChatRoom#isRAICandidate
+     * @method MUC#isRAICandidate
      * @returns { Boolean }
      */
     isRAICandidate () {
@@ -147,7 +152,7 @@ class MUC extends ChatBox {
     /**
      * Checks whether we're still joined and if so, restores the MUC state from cache.
      * @private
-     * @method _converse.ChatRoom#restoreFromCache
+     * @method MUC#restoreFromCache
      * @returns { Boolean } Returns `true` if we're still joined, otherwise returns `false`.
      */
     async restoreFromCache () {
@@ -173,8 +178,8 @@ class MUC extends ChatBox {
     /**
      * Join the MUC
      * @private
-     * @method _converse.ChatRoom#join
-     * @param { String } nick - The user's nickname
+     * @method MUC#join
+     * @param { String } [nick] - The user's nickname
      * @param { String } [password] - Optional password, if required by the groupchat.
      *  Will fall back to the `password` value stored in the room
      *  model (if available).
@@ -203,7 +208,7 @@ class MUC extends ChatBox {
     /**
      * Clear stale cache and re-join a MUC we've been in before.
      * @private
-     * @method _converse.ChatRoom#rejoin
+     * @method MUC#rejoin
      */
     rejoin () {
         this.session.save('connection_status', ROOMSTATUS.DISCONNECTED);
@@ -230,7 +235,7 @@ class MUC extends ChatBox {
          /**
           * *Hook* which allows plugins to update an outgoing MUC join presence stanza
           * @event _converse#constructedMUCPresence
-          * @param { _converse.ChatRoom } - The MUC from which this message stanza is being sent.
+          * @param { MUC } - The MUC from which this message stanza is being sent.
           * @param { Element } stanza - The stanza which will be sent out
           */
         stanza = await api.hook('constructedMUCPresence', this, stanza);
@@ -249,7 +254,7 @@ class MUC extends ChatBox {
 
     /**
      * Given the passed in MUC message, send a XEP-0333 chat marker.
-     * @param { _converse.MUCMessage } msg
+     * @param { MUCMessage } msg
      * @param { ('received'|'displayed'|'acknowledged') } [type='displayed']
      * @param { Boolean } force - Whether a marker should be sent for the
      *  message, even if it didn't include a `markable` element.
@@ -278,7 +283,7 @@ class MUC extends ChatBox {
      * called after the MUC has been left and we don't have that information
      * anymore.
      * @private
-     * @method _converse.ChatRoom#enableRAI
+     * @method MUC#enableRAI
      */
     enableRAI () {
         if (api.settings.get('muc_subscribe_to_rai')) {
@@ -290,7 +295,7 @@ class MUC extends ChatBox {
     /**
      * Handler that gets called when the 'hidden' flag is toggled.
      * @private
-     * @method _converse.ChatRoom#onHiddenChange
+     * @method MUC#onHiddenChange
      */
     async onHiddenChange () {
         const roomstatus = ROOMSTATUS;
@@ -511,7 +516,7 @@ class MUC extends ChatBox {
     /**
      * Handles incoming message stanzas from the service that hosts this MUC
      * @private
-     * @method _converse.ChatRoom#handleMessageFromMUCHost
+     * @method MUC#handleMessageFromMUCHost
      * @param { Element } stanza
      */
     handleMessageFromMUCHost (stanza) {
@@ -532,7 +537,7 @@ class MUC extends ChatBox {
     /**
      * Handles XEP-0452 MUC Mention Notification messages
      * @private
-     * @method _converse.ChatRoom#handleForwardedMentions
+     * @method MUC#handleForwardedMentions
      * @param { Element } stanza
      */
     handleForwardedMentions (stanza) {
@@ -562,7 +567,7 @@ class MUC extends ChatBox {
     /**
      * Parses an incoming message stanza and queues it for processing.
      * @private
-     * @method _converse.ChatRoom#handleMessageStanza
+     * @method MUC#handleMessageStanza
      * @param { Element } stanza
      */
     async handleMessageStanza (stanza) {
@@ -611,7 +616,7 @@ class MUC extends ChatBox {
     /**
      * Register presence and message handlers relevant to this groupchat
      * @private
-     * @method _converse.ChatRoom#registerHandlers
+     * @method MUC#registerHandlers
      */
     registerHandlers () {
         const muc_jid = this.get('jid');
@@ -715,7 +720,7 @@ class MUC extends ChatBox {
      * Sends a message stanza to the XMPP server and expects a reflection
      * or error message within a specific timeout period.
      * @private
-     * @method _converse.ChatRoom#sendTimedMessage
+     * @method MUC#sendTimedMessage
      * @param { _converse.Message|Element } message
      * @returns { Promise<Element>|Promise<TimeoutError> } Returns a promise
      *  which resolves with the reflected message stanza or with an error stanza or {@link TimeoutError}.
@@ -751,7 +756,7 @@ class MUC extends ChatBox {
     /**
      * Retract one of your messages in this groupchat
      * @private
-     * @method _converse.ChatRoom#retractOwnMessage
+     * @method MUC#retractOwnMessage
      * @param { _converse.Message } message - The message which we're retracting.
      */
     async retractOwnMessage (message) {
@@ -801,7 +806,7 @@ class MUC extends ChatBox {
     /**
      * Retract someone else's message in this groupchat.
      * @private
-     * @method _converse.ChatRoom#retractOtherMessage
+     * @method MUC#retractOtherMessage
      * @param { _converse.ChatRoomMessage } message - The message which we're retracting.
      * @param { string } [reason] - The reason for retracting the message.
      * @example
@@ -836,7 +841,7 @@ class MUC extends ChatBox {
     /**
      * Sends an IQ stanza to the XMPP server to retract a message in this groupchat.
      * @private
-     * @method _converse.ChatRoom#sendRetractionIQ
+     * @method MUC#sendRetractionIQ
      * @param { _converse.ChatRoomMessage } message - The message which we're retracting.
      * @param { string } [reason] - The reason for retracting the message.
      */
@@ -856,10 +861,10 @@ class MUC extends ChatBox {
 
     /**
      * Sends an IQ stanza to the XMPP server to destroy this groupchat. Not
-     * to be confused with the {@link _converse.ChatRoom#destroy}
+     * to be confused with the {@link MUC#destroy}
      * method, which simply removes the room from the local browser storage cache.
      * @private
-     * @method _converse.ChatRoom#sendDestroyIQ
+     * @method MUC#sendDestroyIQ
      * @param { string } [reason] - The reason for destroying the groupchat.
      * @param { string } [new_jid] - The JID of the new groupchat which replaces this one.
      */
@@ -883,7 +888,7 @@ class MUC extends ChatBox {
     /**
      * Leave the groupchat.
      * @private
-     * @method _converse.ChatRoom#leave
+     * @method MUC#leave
      * @param { string } [exit_msg] - Message to indicate your reason for leaving
      */
     async leave (exit_msg) {
@@ -941,7 +946,7 @@ class MUC extends ChatBox {
     /**
      * Return an array of unique nicknames based on all occupants and messages in this MUC.
      * @private
-     * @method _converse.ChatRoom#getAllKnownNicknames
+     * @method MUC#getAllKnownNicknames
      * @returns { String[] }
      */
     getAllKnownNicknames () {
@@ -1044,7 +1049,7 @@ class MUC extends ChatBox {
     /**
      * Utility method to construct the JID for the current user as occupant of the groupchat.
      * @private
-     * @method _converse.ChatRoom#getRoomJIDAndNick
+     * @method MUC#getRoomJIDAndNick
      * @returns {string} - The groupchat JID with the user's nickname added at the end.
      * @example groupchat@conference.example.org/nickname
      */
@@ -1056,9 +1061,9 @@ class MUC extends ChatBox {
 
     /**
      * Sends a message with the current XEP-0085 chat state of the user
-     * as taken from the `chat_state` attribute of the {@link _converse.ChatRoom}.
+     * as taken from the `chat_state` attribute of the {@link MUC}.
      * @private
-     * @method _converse.ChatRoom#sendChatState
+     * @method MUC#sendChatState
      */
     sendChatState () {
         if (
@@ -1091,7 +1096,7 @@ class MUC extends ChatBox {
     /**
      * Send a direct invitation as per XEP-0249
      * @private
-     * @method _converse.ChatRoom#directInvite
+     * @method MUC#directInvite
      * @param { String } recipient - JID of the person being invited
      * @param { String } [reason] - Reason for the invitation
      */
@@ -1123,7 +1128,7 @@ class MUC extends ChatBox {
          * to a roster contact, asking them to join a room.
          * @event _converse#chatBoxMaximized
          * @type {object}
-         * @property {_converse.ChatRoom} room
+         * @property {MUC} room
          * @property {string} recipient - The JID of the person being invited
          * @property {string} reason - The original reason for the invitation
          * @example _converse.api.listen.on('chatBoxMaximized', view => { ... });
@@ -1136,9 +1141,9 @@ class MUC extends ChatBox {
     }
 
     /**
-     * Refresh the disco identity, features and fields for this {@link _converse.ChatRoom}.
-     * *features* are stored on the features {@link Model} attribute on this {@link _converse.ChatRoom}.
-     * *fields* are stored on the config {@link Model} attribute on this {@link _converse.ChatRoom}.
+     * Refresh the disco identity, features and fields for this {@link MUC}.
+     * *features* are stored on the features {@link Model} attribute on this {@link MUC}.
+     * *fields* are stored on the config {@link Model} attribute on this {@link MUC}.
      * @private
      * @returns {Promise}
      */
@@ -1153,7 +1158,7 @@ class MUC extends ChatBox {
      * Fetch the *extended* MUC info from the server and cache it locally
      * https://xmpp.org/extensions/xep-0045.html#disco-roominfo
      * @private
-     * @method _converse.ChatRoom#getDiscoInfo
+     * @method MUC#getDiscoInfo
      * @returns {Promise}
      */
     getDiscoInfo () {
@@ -1170,7 +1175,7 @@ class MUC extends ChatBox {
      * in the `config` {@link Model} attribute.
      * See: https://xmpp.org/extensions/xep-0045.html#disco-roominfo
      * @private
-     * @method _converse.ChatRoom#getDiscoInfoFields
+     * @method MUC#getDiscoInfoFields
      * @returns {Promise}
      */
     async getDiscoInfoFields () {
@@ -1187,9 +1192,9 @@ class MUC extends ChatBox {
 
     /**
      * Use converse-disco to populate the features {@link Model} which
-     * is stored as an attibute on this {@link _converse.ChatRoom}.
+     * is stored as an attibute on this {@link MUC}.
      * The results may be cached. If you want to force fetching the features from the
-     * server, call {@link _converse.ChatRoom#refreshDiscoInfo} instead.
+     * server, call {@link MUC#refreshDiscoInfo} instead.
      * @private
      * @returns {Promise}
      */
@@ -1220,7 +1225,7 @@ class MUC extends ChatBox {
      * Given a <field> element, return a copy with a <value> child if
      * we can find a value for it in this rooms config.
      * @private
-     * @method _converse.ChatRoom#addFieldValue
+     * @method MUC#addFieldValue
      * @returns { Element }
      */
     addFieldValue (field) {
@@ -1251,7 +1256,7 @@ class MUC extends ChatBox {
      * Automatically configure the groupchat based on this model's
      * 'roomconfig' data.
      * @private
-     * @method _converse.ChatRoom#autoConfigureChatRoom
+     * @method MUC#autoConfigureChatRoom
      * @returns { Promise<Element> }
      * Returns a promise which resolves once a response IQ has
      * been received.
@@ -1270,7 +1275,7 @@ class MUC extends ChatBox {
      * Returns a promise which resolves once the response IQ
      * has been received.
      * @private
-     * @method _converse.ChatRoom#fetchRoomConfiguration
+     * @method MUC#fetchRoomConfiguration
      * @returns { Promise<Element> }
      */
     fetchRoomConfiguration () {
@@ -1280,7 +1285,7 @@ class MUC extends ChatBox {
     /**
      * Sends an IQ stanza with the groupchat configuration.
      * @private
-     * @method _converse.ChatRoom#sendConfiguration
+     * @method MUC#sendConfiguration
      * @param { Array } config - The groupchat configuration
      * @returns { Promise<Element> } - A promise which resolves with
      * the `result` stanza received from the XMPP server.
@@ -1417,7 +1422,7 @@ class MUC extends ChatBox {
     /**
      * Returns the `role` which the current user has in this MUC
      * @private
-     * @method _converse.ChatRoom#getOwnRole
+     * @method MUC#getOwnRole
      * @returns { ('none'|'visitor'|'participant'|'moderator') }
      */
     getOwnRole () {
@@ -1427,7 +1432,7 @@ class MUC extends ChatBox {
     /**
      * Returns the `affiliation` which the current user has in this MUC
      * @private
-     * @method _converse.ChatRoom#getOwnAffiliation
+     * @method MUC#getOwnAffiliation
      * @returns { ('none'|'outcast'|'member'|'admin'|'owner') }
      */
     getOwnAffiliation () {
@@ -1437,7 +1442,7 @@ class MUC extends ChatBox {
     /**
      * Get the {@link _converse.ChatRoomOccupant} instance which
      * represents the current user.
-     * @method _converse.ChatRoom#getOwnOccupant
+     * @method MUC#getOwnOccupant
      * @returns { _converse.ChatRoomOccupant }
      */
     getOwnOccupant () {
@@ -1479,7 +1484,7 @@ class MUC extends ChatBox {
     /**
      * Send an IQ stanza to modify an occupant's role
      * @private
-     * @method _converse.ChatRoom#setRole
+     * @method MUC#setRole
      * @param { _converse.ChatRoomOccupant } occupant
      * @param { String } role
      * @param { String } reason
@@ -1508,7 +1513,7 @@ class MUC extends ChatBox {
 
     /**
      * @private
-     * @method _converse.ChatRoom#getOccupant
+     * @method MUC#getOccupant
      * @param { String } nickname_or_jid - The nickname or JID of the occupant to be returned
      * @returns { _converse.ChatRoomOccupant }
      */
@@ -1521,7 +1526,7 @@ class MUC extends ChatBox {
     /**
      * Return an array of occupant models that have the required role
      * @private
-     * @method _converse.ChatRoom#getOccupantsWithRole
+     * @method MUC#getOccupantsWithRole
      * @param { String } role
      * @returns { _converse.ChatRoomOccupant[] }
      */
@@ -1540,7 +1545,7 @@ class MUC extends ChatBox {
     /**
      * Return an array of occupant models that have the required affiliation
      * @private
-     * @method _converse.ChatRoom#getOccupantsWithAffiliation
+     * @method MUC#getOccupantsWithAffiliation
      * @param { String } affiliation
      * @returns { _converse.ChatRoomOccupant[] }
      */
@@ -1559,7 +1564,7 @@ class MUC extends ChatBox {
     /**
      * Return an array of occupant models, sorted according to the passed-in attribute.
      * @private
-     * @method _converse.ChatRoom#getOccupantsSortedBy
+     * @method MUC#getOccupantsSortedBy
      * @param { String } attr - The attribute to sort the returned array by
      * @returns { _converse.ChatRoomOccupant[] }
      */
@@ -1575,7 +1580,7 @@ class MUC extends ChatBox {
      * the passed in members, and if it exists, send the delta
      * to the XMPP server to update the member list.
      * @private
-     * @method _converse.ChatRoom#updateMemberLists
+     * @method MUC#updateMemberLists
      * @param { object } members - Map of member jids and affiliations.
      * @returns { Promise }
      *  A promise which is resolved once the list has been
@@ -1596,7 +1601,7 @@ class MUC extends ChatBox {
      * for a server-side reserved nickname or default configured
      * nickname and if found, persist that to the model state.
      * @private
-     * @method _converse.ChatRoom#getAndPersistNickname
+     * @method MUC#getAndPersistNickname
      * @returns { Promise<string> } A promise which resolves with the nickname
      */
     async getAndPersistNickname (nick) {
@@ -1610,7 +1615,7 @@ class MUC extends ChatBox {
      * this user has a reserved nickname for this groupchat.
      * If so, we'll use that, otherwise we render the nickname form.
      * @private
-     * @method _converse.ChatRoom#getReservedNick
+     * @method MUC#getReservedNick
      * @returns { Promise<string> } A promise which resolves with the reserved nick or null
      */
     async getReservedNick () {
@@ -1638,7 +1643,7 @@ class MUC extends ChatBox {
      * users from using it in this MUC.
      * See https://xmpp.org/extensions/xep-0045.html#register
      * @private
-     * @method _converse.ChatRoom#registerNickname
+     * @method MUC#registerNickname
      */
     async registerNickname () {
         const { __ } = _converse;
@@ -1691,8 +1696,8 @@ class MUC extends ChatBox {
 
     /**
      * Check whether we should unregister the user from this MUC, and if so,
-     * call { @link _converse.ChatRoom#sendUnregistrationIQ }
-     * @method _converse.ChatRoom#unregisterNickname
+     * call { @link MUC#sendUnregistrationIQ }
+     * @method MUC#unregisterNickname
      */
     async unregisterNickname () {
         if (api.settings.get('auto_register_muc_nickname') === 'unregister') {
@@ -1711,7 +1716,7 @@ class MUC extends ChatBox {
      * If the user had a 'member' affiliation, it'll be removed and their
      * nickname will no longer be reserved and can instead be used (and
      * registered) by other users.
-     * @method _converse.ChatRoom#sendUnregistrationIQ
+     * @method MUC#sendUnregistrationIQ
      */
     sendUnregistrationIQ () {
         const iq = $iq({ 'to': this.get('jid'), 'type': 'set' })
@@ -1723,7 +1728,7 @@ class MUC extends ChatBox {
     /**
      * Given a presence stanza, update the occupant model based on its contents.
      * @private
-     * @method _converse.ChatRoom#updateOccupantsOnPresence
+     * @method MUC#updateOccupantsOnPresence
      * @param { Element } pres - The presence stanza
      */
     updateOccupantsOnPresence (pres) {
@@ -1790,7 +1795,7 @@ class MUC extends ChatBox {
      * Given two JIDs, which can be either user JIDs or MUC occupant JIDs,
      * determine whether they belong to the same user.
      * @private
-     * @method _converse.ChatRoom#isSameUser
+     * @method MUC#isSameUser
      * @param { String } jid1
      * @param { String } jid2
      * @returns { Boolean }
@@ -1842,7 +1847,7 @@ class MUC extends ChatBox {
     /**
      * Handle a possible subject change and return `true` if so.
      * @private
-     * @method _converse.ChatRoom#handleSubjectChange
+     * @method MUC#handleSubjectChange
      * @param { object } attrs - Attributes representing a received
      *  message, as returned by {@link parseMUCMessage}
      */
@@ -1877,9 +1882,9 @@ class MUC extends ChatBox {
     }
 
     /**
-     * Set the subject for this {@link _converse.ChatRoom}
+     * Set the subject for this {@link MUC}
      * @private
-     * @method _converse.ChatRoom#setSubject
+     * @method MUC#setSubject
      * @param { String } value
      */
     setSubject (value = '') {
@@ -1899,7 +1904,7 @@ class MUC extends ChatBox {
      * Is this a chat state notification that can be ignored,
      * because it's old or because it's from us.
      * @private
-     * @method _converse.ChatRoom#ignorableCSN
+     * @method MUC#ignorableCSN
      * @param { Object } attrs - The message attributes
      */
     ignorableCSN (attrs) {
@@ -1909,7 +1914,7 @@ class MUC extends ChatBox {
     /**
      * Determines whether the message is from ourselves by checking
      * the `from` attribute. Doesn't check the `type` attribute.
-     * @method _converse.ChatRoom#isOwnMessage
+     * @method MUC#isOwnMessage
      * @param {Object|Element|_converse.Message} msg
      * @returns {boolean}
      */
@@ -1946,7 +1951,7 @@ class MUC extends ChatBox {
      * whether we're still joined.
      * @async
      * @private
-     * @method _converse.ChatRoom#isJoined
+     * @method MUC#isJoined
      * @returns {Promise<boolean>}
      */
     async isJoined () {
@@ -1962,7 +1967,7 @@ class MUC extends ChatBox {
 
     /**
      * Sends a status update presence (i.e. based on the `<show>` element)
-     * @method _converse.ChatRoom#sendStatusPresence
+     * @method MUC#sendStatusPresence
      * @param { String } type
      * @param { String } [status] - An optional status message
      * @param { Element[]|Strophe.Builder[]|Element|Strophe.Builder } [child_nodes]
@@ -1978,7 +1983,7 @@ class MUC extends ChatBox {
 
     /**
      * Check whether we're still joined and re-join if not
-     * @method _converse.ChatRoom#rejoinIfNecessary
+     * @method MUC#rejoinIfNecessary
      */
     async rejoinIfNecessary () {
         if (this.isRAICandidate()) {
@@ -1994,7 +1999,7 @@ class MUC extends ChatBox {
 
     /**
      * @private
-     * @method _converse.ChatRoom#shouldShowErrorMessage
+     * @method MUC#shouldShowErrorMessage
      * @returns {Promise<boolean>}
      */
     async shouldShowErrorMessage (attrs) {
@@ -2017,7 +2022,7 @@ class MUC extends ChatBox {
      * it probably hasn't been applied to anything yet, given that
      * the relevant message is only coming in now.
      * @private
-     * @method _converse.ChatRoom#findDanglingModeration
+     * @method MUC#findDanglingModeration
      * @param { object } attrs - Attributes representing a received
      *  message, as returned by {@link parseMUCMessage}
      * @returns { _converse.ChatRoomMessage }
@@ -2048,7 +2053,7 @@ class MUC extends ChatBox {
     /**
      * Handles message moderation based on the passed in attributes.
      * @private
-     * @method _converse.ChatRoom#handleModeration
+     * @method MUC#handleModeration
      * @param {object} attrs - Attributes representing a received
      *  message, as returned by {@link parseMUCMessage}
      * @returns {Promise<boolean>} Returns `true` or `false` depending on
@@ -2249,7 +2254,7 @@ class MUC extends ChatBox {
     /**
      * Returns an already cached message (if it exists) based on the
      * passed in attributes map.
-     * @method _converse.ChatRoom#getDuplicateMessage
+     * @method MUC#getDuplicateMessage
      * @param { object } attrs - Attributes representing a received
      *  message, as returned by {@link parseMUCMessage}
      * @returns {Promise<_converse.Message>}
@@ -2265,9 +2270,9 @@ class MUC extends ChatBox {
 
     /**
      * Handler for all MUC messages sent to this groupchat. This method
-     * shouldn't be called directly, instead {@link _converse.ChatRoom#queueMessage}
+     * shouldn't be called directly, instead {@link MUC#queueMessage}
      * should be called.
-     * @method _converse.ChatRoom#onMessage
+     * @method MUC#onMessage
      * @param { MessageAttributes } attrs - A promise which resolves to the message attributes.
      */
     async onMessage (attrs) {
@@ -2461,7 +2466,7 @@ class MUC extends ChatBox {
     /**
      * Create an info message based on a received MUC status code
      * @private
-     * @method _converse.ChatRoom#createInfoMessage
+     * @method MUC#createInfoMessage
      * @param { string } code - The MUC status code
      * @param { Element } stanza - The original stanza that contains the code
      * @param { Boolean } is_self - Whether this stanza refers to our own presence
@@ -2505,7 +2510,7 @@ class MUC extends ChatBox {
     /**
      * Create info messages based on a received presence or message stanza
      * @private
-     * @method _converse.ChatRoom#createInfoMessages
+     * @method MUC#createInfoMessages
      * @param { Element } stanza
      */
     createInfoMessages (stanza) {
@@ -2559,7 +2564,7 @@ class MUC extends ChatBox {
 
     /**
      * Parses a <presence> stanza with type "error" and sets the proper
-     * `connection_status` value for this {@link _converse.ChatRoom} as
+     * `connection_status` value for this {@link MUC} as
      * well as any additional output that can be shown to the user.
      * @private
      * @param { Element } stanza - The presence stanza
@@ -2626,7 +2631,7 @@ class MUC extends ChatBox {
     /**
      * Listens for incoming presence stanzas from the service that hosts this MUC
      * @private
-     * @method _converse.ChatRoom#onPresenceFromMUCHost
+     * @method MUC#onPresenceFromMUCHost
      * @param { Element } stanza - The presence stanza
      */
     onPresenceFromMUCHost (stanza) {
@@ -2645,7 +2650,7 @@ class MUC extends ChatBox {
     /**
      * Handles incoming presence stanzas coming from the MUC
      * @private
-     * @method _converse.ChatRoom#onPresence
+     * @method MUC#onPresence
      * @param { Element } stanza
      */
     onPresence (stanza) {
@@ -2678,7 +2683,7 @@ class MUC extends ChatBox {
      * auto-configured only if applicable and if the current
      * user is the groupchat's owner.
      * @private
-     * @method _converse.ChatRoom#onOwnPresence
+     * @method MUC#onOwnPresence
      * @param { Element } pres - The stanza
      */
     async onOwnPresence (stanza) {
@@ -2719,9 +2724,8 @@ class MUC extends ChatBox {
     /**
      * Returns a boolean to indicate whether the current user
      * was mentioned in a message.
-     * @private
-     * @method _converse.ChatRoom#isUserMentioned
-     * @param { String } - The text message
+     * @method MUC#isUserMentioned
+     * @param {MUCMessage} message - The text message
      */
     isUserMentioned (message) {
         const nick = this.get('nick');

+ 3 - 0
src/headless/shared/_converse.js

@@ -1,3 +1,6 @@
+/**
+ * @module:shared_converse
+ */
 import i18n from './i18n.js';
 import pluggable from 'pluggable.js/src/pluggable.js';
 import { EventEmitter } from '@converse/skeletor';

+ 1 - 1
src/headless/shared/actions.js

@@ -28,7 +28,7 @@ export function rejectMessage (stanza, text) {
  * @param { String } to_jid
  * @param { String } id - The id of the message being marked
  * @param { String } type - The marker type
- * @param { String } msg_type
+ * @param { String } [msg_type]
  */
 export function sendMarker (to_jid, id, type, msg_type) {
     const stanza = $msg({

+ 3 - 2
src/utils/html.js

@@ -617,18 +617,19 @@ u.xForm2TemplateResult = function (field, stanza, options={}) {
             'value': field.querySelector('value')?.textContent
         });
     }
-};
+}
 
 Object.assign(u, {
-    hasClass,
     addClass,
     ancestor,
     getOOBURLMarkup,
+    hasClass,
     isEqualNode,
     removeClass,
     removeElement,
     slideIn,
     slideOut,
+    xForm2TemplateResult,
 });
 
 export default u;