From d3a80e804f284f3a8d68d1722f09761c7b2ef823 Mon Sep 17 00:00:00 2001 From: JC Brand Date: Tue, 9 Apr 2019 18:28:30 +0200 Subject: [PATCH] Move converse-caps into the headless build --- dist/converse.js | 171 +++++++++++++------------ src/converse.js | 3 +- src/{ => headless}/converse-caps.js | 0 src/headless/converse-core.js | 1 + src/headless/dist/converse-headless.js | 84 +++++++++++- src/headless/headless.js | 1 + 6 files changed, 170 insertions(+), 90 deletions(-) rename src/{ => headless}/converse-caps.js (100%) diff --git a/dist/converse.js b/dist/converse.js index a267d5b03..89d9721de 100644 --- a/dist/converse.js +++ b/dist/converse.js @@ -32702,6 +32702,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_ //# sourceMappingURL=pluggable.js.map + /***/ }), /***/ "./node_modules/process/browser.js": @@ -48593,80 +48594,6 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_0__["default"].plugins /***/ }), -/***/ "./src/converse-caps.js": -/*!******************************!*\ - !*** ./src/converse-caps.js ***! - \******************************/ -/*! no exports provided */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony import */ var _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @converse/headless/converse-core */ "./src/headless/converse-core.js"); -// Converse.js -// https://conversejs.org -// -// Copyright (c) 2013-2019, the Converse.js developers -// Licensed under the Mozilla Public License (MPLv2) - -const _converse$env = _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_0__["default"].env, - Strophe = _converse$env.Strophe, - $build = _converse$env.$build, - _ = _converse$env._, - b64_sha1 = _converse$env.b64_sha1; -Strophe.addNamespace('CAPS', "http://jabber.org/protocol/caps"); - -function propertySort(array, property) { - return array.sort((a, b) => { - return a[property] > b[property] ? -1 : 1; - }); -} - -function generateVerificationString(_converse) { - const identities = _converse.api.disco.own.identities.get(), - features = _converse.api.disco.own.features.get(); - - if (identities.length > 1) { - propertySort(identities, "category"); - propertySort(identities, "type"); - propertySort(identities, "lang"); - } - - let S = _.reduce(identities, (result, id) => `${result}${id.category}/${id.type}/${_.get(id, 'lang', '')}/${id.name}<`, ""); - - features.sort(); - S = _.reduce(features, (result, feature) => `${result}${feature}<`, S); - return b64_sha1(S); -} - -function createCapsNode(_converse) { - return $build("c", { - 'xmlns': Strophe.NS.CAPS, - 'hash': "sha-1", - 'node': "https://conversejs.org", - 'ver': generateVerificationString(_converse) - }).nodeTree; -} - -_converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_0__["default"].plugins.add('converse-caps', { - overrides: { - // Overrides mentioned here will be picked up by converse.js's - // plugin architecture they will replace existing methods on the - // relevant objects or classes. - XMPPStatus: { - constructPresence() { - const presence = this.__super__.constructPresence.apply(this, arguments); - - presence.root().cnode(createCapsNode(this.__super__._converse)); - return presence; - } - - } - } -}); - -/***/ }), - /***/ "./src/converse-chatboxviews.js": /*!**************************************!*\ !*** ./src/converse-chatboxviews.js ***! @@ -60503,13 +60430,13 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_1__["default"].plugins "use strict"; __webpack_require__.r(__webpack_exports__); -/* harmony import */ var _converse_headless_converse_mam__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @converse/headless/converse-mam */ "./src/headless/converse-mam.js"); -/* harmony import */ var _converse_headless_converse_ping__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @converse/headless/converse-ping */ "./src/headless/converse-ping.js"); -/* harmony import */ var _converse_headless_converse_pubsub__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @converse/headless/converse-pubsub */ "./src/headless/converse-pubsub.js"); -/* harmony import */ var _converse_headless_converse_vcard__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @converse/headless/converse-vcard */ "./src/headless/converse-vcard.js"); -/* harmony import */ var converse_autocomplete__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! converse-autocomplete */ "./src/converse-autocomplete.js"); -/* harmony import */ var converse_bookmarks__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! converse-bookmarks */ "./src/converse-bookmarks.js"); -/* harmony import */ var converse_caps__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! converse-caps */ "./src/converse-caps.js"); +/* harmony import */ var _converse_headless_converse_caps__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @converse/headless/converse-caps */ "./src/headless/converse-caps.js"); +/* harmony import */ var _converse_headless_converse_mam__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @converse/headless/converse-mam */ "./src/headless/converse-mam.js"); +/* harmony import */ var _converse_headless_converse_ping__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @converse/headless/converse-ping */ "./src/headless/converse-ping.js"); +/* harmony import */ var _converse_headless_converse_pubsub__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @converse/headless/converse-pubsub */ "./src/headless/converse-pubsub.js"); +/* harmony import */ var _converse_headless_converse_vcard__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @converse/headless/converse-vcard */ "./src/headless/converse-vcard.js"); +/* harmony import */ var converse_autocomplete__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! converse-autocomplete */ "./src/converse-autocomplete.js"); +/* harmony import */ var converse_bookmarks__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! converse-bookmarks */ "./src/converse-bookmarks.js"); /* harmony import */ var converse_chatview__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! converse-chatview */ "./src/converse-chatview.js"); /* harmony import */ var converse_controlbox__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! converse-controlbox */ "./src/converse-controlbox.js"); /* harmony import */ var converse_dragresize__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! converse-dragresize */ "./src/converse-dragresize.js"); @@ -60530,6 +60457,8 @@ __webpack_require__.r(__webpack_exports__); * -------------------- * Any of the following components may be removed if they're not needed. */ + // XEP-0115 Entity Capabilities + // XEP-0313 Message Archive Management // XEP-0199 XMPP Ping @@ -60541,8 +60470,6 @@ __webpack_require__.r(__webpack_exports__); // XEP-0048 Bookmarks - // XEP-0115 Entity Capabilities - // Renders standalone chat boxes for single user chat // The control box @@ -60571,7 +60498,7 @@ __webpack_require__.r(__webpack_exports__); /* END: Removable components */ -const WHITELISTED_PLUGINS = ['converse-autocomplete', 'converse-bookmarks', 'converse-caps', 'converse-chatboxviews', 'converse-chatview', 'converse-controlbox', 'converse-dragresize', 'converse-embedded', 'converse-fullscreen', 'converse-headline', 'converse-mam-views', 'converse-message-view', 'converse-minimize', 'converse-modal', 'converse-muc-views', 'converse-notification', 'converse-omemo', 'converse-profile', 'converse-push', 'converse-register', 'converse-roomslist', 'converse-rosterview', 'converse-singleton']; +const WHITELISTED_PLUGINS = ['converse-autocomplete', 'converse-bookmarks', 'converse-chatboxviews', 'converse-chatview', 'converse-controlbox', 'converse-dragresize', 'converse-embedded', 'converse-fullscreen', 'converse-headline', 'converse-mam-views', 'converse-message-view', 'converse-minimize', 'converse-modal', 'converse-muc-views', 'converse-notification', 'converse-omemo', 'converse-profile', 'converse-push', 'converse-register', 'converse-roomslist', 'converse-rosterview', 'converse-singleton']; const initialize = _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_22__["default"].initialize; _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_22__["default"].initialize = function (settings, callback) { @@ -61698,6 +61625,80 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_22__["default"].initia /***/ }), +/***/ "./src/headless/converse-caps.js": +/*!***************************************!*\ + !*** ./src/headless/converse-caps.js ***! + \***************************************/ +/*! no exports provided */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @converse/headless/converse-core */ "./src/headless/converse-core.js"); +// Converse.js +// https://conversejs.org +// +// Copyright (c) 2013-2019, the Converse.js developers +// Licensed under the Mozilla Public License (MPLv2) + +const _converse$env = _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_0__["default"].env, + Strophe = _converse$env.Strophe, + $build = _converse$env.$build, + _ = _converse$env._, + b64_sha1 = _converse$env.b64_sha1; +Strophe.addNamespace('CAPS', "http://jabber.org/protocol/caps"); + +function propertySort(array, property) { + return array.sort((a, b) => { + return a[property] > b[property] ? -1 : 1; + }); +} + +function generateVerificationString(_converse) { + const identities = _converse.api.disco.own.identities.get(), + features = _converse.api.disco.own.features.get(); + + if (identities.length > 1) { + propertySort(identities, "category"); + propertySort(identities, "type"); + propertySort(identities, "lang"); + } + + let S = _.reduce(identities, (result, id) => `${result}${id.category}/${id.type}/${_.get(id, 'lang', '')}/${id.name}<`, ""); + + features.sort(); + S = _.reduce(features, (result, feature) => `${result}${feature}<`, S); + return b64_sha1(S); +} + +function createCapsNode(_converse) { + return $build("c", { + 'xmlns': Strophe.NS.CAPS, + 'hash': "sha-1", + 'node': "https://conversejs.org", + 'ver': generateVerificationString(_converse) + }).nodeTree; +} + +_converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_0__["default"].plugins.add('converse-caps', { + overrides: { + // Overrides mentioned here will be picked up by converse.js's + // plugin architecture they will replace existing methods on the + // relevant objects or classes. + XMPPStatus: { + constructPresence() { + const presence = this.__super__.constructPresence.apply(this, arguments); + + presence.root().cnode(createCapsNode(this.__super__._converse)); + return presence; + } + + } + } +}); + +/***/ }), + /***/ "./src/headless/converse-chatboxes.js": /*!********************************************!*\ !*** ./src/headless/converse-chatboxes.js ***! @@ -63196,7 +63197,7 @@ pluggable_js_dist_pluggable__WEBPACK_IMPORTED_MODULE_8___default.a.enable(_conve // These are just the @converse/headless plugins, for the full converse, // the other plugins are whitelisted in src/converse.js -_converse.core_plugins = ['converse-chatboxes', 'converse-disco', 'converse-mam', 'converse-muc', 'converse-ping', 'converse-pubsub', 'converse-roster', 'converse-vcard']; +_converse.core_plugins = ['converse-caps', 'converse-chatboxes', 'converse-disco', 'converse-mam', 'converse-muc', 'converse-ping', 'converse-pubsub', 'converse-roster', 'converse-vcard']; _converse.keycodes = { TAB: 9, ENTER: 13, diff --git a/src/converse.js b/src/converse.js index 5d38451d1..e0599417e 100644 --- a/src/converse.js +++ b/src/converse.js @@ -2,13 +2,13 @@ * -------------------- * Any of the following components may be removed if they're not needed. */ +import "@converse/headless/converse-caps"; // XEP-0115 Entity Capabilities import "@converse/headless/converse-mam"; // XEP-0313 Message Archive Management import "@converse/headless/converse-ping"; // XEP-0199 XMPP Ping import "@converse/headless/converse-pubsub"; // XEP-0060 PubSub import "@converse/headless/converse-vcard"; // XEP-0054 VCard-temp import "converse-autocomplete"; import "converse-bookmarks"; // XEP-0048 Bookmarks -import "converse-caps"; // XEP-0115 Entity Capabilities import "converse-chatview"; // Renders standalone chat boxes for single user chat import "converse-controlbox"; // The control box import "converse-dragresize"; // Allows chat boxes to be resized by dragging them @@ -31,7 +31,6 @@ import converse from "@converse/headless/converse-core"; const WHITELISTED_PLUGINS = [ 'converse-autocomplete', 'converse-bookmarks', - 'converse-caps', 'converse-chatboxviews', 'converse-chatview', 'converse-controlbox', diff --git a/src/converse-caps.js b/src/headless/converse-caps.js similarity index 100% rename from src/converse-caps.js rename to src/headless/converse-caps.js diff --git a/src/headless/converse-core.js b/src/headless/converse-core.js index a5ae70ee8..648b20f06 100644 --- a/src/headless/converse-core.js +++ b/src/headless/converse-core.js @@ -83,6 +83,7 @@ pluggable.enable(_converse, '_converse', 'pluggable'); // These are just the @converse/headless plugins, for the full converse, // the other plugins are whitelisted in src/converse.js _converse.core_plugins = [ + 'converse-caps', 'converse-chatboxes', 'converse-disco', 'converse-mam', diff --git a/src/headless/dist/converse-headless.js b/src/headless/dist/converse-headless.js index 2d26d97c8..d870993e7 100644 --- a/src/headless/dist/converse-headless.js +++ b/src/headless/dist/converse-headless.js @@ -30205,6 +30205,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_ //# sourceMappingURL=pluggable.js.map + /***/ }), /***/ "./node_modules/process/browser.js": @@ -40146,6 +40147,80 @@ module.exports = function(module) { /***/ }), +/***/ "./src/headless/converse-caps.js": +/*!***************************************!*\ + !*** ./src/headless/converse-caps.js ***! + \***************************************/ +/*! no exports provided */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @converse/headless/converse-core */ "./src/headless/converse-core.js"); +// Converse.js +// https://conversejs.org +// +// Copyright (c) 2013-2019, the Converse.js developers +// Licensed under the Mozilla Public License (MPLv2) + +const _converse$env = _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_0__["default"].env, + Strophe = _converse$env.Strophe, + $build = _converse$env.$build, + _ = _converse$env._, + b64_sha1 = _converse$env.b64_sha1; +Strophe.addNamespace('CAPS', "http://jabber.org/protocol/caps"); + +function propertySort(array, property) { + return array.sort((a, b) => { + return a[property] > b[property] ? -1 : 1; + }); +} + +function generateVerificationString(_converse) { + const identities = _converse.api.disco.own.identities.get(), + features = _converse.api.disco.own.features.get(); + + if (identities.length > 1) { + propertySort(identities, "category"); + propertySort(identities, "type"); + propertySort(identities, "lang"); + } + + let S = _.reduce(identities, (result, id) => `${result}${id.category}/${id.type}/${_.get(id, 'lang', '')}/${id.name}<`, ""); + + features.sort(); + S = _.reduce(features, (result, feature) => `${result}${feature}<`, S); + return b64_sha1(S); +} + +function createCapsNode(_converse) { + return $build("c", { + 'xmlns': Strophe.NS.CAPS, + 'hash': "sha-1", + 'node': "https://conversejs.org", + 'ver': generateVerificationString(_converse) + }).nodeTree; +} + +_converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_0__["default"].plugins.add('converse-caps', { + overrides: { + // Overrides mentioned here will be picked up by converse.js's + // plugin architecture they will replace existing methods on the + // relevant objects or classes. + XMPPStatus: { + constructPresence() { + const presence = this.__super__.constructPresence.apply(this, arguments); + + presence.root().cnode(createCapsNode(this.__super__._converse)); + return presence; + } + + } + } +}); + +/***/ }), + /***/ "./src/headless/converse-chatboxes.js": /*!********************************************!*\ !*** ./src/headless/converse-chatboxes.js ***! @@ -41644,7 +41719,7 @@ pluggable_js_dist_pluggable__WEBPACK_IMPORTED_MODULE_8___default.a.enable(_conve // These are just the @converse/headless plugins, for the full converse, // the other plugins are whitelisted in src/converse.js -_converse.core_plugins = ['converse-chatboxes', 'converse-disco', 'converse-mam', 'converse-muc', 'converse-ping', 'converse-pubsub', 'converse-roster', 'converse-vcard']; +_converse.core_plugins = ['converse-caps', 'converse-chatboxes', 'converse-disco', 'converse-mam', 'converse-muc', 'converse-ping', 'converse-pubsub', 'converse-roster', 'converse-vcard']; _converse.keycodes = { TAB: 9, ENTER: 13, @@ -48491,7 +48566,8 @@ __webpack_require__.r(__webpack_exports__); /* harmony import */ var _converse_ping__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./converse-ping */ "./src/headless/converse-ping.js"); /* harmony import */ var _converse_roster__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./converse-roster */ "./src/headless/converse-roster.js"); /* harmony import */ var _converse_vcard__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./converse-vcard */ "./src/headless/converse-vcard.js"); -/* harmony import */ var _converse_core__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./converse-core */ "./src/headless/converse-core.js"); +/* harmony import */ var _converse_caps__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./converse-caps */ "./src/headless/converse-caps.js"); +/* harmony import */ var _converse_core__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./converse-core */ "./src/headless/converse-core.js"); /* START: Removable components * -------------------- * Any of the following components may be removed if they're not needed. @@ -48512,10 +48588,12 @@ __webpack_require__.r(__webpack_exports__); // XEP-0054 VCard-temp + // XEP-0115 Entity Capabilities + /* END: Removable components */ -/* harmony default export */ __webpack_exports__["default"] = (_converse_core__WEBPACK_IMPORTED_MODULE_8__["default"]); +/* harmony default export */ __webpack_exports__["default"] = (_converse_core__WEBPACK_IMPORTED_MODULE_9__["default"]); /***/ }), diff --git a/src/headless/headless.js b/src/headless/headless.js index e7d99c059..69daa9ca9 100644 --- a/src/headless/headless.js +++ b/src/headless/headless.js @@ -10,6 +10,7 @@ import "./converse-muc"; // XEP-0045 Multi-user chat import "./converse-ping"; // XEP-0199 XMPP Ping import "./converse-roster"; // Contacts Roster import "./converse-vcard"; // XEP-0054 VCard-temp +import "./converse-caps"; // XEP-0115 Entity Capabilities /* END: Removable components */ import converse from "./converse-core";