Don't import Strophe directly from the view layer, as this apparently
causes Strophe to be bundled twice.

Do the same with sizzle and install it as part of headless.

Update automatic package dependencies and fix failing test due to that
update.
This commit is contained in:
JC Brand 2021-02-24 08:05:39 +01:00
parent 3f342652d0
commit 0777bd22b2
12 changed files with 3772 additions and 8367 deletions

12057
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -117,7 +117,6 @@
"run-headless-chromium": "^0.1.1",
"sass-loader": "^8.0.2",
"sinon": "^9.0.2",
"sizzle": "^2.3.5",
"style-loader": "^0.23.1",
"urijs": "^1.19.2",
"webpack": "^4.43.0",

View File

@ -283,19 +283,20 @@ describe("The 'Add Contact' widget", function () {
await mock.waitForRoster(_converse, 'all', 0);
const xhr = {
'open': function open () {},
'send': function () {
xhr.responseText = JSON.stringify([
class MockXHR extends XMLHttpRequest {
open () {} // eslint-disable-line
responseText = ''
send () {
this.responseText = JSON.stringify([
{"jid": "marty@mcfly.net", "fullname": "Marty McFly"},
{"jid": "doc@brown.com", "fullname": "Doc Brown"}
]);
xhr.onload();
this.onload();
}
};
}
const XMLHttpRequestBackup = window.XMLHttpRequest;
window.XMLHttpRequest = jasmine.createSpy('XMLHttpRequest');
XMLHttpRequest.and.callFake(() => xhr);
window.XMLHttpRequest = MockXHR;
const cbview = _converse.chatboxviews.get('controlbox');
cbview.el.querySelector('.add-contact').click()
@ -340,36 +341,37 @@ describe("The 'Add Contact' widget", function () {
await mock.waitForRoster(_converse, 'all');
await mock.openControlBox(_converse);
var modal;
const xhr = {
'open': function open () {},
'send': function () {
class MockXHR extends XMLHttpRequest {
open () {} // eslint-disable-line
responseText = ''
send () {
const value = modal.el.querySelector('input[name="name"]').value;
if (value === 'existing') {
const contact_jid = mock.cur_names[0].replace(/ /g,'.').toLowerCase() + '@montague.lit';
xhr.responseText = JSON.stringify([{"jid": contact_jid, "fullname": mock.cur_names[0]}]);
this.responseText = JSON.stringify([{"jid": contact_jid, "fullname": mock.cur_names[0]}]);
} else if (value === 'romeo') {
xhr.responseText = JSON.stringify([{"jid": "romeo@montague.lit", "fullname": "Romeo Montague"}]);
this.responseText = JSON.stringify([{"jid": "romeo@montague.lit", "fullname": "Romeo Montague"}]);
} else if (value === 'ambiguous') {
xhr.responseText = JSON.stringify([
this.responseText = JSON.stringify([
{"jid": "marty@mcfly.net", "fullname": "Marty McFly"},
{"jid": "doc@brown.com", "fullname": "Doc Brown"}
]);
} else if (value === 'insufficient') {
xhr.responseText = JSON.stringify([]);
this.responseText = JSON.stringify([]);
} else {
xhr.responseText = JSON.stringify([{"jid": "marty@mcfly.net", "fullname": "Marty McFly"}]);
this.responseText = JSON.stringify([{"jid": "marty@mcfly.net", "fullname": "Marty McFly"}]);
}
xhr.onload();
this.onload();
}
};
}
const XMLHttpRequestBackup = window.XMLHttpRequest;
window.XMLHttpRequest = jasmine.createSpy('XMLHttpRequest');
XMLHttpRequest.and.callFake(() => xhr);
window.XMLHttpRequest = MockXHR;
const cbview = _converse.chatboxviews.get('controlbox');
cbview.el.querySelector('.add-contact').click()
modal = _converse.rosterview.add_contact_modal;
const modal = _converse.rosterview.add_contact_modal;
await u.waitUntil(() => u.isVisible(modal.el), 1000);
expect(modal.jid_auto_complete).toBe(undefined);

View File

@ -1,13 +1,12 @@
import "./autocomplete.js"
import log from "@converse/headless/log";
import sizzle from "sizzle";
import { CustomElement } from './element.js';
import { __ } from '../i18n';
import { __ } from 'i18n';
import { api, converse } from "@converse/headless/converse-core";
import { html } from "lit-html";
import { unsafeHTML } from 'lit-html/directives/unsafe-html.js';
const { Strophe, $iq } = converse.env;
const { Strophe, $iq, sizzle } = converse.env;
const u = converse.env.utils;

View File

@ -1,9 +1,10 @@
import sizzle from 'sizzle';
import { CustomElement } from './element.js';
import { _converse, converse, api } from "@converse/headless/converse-core";
import { html } from "lit-element";
import { tpl_all_emojis, tpl_search_results } from "../templates/emoji_picker.js";
const { sizzle } = converse.env;
export default class EmojiPickerContent extends CustomElement {
static get properties () {

View File

@ -9,7 +9,6 @@ import "converse-modal";
import UserSettingsModal from "modals/user-settings";
import bootstrap from "bootstrap.native";
import log from "@converse/headless/log";
import sizzle from 'sizzle';
import tpl_chat_status_modal from "templates/chat_status_modal";
import tpl_profile from "templates/profile.js";
import tpl_profile_modal from "templates/profile_modal";
@ -17,7 +16,7 @@ import { BootstrapModal } from "./converse-modal.js";
import { __ } from './i18n';
import { _converse, api, converse } from "@converse/headless/converse-core";
const u = converse.env.utils;
const { sizzle, u } = converse.env;
converse.plugins.add('converse-profile', {

View File

@ -42,6 +42,7 @@
"localforage-webextensionstorage-driver": "^2.0.0",
"lodash-es": "^4.17.15",
"pluggable.js": "2.0.1",
"sizzle": "^2.3.5",
"sprintf-js": "^1.1.2",
"strophe.js": "1.4.1"
}

View File

@ -1,10 +1,9 @@
import tpl_add_chatroom_modal from "templates/add_chatroom_modal.js";
import { BootstrapModal } from "../converse-modal.js";
import { Strophe } from 'strophe.js/src/strophe';
import { __ } from '../i18n';
import { __ } from 'i18n';
import { _converse, api, converse } from "@converse/headless/converse-core";
const u = converse.env.utils;
const { u, Strophe } = converse.env;
export default BootstrapModal.extend({

View File

@ -1,13 +1,11 @@
import log from "@converse/headless/log";
import sizzle from "sizzle";
import tpl_moderator_tools_modal from "../templates/moderator_tools_modal.js";
import { AFFILIATIONS, ROLES } from "@converse/headless/converse-muc.js";
import { BootstrapModal } from "../converse-modal.js";
import { __ } from '../i18n';
import { api, converse } from "@converse/headless/converse-core";
const { Strophe } = converse.env;
const u = converse.env.utils;
const { Strophe, sizzle, u } = converse.env;
let _converse;

View File

@ -2,10 +2,9 @@ import { BootstrapModal } from "../converse-modal.js";
import { __ } from '../i18n';
import { api, converse } from "@converse/headless/converse-core";
import log from "@converse/headless/log";
import sizzle from "sizzle";
import tpl_muc_commands_modal from "../templates/muc_commands_modal.js";
const { Strophe, $iq } = converse.env;
const { Strophe, $iq, sizzle } = converse.env;
const u = converse.env.utils;

View File

@ -1,16 +1,14 @@
import log from "@converse/headless/log";
import sizzle from 'sizzle';
import st from "@converse/headless/utils/stanza";
import tpl_list_chatrooms_modal from "templates/list_chatrooms_modal.js";
import tpl_room_description from "templates/room_description.html";
import tpl_spinner from "templates/spinner.js";
import { BootstrapModal } from "../converse-modal.js";
import { Strophe, $iq } from 'strophe.js/src/strophe';
import { __ } from '../i18n';
import { __ } from 'i18n';
import { _converse, api, converse } from "@converse/headless/converse-core";
import { head } from "lodash-es";
const u = converse.env.utils;
const { u, Strophe, $iq, sizzle } = converse.env;
/* Insert groupchat info (based on returned #disco IQ stanza)

View File

@ -5,7 +5,6 @@
*/
import URI from "urijs";
import log from '@converse/headless/log';
import sizzle from "sizzle";
import tpl_audio from "../templates/audio.js";
import tpl_file from "../templates/file.js";
import tpl_form_captcha from "../templates/form_captcha.html";
@ -19,10 +18,12 @@ import tpl_image from "../templates/image.js";
import tpl_select_option from "../templates/select_option.html";
import tpl_video from "../templates/video.js";
import u from "../headless/utils/core";
import { api } from "@converse/headless/converse-core";
import { api, converse } from "@converse/headless/converse-core";
import { html, render } from "lit-html";
import { isFunction } from "lodash-es";
const { sizzle } = converse.env;
const APPROVED_URL_PROTOCOLS = ['http', 'https', 'xmpp', 'mailto'];
function getAutoCompleteProperty (name, options) {