Selaa lähdekoodia

Register Strophe namespaces in constants.js

JC Brand 2 vuotta sitten
vanhempi
commit
16754c15aa
3 muutettua tiedostoa jossa 46 lisäystä ja 47 poistoa
  1. 1 46
      src/headless/core.js
  2. 7 1
      src/headless/shared/_converse.js
  3. 38 0
      src/headless/shared/constants.js

+ 1 - 46
src/headless/core.js

@@ -2,12 +2,12 @@
  * @copyright The Converse.js contributors
  * @license Mozilla Public License (MPLv2)
  */
+import './shared/constants.js';
 import _converse from './shared/_converse';
 import advancedFormat from 'dayjs/plugin/advancedFormat';
 import connection_api from './shared/connection/api.js';
 import dayjs from 'dayjs';
 import i18n from './shared/i18n';
-import pluggable from 'pluggable.js/src/pluggable.js';
 import { Model } from '@converse/skeletor/src/model.js';
 import { Strophe } from 'strophe.js/src/strophe';
 import { settings_api } from './shared/settings/api.js';
@@ -17,56 +17,11 @@ import events_api from './shared/api/events.js';
 import promise_api from './shared/api/promise.js';
 
 export { converse } from './shared/api/public.js';
-
 export { _converse };
 export { i18n };
 
-
 dayjs.extend(advancedFormat);
 
-// Add Strophe Namespaces
-Strophe.addNamespace('ACTIVITY', 'http://jabber.org/protocol/activity');
-Strophe.addNamespace('CARBONS', 'urn:xmpp:carbons:2');
-Strophe.addNamespace('CHATSTATES', 'http://jabber.org/protocol/chatstates');
-Strophe.addNamespace('CSI', 'urn:xmpp:csi:0');
-Strophe.addNamespace('DELAY', 'urn:xmpp:delay');
-Strophe.addNamespace('EME', 'urn:xmpp:eme:0');
-Strophe.addNamespace('FASTEN', 'urn:xmpp:fasten:0');
-Strophe.addNamespace('FORWARD', 'urn:xmpp:forward:0');
-Strophe.addNamespace('HINTS', 'urn:xmpp:hints');
-Strophe.addNamespace('HTTPUPLOAD', 'urn:xmpp:http:upload:0');
-Strophe.addNamespace('MAM', 'urn:xmpp:mam:2');
-Strophe.addNamespace('MARKERS', 'urn:xmpp:chat-markers:0');
-Strophe.addNamespace('MENTIONS', 'urn:xmpp:mmn:0');
-Strophe.addNamespace('MESSAGE_CORRECT', 'urn:xmpp:message-correct:0');
-Strophe.addNamespace('MODERATE', 'urn:xmpp:message-moderate:0');
-Strophe.addNamespace('NICK', 'http://jabber.org/protocol/nick');
-Strophe.addNamespace('OCCUPANTID', 'urn:xmpp:occupant-id:0');
-Strophe.addNamespace('OMEMO', 'eu.siacs.conversations.axolotl');
-Strophe.addNamespace('OUTOFBAND', 'jabber:x:oob');
-Strophe.addNamespace('PUBSUB', 'http://jabber.org/protocol/pubsub');
-Strophe.addNamespace('RAI', 'urn:xmpp:rai:0');
-Strophe.addNamespace('RECEIPTS', 'urn:xmpp:receipts');
-Strophe.addNamespace('REFERENCE', 'urn:xmpp:reference:0');
-Strophe.addNamespace('REGISTER', 'jabber:iq:register');
-Strophe.addNamespace('RETRACT', 'urn:xmpp:message-retract:0');
-Strophe.addNamespace('ROSTERX', 'http://jabber.org/protocol/rosterx');
-Strophe.addNamespace('RSM', 'http://jabber.org/protocol/rsm');
-Strophe.addNamespace('SID', 'urn:xmpp:sid:0');
-Strophe.addNamespace('SPOILER', 'urn:xmpp:spoiler:0');
-Strophe.addNamespace('STANZAS', 'urn:ietf:params:xml:ns:xmpp-stanzas');
-Strophe.addNamespace('STYLING', 'urn:xmpp:styling:0');
-Strophe.addNamespace('VCARD', 'vcard-temp');
-Strophe.addNamespace('VCARDUPDATE', 'vcard-temp:x:update');
-Strophe.addNamespace('XFORM', 'jabber:x:data');
-Strophe.addNamespace('XHTML', 'http://www.w3.org/1999/xhtml');
-
-_converse.VERSION_NAME = "v10.1.2";
-
-// Make converse pluggable
-pluggable.enable(_converse, '_converse', 'pluggable');
-
-
 /**
  * ### The private API
  *

+ 7 - 1
src/headless/shared/_converse.js

@@ -1,6 +1,7 @@
 import i18n from './i18n.js';
 import log from '../log.js';
-import { CONNECTION_STATUS } from './constants';
+import pluggable from 'pluggable.js/src/pluggable.js';
+import { CONNECTION_STATUS, VERSION_NAME } from './constants';
 import { Events } from '@converse/skeletor/src/events.js';
 import { Router } from '@converse/skeletor/src/router.js';
 import { TimeoutError } from './errors.js';
@@ -18,6 +19,7 @@ import { getOpenPromise } from '@converse/openpromise';
 const _converse = {
     log,
     CONNECTION_STATUS,
+    VERSION_NAME,
     templates: {},
     promises: {
         'initialized': getOpenPromise()
@@ -113,6 +115,10 @@ const _converse = {
     '___': str => str
 }
 
+// Make _converse an event emitter
 Object.assign(_converse, Events);
 
+// Make _converse pluggable
+pluggable.enable(_converse, '_converse', 'pluggable');
+
 export default _converse;

+ 38 - 0
src/headless/shared/constants.js

@@ -1,6 +1,7 @@
 import { Strophe } from 'strophe.js/src/strophe';
 
 export const BOSH_WAIT = 59;
+export const VERSION_NAME = "v10.1.2";
 
 export const CONNECTION_STATUS = {};
 CONNECTION_STATUS[Strophe.Status.ATTACHED] = 'ATTACHED';
@@ -15,6 +16,43 @@ CONNECTION_STATUS[Strophe.Status.ERROR] = 'ERROR';
 CONNECTION_STATUS[Strophe.Status.RECONNECTING] = 'RECONNECTING';
 CONNECTION_STATUS[Strophe.Status.REDIRECT] = 'REDIRECT';
 
+// Add Strophe Namespaces
+Strophe.addNamespace('ACTIVITY', 'http://jabber.org/protocol/activity');
+Strophe.addNamespace('CARBONS', 'urn:xmpp:carbons:2');
+Strophe.addNamespace('CHATSTATES', 'http://jabber.org/protocol/chatstates');
+Strophe.addNamespace('CSI', 'urn:xmpp:csi:0');
+Strophe.addNamespace('DELAY', 'urn:xmpp:delay');
+Strophe.addNamespace('EME', 'urn:xmpp:eme:0');
+Strophe.addNamespace('FASTEN', 'urn:xmpp:fasten:0');
+Strophe.addNamespace('FORWARD', 'urn:xmpp:forward:0');
+Strophe.addNamespace('HINTS', 'urn:xmpp:hints');
+Strophe.addNamespace('HTTPUPLOAD', 'urn:xmpp:http:upload:0');
+Strophe.addNamespace('MAM', 'urn:xmpp:mam:2');
+Strophe.addNamespace('MARKERS', 'urn:xmpp:chat-markers:0');
+Strophe.addNamespace('MENTIONS', 'urn:xmpp:mmn:0');
+Strophe.addNamespace('MESSAGE_CORRECT', 'urn:xmpp:message-correct:0');
+Strophe.addNamespace('MODERATE', 'urn:xmpp:message-moderate:0');
+Strophe.addNamespace('NICK', 'http://jabber.org/protocol/nick');
+Strophe.addNamespace('OCCUPANTID', 'urn:xmpp:occupant-id:0');
+Strophe.addNamespace('OMEMO', 'eu.siacs.conversations.axolotl');
+Strophe.addNamespace('OUTOFBAND', 'jabber:x:oob');
+Strophe.addNamespace('PUBSUB', 'http://jabber.org/protocol/pubsub');
+Strophe.addNamespace('RAI', 'urn:xmpp:rai:0');
+Strophe.addNamespace('RECEIPTS', 'urn:xmpp:receipts');
+Strophe.addNamespace('REFERENCE', 'urn:xmpp:reference:0');
+Strophe.addNamespace('REGISTER', 'jabber:iq:register');
+Strophe.addNamespace('RETRACT', 'urn:xmpp:message-retract:0');
+Strophe.addNamespace('ROSTERX', 'http://jabber.org/protocol/rosterx');
+Strophe.addNamespace('RSM', 'http://jabber.org/protocol/rsm');
+Strophe.addNamespace('SID', 'urn:xmpp:sid:0');
+Strophe.addNamespace('SPOILER', 'urn:xmpp:spoiler:0');
+Strophe.addNamespace('STANZAS', 'urn:ietf:params:xml:ns:xmpp-stanzas');
+Strophe.addNamespace('STYLING', 'urn:xmpp:styling:0');
+Strophe.addNamespace('VCARD', 'vcard-temp');
+Strophe.addNamespace('VCARDUPDATE', 'vcard-temp:x:update');
+Strophe.addNamespace('XFORM', 'jabber:x:data');
+Strophe.addNamespace('XHTML', 'http://www.w3.org/1999/xhtml');
+
 // Core plugins are whitelisted automatically
 // These are just the @converse/headless plugins, for the full converse,
 // the other plugins are whitelisted in src/consts.js