Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
Xzensi committed May 29, 2024
2 parents d30f42c + 00538c2 commit c05eb27
Show file tree
Hide file tree
Showing 18 changed files with 73 additions and 98 deletions.
20 changes: 8 additions & 12 deletions dist/userscript/client.user.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// ==UserScript==
// @name NipahTV
// @namespace https://github.com/Xzensi/NipahTV
// @version 1.4.7
// @version 1.4.8
// @author Xzensi
// @description Better Kick and 7TV emote integration for Kick chat.
// @match https://kick.com/*
Expand Down Expand Up @@ -543,14 +543,12 @@ var Publisher = class {

// src/Datastores/EmoteDatastore.ts
var EmoteDatastore = class {
emoteSets = [];
emoteMap = /* @__PURE__ */ new Map();
emoteIdMap = /* @__PURE__ */ new Map();
emoteNameMap = /* @__PURE__ */ new Map();
emoteUsage = /* @__PURE__ */ new Map();
emoteEmoteSetMap = /* @__PURE__ */ new Map();
// Map of emote names splitted into parts for more relevant search results
splittedNamesMap = /* @__PURE__ */ new Map();
emoteSets = [];
emoteUsage = /* @__PURE__ */ new Map();
// Map of provider ids containing map of emote names to emote hids
emoteProviderNameMap = /* @__PURE__ */ new Map();
// Map of pending emote usage changes to be synced to database
Expand Down Expand Up @@ -740,7 +738,6 @@ var EmoteDatastore = class {
var EmotesManager = class {
providers = /* @__PURE__ */ new Map();
loaded = false;
database;
eventBus;
settingsManager;
datastore;
Expand All @@ -749,7 +746,6 @@ var EmotesManager = class {
eventBus,
settingsManager
}, channelId) {
this.database = database;
this.eventBus = eventBus;
this.settingsManager = settingsManager;
this.datastore = new EmoteDatastore({ database, eventBus }, channelId);
Expand Down Expand Up @@ -1119,7 +1115,7 @@ var EmoteMenuComponent = class extends AbstractComponent {
const { settingsManager } = this.rootContext;
const showSearchBox = settingsManager.getSetting("shared.chat.emote_menu.appearance.search_box");
const showSidebar = true;
$(".ntv__emote-menu").remove();
document.querySelectorAll(".ntv__emote-menu").forEach((el) => el.remove());
this.containerEl = parseHTML(
cleanupHTML(`
<div class="ntv__emote-menu" style="display: none">
Expand Down Expand Up @@ -1386,7 +1382,7 @@ var EmoteMenuComponent = class extends AbstractComponent {
})()
}
);
const emoteSetEls = $(".ntv__emote-set", emotesPanelEl);
const emoteSetEls = emotesPanelEl.querySelectorAll(".ntv__emote-set");
for (const emoteSetEl of emoteSetEls)
observer.observe(emoteSetEl);
}
Expand Down Expand Up @@ -6263,10 +6259,10 @@ var SettingsManager = class {
];
settingsMap = /* @__PURE__ */ new Map();
isShowingModal = false;
isLoaded = false;
database;
eventBus;
modal;
isLoaded = false;
constructor({ database, eventBus }) {
this.database = database;
this.eventBus = eventBus;
Expand Down Expand Up @@ -6709,6 +6705,7 @@ var KickNetworkInterface = class extends AbstractNetworkInterface {

// src/Datastores/UsersDatastore.ts
var UsersDatastore = class {
eventBus;
usersNameMap = /* @__PURE__ */ new Map();
usersIdMap = /* @__PURE__ */ new Map();
users = [];
Expand All @@ -6723,7 +6720,6 @@ var UsersDatastore = class {
threshold: 0.4,
keys: [["name"]]
});
eventBus;
constructor({ eventBus }) {
this.eventBus = eventBus;
eventBus.subscribe("ntv.session.destroy", () => {
Expand Down Expand Up @@ -6810,7 +6806,7 @@ var UsersManager = class {
// src/app.ts
var NipahClient = class {
ENV_VARS = {
VERSION: "1.4.7",
VERSION: "1.4.8",
LOCAL_RESOURCE_ROOT: "http://localhost:3000/",
// GITHUB_ROOT: 'https://github.com/Xzensi/NipahTV/raw/master',
// GITHUB_ROOT: 'https://cdn.jsdelivr.net/gh/Xzensi/NipahTV@master',
Expand Down
11 changes: 4 additions & 7 deletions manifest-chrome-v3.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{
"manifest_version": 3,
"name": "NipahTV",
"short_name": "NTV",
"author": "Xzensi",
"homepage_url": "https://github.com/Xzensi/NipahTV",
"description": "A Better Kick and 7TV Emote Integration for Kick.",
"version": "{{VERSION}}",
"minimum_chrome_version": "123",
Expand All @@ -19,13 +22,7 @@
"content_scripts": [
{
"matches": ["https://kick.com/*"],
"js": [
"vendor/jquery.min.js",
"vendor/dexie.min.js",
"vendor/fuse.min.js",
"vendor/twemoji.min.js",
"index.js"
],
"js": ["vendor/dexie.min.js", "vendor/fuse.min.js", "vendor/twemoji.min.js", "index.js"],
"css": ["style.min.css"]
}
],
Expand Down
10 changes: 3 additions & 7 deletions manifest-firefox-v2.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"manifest_version": 2,
"name": "NipahTV",
"short_name": "NTV",
"author": "Xzensi",
"description": "A Better Kick and 7TV Emote Integration for Kick.",
"version": "{{VERSION}}",
"icons": {
Expand All @@ -15,13 +17,7 @@
"content_scripts": [
{
"matches": ["https://kick.com/*"],
"js": [
"vendor/jquery.min.js",
"vendor/dexie.min.js",
"vendor/fuse.min.js",
"vendor/twemoji.min.js",
"index.js"
],
"js": ["vendor/dexie.min.js", "vendor/fuse.min.js", "vendor/twemoji.min.js", "index.js"],
"css": ["style.min.css"]
}
],
Expand Down
2 changes: 0 additions & 2 deletions src/@types/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ declare global {
__USERSCRIPT__: boolean
__LOCAL__?: boolean
NipahTV?: any // Export class NipahClient not allowed for Userscripts
jQuery: JQuery
$: JQuery
Fuse: Fuse
twemoji: any
}
Expand Down
2 changes: 1 addition & 1 deletion src/Classes/Clipboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function flattenNestedElement(node: Node) {
}

export class Clipboard2 {
domParser = new DOMParser()
private domParser = new DOMParser()

handleCopyEvent(event: ClipboardEvent) {
const selection = document.getSelection()
Expand Down
16 changes: 8 additions & 8 deletions src/Classes/Logger.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
export class Logger {
prefix: string
brandStyle: string
okStyle: string
infoStyle: string
errorStyle: string
eventStyle: string
extraMargin: (x?: number) => string
tagStyle: string
private prefix: string
private brandStyle: string
private okStyle: string
private infoStyle: string
private errorStyle: string
private eventStyle: string
private extraMargin: (x?: number) => string
private tagStyle: string

constructor() {
this.prefix = 'NIPAH'
Expand Down
6 changes: 3 additions & 3 deletions src/Classes/MessagesHistory.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export class MessagesHistory {
messages: string[]
cursorIndex: number
maxMessages: number
private messages: string[]
private cursorIndex: number
private maxMessages: number

constructor() {
this.messages = []
Expand Down
2 changes: 1 addition & 1 deletion src/Classes/PriorityEventTarget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const stopImmediatePropagation = function (this: Event | any) {
}

export class PriorityEventTarget {
events: Map<string, Array<Array<[(event: Event) => void, AddEventListenerOptions?]>>> = new Map()
private events: Map<string, Array<Array<[(event: Event) => void, AddEventListenerOptions?]>>> = new Map()

/**
* Adds a priority event listener for the specified event type at the specified priority. It will be called in the order of priority.
Expand Down
8 changes: 4 additions & 4 deletions src/Classes/Publisher.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { log, logEvent, error, assertArgument, assertArray } from '../utils'
import { logEvent, error, assertArgument, assertArray } from '../utils'
import { DTO } from './DTO'

export class Publisher {
listeners = new Map()
onceListeners = new Map()
firedEvents = new Map()
private listeners = new Map()
private onceListeners = new Map()
private firedEvents = new Map()

subscribe(event: string, callback: Function, triggerOnExistingEvent = false, once = false) {
assertArgument(event, 'string')
Expand Down
6 changes: 3 additions & 3 deletions src/Classes/SlidingTimestampWindow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
* where data entries older than (now - timestamp) are removed from the total as new entries are added.
*/
export class SlidingTimestampWindow {
timestampWindow: number
entries: Array<number>
maxEntries: number
private timestampWindow: number
private entries: Array<number>
private maxEntries: number

constructor(historyEntries: Array<number>) {
this.timestampWindow = 14 * 24 * 60 * 60 * 1000 // 2 weeks
Expand Down
32 changes: 11 additions & 21 deletions src/Datastores/EmoteDatastore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,21 @@ import { PLATFORM_ENUM } from '../constants'
import { log, info, error, isEmpty } from '../utils'

export class EmoteDatastore {
private emoteMap = new Map()
private emoteIdMap = new Map()
private emoteNameMap = new Map()
private emoteEmoteSetMap = new Map()

emoteSets: Array<any> = []
emoteMap = new Map()
emoteIdMap = new Map()
emoteNameMap = new Map()
emoteUsage = new Map()
emoteEmoteSetMap = new Map()

// Map of emote names splitted into parts for more relevant search results
splittedNamesMap = new Map()

// Map of provider ids containing map of emote names to emote hids
emoteProviderNameMap = new Map()
private emoteProviderNameMap = new Map()

// Map of pending emote usage changes to be synced to database
pendingEmoteUsageChanges: { [key: string]: boolean } = {}
private pendingEmoteUsageChanges: { [key: string]: boolean } = {}

fuse = new Fuse([], {
private fuse = new Fuse([], {
includeScore: true,
shouldSort: false,
// includeMatches: true,
Expand All @@ -31,9 +29,9 @@ export class EmoteDatastore {
keys: [['name'], ['parts']]
})

database: DatabaseProxy
eventBus: Publisher
channelId: string
private database: DatabaseProxy
private eventBus: Publisher
private channelId: string

constructor({ database, eventBus }: { database: DatabaseProxy; eventBus: Publisher }, channelId: string) {
this.database = database
Expand Down Expand Up @@ -114,14 +112,6 @@ export class EmoteDatastore {
this.emoteNameMap.set(emote.name, emote)
this.emoteEmoteSetMap.set(emote.hid, emoteSet)

// const emoteParts = splitEmoteName(emote.name, 2)
// for (const part of emoteParts) {
// if (!this.splittedNamesMap.has(part)) {
// this.splittedNamesMap.set(part, [])
// }
// this.splittedNamesMap.get(part).push(emote.id)
// }

let providerEmoteNameMap = this.emoteProviderNameMap.get(emote.provider)
if (!providerEmoteNameMap) {
providerEmoteNameMap = new Map()
Expand Down
15 changes: 7 additions & 8 deletions src/Datastores/UsersDatastore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ export type User = {
}

export class UsersDatastore {
usersNameMap: Map<string, User> = new Map()
usersIdMap: Map<string, User> = new Map()
users: Array<User> = []
usersCount = 0
private eventBus: Publisher

maxUsers = 50_000
private usersNameMap: Map<string, User> = new Map()
private usersIdMap: Map<string, User> = new Map()
private users: Array<User> = []
private usersCount = 0
private maxUsers = 50_000

fuse = new Fuse([], {
private fuse = new Fuse([], {
includeScore: true,
shouldSort: true,
includeMatches: true,
Expand All @@ -25,8 +26,6 @@ export class UsersDatastore {
keys: [['name']]
})

eventBus: Publisher

constructor({ eventBus }: { eventBus: Publisher }) {
this.eventBus = eventBus

Expand Down
11 changes: 5 additions & 6 deletions src/Managers/EmotesManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@ import { SettingsManager } from './SettingsManager'
import { DatabaseProxy } from '../Classes/DatabaseProxy'

export class EmotesManager {
providers = new Map()
private providers = new Map()
loaded = false

database: DatabaseProxy
eventBus: Publisher
settingsManager: SettingsManager
datastore: EmoteDatastore
private eventBus: Publisher
private settingsManager: SettingsManager
private datastore: EmoteDatastore

constructor(
{
Expand All @@ -22,7 +21,6 @@ export class EmotesManager {
}: { database: DatabaseProxy; eventBus: Publisher; settingsManager: SettingsManager },
channelId: string
) {
this.database = database
this.eventBus = eventBus
this.settingsManager = settingsManager
this.datastore = new EmoteDatastore({ database, eventBus }, channelId)
Expand Down Expand Up @@ -67,6 +65,7 @@ export class EmotesManager {
for (const emoteSets of providerSets) {
for (const emoteSet of emoteSets) {
for (const emote of emoteSet.emotes) {
// Map of emote names splitted into parts for more relevant search results
const parts = splitEmoteName(emote.name, 2)
if (parts.length && parts[0] !== emote.name) {
emote.parts = parts
Expand Down
14 changes: 7 additions & 7 deletions src/Managers/SettingsManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export class SettingsManager {
- Display images in tooltips
*/

sharedSettings = [
private sharedSettings = [
{
label: 'Appearance',
children: [
Expand Down Expand Up @@ -373,13 +373,13 @@ export class SettingsManager {
}
]

settingsMap = new Map()
isShowingModal = false
isLoaded = false
private settingsMap = new Map()
private isShowingModal = false
private database: DatabaseProxy
private eventBus: Publisher
private modal?: SettingsModal

database: DatabaseProxy
eventBus: Publisher
modal?: SettingsModal
isLoaded = false

constructor({ database, eventBus }: { database: DatabaseProxy; eventBus: Publisher }) {
this.database = database
Expand Down
2 changes: 1 addition & 1 deletion src/Managers/UsersManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { SettingsManager } from './SettingsManager'
import { Publisher } from '../Classes/Publisher'

export class UsersManager {
datastore: UsersDatastore
private datastore: UsersDatastore

constructor({ eventBus, settingsManager }: { eventBus: Publisher; settingsManager: SettingsManager }) {
this.datastore = new UsersDatastore({ eventBus })
Expand Down
Loading

0 comments on commit c05eb27

Please sign in to comment.