浏览代码

Avoid deep imports of types

TypeScript can't find the type definitions
JC Brand 1 年之前
父节点
当前提交
f07e794495
共有 40 个文件被更改,包括 514 次插入455 次删除
  1. 22 16
      src/headless/index.js
  2. 2 56
      src/headless/plugins/chat/index.js
  3. 57 0
      src/headless/plugins/chat/plugin.js
  4. 3 0
      src/headless/plugins/emoji/utils.js
  5. 2 223
      src/headless/plugins/muc/index.js
  6. 229 0
      src/headless/plugins/muc/plugin.js
  7. 2 57
      src/headless/plugins/roster/index.js
  8. 62 0
      src/headless/plugins/roster/plugin.js
  9. 2 62
      src/headless/plugins/status/index.js
  10. 60 0
      src/headless/plugins/status/plugin.js
  11. 4 0
      src/headless/types/index.d.ts
  12. 4 1
      src/headless/types/plugins/chat/index.d.ts
  13. 2 0
      src/headless/types/plugins/chat/plugin.d.ts
  14. 6 1
      src/headless/types/plugins/muc/index.d.ts
  15. 2 0
      src/headless/types/plugins/muc/plugin.d.ts
  16. 5 1
      src/headless/types/plugins/roster/index.d.ts
  17. 2 0
      src/headless/types/plugins/roster/plugin.d.ts
  18. 2 1
      src/headless/types/plugins/status/index.d.ts
  19. 2 0
      src/headless/types/plugins/status/plugin.d.ts
  20. 4 0
      src/headless/types/utils/index.d.ts
  21. 4 0
      src/headless/utils/index.js
  22. 2 2
      src/plugins/minimize/index.js
  23. 2 2
      src/plugins/minimize/utils.js
  24. 4 5
      src/plugins/notifications/utils.js
  25. 1 1
      src/plugins/omemo/utils.js
  26. 1 1
      src/plugins/profile/modals/profile.js
  27. 1 1
      src/plugins/roomslist/templates/roomslist.js
  28. 1 1
      src/plugins/rosterview/utils.js
  29. 3 7
      src/shared/chat/utils.js
  30. 1 1
      src/shared/modals/user-details.js
  31. 4 0
      src/types/headless/utils/index.d.ts
  32. 2 2
      src/types/plugins/minimize/index.d.ts
  33. 2 2
      src/types/plugins/minimize/utils.d.ts
  34. 4 4
      src/types/plugins/notifications/utils.d.ts
  35. 1 1
      src/types/plugins/omemo/utils.d.ts
  36. 1 1
      src/types/plugins/profile/modals/profile.d.ts
  37. 1 1
      src/types/plugins/roomslist/templates/roomslist.d.ts
  38. 3 3
      src/types/plugins/rosterview/utils.d.ts
  39. 1 1
      src/types/shared/chat/utils.d.ts
  40. 1 1
      src/types/shared/modals/user-details.d.ts

+ 22 - 16
src/headless/index.js

@@ -15,22 +15,28 @@ dayjs.extend(advancedFormat);
  * --------------------
  * The following components may be removed if they're not needed.
  */
-import "./plugins/bookmarks/index.js";  // XEP-0199 XMPP Ping
-import "./plugins/bosh/index.js";       // XEP-0206 BOSH
-import "./plugins/caps/index.js";       // XEP-0115 Entity Capabilities
-import "./plugins/chat/index.js";       // RFC-6121 Instant messaging
-import "./plugins/chatboxes/index.js";
-import "./plugins/disco/index.js";      // XEP-0030 Service discovery
-import "./plugins/adhoc/index.js";      // XEP-0050 Ad Hoc Commands
-import "./plugins/headlines/index.js";  // Support for headline messages
-import "./plugins/mam/index.js";        // XEP-0313 Message Archive Management
-import "./plugins/muc/index.js";        // XEP-0045 Multi-user chat
-import "./plugins/ping/index.js";       // XEP-0199 XMPP Ping
-import "./plugins/pubsub.js";           // XEP-0060 Pubsub
-import "./plugins/roster/index.js";     // RFC-6121 Contacts Roster
-import "./plugins/smacks/index.js";     // XEP-0198 Stream Management
-import "./plugins/status/index.js";
-import "./plugins/vcard/index.js";      // XEP-0054 VCard-temp
+import './plugins/bookmarks/index.js'; // XEP-0199 XMPP Ping
+import './plugins/bosh/index.js'; // XEP-0206 BOSH
+import './plugins/caps/index.js'; // XEP-0115 Entity Capabilities
+export { ChatBox, Message, Messages } from './plugins/chat/index.js'; // RFC-6121 Instant messaging
+import './plugins/chatboxes/index.js';
+import './plugins/disco/index.js'; // XEP-0030 Service discovery
+import './plugins/adhoc/index.js'; // XEP-0050 Ad Hoc Commands
+import './plugins/headlines/index.js'; // Support for headline messages
+import './plugins/mam/index.js'; // XEP-0313 Message Archive Management
+
+// XEP-0045 Multi-user chat
+export { MUCMessage, MUCMessages, MUC, MUCOccupant, MUCOccupants } from './plugins/muc/index.js';
+
+import './plugins/ping/index.js'; // XEP-0199 XMPP Ping
+import './plugins/pubsub.js'; // XEP-0060 Pubsub
+
+// RFC-6121 Contacts Roster
+export { RosterContact, RosterContacts, Presence, Presences } from './plugins/roster/index.js';
+
+import './plugins/smacks/index.js'; // XEP-0198 Stream Management
+export { XMPPStatus } from './plugins/status/index.js';
+import './plugins/vcard/index.js'; // XEP-0054 VCard-temp
 /* END: Removable components */
 
 import log from './log.js';

+ 2 - 56
src/headless/plugins/chat/index.js

@@ -1,60 +1,6 @@
-/**
- * @copyright 2022, the Converse.js contributors
- * @license Mozilla Public License (MPLv2)
- */
 import ChatBox from './model.js';
 import Message from './message.js';
 import Messages from './messages.js';
-import _converse from '../../shared/_converse.js';
-import api, { converse } from '../../shared/api/index.js';
-import chat_api from './api.js';
-import { PRIVATE_CHAT_TYPE } from '../../shared/constants.js';
-import {
-    autoJoinChats,
-    enableCarbons,
-    handleMessageStanza,
-    onClearSession,
-    routeToChat,
-    registerMessageHandlers,
-} from './utils.js';
+import './plugin.js';
 
-converse.plugins.add('converse-chat', {
-    dependencies: ['converse-chatboxes', 'converse-disco'],
-
-    initialize () {
-        // Configuration values for this plugin
-        // ====================================
-        // Refer to docs/source/configuration.rst for explanations of these
-        // configuration settings.
-        api.settings.extend({
-            'allow_message_corrections': 'all',
-            'allow_message_retraction': 'all',
-            'allow_message_styling': true,
-            'auto_join_private_chats': [],
-            'clear_messages_on_reconnection': false,
-            'filter_by_resource': false,
-            'prune_messages_above': undefined,
-            'pruning_behavior': 'unscrolled',
-            'send_chat_markers': ['received', 'displayed', 'acknowledged'],
-            'send_chat_state_notifications': true,
-        });
-
-        const exports = { ChatBox, Message, Messages, handleMessageStanza };
-        Object.assign(_converse, exports); // TODO: DEPRECATED
-        Object.assign(_converse.exports, exports);
-
-        Object.assign(api, chat_api);
-
-        api.chatboxes.registry.add(PRIVATE_CHAT_TYPE, ChatBox);
-
-        routeToChat();
-        addEventListener('hashchange', routeToChat);
-
-        api.listen.on('chatBoxesFetched', autoJoinChats);
-        api.listen.on('presencesInitialized', registerMessageHandlers);
-        api.listen.on('clearSession', onClearSession);
-
-        api.listen.on('connected', () => enableCarbons());
-        api.listen.on('reconnected', () => enableCarbons());
-    },
-});
+export { ChatBox, Message, Messages };

+ 57 - 0
src/headless/plugins/chat/plugin.js

@@ -0,0 +1,57 @@
+import ChatBox from './model.js';
+import Message from './message.js';
+import Messages from './messages.js';
+import _converse from '../../shared/_converse.js';
+import api, { converse } from '../../shared/api/index.js';
+import chat_api from './api.js';
+import { PRIVATE_CHAT_TYPE } from '../../shared/constants.js';
+import {
+    autoJoinChats,
+    enableCarbons,
+    handleMessageStanza,
+    onClearSession,
+    routeToChat,
+    registerMessageHandlers,
+} from './utils.js';
+
+
+converse.plugins.add('converse-chat', {
+    dependencies: ['converse-chatboxes', 'converse-disco'],
+
+    initialize () {
+        // Configuration values for this plugin
+        // ====================================
+        // Refer to docs/source/configuration.rst for explanations of these
+        // configuration settings.
+        api.settings.extend({
+            'allow_message_corrections': 'all',
+            'allow_message_retraction': 'all',
+            'allow_message_styling': true,
+            'auto_join_private_chats': [],
+            'clear_messages_on_reconnection': false,
+            'filter_by_resource': false,
+            'prune_messages_above': undefined,
+            'pruning_behavior': 'unscrolled',
+            'send_chat_markers': ['received', 'displayed', 'acknowledged'],
+            'send_chat_state_notifications': true,
+        });
+
+        const exports = { ChatBox, Message, Messages, handleMessageStanza };
+        Object.assign(_converse, exports); // TODO: DEPRECATED
+        Object.assign(_converse.exports, exports);
+
+        Object.assign(api, chat_api);
+
+        api.chatboxes.registry.add(PRIVATE_CHAT_TYPE, ChatBox);
+
+        routeToChat();
+        addEventListener('hashchange', routeToChat);
+
+        api.listen.on('chatBoxesFetched', autoJoinChats);
+        api.listen.on('presencesInitialized', registerMessageHandlers);
+        api.listen.on('clearSession', onClearSession);
+
+        api.listen.on('connected', () => enableCarbons());
+        api.listen.on('reconnected', () => enableCarbons());
+    },
+});

+ 3 - 0
src/headless/plugins/emoji/utils.js

@@ -220,6 +220,9 @@ function getEmojisByAtrribute (attr) {
 }
 
 Object.assign(u, {
+    getCodePointReferences,
+    getShortnameReferences,
+    convertASCII2Emoji,
     getEmojisByAtrribute,
     isOnlyEmojis,
     shortnamesToUnicode,

+ 2 - 223
src/headless/plugins/muc/index.js

@@ -1,229 +1,8 @@
-/**
- * @copyright The Converse.js contributors
- * @license Mozilla Public License (MPLv2)
- * @description Implements the non-view logic for XEP-0045 Multi-User Chat
- */
-import '../chat/index.js';
-import '../disco/index.js';
-import '../emoji/index.js';
 import MUCMessage from './message.js';
 import MUCMessages from './messages.js';
 import MUC from './muc.js';
 import MUCOccupant from './occupant.js';
 import MUCOccupants from './occupants.js';
-import affiliations_api from './affiliations/api.js';
-import muc_api from './api.js';
-import _converse from '../../shared/_converse.js';
-import api, { converse } from '../../shared/api/index.js';
-import { CHATROOMS_TYPE } from '../../shared/constants.js';
-import {
-    autoJoinRooms,
-    disconnectChatRooms,
-    getDefaultMUCNickname,
-    isInfoVisible,
-    onAddClientFeatures,
-    onBeforeResourceBinding,
-    onBeforeTearDown,
-    onDirectMUCInvitation,
-    onStatusInitialized,
-    onWindowStateChanged,
-    registerDirectInvitationHandler,
-    routeToRoom,
-} from './utils.js';
-import { computeAffiliationsDelta, getAssignableAffiliations } from './affiliations/utils.js';
-import {
-    AFFILIATION_CHANGES,
-    AFFILIATION_CHANGES_LIST,
-    INFO_CODES,
-    MUC_NICK_CHANGED_CODE,
-    MUC_ROLE_CHANGES,
-    MUC_ROLE_CHANGES_LIST,
-    MUC_TRAFFIC_STATES,
-    MUC_TRAFFIC_STATES_LIST,
-    ROOMSTATUS,
-    ROOM_FEATURES,
-} from './constants.js';
+import './plugin.js';
 
-converse.AFFILIATION_CHANGES = AFFILIATION_CHANGES;
-converse.AFFILIATION_CHANGES_LIST = AFFILIATION_CHANGES_LIST;
-converse.MUC_TRAFFIC_STATES = MUC_TRAFFIC_STATES;
-converse.MUC_TRAFFIC_STATES_LIST = MUC_TRAFFIC_STATES_LIST;
-converse.MUC_ROLE_CHANGES = MUC_ROLE_CHANGES;
-converse.MUC_ROLE_CHANGES_LIST = MUC_ROLE_CHANGES_LIST;
-
-converse.MUC = { INFO_CODES };
-
-converse.MUC_NICK_CHANGED_CODE = MUC_NICK_CHANGED_CODE;
-converse.ROOM_FEATURES = ROOM_FEATURES;
-converse.ROOMSTATUS = ROOMSTATUS;
-
-const { Strophe } = converse.env;
-
-// Add Strophe Namespaces
-Strophe.addNamespace('MUC_ADMIN', Strophe.NS.MUC + '#admin');
-Strophe.addNamespace('MUC_OWNER', Strophe.NS.MUC + '#owner');
-Strophe.addNamespace('MUC_REGISTER', 'jabber:iq:register');
-Strophe.addNamespace('MUC_ROOMCONF', Strophe.NS.MUC + '#roomconfig');
-Strophe.addNamespace('MUC_USER', Strophe.NS.MUC + '#user');
-Strophe.addNamespace('MUC_HATS', 'xmpp:prosody.im/protocol/hats:1');
-Strophe.addNamespace('CONFINFO', 'urn:ietf:params:xml:ns:conference-info');
-
-converse.plugins.add('converse-muc', {
-    dependencies: ['converse-chatboxes', 'converse-chat', 'converse-disco'],
-
-    initialize () {
-        /* The initialize function gets called as soon as the plugin is
-         * loaded by converse.js's plugin machinery.
-         */
-        const { __, ___ } = _converse;
-
-        // Configuration values for this plugin
-        // ====================================
-        // Refer to docs/source/configuration.rst for explanations of these
-        // configuration settings.
-        api.settings.extend({
-            'allow_muc_invitations': true,
-            'auto_join_on_invite': false,
-            'auto_join_rooms': [],
-            'auto_register_muc_nickname': false,
-            'hide_muc_participants': false,
-            'locked_muc_domain': false,
-            'modtools_disable_assign': false,
-            'muc_clear_messages_on_leave': true,
-            'muc_domain': undefined,
-            'muc_fetch_members': true,
-            'muc_history_max_stanzas': undefined,
-            'muc_instant_rooms': true,
-            'muc_nickname_from_jid': false,
-            'muc_send_probes': false,
-            'muc_show_info_messages': [
-                ...converse.MUC.INFO_CODES.visibility_changes,
-                ...converse.MUC.INFO_CODES.self,
-                ...converse.MUC.INFO_CODES.non_privacy_changes,
-                ...converse.MUC.INFO_CODES.muc_logging_changes,
-                ...converse.MUC.INFO_CODES.nickname_changes,
-                ...converse.MUC.INFO_CODES.disconnected,
-                ...converse.MUC.INFO_CODES.affiliation_changes,
-                ...converse.MUC.INFO_CODES.join_leave_events,
-                ...converse.MUC.INFO_CODES.role_changes,
-            ],
-            'muc_show_logs_before_join': false,
-            'muc_subscribe_to_rai': false,
-        });
-        api.promises.add(['roomsAutoJoined']);
-
-        if (api.settings.get('locked_muc_domain') && typeof api.settings.get('muc_domain') !== 'string') {
-            throw new Error(
-                'Config Error: it makes no sense to set locked_muc_domain ' + 'to true when muc_domain is not set'
-            );
-        }
-
-        // This is for tests (at least until we can import modules inside tests)
-        converse.env.muc_utils = { computeAffiliationsDelta };
-        Object.assign(api, muc_api);
-        Object.assign(api.rooms, affiliations_api);
-
-        /* https://xmpp.org/extensions/xep-0045.html
-         * ----------------------------------------
-         * 100 message      Entering a groupchat         Inform user that any occupant is allowed to see the user's full JID
-         * 101 message (out of band)                     Affiliation change  Inform user that his or her affiliation changed while not in the groupchat
-         * 102 message      Configuration change         Inform occupants that groupchat now shows unavailable members
-         * 103 message      Configuration change         Inform occupants that groupchat now does not show unavailable members
-         * 104 message      Configuration change         Inform occupants that a non-privacy-related groupchat configuration change has occurred
-         * 110 presence     Any groupchat presence       Inform user that presence refers to one of its own groupchat occupants
-         * 170 message or initial presence               Configuration change    Inform occupants that groupchat logging is now enabled
-         * 171 message      Configuration change         Inform occupants that groupchat logging is now disabled
-         * 172 message      Configuration change         Inform occupants that the groupchat is now non-anonymous
-         * 173 message      Configuration change         Inform occupants that the groupchat is now semi-anonymous
-         * 174 message      Configuration change         Inform occupants that the groupchat is now fully-anonymous
-         * 201 presence     Entering a groupchat         Inform user that a new groupchat has been created
-         * 210 presence     Entering a groupchat         Inform user that the service has assigned or modified the occupant's roomnick
-         * 301 presence     Removal from groupchat       Inform user that he or she has been banned from the groupchat
-         * 303 presence     Exiting a groupchat          Inform all occupants of new groupchat nickname
-         * 307 presence     Removal from groupchat       Inform user that he or she has been kicked from the groupchat
-         * 321 presence     Removal from groupchat       Inform user that he or she is being removed from the groupchat because of an affiliation change
-         * 322 presence     Removal from groupchat       Inform user that he or she is being removed from the groupchat because the groupchat has been changed to members-only and the user is not a member
-         * 332 presence     Removal from groupchat       Inform user that he or she is being removed from the groupchat because of a system shutdown
-         */
-        const MUC_FEEDBACK_MESSAGES = {
-            info_messages: {
-                100: __('This groupchat is not anonymous'),
-                102: __('This groupchat now shows unavailable members'),
-                103: __('This groupchat does not show unavailable members'),
-                104: __('The groupchat configuration has changed'),
-                170: __('Groupchat logging is now enabled'),
-                171: __('Groupchat logging is now disabled'),
-                172: __('This groupchat is now no longer anonymous'),
-                173: __('This groupchat is now semi-anonymous'),
-                174: __('This groupchat is now fully-anonymous'),
-                201: __('A new groupchat has been created'),
-            },
-
-            new_nickname_messages: {
-                // XXX: Note the triple underscore function and not double underscore.
-                210: ___('Your nickname has been automatically set to %1$s'),
-                303: ___('Your nickname has been changed to %1$s'),
-            },
-
-            disconnect_messages: {
-                301: __('You have been banned from this groupchat'),
-                333: __('You have exited this groupchat due to a technical problem'),
-                307: __('You have been kicked from this groupchat'),
-                321: __('You have been removed from this groupchat because of an affiliation change'),
-                322: __(
-                    "You have been removed from this groupchat because the groupchat has changed to members-only and you're not a member"
-                ),
-                332: __('You have been removed from this groupchat because the service hosting it is being shut down'),
-            },
-        };
-
-        const labels = { muc: MUC_FEEDBACK_MESSAGES };
-        Object.assign(_converse.labels, labels);
-        Object.assign(_converse, labels); // XXX DEPRECATED
-
-        routeToRoom();
-        addEventListener('hashchange', routeToRoom);
-
-        // TODO: DEPRECATED
-        const legacy_exports = {
-            ChatRoom: MUC,
-            ChatRoomMessage: MUCMessage,
-            ChatRoomMessages: MUCMessages,
-            ChatRoomOccupant: MUCOccupant,
-            ChatRoomOccupants: MUCOccupants,
-        };
-        Object.assign(_converse, legacy_exports);
-
-        const exports = {
-            MUC,
-            MUCMessage,
-            MUCMessages,
-            MUCOccupant,
-            MUCOccupants,
-            getAssignableAffiliations,
-            getDefaultMUCNickname,
-            isInfoVisible,
-            onDirectMUCInvitation,
-        };
-        Object.assign(_converse.exports, exports);
-        Object.assign(_converse, exports); // XXX DEPRECATED
-
-        /** @type {module:shared-api.APIEndpoint} */(api.chatboxes.registry).add(CHATROOMS_TYPE, MUC);
-
-
-        if (api.settings.get('allow_muc_invitations')) {
-            api.listen.on('connected', registerDirectInvitationHandler);
-            api.listen.on('reconnected', registerDirectInvitationHandler);
-        }
-
-        api.listen.on('addClientFeatures', () => api.disco.own.features.add(`${Strophe.NS.CONFINFO}+notify`));
-        api.listen.on('addClientFeatures', onAddClientFeatures);
-        api.listen.on('beforeResourceBinding', onBeforeResourceBinding);
-        api.listen.on('beforeTearDown', onBeforeTearDown);
-        api.listen.on('chatBoxesFetched', autoJoinRooms);
-        api.listen.on('disconnected', disconnectChatRooms);
-        api.listen.on('statusInitialized', onStatusInitialized);
-
-        document.addEventListener('visibilitychange', onWindowStateChanged);
-    },
-});
+export { MUCMessage, MUCMessages, MUC, MUCOccupant, MUCOccupants };

+ 229 - 0
src/headless/plugins/muc/plugin.js

@@ -0,0 +1,229 @@
+/**
+ * @copyright The Converse.js contributors
+ * @license Mozilla Public License (MPLv2)
+ * @description Implements the core logic for XEP-0045 Multi-User Chat
+ */
+import '../chat/index.js';
+import '../disco/index.js';
+import '../emoji/index.js';
+import MUCMessage from './message.js';
+import MUCMessages from './messages.js';
+import MUC from './muc.js';
+import MUCOccupant from './occupant.js';
+import MUCOccupants from './occupants.js';
+import affiliations_api from './affiliations/api.js';
+import muc_api from './api.js';
+import _converse from '../../shared/_converse.js';
+import api, { converse } from '../../shared/api/index.js';
+import { CHATROOMS_TYPE } from '../../shared/constants.js';
+import {
+    autoJoinRooms,
+    disconnectChatRooms,
+    getDefaultMUCNickname,
+    isInfoVisible,
+    onAddClientFeatures,
+    onBeforeResourceBinding,
+    onBeforeTearDown,
+    onDirectMUCInvitation,
+    onStatusInitialized,
+    onWindowStateChanged,
+    registerDirectInvitationHandler,
+    routeToRoom,
+} from './utils.js';
+import { computeAffiliationsDelta, getAssignableAffiliations } from './affiliations/utils.js';
+import {
+    AFFILIATION_CHANGES,
+    AFFILIATION_CHANGES_LIST,
+    INFO_CODES,
+    MUC_NICK_CHANGED_CODE,
+    MUC_ROLE_CHANGES,
+    MUC_ROLE_CHANGES_LIST,
+    MUC_TRAFFIC_STATES,
+    MUC_TRAFFIC_STATES_LIST,
+    ROOMSTATUS,
+    ROOM_FEATURES,
+} from './constants.js';
+
+converse.AFFILIATION_CHANGES = AFFILIATION_CHANGES;
+converse.AFFILIATION_CHANGES_LIST = AFFILIATION_CHANGES_LIST;
+converse.MUC_TRAFFIC_STATES = MUC_TRAFFIC_STATES;
+converse.MUC_TRAFFIC_STATES_LIST = MUC_TRAFFIC_STATES_LIST;
+converse.MUC_ROLE_CHANGES = MUC_ROLE_CHANGES;
+converse.MUC_ROLE_CHANGES_LIST = MUC_ROLE_CHANGES_LIST;
+
+converse.MUC = { INFO_CODES };
+
+converse.MUC_NICK_CHANGED_CODE = MUC_NICK_CHANGED_CODE;
+converse.ROOM_FEATURES = ROOM_FEATURES;
+converse.ROOMSTATUS = ROOMSTATUS;
+
+const { Strophe } = converse.env;
+
+// Add Strophe Namespaces
+Strophe.addNamespace('MUC_ADMIN', Strophe.NS.MUC + '#admin');
+Strophe.addNamespace('MUC_OWNER', Strophe.NS.MUC + '#owner');
+Strophe.addNamespace('MUC_REGISTER', 'jabber:iq:register');
+Strophe.addNamespace('MUC_ROOMCONF', Strophe.NS.MUC + '#roomconfig');
+Strophe.addNamespace('MUC_USER', Strophe.NS.MUC + '#user');
+Strophe.addNamespace('MUC_HATS', 'xmpp:prosody.im/protocol/hats:1');
+Strophe.addNamespace('CONFINFO', 'urn:ietf:params:xml:ns:conference-info');
+
+converse.plugins.add('converse-muc', {
+    dependencies: ['converse-chatboxes', 'converse-chat', 'converse-disco'],
+
+    initialize () {
+        /* The initialize function gets called as soon as the plugin is
+         * loaded by converse.js's plugin machinery.
+         */
+        const { __, ___ } = _converse;
+
+        // Configuration values for this plugin
+        // ====================================
+        // Refer to docs/source/configuration.rst for explanations of these
+        // configuration settings.
+        api.settings.extend({
+            'allow_muc_invitations': true,
+            'auto_join_on_invite': false,
+            'auto_join_rooms': [],
+            'auto_register_muc_nickname': false,
+            'hide_muc_participants': false,
+            'locked_muc_domain': false,
+            'modtools_disable_assign': false,
+            'muc_clear_messages_on_leave': true,
+            'muc_domain': undefined,
+            'muc_fetch_members': true,
+            'muc_history_max_stanzas': undefined,
+            'muc_instant_rooms': true,
+            'muc_nickname_from_jid': false,
+            'muc_send_probes': false,
+            'muc_show_info_messages': [
+                ...converse.MUC.INFO_CODES.visibility_changes,
+                ...converse.MUC.INFO_CODES.self,
+                ...converse.MUC.INFO_CODES.non_privacy_changes,
+                ...converse.MUC.INFO_CODES.muc_logging_changes,
+                ...converse.MUC.INFO_CODES.nickname_changes,
+                ...converse.MUC.INFO_CODES.disconnected,
+                ...converse.MUC.INFO_CODES.affiliation_changes,
+                ...converse.MUC.INFO_CODES.join_leave_events,
+                ...converse.MUC.INFO_CODES.role_changes,
+            ],
+            'muc_show_logs_before_join': false,
+            'muc_subscribe_to_rai': false,
+        });
+        api.promises.add(['roomsAutoJoined']);
+
+        if (api.settings.get('locked_muc_domain') && typeof api.settings.get('muc_domain') !== 'string') {
+            throw new Error(
+                'Config Error: it makes no sense to set locked_muc_domain ' + 'to true when muc_domain is not set'
+            );
+        }
+
+        // This is for tests (at least until we can import modules inside tests)
+        converse.env.muc_utils = { computeAffiliationsDelta };
+        Object.assign(api, muc_api);
+        Object.assign(api.rooms, affiliations_api);
+
+        /* https://xmpp.org/extensions/xep-0045.html
+         * ----------------------------------------
+         * 100 message      Entering a groupchat         Inform user that any occupant is allowed to see the user's full JID
+         * 101 message (out of band)                     Affiliation change  Inform user that his or her affiliation changed while not in the groupchat
+         * 102 message      Configuration change         Inform occupants that groupchat now shows unavailable members
+         * 103 message      Configuration change         Inform occupants that groupchat now does not show unavailable members
+         * 104 message      Configuration change         Inform occupants that a non-privacy-related groupchat configuration change has occurred
+         * 110 presence     Any groupchat presence       Inform user that presence refers to one of its own groupchat occupants
+         * 170 message or initial presence               Configuration change    Inform occupants that groupchat logging is now enabled
+         * 171 message      Configuration change         Inform occupants that groupchat logging is now disabled
+         * 172 message      Configuration change         Inform occupants that the groupchat is now non-anonymous
+         * 173 message      Configuration change         Inform occupants that the groupchat is now semi-anonymous
+         * 174 message      Configuration change         Inform occupants that the groupchat is now fully-anonymous
+         * 201 presence     Entering a groupchat         Inform user that a new groupchat has been created
+         * 210 presence     Entering a groupchat         Inform user that the service has assigned or modified the occupant's roomnick
+         * 301 presence     Removal from groupchat       Inform user that he or she has been banned from the groupchat
+         * 303 presence     Exiting a groupchat          Inform all occupants of new groupchat nickname
+         * 307 presence     Removal from groupchat       Inform user that he or she has been kicked from the groupchat
+         * 321 presence     Removal from groupchat       Inform user that he or she is being removed from the groupchat because of an affiliation change
+         * 322 presence     Removal from groupchat       Inform user that he or she is being removed from the groupchat because the groupchat has been changed to members-only and the user is not a member
+         * 332 presence     Removal from groupchat       Inform user that he or she is being removed from the groupchat because of a system shutdown
+         */
+        const MUC_FEEDBACK_MESSAGES = {
+            info_messages: {
+                100: __('This groupchat is not anonymous'),
+                102: __('This groupchat now shows unavailable members'),
+                103: __('This groupchat does not show unavailable members'),
+                104: __('The groupchat configuration has changed'),
+                170: __('Groupchat logging is now enabled'),
+                171: __('Groupchat logging is now disabled'),
+                172: __('This groupchat is now no longer anonymous'),
+                173: __('This groupchat is now semi-anonymous'),
+                174: __('This groupchat is now fully-anonymous'),
+                201: __('A new groupchat has been created'),
+            },
+
+            new_nickname_messages: {
+                // XXX: Note the triple underscore function and not double underscore.
+                210: ___('Your nickname has been automatically set to %1$s'),
+                303: ___('Your nickname has been changed to %1$s'),
+            },
+
+            disconnect_messages: {
+                301: __('You have been banned from this groupchat'),
+                333: __('You have exited this groupchat due to a technical problem'),
+                307: __('You have been kicked from this groupchat'),
+                321: __('You have been removed from this groupchat because of an affiliation change'),
+                322: __(
+                    "You have been removed from this groupchat because the groupchat has changed to members-only and you're not a member"
+                ),
+                332: __('You have been removed from this groupchat because the service hosting it is being shut down'),
+            },
+        };
+
+        const labels = { muc: MUC_FEEDBACK_MESSAGES };
+        Object.assign(_converse.labels, labels);
+        Object.assign(_converse, labels); // XXX DEPRECATED
+
+        routeToRoom();
+        addEventListener('hashchange', routeToRoom);
+
+        // TODO: DEPRECATED
+        const legacy_exports = {
+            ChatRoom: MUC,
+            ChatRoomMessage: MUCMessage,
+            ChatRoomMessages: MUCMessages,
+            ChatRoomOccupant: MUCOccupant,
+            ChatRoomOccupants: MUCOccupants,
+        };
+        Object.assign(_converse, legacy_exports);
+
+        const exports = {
+            MUC,
+            MUCMessage,
+            MUCMessages,
+            MUCOccupant,
+            MUCOccupants,
+            getAssignableAffiliations,
+            getDefaultMUCNickname,
+            isInfoVisible,
+            onDirectMUCInvitation,
+        };
+        Object.assign(_converse.exports, exports);
+        Object.assign(_converse, exports); // XXX DEPRECATED
+
+        /** @type {module:shared-api.APIEndpoint} */(api.chatboxes.registry).add(CHATROOMS_TYPE, MUC);
+
+
+        if (api.settings.get('allow_muc_invitations')) {
+            api.listen.on('connected', registerDirectInvitationHandler);
+            api.listen.on('reconnected', registerDirectInvitationHandler);
+        }
+
+        api.listen.on('addClientFeatures', () => api.disco.own.features.add(`${Strophe.NS.CONFINFO}+notify`));
+        api.listen.on('addClientFeatures', onAddClientFeatures);
+        api.listen.on('beforeResourceBinding', onBeforeResourceBinding);
+        api.listen.on('beforeTearDown', onBeforeTearDown);
+        api.listen.on('chatBoxesFetched', autoJoinRooms);
+        api.listen.on('disconnected', disconnectChatRooms);
+        api.listen.on('statusInitialized', onStatusInitialized);
+
+        document.addEventListener('visibilitychange', onWindowStateChanged);
+    },
+});

+ 2 - 57
src/headless/plugins/roster/index.js

@@ -1,62 +1,7 @@
-/**
- * @copyright The Converse.js contributors
- * @license Mozilla Public License (MPLv2)
- */
-import '../../plugins/status/index.js';
 import RosterContact from './contact.js';
 import RosterContacts from './contacts.js';
-import _converse from '../../shared/_converse.js';
-import api, { converse } from '../../shared/api/index.js';
-import roster_api from './api.js';
 import Presence from './presence.js';
 import Presences from './presences.js';
-import {
-    onChatBoxesInitialized,
-    onClearSession,
-    onPresencesInitialized,
-    onRosterContactsFetched,
-    onStatusInitialized,
-    unregisterPresenceHandler,
-} from './utils.js';
+import './plugin.js';
 
-
-converse.plugins.add('converse-roster', {
-    dependencies: ['converse-status'],
-
-    initialize () {
-        api.settings.extend({
-            'allow_contact_requests': true,
-            'auto_subscribe': false,
-            'synchronize_availability': true
-        });
-
-        api.promises.add(['cachedRoster', 'roster', 'rosterContactsFetched', 'rosterInitialized']);
-
-        // API methods only available to plugins
-        Object.assign(_converse.api, roster_api);
-
-        const { __ } = _converse;
-        const labels = {
-            HEADER_CURRENT_CONTACTS: __('My contacts'),
-            HEADER_PENDING_CONTACTS: __('Pending contacts'),
-            HEADER_REQUESTING_CONTACTS: __('Contact requests'),
-            HEADER_UNGROUPED: __('Ungrouped'),
-            HEADER_UNREAD: __('New messages'),
-        };
-        Object.assign(_converse, labels); // XXX DEPRECATED
-        Object.assign(_converse.labels, labels);
-
-        const exports = { Presence, Presences, RosterContact, RosterContacts };
-        Object.assign(_converse, exports);  // XXX DEPRECATED
-        Object.assign(_converse.exports, exports);
-
-        api.listen.on('beforeTearDown', () => unregisterPresenceHandler());
-        api.listen.on('chatBoxesInitialized', onChatBoxesInitialized);
-        api.listen.on('clearSession', onClearSession);
-        api.listen.on('presencesInitialized', onPresencesInitialized);
-        api.listen.on('statusInitialized', onStatusInitialized);
-        api.listen.on('streamResumptionFailed', () => _converse.session.set('roster_cached', false));
-
-        api.waitUntil('rosterContactsFetched').then(onRosterContactsFetched);
-    }
-});
+export { RosterContact, RosterContacts, Presence, Presences };

+ 62 - 0
src/headless/plugins/roster/plugin.js

@@ -0,0 +1,62 @@
+/**
+ * @copyright The Converse.js contributors
+ * @license Mozilla Public License (MPLv2)
+ */
+import '../../plugins/status/index.js';
+import RosterContact from './contact.js';
+import RosterContacts from './contacts.js';
+import _converse from '../../shared/_converse.js';
+import api, { converse } from '../../shared/api/index.js';
+import roster_api from './api.js';
+import Presence from './presence.js';
+import Presences from './presences.js';
+import {
+    onChatBoxesInitialized,
+    onClearSession,
+    onPresencesInitialized,
+    onRosterContactsFetched,
+    onStatusInitialized,
+    unregisterPresenceHandler,
+} from './utils.js';
+
+
+converse.plugins.add('converse-roster', {
+    dependencies: ['converse-status'],
+
+    initialize () {
+        api.settings.extend({
+            'allow_contact_requests': true,
+            'auto_subscribe': false,
+            'synchronize_availability': true
+        });
+
+        api.promises.add(['cachedRoster', 'roster', 'rosterContactsFetched', 'rosterInitialized']);
+
+        // API methods only available to plugins
+        Object.assign(_converse.api, roster_api);
+
+        const { __ } = _converse;
+        const labels = {
+            HEADER_CURRENT_CONTACTS: __('My contacts'),
+            HEADER_PENDING_CONTACTS: __('Pending contacts'),
+            HEADER_REQUESTING_CONTACTS: __('Contact requests'),
+            HEADER_UNGROUPED: __('Ungrouped'),
+            HEADER_UNREAD: __('New messages'),
+        };
+        Object.assign(_converse, labels); // XXX DEPRECATED
+        Object.assign(_converse.labels, labels);
+
+        const exports = { Presence, Presences, RosterContact, RosterContacts };
+        Object.assign(_converse, exports);  // XXX DEPRECATED
+        Object.assign(_converse.exports, exports);
+
+        api.listen.on('beforeTearDown', () => unregisterPresenceHandler());
+        api.listen.on('chatBoxesInitialized', onChatBoxesInitialized);
+        api.listen.on('clearSession', onClearSession);
+        api.listen.on('presencesInitialized', onPresencesInitialized);
+        api.listen.on('statusInitialized', onStatusInitialized);
+        api.listen.on('streamResumptionFailed', () => _converse.session.set('roster_cached', false));
+
+        api.waitUntil('rosterContactsFetched').then(onRosterContactsFetched);
+    }
+});

+ 2 - 62
src/headless/plugins/status/index.js

@@ -1,64 +1,4 @@
-/**
- * @copyright The Converse.js contributors
- * @license Mozilla Public License (MPLv2)
- */
 import XMPPStatus from './status.js';
-import _converse from '../../shared/_converse.js';
-import api, { converse } from '../../shared/api/index.js';
-import status_api from './api.js';
-import { shouldClearCache } from '../../utils/session.js';
-import {
-    addStatusToMUCJoinPresence,
-    initStatus,
-    onEverySecond,
-    onUserActivity,
-    registerIntervalHandler,
-    tearDown,
-    sendCSI
-} from './utils.js';
+import './plugin.js';
 
-const { Strophe } = converse.env;
-
-Strophe.addNamespace('IDLE', 'urn:xmpp:idle:1');
-
-
-converse.plugins.add('converse-status', {
-
-    initialize () {
-
-        api.settings.extend({
-            auto_away: 0, // Seconds after which user status is set to 'away'
-            auto_xa: 0, // Seconds after which user status is set to 'xa'
-            csi_waiting_time: 0, // Support for XEP-0352. Seconds before client is considered idle and CSI is sent out.
-            default_state: 'online',
-            idle_presence_timeout: 300, // Seconds after which an idle presence is sent
-            priority: 0,
-        });
-        api.promises.add(['statusInitialized']);
-
-        const exports = { XMPPStatus, onUserActivity, onEverySecond, sendCSI, registerIntervalHandler };
-        Object.assign(_converse, exports); // Deprecated
-        Object.assign(_converse.exports, exports);
-        Object.assign(_converse.api.user, status_api);
-
-        if (api.settings.get("idle_presence_timeout") > 0) {
-            api.listen.on('addClientFeatures', () => api.disco.own.features.add(Strophe.NS.IDLE));
-        }
-
-        api.listen.on('presencesInitialized', (reconnecting) => (!reconnecting && registerIntervalHandler()));
-        api.listen.on('beforeTearDown', tearDown);
-
-        api.listen.on('clearSession', () => {
-            if (shouldClearCache() && _converse.state.xmppstatus) {
-                _converse.state.xmppstatus.destroy();
-                delete _converse.state.xmppstatus;
-                Object.assign(_converse, { xmppstatus: undefined }); // XXX DEPRECATED
-                api.promises.add(['statusInitialized']);
-            }
-        });
-
-        api.listen.on('connected', () => initStatus(false));
-        api.listen.on('reconnected', () => initStatus(true));
-        api.listen.on('constructedMUCPresence', addStatusToMUCJoinPresence);
-    }
-});
+export { XMPPStatus };

+ 60 - 0
src/headless/plugins/status/plugin.js

@@ -0,0 +1,60 @@
+import XMPPStatus from './status.js';
+import _converse from '../../shared/_converse.js';
+import api, { converse } from '../../shared/api/index.js';
+import status_api from './api.js';
+import { shouldClearCache } from '../../utils/session.js';
+import {
+    addStatusToMUCJoinPresence,
+    initStatus,
+    onEverySecond,
+    onUserActivity,
+    registerIntervalHandler,
+    tearDown,
+    sendCSI
+} from './utils.js';
+
+const { Strophe } = converse.env;
+
+Strophe.addNamespace('IDLE', 'urn:xmpp:idle:1');
+
+
+converse.plugins.add('converse-status', {
+
+    initialize () {
+
+        api.settings.extend({
+            auto_away: 0, // Seconds after which user status is set to 'away'
+            auto_xa: 0, // Seconds after which user status is set to 'xa'
+            csi_waiting_time: 0, // Support for XEP-0352. Seconds before client is considered idle and CSI is sent out.
+            default_state: 'online',
+            idle_presence_timeout: 300, // Seconds after which an idle presence is sent
+            priority: 0,
+        });
+        api.promises.add(['statusInitialized']);
+
+        const exports = { XMPPStatus, onUserActivity, onEverySecond, sendCSI, registerIntervalHandler };
+        Object.assign(_converse, exports); // Deprecated
+        Object.assign(_converse.exports, exports);
+        Object.assign(_converse.api.user, status_api);
+
+        if (api.settings.get("idle_presence_timeout") > 0) {
+            api.listen.on('addClientFeatures', () => api.disco.own.features.add(Strophe.NS.IDLE));
+        }
+
+        api.listen.on('presencesInitialized', (reconnecting) => (!reconnecting && registerIntervalHandler()));
+        api.listen.on('beforeTearDown', tearDown);
+
+        api.listen.on('clearSession', () => {
+            if (shouldClearCache() && _converse.state.xmppstatus) {
+                _converse.state.xmppstatus.destroy();
+                delete _converse.state.xmppstatus;
+                Object.assign(_converse, { xmppstatus: undefined }); // XXX DEPRECATED
+                api.promises.add(['statusInitialized']);
+            }
+        });
+
+        api.listen.on('connected', () => initStatus(false));
+        api.listen.on('reconnected', () => initStatus(true));
+        api.listen.on('constructedMUCPresence', addStatusToMUCJoinPresence);
+    }
+});

+ 4 - 0
src/headless/types/index.d.ts

@@ -1,3 +1,4 @@
+export { XMPPStatus } from "./plugins/status/index.js";
 export default converse;
 import api from "./shared/api/index.js";
 import { converse } from "./shared/api/public.js";
@@ -6,4 +7,7 @@ import i18n from "./shared/i18n";
 import log from "./log.js";
 import u from "./utils/index.js";
 export { api, converse, _converse, i18n, log, u };
+export { ChatBox, Message, Messages } from "./plugins/chat/index.js";
+export { MUCMessage, MUCMessages, MUC, MUCOccupant, MUCOccupants } from "./plugins/muc/index.js";
+export { RosterContact, RosterContacts, Presence, Presences } from "./plugins/roster/index.js";
 //# sourceMappingURL=index.d.ts.map

+ 4 - 1
src/headless/types/plugins/chat/index.d.ts

@@ -1,2 +1,5 @@
-export {};
+import ChatBox from "./model.js";
+import Message from "./message.js";
+import Messages from "./messages.js";
+export { ChatBox, Message, Messages };
 //# sourceMappingURL=index.d.ts.map

+ 2 - 0
src/headless/types/plugins/chat/plugin.d.ts

@@ -0,0 +1,2 @@
+export {};
+//# sourceMappingURL=plugin.d.ts.map

+ 6 - 1
src/headless/types/plugins/muc/index.d.ts

@@ -1,2 +1,7 @@
-export {};
+import MUCMessage from "./message.js";
+import MUCMessages from "./messages.js";
+import MUC from "./muc.js";
+import MUCOccupant from "./occupant.js";
+import MUCOccupants from "./occupants.js";
+export { MUCMessage, MUCMessages, MUC, MUCOccupant, MUCOccupants };
 //# sourceMappingURL=index.d.ts.map

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

@@ -0,0 +1,2 @@
+export {};
+//# sourceMappingURL=plugin.d.ts.map

+ 5 - 1
src/headless/types/plugins/roster/index.d.ts

@@ -1,2 +1,6 @@
-export {};
+import RosterContact from "./contact.js";
+import RosterContacts from "./contacts.js";
+import Presence from "./presence.js";
+import Presences from "./presences.js";
+export { RosterContact, RosterContacts, Presence, Presences };
 //# sourceMappingURL=index.d.ts.map

+ 2 - 0
src/headless/types/plugins/roster/plugin.d.ts

@@ -0,0 +1,2 @@
+export {};
+//# sourceMappingURL=plugin.d.ts.map

+ 2 - 1
src/headless/types/plugins/status/index.d.ts

@@ -1,2 +1,3 @@
-export {};
+export { XMPPStatus };
+import XMPPStatus from "./status.js";
 //# sourceMappingURL=index.d.ts.map

+ 2 - 0
src/headless/types/plugins/status/plugin.d.ts

@@ -0,0 +1,2 @@
+export {};
+//# sourceMappingURL=plugin.d.ts.map

+ 4 - 0
src/headless/types/utils/index.d.ts

@@ -49,6 +49,8 @@ declare const _default: {
     isValidJID: typeof isValidJID;
     isValidMUCJID: typeof isValidMUCJID;
     isVideoURL: typeof isVideoURL;
+    isUniView: typeof isUniView;
+    isTestEnv: typeof isTestEnv;
     merge: typeof merge;
     onMultipleEvents: typeof onMultipleEvents;
     placeCaretAtEnd: typeof placeCaretAtEnd;
@@ -94,6 +96,8 @@ import { isURLWithImageExtension } from "./url.js";
 import { isValidJID } from "./jid.js";
 import { isValidMUCJID } from "./jid.js";
 import { isVideoURL } from "./url.js";
+import { isUniView } from "./session.js";
+import { isTestEnv } from "./session.js";
 import { merge } from "./object.js";
 /**
  * Call the callback once all the events have been triggered

+ 4 - 0
src/headless/utils/index.js

@@ -47,6 +47,8 @@ import {
     isAllowedProtocolForMedia,
 } from './url.js';
 
+import { isTestEnv, isUniView } from './session.js';
+
 
 /**
  * The utils object
@@ -220,6 +222,8 @@ export default Object.assign({
     isValidJID,
     isValidMUCJID,
     isVideoURL,
+    isUniView,
+    isTestEnv,
     merge,
     onMultipleEvents,
     placeCaretAtEnd,

+ 2 - 2
src/plugins/minimize/index.js

@@ -3,8 +3,8 @@
  * @copyright 2022, the Converse.js contributors
  * @license Mozilla Public License (MPLv2)
  *
- * @typedef {import('@converse/headless/plugins/muc/muc').default} MUC
- * @typedef {import('@converse/headless/plugins/chat/model').default} ChatBox
+ * @typedef {import('@converse/headless').MUC} MUC
+ * @typedef {import('@converse/headless').ChatBox} ChatBox
  */
 import './view.js';
 import './components/minimized-chat.js';

+ 2 - 2
src/plugins/minimize/utils.js

@@ -1,6 +1,6 @@
 /**
- * @typedef {import('@converse/headless/plugins/muc/muc').default} MUC
- * @typedef {import('@converse/headless/plugins/chat/model').default} ChatBox
+ * @typedef {import('@converse/headless').MUC} MUC
+ * @typedef {import('@converse/headless').ChatBox} ChatBox
  * @typedef {import('plugins/chatview/chat').default} ChatView
  * @typedef {import('plugins/muc-views/muc').default} MUCView
  * @typedef {import('plugins/controlbox/controlbox').default} ControlBoxView

+ 4 - 5
src/plugins/notifications/utils.js

@@ -2,15 +2,14 @@
  * @typedef {module:headless-plugins-muc-muc.MUCMessageAttributes} MUCMessageAttributes
  * @typedef {module:headless-plugins-muc-muc.MUCMessageData} MUCMessageData
  * @typedef {module:headless-plugins-chat-utils.MessageData} MessageData
- * @typedef {import('@converse/headless/plugins/roster/contact').default} RosterContact
+ * @typedef {import('@converse/headless').RosterContact} RosterContact
  */
 import Favico from 'favico.js-slevomat';
 import { __, i18n } from 'i18n';
 import { _converse, api, converse, log } from '@converse/headless';
-import { isEmptyMessage } from '@converse/headless/utils/index.js';
-import { isTestEnv } from '@converse/headless/utils/session.js';
 
-const { Strophe } = converse.env;
+const { Strophe, u } = converse.env;
+const { isEmptyMessage, isTestEnv } = u;
 const supports_html5_notification = 'Notification' in window;
 
 converse.env.Favico = Favico;
@@ -167,7 +166,7 @@ export function showFeedbackNotification (data) {
  * @param {RosterContact} contact
  */
 function showChatStateNotification (contact) {
-    if (api.settings.get('chatstate_notification_blacklist')?.includes(contact.jid)) {
+    if (api.settings.get('chatstate_notification_blacklist')?.includes(contact.get('jid'))) {
         // Don't notify if the user is being ignored.
         return;
     }

+ 1 - 1
src/plugins/omemo/utils.js

@@ -2,7 +2,7 @@
  * @typedef {module:plugins-omemo-index.WindowWithLibsignal} WindowWithLibsignal
  * @typedef {module:plugin-chat-parsers.MessageAttributes} MessageAttributes
  * @typedef {module:plugin-muc-parsers.MUCMessageAttributes} MUCMessageAttributes
- * @typedef {import('@converse/headless/plugins/chat/model.js').default} ChatBox
+ * @typedef {import('@converse/headless').ChatBox} ChatBox
  */
 import tplAudio from 'templates/audio.js';
 import tplFile from 'templates/file.js';

+ 1 - 1
src/plugins/profile/modals/profile.js

@@ -1,6 +1,6 @@
 
 /**
- * @typedef {import("@converse/headless/plugins/status/status").default} XMPPStatus
+ * @typedef {import("@converse/headless").XMPPStatus} XMPPStatus
  */
 import BaseModal from "plugins/modal/modal.js";
 import tplProfileModal from "../templates/profile_modal.js";

+ 1 - 1
src/plugins/roomslist/templates/roomslist.js

@@ -1,6 +1,6 @@
 /**
  * @typedef {import('../view').RoomsList} RoomsList
- * @typedef {import('@converse/headless/plugins/muc/muc').default} MUC
+ * @typedef {import('@converse/headless').MUC} MUC
  */
 import 'plugins/muc-views/modals/add-muc.js';
 import 'plugins/muc-views/modals/muc-list.js';

+ 1 - 1
src/plugins/rosterview/utils.js

@@ -1,6 +1,6 @@
 /**
  * @typedef {import('@converse/skeletor').Model} Model
- * @typedef {import('@converse/headless/plugins/roster/contact').default} RosterContact
+ * @typedef {import('@converse/headless').RosterContact} RosterContact
  */
 import { __ } from 'i18n';
 import { _converse, api, log } from "@converse/headless";

+ 3 - 7
src/shared/chat/utils.js

@@ -1,19 +1,15 @@
 /**
- * @typedef {import('@converse/headless/plugins/chat/message').default} Message
+ * @typedef {import('@converse/headless').Message} Message
  * @typedef {import('../../plugins/muc-views/muc.js').default} MUCView
  */
 import debounce from 'lodash-es/debounce';
-import tplNewDay from "./templates/new-day.js";
+import tplNewDay from './templates/new-day.js';
 import { api, converse } from '@converse/headless';
 import { html } from 'lit';
 import { until } from 'lit/directives/until.js';
-import {
-    convertASCII2Emoji,
-    getShortnameReferences,
-    getCodePointReferences
-} from '@converse/headless/plugins/emoji/utils.js';
 
 const { dayjs, u } = converse.env;
+const { convertASCII2Emoji, getShortnameReferences, getCodePointReferences } = u;
 
 export async function getHeadingDropdownItem (promise_or_data) {
     const data = await promise_or_data;

+ 1 - 1
src/shared/modals/user-details.js

@@ -1,5 +1,5 @@
 /**
- * @typedef {import('headless/plugins/chat/model.js').default} ChatBox
+ * @typedef {import('@converse/headless').ChatBox} ChatBox
  */
 import BaseModal from "plugins/modal/modal.js";
 import { tplUserDetailsModal, tplFooter } from "./templates/user-details.js";

+ 4 - 0
src/types/headless/utils/index.d.ts

@@ -49,6 +49,8 @@ declare const _default: {
     isValidJID: typeof isValidJID;
     isValidMUCJID: typeof isValidMUCJID;
     isVideoURL: typeof isVideoURL;
+    isUniView: typeof isUniView;
+    isTestEnv: typeof isTestEnv;
     merge: typeof merge;
     onMultipleEvents: typeof onMultipleEvents;
     placeCaretAtEnd: typeof placeCaretAtEnd;
@@ -94,6 +96,8 @@ import { isURLWithImageExtension } from "./url.js";
 import { isValidJID } from "./jid.js";
 import { isValidMUCJID } from "./jid.js";
 import { isVideoURL } from "./url.js";
+import { isUniView } from "./session.js";
+import { isTestEnv } from "./session.js";
 import { merge } from "./object.js";
 /**
  * Call the callback once all the events have been triggered

+ 2 - 2
src/types/plugins/minimize/index.d.ts

@@ -1,3 +1,3 @@
-export type MUC = import('@converse/headless/plugins/muc/muc').default;
-export type ChatBox = import('@converse/headless/plugins/chat/model').default;
+export type MUC = import('@converse/headless').MUC;
+export type ChatBox = import('@converse/headless').ChatBox;
 //# sourceMappingURL=index.d.ts.map

+ 2 - 2
src/types/plugins/minimize/utils.d.ts

@@ -19,8 +19,8 @@ export function minimize(ev: any, model: any): void;
  * @param { ChatBox|MUC } model
  */
 export function onMinimizedChanged(model: ChatBox | MUC): void;
-export type MUC = import('@converse/headless/plugins/muc/muc').default;
-export type ChatBox = import('@converse/headless/plugins/chat/model').default;
+export type MUC = import('@converse/headless').MUC;
+export type ChatBox = import('@converse/headless').ChatBox;
 export type ChatView = import('plugins/chatview/chat').default;
 export type MUCView = import('plugins/muc-views/muc').default;
 export type ControlBoxView = import('plugins/controlbox/controlbox').default;

+ 4 - 4
src/types/plugins/notifications/utils.d.ts

@@ -1,5 +1,5 @@
 export function isMessageToHiddenChat(attrs: any): any;
-export function areDesktopNotificationsEnabled(): boolean;
+export function areDesktopNotificationsEnabled(): any;
 /**
  * @typedef {Navigator & {clearAppBadge: Function, setAppBadge: Function} } navigator
  */
@@ -22,11 +22,11 @@ export function handleFeedback(data: any): void;
  * Will show an HTML5 notification to indicate that the chat status has changed.
  * @param {RosterContact} contact
  */
-export function handleChatStateNotification(contact: any): void;
+export function handleChatStateNotification(contact: RosterContact): void;
 /**
  * @param {RosterContact} contact
  */
-export function handleContactRequestNotification(contact: any): void;
+export function handleContactRequestNotification(contact: RosterContact): void;
 export function requestPermission(): void;
 export type navigator = Navigator & {
     clearAppBadge: Function;
@@ -35,5 +35,5 @@ export type navigator = Navigator & {
 export type MUCMessageAttributes = any;
 export type MUCMessageData = any;
 export type MessageData = any;
-export type RosterContact = any;
+export type RosterContact = import('@converse/headless').RosterContact;
 //# sourceMappingURL=utils.d.ts.map

+ 1 - 1
src/types/plugins/omemo/utils.d.ts

@@ -58,7 +58,7 @@ export namespace omemo {
 export type WindowWithLibsignal = any;
 export type MessageAttributes = any;
 export type MUCMessageAttributes = any;
-export type ChatBox = import('@converse/headless/plugins/chat/model.js').default;
+export type ChatBox = import('@converse/headless').ChatBox;
 import { IQError } from "shared/errors.js";
 import { UserFacingError } from "shared/errors.js";
 declare function decryptMessage(obj: any): Promise<string>;

+ 1 - 1
src/types/plugins/profile/modals/profile.d.ts

@@ -5,6 +5,6 @@ export default class ProfileModal extends BaseModal {
     setVCard(data: any): Promise<void>;
     onFormSubmitted(ev: any): void;
 }
-export type XMPPStatus = import("@converse/headless/plugins/status/status").default;
+export type XMPPStatus = import("@converse/headless").XMPPStatus;
 import BaseModal from "plugins/modal/modal.js";
 //# sourceMappingURL=profile.d.ts.map

+ 1 - 1
src/types/plugins/roomslist/templates/roomslist.d.ts

@@ -6,5 +6,5 @@ export function tplRoomItem(el: RoomsList, room: MUC): import("lit-html").Templa
 declare function _default(el: RoomsList): import("lit-html").TemplateResult<1>;
 export default _default;
 export type RoomsList = import('../view').RoomsList;
-export type MUC = import('@converse/headless/plugins/muc/muc').default;
+export type MUC = import('@converse/headless').MUC;
 //# sourceMappingURL=roomslist.d.ts.map

+ 3 - 3
src/types/plugins/rosterview/utils.d.ts

@@ -6,16 +6,16 @@ export function toggleGroup(ev: any, name: any): void;
  * @param {string} groupname
  * @returns {boolean}
  */
-export function isContactFiltered(contact: any, groupname: string): boolean;
+export function isContactFiltered(contact: RosterContact, groupname: string): boolean;
 /**
  * @param {RosterContact} contact
  * @param {string} groupname
  * @param {Model} model
  * @returns {boolean}
  */
-export function shouldShowContact(contact: any, groupname: string, model: Model): boolean;
+export function shouldShowContact(contact: RosterContact, groupname: string, model: Model): boolean;
 export function shouldShowGroup(group: any, model: any): boolean;
 export function populateContactsMap(contacts_map: any, contact: any): any;
 export type Model = import('@converse/skeletor').Model;
-export type RosterContact = any;
+export type RosterContact = import('@converse/headless').RosterContact;
 //# sourceMappingURL=utils.d.ts.map

+ 1 - 1
src/types/shared/chat/utils.d.ts

@@ -63,6 +63,6 @@ export type EmojiMarkupOptions = {
     unicode_only?: boolean;
     add_title_wrapper?: boolean;
 };
-export type Message = import('@converse/headless/plugins/chat/message').default;
+export type Message = import('@converse/headless').Message;
 export type MUCView = import('../../plugins/muc-views/muc.js').default;
 //# sourceMappingURL=utils.d.ts.map

+ 1 - 1
src/types/shared/modals/user-details.d.ts

@@ -6,6 +6,6 @@ export default class UserDetailsModal extends BaseModal {
     refreshContact(ev: any): Promise<void>;
     removeContact(ev: any): Promise<void>;
 }
-export type ChatBox = import('headless/plugins/chat/model.js').default;
+export type ChatBox = import('@converse/headless').ChatBox;
 import BaseModal from "plugins/modal/modal.js";
 //# sourceMappingURL=user-details.d.ts.map