diff --git a/packages/buttons/package.json b/packages/buttons/package.json index 53e00ca7..2d8f3aaa 100644 --- a/packages/buttons/package.json +++ b/packages/buttons/package.json @@ -5,7 +5,7 @@ "main": "dist/index.js", "types": "dist/index.d.ts", "scripts": { - "build": "tsc -p .", + "build": "tsup && node ../../scripts/fixup-dts.js", "lint": "eslint . --ext .ts" }, "author": "PapiOphidian", diff --git a/packages/buttons/src/index.ts b/packages/buttons/src/index.ts index 2eeda94a..e59b5f32 100644 --- a/packages/buttons/src/index.ts +++ b/packages/buttons/src/index.ts @@ -21,6 +21,34 @@ const randomString = Math.random().toString(36).substring(7) let idSequence = 0 const bcAcceptableTypes = [2, 3, 5, 6, 7, 8] as const +class BetterComponent { + public callback: ((interaction: APIMessageComponentInteraction, component: BetterComponent) => unknown) | null = null + public id: string = BetterComponent.#nextID + public component: APIButtonComponentWithCustomId | APISelectMenuComponent + + public constructor( + public info: Omit, + extraEncodedInfo: Record + ) { + components.set(this.id, this) + this.component = { custom_id: encoding.encode({ mid: this.id, ...(extraEncodedInfo || {}) }), ...this.info } as BetterComponent["component"] + } + + static get #nextID(): string { + return `menu-${randomString}-${idSequence++}` + } + + public setCallback(fn: (interaction: APIMessageComponentInteraction, component: BetterComponent) => unknown): this { + this.callback = fn + return this + } + + public destroy(): this { + components.delete(this.id) + return this + } +} + const cc = { setHandlers(router: (button: APIMessageComponentInteractionData, user: APIUser) => string, info: { [route: string]: (button: APIMessageComponentInteractionData, user: APIUser) => unknown @@ -43,33 +71,7 @@ const cc = { if (handlers[route]) handlers[route](interaction.data, interaction.user ? interaction.user : interaction.member!.user) }, - BetterComponent: class BetterComponent { - public callback: ((interaction: APIMessageComponentInteraction, component: BetterComponent) => unknown) | null = null - public id: string = BetterComponent.#nextID - public component: APIButtonComponentWithCustomId | APISelectMenuComponent - - public constructor( - public info: Omit, - extraEncodedInfo: Record - ) { - components.set(this.id, this) - this.component = { custom_id: encoding.encode({ mid: this.id, ...(extraEncodedInfo || {}) }), ...this.info } as BetterComponent["component"] - } - - static get #nextID(): string { - return `menu-${randomString}-${idSequence++}` - } - - public setCallback(fn: (interaction: APIMessageComponentInteraction, component: BetterComponent) => unknown): this { - this.callback = fn - return this - } - - public destroy(): this { - components.delete(this.id) - return this - } - } + BetterComponent } export = cc diff --git a/packages/buttons/tsconfig.json b/packages/buttons/tsconfig.json index c46f9943..2c49216b 100644 --- a/packages/buttons/tsconfig.json +++ b/packages/buttons/tsconfig.json @@ -4,6 +4,7 @@ "compilerOptions": { "outDir": "./dist", "sourceMap": false, - "declaration": true + "declaration": true, + "incremental": false } } diff --git a/packages/buttons/tsup.config.json b/packages/buttons/tsup.config.json new file mode 100644 index 00000000..87dca96f --- /dev/null +++ b/packages/buttons/tsup.config.json @@ -0,0 +1,16 @@ +{ + "clean": false, + "dts": true, + "entryPoints": [ + "src/index.ts" + ], + "format": [ + "cjs" + ], + "minify": true, + "skipNodeModulesBundle": true, + "sourcemap": true, + "target": "es2022", + "splitting": false, + "keepNames": true +} diff --git a/packages/commands/package.json b/packages/commands/package.json index 858d6817..cd4c79de 100644 --- a/packages/commands/package.json +++ b/packages/commands/package.json @@ -5,7 +5,7 @@ "main": "dist/index.js", "types": "dist/index.d.ts", "scripts": { - "build": "tsc -p .", + "build": "tsup", "lint": "eslint . --ext .ts" }, "author": "PapiOphidian", diff --git a/packages/commands/tsconfig.json b/packages/commands/tsconfig.json index 19c70263..91cf718b 100644 --- a/packages/commands/tsconfig.json +++ b/packages/commands/tsconfig.json @@ -5,6 +5,7 @@ "compilerOptions": { "outDir": "./dist", "sourceMap": false, - "declaration": true + "declaration": true, + "incremental": false } } diff --git a/packages/commands/tsup.config.json b/packages/commands/tsup.config.json new file mode 100644 index 00000000..87dca96f --- /dev/null +++ b/packages/commands/tsup.config.json @@ -0,0 +1,16 @@ +{ + "clean": false, + "dts": true, + "entryPoints": [ + "src/index.ts" + ], + "format": [ + "cjs" + ], + "minify": true, + "skipNodeModulesBundle": true, + "sourcemap": true, + "target": "es2022", + "splitting": false, + "keepNames": true +} diff --git a/packages/encoding/package.json b/packages/encoding/package.json index 666f65ee..2aab2eb3 100644 --- a/packages/encoding/package.json +++ b/packages/encoding/package.json @@ -5,7 +5,7 @@ "main": "dist/index.js", "types": "dist/index.d.ts", "scripts": { - "build": "tsc -p .", + "build": "tsup", "lint": "eslint . --ext .ts" }, "author": "PapiOphidian", diff --git a/packages/encoding/tsconfig.json b/packages/encoding/tsconfig.json index c46f9943..2c49216b 100644 --- a/packages/encoding/tsconfig.json +++ b/packages/encoding/tsconfig.json @@ -4,6 +4,7 @@ "compilerOptions": { "outDir": "./dist", "sourceMap": false, - "declaration": true + "declaration": true, + "incremental": false } } diff --git a/packages/encoding/tsup.config.json b/packages/encoding/tsup.config.json new file mode 100644 index 00000000..87dca96f --- /dev/null +++ b/packages/encoding/tsup.config.json @@ -0,0 +1,16 @@ +{ + "clean": false, + "dts": true, + "entryPoints": [ + "src/index.ts" + ], + "format": [ + "cjs" + ], + "minify": true, + "skipNodeModulesBundle": true, + "sourcemap": true, + "target": "es2022", + "splitting": false, + "keepNames": true +} diff --git a/packages/runtime-website-client/src/classes.ts b/packages/runtime-website-client/src/classes.ts index f8f0853b..c44d1913 100644 --- a/packages/runtime-website-client/src/classes.ts +++ b/packages/runtime-website-client/src/classes.ts @@ -10,6 +10,9 @@ import type { UnpackArray } from "../../shared-types/index" // From HTML const serverTimeDiff = _serverTimeDiff +type WebQueueMembers = ReturnType["members"] +type WebTrackJSON = ReturnType + export class ElemJS { public parent: ElemJS public children: Array> = [] @@ -132,7 +135,7 @@ export class Queue extends ElemJS { super(container) } - public addItem(data: ReturnType, position?: number): void { + public addItem(data: WebTrackJSON, position?: number): void { const shouldAnimate = this.addingCount < this.animateMax const e = new QueueItem(data, this) if (shouldAnimate) { @@ -180,12 +183,12 @@ export class QueueItem extends ElemJS { length: ejs`div.song-length` as ElemJS, controls: ejs`div.song-management` as ElemJS } - public data: ReturnType = {} as ReturnType + public data: WebTrackJSON = {} as WebTrackJSON public shifting = false declare public parent: Q - public constructor(data: ReturnType, public queue: Q) { + public constructor(data: WebTrackJSON, public queue: Q) { super("div") this.class("queue-item") @@ -197,7 +200,7 @@ export class QueueItem extends ElemJS { this.updateData(data) } - public updateData(data: ReturnType): void { + public updateData(data: WebTrackJSON): void { Object.assign(this.data, data) this.render() this.preloadThumbnail() @@ -362,7 +365,7 @@ class AttributeButton extends ElemJS { } export class Player extends ElemJS { - public track: ReturnType | null = null + public track: WebTrackJSON | null = null public thumbnailDisplayHeight = 94 public attributes = { loop: false @@ -388,13 +391,13 @@ export class Player extends ElemJS { this.render() } - public setTrack(track: ReturnType | null): void { + public setTrack(track: WebTrackJSON | null): void { this.trackSet = true this.track = track this.render() } - public updateData(data: ReturnType): void { + public updateData(data: WebTrackJSON): void { this.trackSet = true Object.assign(this.track!, data) this.render() @@ -650,7 +653,7 @@ export class VoiceInfo extends ElemJS { this.render() } - public setMembers(members: ReturnType["members"]): void { + public setMembers(members: WebQueueMembers): void { members.forEach(member => { if (!this.memberStore.has(member.id)) { this.memberStore.set(member.id, new VoiceMember(member)) @@ -712,7 +715,7 @@ export class VoiceMember extends ElemJS { public isNew = true public leaving = false - public constructor(public props: UnpackArray["members"]>) { + public constructor(public props: UnpackArray) { super("div") } diff --git a/packages/runtime-website-client/src/player.ts b/packages/runtime-website-client/src/player.ts index a28e16c0..b9f2f506 100644 --- a/packages/runtime-website-client/src/player.ts +++ b/packages/runtime-website-client/src/player.ts @@ -9,8 +9,11 @@ import { ListenManager } from "./wrappers/ListenManager.js" import type { Queue as WebQueue } from "../../runtime-website/src/music/queue.js" import type { Track as WebTrack } from "../../runtime-website/src/music/tracktypes.js" +type WebQueueJSON = ReturnType +type WebTrackJSON = ReturnType + export class Session { - public state: ReturnType | null = null + public state: WebQueueJSON | null = null public player: Player = new Player(q("#player-container")!, this) public queue: Queue = new Queue(q("#queue-container")!, this) public voiceInfo: VoiceInfo = new VoiceInfo(q("#voice-info")!) @@ -72,7 +75,7 @@ export class Session { this.sideControls.render() } - public updateState(data: { d: ReturnType }): void { + public updateState(data: { d: WebQueueJSON }): void { const oldState = this.state this.state = data.d || null if (this.state === null) { @@ -97,7 +100,7 @@ export class Session { this.listenersUpdate(data) } - public listenersUpdate(data: { d: ReturnType }): void { + public listenersUpdate(data: { d: WebQueueJSON }): void { if (data && this.state) { this.state.members = data.d.members this.voiceInfo.setMembers(this.state.members) @@ -106,7 +109,7 @@ export class Session { } } - public trackAdd(data: { d: { position: number; track: ReturnType } }): void { + public trackAdd(data: { d: { position: number; track: WebTrackJSON } }): void { if (!this.state) return this.state.tracks.splice(data.d.position, 0, data.d.track) if (this.state.tracks.length == 1) { @@ -138,7 +141,7 @@ export class Session { this.listenManager.next(this.state.tracks[0]) } - public trackUpdate(data: { d: { index: number; track: ReturnType } }): void { + public trackUpdate(data: { d: { index: number; track: WebTrackJSON } }): void { if (!this.state) return const track = data.d.track const index = data.d.index diff --git a/packages/runtime-website-client/src/wrappers/ListenManager.ts b/packages/runtime-website-client/src/wrappers/ListenManager.ts index e4088560..602d8183 100644 --- a/packages/runtime-website-client/src/wrappers/ListenManager.ts +++ b/packages/runtime-website-client/src/wrappers/ListenManager.ts @@ -4,12 +4,14 @@ import { SoundCloudWrapper } from "./SoundCloudWrapper.js" import type { Track as WebTrack } from "../../../runtime-website/src/music/tracktypes" +type WebTrackJSON = ReturnType + export class ListenManager { public currentWrapper: Wrapper | null = null public wrappers = { soundCloudWrapper: new SoundCloudWrapper() } public enabled = false - public boot(track: ReturnType, timeGetter: () => number): void { + public boot(track: WebTrackJSON, timeGetter: () => number): void { this.enabled = true this._selectWrapper(track) if (!this.currentWrapper) return @@ -17,7 +19,7 @@ export class ListenManager { this.currentWrapper.seekAndPlay(timeGetter, track.length * 1000) } - public load(track: ReturnType): void { + public load(track: WebTrackJSON): void { if (!this.enabled) return this.stop() this._selectWrapper(track) @@ -25,7 +27,7 @@ export class ListenManager { this.currentWrapper.load(track) } - public async next(track: ReturnType): Promise { + public async next(track: WebTrackJSON): Promise { if (!this.enabled) return console.log("next: calling stop") if (this.currentWrapper) await this.currentWrapper.stop() @@ -55,7 +57,7 @@ export class ListenManager { this.currentWrapper = null } - private _selectWrapper(track: ReturnType): void { + private _selectWrapper(track: WebTrackJSON): void { if (track.source === "soundcloud") this.currentWrapper = this.wrappers.soundCloudWrapper else this.currentWrapper = null } diff --git a/packages/sql/tsup.config.json b/packages/sql/tsup.config.json index 8145aca5..87dca96f 100644 --- a/packages/sql/tsup.config.json +++ b/packages/sql/tsup.config.json @@ -9,7 +9,7 @@ ], "minify": true, "skipNodeModulesBundle": true, - "sourcemap": false, + "sourcemap": true, "target": "es2022", "splitting": false, "keepNames": true