mirror of
https://github.com/FrankerFaceZ/FrankerFaceZ.git
synced 2025-06-28 15:27:43 +00:00
eslint: run pnpm eslint --fix
This commit is contained in:
parent
d089002698
commit
a69832e3a3
53 changed files with 633 additions and 615 deletions
|
@ -97,7 +97,7 @@
|
||||||
|
|
||||||
// Now, inject our script into the page context.
|
// Now, inject our script into the page context.
|
||||||
const HOST = location.hostname,
|
const HOST = location.hostname,
|
||||||
SERVER = browser.runtime.getURL("web"),
|
SERVER = browser.runtime.getURL('web'),
|
||||||
script = document.createElement('script');
|
script = document.createElement('script');
|
||||||
|
|
||||||
let FLAVOR =
|
let FLAVOR =
|
||||||
|
|
|
@ -138,7 +138,7 @@ class FFZESBridge {
|
||||||
this.port.postMessage(msg);
|
this.port.postMessage(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
}
|
||||||
|
|
||||||
FFZESBridge.Logger = Logger;
|
FFZESBridge.Logger = Logger;
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ export default class Actions extends Module {
|
||||||
this.actions = {};
|
this.actions = {};
|
||||||
this.renderers = {};
|
this.renderers = {};
|
||||||
|
|
||||||
this.filterAction = (x) => x.appearance &&
|
this.filterAction = x => x.appearance &&
|
||||||
this.renderers[x.appearance.type] &&
|
this.renderers[x.appearance.type] &&
|
||||||
(! this.renderers[x.appearance.type].load || this.renderers[x.appearance.type].load(x.appearance)) &&
|
(! this.renderers[x.appearance.type].load || this.renderers[x.appearance.type].load(x.appearance)) &&
|
||||||
(! x.action || this.actions[x.action]);
|
(! x.action || this.actions[x.action]);
|
||||||
|
|
|
@ -61,7 +61,6 @@
|
||||||
{{ t('setting.actions.chat.target-incompatible', 'Note: This is not compatible with pasting a message into chat, and will not function if that is enabled.') }}
|
{{ t('setting.actions.chat.target-incompatible', 'Note: This is not compatible with pasting a message into chat, and will not function if that is enabled.') }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -15,7 +15,9 @@
|
||||||
v-for="profile in profiles"
|
v-for="profile in profiles"
|
||||||
:key="profile.value"
|
:key="profile.value"
|
||||||
:value="profile.value"
|
:value="profile.value"
|
||||||
>{{ profile.i18n_key ? t(profile.i18n_key, profile.name) : profile.name }}</option>
|
>
|
||||||
|
{{ profile.i18n_key ? t(profile.i18n_key, profile.name) : profile.name }}
|
||||||
|
</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -40,7 +40,7 @@ export const pin = {
|
||||||
},
|
},
|
||||||
|
|
||||||
hidden(data, message, current_room, current_user, mod_icons, instance) {
|
hidden(data, message, current_room, current_user, mod_icons, instance) {
|
||||||
let line = instance;
|
const line = instance;
|
||||||
|
|
||||||
if ( ! line )
|
if ( ! line )
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -739,10 +739,10 @@ export default class Badges extends Module {
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
room_id: room_id,
|
room_id,
|
||||||
room_login: room_login,
|
room_login,
|
||||||
user_id: user_id,
|
user_id,
|
||||||
user_login: user_login,
|
user_login,
|
||||||
data
|
data
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -1279,11 +1279,11 @@ export default class Badges extends Module {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ( d.lifetime )
|
if ( d.lifetime )
|
||||||
return '\n' + this.i18n.t('badges.subwoofer.lifetime', 'Lifetime Subwoofer');
|
return `\n${ this.i18n.t('badges.subwoofer.lifetime', 'Lifetime Subwoofer')}`;
|
||||||
|
|
||||||
return '\n' + this.i18n.t('badges.subwoofer.months', '({count, plural, one {# Month} other {# Months}})', {
|
return `\n${ this.i18n.t('badges.subwoofer.months', '({count, plural, one {# Month} other {# Months}})', {
|
||||||
count: d.months
|
count: d.months
|
||||||
});
|
})}`;
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
<template>
|
<template>
|
||||||
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
|
@ -639,7 +639,7 @@ export default class Emotes extends Module {
|
||||||
const overrides = {},
|
const overrides = {},
|
||||||
warnings = {};
|
warnings = {};
|
||||||
|
|
||||||
overrides.addFilter = (filter) => {
|
overrides.addFilter = filter => {
|
||||||
if ( filter )
|
if ( filter )
|
||||||
filter.__source = addon_id;
|
filter.__source = addon_id;
|
||||||
|
|
||||||
|
@ -707,7 +707,7 @@ export default class Emotes extends Module {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( is_dev ) {
|
if ( is_dev ) {
|
||||||
overrides.removeFilter = (filter) => {
|
overrides.removeFilter = filter => {
|
||||||
let type;
|
let type;
|
||||||
if ( typeof filter === 'string' ) type = filter;
|
if ( typeof filter === 'string' ) type = filter;
|
||||||
else type = filter.type;
|
else type = filter.type;
|
||||||
|
@ -1073,7 +1073,7 @@ export default class Emotes extends Module {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Get the current channel.
|
// Get the current channel.
|
||||||
let room_id = this.parent.context.get('context.channelID'),
|
const room_id = this.parent.context.get('context.channelID'),
|
||||||
room_login = this.parent.context.get('context.channel');
|
room_login = this.parent.context.get('context.channel');
|
||||||
|
|
||||||
// And now get the current user's available emote sets.
|
// And now get the current user's available emote sets.
|
||||||
|
@ -2269,9 +2269,9 @@ export default class Emotes extends Module {
|
||||||
if ( ! set )
|
if ( ! set )
|
||||||
throw new Error(`Invalid emote set "${set_id}"`);
|
throw new Error(`Invalid emote set "${set_id}"`);
|
||||||
|
|
||||||
let processed = this.processEmote(emote, set_id);
|
const processed = this.processEmote(emote, set_id);
|
||||||
if ( ! processed )
|
if ( ! processed )
|
||||||
throw new Error("Invalid emote data object.");
|
throw new Error('Invalid emote data object.');
|
||||||
|
|
||||||
const is_disabled = this.shouldFilterEmote(processed, set, set_id);
|
const is_disabled = this.shouldFilterEmote(processed, set, set_id);
|
||||||
|
|
||||||
|
@ -2284,7 +2284,7 @@ export default class Emotes extends Module {
|
||||||
// 6. Old emote disabled. New emote disabled.
|
// 6. Old emote disabled. New emote disabled.
|
||||||
|
|
||||||
// Are we removing a disabled emote?
|
// Are we removing a disabled emote?
|
||||||
let removed = set.disabled_emotes[processed.id];
|
const removed = set.disabled_emotes[processed.id];
|
||||||
if ( removed ) {
|
if ( removed ) {
|
||||||
delete set.disabled_emotes[processed.id];
|
delete set.disabled_emotes[processed.id];
|
||||||
set.disabled_count--;
|
set.disabled_count--;
|
||||||
|
@ -2456,7 +2456,7 @@ export default class Emotes extends Module {
|
||||||
const bad_emotes = [];
|
const bad_emotes = [];
|
||||||
|
|
||||||
for(const emote of ems) {
|
for(const emote of ems) {
|
||||||
let processed = this.processEmote(emote, set_id);
|
const processed = this.processEmote(emote, set_id);
|
||||||
if ( ! processed ) {
|
if ( ! processed ) {
|
||||||
bad_emotes.push(emote);
|
bad_emotes.push(emote);
|
||||||
continue;
|
continue;
|
||||||
|
@ -2554,7 +2554,7 @@ export default class Emotes extends Module {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( emote.modifier && emote.mask?.[1] ) {
|
if ( emote.modifier && emote.mask?.[1] ) {
|
||||||
output = (output || '') + `.modified-emote[data-modifiers~="${emote.id}"] > .chat-line__message--emote {
|
output = `${output || '' }.modified-emote[data-modifiers~="${emote.id}"] > .chat-line__message--emote {
|
||||||
-webkit-mask-image: url("${emote.mask[1]}");
|
-webkit-mask-image: url("${emote.mask[1]}");
|
||||||
-webkit-mask-position: center center;
|
-webkit-mask-position: center center;
|
||||||
}`
|
}`
|
||||||
|
|
|
@ -134,9 +134,7 @@ export default class Chat extends Module {
|
||||||
});*/
|
});*/
|
||||||
|
|
||||||
this.settings.add('debug.link-resolver.source', {
|
this.settings.add('debug.link-resolver.source', {
|
||||||
process: (ctx, val) => {
|
process: (ctx, val) => LINK_DATA_HOSTS[val] ?? LINK_DATA_HOSTS.Production,
|
||||||
return LINK_DATA_HOSTS[val] ?? LINK_DATA_HOSTS.Production;
|
|
||||||
},
|
|
||||||
|
|
||||||
default: null,
|
default: null,
|
||||||
ui: {
|
ui: {
|
||||||
|
@ -1463,13 +1461,13 @@ export default class Chat extends Module {
|
||||||
|
|
||||||
if ( is_dev ) {
|
if ( is_dev ) {
|
||||||
overrides.getUser = (...args) => {
|
overrides.getUser = (...args) => {
|
||||||
let result = this.getUser(...args);
|
const result = this.getUser(...args);
|
||||||
if ( result )
|
if ( result )
|
||||||
return new Proxy(result, user_proxy);
|
return new Proxy(result, user_proxy);
|
||||||
}
|
}
|
||||||
|
|
||||||
overrides.getRoom = (...args) => {
|
overrides.getRoom = (...args) => {
|
||||||
let result = this.getRoom(...args);
|
const result = this.getRoom(...args);
|
||||||
if ( result )
|
if ( result )
|
||||||
return new Proxy(result, room_proxy);
|
return new Proxy(result, room_proxy);
|
||||||
}
|
}
|
||||||
|
@ -1579,7 +1577,7 @@ export default class Chat extends Module {
|
||||||
this.emit('chat:reload-data');
|
this.emit('chat:reload-data');
|
||||||
});
|
});
|
||||||
|
|
||||||
this.on('load_tracker:complete:chat-data', (list) => {
|
this.on('load_tracker:complete:chat-data', list => {
|
||||||
if ( this.triggered_reload ) {
|
if ( this.triggered_reload ) {
|
||||||
const sc = this.resolve('site.chat');
|
const sc = this.resolve('site.chat');
|
||||||
if ( sc?.addNotice )
|
if ( sc?.addNotice )
|
||||||
|
@ -1649,7 +1647,7 @@ export default class Chat extends Module {
|
||||||
|
|
||||||
result.then(value => {
|
result.then(value => {
|
||||||
// If something is already running, don't override it.
|
// If something is already running, don't override it.
|
||||||
let info = this._link_info[url];
|
const info = this._link_info[url];
|
||||||
if ( info )
|
if ( info )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -2599,7 +2597,7 @@ export default class Chat extends Module {
|
||||||
emote = emote_set?.emotes?.[token.id];
|
emote = emote_set?.emotes?.[token.id];
|
||||||
|
|
||||||
if ( emote ) {
|
if ( emote ) {
|
||||||
let urls = (animated ? emote.animated : null) ?? emote.urls;
|
const urls = (animated ? emote.animated : null) ?? emote.urls;
|
||||||
let pair = getBiggestImage(urls);
|
let pair = getBiggestImage(urls);
|
||||||
if (! pair )
|
if (! pair )
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -406,7 +406,7 @@ export const Video = {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let length = video.lengthSeconds;
|
const length = video.lengthSeconds;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
v: 5,
|
v: 5,
|
||||||
|
@ -483,7 +483,7 @@ export const Video = {
|
||||||
type: 'icon',
|
type: 'icon',
|
||||||
name: 'twitch'
|
name: 'twitch'
|
||||||
},
|
},
|
||||||
" Twitch • ",
|
' Twitch • ',
|
||||||
{
|
{
|
||||||
type: 'format',
|
type: 'format',
|
||||||
format: 'datetime',
|
format: 'datetime',
|
||||||
|
|
|
@ -1312,13 +1312,13 @@ export const AddonEmotes = {
|
||||||
hoverSrcSet = big ? token.animSrcSet2 : token.animSrcSet;
|
hoverSrcSet = big ? token.animSrcSet2 : token.animSrcSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
let style = undefined, outerStyle = undefined;
|
let style, outerStyle;
|
||||||
const mods = token.modifiers || [], ml = mods.length,
|
const mods = token.modifiers || [], ml = mods.length,
|
||||||
effects = token.modifier_flags,
|
effects = token.modifier_flags,
|
||||||
is_big = (token.big && ! token.can_big && token.height);
|
is_big = (token.big && ! token.can_big && token.height);
|
||||||
|
|
||||||
let as_bg = (this.emotes.activeAsBackgroundMask & effects) !== 0;
|
let as_bg = (this.emotes.activeAsBackgroundMask & effects) !== 0;
|
||||||
let no_wide = (this.emotes.activeNoWideMask & effects) !== 0;
|
const no_wide = (this.emotes.activeNoWideMask & effects) !== 0;
|
||||||
|
|
||||||
if ( no_wide || effects || ml ) {
|
if ( no_wide || effects || ml ) {
|
||||||
// We need to calculate the size of the emote and the biggest
|
// We need to calculate the size of the emote and the biggest
|
||||||
|
@ -1620,19 +1620,19 @@ export const AddonEmotes = {
|
||||||
|
|
||||||
const target = this.emotes.getTargetEmote();
|
const target = this.emotes.getTargetEmote();
|
||||||
|
|
||||||
let style = {
|
const style = {
|
||||||
width: (target.width ?? 28) * 2,
|
width: (target.width ?? 28) * 2,
|
||||||
height: (target.height ?? 28) * 2
|
height: (target.height ?? 28) * 2
|
||||||
};
|
};
|
||||||
|
|
||||||
let outerStyle = {
|
const outerStyle = {
|
||||||
width: style.width,
|
width: style.width,
|
||||||
height: style.height
|
height: style.height
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
let as_bg = (this.emotes.activeAsBackgroundMask & effects) !== 0;
|
const as_bg = (this.emotes.activeAsBackgroundMask & effects) !== 0;
|
||||||
let no_wide = (this.emotes.activeNoWideMask & effects) !== 0;
|
const no_wide = (this.emotes.activeNoWideMask & effects) !== 0;
|
||||||
|
|
||||||
let changed = false;
|
let changed = false;
|
||||||
|
|
||||||
|
@ -2010,7 +2010,7 @@ export const Emoji = {
|
||||||
}
|
}
|
||||||
|
|
||||||
const text = replace ?
|
const text = replace ?
|
||||||
token.text.replace(JOINER_REPLACEMENT, "\u200d") :
|
token.text.replace(JOINER_REPLACEMENT, '\u200d') :
|
||||||
token.text;
|
token.text;
|
||||||
|
|
||||||
splitter.lastIndex = 0;
|
splitter.lastIndex = 0;
|
||||||
|
|
|
@ -94,10 +94,12 @@
|
||||||
@click="toggleFavorite"
|
@click="toggleFavorite"
|
||||||
>
|
>
|
||||||
<span class="tw-button-icon__icon">
|
<span class="tw-button-icon__icon">
|
||||||
<figure :class="{
|
<figure
|
||||||
|
:class="{
|
||||||
'ffz-i-star': isFavorite,
|
'ffz-i-star': isFavorite,
|
||||||
'ffz-i-star-empty': ! isFavorite
|
'ffz-i-star-empty': ! isFavorite
|
||||||
}" />
|
}"
|
||||||
|
/>
|
||||||
</span>
|
</span>
|
||||||
</button>
|
</button>
|
||||||
<div class="tw-flex tw-flex-column tw-align-self-start">
|
<div class="tw-flex tw-flex-column tw-align-self-start">
|
||||||
|
@ -175,20 +177,20 @@
|
||||||
<ReportForm
|
<ReportForm
|
||||||
v-if="reporting"
|
v-if="reporting"
|
||||||
:emote="emote"
|
:emote="emote"
|
||||||
:getFFZ="getFFZ"
|
:get-f-f-z="getFFZ"
|
||||||
@close="close"
|
@close="close"
|
||||||
/>
|
/>
|
||||||
<component
|
<component
|
||||||
v-if="! reporting && loaded && hasBody"
|
|
||||||
:is="bodyComponent"
|
:is="bodyComponent"
|
||||||
|
v-if="! reporting && loaded && hasBody"
|
||||||
:emote="emote"
|
:emote="emote"
|
||||||
:getFFZ="getFFZ"
|
:get-f-f-z="getFFZ"
|
||||||
@close="close"
|
@close="close"
|
||||||
/>
|
/>
|
||||||
<Modifiers
|
<Modifiers
|
||||||
v-if="! reporting && raw_modifiers && raw_modifiers.length"
|
v-if="! reporting && raw_modifiers && raw_modifiers.length"
|
||||||
:raw_modifiers="raw_modifiers"
|
:raw_modifiers="raw_modifiers"
|
||||||
:getFFZ="getFFZ"
|
:get-f-f-z="getFFZ"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
@ -358,7 +360,7 @@ export default {
|
||||||
if ( this.reportTwitchEmote(this.emote.id, this.emote.channel_id) )
|
if ( this.reportTwitchEmote(this.emote.id, this.emote.channel_id) )
|
||||||
this.close();
|
this.close();
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -371,7 +373,7 @@ export default {
|
||||||
parent = document.body;
|
parent = document.body;
|
||||||
|
|
||||||
const box = el.getBoundingClientRect();
|
const box = el.getBoundingClientRect();
|
||||||
let pbox = parent.getBoundingClientRect();
|
const pbox = parent.getBoundingClientRect();
|
||||||
|
|
||||||
if ( box.top < pbox.top ) {
|
if ( box.top < pbox.top ) {
|
||||||
el.style.top = `${el.offsetTop + (pbox.top - box.top)}px`;
|
el.style.top = `${el.offsetTop + (pbox.top - box.top)}px`;
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
<img
|
<img
|
||||||
class="tw-block tw-image tw-image-avatar"
|
class="tw-block tw-image tw-image-avatar"
|
||||||
:src="image"
|
:src="image"
|
||||||
/>
|
>
|
||||||
</figure>
|
</figure>
|
||||||
<div class="tw-flex-grow-1">
|
<div class="tw-flex-grow-1">
|
||||||
{{ collection.title }}
|
{{ collection.title }}
|
||||||
|
|
|
@ -36,12 +36,12 @@
|
||||||
{{ t('emote-card.error', 'There was an error loading data.') }}
|
{{ t('emote-card.error', 'There was an error loading data.') }}
|
||||||
</div>
|
</div>
|
||||||
<CollectionEntry
|
<CollectionEntry
|
||||||
v-else
|
|
||||||
v-for="collection in collections"
|
v-for="collection in collections"
|
||||||
|
v-else
|
||||||
:key="collection.id"
|
:key="collection.id"
|
||||||
:collection="collection"
|
:collection="collection"
|
||||||
:emote="emote"
|
:emote="emote"
|
||||||
:getFFZ="getFFZ"
|
:get-f-f-z="getFFZ"
|
||||||
:initial="presence.includes(collection.id)"
|
:initial="presence.includes(collection.id)"
|
||||||
/>
|
/>
|
||||||
</simplebar>
|
</simplebar>
|
||||||
|
|
|
@ -19,8 +19,8 @@
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
v-if="expanded"
|
|
||||||
v-for="(mod, idx) in modifiers"
|
v-for="(mod, idx) in modifiers"
|
||||||
|
v-if="expanded"
|
||||||
:key="idx"
|
:key="idx"
|
||||||
class="tw-pd-05 tw-flex tw-align-items-center tw-border-t"
|
class="tw-pd-05 tw-flex tw-align-items-center tw-border-t"
|
||||||
>
|
>
|
||||||
|
@ -48,7 +48,9 @@
|
||||||
</figure>
|
</figure>
|
||||||
</div>
|
</div>
|
||||||
<div class="tw-align-left tw-flex-grow-1 tw-ellipsis tw-mg-x-1">
|
<div class="tw-align-left tw-flex-grow-1 tw-ellipsis tw-mg-x-1">
|
||||||
<h4 class="tw-inline" :title="mod.name">{{ mod.name }}</h4>
|
<h4 class="tw-inline" :title="mod.name">
|
||||||
|
{{ mod.name }}
|
||||||
|
</h4>
|
||||||
<p
|
<p
|
||||||
v-if="mod.source"
|
v-if="mod.source"
|
||||||
class="tw-c-text-alt-2 tw-font-size-6"
|
class="tw-c-text-alt-2 tw-font-size-6"
|
||||||
|
|
|
@ -48,7 +48,9 @@
|
||||||
phrase="emote-card.report-details"
|
phrase="emote-card.report-details"
|
||||||
default="You are reporting this emote for {reason}. Please enter any additional details below:"
|
default="You are reporting this emote for {reason}. Please enter any additional details below:"
|
||||||
>
|
>
|
||||||
<template #reason><code>{{ category.i18n ? t(category.i18n, category.title, category) : category.title }}</code></template>
|
<template #reason>
|
||||||
|
<code>{{ category.i18n ? t(category.i18n, category.title, category) : category.title }}</code>
|
||||||
|
</template>
|
||||||
</t-list>
|
</t-list>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
@ -88,12 +90,12 @@
|
||||||
>
|
>
|
||||||
<input
|
<input
|
||||||
:id="'report$' + id + '$reason$' + idx"
|
:id="'report$' + id + '$reason$' + idx"
|
||||||
:name="'report-reasons$' + id"
|
|
||||||
v-model="pendingCategory"
|
v-model="pendingCategory"
|
||||||
|
:name="'report-reasons$' + id"
|
||||||
:value="reason"
|
:value="reason"
|
||||||
type="radio"
|
type="radio"
|
||||||
class="ffz-radio__input"
|
class="ffz-radio__input"
|
||||||
/>
|
>
|
||||||
<label
|
<label
|
||||||
:for="'report$' + id + '$reason$' + idx"
|
:for="'report$' + id + '$reason$' + idx"
|
||||||
class="tw-block ffz-radio__label tw-pd-r-1 tw-pd-y-1"
|
class="tw-block ffz-radio__label tw-pd-r-1 tw-pd-y-1"
|
||||||
|
@ -117,7 +119,6 @@
|
||||||
</span>
|
</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</template>
|
</template>
|
||||||
</section>
|
</section>
|
||||||
</template>
|
</template>
|
||||||
|
@ -155,7 +156,7 @@ export default {
|
||||||
|
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
REASONS: REASONS,
|
REASONS,
|
||||||
id: id++,
|
id: id++,
|
||||||
message: '',
|
message: '',
|
||||||
pendingCategory: null,
|
pendingCategory: null,
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
<figure class="ffz-emote-card__live-indicator tw-mg-r-05" />
|
<figure class="ffz-emote-card__live-indicator tw-mg-r-05" />
|
||||||
{{ t('emote-card.live', 'LIVE') }}
|
{{ t('emote-card.live', 'LIVE') }}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</section>
|
</section>
|
||||||
<template v-if="isSubscriptionEmote">
|
<template v-if="isSubscriptionEmote">
|
||||||
<p v-if="emote.unlocked">
|
<p v-if="emote.unlocked">
|
||||||
|
@ -75,7 +74,7 @@
|
||||||
:data-title="extra.name"
|
:data-title="extra.name"
|
||||||
class="ffz-tooltip"
|
class="ffz-tooltip"
|
||||||
>
|
>
|
||||||
<img :src="extra.src" :srcset="extra.srcSet" :alt="extra.name" />
|
<img :src="extra.src" :srcset="extra.srcSet" :alt="extra.name">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="emote.channel_id" class="tw-mg-t-1 tw-flex">
|
<div v-if="emote.channel_id" class="tw-mg-t-1 tw-flex">
|
||||||
|
|
|
@ -213,7 +213,7 @@ export default class EmoteCard extends Module {
|
||||||
}
|
}
|
||||||
|
|
||||||
source = this.i18n.t('emote-card.sub', 'Tier {tier} Sub Emote ({source})', {
|
source = this.i18n.t('emote-card.sub', 'Tier {tier} Sub Emote ({source})', {
|
||||||
tier: tier,
|
tier,
|
||||||
source: data.owner?.displayName || data.owner?.login
|
source: data.owner?.displayName || data.owner?.login
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -511,7 +511,7 @@ export default class EmoteCard extends Module {
|
||||||
props: {
|
props: {
|
||||||
raw_emote: deep_copy(emote),
|
raw_emote: deep_copy(emote),
|
||||||
raw_modifiers: modifiers,
|
raw_modifiers: modifiers,
|
||||||
data: data,
|
data,
|
||||||
|
|
||||||
getFFZ: () => this,
|
getFFZ: () => this,
|
||||||
reportTwitchEmote: (...args) => this.reportTwitchEmote(...args),
|
reportTwitchEmote: (...args) => this.reportTwitchEmote(...args),
|
||||||
|
|
|
@ -145,13 +145,13 @@
|
||||||
<ManageFFZ
|
<ManageFFZ
|
||||||
v-if="active_tab === 'manage' && ffzEmote"
|
v-if="active_tab === 'manage' && ffzEmote"
|
||||||
:emote="ffzEmote"
|
:emote="ffzEmote"
|
||||||
:getFFZ="getFFZ"
|
:get-f-f-z="getFFZ"
|
||||||
:no-header="true"
|
:no-header="true"
|
||||||
/>
|
/>
|
||||||
</keep-alive>
|
</keep-alive>
|
||||||
<div
|
<div
|
||||||
class="tw-c-background-base tw-pd-05"
|
|
||||||
v-if="active_tab === 'urls'"
|
v-if="active_tab === 'urls'"
|
||||||
|
class="tw-c-background-base tw-pd-05"
|
||||||
>
|
>
|
||||||
<table v-if="embed && embed.urls && embed.urls.length">
|
<table v-if="embed && embed.urls && embed.urls.length">
|
||||||
<tbody
|
<tbody
|
||||||
|
@ -159,7 +159,9 @@
|
||||||
:key="idx"
|
:key="idx"
|
||||||
>
|
>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="tw-c-text-alt-2">{{ tNumber(idx + 1) }}.</td>
|
<td class="tw-c-text-alt-2">
|
||||||
|
{{ tNumber(idx + 1) }}.
|
||||||
|
</td>
|
||||||
<td class="tw-pd-x-05 tw-word-break-all">
|
<td class="tw-pd-x-05 tw-word-break-all">
|
||||||
<a
|
<a
|
||||||
:data-url="url.url"
|
:data-url="url.url"
|
||||||
|
@ -180,8 +182,8 @@
|
||||||
class="ffz-pill"
|
class="ffz-pill"
|
||||||
>{{ t('link-card.shortened', 'shortened') }}</span>
|
>{{ t('link-card.shortened', 'shortened') }}</span>
|
||||||
<span
|
<span
|
||||||
v-if="url.flags"
|
|
||||||
v-for="flag in url.flags"
|
v-for="flag in url.flags"
|
||||||
|
v-if="url.flags"
|
||||||
class="ffz-pill ffz-pill--live"
|
class="ffz-pill ffz-pill--live"
|
||||||
>{{ flag }}</span>
|
>{{ flag }}</span>
|
||||||
</td>
|
</td>
|
||||||
|
|
|
@ -88,7 +88,7 @@ export default class LinkCard extends Module {
|
||||||
|
|
||||||
out.push(createElement('span', url.host));
|
out.push(createElement('span', url.host));
|
||||||
|
|
||||||
let suffix = url.toString().slice(url.origin.length);
|
const suffix = url.toString().slice(url.origin.length);
|
||||||
|
|
||||||
if ( suffix.length && suffix !== '/' )
|
if ( suffix.length && suffix !== '/' )
|
||||||
out.push(createElement('span', {
|
out.push(createElement('span', {
|
||||||
|
@ -112,7 +112,7 @@ export default class LinkCard extends Module {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let pos_x = event ? event.clientX : window.innerWidth / 2,
|
const pos_x = event ? event.clientX : window.innerWidth / 2,
|
||||||
pos_y = event ? event.clientY + 15 : window.innerHeight / 2;
|
pos_y = event ? event.clientY + 15 : window.innerHeight / 2;
|
||||||
|
|
||||||
/*if ( this.last_card ) {
|
/*if ( this.last_card ) {
|
||||||
|
@ -150,7 +150,7 @@ export default class LinkCard extends Module {
|
||||||
render: h => h('link-card', {
|
render: h => h('link-card', {
|
||||||
props: {
|
props: {
|
||||||
url: link,
|
url: link,
|
||||||
data: data,
|
data,
|
||||||
|
|
||||||
use_dest: this.settings.get('link-cards.use-destination'),
|
use_dest: this.settings.get('link-cards.use-destination'),
|
||||||
|
|
||||||
|
|
|
@ -827,7 +827,7 @@ export default {
|
||||||
},
|
},
|
||||||
|
|
||||||
maybeDynamic(data) {
|
maybeDynamic(data) {
|
||||||
let ap = data.appearance;
|
const ap = data.appearance;
|
||||||
if (ap?.type === 'dynamic') {
|
if (ap?.type === 'dynamic') {
|
||||||
const act = this.action_def,
|
const act = this.action_def,
|
||||||
ffz = this.vuectx.getFFZ(),
|
ffz = this.vuectx.getFFZ(),
|
||||||
|
|
|
@ -156,13 +156,9 @@ const TITLE_MATCH = /^(.+?)?\s*v?(\d+\.\d+\.\d+(?:\-[a-z0-9-]+)?)$/i,
|
||||||
|
|
||||||
|
|
||||||
function linkify(text, repo) {
|
function linkify(text, repo) {
|
||||||
text = text.replace(SETTING_REGEX, (_, link) => {
|
text = text.replace(SETTING_REGEX, (_, link) => `](~${link})`);
|
||||||
return `](~${link})`
|
|
||||||
});
|
|
||||||
|
|
||||||
return text.replace(ISSUE_REGEX, (_, space, number) => {
|
return text.replace(ISSUE_REGEX, (_, space, number) => `${space}[#${number}](https://github.com/FrankerFaceZ/${repo}/issues/${number})`);
|
||||||
return `${space}[#${number}](https://github.com/FrankerFaceZ/${repo}/issues/${number})`;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -248,7 +244,7 @@ export default {
|
||||||
description = lines;
|
description = lines;
|
||||||
}
|
}
|
||||||
|
|
||||||
let message = description.join('\n').trim();
|
const message = description.join('\n').trim();
|
||||||
|
|
||||||
const segments = [];
|
const segments = [];
|
||||||
|
|
||||||
|
|
|
@ -794,7 +794,7 @@ export default {
|
||||||
},
|
},
|
||||||
|
|
||||||
maybeDynamic(data) {
|
maybeDynamic(data) {
|
||||||
let ap = data.appearance;
|
const ap = data.appearance;
|
||||||
if (ap?.type === 'dynamic') {
|
if (ap?.type === 'dynamic') {
|
||||||
const act = this.data.actions[data.action],
|
const act = this.data.actions[data.action],
|
||||||
ffz = this.context.getFFZ(),
|
ffz = this.context.getFFZ(),
|
||||||
|
|
|
@ -36,7 +36,7 @@
|
||||||
class="tw-block tw-font-size-6 tw-full-width ffz-textarea ffz-mg-t-1p"
|
class="tw-block tw-font-size-6 tw-full-width ffz-textarea ffz-mg-t-1p"
|
||||||
@blur="updateMessage"
|
@blur="updateMessage"
|
||||||
@input="onMessageChange"
|
@input="onMessageChange"
|
||||||
/>
|
>
|
||||||
<textarea
|
<textarea
|
||||||
ref="message"
|
ref="message"
|
||||||
class="tw-block tw-font-size-6 tw-full-width ffz-textarea ffz-mg-t-1p tw-border-bottom-left-radius-medium tw-border-bottom-right-radius-medium"
|
class="tw-block tw-font-size-6 tw-full-width ffz-textarea ffz-mg-t-1p tw-border-bottom-left-radius-medium tw-border-bottom-right-radius-medium"
|
||||||
|
@ -151,17 +151,25 @@
|
||||||
{{ tTime(item.timestamp, 'HH:mm:ss') }}
|
{{ tTime(item.timestamp, 'HH:mm:ss') }}
|
||||||
</time>
|
</time>
|
||||||
<div v-if="item.pubsub" class="tw-flex-grow-1">
|
<div v-if="item.pubsub" class="tw-flex-grow-1">
|
||||||
<div class="tw-mg-b-05 tw-border-b tw-pd-b-05">{{ item.topic }}</div>
|
<div class="tw-mg-b-05 tw-border-b tw-pd-b-05">
|
||||||
|
{{ item.topic }}
|
||||||
|
</div>
|
||||||
<div v-html="highlightJson(item.data)" />
|
<div v-html="highlightJson(item.data)" />
|
||||||
</div>
|
</div>
|
||||||
<div v-else-if="item.chat" class="tw-flex-grow-1">
|
<div v-else-if="item.chat" class="tw-flex-grow-1">
|
||||||
<div v-if="item.tags" class="ffz-ct--tags">
|
<div v-if="item.tags" class="ffz-ct--tags">
|
||||||
@<template v-for="(tag, key) in item.tags"><span class="ffz-ct--tag">{{ key }}</span>=<span class="ffz-ct--tag-value">{{ tag }}</span>;</template>
|
@<template v-for="(tag, key) in item.tags">
|
||||||
|
<span class="ffz-ct--tag">{{ key }}</span>=<span class="ffz-ct--tag-value">{{ tag }}</span>;
|
||||||
|
</template>
|
||||||
</div>
|
</div>
|
||||||
<div class="ffz-ct--prefix">
|
<div class="ffz-ct--prefix">
|
||||||
<template v-if="item.prefix">:<span v-if="item.user" class="ffz-ct--user">{{ item.user }}</span><span class="ffz-ct--prefix">{{ item.prefix }}</span></template>
|
<template v-if="item.prefix">
|
||||||
|
:<span v-if="item.user" class="ffz-ct--user">{{ item.user }}</span><span class="ffz-ct--prefix">{{ item.prefix }}</span>
|
||||||
|
</template>
|
||||||
<span class="ffz-ct--command">{{ item.command }}</span>
|
<span class="ffz-ct--command">{{ item.command }}</span>
|
||||||
<template v-if="item.channel">#<span class="ffz-ct--channel">{{ item.channel }}</span></template>
|
<template v-if="item.channel">
|
||||||
|
#<span class="ffz-ct--channel">{{ item.channel }}</span>
|
||||||
|
</template>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="item.last_param" class="ffz-ct--params">
|
<div v-if="item.last_param" class="ffz-ct--params">
|
||||||
<span v-for="para in item.params" class="ffz-ct--param">{{ para }}</span>
|
<span v-for="para in item.params" class="ffz-ct--param">{{ para }}</span>
|
||||||
|
@ -212,8 +220,8 @@ const IGNORE_COMMANDS = [
|
||||||
|
|
||||||
let LOADED_SAMPLES = [
|
let LOADED_SAMPLES = [
|
||||||
{
|
{
|
||||||
"name": "Ping",
|
'name': 'Ping',
|
||||||
"data": "PING :tmi.twitch.tv"
|
'data': 'PING :tmi.twitch.tv'
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -228,7 +236,7 @@ export default {
|
||||||
const message = state?.ffz_ct_message ?? samples[0].data;
|
const message = state?.ffz_ct_message ?? samples[0].data;
|
||||||
const topic = state?.ffz_ct_topic ?? samples[0].topic ?? '';
|
const topic = state?.ffz_ct_topic ?? samples[0].topic ?? '';
|
||||||
|
|
||||||
let is_custom = true;
|
const is_custom = true;
|
||||||
/*for(const item of samples) {
|
/*for(const item of samples) {
|
||||||
if ( ! item.topic )
|
if ( ! item.topic )
|
||||||
item.topic = '';
|
item.topic = '';
|
||||||
|
@ -384,7 +392,7 @@ export default {
|
||||||
if ( conn.ws )
|
if ( conn.ws )
|
||||||
conn.ws.onmessage = conn.onSocketMessage;
|
conn.ws.onmessage = conn.onSocketMessage;
|
||||||
|
|
||||||
this.addLog("Started capturing chat.");
|
this.addLog('Started capturing chat.');
|
||||||
|
|
||||||
this.listening_chat = true;
|
this.listening_chat = true;
|
||||||
},
|
},
|
||||||
|
@ -400,7 +408,7 @@ export default {
|
||||||
if ( conn.ws )
|
if ( conn.ws )
|
||||||
conn.ws.onmessage = conn.onSocketMessage;
|
conn.ws.onmessage = conn.onSocketMessage;
|
||||||
|
|
||||||
this.addLog("Stopped capturing chat.");
|
this.addLog('Stopped capturing chat.');
|
||||||
|
|
||||||
this.listening_chat = false;
|
this.listening_chat = false;
|
||||||
},
|
},
|
||||||
|
@ -451,7 +459,7 @@ export default {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
this.chat.on('site.subpump:pubsub-message', this.handlePubsub, this);
|
this.chat.on('site.subpump:pubsub-message', this.handlePubsub, this);
|
||||||
this.addLog("Started capturing PubSub.");
|
this.addLog('Started capturing PubSub.');
|
||||||
|
|
||||||
this.listening_pubsub = true;
|
this.listening_pubsub = true;
|
||||||
},
|
},
|
||||||
|
@ -461,7 +469,7 @@ export default {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
this.chat.off('site.subpump:pubsub-message', this.handlePubsub, this);
|
this.chat.off('site.subpump:pubsub-message', this.handlePubsub, this);
|
||||||
this.addLog("Stopped capturing PubSub.");
|
this.addLog('Stopped capturing PubSub.');
|
||||||
|
|
||||||
this.listening_pubsub = false;
|
this.listening_pubsub = false;
|
||||||
},
|
},
|
||||||
|
@ -589,7 +597,7 @@ export default {
|
||||||
data = JSON.parse(this.message);
|
data = JSON.parse(this.message);
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
alert("Unable to parse message.");
|
alert('Unable to parse message.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -612,7 +620,7 @@ export default {
|
||||||
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
alert("Unable to parse message.");
|
alert('Unable to parse message.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,17 +56,19 @@
|
||||||
<img
|
<img
|
||||||
:src="provider.icon"
|
:src="provider.icon"
|
||||||
class="tw-image"
|
class="tw-image"
|
||||||
/>
|
>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<h4 v-if="! provider.name">
|
<h4 v-if="! provider.name">
|
||||||
{{ t('emote-source.unknown', 'Unknown ({id})', provider) }}
|
{{ t('emote-source.unknown', 'Unknown ({id})', provider) }}
|
||||||
</h4>
|
</h4>
|
||||||
<h4 v-else>{{
|
<h4 v-else>
|
||||||
|
{{
|
||||||
provider.i18n_key
|
provider.i18n_key
|
||||||
? t(provider.i18n_key, provider.name, provider)
|
? t(provider.i18n_key, provider.name, provider)
|
||||||
: provider.name
|
: provider.name
|
||||||
}}</h4>
|
}}
|
||||||
|
</h4>
|
||||||
<div v-if="provider.description">
|
<div v-if="provider.description">
|
||||||
{{ provider.desc_i18n_key ? t(provider.desc_i18n_key, provider.description, provider) : provider.description }}
|
{{ provider.desc_i18n_key ? t(provider.desc_i18n_key, provider.description, provider) : provider.description }}
|
||||||
</div>
|
</div>
|
||||||
|
@ -83,7 +85,7 @@ import settingMixin from '../setting-mixin';
|
||||||
import Sortable from 'sortablejs';
|
import Sortable from 'sortablejs';
|
||||||
import { deep_copy } from 'utilities/object';
|
import { deep_copy } from 'utilities/object';
|
||||||
|
|
||||||
let last_id = 0;
|
const last_id = 0;
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
mixins: [settingMixin],
|
mixins: [settingMixin],
|
||||||
|
|
|
@ -8,8 +8,8 @@
|
||||||
{{ t('setting.filters.missing', 'This rule of type "{type}" cannot be loaded. It may be from an add-on that is not loaded.', {type: editing && editing.type}) }}
|
{{ t('setting.filters.missing', 'This rule of type "{type}" cannot be loaded. It may be from an add-on that is not loaded.', {type: editing && editing.type}) }}
|
||||||
</div>
|
</div>
|
||||||
<component
|
<component
|
||||||
v-else
|
|
||||||
:is="component"
|
:is="component"
|
||||||
|
v-else
|
||||||
v-model="editing"
|
v-model="editing"
|
||||||
:type="type"
|
:type="type"
|
||||||
:filters="filters"
|
:filters="filters"
|
||||||
|
|
|
@ -212,7 +212,7 @@
|
||||||
<h1 class="tw-mg-5 ffz-i-zreknarf loading" />
|
<h1 class="tw-mg-5 ffz-i-zreknarf loading" />
|
||||||
</div>
|
</div>
|
||||||
<code v-else-if="typeof raw_data === 'string'">{{ raw_data }}</code>
|
<code v-else-if="typeof raw_data === 'string'">{{ raw_data }}</code>
|
||||||
<code v-else v-html="highlightJson(raw_data, true)"></code>
|
<code v-else v-html="highlightJson(raw_data, true)" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -100,8 +100,8 @@
|
||||||
<input
|
<input
|
||||||
id="ffz:editor:name"
|
id="ffz:editor:name"
|
||||||
ref="name"
|
ref="name"
|
||||||
:disabled="isEphemeral"
|
|
||||||
v-model="name"
|
v-model="name"
|
||||||
|
:disabled="isEphemeral"
|
||||||
class="tw-full-width tw-border-radius-medium tw-font-size-6 tw-pd-x-1 tw-pd-y-05 ffz-input"
|
class="tw-full-width tw-border-radius-medium tw-font-size-6 tw-pd-x-1 tw-pd-y-05 ffz-input"
|
||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
|
@ -114,8 +114,8 @@
|
||||||
<textarea
|
<textarea
|
||||||
id="ffz:editor:description"
|
id="ffz:editor:description"
|
||||||
ref="desc"
|
ref="desc"
|
||||||
:disabled="isEphemeral"
|
|
||||||
v-model="desc"
|
v-model="desc"
|
||||||
|
:disabled="isEphemeral"
|
||||||
class="tw-full-width tw-border-radius-medium tw-font-size-6 tw-pd-x-1 tw-pd-y-05 ffz-input"
|
class="tw-full-width tw-border-radius-medium tw-font-size-6 tw-pd-x-1 tw-pd-y-05 ffz-input"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
@ -129,8 +129,8 @@
|
||||||
<key-picker
|
<key-picker
|
||||||
id="ffz:editor:hotkey"
|
id="ffz:editor:hotkey"
|
||||||
ref="hotkey"
|
ref="hotkey"
|
||||||
:disabled="isEphemeral"
|
|
||||||
v-model="hotkey"
|
v-model="hotkey"
|
||||||
|
:disabled="isEphemeral"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -541,7 +541,7 @@ export default {
|
||||||
prof.update({
|
prof.update({
|
||||||
i18n_key: undefined,
|
i18n_key: undefined,
|
||||||
desc_i18n_key: undefined,
|
desc_i18n_key: undefined,
|
||||||
description: `${prof.description ? prof.description + '\n' : ''}${this.t('setting.backup-restore.imported-at', 'Imported at {now,datetime}.', {now: new Date})}`
|
description: `${prof.description ? `${prof.description }\n` : ''}${this.t('setting.backup-restore.imported-at', 'Imported at {now,datetime}.', {now: new Date})}`
|
||||||
});
|
});
|
||||||
|
|
||||||
let i = 0;
|
let i = 0;
|
||||||
|
|
|
@ -58,7 +58,6 @@
|
||||||
{{ t('setting.filter.add-default-tip', 'Add all of the default values to this profile.') }}
|
{{ t('setting.filter.add-default-tip', 'Add all of the default values to this profile.') }}
|
||||||
</span>
|
</span>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<filter-editor
|
<filter-editor
|
||||||
|
@ -68,7 +67,6 @@
|
||||||
:preview="preview"
|
:preview="preview"
|
||||||
@input="onInput"
|
@input="onInput"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
|
@ -42,12 +42,16 @@
|
||||||
<div v-if="page == 'versions'">
|
<div v-if="page == 'versions'">
|
||||||
<table>
|
<table>
|
||||||
<thead class="tw-border-b tw-pd-b-05 tw-mg-b-05 tw-strong">
|
<thead class="tw-border-b tw-pd-b-05 tw-mg-b-05 tw-strong">
|
||||||
<th class="tw-pd-r-1">{{ t('socket.info.version', 'Version') }}</th>
|
<th class="tw-pd-r-1">
|
||||||
|
{{ t('socket.info.version', 'Version') }}
|
||||||
|
</th>
|
||||||
<th>{{ t('socket.info.count', 'Count') }}</th>
|
<th>{{ t('socket.info.count', 'Count') }}</th>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr v-for="entry in version_list" :key="entry[0]">
|
<tr v-for="entry in version_list" :key="entry[0]">
|
||||||
<td class="tw-pd-r-1">{{ entry[0] }}</td>
|
<td class="tw-pd-r-1">
|
||||||
|
{{ entry[0] }}
|
||||||
|
</td>
|
||||||
<td>{{ tNumber(entry[1]) }}</td>
|
<td>{{ tNumber(entry[1]) }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
@ -56,12 +60,16 @@
|
||||||
<div v-if="page == 'commands'">
|
<div v-if="page == 'commands'">
|
||||||
<table>
|
<table>
|
||||||
<thead class="tw-border-b tw-pd-b-05 tw-mg-b-05 tw-strong">
|
<thead class="tw-border-b tw-pd-b-05 tw-mg-b-05 tw-strong">
|
||||||
<th class="tw-pd-r-1">{{ t('socket.info.command', 'Command') }}</th>
|
<th class="tw-pd-r-1">
|
||||||
|
{{ t('socket.info.command', 'Command') }}
|
||||||
|
</th>
|
||||||
<th>{{ t('socket.info.count', 'Count') }}</th>
|
<th>{{ t('socket.info.count', 'Count') }}</th>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr v-for="entry in command_list" :key="entry[0]">
|
<tr v-for="entry in command_list" :key="entry[0]">
|
||||||
<td class="tw-pd-r-1">{{ entry[0] }}</td>
|
<td class="tw-pd-r-1">
|
||||||
|
{{ entry[0] }}
|
||||||
|
</td>
|
||||||
<td>{{ tNumber(entry[1]) }}</td>
|
<td>{{ tNumber(entry[1]) }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|
|
@ -7,8 +7,8 @@
|
||||||
</div>
|
</div>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<button
|
<button
|
||||||
@click="accept"
|
|
||||||
class="tw-button tw-mg-b-05"
|
class="tw-button tw-mg-b-05"
|
||||||
|
@click="accept"
|
||||||
>
|
>
|
||||||
<span class="tw-button__text">
|
<span class="tw-button__text">
|
||||||
{{ acceptText }}
|
{{ acceptText }}
|
||||||
|
@ -16,8 +16,8 @@
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
v-if="! declined"
|
v-if="! declined"
|
||||||
@click="reject"
|
|
||||||
class="tw-button tw-button--text tw-block"
|
class="tw-button tw-button--text tw-block"
|
||||||
|
@click="reject"
|
||||||
>
|
>
|
||||||
<span class="tw-button__text">
|
<span class="tw-button__text">
|
||||||
{{ t('tooltip.decline-tos', 'I do not accept.') }}
|
{{ t('tooltip.decline-tos', 'I do not accept.') }}
|
||||||
|
|
|
@ -30,11 +30,15 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="ffz--i18n-sub-entry tw-mg-l-05 tw-flex-grow-1">
|
<div class="ffz--i18n-sub-entry tw-mg-l-05 tw-flex-grow-1">
|
||||||
<div v-if="error && ! open">
|
<div v-if="error && ! open">
|
||||||
<div class="tw-strong">{{ t('i18n.ui.error', 'Error') }}</div>
|
<div class="tw-strong">
|
||||||
|
{{ t('i18n.ui.error', 'Error') }}
|
||||||
|
</div>
|
||||||
<code class="tw-font-size-7 tw-c-text-alt-2">{{ error }}</code>
|
<code class="tw-font-size-7 tw-c-text-alt-2">{{ error }}</code>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="source">
|
<div v-if="source">
|
||||||
<div class="tw-strong">{{ t('i18n.ui.source', 'Source') }}</div>
|
<div class="tw-strong">
|
||||||
|
{{ t('i18n.ui.source', 'Source') }}
|
||||||
|
</div>
|
||||||
<div
|
<div
|
||||||
v-for="(line, idx) in source"
|
v-for="(line, idx) in source"
|
||||||
:key="idx"
|
:key="idx"
|
||||||
|
@ -50,7 +54,9 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="context_str && ! open">
|
<div v-if="context_str && ! open">
|
||||||
<div class="tw-strong">{{ t('i18n.ui.context', 'Context') }}</div>
|
<div class="tw-strong">
|
||||||
|
{{ t('i18n.ui.context', 'Context') }}
|
||||||
|
</div>
|
||||||
<code class="tw-font-size-7 tw-c-text-alt-2">{{ context_str }}</code>
|
<code class="tw-font-size-7 tw-c-text-alt-2">{{ context_str }}</code>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -4,7 +4,9 @@
|
||||||
class="ffz-dialog tw-elevation-3 tw-c-background-alt tw-c-text-base tw-border tw-flex tw-flex-nowrap tw-flex-column"
|
class="ffz-dialog tw-elevation-3 tw-c-background-alt tw-c-text-base tw-border tw-flex tw-flex-nowrap tw-flex-column"
|
||||||
>
|
>
|
||||||
<header class="tw-c-background-base tw-full-width tw-align-items-center tw-flex tw-flex-nowrap" @dblclick="resize">
|
<header class="tw-c-background-base tw-full-width tw-align-items-center tw-flex tw-flex-nowrap" @dblclick="resize">
|
||||||
<h3 class="ffz-i-zreknarf ffz-i-pd-1">{{ t('i18n.ui.title', 'Translation Tester') }}</h3>
|
<h3 class="ffz-i-zreknarf ffz-i-pd-1">
|
||||||
|
{{ t('i18n.ui.title', 'Translation Tester') }}
|
||||||
|
</h3>
|
||||||
<div class="tw-flex-grow-1 tw-pd-x-2">
|
<div class="tw-flex-grow-1 tw-pd-x-2">
|
||||||
<div class="tw-search-input">
|
<div class="tw-search-input">
|
||||||
<label for="ffz-main-menu.search" class="tw-hide-accessible">{{ t('i18n.ui.search', 'Search Strings') }}</label>
|
<label for="ffz-main-menu.search" class="tw-hide-accessible">{{ t('i18n.ui.search', 'Search Strings') }}</label>
|
||||||
|
|
|
@ -120,7 +120,7 @@
|
||||||
:channel="channel"
|
:channel="channel"
|
||||||
:user="user"
|
:user="user"
|
||||||
:self="self"
|
:self="self"
|
||||||
:getFFZ="getFFZ"
|
:get-f-f-z="getFFZ"
|
||||||
@close="close"
|
@close="close"
|
||||||
/>
|
/>
|
||||||
</keep-alive>
|
</keep-alive>
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div />
|
||||||
|
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
|
@ -42,10 +42,6 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
created() {
|
|
||||||
this.detectMonitors();
|
|
||||||
},
|
|
||||||
|
|
||||||
watch: {
|
watch: {
|
||||||
selected() {
|
selected() {
|
||||||
if ( ! this.ready || ! this.selected )
|
if ( ! this.ready || ! this.selected )
|
||||||
|
@ -62,6 +58,10 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
created() {
|
||||||
|
this.detectMonitors();
|
||||||
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
async detectMonitors() {
|
async detectMonitors() {
|
||||||
let data;
|
let data;
|
||||||
|
|
|
@ -42,7 +42,7 @@ export default class BaseSite extends Module {
|
||||||
if ( this._reactDom )
|
if ( this._reactDom )
|
||||||
return this._reactDom;
|
return this._reactDom;
|
||||||
|
|
||||||
let reactDom = this.resolve('site.web_munch')?.getModule?.('react-dom');
|
const reactDom = this.resolve('site.web_munch')?.getModule?.('react-dom');
|
||||||
if ( reactDom?.createPortal )
|
if ( reactDom?.createPortal )
|
||||||
return this._reactDom = reactDom;
|
return this._reactDom = reactDom;
|
||||||
}
|
}
|
||||||
|
|
|
@ -644,7 +644,7 @@ export default class Metadata extends Module {
|
||||||
if ( order != null )
|
if ( order != null )
|
||||||
el.style.order = order;
|
el.style.order = order;
|
||||||
|
|
||||||
let subcontainer = container;
|
const subcontainer = container;
|
||||||
|
|
||||||
/*if ( button )
|
/*if ( button )
|
||||||
subcontainer = container.querySelector('.tw-flex:last-child') || container;
|
subcontainer = container.querySelector('.tw-flex:last-child') || container;
|
||||||
|
|
|
@ -633,7 +633,7 @@ export default class PlayerBase extends Module {
|
||||||
default: false,
|
default: false,
|
||||||
ui: {
|
ui: {
|
||||||
path: 'Player > General >> Playback',
|
path: 'Player > General >> Playback',
|
||||||
title: "Pause/Unpause the player by clicking.",
|
title: 'Pause/Unpause the player by clicking.',
|
||||||
component: 'setting-check-box'
|
component: 'setting-check-box'
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -2572,7 +2572,7 @@ export default class EmoteMenu extends Module {
|
||||||
effect_prefix: emote.modifier ? emote.modifier_prefix : false,
|
effect_prefix: emote.modifier ? emote.modifier_prefix : false,
|
||||||
name: emote.name,
|
name: emote.name,
|
||||||
favorite: is_fav,
|
favorite: is_fav,
|
||||||
locked: locked,
|
locked,
|
||||||
hidden: known_hidden.includes(emote.id),
|
hidden: known_hidden.includes(emote.id),
|
||||||
height: emote.height,
|
height: emote.height,
|
||||||
width: emote.width
|
width: emote.width
|
||||||
|
|
|
@ -163,31 +163,31 @@ const INLINE_CALLOUT_TYPES = {
|
||||||
};
|
};
|
||||||
|
|
||||||
const CALLOUT_TYPES = {
|
const CALLOUT_TYPES = {
|
||||||
"AppointedModerator": "appointed-moderator",
|
'AppointedModerator': 'appointed-moderator',
|
||||||
"BitsBadgeTier": "bits-badge-tier",
|
'BitsBadgeTier': 'bits-badge-tier',
|
||||||
"BitsPowerUps": "bits-power-ups",
|
'BitsPowerUps': 'bits-power-ups',
|
||||||
"ClipLiveNudge": "clip-live-nudge",
|
'ClipLiveNudge': 'clip-live-nudge',
|
||||||
"CommunityMoment": "community-moment",
|
'CommunityMoment': 'community-moment',
|
||||||
"CommunityPointsRewards": "community-points-rewards",
|
'CommunityPointsRewards': 'community-points-rewards',
|
||||||
"CosmicAbyss": "cosmic-abyss",
|
'CosmicAbyss': 'cosmic-abyss',
|
||||||
"CreatorAnniversaries": "creator-anniversaries",
|
'CreatorAnniversaries': 'creator-anniversaries',
|
||||||
"Drop": "drop",
|
'Drop': 'drop',
|
||||||
"EarnedSubBadge": "earned-sub-badge",
|
'EarnedSubBadge': 'earned-sub-badge',
|
||||||
"FavoritedGuestCollab": "favorited-guest-collab",
|
'FavoritedGuestCollab': 'favorited-guest-collab',
|
||||||
"GiftBadgeExpiration": "gift-badge-expiration",
|
'GiftBadgeExpiration': 'gift-badge-expiration',
|
||||||
"GiftBadgeRestored": "gift-badge-restored",
|
'GiftBadgeRestored': 'gift-badge-restored',
|
||||||
"GiftBundleUpSell": "gift-bundle-up-sell",
|
'GiftBundleUpSell': 'gift-bundle-up-sell',
|
||||||
"HypeTrainRewards": "hype-train-rewards",
|
'HypeTrainRewards': 'hype-train-rewards',
|
||||||
"LapsedBitsUser": "lapsed-bits-user",
|
'LapsedBitsUser': 'lapsed-bits-user',
|
||||||
"PartnerPlusUpSellNudge": "partner-plus-up-sell-nudge",
|
'PartnerPlusUpSellNudge': 'partner-plus-up-sell-nudge',
|
||||||
"ReplyByKeyboard": "reply-by-keyboard",
|
'ReplyByKeyboard': 'reply-by-keyboard',
|
||||||
"RequestToJoinAccepted": "request-to-join-accepted",
|
'RequestToJoinAccepted': 'request-to-join-accepted',
|
||||||
"STPromo": "st-promo",
|
'STPromo': 'st-promo',
|
||||||
"ShareResub": "share-resub",
|
'ShareResub': 'share-resub',
|
||||||
"SubtemberPromoBits": "subtember-promo-bits",
|
'SubtemberPromoBits': 'subtember-promo-bits',
|
||||||
"ThankSubGifter": "thank-sub-gifter",
|
'ThankSubGifter': 'thank-sub-gifter',
|
||||||
"TurnOffAnimatedEmotes": "turn-off-animated-emotes",
|
'TurnOffAnimatedEmotes': 'turn-off-animated-emotes',
|
||||||
"WalletDrop": "wallet-drop"
|
'WalletDrop': 'wallet-drop'
|
||||||
};
|
};
|
||||||
|
|
||||||
const UNBLOCKABLE_CALLOUTS = [];
|
const UNBLOCKABLE_CALLOUTS = [];
|
||||||
|
@ -1641,7 +1641,7 @@ export default class ChatHook extends Module {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
t.insertChannelPointMessage(msg);
|
t.insertChannelPointMessage(msg);
|
||||||
return;
|
|
||||||
|
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
t.log.error('Error handling reward event:', err);
|
t.log.error('Error handling reward event:', err);
|
||||||
|
@ -2001,7 +2001,7 @@ export default class ChatHook extends Module {
|
||||||
const event = inst.props?.event?.callout?.contextMenuProps?.event ?? inst.props?.event,
|
const event = inst.props?.event?.callout?.contextMenuProps?.event ?? inst.props?.event,
|
||||||
type = event?.type;
|
type = event?.type;
|
||||||
|
|
||||||
if ( type !== 'drop' || inst._ffz_clicking || ! this.chat.context.get("chat.drops.auto-rewards") )
|
if ( type !== 'drop' || inst._ffz_clicking || ! this.chat.context.get('chat.drops.auto-rewards') )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
//console.warn('autoClickDrop', event, inst);
|
//console.warn('autoClickDrop', event, inst);
|
||||||
|
@ -2021,7 +2021,7 @@ export default class ChatHook extends Module {
|
||||||
const event = inst.props?.event?.callout?.contextMenuProps?.event ?? inst.props?.event,
|
const event = inst.props?.event?.callout?.contextMenuProps?.event ?? inst.props?.event,
|
||||||
type = event?.type;
|
type = event?.type;
|
||||||
|
|
||||||
if ( type !== 'drop' || ! this.chat.context.get("chat.drops.auto-rewards") )
|
if ( type !== 'drop' || ! this.chat.context.get('chat.drops.auto-rewards') )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
btn.click();
|
btn.click();
|
||||||
|
@ -3317,7 +3317,7 @@ export default class ChatHook extends Module {
|
||||||
id: out.id,
|
id: out.id,
|
||||||
displayName: out.user.userDisplayName,
|
displayName: out.user.userDisplayName,
|
||||||
login: out.user.userLogin,
|
login: out.user.userLogin,
|
||||||
reward: reward,
|
reward,
|
||||||
message: out,
|
message: out,
|
||||||
userID: out.user.userID,
|
userID: out.user.userID,
|
||||||
animationID: e.animationID,
|
animationID: e.animationID,
|
||||||
|
|
|
@ -41,9 +41,7 @@ export default class ChatLine extends Module {
|
||||||
this.line_types = {};
|
this.line_types = {};
|
||||||
|
|
||||||
this.line_types.unknown = {
|
this.line_types.unknown = {
|
||||||
renderNotice: (msg, current_user, room, inst, e) => {
|
renderNotice: (msg, current_user, room, inst, e) => `Unknown message type: ${msg.ffz_type}`
|
||||||
return `Unknown message type: ${msg.ffz_type}`
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
this.line_types.notice = {
|
this.line_types.notice = {
|
||||||
|
@ -179,19 +177,17 @@ export default class ChatLine extends Module {
|
||||||
};
|
};
|
||||||
|
|
||||||
this.line_types.cheer = {
|
this.line_types.cheer = {
|
||||||
renderNotice: (msg, current_user, room, inst, e) => {
|
renderNotice: (msg, current_user, room, inst, e) => this.i18n.tList(
|
||||||
return this.i18n.tList(
|
|
||||||
'chat.bits-message',
|
'chat.bits-message',
|
||||||
'Cheered {count, plural, one {# Bit} other {# Bits}}',
|
'Cheered {count, plural, one {# Bit} other {# Bits}}',
|
||||||
{
|
{
|
||||||
count: msg.bits || 0
|
count: msg.bits || 0
|
||||||
}
|
}
|
||||||
);
|
)
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
this.line_types.points = {
|
this.line_types.points = {
|
||||||
getClass: (msg) => {
|
getClass: msg => {
|
||||||
const highlight = msg.ffz_reward_highlight && this.chat.context.get('chat.points.allow-highlight') === 2;
|
const highlight = msg.ffz_reward_highlight && this.chat.context.get('chat.points.allow-highlight') === 2;
|
||||||
|
|
||||||
return `ffz--points-line tw-pd-l-1 tw-pd-r-2 ${highlight ? 'ffz-custom-color ffz--points-highlight' : ''}`;
|
return `ffz--points-line tw-pd-l-1 tw-pd-r-2 ${highlight ? 'ffz-custom-color ffz--points-highlight' : ''}`;
|
||||||
|
|
|
@ -873,9 +873,9 @@ export default class Directory extends Module {
|
||||||
else if ( ! el.contains(el.ffz_flags_el) )
|
else if ( ! el.contains(el.ffz_flags_el) )
|
||||||
container.appendChild(el.ffz_flags_el);
|
container.appendChild(el.ffz_flags_el);
|
||||||
|
|
||||||
el.ffz_flags_tt.textContent = this.i18n.t('metadata.flags.tooltip', 'Intended for certain audiences. May contain:')
|
el.ffz_flags_tt.textContent = `${this.i18n.t('metadata.flags.tooltip', 'Intended for certain audiences. May contain:')
|
||||||
+ '\n\n'
|
}\n\n${
|
||||||
+ el._ffz_flags.map(x => x.localizedName).join('\n');
|
el._ffz_flags.map(x => x.localizedName).join('\n')}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
clearFlags(el) {
|
clearFlags(el) {
|
||||||
|
|
|
@ -105,7 +105,7 @@ export default class ModView extends Module {
|
||||||
const root = this.fine.getReactInstance(el);
|
const root = this.fine.getReactInstance(el);
|
||||||
|
|
||||||
let channel = null;
|
let channel = null;
|
||||||
let node = this.fine.searchNode(root, n => {
|
const node = this.fine.searchNode(root, n => {
|
||||||
let i = 0;
|
let i = 0;
|
||||||
let state = n.memoizedState;
|
let state = n.memoizedState;
|
||||||
while(state != null && channel == null && i < 50) {
|
while(state != null && channel == null && i < 50) {
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
<div class="tw-relative">
|
<div class="tw-relative">
|
||||||
<div class="tw-absolute tw-align-items-center tw-c-text-alt-2 tw-flex tw-full-height ffz-input__icon tw-justify-content-center tw-left-0 tw-top-0 tw-z-default">
|
<div class="tw-absolute tw-align-items-center tw-c-text-alt-2 tw-flex tw-full-height ffz-input__icon tw-justify-content-center tw-left-0 tw-top-0 tw-z-default">
|
||||||
<figure class="tw-mg-y-05 tw-mg-x-05">
|
<figure class="tw-mg-y-05 tw-mg-x-05">
|
||||||
<img class="ffz-preview-emote" v-if="val.src" :src="val.src" />
|
<img v-if="val.src" class="ffz-preview-emote" :src="val.src">
|
||||||
</figure>
|
</figure>
|
||||||
</div>
|
</div>
|
||||||
<input
|
<input
|
||||||
|
@ -24,7 +24,7 @@
|
||||||
@focus="onFocus"
|
@focus="onFocus"
|
||||||
@blur="onBlur"
|
@blur="onBlur"
|
||||||
@keydown.escape="open = false"
|
@keydown.escape="open = false"
|
||||||
/>
|
>
|
||||||
<button
|
<button
|
||||||
v-if="clearable"
|
v-if="clearable"
|
||||||
class="tw-absolute tw-right-0 tw-top-0 tw-button tw-button--text ffz-il-tooltip__container"
|
class="tw-absolute tw-right-0 tw-top-0 tw-button tw-button--text ffz-il-tooltip__container"
|
||||||
|
@ -65,7 +65,7 @@
|
||||||
@blur="onBlur"
|
@blur="onBlur"
|
||||||
>
|
>
|
||||||
<figure :class="`tw-mg-y-05 tw-mg-x-1`">
|
<figure :class="`tw-mg-y-05 tw-mg-x-1`">
|
||||||
<img :src="i.src" />
|
<img :src="i.src">
|
||||||
</figure>
|
</figure>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
// better use of promise return values in general.
|
// better use of promise return values in general.
|
||||||
|
|
||||||
// bytes.ts
|
// bytes.ts
|
||||||
var _Bytes = class _Bytes {
|
const _Bytes = class _Bytes {
|
||||||
constructor(bytes) {
|
constructor(bytes) {
|
||||||
this._bytes = bytes;
|
this._bytes = bytes;
|
||||||
this.length = bytes.length;
|
this.length = bytes.length;
|
||||||
|
@ -12,7 +12,7 @@ var _Bytes = class _Bytes {
|
||||||
return this._bytes;
|
return this._bytes;
|
||||||
}
|
}
|
||||||
async sha1() {
|
async sha1() {
|
||||||
const hash = await cryptoSubtle().digest("SHA-1", this._bytes);
|
const hash = await cryptoSubtle().digest('SHA-1', this._bytes);
|
||||||
return new _Bytes(new Uint8Array(hash));
|
return new _Bytes(new Uint8Array(hash));
|
||||||
}
|
}
|
||||||
concat(other) {
|
concat(other) {
|
||||||
|
@ -25,28 +25,28 @@ var _Bytes = class _Bytes {
|
||||||
return (await _Bytes.ofUtf8(`blob ${this.length}\0`).concat(this).sha1()).hex();
|
return (await _Bytes.ofUtf8(`blob ${this.length}\0`).concat(this).sha1()).hex();
|
||||||
}
|
}
|
||||||
async hmacSha1(key) {
|
async hmacSha1(key) {
|
||||||
const cryptoKey = await cryptoSubtle().importKey("raw", key._bytes, { name: "HMAC", hash: "SHA-1" }, true, ["sign"]);
|
const cryptoKey = await cryptoSubtle().importKey('raw', key._bytes, { name: 'HMAC', hash: 'SHA-1' }, true, ['sign']);
|
||||||
const sig = await cryptoSubtle().sign("HMAC", cryptoKey, this._bytes);
|
const sig = await cryptoSubtle().sign('HMAC', cryptoKey, this._bytes);
|
||||||
return new _Bytes(new Uint8Array(sig));
|
return new _Bytes(new Uint8Array(sig));
|
||||||
}
|
}
|
||||||
async sha256() {
|
async sha256() {
|
||||||
const hash = await cryptoSubtle().digest("SHA-256", this._bytes);
|
const hash = await cryptoSubtle().digest('SHA-256', this._bytes);
|
||||||
return new _Bytes(new Uint8Array(hash));
|
return new _Bytes(new Uint8Array(hash));
|
||||||
}
|
}
|
||||||
async hmacSha256(key) {
|
async hmacSha256(key) {
|
||||||
const cryptoKey = await cryptoSubtle().importKey("raw", key._bytes, { name: "HMAC", hash: "SHA-256" }, true, ["sign"]);
|
const cryptoKey = await cryptoSubtle().importKey('raw', key._bytes, { name: 'HMAC', hash: 'SHA-256' }, true, ['sign']);
|
||||||
const sig = await cryptoSubtle().sign("HMAC", cryptoKey, this._bytes);
|
const sig = await cryptoSubtle().sign('HMAC', cryptoKey, this._bytes);
|
||||||
return new _Bytes(new Uint8Array(sig));
|
return new _Bytes(new Uint8Array(sig));
|
||||||
}
|
}
|
||||||
hex() {
|
hex() {
|
||||||
const a = Array.from(this._bytes);
|
const a = Array.from(this._bytes);
|
||||||
return a.map((b) => b.toString(16).padStart(2, "0")).join("");
|
return a.map(b => b.toString(16).padStart(2, '0')).join('');
|
||||||
}
|
}
|
||||||
static ofHex(hex2) {
|
static ofHex(hex2) {
|
||||||
if (hex2 === "") {
|
if (hex2 === '') {
|
||||||
return _Bytes.EMPTY;
|
return _Bytes.EMPTY;
|
||||||
}
|
}
|
||||||
return new _Bytes(new Uint8Array(hex2.match(/.{1,2}/g).map((byte) => parseInt(byte, 16))));
|
return new _Bytes(new Uint8Array(hex2.match(/.{1,2}/g).map(byte => parseInt(byte, 16))));
|
||||||
}
|
}
|
||||||
utf8() {
|
utf8() {
|
||||||
return new TextDecoder().decode(this._bytes);
|
return new TextDecoder().decode(this._bytes);
|
||||||
|
@ -75,7 +75,7 @@ var _Bytes = class _Bytes {
|
||||||
return new _Bytes(rt);
|
return new _Bytes(rt);
|
||||||
}
|
}
|
||||||
static formatSize(sizeInBytes) {
|
static formatSize(sizeInBytes) {
|
||||||
const sign = sizeInBytes < 0 ? "-" : "";
|
const sign = sizeInBytes < 0 ? '-' : '';
|
||||||
let size = Math.abs(sizeInBytes);
|
let size = Math.abs(sizeInBytes);
|
||||||
if (size < 1024)
|
if (size < 1024)
|
||||||
return `${sign}${size}bytes`;
|
return `${sign}${size}bytes`;
|
||||||
|
@ -87,14 +87,14 @@ var _Bytes = class _Bytes {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
_Bytes.EMPTY = new _Bytes(new Uint8Array(0));
|
_Bytes.EMPTY = new _Bytes(new Uint8Array(0));
|
||||||
var Bytes = _Bytes;
|
const Bytes = _Bytes;
|
||||||
function roundToOneDecimal(value) {
|
function roundToOneDecimal(value) {
|
||||||
return Math.round(value * 10) / 10;
|
return Math.round(value * 10) / 10;
|
||||||
}
|
}
|
||||||
function base64Encode(buf) {
|
function base64Encode(buf) {
|
||||||
let string = "";
|
let string = '';
|
||||||
buf.forEach(
|
buf.forEach(
|
||||||
(byte) => {
|
byte => {
|
||||||
string += String.fromCharCode(byte);
|
string += String.fromCharCode(byte);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -102,7 +102,7 @@ var _Bytes = class _Bytes {
|
||||||
}
|
}
|
||||||
function base64Decode(str, urlSafe) {
|
function base64Decode(str, urlSafe) {
|
||||||
if (urlSafe)
|
if (urlSafe)
|
||||||
str = str.replace(/_/g, "/").replace(/-/g, "+");
|
str = str.replace(/_/g, '/').replace(/-/g, '+');
|
||||||
str = atob(str);
|
str = atob(str);
|
||||||
const length = str.length, buf = new ArrayBuffer(length), bufView = new Uint8Array(buf);
|
const length = str.length, buf = new ArrayBuffer(length), bufView = new Uint8Array(buf);
|
||||||
for (let i = 0; i < length; i++) {
|
for (let i = 0; i < length; i++) {
|
||||||
|
@ -120,13 +120,13 @@ var _Bytes = class _Bytes {
|
||||||
throw new Error(`Bad ${name}: expected ${expected}, found ${value}`);
|
throw new Error(`Bad ${name}: expected ${expected}, found ${value}`);
|
||||||
}
|
}
|
||||||
function check(name, value, isValid) {
|
function check(name, value, isValid) {
|
||||||
const valid = typeof isValid === "boolean" && isValid || typeof isValid === "function" && isValid(value);
|
const valid = typeof isValid === 'boolean' && isValid || typeof isValid === 'function' && isValid(value);
|
||||||
if (!valid)
|
if (!valid)
|
||||||
throw new Error(`Bad ${name}: ${value}`);
|
throw new Error(`Bad ${name}: ${value}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// mqtt/mqtt.ts
|
// mqtt/mqtt.ts
|
||||||
var Mqtt = class {
|
const Mqtt = class {
|
||||||
};
|
};
|
||||||
/** Enable debug-level logging throughout MqttClient and its dependencies. */
|
/** Enable debug-level logging throughout MqttClient and its dependencies. */
|
||||||
Mqtt.DEBUG = false;
|
Mqtt.DEBUG = false;
|
||||||
|
@ -151,7 +151,7 @@ var _Bytes = class _Bytes {
|
||||||
encodedByte = buffer[i++];
|
encodedByte = buffer[i++];
|
||||||
value += (encodedByte & 127) * multiplier;
|
value += (encodedByte & 127) * multiplier;
|
||||||
if (multiplier > 128 * 128 * 128)
|
if (multiplier > 128 * 128 * 128)
|
||||||
throw Error("malformed length");
|
throw Error('malformed length');
|
||||||
multiplier *= 128;
|
multiplier *= 128;
|
||||||
} while ((encodedByte & 128) != 0);
|
} while ((encodedByte & 128) != 0);
|
||||||
return { value, bytesUsed: i - startIndex };
|
return { value, bytesUsed: i - startIndex };
|
||||||
|
@ -159,7 +159,7 @@ var _Bytes = class _Bytes {
|
||||||
function encodeUtf8(value) {
|
function encodeUtf8(value) {
|
||||||
const arr = encoder.encode(value);
|
const arr = encoder.encode(value);
|
||||||
if (arr.length > 65535)
|
if (arr.length > 65535)
|
||||||
throw new Error("the maximum size of a UTF-8 Encoded String is 65,535 bytes.");
|
throw new Error('the maximum size of a UTF-8 Encoded String is 65,535 bytes.');
|
||||||
const lengthBytes = [arr.length >> 8, arr.length & 255];
|
const lengthBytes = [arr.length >> 8, arr.length & 255];
|
||||||
return [...lengthBytes, ...arr];
|
return [...lengthBytes, ...arr];
|
||||||
}
|
}
|
||||||
|
@ -221,25 +221,25 @@ var _Bytes = class _Bytes {
|
||||||
}
|
}
|
||||||
function computeControlPacketTypeName(type) {
|
function computeControlPacketTypeName(type) {
|
||||||
if (type === CONNECT)
|
if (type === CONNECT)
|
||||||
return "CONNECT";
|
return 'CONNECT';
|
||||||
if (type === CONNACK)
|
if (type === CONNACK)
|
||||||
return "CONNACK";
|
return 'CONNACK';
|
||||||
if (type === PUBLISH)
|
if (type === PUBLISH)
|
||||||
return "PUBLISH";
|
return 'PUBLISH';
|
||||||
if (type === SUBSCRIBE)
|
if (type === SUBSCRIBE)
|
||||||
return "SUBSCRIBE";
|
return 'SUBSCRIBE';
|
||||||
if (type === SUBACK)
|
if (type === SUBACK)
|
||||||
return "SUBACK";
|
return 'SUBACK';
|
||||||
if (type === UNSUBSCRIBE)
|
if (type === UNSUBSCRIBE)
|
||||||
return "UNSUBSCRIBE";
|
return 'UNSUBSCRIBE';
|
||||||
if (type === UNSUBACK)
|
if (type === UNSUBACK)
|
||||||
return "UNSUBACK";
|
return 'UNSUBACK';
|
||||||
if (type === PINGREQ)
|
if (type === PINGREQ)
|
||||||
return "PINGREQ";
|
return 'PINGREQ';
|
||||||
if (type === PINGRESP)
|
if (type === PINGRESP)
|
||||||
return "PINGRESP";
|
return 'PINGRESP';
|
||||||
if (type === DISCONNECT)
|
if (type === DISCONNECT)
|
||||||
return "DISCONNECT";
|
return 'DISCONNECT';
|
||||||
throw new Error(`computeControlPacketTypeName: Unsupported controlPacketType: ${type}`);
|
throw new Error(`computeControlPacketTypeName: Unsupported controlPacketType: ${type}`);
|
||||||
}
|
}
|
||||||
var CONNECT = 1;
|
var CONNECT = 1;
|
||||||
|
@ -247,7 +247,7 @@ var _Bytes = class _Bytes {
|
||||||
const { type, keepAlive, clientId, username, password, clean } = message;
|
const { type, keepAlive, clientId, username, password, clean } = message;
|
||||||
const connectFlags = (username ? 1 : 0) << 7 | 1 << 6 | (clean ? 1 : 0) << 1;
|
const connectFlags = (username ? 1 : 0) << 7 | 1 << 6 | (clean ? 1 : 0) << 1;
|
||||||
const variableHeader = [
|
const variableHeader = [
|
||||||
...encodeUtf8("MQTT"),
|
...encodeUtf8('MQTT'),
|
||||||
// protocol name
|
// protocol name
|
||||||
5,
|
5,
|
||||||
// protocol version
|
// protocol version
|
||||||
|
@ -272,11 +272,11 @@ var _Bytes = class _Bytes {
|
||||||
const connectAcknowledgeFlagsReserved = connectAcknowledgeFlags & 254;
|
const connectAcknowledgeFlagsReserved = connectAcknowledgeFlags & 254;
|
||||||
if (DEBUG)
|
if (DEBUG)
|
||||||
console.log({ sessionPresent, connectAcknowledgeFlagsReserved });
|
console.log({ sessionPresent, connectAcknowledgeFlagsReserved });
|
||||||
checkEqual("connectAcknowledgeFlagsReserved", connectAcknowledgeFlagsReserved, 0);
|
checkEqual('connectAcknowledgeFlagsReserved', connectAcknowledgeFlagsReserved, 0);
|
||||||
let rt = { type: CONNACK, sessionPresent };
|
let rt = { type: CONNACK, sessionPresent };
|
||||||
rt = { ...rt, reason: readReason(reader, CONNACK_REASONS) };
|
rt = { ...rt, reason: readReason(reader, CONNACK_REASONS) };
|
||||||
if (reader.remaining() > 0) {
|
if (reader.remaining() > 0) {
|
||||||
readProperties(reader, (propertyId) => {
|
readProperties(reader, propertyId => {
|
||||||
if (propertyId === 17) {
|
if (propertyId === 17) {
|
||||||
const sessionExpiryInterval = reader.readUint32();
|
const sessionExpiryInterval = reader.readUint32();
|
||||||
if (DEBUG)
|
if (DEBUG)
|
||||||
|
@ -286,10 +286,10 @@ var _Bytes = class _Bytes {
|
||||||
const maximumQos = reader.readUint8();
|
const maximumQos = reader.readUint8();
|
||||||
if (DEBUG)
|
if (DEBUG)
|
||||||
console.log({ maximumQos });
|
console.log({ maximumQos });
|
||||||
check("maximumQos", maximumQos, maximumQos === 0 || maximumQos === 1);
|
check('maximumQos', maximumQos, maximumQos === 0 || maximumQos === 1);
|
||||||
rt = { ...rt, maximumQos };
|
rt = { ...rt, maximumQos };
|
||||||
} else if (propertyId === 37) {
|
} else if (propertyId === 37) {
|
||||||
rt = { ...rt, retainAvailable: readBooleanProperty("retainAvailable", reader) };
|
rt = { ...rt, retainAvailable: readBooleanProperty('retainAvailable', reader) };
|
||||||
} else if (propertyId === 39) {
|
} else if (propertyId === 39) {
|
||||||
const maximumPacketSize = reader.readUint32();
|
const maximumPacketSize = reader.readUint32();
|
||||||
if (DEBUG)
|
if (DEBUG)
|
||||||
|
@ -306,11 +306,11 @@ var _Bytes = class _Bytes {
|
||||||
console.log({ topicAliasMaximum });
|
console.log({ topicAliasMaximum });
|
||||||
rt = { ...rt, topicAliasMaximum };
|
rt = { ...rt, topicAliasMaximum };
|
||||||
} else if (propertyId === 40) {
|
} else if (propertyId === 40) {
|
||||||
rt = { ...rt, wildcardSubscriptionAvailable: readBooleanProperty("wildcardSubscriptionAvailable", reader) };
|
rt = { ...rt, wildcardSubscriptionAvailable: readBooleanProperty('wildcardSubscriptionAvailable', reader) };
|
||||||
} else if (propertyId === 41) {
|
} else if (propertyId === 41) {
|
||||||
rt = { ...rt, subscriptionIdentifiersAvailable: readBooleanProperty("subscriptionIdentifiersAvailable", reader) };
|
rt = { ...rt, subscriptionIdentifiersAvailable: readBooleanProperty('subscriptionIdentifiersAvailable', reader) };
|
||||||
} else if (propertyId === 42) {
|
} else if (propertyId === 42) {
|
||||||
rt = { ...rt, sharedSubscriptionAvailable: readBooleanProperty("sharedSubscriptionAvailable", reader) };
|
rt = { ...rt, sharedSubscriptionAvailable: readBooleanProperty('sharedSubscriptionAvailable', reader) };
|
||||||
} else if (propertyId === 19) {
|
} else if (propertyId === 19) {
|
||||||
const serverKeepAlive = reader.readUint16();
|
const serverKeepAlive = reader.readUint16();
|
||||||
if (DEBUG)
|
if (DEBUG)
|
||||||
|
@ -326,33 +326,33 @@ var _Bytes = class _Bytes {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
checkEqual("remaining", reader.remaining(), 0);
|
checkEqual('remaining', reader.remaining(), 0);
|
||||||
return rt;
|
return rt;
|
||||||
}
|
}
|
||||||
var CONNACK_REASONS = {
|
var CONNACK_REASONS = {
|
||||||
// 3.2.2.2 Connect Reason Code
|
// 3.2.2.2 Connect Reason Code
|
||||||
0: ["Success", "The Connection is accepted."],
|
0: ['Success', 'The Connection is accepted.'],
|
||||||
128: ["Unspecified error", "The Server does not wish to reveal the reason for the failure, or none of the other Reason Codes apply."],
|
128: ['Unspecified error', 'The Server does not wish to reveal the reason for the failure, or none of the other Reason Codes apply.'],
|
||||||
129: ["Malformed Packet", "Data within the CONNECT packet could not be correctly parsed."],
|
129: ['Malformed Packet', 'Data within the CONNECT packet could not be correctly parsed.'],
|
||||||
130: ["Protocol Error", "Data in the CONNECT packet does not conform to this specification."],
|
130: ['Protocol Error', 'Data in the CONNECT packet does not conform to this specification.'],
|
||||||
131: ["Implementation specific error", "The CONNECT is valid but is not accepted by this Server."],
|
131: ['Implementation specific error', 'The CONNECT is valid but is not accepted by this Server.'],
|
||||||
132: ["Unsupported Protocol Version", "The Server does not support the version of the MQTT protocol requested by the Client."],
|
132: ['Unsupported Protocol Version', 'The Server does not support the version of the MQTT protocol requested by the Client.'],
|
||||||
133: ["Client Identifier not valid", "The Client Identifier is a valid string but is not allowed by the Server."],
|
133: ['Client Identifier not valid', 'The Client Identifier is a valid string but is not allowed by the Server.'],
|
||||||
134: ["Bad User Name or Password", "The Server does not accept the User Name or Password specified by the Client"],
|
134: ['Bad User Name or Password', 'The Server does not accept the User Name or Password specified by the Client'],
|
||||||
135: ["Not authorized", "The Client is not authorized to connect."],
|
135: ['Not authorized', 'The Client is not authorized to connect.'],
|
||||||
136: ["Server unavailable", "The MQTT Server is not available."],
|
136: ['Server unavailable', 'The MQTT Server is not available.'],
|
||||||
137: ["Server busy", "The Server is busy. Try again later."],
|
137: ['Server busy', 'The Server is busy. Try again later.'],
|
||||||
138: ["Banned", "This Client has been banned by administrative action. Contact the server administrator."],
|
138: ['Banned', 'This Client has been banned by administrative action. Contact the server administrator.'],
|
||||||
140: ["Bad authentication method", "The authentication method is not supported or does not match the authentication method currently in use."],
|
140: ['Bad authentication method', 'The authentication method is not supported or does not match the authentication method currently in use.'],
|
||||||
144: ["Topic Name invalid", "The Will Topic Name is not malformed, but is not accepted by this Server."],
|
144: ['Topic Name invalid', 'The Will Topic Name is not malformed, but is not accepted by this Server.'],
|
||||||
149: ["Packet too large", "The CONNECT packet exceeded the maximum permissible size."],
|
149: ['Packet too large', 'The CONNECT packet exceeded the maximum permissible size.'],
|
||||||
151: ["Quota exceeded", "An implementation or administrative imposed limit has been exceeded."],
|
151: ['Quota exceeded', 'An implementation or administrative imposed limit has been exceeded.'],
|
||||||
153: ["Payload format invalid", "The Will Payload does not match the specified Payload Format Indicator."],
|
153: ['Payload format invalid', 'The Will Payload does not match the specified Payload Format Indicator.'],
|
||||||
154: ["Retain not supported", "The Server does not support retained messages, and Will Retain was set to 1."],
|
154: ['Retain not supported', 'The Server does not support retained messages, and Will Retain was set to 1.'],
|
||||||
155: ["QoS not supported", "The Server does not support the QoS set in Will QoS."],
|
155: ['QoS not supported', 'The Server does not support the QoS set in Will QoS.'],
|
||||||
156: ["Use another server", "The Client should temporarily use another server."],
|
156: ['Use another server', 'The Client should temporarily use another server.'],
|
||||||
157: ["Server moved", "The Client should permanently use another server."],
|
157: ['Server moved', 'The Client should permanently use another server.'],
|
||||||
159: ["Connection rate exceeded", "The connection rate limit has been exceeded."]
|
159: ['Connection rate exceeded', 'The connection rate limit has been exceeded.']
|
||||||
};
|
};
|
||||||
var PUBLISH = 3;
|
var PUBLISH = 3;
|
||||||
function readPublish(reader, controlPacketFlags) {
|
function readPublish(reader, controlPacketFlags) {
|
||||||
|
@ -370,12 +370,12 @@ var _Bytes = class _Bytes {
|
||||||
if (qosLevel === 1 || qosLevel === 2) {
|
if (qosLevel === 1 || qosLevel === 2) {
|
||||||
rt = { ...rt, packetId: reader.readUint16() };
|
rt = { ...rt, packetId: reader.readUint16() };
|
||||||
}
|
}
|
||||||
readProperties(reader, (propertyId) => {
|
readProperties(reader, propertyId => {
|
||||||
if (propertyId === 1) {
|
if (propertyId === 1) {
|
||||||
const payloadFormatIndicator = reader.readUint8();
|
const payloadFormatIndicator = reader.readUint8();
|
||||||
if (DEBUG)
|
if (DEBUG)
|
||||||
console.log({ payloadFormatIndicator });
|
console.log({ payloadFormatIndicator });
|
||||||
check("payloadFormatIndicator", payloadFormatIndicator, payloadFormatIndicator === 0 || payloadFormatIndicator === 1);
|
check('payloadFormatIndicator', payloadFormatIndicator, payloadFormatIndicator === 0 || payloadFormatIndicator === 1);
|
||||||
rt = { ...rt, payloadFormatIndicator };
|
rt = { ...rt, payloadFormatIndicator };
|
||||||
} else if (propertyId === 3) {
|
} else if (propertyId === 3) {
|
||||||
const contentType = reader.readUtf8();
|
const contentType = reader.readUtf8();
|
||||||
|
@ -424,7 +424,7 @@ var _Bytes = class _Bytes {
|
||||||
...encodeVariableByteInteger(0)
|
...encodeVariableByteInteger(0)
|
||||||
// properties = none
|
// properties = none
|
||||||
];
|
];
|
||||||
const payload = subscriptions.flatMap((v) => [
|
const payload = subscriptions.flatMap(v => [
|
||||||
...encodeUtf8(v.topicFilter),
|
...encodeUtf8(v.topicFilter),
|
||||||
0
|
0
|
||||||
/* qos 0, no no-local, no retain as published, retain handling = Send retained messages at the time of the subscribe */
|
/* qos 0, no no-local, no retain as published, retain handling = Send retained messages at the time of the subscribe */
|
||||||
|
@ -433,10 +433,10 @@ var _Bytes = class _Bytes {
|
||||||
}
|
}
|
||||||
var SUBACK = 9;
|
var SUBACK = 9;
|
||||||
function readSuback(reader, controlPacketFlags) {
|
function readSuback(reader, controlPacketFlags) {
|
||||||
checkEqual("controlPacketFlags", controlPacketFlags, 0);
|
checkEqual('controlPacketFlags', controlPacketFlags, 0);
|
||||||
const packetId = reader.readUint16();
|
const packetId = reader.readUint16();
|
||||||
const rt = { type: SUBACK, packetId, reasons: [] };
|
const rt = { type: SUBACK, packetId, reasons: [] };
|
||||||
readProperties(reader, (propertyId) => {
|
readProperties(reader, propertyId => {
|
||||||
throw new Error(`Unsupported propertyId: ${propertyId}`);
|
throw new Error(`Unsupported propertyId: ${propertyId}`);
|
||||||
});
|
});
|
||||||
while (reader.remaining() > 0) {
|
while (reader.remaining() > 0) {
|
||||||
|
@ -446,18 +446,18 @@ var _Bytes = class _Bytes {
|
||||||
}
|
}
|
||||||
var SUBACK_REASONS = {
|
var SUBACK_REASONS = {
|
||||||
// 3.9.3 SUBACK Payload
|
// 3.9.3 SUBACK Payload
|
||||||
0: ["Granted QoS 0", "The subscription is accepted and the maximum QoS sent will be QoS 0. This might be a lower QoS than was requested."],
|
0: ['Granted QoS 0', 'The subscription is accepted and the maximum QoS sent will be QoS 0. This might be a lower QoS than was requested.'],
|
||||||
1: ["Granted QoS 1", "The subscription is accepted and the maximum QoS sent will be QoS 1. This might be a lower QoS than was requested."],
|
1: ['Granted QoS 1', 'The subscription is accepted and the maximum QoS sent will be QoS 1. This might be a lower QoS than was requested.'],
|
||||||
2: ["Granted QoS 2", "The subscription is accepted and any received QoS will be sent to this subscription."],
|
2: ['Granted QoS 2', 'The subscription is accepted and any received QoS will be sent to this subscription.'],
|
||||||
128: ["Unspecified error", "The subscription is not accepted and the Server either does not wish to reveal the reason or none of the other Reason Codes apply."],
|
128: ['Unspecified error', 'The subscription is not accepted and the Server either does not wish to reveal the reason or none of the other Reason Codes apply.'],
|
||||||
131: ["Implementation specific error", "The SUBSCRIBE is valid but the Server does not accept it."],
|
131: ['Implementation specific error', 'The SUBSCRIBE is valid but the Server does not accept it.'],
|
||||||
135: ["Not authorized", "The Client is not authorized to make this subscription."],
|
135: ['Not authorized', 'The Client is not authorized to make this subscription.'],
|
||||||
143: ["Topic Filter invalid", "The Topic Filter is correctly formed but is not allowed for this Client."],
|
143: ['Topic Filter invalid', 'The Topic Filter is correctly formed but is not allowed for this Client.'],
|
||||||
145: ["Packet Identifier in use", "The specified Packet Identifier is already in use."],
|
145: ['Packet Identifier in use', 'The specified Packet Identifier is already in use.'],
|
||||||
151: ["Quota exceeded", "An implementation or administrative imposed limit has been exceeded."],
|
151: ['Quota exceeded', 'An implementation or administrative imposed limit has been exceeded.'],
|
||||||
158: ["Shared Subscriptions not supported", "The Server does not support Shared Subscriptions for this Client."],
|
158: ['Shared Subscriptions not supported', 'The Server does not support Shared Subscriptions for this Client.'],
|
||||||
161: ["Subscription Identifiers not supported", "The Server does not support Subscription Identifiers; the subscription is not accepted."],
|
161: ['Subscription Identifiers not supported', 'The Server does not support Subscription Identifiers; the subscription is not accepted.'],
|
||||||
162: ["Wildcard Subscriptions not supported", "The Server does not support Wildcard Subscriptions; the subscription is not accepted."]
|
162: ['Wildcard Subscriptions not supported', 'The Server does not support Wildcard Subscriptions; the subscription is not accepted.']
|
||||||
};
|
};
|
||||||
var UNSUBSCRIBE = 10;
|
var UNSUBSCRIBE = 10;
|
||||||
function encodeUnsubscribe(message) {
|
function encodeUnsubscribe(message) {
|
||||||
|
@ -467,15 +467,15 @@ var _Bytes = class _Bytes {
|
||||||
...encodeVariableByteInteger(0)
|
...encodeVariableByteInteger(0)
|
||||||
// properties = none
|
// properties = none
|
||||||
];
|
];
|
||||||
const payload = unsubscriptions.flatMap((v) => [...encodeUtf8(v.topicFilter)]);
|
const payload = unsubscriptions.flatMap(v => [...encodeUtf8(v.topicFilter)]);
|
||||||
return encodePacket(type, { variableHeader, payload });
|
return encodePacket(type, { variableHeader, payload });
|
||||||
}
|
}
|
||||||
var UNSUBACK = 11;
|
var UNSUBACK = 11;
|
||||||
function readUnsuback(reader, controlPacketFlags) {
|
function readUnsuback(reader, controlPacketFlags) {
|
||||||
checkEqual("controlPacketFlags", controlPacketFlags, 0);
|
checkEqual('controlPacketFlags', controlPacketFlags, 0);
|
||||||
const packetId = reader.readUint16();
|
const packetId = reader.readUint16();
|
||||||
const rt = { type: UNSUBACK, packetId, reasons: [] };
|
const rt = { type: UNSUBACK, packetId, reasons: [] };
|
||||||
readProperties(reader, (propertyId) => {
|
readProperties(reader, propertyId => {
|
||||||
throw new Error(`Unsupported propertyId: ${propertyId}`);
|
throw new Error(`Unsupported propertyId: ${propertyId}`);
|
||||||
});
|
});
|
||||||
while (reader.remaining() > 0) {
|
while (reader.remaining() > 0) {
|
||||||
|
@ -484,13 +484,13 @@ var _Bytes = class _Bytes {
|
||||||
return rt;
|
return rt;
|
||||||
}
|
}
|
||||||
var UNSUBACK_REASONS = {
|
var UNSUBACK_REASONS = {
|
||||||
0: ["Success", "The subscription is deleted."],
|
0: ['Success', 'The subscription is deleted.'],
|
||||||
17: ["No subscription existed", "No matching Topic Filter is being used by the Client."],
|
17: ['No subscription existed', 'No matching Topic Filter is being used by the Client.'],
|
||||||
128: ["Unspecified error", "The unsubscribe could not be completed and the Server either does not wish to reveal the reason or none of the other Reason Codes apply."],
|
128: ['Unspecified error', 'The unsubscribe could not be completed and the Server either does not wish to reveal the reason or none of the other Reason Codes apply.'],
|
||||||
131: ["Implementation specific error", "The UNSUBSCRIBE is valid but the Server does not accept it."],
|
131: ['Implementation specific error', 'The UNSUBSCRIBE is valid but the Server does not accept it.'],
|
||||||
135: ["Not authorized", "The Client is not authorized to unsubscribe."],
|
135: ['Not authorized', 'The Client is not authorized to unsubscribe.'],
|
||||||
143: ["Topic Filter invalid", "The Topic Filter is correctly formed but is not allowed for this Client."],
|
143: ['Topic Filter invalid', 'The Topic Filter is correctly formed but is not allowed for this Client.'],
|
||||||
145: ["Packet Identifier in use", "The specified Packet Identifier is already in use."]
|
145: ['Packet Identifier in use', 'The specified Packet Identifier is already in use.']
|
||||||
};
|
};
|
||||||
var PINGREQ = 12;
|
var PINGREQ = 12;
|
||||||
function encodePingreq(message) {
|
function encodePingreq(message) {
|
||||||
|
@ -499,56 +499,56 @@ var _Bytes = class _Bytes {
|
||||||
}
|
}
|
||||||
var PINGRESP = 13;
|
var PINGRESP = 13;
|
||||||
function readPingresp(reader, controlPacketFlags) {
|
function readPingresp(reader, controlPacketFlags) {
|
||||||
checkEqual("controlPacketFlags", controlPacketFlags, 0);
|
checkEqual('controlPacketFlags', controlPacketFlags, 0);
|
||||||
checkEqual("remaining", reader.remaining(), 0);
|
checkEqual('remaining', reader.remaining(), 0);
|
||||||
return { type: PINGRESP };
|
return { type: PINGRESP };
|
||||||
}
|
}
|
||||||
var DISCONNECT = 14;
|
var DISCONNECT = 14;
|
||||||
function readDisconnect(reader, controlPacketFlags, remainingLength) {
|
function readDisconnect(reader, controlPacketFlags, remainingLength) {
|
||||||
checkEqual("controlPacketFlags", controlPacketFlags, 0);
|
checkEqual('controlPacketFlags', controlPacketFlags, 0);
|
||||||
let rt = { type: DISCONNECT };
|
let rt = { type: DISCONNECT };
|
||||||
if (remainingLength > 0) {
|
if (remainingLength > 0) {
|
||||||
rt = { ...rt, reason: readReason(reader, DISCONNECT_REASONS) };
|
rt = { ...rt, reason: readReason(reader, DISCONNECT_REASONS) };
|
||||||
}
|
}
|
||||||
if (remainingLength > 1) {
|
if (remainingLength > 1) {
|
||||||
readProperties(reader, (propertyId) => {
|
readProperties(reader, propertyId => {
|
||||||
throw new Error(`Unsupported propertyId: ${propertyId}`);
|
throw new Error(`Unsupported propertyId: ${propertyId}`);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
checkEqual("remaining", reader.remaining(), 0);
|
checkEqual('remaining', reader.remaining(), 0);
|
||||||
return rt;
|
return rt;
|
||||||
}
|
}
|
||||||
var DISCONNECT_REASONS = {
|
var DISCONNECT_REASONS = {
|
||||||
// 3.14.2.1 Disconnect Reason Code
|
// 3.14.2.1 Disconnect Reason Code
|
||||||
0: ["Normal disconnection", "Close the connection normally. Do not send the Will Message."],
|
0: ['Normal disconnection', 'Close the connection normally. Do not send the Will Message.'],
|
||||||
4: ["Disconnect with Will Message", "The Client wishes to disconnect but requires that the Server also publishes its Will Message."],
|
4: ['Disconnect with Will Message', 'The Client wishes to disconnect but requires that the Server also publishes its Will Message.'],
|
||||||
128: ["Unspecified error", "The Connection is closed but the sender either does not wish to reveal the reason, or none of the other Reason Codes apply."],
|
128: ['Unspecified error', 'The Connection is closed but the sender either does not wish to reveal the reason, or none of the other Reason Codes apply.'],
|
||||||
129: ["Malformed Packet", "The received packet does not conform to this specification."],
|
129: ['Malformed Packet', 'The received packet does not conform to this specification.'],
|
||||||
130: ["Protocol Error", "An unexpected or out of order packet was received."],
|
130: ['Protocol Error', 'An unexpected or out of order packet was received.'],
|
||||||
131: ["Implementation specific error", "The packet received is valid but cannot be processed by this implementation."],
|
131: ['Implementation specific error', 'The packet received is valid but cannot be processed by this implementation.'],
|
||||||
135: ["Not authorized", "The request is not authorized."],
|
135: ['Not authorized', 'The request is not authorized.'],
|
||||||
137: ["Server busy", "The Server is busy and cannot continue processing requests from this Client."],
|
137: ['Server busy', 'The Server is busy and cannot continue processing requests from this Client.'],
|
||||||
139: ["Server shutting down", "The Server is shutting down."],
|
139: ['Server shutting down', 'The Server is shutting down.'],
|
||||||
141: ["Keep Alive timeout", "The Connection is closed because no packet has been received for 1.5 times the Keepalive time."],
|
141: ['Keep Alive timeout', 'The Connection is closed because no packet has been received for 1.5 times the Keepalive time.'],
|
||||||
142: ["Session taken over", "Another Connection using the same ClientID has connected causing this Connection to be closed."],
|
142: ['Session taken over', 'Another Connection using the same ClientID has connected causing this Connection to be closed.'],
|
||||||
143: ["Topic Filter invalid", "The Topic Filter is correctly formed, but is not accepted by this Sever."],
|
143: ['Topic Filter invalid', 'The Topic Filter is correctly formed, but is not accepted by this Sever.'],
|
||||||
144: ["Topic Name invalid", "The Topic Name is correctly formed, but is not accepted by this Client or Server."],
|
144: ['Topic Name invalid', 'The Topic Name is correctly formed, but is not accepted by this Client or Server.'],
|
||||||
147: ["Receive Maximum exceeded", "The Client or Server has received more than Receive Maximum publication for which it has not sent PUBACK or PUBCOMP."],
|
147: ['Receive Maximum exceeded', 'The Client or Server has received more than Receive Maximum publication for which it has not sent PUBACK or PUBCOMP.'],
|
||||||
148: ["Topic Alias invalid", "The Client or Server has received a PUBLISH packet containing a Topic Alias which is greater than the Maximum Topic Alias it sent in the CONNECT or CONNACK packet."],
|
148: ['Topic Alias invalid', 'The Client or Server has received a PUBLISH packet containing a Topic Alias which is greater than the Maximum Topic Alias it sent in the CONNECT or CONNACK packet.'],
|
||||||
149: ["Packet too large", "The packet size is greater than Maximum Packet Size for this Client or Server."],
|
149: ['Packet too large', 'The packet size is greater than Maximum Packet Size for this Client or Server.'],
|
||||||
150: ["Message rate too high", "The received data rate is too high."],
|
150: ['Message rate too high', 'The received data rate is too high.'],
|
||||||
151: ["Quota exceeded", "An implementation or administrative imposed limit has been exceeded."],
|
151: ['Quota exceeded', 'An implementation or administrative imposed limit has been exceeded.'],
|
||||||
152: ["Administrative action", "The Connection is closed due to an administrative action."],
|
152: ['Administrative action', 'The Connection is closed due to an administrative action.'],
|
||||||
153: ["Payload format invalid", "The payload format does not match the one specified by the Payload Format Indicator."],
|
153: ['Payload format invalid', 'The payload format does not match the one specified by the Payload Format Indicator.'],
|
||||||
154: ["Retain not supported", "The Server has does not support retained messages."],
|
154: ['Retain not supported', 'The Server has does not support retained messages.'],
|
||||||
155: ["QoS not supported", "The Client specified a QoS greater than the QoS specified in a Maximum QoS in the CONNACK."],
|
155: ['QoS not supported', 'The Client specified a QoS greater than the QoS specified in a Maximum QoS in the CONNACK.'],
|
||||||
156: ["Use another server", "The Client should temporarily change its Server."],
|
156: ['Use another server', 'The Client should temporarily change its Server.'],
|
||||||
157: ["Server moved", "The Server is moved and the Client should permanently change its server location."],
|
157: ['Server moved', 'The Server is moved and the Client should permanently change its server location.'],
|
||||||
158: ["Shared Subscriptions not supported", "The Server does not support Shared Subscriptions."],
|
158: ['Shared Subscriptions not supported', 'The Server does not support Shared Subscriptions.'],
|
||||||
159: ["Connection rate exceeded", "This connection is closed because the connection rate is too high."],
|
159: ['Connection rate exceeded', 'This connection is closed because the connection rate is too high.'],
|
||||||
160: ["Maximum connect time", "The maximum connection time authorized for this connection has been exceeded."],
|
160: ['Maximum connect time', 'The maximum connection time authorized for this connection has been exceeded.'],
|
||||||
161: ["Subscription Identifiers not supported", "The Server does not support Subscription Identifiers; the subscription is not accepted."],
|
161: ['Subscription Identifiers not supported', 'The Server does not support Subscription Identifiers; the subscription is not accepted.'],
|
||||||
162: ["Wildcard Subscriptions not supported", "The Server does not support Wildcard Subscriptions; the subscription is not accepted."]
|
162: ['Wildcard Subscriptions not supported', 'The Server does not support Wildcard Subscriptions; the subscription is not accepted.']
|
||||||
};
|
};
|
||||||
function encodeDisconnect(message) {
|
function encodeDisconnect(message) {
|
||||||
const { type, reason } = message;
|
const { type, reason } = message;
|
||||||
|
@ -665,33 +665,33 @@ var _Bytes = class _Bytes {
|
||||||
};
|
};
|
||||||
|
|
||||||
// mqtt/web_socket_connection.ts
|
// mqtt/web_socket_connection.ts
|
||||||
var WebSocketConnection = class _WebSocketConnection {
|
const WebSocketConnection = class _WebSocketConnection {
|
||||||
constructor(ws) {
|
constructor(ws) {
|
||||||
this.onRead = () => {
|
this.onRead = () => {
|
||||||
};
|
};
|
||||||
const { DEBUG } = Mqtt;
|
const { DEBUG } = Mqtt;
|
||||||
this.ws = ws;
|
this.ws = ws;
|
||||||
this.completionPromise = new Promise((resolve, reject) => {
|
this.completionPromise = new Promise((resolve, reject) => {
|
||||||
ws.addEventListener("close", (event) => {
|
ws.addEventListener('close', event => {
|
||||||
if (DEBUG)
|
if (DEBUG)
|
||||||
console.log("ws close", event, JSON.stringify(event));
|
console.log('ws close', event, JSON.stringify(event));
|
||||||
resolve();
|
resolve();
|
||||||
});
|
});
|
||||||
ws.addEventListener("error", (event) => {
|
ws.addEventListener('error', event => {
|
||||||
if (DEBUG)
|
if (DEBUG)
|
||||||
console.log("ws error", event);
|
console.log('ws error', event);
|
||||||
reject(event.message ?? event);
|
reject(event.message ?? event);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
ws.addEventListener("message", async (event) => {
|
ws.addEventListener('message', async event => {
|
||||||
if (DEBUG)
|
if (DEBUG)
|
||||||
console.log("ws message", typeof event.data, event.data);
|
console.log('ws message', typeof event.data, event.data);
|
||||||
if (event.data instanceof Blob) {
|
if (event.data instanceof Blob) {
|
||||||
const bytes = new Uint8Array(await event.data.arrayBuffer());
|
const bytes = new Uint8Array(await event.data.arrayBuffer());
|
||||||
this.onRead(bytes);
|
this.onRead(bytes);
|
||||||
} else if (event.data instanceof Uint8Array) {
|
} else if (event.data instanceof Uint8Array) {
|
||||||
let bytes = event.data;
|
let bytes = event.data;
|
||||||
if (bytes.constructor.name === "Buffer") {
|
if (bytes.constructor.name === 'Buffer') {
|
||||||
bytes = new Uint8Array(bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.byteLength));
|
bytes = new Uint8Array(bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.byteLength));
|
||||||
}
|
}
|
||||||
this.onRead(bytes);
|
this.onRead(bytes);
|
||||||
|
@ -702,52 +702,52 @@ var _Bytes = class _Bytes {
|
||||||
throw new Error(`Unsupported event.data: ${event.data.constructor.name}`);
|
throw new Error(`Unsupported event.data: ${event.data.constructor.name}`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
ws.addEventListener("open", (event) => {
|
ws.addEventListener('open', event => {
|
||||||
if (DEBUG)
|
if (DEBUG)
|
||||||
console.log("ws open", event);
|
console.log('ws open', event);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
static async create(opts) {
|
static async create(opts) {
|
||||||
const { DEBUG } = Mqtt;
|
const { DEBUG } = Mqtt;
|
||||||
const { hostname, port, pathname } = opts;
|
const { hostname, port, pathname } = opts;
|
||||||
if ("accept" in WebSocket.prototype) {
|
if ('accept' in WebSocket.prototype) {
|
||||||
if (DEBUG)
|
if (DEBUG)
|
||||||
console.log("Found WebSocket.accept, using Cloudflare workaround");
|
console.log('Found WebSocket.accept, using Cloudflare workaround');
|
||||||
if (port !== 443)
|
if (port !== 443)
|
||||||
throw new Error(`Cloudflare Workers only support outgoing WebSocket requests on port 443 (https)`);
|
throw new Error(`Cloudflare Workers only support outgoing WebSocket requests on port 443 (https)`);
|
||||||
const url2 = `https://${hostname}${port ? `:${port}` : ''}${pathname ?? ''}`;
|
const url2 = `https://${hostname}${port ? `:${port}` : ''}${pathname ?? ''}`;
|
||||||
if (DEBUG)
|
if (DEBUG)
|
||||||
console.log(`Fetching ${url2}`);
|
console.log(`Fetching ${url2}`);
|
||||||
const resp = await fetch(url2, { headers: { upgrade: "websocket" } });
|
const resp = await fetch(url2, { headers: { upgrade: 'websocket' } });
|
||||||
const { webSocket } = resp;
|
const { webSocket } = resp;
|
||||||
if (typeof webSocket !== "object")
|
if (typeof webSocket !== 'object')
|
||||||
throw new Error(`Cloudflare fetch response for upgrade request returned no WebSocket`);
|
throw new Error(`Cloudflare fetch response for upgrade request returned no WebSocket`);
|
||||||
if (DEBUG)
|
if (DEBUG)
|
||||||
console.log("Calling WebSocket.accept()");
|
console.log('Calling WebSocket.accept()');
|
||||||
webSocket.accept();
|
webSocket.accept();
|
||||||
if (DEBUG)
|
if (DEBUG)
|
||||||
console.log("Accepted!");
|
console.log('Accepted!');
|
||||||
return new _WebSocketConnection(webSocket);
|
return new _WebSocketConnection(webSocket);
|
||||||
}
|
}
|
||||||
const url = `wss://${hostname}${port ? `:${port}` : ''}${pathname ?? ''}`;
|
const url = `wss://${hostname}${port ? `:${port}` : ''}${pathname ?? ''}`;
|
||||||
const ws = new WebSocket(url, "mqtt");
|
const ws = new WebSocket(url, 'mqtt');
|
||||||
if (DEBUG)
|
if (DEBUG)
|
||||||
console.log(`new WebSocket('${url}', 'mqtt')`);
|
console.log(`new WebSocket('${url}', 'mqtt')`);
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
let resolved = false;
|
let resolved = false;
|
||||||
ws.addEventListener("open", (event) => {
|
ws.addEventListener('open', event => {
|
||||||
if (resolved)
|
if (resolved)
|
||||||
return;
|
return;
|
||||||
if (DEBUG)
|
if (DEBUG)
|
||||||
console.log("ws open", event);
|
console.log('ws open', event);
|
||||||
resolved = true;
|
resolved = true;
|
||||||
resolve(new _WebSocketConnection(ws));
|
resolve(new _WebSocketConnection(ws));
|
||||||
});
|
});
|
||||||
ws.addEventListener("error", (event) => {
|
ws.addEventListener('error', event => {
|
||||||
if (resolved)
|
if (resolved)
|
||||||
return;
|
return;
|
||||||
if (DEBUG)
|
if (DEBUG)
|
||||||
console.log("ws error", event);
|
console.log('ws error', event);
|
||||||
resolved = true;
|
resolved = true;
|
||||||
reject(event);
|
reject(event);
|
||||||
});
|
});
|
||||||
|
@ -763,9 +763,9 @@ var _Bytes = class _Bytes {
|
||||||
};
|
};
|
||||||
|
|
||||||
// mqtt/mqtt_client.ts
|
// mqtt/mqtt_client.ts
|
||||||
var DEFAULT_KEEP_ALIVE_SECONDS = 10;
|
const DEFAULT_KEEP_ALIVE_SECONDS = 10;
|
||||||
var MAX_PACKET_IDS = 256 * 256;
|
const MAX_PACKET_IDS = 256 * 256;
|
||||||
var _MqttClient = class _MqttClient {
|
const _MqttClient = class _MqttClient {
|
||||||
/**
|
/**
|
||||||
* Creates a new MqttClient.
|
* Creates a new MqttClient.
|
||||||
*
|
*
|
||||||
|
@ -842,23 +842,23 @@ var _Bytes = class _Bytes {
|
||||||
*/
|
*/
|
||||||
async connect(opts) {
|
async connect(opts) {
|
||||||
const { DEBUG } = Mqtt;
|
const { DEBUG } = Mqtt;
|
||||||
const { clientId = "", username, password, keepAlive = DEFAULT_KEEP_ALIVE_SECONDS, clean = false } = opts;
|
const { clientId = '', username, password, keepAlive = DEFAULT_KEEP_ALIVE_SECONDS, clean = false } = opts;
|
||||||
const { protocol, hostname, port, pathname } = this;
|
const { protocol, hostname, port, pathname } = this;
|
||||||
if (!this.connection) {
|
if (!this.connection) {
|
||||||
this.connection = await _MqttClient.protocolHandlers[protocol]({ hostname, port, pathname });
|
this.connection = await _MqttClient.protocolHandlers[protocol]({ hostname, port, pathname });
|
||||||
this.connection.onRead = (bytes) => {
|
this.connection.onRead = bytes => {
|
||||||
this.processBytes(bytes);
|
this.processBytes(bytes);
|
||||||
};
|
};
|
||||||
this.connectionCompletion = this.connection.completionPromise.then(() => {
|
this.connectionCompletion = this.connection.completionPromise.then(() => {
|
||||||
if (DEBUG)
|
if (DEBUG)
|
||||||
console.log("read loop done");
|
console.log('read loop done');
|
||||||
this.clearPing();
|
this.clearPing();
|
||||||
this.connection = void 0;
|
this.connection = void 0;
|
||||||
if (this.pendingConnect) {
|
if (this.pendingConnect) {
|
||||||
this.pendingConnect.reject("Connect failed, connection closed");
|
this.pendingConnect.reject('Connect failed, connection closed');
|
||||||
this.pendingConnect = void 0;
|
this.pendingConnect = void 0;
|
||||||
}
|
}
|
||||||
}, (e) => {
|
}, e => {
|
||||||
console.log(`unhandled read loop error: ${e.stack || e}`);
|
console.log(`unhandled read loop error: ${e.stack || e}`);
|
||||||
this.clearPing();
|
this.clearPing();
|
||||||
});
|
});
|
||||||
|
@ -890,8 +890,8 @@ var _Bytes = class _Bytes {
|
||||||
*/
|
*/
|
||||||
async publish(opts) {
|
async publish(opts) {
|
||||||
const { topic, payload: inputPayload, contentType } = opts;
|
const { topic, payload: inputPayload, contentType } = opts;
|
||||||
const payloadFormatIndicator = typeof inputPayload === "string" ? 1 : 0;
|
const payloadFormatIndicator = typeof inputPayload === 'string' ? 1 : 0;
|
||||||
const payload = typeof inputPayload === "string" ? Bytes.ofUtf8(inputPayload).array() : inputPayload;
|
const payload = typeof inputPayload === 'string' ? Bytes.ofUtf8(inputPayload).array() : inputPayload;
|
||||||
await this.sendMessage({ type: PUBLISH, dup: false, qosLevel: 0, retain: false, topic, payload, payloadFormatIndicator, contentType });
|
await this.sendMessage({ type: PUBLISH, dup: false, qosLevel: 0, retain: false, topic, payload, payloadFormatIndicator, contentType });
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -906,7 +906,7 @@ var _Bytes = class _Bytes {
|
||||||
async subscribe(opts) {
|
async subscribe(opts) {
|
||||||
const topicFilter = opts.topicFilter ?? opts;
|
const topicFilter = opts.topicFilter ?? opts;
|
||||||
const packetId = this.obtainPacketId();
|
const packetId = this.obtainPacketId();
|
||||||
const subscriptions = Array.isArray(topicFilter) ? topicFilter.map((filter) => ({ topicFilter: filter })) : [{ topicFilter }];
|
const subscriptions = Array.isArray(topicFilter) ? topicFilter.map(filter => ({ topicFilter: filter })) : [{ topicFilter }];
|
||||||
const signal = new Signal();
|
const signal = new Signal();
|
||||||
this.pendingSubscribes[packetId] = signal;
|
this.pendingSubscribes[packetId] = signal;
|
||||||
await this.sendMessage({ type: SUBSCRIBE, packetId, subscriptions });
|
await this.sendMessage({ type: SUBSCRIBE, packetId, subscriptions });
|
||||||
|
@ -922,7 +922,7 @@ var _Bytes = class _Bytes {
|
||||||
async unsubscribe(opts) {
|
async unsubscribe(opts) {
|
||||||
const topicFilter = opts.topicFilter ?? opts;
|
const topicFilter = opts.topicFilter ?? opts;
|
||||||
const packetId = this.obtainPacketId();
|
const packetId = this.obtainPacketId();
|
||||||
const unsubscriptions = Array.isArray(topicFilter) ? topicFilter.map((filter) => ({ topicFilter: filter })) : [{ topicFilter }];
|
const unsubscriptions = Array.isArray(topicFilter) ? topicFilter.map(filter => ({ topicFilter: filter })) : [{ topicFilter }];
|
||||||
const signal = new Signal();
|
const signal = new Signal();
|
||||||
this.pendingUnsubscribes[packetId] = signal;
|
this.pendingUnsubscribes[packetId] = signal;
|
||||||
await this.sendMessage({ type: UNSUBSCRIBE, packetId, unsubscriptions });
|
await this.sendMessage({ type: UNSUBSCRIBE, packetId, unsubscriptions });
|
||||||
|
@ -970,14 +970,14 @@ var _Bytes = class _Bytes {
|
||||||
this.savedBytes.splice(0);
|
this.savedBytes.splice(0);
|
||||||
}
|
}
|
||||||
if (DEBUG)
|
if (DEBUG)
|
||||||
console.log("processBytes", bytes.length + " bytes");
|
console.log('processBytes', `${bytes.length } bytes`);
|
||||||
if (DEBUG)
|
if (DEBUG)
|
||||||
console.log(hex(bytes));
|
console.log(hex(bytes));
|
||||||
const reader = new Reader(bytes, 0);
|
const reader = new Reader(bytes, 0);
|
||||||
while (reader.remaining() > 0) {
|
while (reader.remaining() > 0) {
|
||||||
const start = reader.position;
|
const start = reader.position;
|
||||||
const message = readMessage(reader);
|
const message = readMessage(reader);
|
||||||
if ("needsMoreBytes" in message) {
|
if ('needsMoreBytes' in message) {
|
||||||
this.savedBytes.push(...bytes.slice(start));
|
this.savedBytes.push(...bytes.slice(start));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1004,7 +1004,7 @@ var _Bytes = class _Bytes {
|
||||||
this.releasePacketId(packetId);
|
this.releasePacketId(packetId);
|
||||||
const signal = this.pendingSubscribes[packetId];
|
const signal = this.pendingSubscribes[packetId];
|
||||||
if (signal) {
|
if (signal) {
|
||||||
if (reasons.some((v) => v.code >= 128)) {
|
if (reasons.some(v => v.code >= 128)) {
|
||||||
signal.reject(JSON.stringify(reasons));
|
signal.reject(JSON.stringify(reasons));
|
||||||
} else {
|
} else {
|
||||||
signal.resolve(message);
|
signal.resolve(message);
|
||||||
|
@ -1016,7 +1016,7 @@ var _Bytes = class _Bytes {
|
||||||
this.releasePacketId(packetId);
|
this.releasePacketId(packetId);
|
||||||
const signal = this.pendingUnsubscribes[packetId];
|
const signal = this.pendingUnsubscribes[packetId];
|
||||||
if (signal) {
|
if (signal) {
|
||||||
if (reasons.some((v) => v.code >= 128)) {
|
if (reasons.some(v => v.code >= 128)) {
|
||||||
signal.reject(message);
|
signal.reject(message);
|
||||||
} else {
|
} else {
|
||||||
signal.resolve(message);
|
signal.resolve(message);
|
||||||
|
@ -1035,7 +1035,7 @@ var _Bytes = class _Bytes {
|
||||||
if (this.onMqttMessage)
|
if (this.onMqttMessage)
|
||||||
this.onMqttMessage(message);
|
this.onMqttMessage(message);
|
||||||
}
|
}
|
||||||
checkEqual("reader.remaining", reader.remaining(), 0);
|
checkEqual('reader.remaining', reader.remaining(), 0);
|
||||||
}
|
}
|
||||||
/** @internal */
|
/** @internal */
|
||||||
clearPing() {
|
clearPing() {
|
||||||
|
@ -1057,7 +1057,7 @@ var _Bytes = class _Bytes {
|
||||||
const intervalMillis = 1e3 / (maxMessagesPerSecond ?? 1);
|
const intervalMillis = 1e3 / (maxMessagesPerSecond ?? 1);
|
||||||
const waitMillis = maxMessagesPerSecond !== void 0 && diff < intervalMillis ? intervalMillis - diff : 0;
|
const waitMillis = maxMessagesPerSecond !== void 0 && diff < intervalMillis ? intervalMillis - diff : 0;
|
||||||
if (DEBUG)
|
if (DEBUG)
|
||||||
console.log(`Sending ${computeControlPacketTypeName(message.type)}${waitMillis > 0 ? ` (waiting ${waitMillis}ms)` : ""}`);
|
console.log(`Sending ${computeControlPacketTypeName(message.type)}${waitMillis > 0 ? ` (waiting ${waitMillis}ms)` : ''}`);
|
||||||
if (waitMillis > 0)
|
if (waitMillis > 0)
|
||||||
await sleep(waitMillis);
|
await sleep(waitMillis);
|
||||||
if (this.receivedDisconnect)
|
if (this.receivedDisconnect)
|
||||||
|
@ -1074,14 +1074,14 @@ var _Bytes = class _Bytes {
|
||||||
* e.g. you could write your own 'mqtts' TCP implementation for Node and plug it in here.
|
* e.g. you could write your own 'mqtts' TCP implementation for Node and plug it in here.
|
||||||
*/
|
*/
|
||||||
_MqttClient.protocolHandlers = {
|
_MqttClient.protocolHandlers = {
|
||||||
"mqtts": () => {
|
'mqtts': () => {
|
||||||
throw new Error(`The 'mqtts' protocol is not supported in this environment`);
|
throw new Error(`The 'mqtts' protocol is not supported in this environment`);
|
||||||
},
|
},
|
||||||
"wss": WebSocketConnection.create
|
'wss': WebSocketConnection.create
|
||||||
};
|
};
|
||||||
var MqttClient = _MqttClient;
|
const MqttClient = _MqttClient;
|
||||||
function sleep(ms) {
|
function sleep(ms) {
|
||||||
return new Promise((resolve) => setTimeout(resolve, ms));
|
return new Promise(resolve => setTimeout(resolve, ms));
|
||||||
}
|
}
|
||||||
var Signal = class {
|
var Signal = class {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
|
|
@ -673,7 +673,7 @@ function header_vue(token, h, ctx) {
|
||||||
background = renderWithCapture(token.background, h, ctx, token.markdown).content;
|
background = renderWithCapture(token.background, h, ctx, token.markdown).content;
|
||||||
}
|
}
|
||||||
|
|
||||||
let subtok = resolveToken(token.sub_logo, ctx);
|
const subtok = resolveToken(token.sub_logo, ctx);
|
||||||
if ( ! token.compact && subtok && canShowImage(subtok, ctx) ) {
|
if ( ! token.compact && subtok && canShowImage(subtok, ctx) ) {
|
||||||
const aspect = subtok.aspect;
|
const aspect = subtok.aspect;
|
||||||
|
|
||||||
|
@ -848,7 +848,7 @@ function header_normal(token, createElement, ctx) {
|
||||||
background = renderWithCapture(token.background, createElement, ctx, token.markdown).content;
|
background = renderWithCapture(token.background, createElement, ctx, token.markdown).content;
|
||||||
}
|
}
|
||||||
|
|
||||||
let subtok = resolveToken(token.sub_logo, ctx);
|
const subtok = resolveToken(token.sub_logo, ctx);
|
||||||
if ( ! token.compact && subtok && canShowImage(subtok, ctx) ) {
|
if ( ! token.compact && subtok && canShowImage(subtok, ctx) ) {
|
||||||
const aspect = subtok.aspect;
|
const aspect = subtok.aspect;
|
||||||
|
|
||||||
|
@ -1124,7 +1124,7 @@ function findMatchingLocale(locale, list) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// What about partials?
|
// What about partials?
|
||||||
let prefixed = `${locale.toLowerCase()}-`;
|
const prefixed = `${locale.toLowerCase()}-`;
|
||||||
for(const item of list) {
|
for(const item of list) {
|
||||||
if ( item.toLowerCase().startsWith(prefixed) )
|
if ( item.toLowerCase().startsWith(prefixed) )
|
||||||
return item;
|
return item;
|
||||||
|
@ -1141,7 +1141,7 @@ TOKEN_TYPES.i18n_select = function(token, createElement, ctx) {
|
||||||
|
|
||||||
// What locale and choices do we have.
|
// What locale and choices do we have.
|
||||||
const choices = token.choices || {};
|
const choices = token.choices || {};
|
||||||
let locale = ctx.i18n?.locale ?? 'en';
|
const locale = ctx.i18n?.locale ?? 'en';
|
||||||
|
|
||||||
// Try to find a valid match, or use the default.
|
// Try to find a valid match, or use the default.
|
||||||
let selected = findMatchingLocale(locale, Object.keys(choices));
|
let selected = findMatchingLocale(locale, Object.keys(choices));
|
||||||
|
@ -1182,7 +1182,7 @@ TOKEN_TYPES.link = function(token, createElement, ctx) {
|
||||||
klass.push(`ffz-link--inherit`);
|
klass.push(`ffz-link--inherit`);
|
||||||
|
|
||||||
if ( ctx.vue ) {
|
if ( ctx.vue ) {
|
||||||
let on = {};
|
const on = {};
|
||||||
if ( ctx.link_click_handler )
|
if ( ctx.link_click_handler )
|
||||||
on.click = ctx.link_click_handler;
|
on.click = ctx.link_click_handler;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue