JC Brand 1 месяц назад
Родитель
Сommit
e9ea3640bf

+ 1 - 0
package-lock.json

@@ -10807,6 +10807,7 @@
       "version": "10.1.7",
       "version": "10.1.7",
       "license": "MPL-2.0",
       "license": "MPL-2.0",
       "dependencies": {
       "dependencies": {
+        "@converse/log": "file:../log",
         "@converse/openpromise": "^0.0.1",
         "@converse/openpromise": "^0.0.1",
         "@converse/skeletor": "conversejs/skeletor#7e1cbeba0161bfe91d709a22deaa70e4daa0cd39",
         "@converse/skeletor": "conversejs/skeletor#7e1cbeba0161bfe91d709a22deaa70e4daa0cd39",
         "dayjs": "^1.11.8",
         "dayjs": "^1.11.8",

+ 1 - 1
package.json

@@ -45,7 +45,7 @@
     "serve-tls": "http-server -S -C certs/chat.example.org.crt -K certs/chat.example.org.key",
     "serve-tls": "http-server -S -C certs/chat.example.org.crt -K certs/chat.example.org.key",
     "devserver": "webpack serve --config webpack/webpack.serve.js",
     "devserver": "webpack serve --config webpack/webpack.serve.js",
     "watch": "webpack --watch --config webpack/webpack.build.js --mode=development",
     "watch": "webpack --watch --config webpack/webpack.build.js --mode=development",
-    "types": "tsc -p ./src/headless/tsconfig.json && tsc",
+    "types": "tsc -p ./src/log/tsconfig.json && tsc -p ./src/headless/tsconfig.json && tsc",
     "check:types": "tsc --noEmit"
     "check:types": "tsc --noEmit"
   },
   },
   "repository": {
   "repository": {

+ 1 - 1
src/headless/index.js

@@ -1,12 +1,12 @@
 import dayjs from 'dayjs';
 import dayjs from 'dayjs';
 import advancedFormat from 'dayjs/plugin/advancedFormat';
 import advancedFormat from 'dayjs/plugin/advancedFormat';
+import log from '@converse/log';
 
 
 dayjs.extend(advancedFormat);
 dayjs.extend(advancedFormat);
 
 
 import { _converse, api, constants as shared_constants, i18n, parsers } from './shared/index.js';
 import { _converse, api, constants as shared_constants, i18n, parsers } from './shared/index.js';
 import u from './utils/index.js';
 import u from './utils/index.js';
 import converse from './shared/api/public.js';
 import converse from './shared/api/public.js';
-import log from './log.js';
 
 
 import BaseMessage from './shared/message.js';
 import BaseMessage from './shared/message.js';
 export { BaseMessage };
 export { BaseMessage };

+ 1 - 1
src/headless/types/index.d.ts

@@ -8,7 +8,7 @@ import { api } from './shared/index.js';
 import converse from './shared/api/public.js';
 import converse from './shared/api/public.js';
 import { _converse } from './shared/index.js';
 import { _converse } from './shared/index.js';
 import { i18n } from './shared/index.js';
 import { i18n } from './shared/index.js';
-import log from './log.js';
+import log from '@converse/log';
 import u from './utils/index.js';
 import u from './utils/index.js';
 export const constants: typeof shared_constants & typeof muc_constants;
 export const constants: typeof shared_constants & typeof muc_constants;
 import { parsers } from './shared/index.js';
 import { parsers } from './shared/index.js';

+ 1 - 1
src/headless/types/plugins/bookmarks/collection.d.ts

@@ -15,7 +15,7 @@ declare class Bookmarks extends Collection {
     /**
     /**
      * @param {import('./types').BookmarkAttrs} attrs
      * @param {import('./types').BookmarkAttrs} attrs
      */
      */
-    setBookmark(attrs: import("./types").BookmarkAttrs, create?: boolean): void;
+    setBookmark(attrs: import("./types").BookmarkAttrs, create?: boolean): any;
     /**
     /**
      * @param {'urn:xmpp:bookmarks:1'|'storage:bookmarks'} node
      * @param {'urn:xmpp:bookmarks:1'|'storage:bookmarks'} node
      * @returns {Stanza|Stanza[]}
      * @returns {Stanza|Stanza[]}

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

@@ -124,7 +124,7 @@ declare const ChatBox_base: {
         sendMarkerForMessage(msg: import("../../index.js").BaseMessage<any>, type?: ("received" | "displayed" | "acknowledged"), force?: boolean): Promise<void>;
         sendMarkerForMessage(msg: import("../../index.js").BaseMessage<any>, type?: ("received" | "displayed" | "acknowledged"), force?: boolean): Promise<void>;
         handleUnreadMessage(message: import("../../index.js").BaseMessage<any>): void;
         handleUnreadMessage(message: import("../../index.js").BaseMessage<any>): void;
         getErrorAttributesForMessage(message: import("../../index.js").BaseMessage<any>, attrs: import("../../shared/types").MessageAttributes): Promise<any>;
         getErrorAttributesForMessage(message: import("../../index.js").BaseMessage<any>, attrs: import("../../shared/types").MessageAttributes): Promise<any>;
-        handleErrorMessageStanza(stanza: Element): Promise<void>;
+        handleErrorMessageStanza(stanza: Element): Promise<any>;
         incrementUnreadMsgsCounter(message: import("../../index.js").BaseMessage<any>): void;
         incrementUnreadMsgsCounter(message: import("../../index.js").BaseMessage<any>): void;
         clearUnreadMsgCounter(): void;
         clearUnreadMsgCounter(): void;
         handleRetraction(attrs: import("../../shared/types").MessageAttributes): Promise<boolean>;
         handleRetraction(attrs: import("../../shared/types").MessageAttributes): Promise<boolean>;
@@ -360,7 +360,7 @@ declare class ChatBox extends ChatBox_base {
     /**
     /**
      * @param {MessageAttributes|StanzaParseError} attrs_or_error
      * @param {MessageAttributes|StanzaParseError} attrs_or_error
      */
      */
-    onMessage(attrs_or_error: import("../../shared/types").MessageAttributes | import("../../shared/errors").StanzaParseError): Promise<void>;
+    onMessage(attrs_or_error: import("../../shared/types").MessageAttributes | import("../../shared/errors").StanzaParseError): Promise<any>;
     /**
     /**
      * @param {import('../roster/presence').default} item
      * @param {import('../roster/presence').default} item
      */
      */

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

@@ -1,4 +1,4 @@
-export function routeToChat(event: any): void;
+export function routeToChat(event: any): any;
 export function onClearSession(): Promise<void>;
 export function onClearSession(): Promise<void>;
 /**
 /**
  * Given a stanza, determine whether it's a new
  * Given a stanza, determine whether it's a new
@@ -12,7 +12,7 @@ export function registerMessageHandlers(): void;
  * Handler method for all incoming single-user chat "message" stanzas.
  * Handler method for all incoming single-user chat "message" stanzas.
  * @param {Element|Builder} stanza
  * @param {Element|Builder} stanza
  */
  */
-export function handleMessageStanza(stanza: Element | Builder): Promise<true | void>;
+export function handleMessageStanza(stanza: Element | Builder): Promise<any>;
 /**
 /**
  * Ask the XMPP server to enable Message Carbons
  * Ask the XMPP server to enable Message Carbons
  * See [XEP-0280](https://xmpp.org/extensions/xep-0280.html#enabling)
  * See [XEP-0280](https://xmpp.org/extensions/xep-0280.html#enabling)

+ 3 - 3
src/headless/types/plugins/muc/muc.d.ts

@@ -124,7 +124,7 @@ declare const MUC_base: {
         sendMarkerForMessage(msg: import("../../shared/message.js").default<any>, type?: ("received" | "displayed" | "acknowledged"), force?: boolean): Promise<void>;
         sendMarkerForMessage(msg: import("../../shared/message.js").default<any>, type?: ("received" | "displayed" | "acknowledged"), force?: boolean): Promise<void>;
         handleUnreadMessage(message: import("../../shared/message.js").default<any>): void;
         handleUnreadMessage(message: import("../../shared/message.js").default<any>): void;
         getErrorAttributesForMessage(message: import("../../shared/message.js").default<any>, attrs: import("../../shared/types").MessageAttributes): Promise<any>;
         getErrorAttributesForMessage(message: import("../../shared/message.js").default<any>, attrs: import("../../shared/types").MessageAttributes): Promise<any>;
-        handleErrorMessageStanza(stanza: Element): Promise<void>;
+        handleErrorMessageStanza(stanza: Element): Promise<any>;
         incrementUnreadMsgsCounter(message: import("../../shared/message.js").default<any>): void;
         incrementUnreadMsgsCounter(message: import("../../shared/message.js").default<any>): void;
         clearUnreadMsgCounter(): void;
         clearUnreadMsgCounter(): void;
         handleRetraction(attrs: import("../../shared/types").MessageAttributes): Promise<boolean>;
         handleRetraction(attrs: import("../../shared/types").MessageAttributes): Promise<boolean>;
@@ -394,7 +394,7 @@ declare class MUC extends MUC_base {
     /**
     /**
      * @param {Element} stanza
      * @param {Element} stanza
      */
      */
-    handleErrorMessageStanza(stanza: Element): Promise<void>;
+    handleErrorMessageStanza(stanza: Element): Promise<any>;
     /**
     /**
      * Handles incoming message stanzas from the service that hosts this MUC
      * Handles incoming message stanzas from the service that hosts this MUC
      * @param {Element} stanza
      * @param {Element} stanza
@@ -835,7 +835,7 @@ declare class MUC extends MUC_base {
      * should be called.
      * should be called.
      * @param {MUCMessageAttributes|StanzaParseError} attrs_or_error - A promise which resolves to the message attributes.
      * @param {MUCMessageAttributes|StanzaParseError} attrs_or_error - A promise which resolves to the message attributes.
      */
      */
-    onMessage(attrs_or_error: import("./types").MUCMessageAttributes | import("../../shared/errors.js").StanzaParseError): Promise<void>;
+    onMessage(attrs_or_error: import("./types").MUCMessageAttributes | import("../../shared/errors.js").StanzaParseError): Promise<any>;
     /**
     /**
      * @param {Element} pres
      * @param {Element} pres
      */
      */

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

@@ -124,7 +124,7 @@ declare const MUCOccupant_base: {
         sendMarkerForMessage(msg: import("../..").BaseMessage<any>, type?: ("received" | "displayed" | "acknowledged"), force?: boolean): Promise<void>;
         sendMarkerForMessage(msg: import("../..").BaseMessage<any>, type?: ("received" | "displayed" | "acknowledged"), force?: boolean): Promise<void>;
         handleUnreadMessage(message: import("../..").BaseMessage<any>): void;
         handleUnreadMessage(message: import("../..").BaseMessage<any>): void;
         getErrorAttributesForMessage(message: import("../..").BaseMessage<any>, attrs: import("../../shared/types").MessageAttributes): Promise<any>;
         getErrorAttributesForMessage(message: import("../..").BaseMessage<any>, attrs: import("../../shared/types").MessageAttributes): Promise<any>;
-        handleErrorMessageStanza(stanza: Element): Promise<void>;
+        handleErrorMessageStanza(stanza: Element): Promise<any>;
         incrementUnreadMsgsCounter(message: import("../..").BaseMessage<any>): void;
         incrementUnreadMsgsCounter(message: import("../..").BaseMessage<any>): void;
         clearUnreadMsgCounter(): void;
         clearUnreadMsgCounter(): void;
         handleRetraction(attrs: import("../../shared/types").MessageAttributes): Promise<boolean>;
         handleRetraction(attrs: import("../../shared/types").MessageAttributes): Promise<boolean>;
@@ -290,7 +290,7 @@ declare class MUCOccupant extends MUCOccupant_base {
      * This method houldn't be called directly, instead {@link MUC#queueMessage} should be called.
      * This method houldn't be called directly, instead {@link MUC#queueMessage} should be called.
      * @param {MessageAttributes|StanzaParseError} attrs_or_error
      * @param {MessageAttributes|StanzaParseError} attrs_or_error
      */
      */
-    onMessage(attrs_or_error: import("../../shared/types").MessageAttributes | import("../../shared/errors").StanzaParseError): Promise<void>;
+    onMessage(attrs_or_error: import("../../shared/types").MessageAttributes | import("../../shared/errors").StanzaParseError): Promise<any>;
     /**
     /**
      * Return roles which may be assigned to this occupant
      * Return roles which may be assigned to this occupant
      * @returns {typeof ROLES} - An array of assignable roles
      * @returns {typeof ROLES} - An array of assignable roles

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

@@ -18,7 +18,7 @@ export function onWindowStateChanged(): Promise<void>;
 /**
 /**
  * @param {Event} [event]
  * @param {Event} [event]
  */
  */
-export function routeToRoom(event?: Event): Promise<void>;
+export function routeToRoom(event?: Event): Promise<any>;
 /**
 /**
  * Opens a groupchat, making sure that certain attributes
  * Opens a groupchat, making sure that certain attributes
  * are correct, for example that the "type" is set to
  * are correct, for example that the "type" is set to

+ 1 - 1
src/headless/types/shared/chatbox.d.ts

@@ -54,7 +54,7 @@ declare const ChatBoxBase_base: {
         sendMarkerForMessage(msg: import("./message.js").default<any>, type?: ("received" | "displayed" | "acknowledged"), force?: boolean): Promise<void>;
         sendMarkerForMessage(msg: import("./message.js").default<any>, type?: ("received" | "displayed" | "acknowledged"), force?: boolean): Promise<void>;
         handleUnreadMessage(message: import("./message.js").default<any>): void;
         handleUnreadMessage(message: import("./message.js").default<any>): void;
         getErrorAttributesForMessage(message: import("./message.js").default<any>, attrs: import("./types.js").MessageAttributes): Promise<any>;
         getErrorAttributesForMessage(message: import("./message.js").default<any>, attrs: import("./types.js").MessageAttributes): Promise<any>;
-        handleErrorMessageStanza(stanza: Element): Promise<void>;
+        handleErrorMessageStanza(stanza: Element): Promise<any>;
         incrementUnreadMsgsCounter(message: import("./message.js").default<any>): void;
         incrementUnreadMsgsCounter(message: import("./message.js").default<any>): void;
         clearUnreadMsgCounter(): void;
         clearUnreadMsgCounter(): void;
         handleRetraction(attrs: import("./types.js").MessageAttributes): Promise<boolean>;
         handleRetraction(attrs: import("./types.js").MessageAttributes): Promise<boolean>;

+ 1 - 1
src/headless/types/shared/connection/index.d.ts

@@ -11,7 +11,7 @@ export class Connection extends Connection_base {
     /** @param {Element} body */
     /** @param {Element} body */
     xmlInput(body: Element): void;
     xmlInput(body: Element): void;
     bind(): Promise<void>;
     bind(): Promise<void>;
-    onDomainDiscovered(response: any): Promise<void>;
+    onDomainDiscovered(response: any): Promise<any>;
     /**
     /**
      * Adds support for XEP-0156 by quering the XMPP server for alternate
      * Adds support for XEP-0156 by quering the XMPP server for alternate
      * connection methods. This allows users to use the websocket or BOSH
      * connection methods. This allows users to use the websocket or BOSH

+ 1 - 1
src/headless/types/shared/model-with-messages.d.ts

@@ -195,7 +195,7 @@ export default function ModelWithMessages<T extends import("./types").ModelExten
         /**
         /**
          * @param {Element} stanza
          * @param {Element} stanza
          */
          */
-        handleErrorMessageStanza(stanza: Element): Promise<void>;
+        handleErrorMessageStanza(stanza: Element): Promise<any>;
         /**
         /**
          * @param {BaseMessage} message
          * @param {BaseMessage} message
          */
          */

+ 1 - 1
src/headless/types/utils/index.d.ts

@@ -23,7 +23,7 @@ declare const _default: {
     shouldCreateMessage: typeof shouldCreateMessage;
     shouldCreateMessage: typeof shouldCreateMessage;
     triggerEvent: typeof triggerEvent;
     triggerEvent: typeof triggerEvent;
     isValidURL(text: string): boolean;
     isValidURL(text: string): boolean;
-    getURI(url: string | promise.getOpenPromise): any;
+    getURI(url: string | log): any;
     checkFileTypes(types: string[], url: string): boolean;
     checkFileTypes(types: string[], url: string): boolean;
     filterQueryParamsFromURL(url: any): any;
     filterQueryParamsFromURL(url: any): any;
     isURLWithImageExtension(url: any): boolean;
     isURLWithImageExtension(url: any): boolean;

+ 1 - 1
src/shared/gif/index.js

@@ -1,4 +1,4 @@
-import { log } from "@converse/headless";
+import log from "@converse/log";
 import { getOpenPromise } from "@converse/openpromise";
 import { getOpenPromise } from "@converse/openpromise";
 import { parseGIF, decompressFrames } from "gifuct-js";
 import { parseGIF, decompressFrames } from "gifuct-js";
 
 

+ 5 - 5
src/shared/texture/component.js

@@ -1,7 +1,7 @@
-import { LitElement } from 'lit';
-import renderTexture from './directive.js';
+import { LitElement } from "lit";
+import renderTexture from "./directive.js";
 
 
-import './texture.scss';
+import "./texture.scss";
 
 
 /**
 /**
  * The Texture custom element allows you to parse transform text into rich DOM elements.
  * The Texture custom element allows you to parse transform text into rich DOM elements.
@@ -28,7 +28,7 @@ export default class Texture extends LitElement {
         };
         };
     }
     }
 
 
-    createRenderRoot () {
+    createRenderRoot() {
         // Render without the shadow DOM
         // Render without the shadow DOM
         return this;
         return this;
     }
     }
@@ -67,4 +67,4 @@ export default class Texture extends LitElement {
     }
     }
 }
 }
 
 
-customElements.define('converse-texture', Texture);
+customElements.define("converse-texture", Texture);

+ 9 - 9
src/shared/texture/constants.js

@@ -1,11 +1,11 @@
-export const bracketing_directives = ['*', '_', '~', '`'];
-export const styling_directives = [...bracketing_directives, '```', '>'];
+export const bracketing_directives = ["*", "_", "~", "`"];
+export const styling_directives = [...bracketing_directives, "```", ">"];
 export const styling_map = {
 export const styling_map = {
-    '*': { 'name': 'strong', 'type': 'span' },
-    '_': { 'name': 'emphasis', 'type': 'span' },
-    '~': { 'name': 'strike', 'type': 'span' },
-    '`': { 'name': 'preformatted', 'type': 'span' },
-    '```': { 'name': 'preformatted_block', 'type': 'block' },
-    '>': { 'name': 'quote', 'type': 'block' },
+    "*": { "name": "strong", "type": "span" },
+    "_": { "name": "emphasis", "type": "span" },
+    "~": { "name": "strike", "type": "span" },
+    "`": { "name": "preformatted", "type": "span" },
+    "```": { "name": "preformatted_block", "type": "block" },
+    ">": { "name": "quote", "type": "block" },
 };
 };
-export const dont_escape = ['_', '>', '`', '~'];
+export const dont_escape = ["_", ">", "`", "~"];

+ 4 - 4
src/shared/texture/directive.js

@@ -1,7 +1,7 @@
-import { html } from 'lit';
-import { until } from 'lit/directives/until.js';
-import { Directive, directive } from 'lit/directive.js';
-import { Texture } from './texture.js';
+import { html } from "lit";
+import { until } from "lit/directives/until.js";
+import { Directive, directive } from "lit/directive.js";
+import { Texture } from "./texture.js";
 
 
 class TextureRenderer {
 class TextureRenderer {
     /**
     /**

+ 37 - 37
src/shared/texture/texture.js

@@ -1,15 +1,15 @@
-import { html } from 'lit';
-import { until } from 'lit/directives/until.js';
-import { Directive, directive } from 'lit/directive.js';
-import { api, u } from '@converse/headless';
-import tplAudio from './templates/audio.js';
-import tplGif from './templates/gif.js';
-import tplImage from './templates/image.js';
-import tplVideo from './templates/video.js';
-import tplSpotify from './templates/spotify.js';
-import { getEmojiMarkup } from '../chat/utils.js';
-import { getHyperlinkTemplate } from '../../utils/html.js';
-import { shouldRenderMediaFromURL } from 'utils/url.js';
+import { html } from "lit";
+import { until } from "lit/directives/until.js";
+import { Directive, directive } from "lit/directive.js";
+import { api, u } from "@converse/headless";
+import tplAudio from "./templates/audio.js";
+import tplGif from "./templates/gif.js";
+import tplImage from "./templates/image.js";
+import tplVideo from "./templates/video.js";
+import tplSpotify from "./templates/spotify.js";
+import { getEmojiMarkup } from "../chat/utils.js";
+import { getHyperlinkTemplate } from "../../utils/html.js";
+import { shouldRenderMediaFromURL } from "utils/url.js";
 import {
 import {
     collapseLineBreaks,
     collapseLineBreaks,
     containsDirectives,
     containsDirectives,
@@ -20,8 +20,8 @@ import {
     isString,
     isString,
     tplMention,
     tplMention,
     tplMentionWithNick,
     tplMentionWithNick,
-} from './utils.js';
-import { styling_map } from './constants.js';
+} from "./utils.js";
+import { styling_map } from "./constants.js";
 
 
 const {
 const {
     convertASCII2Emoji,
     convertASCII2Emoji,
@@ -111,14 +111,14 @@ export class Texture extends String {
      */
      */
     shouldRenderMedia(url, type) {
     shouldRenderMedia(url, type) {
         let override;
         let override;
-        if (type === 'image') {
+        if (type === "image") {
             override = this.show_images;
             override = this.show_images;
-        } else if (type === 'audio') {
+        } else if (type === "audio") {
             override = this.embed_audio;
             override = this.embed_audio;
-        } else if (type === 'video') {
+        } else if (type === "video") {
             override = this.embed_videos;
             override = this.embed_videos;
         }
         }
-        if (typeof override === 'boolean') {
+        if (typeof override === "boolean") {
             return override;
             return override;
         }
         }
         return shouldRenderMediaFromURL(url, type);
         return shouldRenderMediaFromURL(url, type);
@@ -133,9 +133,9 @@ export class Texture extends String {
         const url_text = url_obj.url;
         const url_text = url_obj.url;
         const filtered_url = filterQueryParamsFromURL(url_text);
         const filtered_url = filterQueryParamsFromURL(url_text);
         let template;
         let template;
-        if (isGIFURL(url_text) && this.shouldRenderMedia(url_text, 'image')) {
+        if (isGIFURL(url_text) && this.shouldRenderMedia(url_text, "image")) {
             template = tplGif(filtered_url, this.hide_media_urls);
             template = tplGif(filtered_url, this.hide_media_urls);
-        } else if (isImageURL(url_text) && this.shouldRenderMedia(url_text, 'image')) {
+        } else if (isImageURL(url_text) && this.shouldRenderMedia(url_text, "image")) {
             template = tplImage({
             template = tplImage({
                 src: filtered_url,
                 src: filtered_url,
                 // XXX: bit of an abuse of `hide_media_urls`, might want a dedicated option here
                 // XXX: bit of an abuse of `hide_media_urls`, might want a dedicated option here
@@ -143,18 +143,18 @@ export class Texture extends String {
                 onClick: this.onImgClick,
                 onClick: this.onImgClick,
                 onLoad: this.onImgLoad,
                 onLoad: this.onImgLoad,
             });
             });
-        } else if (isVideoURL(url_text) && this.shouldRenderMedia(url_text, 'video')) {
+        } else if (isVideoURL(url_text) && this.shouldRenderMedia(url_text, "video")) {
             template = tplVideo(filtered_url, this.hide_media_urls);
             template = tplVideo(filtered_url, this.hide_media_urls);
-        } else if (isAudioURL(url_text) && this.shouldRenderMedia(url_text, 'audio')) {
+        } else if (isAudioURL(url_text) && this.shouldRenderMedia(url_text, "audio")) {
             template = tplAudio(filtered_url, this.hide_media_urls);
             template = tplAudio(filtered_url, this.hide_media_urls);
-        } else if (api.settings.get('embed_3rd_party_media_players') && isSpotifyTrack(url_text)) {
-            const song_id = url_text.split('/track/')[1];
+        } else if (api.settings.get("embed_3rd_party_media_players") && isSpotifyTrack(url_text)) {
+            const song_id = url_text.split("/track/")[1];
             template = tplSpotify(song_id, url_text, this.hide_media_urls);
             template = tplSpotify(song_id, url_text, this.hide_media_urls);
         } else {
         } else {
-            if (this.shouldRenderMedia(url_text, 'audio') && api.settings.get('fetch_url_headers')) {
+            if (this.shouldRenderMedia(url_text, "audio") && api.settings.get("fetch_url_headers")) {
                 const headers = await getHeaders(url_text);
                 const headers = await getHeaders(url_text);
-                if (headers?.get('content-type')?.startsWith('audio')) {
-                    template = tplAudio(filtered_url, this.hide_media_urls, headers.get('Icy-Name'));
+                if (headers?.get("content-type")?.startsWith("audio")) {
+                    template = tplAudio(filtered_url, this.hide_media_urls, headers.get("Icy-Name"));
                 }
                 }
             }
             }
         }
         }
@@ -195,7 +195,7 @@ export class Texture extends String {
             this.addTemplateResult(
             this.addTemplateResult(
                 m.index + offset,
                 m.index + offset,
                 m.index + m[0].length + offset,
                 m.index + m[0].length + offset,
-                getHyperlinkTemplate(m[0].replace(regex, api.settings.get('geouri_replacement')))
+                getHyperlinkTemplate(m[0].replace(regex, api.settings.get("geouri_replacement")))
             );
             );
         }
         }
     }
     }
@@ -252,7 +252,7 @@ export class Texture extends String {
 
 
         const references = [];
         const references = [];
         const mention_ranges = this.mentions.map((m) =>
         const mention_ranges = this.mentions.map((m) =>
-            Array.from({ 'length': Number(m.end) }, (_, i) => Number(m.begin) + i)
+            Array.from({ "length": Number(m.end) }, (_, i) => Number(m.begin) + i)
         );
         );
         let i = 0;
         let i = 0;
         while (i < this.length) {
         while (i < this.length) {
@@ -268,8 +268,8 @@ export class Texture extends String {
                 const is_quote = isQuoteDirective(d);
                 const is_quote = isQuoteDirective(d);
                 const end = i + length;
                 const end = i + length;
                 const slice_end = is_quote ? end : end - d.length;
                 const slice_end = is_quote ? end : end - d.length;
-                let slice_begin = d === '```' ? i + d.length + 1 : i + d.length;
-                if (is_quote && this[slice_begin] === ' ') {
+                let slice_begin = d === "```" ? i + d.length + 1 : i + d.length;
+                if (is_quote && this[slice_begin] === " ") {
                     // Trim leading space inside codeblock
                     // Trim leading space inside codeblock
                     slice_begin += 1;
                     slice_begin += 1;
                 }
                 }
@@ -329,7 +329,7 @@ export class Texture extends String {
          *  add TemplateResult objects meant to render rich parts of the message.
          *  add TemplateResult objects meant to render rich parts of the message.
          * @example _converse.api.listen.on('beforeMessageBodyTransformed', (view, text) => { ... });
          * @example _converse.api.listen.on('beforeMessageBodyTransformed', (view, text) => { ... });
          */
          */
-        await api.trigger('beforeMessageBodyTransformed', this, { synchronous: true });
+        await api.trigger("beforeMessageBodyTransformed", this, { synchronous: true });
 
 
         this.render_styling && this.addStyling();
         this.render_styling && this.addStyling();
         await this.addAnnotations(this.addMentions);
         await this.addAnnotations(this.addMentions);
@@ -348,7 +348,7 @@ export class Texture extends String {
          *  add TemplateResult objects meant to render rich parts of the message.
          *  add TemplateResult objects meant to render rich parts of the message.
          * @example _converse.api.listen.on('afterMessageBodyTransformed', (view, text) => { ... });
          * @example _converse.api.listen.on('afterMessageBodyTransformed', (view, text) => { ... });
          */
          */
-        await api.trigger('afterMessageBodyTransformed', this, { synchronous: true });
+        await api.trigger("afterMessageBodyTransformed", this, { synchronous: true });
 
 
         this.payload = this.marshall();
         this.payload = this.marshall();
         this.options.show_me_message && this.trimMeMessage();
         this.options.show_me_message && this.trimMeMessage();
@@ -378,7 +378,7 @@ export class Texture extends String {
         if (!text) {
         if (!text) {
             return false;
             return false;
         }
         }
-        return text.startsWith('/me ');
+        return text.startsWith("/me ");
     }
     }
 
 
     /**
     /**
@@ -424,7 +424,7 @@ class StylingDirective extends Directive {
         const t = new Texture(
         const t = new Texture(
             txt,
             txt,
             offset,
             offset,
-            Object.assign(options, { 'show_images': false, 'embed_videos': false, 'embed_audio': false })
+            Object.assign(options, { "show_images": false, "embed_videos": false, "embed_audio": false })
         );
         );
         return html`${until(StylingDirective.transform(t), html`${t}`)}`;
         return html`${until(StylingDirective.transform(t), html`${t}`)}`;
     }
     }
@@ -459,9 +459,9 @@ export function getDirectiveTemplate(d, text, offset, options) {
             // This big [] corresponds to \s without newlines, to avoid issues when the > is the last character of the line
             // This big [] corresponds to \s without newlines, to avoid issues when the > is the last character of the line
             .replace(
             .replace(
                 /\n\u200B*>[ \f\r\t\v\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]?/g,
                 /\n\u200B*>[ \f\r\t\v\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]?/g,
-                (m) => `\n${'\u200B'.repeat(m.length - 1)}`
+                (m) => `\n${"\u200B".repeat(m.length - 1)}`
             )
             )
-            .replace(/\n$/, ''); // Trim line-break at the end
+            .replace(/\n$/, ""); // Trim line-break at the end
         return template(newtext, offset, options);
         return template(newtext, offset, options);
     } else {
     } else {
         return template(text, offset, options);
         return template(text, offset, options);

+ 13 - 14
src/shared/texture/utils.js

@@ -1,12 +1,12 @@
-import { html } from 'lit';
-import { bracketing_directives, dont_escape, styling_directives, styling_map } from './constants';
+import { html } from "lit";
+import { bracketing_directives, dont_escape, styling_directives, styling_map } from "./constants";
 
 
 /**
 /**
  * @param {any} s
  * @param {any} s
  * @returns {boolean} - Returns true if the input is a string, otherwise false.
  * @returns {boolean} - Returns true if the input is a string, otherwise false.
  */
  */
 export function isString(s) {
 export function isString(s) {
-    return typeof s === 'string';
+    return typeof s === "string";
 }
 }
 
 
 /**
 /**
@@ -16,7 +16,7 @@ export function isString(s) {
 export function isSpotifyTrack(url) {
 export function isSpotifyTrack(url) {
     try {
     try {
         const { hostname, pathname } = new URL(url);
         const { hostname, pathname } = new URL(url);
-        return hostname === 'open.spotify.com' && pathname.startsWith('/track/');
+        return hostname === "open.spotify.com" && pathname.startsWith("/track/");
     } catch (e) {
     } catch (e) {
         console.debug(`Could not create URL object from ${url}`);
         console.debug(`Could not create URL object from ${url}`);
         return false;
         return false;
@@ -29,7 +29,7 @@ export function isSpotifyTrack(url) {
  */
  */
 export async function getHeaders(url) {
 export async function getHeaders(url) {
     try {
     try {
-        const response = await fetch(url, { method: 'HEAD' });
+        const response = await fetch(url, { method: "HEAD" });
         return response.headers;
         return response.headers;
     } catch (e) {
     } catch (e) {
         console.debug(`Error calling HEAD on url ${url}: ${e}`);
         console.debug(`Error calling HEAD on url ${url}: ${e}`);
@@ -37,7 +37,6 @@ export async function getHeaders(url) {
     }
     }
 }
 }
 
 
-
 /**
 /**
  * We don't render more than two line-breaks, replace extra line-breaks with
  * We don't render more than two line-breaks, replace extra line-breaks with
  * the zero-width whitespace character
  * the zero-width whitespace character
@@ -47,7 +46,7 @@ export async function getHeaders(url) {
  * @param {string} text
  * @param {string} text
  */
  */
 export function collapseLineBreaks(text) {
 export function collapseLineBreaks(text) {
-    return text.replace(/\n(\u200B*\n)+/g, (m) => `\n${'\u200B'.repeat(m.length - 2)}\n`);
+    return text.replace(/\n(\u200B*\n)+/g, (m) => `\n${"\u200B".repeat(m.length - 2)}\n`);
 }
 }
 
 
 export const tplMentionWithNick = (o) =>
 export const tplMentionWithNick = (o) =>
@@ -69,12 +68,12 @@ function isValidDirective(d, text, i, opening) {
     // Ignore directives that are parts of words
     // Ignore directives that are parts of words
     // More info on the Regexes used here: https://javascript.info/regexp-unicode#unicode-properties-p
     // More info on the Regexes used here: https://javascript.info/regexp-unicode#unicode-properties-p
     if (opening) {
     if (opening) {
-        const regex = RegExp(dont_escape.includes(d) ? `^(\\p{L}|\\p{N})${d}` : `^(\\p{L}|\\p{N})\\${d}`, 'u');
+        const regex = RegExp(dont_escape.includes(d) ? `^(\\p{L}|\\p{N})${d}` : `^(\\p{L}|\\p{N})\\${d}`, "u");
         if (i > 1 && regex.test(text.slice(i - 1))) {
         if (i > 1 && regex.test(text.slice(i - 1))) {
             return false;
             return false;
         }
         }
         const is_quote = isQuoteDirective(d);
         const is_quote = isQuoteDirective(d);
-        if (is_quote && i > 0 && text[i - 1] !== '\n') {
+        if (is_quote && i > 0 && text[i - 1] !== "\n") {
             // Quote directives must be on newlines
             // Quote directives must be on newlines
             return false;
             return false;
         } else if (bracketing_directives.includes(d) && text[i + 1] === d) {
         } else if (bracketing_directives.includes(d) && text[i + 1] === d) {
@@ -82,7 +81,7 @@ function isValidDirective(d, text, i, opening) {
             return false;
             return false;
         }
         }
     } else {
     } else {
-        const regex = RegExp(dont_escape.includes(d) ? `^${d}(\\p{L}|\\p{N})` : `^\\${d}(\\p{L}|\\p{N})`, 'u');
+        const regex = RegExp(dont_escape.includes(d) ? `^${d}(\\p{L}|\\p{N})` : `^\\${d}(\\p{L}|\\p{N})`, "u");
         if (i < text.length - 1 && regex.test(text.slice(i))) {
         if (i < text.length - 1 && regex.test(text.slice(i))) {
             return false;
             return false;
         }
         }
@@ -106,7 +105,7 @@ function getDirective(text, i, opening = true) {
 
 
     if (
     if (
         /(^```[\s,\u200B]*\n)|(^```[\s,\u200B]*$)/.test(text.slice(i)) &&
         /(^```[\s,\u200B]*\n)|(^```[\s,\u200B]*$)/.test(text.slice(i)) &&
-        (i === 0 || text[i - 1] === '>' || /\n\u200B{0,2}$/.test(text.slice(0, i)))
+        (i === 0 || text[i - 1] === ">" || /\n\u200B{0,2}$/.test(text.slice(0, i)))
     ) {
     ) {
         d = text.slice(i, i + 3);
         d = text.slice(i, i + 3);
     } else if (styling_directives.includes(text.slice(i, i + 1))) {
     } else if (styling_directives.includes(text.slice(i, i + 1))) {
@@ -147,8 +146,8 @@ function getDirectiveLength(d, text, i) {
             .split(/\n\u200B*[^>\u200B]/)
             .split(/\n\u200B*[^>\u200B]/)
             .shift().length;
             .shift().length;
         return i - begin;
         return i - begin;
-    } else if (styling_map[d].type === 'span') {
-        const line = text.slice(i).split('\n').shift();
+    } else if (styling_map[d].type === "span") {
+        const line = text.slice(i).split("\n").shift();
         let j = 0;
         let j = 0;
         let idx = line.indexOf(d);
         let idx = line.indexOf(d);
         while (idx !== -1) {
         while (idx !== -1) {
@@ -177,7 +176,7 @@ function getDirectiveLength(d, text, i) {
  * @param {string} d
  * @param {string} d
  */
  */
 export function isQuoteDirective(d) {
 export function isQuoteDirective(d) {
-    return ['>', '&gt;'].includes(d);
+    return [">", "&gt;"].includes(d);
 }
 }
 
 
 /**
 /**

+ 1 - 1
src/types/shared/texture/component.d.ts

@@ -63,5 +63,5 @@ export default class Texture extends LitElement {
         };
         };
     }>;
     }>;
 }
 }
-import { LitElement } from 'lit';
+import { LitElement } from "lit";
 //# sourceMappingURL=component.d.ts.map
 //# sourceMappingURL=component.d.ts.map

+ 5 - 5
src/types/shared/texture/constants.d.ts

@@ -1,7 +1,7 @@
 export const bracketing_directives: string[];
 export const bracketing_directives: string[];
 export const styling_directives: string[];
 export const styling_directives: string[];
 export const styling_map: {
 export const styling_map: {
-    '*': {
+    "*": {
         name: string;
         name: string;
         type: string;
         type: string;
     };
     };
@@ -9,19 +9,19 @@ export const styling_map: {
         name: string;
         name: string;
         type: string;
         type: string;
     };
     };
-    '~': {
+    "~": {
         name: string;
         name: string;
         type: string;
         type: string;
     };
     };
-    '`': {
+    "`": {
         name: string;
         name: string;
         type: string;
         type: string;
     };
     };
-    '```': {
+    "```": {
         name: string;
         name: string;
         type: string;
         type: string;
     };
     };
-    '>': {
+    ">": {
         name: string;
         name: string;
         type: string;
         type: string;
     };
     };

+ 1 - 1
src/types/shared/texture/directive.d.ts

@@ -9,5 +9,5 @@ declare class TextureDirective extends Directive {
      */
      */
     render(text: string, offset: number, options: object, callback?: Function): import("lit").TemplateResult<1>;
     render(text: string, offset: number, options: object, callback?: Function): import("lit").TemplateResult<1>;
 }
 }
-import { Directive } from 'lit/directive.js';
+import { Directive } from "lit/directive.js";
 //# sourceMappingURL=directive.d.ts.map
 //# sourceMappingURL=directive.d.ts.map