diff options
author | RaindropsSys <contact@minteck.org> | 2023-04-24 14:03:36 +0200 |
---|---|---|
committer | RaindropsSys <contact@minteck.org> | 2023-04-24 14:03:36 +0200 |
commit | 633c92eae865e957121e08de634aeee11a8b3992 (patch) | |
tree | 09d881bee1dae0b6eee49db1dfaf0f500240606c /includes/external/matrix/node_modules/matrix-events-sdk/lib/events | |
parent | c4657e4509733699c0f26a3c900bab47e915d5a0 (diff) | |
download | pluralconnect-633c92eae865e957121e08de634aeee11a8b3992.tar.gz pluralconnect-633c92eae865e957121e08de634aeee11a8b3992.tar.bz2 pluralconnect-633c92eae865e957121e08de634aeee11a8b3992.zip |
Updated 18 files, added 1692 files and deleted includes/system/compare.inc (automated)
Diffstat (limited to 'includes/external/matrix/node_modules/matrix-events-sdk/lib/events')
20 files changed, 1753 insertions, 0 deletions
diff --git a/includes/external/matrix/node_modules/matrix-events-sdk/lib/events/EmoteEvent.d.ts b/includes/external/matrix/node_modules/matrix-events-sdk/lib/events/EmoteEvent.d.ts new file mode 100644 index 0000000..9fc0e91 --- /dev/null +++ b/includes/external/matrix/node_modules/matrix-events-sdk/lib/events/EmoteEvent.d.ts @@ -0,0 +1,21 @@ +import { MessageEvent } from "./MessageEvent"; +import { IPartialEvent } from "../IPartialEvent"; +import { M_EMOTE_EVENT_CONTENT } from "./message_types"; +import { EventType } from "../utility/events"; +/** + * Represents an emote. This is essentially a MessageEvent with + * emote characteristics considered. + */ +export declare class EmoteEvent extends MessageEvent { + constructor(wireFormat: IPartialEvent<M_EMOTE_EVENT_CONTENT>); + get isEmote(): boolean; + isEquivalentTo(primaryEventType: EventType): boolean; + serialize(): IPartialEvent<object>; + /** + * Creates a new EmoteEvent from text and HTML. + * @param {string} text The text. + * @param {string} html Optional HTML. + * @returns {MessageEvent} The representative message event. + */ + static from(text: string, html?: string): EmoteEvent; +} diff --git a/includes/external/matrix/node_modules/matrix-events-sdk/lib/events/EmoteEvent.js b/includes/external/matrix/node_modules/matrix-events-sdk/lib/events/EmoteEvent.js new file mode 100644 index 0000000..1b1a2f2 --- /dev/null +++ b/includes/external/matrix/node_modules/matrix-events-sdk/lib/events/EmoteEvent.js @@ -0,0 +1,99 @@ +"use strict"; + +function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.EmoteEvent = void 0; + +var _MessageEvent2 = require("./MessageEvent"); + +var _message_types = require("./message_types"); + +var _events = require("../utility/events"); + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } + +function _get() { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(arguments.length < 3 ? target : receiver); } return desc.value; }; } return _get.apply(this, arguments); } + +function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +// Emote events are just decorated message events + +/** + * Represents an emote. This is essentially a MessageEvent with + * emote characteristics considered. + */ +var EmoteEvent = /*#__PURE__*/function (_MessageEvent) { + _inherits(EmoteEvent, _MessageEvent); + + var _super = _createSuper(EmoteEvent); + + function EmoteEvent(wireFormat) { + _classCallCheck(this, EmoteEvent); + + return _super.call(this, wireFormat); + } + + _createClass(EmoteEvent, [{ + key: "isEmote", + get: function get() { + return true; // override + } + }, { + key: "isEquivalentTo", + value: function isEquivalentTo(primaryEventType) { + return (0, _events.isEventTypeSame)(primaryEventType, _message_types.M_EMOTE) || _get(_getPrototypeOf(EmoteEvent.prototype), "isEquivalentTo", this).call(this, primaryEventType); + } + }, { + key: "serialize", + value: function serialize() { + var message = _get(_getPrototypeOf(EmoteEvent.prototype), "serialize", this).call(this); + + message.content['msgtype'] = "m.emote"; + return message; + } + /** + * Creates a new EmoteEvent from text and HTML. + * @param {string} text The text. + * @param {string} html Optional HTML. + * @returns {MessageEvent} The representative message event. + */ + + }], [{ + key: "from", + value: function from(text, html) { + var _content; + + return new EmoteEvent({ + type: _message_types.M_EMOTE.name, + content: (_content = {}, _defineProperty(_content, _message_types.M_TEXT.name, text), _defineProperty(_content, _message_types.M_HTML.name, html), _content) + }); + } + }]); + + return EmoteEvent; +}(_MessageEvent2.MessageEvent); + +exports.EmoteEvent = EmoteEvent;
\ No newline at end of file diff --git a/includes/external/matrix/node_modules/matrix-events-sdk/lib/events/ExtensibleEvent.d.ts b/includes/external/matrix/node_modules/matrix-events-sdk/lib/events/ExtensibleEvent.d.ts new file mode 100644 index 0000000..a82f967 --- /dev/null +++ b/includes/external/matrix/node_modules/matrix-events-sdk/lib/events/ExtensibleEvent.d.ts @@ -0,0 +1,38 @@ +import { IPartialEvent } from "../IPartialEvent"; +import { EventType } from "../utility/events"; +/** + * Represents an Extensible Event in Matrix. + */ +export declare abstract class ExtensibleEvent<TContent extends object = object> { + readonly wireFormat: IPartialEvent<TContent>; + protected constructor(wireFormat: IPartialEvent<TContent>); + /** + * Shortcut to wireFormat.content + */ + get wireContent(): TContent; + /** + * Serializes the event into a format which can be used to send the + * event to the room. + * @returns {IPartialEvent<object>} The serialized event. + */ + abstract serialize(): IPartialEvent<object>; + /** + * Determines if this event is equivalent to the provided event type. + * This is recommended over `instanceof` checks due to issues in the JS + * runtime (and layering of dependencies in some projects). + * + * Implementations should pass this check off to their super classes + * if their own checks fail. Some primary implementations do not extend + * fallback classes given they support the primary type first. Thus, + * those classes may return false if asked about their fallback + * representation. + * + * Note that this only checks primary event types: legacy events, like + * m.room.message, should/will fail this check. + * @param {EventType} primaryEventType The (potentially namespaced) event + * type. + * @returns {boolean} True if this event *could* be represented as the + * given type. + */ + abstract isEquivalentTo(primaryEventType: EventType): boolean; +} diff --git a/includes/external/matrix/node_modules/matrix-events-sdk/lib/events/ExtensibleEvent.js b/includes/external/matrix/node_modules/matrix-events-sdk/lib/events/ExtensibleEvent.js new file mode 100644 index 0000000..e7959d0 --- /dev/null +++ b/includes/external/matrix/node_modules/matrix-events-sdk/lib/events/ExtensibleEvent.js @@ -0,0 +1,60 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.ExtensibleEvent = void 0; + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } + +/* +Copyright 2021 - 2022 The Matrix.org Foundation C.I.C. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +/** + * Represents an Extensible Event in Matrix. + */ +var ExtensibleEvent = /*#__PURE__*/function () { + function ExtensibleEvent(wireFormat) { + _classCallCheck(this, ExtensibleEvent); + + this.wireFormat = wireFormat; + } + /** + * Shortcut to wireFormat.content + */ + + + _createClass(ExtensibleEvent, [{ + key: "wireContent", + get: function get() { + return this.wireFormat.content; + } + /** + * Serializes the event into a format which can be used to send the + * event to the room. + * @returns {IPartialEvent<object>} The serialized event. + */ + + }]); + + return ExtensibleEvent; +}(); + +exports.ExtensibleEvent = ExtensibleEvent;
\ No newline at end of file diff --git a/includes/external/matrix/node_modules/matrix-events-sdk/lib/events/MessageEvent.d.ts b/includes/external/matrix/node_modules/matrix-events-sdk/lib/events/MessageEvent.d.ts new file mode 100644 index 0000000..0f73258 --- /dev/null +++ b/includes/external/matrix/node_modules/matrix-events-sdk/lib/events/MessageEvent.d.ts @@ -0,0 +1,58 @@ +import { ExtensibleEvent } from "./ExtensibleEvent"; +import { IPartialEvent } from "../IPartialEvent"; +import { Optional } from "../types"; +import { IMessageRendering, M_MESSAGE_EVENT_CONTENT } from "./message_types"; +import { EventType } from "../utility/events"; +/** + * Represents a message event. Message events are the simplest form of event with + * just text (optionally of different mimetypes, like HTML). + * + * Message events can additionally be an Emote or Notice, though typically those + * are represented as EmoteEvent and NoticeEvent respectively. + */ +export declare class MessageEvent extends ExtensibleEvent<M_MESSAGE_EVENT_CONTENT> { + /** + * The default text for the event. + */ + readonly text: string; + /** + * The default HTML for the event, if provided. + */ + readonly html: Optional<string>; + /** + * All the different renderings of the message. Note that this is the same + * format as an m.message body but may contain elements not found directly + * in the event content: this is because this is interpreted based off the + * other information available in the event. + */ + readonly renderings: IMessageRendering[]; + /** + * Creates a new MessageEvent from a pure format. Note that the event is + * *not* parsed here: it will be treated as a literal m.message primary + * typed event. + * @param {IPartialEvent<M_MESSAGE_EVENT_CONTENT>} wireFormat The event. + */ + constructor(wireFormat: IPartialEvent<M_MESSAGE_EVENT_CONTENT>); + /** + * Gets whether this message is considered an "emote". Note that a message + * might be an emote and notice at the same time: while technically possible, + * the event should be interpreted as one or the other. + */ + get isEmote(): boolean; + /** + * Gets whether this message is considered a "notice". Note that a message + * might be an emote and notice at the same time: while technically possible, + * the event should be interpreted as one or the other. + */ + get isNotice(): boolean; + isEquivalentTo(primaryEventType: EventType): boolean; + protected serializeMMessageOnly(): M_MESSAGE_EVENT_CONTENT; + serialize(): IPartialEvent<object>; + /** + * Creates a new MessageEvent from text and HTML. + * @param {string} text The text. + * @param {string} html Optional HTML. + * @returns {MessageEvent} The representative message event. + */ + static from(text: string, html?: string): MessageEvent; +} diff --git a/includes/external/matrix/node_modules/matrix-events-sdk/lib/events/MessageEvent.js b/includes/external/matrix/node_modules/matrix-events-sdk/lib/events/MessageEvent.js new file mode 100644 index 0000000..f11d586 --- /dev/null +++ b/includes/external/matrix/node_modules/matrix-events-sdk/lib/events/MessageEvent.js @@ -0,0 +1,214 @@ +"use strict"; + +function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.MessageEvent = void 0; + +var _ExtensibleEvent2 = require("./ExtensibleEvent"); + +var _types = require("../types"); + +var _InvalidEventError = require("../InvalidEventError"); + +var _message_types = require("./message_types"); + +var _events = require("../utility/events"); + +function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +/** + * Represents a message event. Message events are the simplest form of event with + * just text (optionally of different mimetypes, like HTML). + * + * Message events can additionally be an Emote or Notice, though typically those + * are represented as EmoteEvent and NoticeEvent respectively. + */ +var MessageEvent = /*#__PURE__*/function (_ExtensibleEvent) { + _inherits(MessageEvent, _ExtensibleEvent); + + var _super = _createSuper(MessageEvent); + + /** + * The default text for the event. + */ + + /** + * The default HTML for the event, if provided. + */ + + /** + * All the different renderings of the message. Note that this is the same + * format as an m.message body but may contain elements not found directly + * in the event content: this is because this is interpreted based off the + * other information available in the event. + */ + + /** + * Creates a new MessageEvent from a pure format. Note that the event is + * *not* parsed here: it will be treated as a literal m.message primary + * typed event. + * @param {IPartialEvent<M_MESSAGE_EVENT_CONTENT>} wireFormat The event. + */ + function MessageEvent(wireFormat) { + var _this; + + _classCallCheck(this, MessageEvent); + + _this = _super.call(this, wireFormat); + + _defineProperty(_assertThisInitialized(_this), "text", void 0); + + _defineProperty(_assertThisInitialized(_this), "html", void 0); + + _defineProperty(_assertThisInitialized(_this), "renderings", void 0); + + var mmessage = _message_types.M_MESSAGE.findIn(_this.wireContent); + + var mtext = _message_types.M_TEXT.findIn(_this.wireContent); + + var mhtml = _message_types.M_HTML.findIn(_this.wireContent); + + if ((0, _types.isProvided)(mmessage)) { + if (!Array.isArray(mmessage)) { + throw new _InvalidEventError.InvalidEventError("m.message contents must be an array"); + } + + var text = mmessage.find(function (r) { + return !(0, _types.isProvided)(r.mimetype) || r.mimetype === "text/plain"; + }); + var html = mmessage.find(function (r) { + return r.mimetype === "text/html"; + }); + if (!text) throw new _InvalidEventError.InvalidEventError("m.message is missing a plain text representation"); + _this.text = text.body; + _this.html = html === null || html === void 0 ? void 0 : html.body; + _this.renderings = mmessage; + } else if ((0, _types.isOptionalAString)(mtext)) { + _this.text = mtext; + _this.html = mhtml; + _this.renderings = [{ + body: mtext, + mimetype: "text/plain" + }]; + + if (_this.html) { + _this.renderings.push({ + body: _this.html, + mimetype: "text/html" + }); + } + } else { + throw new _InvalidEventError.InvalidEventError("Missing textual representation for event"); + } + + return _this; + } + /** + * Gets whether this message is considered an "emote". Note that a message + * might be an emote and notice at the same time: while technically possible, + * the event should be interpreted as one or the other. + */ + + + _createClass(MessageEvent, [{ + key: "isEmote", + get: function get() { + return _message_types.M_EMOTE.matches(this.wireFormat.type) || (0, _types.isProvided)(_message_types.M_EMOTE.findIn(this.wireFormat.content)); + } + /** + * Gets whether this message is considered a "notice". Note that a message + * might be an emote and notice at the same time: while technically possible, + * the event should be interpreted as one or the other. + */ + + }, { + key: "isNotice", + get: function get() { + return _message_types.M_NOTICE.matches(this.wireFormat.type) || (0, _types.isProvided)(_message_types.M_NOTICE.findIn(this.wireFormat.content)); + } + }, { + key: "isEquivalentTo", + value: function isEquivalentTo(primaryEventType) { + return (0, _events.isEventTypeSame)(primaryEventType, _message_types.M_MESSAGE); + } + }, { + key: "serializeMMessageOnly", + value: function serializeMMessageOnly() { + var messageRendering = _defineProperty({}, _message_types.M_MESSAGE.name, this.renderings); // Use the shorthand if it's just a simple text event + + + if (this.renderings.length === 1) { + var mime = this.renderings[0].mimetype; + + if (mime === undefined || mime === "text/plain") { + messageRendering = _defineProperty({}, _message_types.M_TEXT.name, this.renderings[0].body); + } + } + + return messageRendering; + } + }, { + key: "serialize", + value: function serialize() { + var _this$html; + + return { + type: "m.room.message", + content: _objectSpread(_objectSpread({}, this.serializeMMessageOnly()), {}, { + body: this.text, + msgtype: "m.text", + format: this.html ? "org.matrix.custom.html" : undefined, + formatted_body: (_this$html = this.html) !== null && _this$html !== void 0 ? _this$html : undefined + }) + }; + } + /** + * Creates a new MessageEvent from text and HTML. + * @param {string} text The text. + * @param {string} html Optional HTML. + * @returns {MessageEvent} The representative message event. + */ + + }], [{ + key: "from", + value: function from(text, html) { + var _content; + + return new MessageEvent({ + type: _message_types.M_MESSAGE.name, + content: (_content = {}, _defineProperty(_content, _message_types.M_TEXT.name, text), _defineProperty(_content, _message_types.M_HTML.name, html), _content) + }); + } + }]); + + return MessageEvent; +}(_ExtensibleEvent2.ExtensibleEvent); + +exports.MessageEvent = MessageEvent;
\ No newline at end of file diff --git a/includes/external/matrix/node_modules/matrix-events-sdk/lib/events/NoticeEvent.d.ts b/includes/external/matrix/node_modules/matrix-events-sdk/lib/events/NoticeEvent.d.ts new file mode 100644 index 0000000..41e2742 --- /dev/null +++ b/includes/external/matrix/node_modules/matrix-events-sdk/lib/events/NoticeEvent.d.ts @@ -0,0 +1,21 @@ +import { MessageEvent } from "./MessageEvent"; +import { IPartialEvent } from "../IPartialEvent"; +import { M_NOTICE_EVENT_CONTENT } from "./message_types"; +import { EventType } from "../utility/events"; +/** + * Represents a notice. This is essentially a MessageEvent with + * notice characteristics considered. + */ +export declare class NoticeEvent extends MessageEvent { + constructor(wireFormat: IPartialEvent<M_NOTICE_EVENT_CONTENT>); + get isNotice(): boolean; + isEquivalentTo(primaryEventType: EventType): boolean; + serialize(): IPartialEvent<object>; + /** + * Creates a new NoticeEvent from text and HTML. + * @param {string} text The text. + * @param {string} html Optional HTML. + * @returns {MessageEvent} The representative message event. + */ + static from(text: string, html?: string): NoticeEvent; +} diff --git a/includes/external/matrix/node_modules/matrix-events-sdk/lib/events/NoticeEvent.js b/includes/external/matrix/node_modules/matrix-events-sdk/lib/events/NoticeEvent.js new file mode 100644 index 0000000..999d192 --- /dev/null +++ b/includes/external/matrix/node_modules/matrix-events-sdk/lib/events/NoticeEvent.js @@ -0,0 +1,99 @@ +"use strict"; + +function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.NoticeEvent = void 0; + +var _MessageEvent2 = require("./MessageEvent"); + +var _message_types = require("./message_types"); + +var _events = require("../utility/events"); + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } + +function _get() { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(arguments.length < 3 ? target : receiver); } return desc.value; }; } return _get.apply(this, arguments); } + +function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +// Notice events are just decorated message events + +/** + * Represents a notice. This is essentially a MessageEvent with + * notice characteristics considered. + */ +var NoticeEvent = /*#__PURE__*/function (_MessageEvent) { + _inherits(NoticeEvent, _MessageEvent); + + var _super = _createSuper(NoticeEvent); + + function NoticeEvent(wireFormat) { + _classCallCheck(this, NoticeEvent); + + return _super.call(this, wireFormat); + } + + _createClass(NoticeEvent, [{ + key: "isNotice", + get: function get() { + return true; // override + } + }, { + key: "isEquivalentTo", + value: function isEquivalentTo(primaryEventType) { + return (0, _events.isEventTypeSame)(primaryEventType, _message_types.M_NOTICE) || _get(_getPrototypeOf(NoticeEvent.prototype), "isEquivalentTo", this).call(this, primaryEventType); + } + }, { + key: "serialize", + value: function serialize() { + var message = _get(_getPrototypeOf(NoticeEvent.prototype), "serialize", this).call(this); + + message.content['msgtype'] = "m.notice"; + return message; + } + /** + * Creates a new NoticeEvent from text and HTML. + * @param {string} text The text. + * @param {string} html Optional HTML. + * @returns {MessageEvent} The representative message event. + */ + + }], [{ + key: "from", + value: function from(text, html) { + var _content; + + return new NoticeEvent({ + type: _message_types.M_NOTICE.name, + content: (_content = {}, _defineProperty(_content, _message_types.M_TEXT.name, text), _defineProperty(_content, _message_types.M_HTML.name, html), _content) + }); + } + }]); + + return NoticeEvent; +}(_MessageEvent2.MessageEvent); + +exports.NoticeEvent = NoticeEvent;
\ No newline at end of file diff --git a/includes/external/matrix/node_modules/matrix-events-sdk/lib/events/PollEndEvent.d.ts b/includes/external/matrix/node_modules/matrix-events-sdk/lib/events/PollEndEvent.d.ts new file mode 100644 index 0000000..7d9b4a6 --- /dev/null +++ b/includes/external/matrix/node_modules/matrix-events-sdk/lib/events/PollEndEvent.d.ts @@ -0,0 +1,33 @@ +import { M_POLL_END_EVENT_CONTENT } from "./poll_types"; +import { IPartialEvent } from "../IPartialEvent"; +import { MessageEvent } from "./MessageEvent"; +import { EventType } from "../utility/events"; +import { ExtensibleEvent } from "./ExtensibleEvent"; +/** + * Represents a poll end/closure event. + */ +export declare class PollEndEvent extends ExtensibleEvent<M_POLL_END_EVENT_CONTENT> { + /** + * The poll start event ID referenced by the response. + */ + readonly pollEventId: string; + /** + * The closing message for the event. + */ + readonly closingMessage: MessageEvent; + /** + * Creates a new PollEndEvent from a pure format. Note that the event is *not* + * parsed here: it will be treated as a literal m.poll.response primary typed event. + * @param {IPartialEvent<M_POLL_END_EVENT_CONTENT>} wireFormat The event. + */ + constructor(wireFormat: IPartialEvent<M_POLL_END_EVENT_CONTENT>); + isEquivalentTo(primaryEventType: EventType): boolean; + serialize(): IPartialEvent<object>; + /** + * Creates a new PollEndEvent from a poll event ID. + * @param {string} pollEventId The poll start event ID. + * @param {string} message A closing message, typically revealing the top answer. + * @returns {PollStartEvent} The representative poll closure event. + */ + static from(pollEventId: string, message: string): PollEndEvent; +} diff --git a/includes/external/matrix/node_modules/matrix-events-sdk/lib/events/PollEndEvent.js b/includes/external/matrix/node_modules/matrix-events-sdk/lib/events/PollEndEvent.js new file mode 100644 index 0000000..4c55da8 --- /dev/null +++ b/includes/external/matrix/node_modules/matrix-events-sdk/lib/events/PollEndEvent.js @@ -0,0 +1,138 @@ +"use strict"; + +function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.PollEndEvent = void 0; + +var _poll_types = require("./poll_types"); + +var _InvalidEventError = require("../InvalidEventError"); + +var _relationship_types = require("./relationship_types"); + +var _MessageEvent = require("./MessageEvent"); + +var _message_types = require("./message_types"); + +var _events = require("../utility/events"); + +var _ExtensibleEvent2 = require("./ExtensibleEvent"); + +function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +/** + * Represents a poll end/closure event. + */ +var PollEndEvent = /*#__PURE__*/function (_ExtensibleEvent) { + _inherits(PollEndEvent, _ExtensibleEvent); + + var _super = _createSuper(PollEndEvent); + + /** + * The poll start event ID referenced by the response. + */ + + /** + * The closing message for the event. + */ + + /** + * Creates a new PollEndEvent from a pure format. Note that the event is *not* + * parsed here: it will be treated as a literal m.poll.response primary typed event. + * @param {IPartialEvent<M_POLL_END_EVENT_CONTENT>} wireFormat The event. + */ + function PollEndEvent(wireFormat) { + var _this; + + _classCallCheck(this, PollEndEvent); + + _this = _super.call(this, wireFormat); + + _defineProperty(_assertThisInitialized(_this), "pollEventId", void 0); + + _defineProperty(_assertThisInitialized(_this), "closingMessage", void 0); + + var rel = _this.wireContent["m.relates_to"]; + + if (!_relationship_types.REFERENCE_RELATION.matches(rel === null || rel === void 0 ? void 0 : rel.rel_type) || typeof (rel === null || rel === void 0 ? void 0 : rel.event_id) !== "string") { + throw new _InvalidEventError.InvalidEventError("Relationship must be a reference to an event"); + } + + _this.pollEventId = rel.event_id; + _this.closingMessage = new _MessageEvent.MessageEvent(_this.wireFormat); + return _this; + } + + _createClass(PollEndEvent, [{ + key: "isEquivalentTo", + value: function isEquivalentTo(primaryEventType) { + return (0, _events.isEventTypeSame)(primaryEventType, _poll_types.M_POLL_END); + } + }, { + key: "serialize", + value: function serialize() { + return { + type: _poll_types.M_POLL_END.name, + content: _objectSpread(_defineProperty({ + "m.relates_to": { + rel_type: _relationship_types.REFERENCE_RELATION.name, + event_id: this.pollEventId + } + }, _poll_types.M_POLL_END.name, {}), this.closingMessage.serialize().content) + }; + } + /** + * Creates a new PollEndEvent from a poll event ID. + * @param {string} pollEventId The poll start event ID. + * @param {string} message A closing message, typically revealing the top answer. + * @returns {PollStartEvent} The representative poll closure event. + */ + + }], [{ + key: "from", + value: function from(pollEventId, message) { + var _content; + + return new PollEndEvent({ + type: _poll_types.M_POLL_END.name, + content: (_content = { + "m.relates_to": { + rel_type: _relationship_types.REFERENCE_RELATION.name, + event_id: pollEventId + } + }, _defineProperty(_content, _poll_types.M_POLL_END.name, {}), _defineProperty(_content, _message_types.M_TEXT.name, message), _content) + }); + } + }]); + + return PollEndEvent; +}(_ExtensibleEvent2.ExtensibleEvent); + +exports.PollEndEvent = PollEndEvent;
\ No newline at end of file diff --git a/includes/external/matrix/node_modules/matrix-events-sdk/lib/events/PollResponseEvent.d.ts b/includes/external/matrix/node_modules/matrix-events-sdk/lib/events/PollResponseEvent.d.ts new file mode 100644 index 0000000..ad9e3b1 --- /dev/null +++ b/includes/external/matrix/node_modules/matrix-events-sdk/lib/events/PollResponseEvent.d.ts @@ -0,0 +1,49 @@ +import { ExtensibleEvent } from "./ExtensibleEvent"; +import { M_POLL_RESPONSE_EVENT_CONTENT } from "./poll_types"; +import { IPartialEvent } from "../IPartialEvent"; +import { PollStartEvent } from "./PollStartEvent"; +import { EventType } from "../utility/events"; +/** + * Represents a poll response event. + */ +export declare class PollResponseEvent extends ExtensibleEvent<M_POLL_RESPONSE_EVENT_CONTENT> { + private internalAnswerIds; + private internalSpoiled; + /** + * The provided answers for the poll. Note that this may be falsy/unpredictable if + * the `spoiled` property is true. + */ + get answerIds(): string[]; + /** + * The poll start event ID referenced by the response. + */ + readonly pollEventId: string; + /** + * Whether the vote is spoiled. + */ + get spoiled(): boolean; + /** + * Creates a new PollResponseEvent from a pure format. Note that the event is *not* + * parsed here: it will be treated as a literal m.poll.response primary typed event. + * + * To validate the response against a poll, call `validateAgainst` after creation. + * @param {IPartialEvent<M_POLL_RESPONSE_EVENT_CONTENT>} wireFormat The event. + */ + constructor(wireFormat: IPartialEvent<M_POLL_RESPONSE_EVENT_CONTENT>); + /** + * Validates the poll response using the poll start event as a frame of reference. This + * is used to determine if the vote is spoiled, whether the answers are valid, etc. + * @param {PollStartEvent} poll The poll start event. + */ + validateAgainst(poll: PollStartEvent): void; + isEquivalentTo(primaryEventType: EventType): boolean; + serialize(): IPartialEvent<object>; + /** + * Creates a new PollResponseEvent from a set of answers. To spoil the vote, pass an empty + * answers array. + * @param {string} answers The user's answers. Should be valid from a poll's answer IDs. + * @param {string} pollEventId The poll start event ID. + * @returns {PollStartEvent} The representative poll response event. + */ + static from(answers: string[], pollEventId: string): PollResponseEvent; +} diff --git a/includes/external/matrix/node_modules/matrix-events-sdk/lib/events/PollResponseEvent.js b/includes/external/matrix/node_modules/matrix-events-sdk/lib/events/PollResponseEvent.js new file mode 100644 index 0000000..f060d55 --- /dev/null +++ b/includes/external/matrix/node_modules/matrix-events-sdk/lib/events/PollResponseEvent.js @@ -0,0 +1,198 @@ +"use strict"; + +function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.PollResponseEvent = void 0; + +var _ExtensibleEvent2 = require("./ExtensibleEvent"); + +var _poll_types = require("./poll_types"); + +var _InvalidEventError = require("../InvalidEventError"); + +var _relationship_types = require("./relationship_types"); + +var _events = require("../utility/events"); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +/** + * Represents a poll response event. + */ +var PollResponseEvent = /*#__PURE__*/function (_ExtensibleEvent) { + _inherits(PollResponseEvent, _ExtensibleEvent); + + var _super = _createSuper(PollResponseEvent); + + /** + * Creates a new PollResponseEvent from a pure format. Note that the event is *not* + * parsed here: it will be treated as a literal m.poll.response primary typed event. + * + * To validate the response against a poll, call `validateAgainst` after creation. + * @param {IPartialEvent<M_POLL_RESPONSE_EVENT_CONTENT>} wireFormat The event. + */ + function PollResponseEvent(wireFormat) { + var _this; + + _classCallCheck(this, PollResponseEvent); + + _this = _super.call(this, wireFormat); + + _defineProperty(_assertThisInitialized(_this), "internalAnswerIds", void 0); + + _defineProperty(_assertThisInitialized(_this), "internalSpoiled", void 0); + + _defineProperty(_assertThisInitialized(_this), "pollEventId", void 0); + + var rel = _this.wireContent["m.relates_to"]; + + if (!_relationship_types.REFERENCE_RELATION.matches(rel === null || rel === void 0 ? void 0 : rel.rel_type) || typeof (rel === null || rel === void 0 ? void 0 : rel.event_id) !== "string") { + throw new _InvalidEventError.InvalidEventError("Relationship must be a reference to an event"); + } + + _this.pollEventId = rel.event_id; + + _this.validateAgainst(null); + + return _this; + } + /** + * Validates the poll response using the poll start event as a frame of reference. This + * is used to determine if the vote is spoiled, whether the answers are valid, etc. + * @param {PollStartEvent} poll The poll start event. + */ + + + _createClass(PollResponseEvent, [{ + key: "answerIds", + get: + /** + * The provided answers for the poll. Note that this may be falsy/unpredictable if + * the `spoiled` property is true. + */ + function get() { + return this.internalAnswerIds; + } + /** + * The poll start event ID referenced by the response. + */ + + }, { + key: "spoiled", + get: + /** + * Whether the vote is spoiled. + */ + function get() { + return this.internalSpoiled; + } + }, { + key: "validateAgainst", + value: function validateAgainst(poll) { + var response = _poll_types.M_POLL_RESPONSE.findIn(this.wireContent); + + if (!Array.isArray(response === null || response === void 0 ? void 0 : response.answers)) { + this.internalSpoiled = true; + this.internalAnswerIds = []; + return; + } + + var answers = response.answers; + + if (answers.some(function (a) { + return typeof a !== "string"; + }) || answers.length === 0) { + this.internalSpoiled = true; + this.internalAnswerIds = []; + return; + } + + if (poll) { + if (answers.some(function (a) { + return !poll.answers.some(function (pa) { + return pa.id === a; + }); + })) { + this.internalSpoiled = true; + this.internalAnswerIds = []; + return; + } + + answers = answers.slice(0, poll.maxSelections); + } + + this.internalAnswerIds = answers; + this.internalSpoiled = false; + } + }, { + key: "isEquivalentTo", + value: function isEquivalentTo(primaryEventType) { + return (0, _events.isEventTypeSame)(primaryEventType, _poll_types.M_POLL_RESPONSE); + } + }, { + key: "serialize", + value: function serialize() { + return { + type: _poll_types.M_POLL_RESPONSE.name, + content: _defineProperty({ + "m.relates_to": { + rel_type: _relationship_types.REFERENCE_RELATION.name, + event_id: this.pollEventId + } + }, _poll_types.M_POLL_RESPONSE.name, { + answers: this.spoiled ? undefined : this.answerIds + }) + }; + } + /** + * Creates a new PollResponseEvent from a set of answers. To spoil the vote, pass an empty + * answers array. + * @param {string} answers The user's answers. Should be valid from a poll's answer IDs. + * @param {string} pollEventId The poll start event ID. + * @returns {PollStartEvent} The representative poll response event. + */ + + }], [{ + key: "from", + value: function from(answers, pollEventId) { + return new PollResponseEvent({ + type: _poll_types.M_POLL_RESPONSE.name, + content: _defineProperty({ + "m.relates_to": { + rel_type: _relationship_types.REFERENCE_RELATION.name, + event_id: pollEventId + } + }, _poll_types.M_POLL_RESPONSE.name, { + answers: answers + }) + }); + } + }]); + + return PollResponseEvent; +}(_ExtensibleEvent2.ExtensibleEvent); + +exports.PollResponseEvent = PollResponseEvent;
\ No newline at end of file diff --git a/includes/external/matrix/node_modules/matrix-events-sdk/lib/events/PollStartEvent.d.ts b/includes/external/matrix/node_modules/matrix-events-sdk/lib/events/PollStartEvent.d.ts new file mode 100644 index 0000000..2e85560 --- /dev/null +++ b/includes/external/matrix/node_modules/matrix-events-sdk/lib/events/PollStartEvent.d.ts @@ -0,0 +1,71 @@ +import { KNOWN_POLL_KIND, M_POLL_START_EVENT_CONTENT, POLL_ANSWER } from "./poll_types"; +import { IPartialEvent } from "../IPartialEvent"; +import { MessageEvent } from "./MessageEvent"; +import { EventType } from "../utility/events"; +import { ExtensibleEvent } from "./ExtensibleEvent"; +/** + * Represents a poll answer. Note that this is represented as a subtype and is + * not registered as a parsable event - it is implied for usage exclusively + * within the PollStartEvent parsing. + */ +export declare class PollAnswerSubevent extends MessageEvent { + /** + * The answer ID. + */ + readonly id: string; + constructor(wireFormat: IPartialEvent<POLL_ANSWER>); + serialize(): IPartialEvent<object>; + /** + * Creates a new PollAnswerSubevent from ID and text. + * @param {string} id The answer ID (unique within the poll). + * @param {string} text The text. + * @returns {PollAnswerSubevent} The representative answer. + */ + static from(id: string, text: string): PollAnswerSubevent; +} +/** + * Represents a poll start event. + */ +export declare class PollStartEvent extends ExtensibleEvent<M_POLL_START_EVENT_CONTENT> { + /** + * The question being asked, as a MessageEvent node. + */ + readonly question: MessageEvent; + /** + * The interpreted kind of poll. Note that this will infer a value that is known to the + * SDK rather than verbatim - this means unknown types will be represented as undisclosed + * polls. + * + * To get the raw kind, use rawKind. + */ + readonly kind: KNOWN_POLL_KIND; + /** + * The true kind as provided by the event sender. Might not be valid. + */ + readonly rawKind: string; + /** + * The maximum number of selections a user is allowed to make. + */ + readonly maxSelections: number; + /** + * The possible answers for the poll. + */ + readonly answers: PollAnswerSubevent[]; + /** + * Creates a new PollStartEvent from a pure format. Note that the event is *not* + * parsed here: it will be treated as a literal m.poll.start primary typed event. + * @param {IPartialEvent<M_POLL_START_EVENT_CONTENT>} wireFormat The event. + */ + constructor(wireFormat: IPartialEvent<M_POLL_START_EVENT_CONTENT>); + isEquivalentTo(primaryEventType: EventType): boolean; + serialize(): IPartialEvent<object>; + /** + * Creates a new PollStartEvent from question, answers, and metadata. + * @param {string} question The question to ask. + * @param {string} answers The answers. Should be unique within each other. + * @param {KNOWN_POLL_KIND|string} kind The kind of poll. + * @param {number} maxSelections The maximum number of selections. Must be 1 or higher. + * @returns {PollStartEvent} The representative poll start event. + */ + static from(question: string, answers: string[], kind: KNOWN_POLL_KIND | string, maxSelections?: number): PollStartEvent; +} diff --git a/includes/external/matrix/node_modules/matrix-events-sdk/lib/events/PollStartEvent.js b/includes/external/matrix/node_modules/matrix-events-sdk/lib/events/PollStartEvent.js new file mode 100644 index 0000000..23bca9d --- /dev/null +++ b/includes/external/matrix/node_modules/matrix-events-sdk/lib/events/PollStartEvent.js @@ -0,0 +1,287 @@ +"use strict"; + +function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.PollStartEvent = exports.PollAnswerSubevent = void 0; + +var _poll_types = require("./poll_types"); + +var _MessageEvent2 = require("./MessageEvent"); + +var _message_types = require("./message_types"); + +var _InvalidEventError = require("../InvalidEventError"); + +var _NamespacedValue = require("../NamespacedValue"); + +var _events = require("../utility/events"); + +var _ExtensibleEvent2 = require("./ExtensibleEvent"); + +function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } + +function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } + +function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } + +function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); } + +function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } + +function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } + +function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +/** + * Represents a poll answer. Note that this is represented as a subtype and is + * not registered as a parsable event - it is implied for usage exclusively + * within the PollStartEvent parsing. + */ +var PollAnswerSubevent = /*#__PURE__*/function (_MessageEvent) { + _inherits(PollAnswerSubevent, _MessageEvent); + + var _super = _createSuper(PollAnswerSubevent); + + /** + * The answer ID. + */ + function PollAnswerSubevent(wireFormat) { + var _this; + + _classCallCheck(this, PollAnswerSubevent); + + _this = _super.call(this, wireFormat); + + _defineProperty(_assertThisInitialized(_this), "id", void 0); + + var id = wireFormat.content.id; + + if (!id || typeof id !== "string") { + throw new _InvalidEventError.InvalidEventError("Answer ID must be a non-empty string"); + } + + _this.id = id; + return _this; + } + + _createClass(PollAnswerSubevent, [{ + key: "serialize", + value: function serialize() { + return { + type: "org.matrix.sdk.poll.answer", + content: _objectSpread({ + id: this.id + }, this.serializeMMessageOnly()) + }; + } + /** + * Creates a new PollAnswerSubevent from ID and text. + * @param {string} id The answer ID (unique within the poll). + * @param {string} text The text. + * @returns {PollAnswerSubevent} The representative answer. + */ + + }], [{ + key: "from", + value: function from(id, text) { + return new PollAnswerSubevent({ + type: "org.matrix.sdk.poll.answer", + content: _defineProperty({ + id: id + }, _message_types.M_TEXT.name, text) + }); + } + }]); + + return PollAnswerSubevent; +}(_MessageEvent2.MessageEvent); +/** + * Represents a poll start event. + */ + + +exports.PollAnswerSubevent = PollAnswerSubevent; + +var PollStartEvent = /*#__PURE__*/function (_ExtensibleEvent) { + _inherits(PollStartEvent, _ExtensibleEvent); + + var _super2 = _createSuper(PollStartEvent); + + /** + * The question being asked, as a MessageEvent node. + */ + + /** + * The interpreted kind of poll. Note that this will infer a value that is known to the + * SDK rather than verbatim - this means unknown types will be represented as undisclosed + * polls. + * + * To get the raw kind, use rawKind. + */ + + /** + * The true kind as provided by the event sender. Might not be valid. + */ + + /** + * The maximum number of selections a user is allowed to make. + */ + + /** + * The possible answers for the poll. + */ + + /** + * Creates a new PollStartEvent from a pure format. Note that the event is *not* + * parsed here: it will be treated as a literal m.poll.start primary typed event. + * @param {IPartialEvent<M_POLL_START_EVENT_CONTENT>} wireFormat The event. + */ + function PollStartEvent(wireFormat) { + var _this2; + + _classCallCheck(this, PollStartEvent); + + _this2 = _super2.call(this, wireFormat); + + _defineProperty(_assertThisInitialized(_this2), "question", void 0); + + _defineProperty(_assertThisInitialized(_this2), "kind", void 0); + + _defineProperty(_assertThisInitialized(_this2), "rawKind", void 0); + + _defineProperty(_assertThisInitialized(_this2), "maxSelections", void 0); + + _defineProperty(_assertThisInitialized(_this2), "answers", void 0); + + var poll = _poll_types.M_POLL_START.findIn(_this2.wireContent); + + if (!poll.question) { + throw new _InvalidEventError.InvalidEventError("A question is required"); + } + + _this2.question = new _MessageEvent2.MessageEvent({ + type: "org.matrix.sdk.poll.question", + content: poll.question + }); + _this2.rawKind = poll.kind; + + if (_poll_types.M_POLL_KIND_DISCLOSED.matches(_this2.rawKind)) { + _this2.kind = _poll_types.M_POLL_KIND_DISCLOSED; + } else { + _this2.kind = _poll_types.M_POLL_KIND_UNDISCLOSED; // default & assumed value + } + + _this2.maxSelections = Number.isFinite(poll.max_selections) && poll.max_selections > 0 ? poll.max_selections : 1; + + if (!Array.isArray(poll.answers)) { + throw new _InvalidEventError.InvalidEventError("Poll answers must be an array"); + } + + var answers = poll.answers.slice(0, 20).map(function (a) { + return new PollAnswerSubevent({ + type: "org.matrix.sdk.poll.answer", + content: a + }); + }); + + if (answers.length <= 0) { + throw new _InvalidEventError.InvalidEventError("No answers available"); + } + + _this2.answers = answers; + return _this2; + } + + _createClass(PollStartEvent, [{ + key: "isEquivalentTo", + value: function isEquivalentTo(primaryEventType) { + return (0, _events.isEventTypeSame)(primaryEventType, _poll_types.M_POLL_START); + } + }, { + key: "serialize", + value: function serialize() { + var _content2; + + return { + type: _poll_types.M_POLL_START.name, + content: (_content2 = {}, _defineProperty(_content2, _poll_types.M_POLL_START.name, { + question: this.question.serialize().content, + kind: this.rawKind, + max_selections: this.maxSelections, + answers: this.answers.map(function (a) { + return a.serialize().content; + }) + }), _defineProperty(_content2, _message_types.M_TEXT.name, "".concat(this.question.text, "\n").concat(this.answers.map(function (a, i) { + return "".concat(i + 1, ". ").concat(a.text); + }).join("\n"))), _content2) + }; + } + /** + * Creates a new PollStartEvent from question, answers, and metadata. + * @param {string} question The question to ask. + * @param {string} answers The answers. Should be unique within each other. + * @param {KNOWN_POLL_KIND|string} kind The kind of poll. + * @param {number} maxSelections The maximum number of selections. Must be 1 or higher. + * @returns {PollStartEvent} The representative poll start event. + */ + + }], [{ + key: "from", + value: function from(question, answers, kind) { + var _content3; + + var maxSelections = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1; + return new PollStartEvent({ + type: _poll_types.M_POLL_START.name, + content: (_content3 = {}, _defineProperty(_content3, _message_types.M_TEXT.name, question), _defineProperty(_content3, _poll_types.M_POLL_START.name, { + question: _defineProperty({}, _message_types.M_TEXT.name, question), + kind: kind instanceof _NamespacedValue.NamespacedValue ? kind.name : kind, + max_selections: maxSelections, + answers: answers.map(function (a) { + return _defineProperty({ + id: makeId() + }, _message_types.M_TEXT.name, a); + }) + }), _content3) + }); + } + }]); + + return PollStartEvent; +}(_ExtensibleEvent2.ExtensibleEvent); + +exports.PollStartEvent = PollStartEvent; +var LETTERS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; + +function makeId() { + return _toConsumableArray(Array(16)).map(function () { + return LETTERS.charAt(Math.floor(Math.random() * LETTERS.length)); + }).join(''); +}
\ No newline at end of file diff --git a/includes/external/matrix/node_modules/matrix-events-sdk/lib/events/message_types.d.ts b/includes/external/matrix/node_modules/matrix-events-sdk/lib/events/message_types.d.ts new file mode 100644 index 0000000..f102baa --- /dev/null +++ b/includes/external/matrix/node_modules/matrix-events-sdk/lib/events/message_types.d.ts @@ -0,0 +1,81 @@ +import { UnstableValue } from "../NamespacedValue"; +import { EitherAnd } from "../types"; +/** + * The namespaced value for m.message + */ +export declare const M_MESSAGE: UnstableValue<"m.message", "org.matrix.msc1767.message">; +/** + * An m.message event rendering + */ +export interface IMessageRendering { + body: string; + mimetype?: string; +} +/** + * The content for an m.message event + */ +export declare type M_MESSAGE_EVENT = EitherAnd<{ + [M_MESSAGE.name]: IMessageRendering[]; +}, { + [M_MESSAGE.altName]: IMessageRendering[]; +}>; +/** + * The namespaced value for m.text + */ +export declare const M_TEXT: UnstableValue<"m.text", "org.matrix.msc1767.text">; +/** + * The content for an m.text event + */ +export declare type M_TEXT_EVENT = EitherAnd<{ + [M_TEXT.name]: string; +}, { + [M_TEXT.altName]: string; +}>; +/** + * The namespaced value for m.html + */ +export declare const M_HTML: UnstableValue<"m.html", "org.matrix.msc1767.html">; +/** + * The content for an m.html event + */ +export declare type M_HTML_EVENT = EitherAnd<{ + [M_HTML.name]: string; +}, { + [M_HTML.altName]: string; +}>; +/** + * The content for an m.message, m.text, or m.html event + */ +export declare type M_MESSAGE_EVENT_CONTENT = M_MESSAGE_EVENT | M_TEXT_EVENT | M_HTML_EVENT; +/** + * The namespaced value for m.emote + */ +export declare const M_EMOTE: UnstableValue<"m.emote", "org.matrix.msc1767.emote">; +/** + * The event definition for an m.emote event (in content) + */ +export declare type M_EMOTE_EVENT = EitherAnd<{ + [M_EMOTE.name]?: {}; +}, { + [M_EMOTE.altName]?: {}; +}>; +/** + * The content for an m.emote event + */ +export declare type M_EMOTE_EVENT_CONTENT = M_MESSAGE_EVENT_CONTENT & M_EMOTE_EVENT; +/** + * The namespaced value for m.notice + */ +export declare const M_NOTICE: UnstableValue<"m.notice", "org.matrix.msc1767.notice">; +/** + * The event definition for an m.notice event (in content) + */ +export declare type M_NOTICE_EVENT = EitherAnd<{ + [M_NOTICE.name]?: {}; +}, { + [M_NOTICE.altName]?: {}; +}>; +/** + * The content for an m.notice event + */ +export declare type M_NOTICE_EVENT_CONTENT = M_MESSAGE_EVENT_CONTENT & M_NOTICE_EVENT; diff --git a/includes/external/matrix/node_modules/matrix-events-sdk/lib/events/message_types.js b/includes/external/matrix/node_modules/matrix-events-sdk/lib/events/message_types.js new file mode 100644 index 0000000..a466668 --- /dev/null +++ b/includes/external/matrix/node_modules/matrix-events-sdk/lib/events/message_types.js @@ -0,0 +1,74 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.M_TEXT = exports.M_NOTICE = exports.M_MESSAGE = exports.M_HTML = exports.M_EMOTE = void 0; + +var _NamespacedValue = require("../NamespacedValue"); + +/* +Copyright 2022 The Matrix.org Foundation C.I.C. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +/** + * The namespaced value for m.message + */ +var M_MESSAGE = new _NamespacedValue.UnstableValue("m.message", "org.matrix.msc1767.message"); +/** + * An m.message event rendering + */ + +exports.M_MESSAGE = M_MESSAGE; + +/** + * The namespaced value for m.text + */ +var M_TEXT = new _NamespacedValue.UnstableValue("m.text", "org.matrix.msc1767.text"); +/** + * The content for an m.text event + */ + +exports.M_TEXT = M_TEXT; + +/** + * The namespaced value for m.html + */ +var M_HTML = new _NamespacedValue.UnstableValue("m.html", "org.matrix.msc1767.html"); +/** + * The content for an m.html event + */ + +exports.M_HTML = M_HTML; + +/** + * The namespaced value for m.emote + */ +var M_EMOTE = new _NamespacedValue.UnstableValue("m.emote", "org.matrix.msc1767.emote"); +/** + * The event definition for an m.emote event (in content) + */ + +exports.M_EMOTE = M_EMOTE; + +/** + * The namespaced value for m.notice + */ +var M_NOTICE = new _NamespacedValue.UnstableValue("m.notice", "org.matrix.msc1767.notice"); +/** + * The event definition for an m.notice event (in content) + */ + +exports.M_NOTICE = M_NOTICE;
\ No newline at end of file diff --git a/includes/external/matrix/node_modules/matrix-events-sdk/lib/events/poll_types.d.ts b/includes/external/matrix/node_modules/matrix-events-sdk/lib/events/poll_types.d.ts new file mode 100644 index 0000000..5cb2386 --- /dev/null +++ b/includes/external/matrix/node_modules/matrix-events-sdk/lib/events/poll_types.d.ts @@ -0,0 +1,89 @@ +import { UnstableValue } from "../NamespacedValue"; +import { EitherAnd, TSNamespace } from "../types"; +import { M_MESSAGE_EVENT_CONTENT } from "./message_types"; +import { REFERENCE_RELATION, RELATES_TO_RELATIONSHIP } from "./relationship_types"; +/** + * Identifier for a disclosed poll. + */ +export declare const M_POLL_KIND_DISCLOSED: UnstableValue<"m.poll.disclosed", "org.matrix.msc3381.poll.disclosed">; +/** + * Identifier for an undisclosed poll. + */ +export declare const M_POLL_KIND_UNDISCLOSED: UnstableValue<"m.poll.undisclosed", "org.matrix.msc3381.poll.undisclosed">; +/** + * Any poll kind. + */ +export declare type POLL_KIND = TSNamespace<typeof M_POLL_KIND_DISCLOSED> | TSNamespace<typeof M_POLL_KIND_UNDISCLOSED> | string; +/** + * Known poll kind namespaces. + */ +export declare type KNOWN_POLL_KIND = (typeof M_POLL_KIND_DISCLOSED) | (typeof M_POLL_KIND_UNDISCLOSED); +/** + * The namespaced value for m.poll.start + */ +export declare const M_POLL_START: UnstableValue<"m.poll.start", "org.matrix.msc3381.poll.start">; +/** + * The m.poll.start type within event content + */ +export declare type M_POLL_START_SUBTYPE = { + question: M_MESSAGE_EVENT_CONTENT; + kind: POLL_KIND; + max_selections?: number; + answers: POLL_ANSWER[]; +}; +/** + * A poll answer. + */ +export declare type POLL_ANSWER = M_MESSAGE_EVENT_CONTENT & { + id: string; +}; +/** + * The event definition for an m.poll.start event (in content) + */ +export declare type M_POLL_START_EVENT = EitherAnd<{ + [M_POLL_START.name]: M_POLL_START_SUBTYPE; +}, { + [M_POLL_START.altName]: M_POLL_START_SUBTYPE; +}>; +/** + * The content for an m.poll.start event + */ +export declare type M_POLL_START_EVENT_CONTENT = M_POLL_START_EVENT & M_MESSAGE_EVENT_CONTENT; +/** + * The namespaced value for m.poll.response + */ +export declare const M_POLL_RESPONSE: UnstableValue<"m.poll.response", "org.matrix.msc3381.poll.response">; +/** + * The m.poll.response type within event content + */ +export declare type M_POLL_RESPONSE_SUBTYPE = { + answers: string[]; +}; +/** + * The event definition for an m.poll.response event (in content) + */ +export declare type M_POLL_RESPONSE_EVENT = EitherAnd<{ + [M_POLL_RESPONSE.name]: M_POLL_RESPONSE_SUBTYPE; +}, { + [M_POLL_RESPONSE.altName]: M_POLL_RESPONSE_SUBTYPE; +}>; +/** + * The content for an m.poll.response event + */ +export declare type M_POLL_RESPONSE_EVENT_CONTENT = M_POLL_RESPONSE_EVENT & RELATES_TO_RELATIONSHIP<typeof REFERENCE_RELATION>; +/** + * The namespaced value for m.poll.end + */ +export declare const M_POLL_END: UnstableValue<"m.poll.end", "org.matrix.msc3381.poll.end">; +/** + * The event definition for an m.poll.end event (in content) + */ +export declare type M_POLL_END_EVENT = EitherAnd<{ + [M_POLL_END.name]: {}; +}, { + [M_POLL_END.altName]: {}; +}>; +/** + * The content for an m.poll.end event + */ +export declare type M_POLL_END_EVENT_CONTENT = M_POLL_END_EVENT & RELATES_TO_RELATIONSHIP<typeof REFERENCE_RELATION> & M_MESSAGE_EVENT_CONTENT; diff --git a/includes/external/matrix/node_modules/matrix-events-sdk/lib/events/poll_types.js b/includes/external/matrix/node_modules/matrix-events-sdk/lib/events/poll_types.js new file mode 100644 index 0000000..48e4793 --- /dev/null +++ b/includes/external/matrix/node_modules/matrix-events-sdk/lib/events/poll_types.js @@ -0,0 +1,70 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.M_POLL_START = exports.M_POLL_RESPONSE = exports.M_POLL_KIND_UNDISCLOSED = exports.M_POLL_KIND_DISCLOSED = exports.M_POLL_END = void 0; + +var _NamespacedValue = require("../NamespacedValue"); + +/* +Copyright 2022 The Matrix.org Foundation C.I.C. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +/** + * Identifier for a disclosed poll. + */ +var M_POLL_KIND_DISCLOSED = new _NamespacedValue.UnstableValue("m.poll.disclosed", "org.matrix.msc3381.poll.disclosed"); +/** + * Identifier for an undisclosed poll. + */ + +exports.M_POLL_KIND_DISCLOSED = M_POLL_KIND_DISCLOSED; +var M_POLL_KIND_UNDISCLOSED = new _NamespacedValue.UnstableValue("m.poll.undisclosed", "org.matrix.msc3381.poll.undisclosed"); +/** + * Any poll kind. + */ + +exports.M_POLL_KIND_UNDISCLOSED = M_POLL_KIND_UNDISCLOSED; + +/** + * The namespaced value for m.poll.start + */ +var M_POLL_START = new _NamespacedValue.UnstableValue("m.poll.start", "org.matrix.msc3381.poll.start"); +/** + * The m.poll.start type within event content + */ + +exports.M_POLL_START = M_POLL_START; + +/** + * The namespaced value for m.poll.response + */ +var M_POLL_RESPONSE = new _NamespacedValue.UnstableValue("m.poll.response", "org.matrix.msc3381.poll.response"); +/** + * The m.poll.response type within event content + */ + +exports.M_POLL_RESPONSE = M_POLL_RESPONSE; + +/** + * The namespaced value for m.poll.end + */ +var M_POLL_END = new _NamespacedValue.UnstableValue("m.poll.end", "org.matrix.msc3381.poll.end"); +/** + * The event definition for an m.poll.end event (in content) + */ + +exports.M_POLL_END = M_POLL_END;
\ No newline at end of file diff --git a/includes/external/matrix/node_modules/matrix-events-sdk/lib/events/relationship_types.d.ts b/includes/external/matrix/node_modules/matrix-events-sdk/lib/events/relationship_types.d.ts new file mode 100644 index 0000000..f3e745e --- /dev/null +++ b/includes/external/matrix/node_modules/matrix-events-sdk/lib/events/relationship_types.d.ts @@ -0,0 +1,19 @@ +import { NamespacedValue } from "../NamespacedValue"; +import { DefaultNever, TSNamespace } from "../types"; +/** + * The namespaced value for an m.reference relation + */ +export declare const REFERENCE_RELATION: NamespacedValue<"m.reference", string>; +/** + * Represents any relation type + */ +export declare type ANY_RELATION = TSNamespace<typeof REFERENCE_RELATION> | string; +/** + * An m.relates_to relationship + */ +export declare type RELATES_TO_RELATIONSHIP<R = never, C = never> = { + "m.relates_to": { + rel_type: [R] extends [never] ? ANY_RELATION : TSNamespace<R>; + event_id: string; + } & DefaultNever<C, {}>; +}; diff --git a/includes/external/matrix/node_modules/matrix-events-sdk/lib/events/relationship_types.js b/includes/external/matrix/node_modules/matrix-events-sdk/lib/events/relationship_types.js new file mode 100644 index 0000000..0704266 --- /dev/null +++ b/includes/external/matrix/node_modules/matrix-events-sdk/lib/events/relationship_types.js @@ -0,0 +1,34 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.REFERENCE_RELATION = void 0; + +var _NamespacedValue = require("../NamespacedValue"); + +/* +Copyright 2022 The Matrix.org Foundation C.I.C. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +/** + * The namespaced value for an m.reference relation + */ +var REFERENCE_RELATION = new _NamespacedValue.NamespacedValue("m.reference"); +/** + * Represents any relation type + */ + +exports.REFERENCE_RELATION = REFERENCE_RELATION;
\ No newline at end of file |