XL v1.3.19
This commit is contained in:
parent
e20749ea6f
commit
dda6b7f222
|
@ -41,7 +41,7 @@ var XenoLib = (() => {
|
|||
twitter_username: ''
|
||||
}
|
||||
],
|
||||
version: '1.3.18',
|
||||
version: '1.3.19',
|
||||
description: 'Simple library to complement plugins with shared code without lowering performance.',
|
||||
github: 'https://github.com/1Lighty',
|
||||
github_raw: 'https://raw.githubusercontent.com/1Lighty/BetterDiscordPlugins/master/Plugins/1XenoLib.plugin.js'
|
||||
|
@ -50,7 +50,7 @@ var XenoLib = (() => {
|
|||
{
|
||||
title: 'Boring changes',
|
||||
type: 'fixed',
|
||||
items: ['Fixed notifications not working.', 'Fixed parser error.']
|
||||
items: ['Fix up startup warnings and errors.', 'Fixed notifications closing sometimes if you hover them near the end of the timeout.', 'Future proofing.']
|
||||
}
|
||||
],
|
||||
defaultConfig: [
|
||||
|
@ -432,7 +432,7 @@ var XenoLib = (() => {
|
|||
return null;
|
||||
}
|
||||
};
|
||||
const renderContextMenus = ['NativeContextMenu', 'GuildRoleContextMenu', 'DeveloperContextMenu', 'ScreenshareContextMenu'];
|
||||
const renderContextMenus = ['NativeContextMenu', 'DeveloperContextMenu'];
|
||||
const hookContextMenus = [getModule(/case \w.ContextMenuTypes.CHANNEL_LIST_TEXT/), getModule(/case \w.ContextMenuTypes.GUILD_CHANNEL_LIST/), getModule(/case \w.ContextMenuTypes.USER_CHANNEL_MEMBERS/), getModule(/case \w\.ContextMenuTypes\.MESSAGE_MAIN/)];
|
||||
for (const type of renderContextMenus) {
|
||||
const module = WebpackModules.getByDisplayName(type);
|
||||
|
@ -483,9 +483,9 @@ var XenoLib = (() => {
|
|||
|
||||
const ContextMenuSubMenuItem = WebpackModules.getByDisplayName('FluxContainer(SubMenuItem)');
|
||||
XenoLib.unpatchContext = callback => XenoLib.__contextPatches.splice(XenoLib.__contextPatches.indexOf(callback), 1);
|
||||
XenoLib.createContextMenuItem = (label, action, options = {}) => React.createElement(ContextMenuItem, { label, action: () => (!options.noClose && ContextMenuActions.closeContextMenu(), action()), ...options });
|
||||
XenoLib.createContextMenuSubMenu = (label, items, options = {}) => React.createElement(ContextMenuSubMenuItem, { label, render: items, ...options });
|
||||
XenoLib.createContextMenuGroup = (children, options) => React.createElement(ContextMenuItemsGroup, { children, ...options });
|
||||
XenoLib.createContextMenuItem = (label, action, options = {}) => (!ContextMenuItem ? null : React.createElement(ContextMenuItem, { label, action: () => (!options.noClose && ContextMenuActions.closeContextMenu(), action()), ...options }));
|
||||
XenoLib.createContextMenuSubMenu = (label, items, options = {}) => (!ContextMenuSubMenuItem ? null : React.createElement(ContextMenuSubMenuItem, { label, render: items, ...options }));
|
||||
XenoLib.createContextMenuGroup = (children, options) => (!ContextMenuItemsGroup ? null : React.createElement(ContextMenuItemsGroup, { children, ...options }));
|
||||
|
||||
try {
|
||||
XenoLib.ReactComponents.ButtonOptions = WebpackModules.getByProps('ButtonLink');
|
||||
|
@ -855,7 +855,7 @@ var XenoLib = (() => {
|
|||
const ParsersModule = WebpackModules.getByProps('parseAllowLinks', 'parse');
|
||||
try {
|
||||
const DeepClone = WebpackModules.getByString('/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(');
|
||||
const ReactParserRules = WebpackModules.getByRegex(/function\(\){return \w}$/);
|
||||
const ReactParserRules = WebpackModules.find(m => m.default && m.default.toString().search(/function\(\){return \w}$/) !== -1).default; /* thanks Zere for not fixing the bug ._. */
|
||||
const FANCY_PANTS_PARSER_RULES = DeepClone([WebpackModules.getByProps('RULES', 'ALLOW_LINKS_RULES').ALLOW_LINKS_RULES, ReactParserRules()]);
|
||||
FANCY_PANTS_PARSER_RULES.image = WebpackModules.getByProps('defaultParse').defaultRules.image;
|
||||
return ParsersModule.reactParserFor(FANCY_PANTS_PARSER_RULES);
|
||||
|
@ -941,37 +941,6 @@ var XenoLib = (() => {
|
|||
ModalStack.push(props => React.createElement(XenoLib.ReactComponents.ErrorBoundary, { label: 'Changelog', onError: () => props.onClose() }, React.createElement(ChangelogModal, { className: ChangelogClasses.container, selectable: true, onScroll: _ => _, onClose: _ => _, renderHeader: () => React.createElement(FlexChild.Child, { grow: 1, shrink: 1 }, React.createElement(Titles.default, { tag: Titles.Tags.H4 }, title), React.createElement(TextElement, { size: TextElement.Sizes.SIZE_12, className: ChangelogClasses.date }, `Version ${version}`)), renderFooter: () => React.createElement(FlexChild.Child, { gro: 1, shrink: 1 }, React.createElement(TextElement, { size: TextElement.Sizes.SIZE_12 }, footer ? (typeof footer === 'string' ? FancyParser(footer) : footer) : renderFooter())), children: items, ...props })));
|
||||
};
|
||||
|
||||
/* NOTIFICATIONS START */
|
||||
let UPDATEKEY = {};
|
||||
try {
|
||||
const DeepEqualityCheck = (content1, content2) => {
|
||||
if (typeof content1 !== typeof content2) return false;
|
||||
const isCNT1HTML = content1 instanceof HTMLElement;
|
||||
const isCNT2HTML = content2 instanceof HTMLElement;
|
||||
if (isCNT1HTML !== isCNT2HTML) return false;
|
||||
else if (isCNT1HTML) return content1.isEqualNode(content2);
|
||||
if (content1 !== content2) {
|
||||
if (Array.isArray(content1)) {
|
||||
if (content1.length !== content2.length) return false;
|
||||
for (const [index, item] of content1.entries()) {
|
||||
if (!DeepEqualityCheck(item, content2[index])) return false;
|
||||
}
|
||||
} else if (typeof content1 === 'object') {
|
||||
if (content1.type) {
|
||||
if (typeof content1.type !== typeof content2.type) return false;
|
||||
if (content1.type !== content2.type) return false;
|
||||
}
|
||||
if (typeof content1.props !== typeof content2.props) return false;
|
||||
if (content1.props) {
|
||||
if (Object.keys(content1.props).length !== Object.keys(content2.props).length) return false;
|
||||
for (const prop in content1.props) {
|
||||
if (!DeepEqualityCheck(content1.props[prop], content2.props[prop])) return false;
|
||||
}
|
||||
}
|
||||
} else return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
/* https://github.com/react-spring/zustand
|
||||
* MIT License
|
||||
*
|
||||
|
@ -995,7 +964,7 @@ var XenoLib = (() => {
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
function zustand(createState) {
|
||||
XenoLib.zustand = createState => {
|
||||
var state;
|
||||
var listeners = new Set();
|
||||
const setState = partial => {
|
||||
|
@ -1063,8 +1032,40 @@ var XenoLib = (() => {
|
|||
const api = { setState: setState, getState: getState, subscribe: apiSubscribe, destroy: destroy };
|
||||
state = createState(setState, getState, api);
|
||||
return [useStore, api];
|
||||
};
|
||||
|
||||
/* NOTIFICATIONS START */
|
||||
let UPDATEKEY = {};
|
||||
try {
|
||||
const DeepEqualityCheck = (content1, content2) => {
|
||||
if (typeof content1 !== typeof content2) return false;
|
||||
const isCNT1HTML = content1 instanceof HTMLElement;
|
||||
const isCNT2HTML = content2 instanceof HTMLElement;
|
||||
if (isCNT1HTML !== isCNT2HTML) return false;
|
||||
else if (isCNT1HTML) return content1.isEqualNode(content2);
|
||||
if (content1 !== content2) {
|
||||
if (Array.isArray(content1)) {
|
||||
if (content1.length !== content2.length) return false;
|
||||
for (const [index, item] of content1.entries()) {
|
||||
if (!DeepEqualityCheck(item, content2[index])) return false;
|
||||
}
|
||||
const [useStore, api] = zustand(e => ({ data: [] }));
|
||||
} else if (typeof content1 === 'object') {
|
||||
if (content1.type) {
|
||||
if (typeof content1.type !== typeof content2.type) return false;
|
||||
if (content1.type !== content2.type) return false;
|
||||
}
|
||||
if (typeof content1.props !== typeof content2.props) return false;
|
||||
if (content1.props) {
|
||||
if (Object.keys(content1.props).length !== Object.keys(content2.props).length) return false;
|
||||
for (const prop in content1.props) {
|
||||
if (!DeepEqualityCheck(content1.props[prop], content2.props[prop])) return false;
|
||||
}
|
||||
}
|
||||
} else return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
const [useStore, api] = XenoLib.zustand(e => ({ data: [] }));
|
||||
const defaultOptions = {
|
||||
loading: false,
|
||||
progress: -1,
|
||||
|
@ -1333,6 +1334,7 @@ var XenoLib = (() => {
|
|||
if (this.state.hovered && !this.state.closeFast) return;
|
||||
if (!this.state.closeFast && !LibrarySettings.notifications.timeoutReset) this._startProgressing = Date.now();
|
||||
await next({ progress: 100 });
|
||||
if (this.state.hovered && !this.state.closeFast) return; /* race condition: notif is hovered, but it continues and closes! */
|
||||
this.state.leaving = true;
|
||||
if (!this.state.closeFast) {
|
||||
api.setState(state => {
|
||||
|
@ -1378,7 +1380,8 @@ var XenoLib = (() => {
|
|||
if (this._startProgressing) {
|
||||
this._timeout -= Date.now() - this._startProgressing;
|
||||
}
|
||||
this.setState({ hovered: true });
|
||||
this.state.hovered = true;
|
||||
this.forceUpdate();
|
||||
},
|
||||
onMouseLeave: e => {
|
||||
if (this.state.leaving || !this.props.timeout || this.state.closeFast) return;
|
||||
|
@ -1660,7 +1663,7 @@ var XenoLib = (() => {
|
|||
if (global.BdApi && 'function' == typeof BdApi.getPlugin) {
|
||||
const a = (c, a) => ((c = c.split('.').map(b => parseInt(b))), (a = a.split('.').map(b => parseInt(b))), !!(a[0] > c[0])) || !!(a[0] == c[0] && a[1] > c[1]) || !!(a[0] == c[0] && a[1] == c[1] && a[2] > c[2]),
|
||||
b = BdApi.getPlugin('ZeresPluginLibrary');
|
||||
((b, c) => b && b._config && b._config.info && b._config.info.version && a(b._config.info.version, c))(b, '1.2.14') && (ZeresPluginLibraryOutdated = !0);
|
||||
((b, c) => b && b._config && b._config.info && b._config.info.version && a(b._config.info.version, c))(b, '1.2.16') && (ZeresPluginLibraryOutdated = !0);
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Error checking if ZeresPluginLibrary is out of date', e);
|
||||
|
@ -1694,8 +1697,8 @@ var XenoLib = (() => {
|
|||
e = BdApi.findModuleByProps('push', 'update', 'pop', 'popWithKey'),
|
||||
f = BdApi.findModuleByDisplayName('Text'),
|
||||
g = BdApi.findModule(a => a.defaultProps && a.key && 'confirm-modal' === a.key()),
|
||||
h = () => BdApi.alert(c, BdApi.React.createElement('span', {}, BdApi.React.createElement('div', {}, d), `Due to a slight mishap however, you'll have to download the libraries yourself.`, b || ZeresPluginLibraryOutdated ? BdApi.React.createElement('div', {}, BdApi.React.createElement('a', { href: 'https://betterdiscord.net/ghdl?id=2252', target: '_blank' }, 'Click here to download ZeresPluginLibrary')) : null));
|
||||
if (!e || !g || !f) return h();
|
||||
h = () => BdApi.alert(c, BdApi.React.createElement('span', {}, BdApi.React.createElement('div', {}, d), `Due to a slight mishap however, you'll have to download the libraries yourself. This is not intentional, something went wrong, errors are in console.`, b || ZeresPluginLibraryOutdated ? BdApi.React.createElement('div', {}, BdApi.React.createElement('a', { href: 'https://betterdiscord.net/ghdl?id=2252', target: '_blank' }, 'Click here to download ZeresPluginLibrary')) : null));
|
||||
if (!e || !g || !f) return console.error(`Missing components:${(e ? '' : ' ModalStack') + (g ? '' : ' ConfirmationModalComponent') + (f ? '' : 'TextElement')}`), h();
|
||||
class i extends BdApi.React.PureComponent {
|
||||
constructor(a) {
|
||||
super(a), (this.state = { hasError: !1 });
|
||||
|
@ -1712,15 +1715,18 @@ var XenoLib = (() => {
|
|||
this.props.onConfirm();
|
||||
}
|
||||
}
|
||||
let k = !1;
|
||||
const l = e.push(
|
||||
a =>
|
||||
BdApi.React.createElement(
|
||||
let k = !1,
|
||||
l = !1;
|
||||
const m = e.push(
|
||||
a => {
|
||||
if (l) return null;
|
||||
try {
|
||||
return BdApi.React.createElement(
|
||||
i,
|
||||
{
|
||||
label: 'missing dependency modal',
|
||||
onError: () => {
|
||||
e.popWithKey(l), h();
|
||||
e.popWithKey(m), h();
|
||||
}
|
||||
},
|
||||
BdApi.React.createElement(
|
||||
|
@ -1738,13 +1744,24 @@ var XenoLib = (() => {
|
|||
const a = require('request'),
|
||||
b = require('fs'),
|
||||
c = require('path');
|
||||
a('https://raw.githubusercontent.com/rauenzi/BDPluginLibrary/master/release/0PluginLibrary.plugin.js', (a, d, f) => (a || 200 !== d.statusCode ? (e.popWithKey(l), h()) : void b.writeFile(c.join(BdApi.Plugins.folder, '0PluginLibrary.plugin.js'), f, () => {})));
|
||||
a('https://raw.githubusercontent.com/rauenzi/BDPluginLibrary/master/release/0PluginLibrary.plugin.js', (a, d, f) => {
|
||||
try {
|
||||
if (a || 200 !== d.statusCode) return e.popWithKey(m), h();
|
||||
b.writeFile(c.join(BdApi.Plugins && BdApi.Plugins.folder ? BdApi.Plugins.folder : window.ContentManager.pluginsFolder, '0PluginLibrary.plugin.js'), f, () => {});
|
||||
} catch (a) {
|
||||
console.error('Fatal error downloading ZeresPluginLibrary', a), e.popWithKey(m), h();
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
a
|
||||
)
|
||||
)
|
||||
),
|
||||
);
|
||||
} catch (a) {
|
||||
return console.error('There has been an error constructing the modal', a), (l = !0), e.popWithKey(m), h(), null;
|
||||
}
|
||||
},
|
||||
void 0,
|
||||
`${this.name}_DEP_MODAL`
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue