mobidev-thelounge
Version:
The self-hosted Web IRC client
1,422 lines (1,310 loc) • 1.14 MB
JavaScript
(globalThis["webpackChunkmobidev_thelounge"] = globalThis["webpackChunkmobidev_thelounge"] || []).push([["js/bundle.vendor.js"],{
/***/ "./node_modules/@socket.io/component-emitter/index.js":
/*!************************************************************!*\
!*** ./node_modules/@socket.io/component-emitter/index.js ***!
\************************************************************/
/***/ ((__unused_webpack_module, exports) => {
/**
* Expose `Emitter`.
*/
exports.Emitter = Emitter;
/**
* Initialize a new `Emitter`.
*
* @api public
*/
function Emitter(obj) {
if (obj) return mixin(obj);
}
/**
* Mixin the emitter properties.
*
* @param {Object} obj
* @return {Object}
* @api private
*/
function mixin(obj) {
for (var key in Emitter.prototype) {
obj[key] = Emitter.prototype[key];
}
return obj;
}
/**
* Listen on the given `event` with `fn`.
*
* @param {String} event
* @param {Function} fn
* @return {Emitter}
* @api public
*/
Emitter.prototype.on =
Emitter.prototype.addEventListener = function(event, fn){
this._callbacks = this._callbacks || {};
(this._callbacks['$' + event] = this._callbacks['$' + event] || [])
.push(fn);
return this;
};
/**
* Adds an `event` listener that will be invoked a single
* time then automatically removed.
*
* @param {String} event
* @param {Function} fn
* @return {Emitter}
* @api public
*/
Emitter.prototype.once = function(event, fn){
function on() {
this.off(event, on);
fn.apply(this, arguments);
}
on.fn = fn;
this.on(event, on);
return this;
};
/**
* Remove the given callback for `event` or all
* registered callbacks.
*
* @param {String} event
* @param {Function} fn
* @return {Emitter}
* @api public
*/
Emitter.prototype.off =
Emitter.prototype.removeListener =
Emitter.prototype.removeAllListeners =
Emitter.prototype.removeEventListener = function(event, fn){
this._callbacks = this._callbacks || {};
// all
if (0 == arguments.length) {
this._callbacks = {};
return this;
}
// specific event
var callbacks = this._callbacks['$' + event];
if (!callbacks) return this;
// remove all handlers
if (1 == arguments.length) {
delete this._callbacks['$' + event];
return this;
}
// remove specific handler
var cb;
for (var i = 0; i < callbacks.length; i++) {
cb = callbacks[i];
if (cb === fn || cb.fn === fn) {
callbacks.splice(i, 1);
break;
}
}
// Remove event specific arrays for event types that no
// one is subscribed for to avoid memory leak.
if (callbacks.length === 0) {
delete this._callbacks['$' + event];
}
return this;
};
/**
* Emit `event` with the given args.
*
* @param {String} event
* @param {Mixed} ...
* @return {Emitter}
*/
Emitter.prototype.emit = function(event){
this._callbacks = this._callbacks || {};
var args = new Array(arguments.length - 1)
, callbacks = this._callbacks['$' + event];
for (var i = 1; i < arguments.length; i++) {
args[i - 1] = arguments[i];
}
if (callbacks) {
callbacks = callbacks.slice(0);
for (var i = 0, len = callbacks.length; i < len; ++i) {
callbacks[i].apply(this, args);
}
}
return this;
};
// alias used for reserved events (protected method)
Emitter.prototype.emitReserved = Emitter.prototype.emit;
/**
* Return array of callbacks for `event`.
*
* @param {String} event
* @return {Array}
* @api public
*/
Emitter.prototype.listeners = function(event){
this._callbacks = this._callbacks || {};
return this._callbacks['$' + event] || [];
};
/**
* Check if this emitter has `event` handlers.
*
* @param {String} event
* @return {Boolean}
* @api public
*/
Emitter.prototype.hasListeners = function(event){
return !! this.listeners(event).length;
};
/***/ }),
/***/ "./node_modules/@textcomplete/core/dist/Completer.js":
/*!***********************************************************!*\
!*** ./node_modules/@textcomplete/core/dist/Completer.js ***!
\***********************************************************/
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
"use strict";
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.Completer = void 0;
const eventemitter3_1 = __webpack_require__(/*! eventemitter3 */ "./node_modules/eventemitter3/index.js");
const Strategy_1 = __webpack_require__(/*! ./Strategy */ "./node_modules/@textcomplete/core/dist/Strategy.js");
class Completer extends eventemitter3_1.EventEmitter {
constructor(strategyPropsList) {
super();
this.handleQueryResult = (searchResults) => {
this.emit("hit", { searchResults });
};
this.strategies = strategyPropsList.map((p) => new Strategy_1.Strategy(p));
}
destroy() {
this.strategies.forEach((s) => s.destroy());
return this;
}
run(beforeCursor) {
for (const strategy of this.strategies) {
const executed = strategy.execute(beforeCursor, this.handleQueryResult);
if (executed)
return;
}
this.handleQueryResult([]);
}
}
exports.Completer = Completer;
//# sourceMappingURL=Completer.js.map
/***/ }),
/***/ "./node_modules/@textcomplete/core/dist/Dropdown.js":
/*!**********************************************************!*\
!*** ./node_modules/@textcomplete/core/dist/Dropdown.js ***!
\**********************************************************/
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
"use strict";
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.Dropdown = exports.DEFAULT_DROPDOWN_ITEM_ACTIVE_CLASS_NAME = exports.DEFAULT_DROPDOWN_ITEM_CLASS_NAME = exports.DEFAULT_DROPDOWN_CLASS_NAME = exports.DEFAULT_DROPDOWN_PLACEMENT = exports.DEFAULT_DROPDOWN_MAX_COUNT = void 0;
const eventemitter3_1 = __webpack_require__(/*! eventemitter3 */ "./node_modules/eventemitter3/index.js");
const utils_1 = __webpack_require__(/*! ./utils */ "./node_modules/@textcomplete/core/dist/utils.js");
// Default constants for Dropdown
exports.DEFAULT_DROPDOWN_MAX_COUNT = 10;
exports.DEFAULT_DROPDOWN_PLACEMENT = "auto";
exports.DEFAULT_DROPDOWN_CLASS_NAME = "dropdown-menu textcomplete-dropdown";
// Default constants for DropdownItem
exports.DEFAULT_DROPDOWN_ITEM_CLASS_NAME = "textcomplete-item";
exports.DEFAULT_DROPDOWN_ITEM_ACTIVE_CLASS_NAME = `${exports.DEFAULT_DROPDOWN_ITEM_CLASS_NAME} active`;
class Dropdown extends eventemitter3_1.EventEmitter {
constructor(el, option) {
super();
this.el = el;
this.option = option;
this.shown = false;
this.items = [];
this.activeIndex = null;
}
static create(option) {
const ul = document.createElement("ul");
ul.className = option.className || exports.DEFAULT_DROPDOWN_CLASS_NAME;
Object.assign(ul.style, {
display: "none",
position: "absolute",
zIndex: "1000",
}, option.style);
const parent = option.parent || document.body;
parent === null || parent === void 0 ? void 0 : parent.appendChild(ul);
return new Dropdown(ul, option);
}
/**
* Render the given search results. Previous results are cleared.
*
* @emits render
* @emits rendered
*/
render(searchResults, cursorOffset) {
const event = (0, utils_1.createCustomEvent)("render", { cancelable: true });
this.emit("render", event);
if (event.defaultPrevented)
return this;
this.clear();
if (searchResults.length === 0)
return this.hide();
this.items = searchResults
.slice(0, this.option.maxCount || exports.DEFAULT_DROPDOWN_MAX_COUNT)
.map((r, index) => { var _a; return new DropdownItem(this, index, r, ((_a = this.option) === null || _a === void 0 ? void 0 : _a.item) || {}); });
this.setStrategyId(searchResults[0])
.renderEdge(searchResults, "header")
.renderItems()
.renderEdge(searchResults, "footer")
.show()
.setOffset(cursorOffset)
.activate(0);
this.emit("rendered", (0, utils_1.createCustomEvent)("rendered"));
return this;
}
destroy() {
var _a;
this.clear();
(_a = this.el.parentNode) === null || _a === void 0 ? void 0 : _a.removeChild(this.el);
return this;
}
/**
* Select the given item
*
* @emits select
* @emits selected
*/
select(item) {
const detail = { searchResult: item.searchResult };
const event = (0, utils_1.createCustomEvent)("select", { cancelable: true, detail });
this.emit("select", event);
if (event.defaultPrevented)
return this;
this.hide();
this.emit("selected", (0, utils_1.createCustomEvent)("selected", { detail }));
return this;
}
/**
* Show the dropdown element
*
* @emits show
* @emits shown
*/
show() {
if (!this.shown) {
const event = (0, utils_1.createCustomEvent)("show", { cancelable: true });
this.emit("show", event);
if (event.defaultPrevented)
return this;
this.el.style.display = "block";
this.shown = true;
this.emit("shown", (0, utils_1.createCustomEvent)("shown"));
}
return this;
}
/**
* Hide the dropdown element
*
* @emits hide
* @emits hidden
*/
hide() {
if (this.shown) {
const event = (0, utils_1.createCustomEvent)("hide", { cancelable: true });
this.emit("hide", event);
if (event.defaultPrevented)
return this;
this.el.style.display = "none";
this.shown = false;
this.clear();
this.emit("hidden", (0, utils_1.createCustomEvent)("hidden"));
}
return this;
}
/** Clear search results */
clear() {
this.items.forEach((i) => i.destroy());
this.items = [];
this.el.innerHTML = "";
this.activeIndex = null;
return this;
}
up(e) {
return this.shown ? this.moveActiveItem("prev", e) : this;
}
down(e) {
return this.shown ? this.moveActiveItem("next", e) : this;
}
moveActiveItem(direction, e) {
if (this.activeIndex != null) {
const activeIndex = direction === "next"
? this.getNextActiveIndex()
: this.getPrevActiveIndex();
if (activeIndex != null) {
this.activate(activeIndex);
e.preventDefault();
}
}
return this;
}
activate(index) {
if (this.activeIndex !== index) {
if (this.activeIndex != null) {
this.items[this.activeIndex].deactivate();
}
this.activeIndex = index;
this.items[index].activate();
}
return this;
}
isShown() {
return this.shown;
}
getActiveItem() {
return this.activeIndex != null ? this.items[this.activeIndex] : null;
}
setOffset(cursorOffset) {
const doc = document.documentElement;
if (doc) {
const elementWidth = this.el.offsetWidth;
if (cursorOffset.left) {
const browserWidth = this.option.dynamicWidth
? doc.scrollWidth
: doc.clientWidth;
if (cursorOffset.left + elementWidth > browserWidth) {
cursorOffset.left = browserWidth - elementWidth;
}
this.el.style.left = `${cursorOffset.left}px`;
}
else if (cursorOffset.right) {
if (cursorOffset.right - elementWidth < 0) {
cursorOffset.right = 0;
}
this.el.style.right = `${cursorOffset.right}px`;
}
let forceTop = false;
const placement = this.option.placement || exports.DEFAULT_DROPDOWN_PLACEMENT;
if (placement === "auto") {
const dropdownHeight = this.items.length * cursorOffset.lineHeight;
forceTop =
cursorOffset.clientTop != null &&
cursorOffset.clientTop + dropdownHeight > doc.clientHeight;
}
if (placement === "top" || forceTop) {
this.el.style.bottom = `${doc.clientHeight - cursorOffset.top + cursorOffset.lineHeight}px`;
this.el.style.top = "auto";
}
else {
this.el.style.top = `${cursorOffset.top}px`;
this.el.style.bottom = "auto";
}
}
return this;
}
getNextActiveIndex() {
if (this.activeIndex == null)
throw new Error();
return this.activeIndex < this.items.length - 1
? this.activeIndex + 1
: this.option.rotate
? 0
: null;
}
getPrevActiveIndex() {
if (this.activeIndex == null)
throw new Error();
return this.activeIndex !== 0
? this.activeIndex - 1
: this.option.rotate
? this.items.length - 1
: null;
}
renderItems() {
const fragment = document.createDocumentFragment();
for (const item of this.items) {
fragment.appendChild(item.el);
}
this.el.appendChild(fragment);
return this;
}
setStrategyId(searchResult) {
const id = searchResult.getStrategyId();
if (id)
this.el.dataset.strategy = id;
return this;
}
renderEdge(searchResults, type) {
const option = this.option[type];
const li = document.createElement("li");
li.className = `textcomplete-${type}`;
li.innerHTML =
typeof option === "function"
? option(searchResults.map((s) => s.data))
: option || "";
this.el.appendChild(li);
return this;
}
}
exports.Dropdown = Dropdown;
class DropdownItem {
constructor(dropdown, index, searchResult, props) {
this.dropdown = dropdown;
this.index = index;
this.searchResult = searchResult;
this.props = props;
this.active = false;
this.onClick = (e) => {
e.preventDefault();
this.dropdown.select(this);
};
this.className = this.props.className || exports.DEFAULT_DROPDOWN_ITEM_CLASS_NAME;
this.activeClassName =
this.props.activeClassName || exports.DEFAULT_DROPDOWN_ITEM_ACTIVE_CLASS_NAME;
const li = document.createElement("li");
li.className = this.active ? this.activeClassName : this.className;
const span = document.createElement("span");
span.tabIndex = -1;
span.innerHTML = this.searchResult.render();
li.appendChild(span);
li.addEventListener("mousedown", this.onClick);
li.addEventListener("touchstart", this.onClick);
this.el = li;
}
destroy() {
var _a;
const li = this.el;
(_a = li.parentNode) === null || _a === void 0 ? void 0 : _a.removeChild(li);
li.removeEventListener("mousedown", this.onClick, false);
li.removeEventListener("touchstart", this.onClick, false);
return this;
}
activate() {
if (!this.active) {
this.active = true;
this.el.className = this.activeClassName;
this.dropdown.el.scrollTop = this.el.offsetTop;
}
return this;
}
deactivate() {
if (this.active) {
this.active = false;
this.el.className = this.className;
}
return this;
}
}
//# sourceMappingURL=Dropdown.js.map
/***/ }),
/***/ "./node_modules/@textcomplete/core/dist/Editor.js":
/*!********************************************************!*\
!*** ./node_modules/@textcomplete/core/dist/Editor.js ***!
\********************************************************/
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
"use strict";
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.Editor = void 0;
const eventemitter3_1 = __webpack_require__(/*! eventemitter3 */ "./node_modules/eventemitter3/index.js");
const utils_1 = __webpack_require__(/*! ./utils */ "./node_modules/@textcomplete/core/dist/utils.js");
class Editor extends eventemitter3_1.EventEmitter {
/**
* Finalize the editor object.
*
* It is called when associated textcomplete object is destroyed.
*/
destroy() {
return this;
}
/**
* It is called when a search result is selected by a user.
*/
applySearchResult(_searchResult) {
throw new Error("Not implemented.");
}
/**
* The input cursor's absolute coordinates from the window's left
* top corner.
*/
getCursorOffset() {
throw new Error("Not implemented.");
}
/**
* Editor string value from head to the cursor.
* Returns null if selection type is range not cursor.
*/
getBeforeCursor() {
throw new Error("Not implemented.");
}
/**
* Emit a move event, which moves active dropdown element.
* Child class must call this method at proper timing with proper parameter.
*
* @see {@link Textarea} for live example.
*/
emitMoveEvent(code) {
const moveEvent = (0, utils_1.createCustomEvent)("move", {
cancelable: true,
detail: {
code: code,
},
});
this.emit("move", moveEvent);
return moveEvent;
}
/**
* Emit a enter event, which selects current search result.
* Child class must call this method at proper timing.
*
* @see {@link Textarea} for live example.
*/
emitEnterEvent() {
const enterEvent = (0, utils_1.createCustomEvent)("enter", { cancelable: true });
this.emit("enter", enterEvent);
return enterEvent;
}
/**
* Emit a change event, which triggers auto completion.
* Child class must call this method at proper timing.
*
* @see {@link Textarea} for live example.
*/
emitChangeEvent() {
const changeEvent = (0, utils_1.createCustomEvent)("change", {
detail: {
beforeCursor: this.getBeforeCursor(),
},
});
this.emit("change", changeEvent);
return changeEvent;
}
/**
* Emit a esc event, which hides dropdown element.
* Child class must call this method at proper timing.
*
* @see {@link Textarea} for live example.
*/
emitEscEvent() {
const escEvent = (0, utils_1.createCustomEvent)("esc", { cancelable: true });
this.emit("esc", escEvent);
return escEvent;
}
/**
* Helper method for parsing KeyboardEvent.
*
* @see {@link Textarea} for live example.
*/
getCode(e) {
return e.keyCode === 9 // tab
? "ENTER"
: e.keyCode === 13 // enter
? "ENTER"
: e.keyCode === 27 // esc
? "ESC"
: e.keyCode === 38 // up
? "UP"
: e.keyCode === 40 // down
? "DOWN"
: e.keyCode === 78 && e.ctrlKey // ctrl-n
? "DOWN"
: e.keyCode === 80 && e.ctrlKey // ctrl-p
? "UP"
: "OTHER";
}
}
exports.Editor = Editor;
//# sourceMappingURL=Editor.js.map
/***/ }),
/***/ "./node_modules/@textcomplete/core/dist/SearchResult.js":
/*!**************************************************************!*\
!*** ./node_modules/@textcomplete/core/dist/SearchResult.js ***!
\**************************************************************/
/***/ ((__unused_webpack_module, exports) => {
"use strict";
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.SearchResult = void 0;
const MAIN = /\$&/g;
const PLACE = /\$(\d)/g;
class SearchResult {
constructor(data, term, strategy) {
this.data = data;
this.term = term;
this.strategy = strategy;
}
getReplacementData(beforeCursor) {
let result = this.strategy.replace(this.data);
if (result == null)
return null;
let afterCursor = "";
if (Array.isArray(result)) {
afterCursor = result[1];
result = result[0];
}
const match = this.strategy.match(beforeCursor);
if (match == null || match.index == null)
return null;
const replacement = result
.replace(MAIN, match[0])
.replace(PLACE, (_, p) => match[parseInt(p)]);
return {
start: match.index,
end: match.index + match[0].length,
beforeCursor: replacement,
afterCursor: afterCursor,
};
}
replace(beforeCursor, afterCursor) {
const replacement = this.getReplacementData(beforeCursor);
if (replacement === null)
return;
afterCursor = replacement.afterCursor + afterCursor;
return [
[
beforeCursor.slice(0, replacement.start),
replacement.beforeCursor,
beforeCursor.slice(replacement.end),
].join(""),
afterCursor,
];
}
render() {
return this.strategy.renderTemplate(this.data, this.term);
}
getStrategyId() {
return this.strategy.getId();
}
}
exports.SearchResult = SearchResult;
//# sourceMappingURL=SearchResult.js.map
/***/ }),
/***/ "./node_modules/@textcomplete/core/dist/Strategy.js":
/*!**********************************************************!*\
!*** ./node_modules/@textcomplete/core/dist/Strategy.js ***!
\**********************************************************/
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
"use strict";
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.Strategy = exports.DEFAULT_INDEX = void 0;
const SearchResult_1 = __webpack_require__(/*! ./SearchResult */ "./node_modules/@textcomplete/core/dist/SearchResult.js");
exports.DEFAULT_INDEX = 1;
class Strategy {
constructor(props) {
this.props = props;
this.cache = {};
}
destroy() {
this.cache = {};
return this;
}
replace(data) {
return this.props.replace(data);
}
execute(beforeCursor, callback) {
var _a;
const match = this.matchWithContext(beforeCursor);
if (!match)
return false;
const term = match[(_a = this.props.index) !== null && _a !== void 0 ? _a : exports.DEFAULT_INDEX];
this.search(term, (results) => {
callback(results.map((result) => new SearchResult_1.SearchResult(result, term, this)));
}, match);
return true;
}
renderTemplate(data, term) {
if (this.props.template) {
return this.props.template(data, term);
}
if (typeof data === "string")
return data;
throw new Error(`Unexpected render data type: ${typeof data}. Please implement template parameter by yourself`);
}
getId() {
return this.props.id || null;
}
match(text) {
return typeof this.props.match === "function"
? this.props.match(text)
: text.match(this.props.match);
}
search(term, callback, match) {
if (this.props.cache) {
this.searchWithCach(term, callback, match);
}
else {
this.props.search(term, callback, match);
}
}
matchWithContext(beforeCursor) {
const context = this.context(beforeCursor);
if (context === false)
return null;
return this.match(context === true ? beforeCursor : context);
}
context(beforeCursor) {
return this.props.context ? this.props.context(beforeCursor) : true;
}
searchWithCach(term, callback, match) {
if (this.cache[term] != null) {
callback(this.cache[term]);
}
else {
this.props.search(term, (results) => {
this.cache[term] = results;
callback(results);
}, match);
}
}
}
exports.Strategy = Strategy;
//# sourceMappingURL=Strategy.js.map
/***/ }),
/***/ "./node_modules/@textcomplete/core/dist/Textcomplete.js":
/*!**************************************************************!*\
!*** ./node_modules/@textcomplete/core/dist/Textcomplete.js ***!
\**************************************************************/
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
"use strict";
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.Textcomplete = void 0;
const eventemitter3_1 = __webpack_require__(/*! eventemitter3 */ "./node_modules/eventemitter3/index.js");
const Dropdown_1 = __webpack_require__(/*! ./Dropdown */ "./node_modules/@textcomplete/core/dist/Dropdown.js");
const Completer_1 = __webpack_require__(/*! ./Completer */ "./node_modules/@textcomplete/core/dist/Completer.js");
const PASSTHOUGH_EVENT_NAMES = [
"show",
"shown",
"render",
"rendered",
"selected",
"hidden",
"hide",
];
class Textcomplete extends eventemitter3_1.EventEmitter {
constructor(editor, strategies, option) {
super();
this.editor = editor;
this.isQueryInFlight = false;
this.nextPendingQuery = null;
this.handleHit = ({ searchResults, }) => {
if (searchResults.length) {
this.dropdown.render(searchResults, this.editor.getCursorOffset());
}
else {
this.dropdown.hide();
}
this.isQueryInFlight = false;
if (this.nextPendingQuery !== null)
this.trigger(this.nextPendingQuery);
};
this.handleMove = (e) => {
e.detail.code === "UP" ? this.dropdown.up(e) : this.dropdown.down(e);
};
this.handleEnter = (e) => {
const activeItem = this.dropdown.getActiveItem();
if (activeItem) {
this.dropdown.select(activeItem);
e.preventDefault();
}
else {
this.dropdown.hide();
}
};
this.handleEsc = (e) => {
if (this.dropdown.isShown()) {
this.dropdown.hide();
e.preventDefault();
}
};
this.handleChange = (e) => {
if (e.detail.beforeCursor != null) {
this.trigger(e.detail.beforeCursor);
}
else {
this.dropdown.hide();
}
};
this.handleSelect = (selectEvent) => {
this.emit("select", selectEvent);
if (!selectEvent.defaultPrevented) {
this.editor.applySearchResult(selectEvent.detail.searchResult);
}
};
this.handleResize = () => {
if (this.dropdown.isShown()) {
this.dropdown.setOffset(this.editor.getCursorOffset());
}
};
this.completer = new Completer_1.Completer(strategies);
this.dropdown = Dropdown_1.Dropdown.create((option === null || option === void 0 ? void 0 : option.dropdown) || {});
this.startListening();
}
destroy(destroyEditor = true) {
this.completer.destroy();
this.dropdown.destroy();
if (destroyEditor)
this.editor.destroy();
this.stopListening();
return this;
}
isShown() {
return this.dropdown.isShown();
}
hide() {
this.dropdown.hide();
return this;
}
trigger(beforeCursor) {
if (this.isQueryInFlight) {
this.nextPendingQuery = beforeCursor;
}
else {
this.isQueryInFlight = true;
this.nextPendingQuery = null;
this.completer.run(beforeCursor);
}
return this;
}
startListening() {
var _a;
this.editor
.on("move", this.handleMove)
.on("enter", this.handleEnter)
.on("esc", this.handleEsc)
.on("change", this.handleChange);
this.dropdown.on("select", this.handleSelect);
for (const eventName of PASSTHOUGH_EVENT_NAMES) {
this.dropdown.on(eventName, (e) => this.emit(eventName, e));
}
this.completer.on("hit", this.handleHit);
(_a = this.dropdown.el.ownerDocument.defaultView) === null || _a === void 0 ? void 0 : _a.addEventListener("resize", this.handleResize);
}
stopListening() {
var _a;
(_a = this.dropdown.el.ownerDocument.defaultView) === null || _a === void 0 ? void 0 : _a.removeEventListener("resize", this.handleResize);
this.completer.removeAllListeners();
this.dropdown.removeAllListeners();
this.editor
.removeListener("move", this.handleMove)
.removeListener("enter", this.handleEnter)
.removeListener("esc", this.handleEsc)
.removeListener("change", this.handleChange);
}
}
exports.Textcomplete = Textcomplete;
//# sourceMappingURL=Textcomplete.js.map
/***/ }),
/***/ "./node_modules/@textcomplete/core/dist/index.js":
/*!*******************************************************!*\
!*** ./node_modules/@textcomplete/core/dist/index.js ***!
\*******************************************************/
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
__exportStar(__webpack_require__(/*! ./Completer */ "./node_modules/@textcomplete/core/dist/Completer.js"), exports);
__exportStar(__webpack_require__(/*! ./Dropdown */ "./node_modules/@textcomplete/core/dist/Dropdown.js"), exports);
__exportStar(__webpack_require__(/*! ./Editor */ "./node_modules/@textcomplete/core/dist/Editor.js"), exports);
__exportStar(__webpack_require__(/*! ./SearchResult */ "./node_modules/@textcomplete/core/dist/SearchResult.js"), exports);
__exportStar(__webpack_require__(/*! ./Strategy */ "./node_modules/@textcomplete/core/dist/Strategy.js"), exports);
__exportStar(__webpack_require__(/*! ./Textcomplete */ "./node_modules/@textcomplete/core/dist/Textcomplete.js"), exports);
__exportStar(__webpack_require__(/*! ./utils */ "./node_modules/@textcomplete/core/dist/utils.js"), exports);
//# sourceMappingURL=index.js.map
/***/ }),
/***/ "./node_modules/@textcomplete/core/dist/utils.js":
/*!*******************************************************!*\
!*** ./node_modules/@textcomplete/core/dist/utils.js ***!
\*******************************************************/
/***/ ((__unused_webpack_module, exports) => {
"use strict";
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.createCustomEvent = void 0;
const isCustomEventSupported = typeof window !== "undefined" && !!window.CustomEvent;
const createCustomEvent = (type, options) => {
if (isCustomEventSupported)
return new CustomEvent(type, options);
const event = document.createEvent("CustomEvent");
event.initCustomEvent(type,
/* bubbles */ false, (options === null || options === void 0 ? void 0 : options.cancelable) || false, (options === null || options === void 0 ? void 0 : options.detail) || undefined);
return event;
};
exports.createCustomEvent = createCustomEvent;
//# sourceMappingURL=utils.js.map
/***/ }),
/***/ "./node_modules/@textcomplete/textarea/dist/TextareaEditor.js":
/*!********************************************************************!*\
!*** ./node_modules/@textcomplete/textarea/dist/TextareaEditor.js ***!
\********************************************************************/
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.TextareaEditor = void 0;
const undate_1 = __webpack_require__(/*! undate */ "./node_modules/undate/dist/index.mjs");
const textarea_caret_1 = __importDefault(__webpack_require__(/*! textarea-caret */ "./node_modules/textarea-caret/index.js"));
const core_1 = __webpack_require__(/*! @textcomplete/core */ "./node_modules/@textcomplete/core/dist/index.js");
const utils_1 = __webpack_require__(/*! @textcomplete/utils */ "./node_modules/@textcomplete/utils/dist/index.js");
class TextareaEditor extends core_1.Editor {
constructor(el) {
super();
this.el = el;
this.onInput = () => {
this.emitChangeEvent();
};
this.onKeydown = (e) => {
const code = this.getCode(e);
let event;
if (code === "UP" || code === "DOWN") {
event = this.emitMoveEvent(code);
}
else if (code === "ENTER") {
event = this.emitEnterEvent();
}
else if (code === "ESC") {
event = this.emitEscEvent();
}
if (event && event.defaultPrevented) {
e.preventDefault();
}
};
this.startListening();
}
destroy() {
super.destroy();
this.stopListening();
return this;
}
/**
* @implements {@link Editor#applySearchResult}
*/
applySearchResult(searchResult) {
const beforeCursor = this.getBeforeCursor();
if (beforeCursor != null) {
const replace = searchResult.replace(beforeCursor, this.getAfterCursor());
this.el.focus(); // Clicking a dropdown item removes focus from the element.
if (Array.isArray(replace)) {
(0, undate_1.update)(this.el, replace[0], replace[1]);
if (this.el) {
this.el.dispatchEvent((0, core_1.createCustomEvent)("input"));
}
}
}
}
/**
* @implements {@link Editor#getCursorOffset}
*/
getCursorOffset() {
const elOffset = (0, utils_1.calculateElementOffset)(this.el);
const elScroll = this.getElScroll();
const cursorPosition = this.getCursorPosition();
const lineHeight = (0, utils_1.getLineHeightPx)(this.el);
const top = elOffset.top - elScroll.top + cursorPosition.top + lineHeight;
const left = elOffset.left - elScroll.left + cursorPosition.left;
const clientTop = this.el.getBoundingClientRect().top;
if (this.el.dir !== "rtl") {
return { top, left, lineHeight, clientTop };
}
else {
const right = document.documentElement
? document.documentElement.clientWidth - left
: 0;
return { top, right, lineHeight, clientTop };
}
}
/**
* @implements {@link Editor#getBeforeCursor}
*/
getBeforeCursor() {
return this.el.selectionStart !== this.el.selectionEnd
? null
: this.el.value.substring(0, this.el.selectionEnd);
}
getAfterCursor() {
return this.el.value.substring(this.el.selectionEnd);
}
getElScroll() {
return { top: this.el.scrollTop, left: this.el.scrollLeft };
}
/**
* The input cursor's relative coordinates from the textarea's left
* top corner.
*/
getCursorPosition() {
return (0, textarea_caret_1.default)(this.el, this.el.selectionEnd);
}
startListening() {
this.el.addEventListener("input", this.onInput);
this.el.addEventListener("keydown", this.onKeydown);
}
stopListening() {
this.el.removeEventListener("input", this.onInput);
this.el.removeEventListener("keydown", this.onKeydown);
}
}
exports.TextareaEditor = TextareaEditor;
//# sourceMappingURL=TextareaEditor.js.map
/***/ }),
/***/ "./node_modules/@textcomplete/textarea/dist/index.js":
/*!***********************************************************!*\
!*** ./node_modules/@textcomplete/textarea/dist/index.js ***!
\***********************************************************/
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
"use strict";
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.TextareaEditor = void 0;
var TextareaEditor_1 = __webpack_require__(/*! ./TextareaEditor */ "./node_modules/@textcomplete/textarea/dist/TextareaEditor.js");
Object.defineProperty(exports, "TextareaEditor", ({ enumerable: true, get: function () { return TextareaEditor_1.TextareaEditor; } }));
//# sourceMappingURL=index.js.map
/***/ }),
/***/ "./node_modules/@textcomplete/utils/dist/calculateElementOffset.js":
/*!*************************************************************************!*\
!*** ./node_modules/@textcomplete/utils/dist/calculateElementOffset.js ***!
\*************************************************************************/
/***/ ((__unused_webpack_module, exports) => {
"use strict";
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.calculateElementOffset = void 0;
/**
* Get the current coordinates of the `el` relative to the document.
*/
const calculateElementOffset = (el) => {
const rect = el.getBoundingClientRect();
const owner = el.ownerDocument;
if (owner == null) {
throw new Error("Given element does not belong to document");
}
const { defaultView, documentElement } = owner;
if (defaultView == null) {
throw new Error("Given element does not belong to window");
}
const offset = {
top: rect.top + defaultView.pageYOffset,
left: rect.left + defaultView.pageXOffset,
};
if (documentElement) {
offset.top -= documentElement.clientTop;
offset.left -= documentElement.clientLeft;
}
return offset;
};
exports.calculateElementOffset = calculateElementOffset;
//# sourceMappingURL=calculateElementOffset.js.map
/***/ }),
/***/ "./node_modules/@textcomplete/utils/dist/getLineHeightPx.js":
/*!******************************************************************!*\
!*** ./node_modules/@textcomplete/utils/dist/getLineHeightPx.js ***!
\******************************************************************/
/***/ ((__unused_webpack_module, exports) => {
"use strict";
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.getLineHeightPx = void 0;
const CHAR_CODE_ZERO = "0".charCodeAt(0);
const CHAR_CODE_NINE = "9".charCodeAt(0);
const isDigit = (charCode) => CHAR_CODE_ZERO <= charCode && charCode <= CHAR_CODE_NINE;
const getLineHeightPx = (el) => {
const computedStyle = getComputedStyle(el);
const lineHeight = computedStyle.lineHeight;
// If the char code starts with a digit, it is either a value in pixels,
// or unitless, as per:
// https://drafts.csswg.org/css2/visudet.html#propdef-line-height
// https://drafts.csswg.org/css2/cascade.html#computed-value
if (isDigit(lineHeight.charCodeAt(0))) {
const floatLineHeight = parseFloat(lineHeight);
// In real browsers the value is *always* in pixels, even for unit-less
// line-heights. However, we still check as per the spec.
return isDigit(lineHeight.charCodeAt(lineHeight.length - 1))
? floatLineHeight * parseFloat(computedStyle.fontSize)
: floatLineHeight;
}
// Otherwise, the value is "normal".
// If the line-height is "normal", calculate by font-size
return calculateLineHeightPx(el.nodeName, computedStyle);
};
exports.getLineHeightPx = getLineHeightPx;
/**
* Returns calculated line-height of the given node in pixels.
*/
const calculateLineHeightPx = (nodeName, computedStyle) => {
const body = document.body;
if (!body)
return 0;
const tempNode = document.createElement(nodeName);
tempNode.innerHTML = " ";
Object.assign(tempNode.style, {
fontSize: computedStyle.fontSize,
fontFamily: computedStyle.fontFamily,
padding: "0",
});
body.appendChild(tempNode);
// Make sure textarea has only 1 row
if (tempNode instanceof HTMLTextAreaElement) {
tempNode.rows = 1;
}
// Assume the height of the element is the line-height
const height = tempNode.offsetHeight;
body.removeChild(tempNode);
return height;
};
//# sourceMappingURL=getLineHeightPx.js.map
/***/ }),
/***/ "./node_modules/@textcomplete/utils/dist/index.js":
/*!********************************************************!*\
!*** ./node_modules/@textcomplete/utils/dist/index.js ***!
\********************************************************/
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
__exportStar(__webpack_require__(/*! ./calculateElementOffset */ "./node_modules/@textcomplete/utils/dist/calculateElementOffset.js"), exports);
__exportStar(__webpack_require__(/*! ./getLineHeightPx */ "./node_modules/@textcomplete/utils/dist/getLineHeightPx.js"), exports);
__exportStar(__webpack_require__(/*! ./isSafari */ "./node_modules/@textcomplete/utils/dist/isSafari.js"), exports);
//# sourceMappingURL=index.js.map
/***/ }),
/***/ "./node_modules/@textcomplete/utils/dist/isSafari.js":
/*!***********************************************************!*\
!*** ./node_modules/@textcomplete/utils/dist/isSafari.js ***!
\***********************************************************/
/***/ ((__unused_webpack_module, exports) => {
"use strict";
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.isSafari = void 0;
const isSafari = () => /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
exports.isSafari = isSafari;
//# sourceMappingURL=isSafari.js.map
/***/ }),
/***/ "./node_modules/@vue/devtools-api/lib/esm/const.js":
/*!*********************************************************!*\
!*** ./node_modules/@vue/devtools-api/lib/esm/const.js ***!
\*********************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "HOOK_SETUP": () => (/* binding */ HOOK_SETUP),
/* harmony export */ "HOOK_PLUGIN_SETTINGS_SET": () => (/* binding */ HOOK_PLUGIN_SETTINGS_SET)
/* harmony export */ });
const HOOK_SETUP = 'devtools-plugin:setup';
const HOOK_PLUGIN_SETTINGS_SET = 'plugin:settings:set';
/***/ }),
/***/ "./node_modules/@vue/devtools-api/lib/esm/env.js":
/*!*******************************************************!*\
!*** ./node_modules/@vue/devtools-api/lib/esm/env.js ***!
\*******************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "getDevtoolsGlobalHook": () => (/* binding */ getDevtoolsGlobalHook),
/* harmony export */ "getTarget": () => (/* binding */ getTarget),
/* harmony export */ "isProxyAvailable": () => (/* binding */ isProxyAvailable)
/* harmony export */ });
function getDevtoolsGlobalHook() {
return getTarget().__VUE_DEVTOOLS_GLOBAL_HOOK__;
}
function getTarget() {
// @ts-ignore
return (typeof navigator !== 'undefined' && typeof window !== 'undefined')
? window
: typeof __webpack_require__.g !== 'undefined'
? __webpack_require__.g
: {};
}
const isProxyAvailable = typeof Proxy === 'function';
/***/ }),
/***/ "./node_modules/@vue/devtools-api/lib/esm/index.js":
/*!*********************************************************!*\
!*** ./node_modules/@vue/devtools-api/lib/esm/index.js ***!
\*********************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "isPerformanceSupported": () => (/* reexport safe */ _time_js__WEBPACK_IMPORTED_MODULE_0__.isPerformanceSupported),
/* harmony export */ "now": () => (/* reexport safe */ _time_js__WEBPACK_IMPORTED_MODULE_0__.now),
/* harmony export */ "setupDevtoolsPlugin": () => (/* binding */ setupDevtoolsPlugin)
/* harmony export */ });
/* harmony import */ var _env_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./env.js */ "./node_modules/@vue/devtools-api/lib/esm/env.js");
/* harmony import */ var _const_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./const.js */ "./node_modules/@vue/devtools-api/lib/esm/const.js");
/* harmony import */ var _proxy_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./proxy.js */ "./node_modules/@vue/devtools-api/lib/esm/proxy.js");
/* harmony import */ var _time_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./time.js */ "./node_modules/@vue/devtools-api/lib/esm/time.js");
function setupDevtoolsPlugin(pluginDescriptor, setupFn) {
const descriptor = pluginDescriptor;
const target = (0,_env_js__WEBPACK_IMPORTED_MODULE_1__.getTarget)();
const hook = (0,_env_js__WEBPACK_IMPORTED_MODULE_1__.getDevtoolsGlobalHook)();
const enableProxy = _env_js__WEBPACK_IMPORTED_MODULE_1__.isProxyAvailable && descriptor.enableEarlyProxy;
if (hook && (target.__VUE_DEVTOOLS_PLUGIN_API_AVAILABLE__ || !enableProxy)) {
hook.emit(_const_js__WEBPACK_IMPORTED_MODULE_2__.HOOK_SETUP, pluginDescriptor, setupFn);
}
else {
const proxy = enableProxy ? new _proxy_js__WEBPACK_IMPORTED_MODULE_3__.ApiProxy(descriptor, hook) : null;
const list = target.__VUE_DEVTOOLS_PLUGINS__ = target.__VUE_DEVTOOLS_PLUGINS__ || [];
list.push({
pluginDescriptor: descriptor,
setupFn,
proxy,
});
if (proxy)
setupFn(proxy.proxiedTarget);
}
}
/***/ }),
/***/ "./node_modules/@vue/devtools-api/lib/esm/proxy.js":
/*!*********************************************************!*\
!*** ./node_modules/@vue/devtools-api/lib/esm/proxy.js ***!
\*********************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "ApiProxy": () => (/* binding */ ApiProxy)
/* harmony export */ });
/* harmony import */ var _const_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./const.js */ "./node_modules/@vue/devtools-api/lib/esm/const.js");
/* harmony import */ var _time_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./time.js */ "./node_modules/@vue/devtools-api/lib/esm/time.js");
class ApiProxy {
constructor(plugin, hook) {
this.target = null;
this.targetQueue = [];
this.onQueue = [];
this.plugin = plugin;
this.hook = hook;
const defaultSettings = {};
if (plugin.settings) {
for (const id in plugin.settings) {
const item = plugin.settings[id];
defaultSettings[id] = item.defaultValue;
}
}
const localSettingsSaveId = `__vue-devtools-plugin-settings__${plugin.id}`;
let currentSettings = Object.assign({}, defaultSettings);
try {
const raw = localStorage.getItem(localSettingsSaveId);
const data = JSON.parse(raw);
Object.assign(currentSettings, data);
}
catch (e) {
// noop
}
this.fallbacks = {
getSettings() {
return currentSettings;
},
setSettings(value) {
try {
localStorage.setItem(localSettingsSaveId, JSON.stringify(value));
}
catch (e) {
// noop
}
currentSettings = value;
},
now() {
return (0