jadefin/JadefinModules.js

249 lines
7.5 KiB
JavaScript

//@ts-check
import JadefinIntegrity from "./JadefinIntegrity.js";
import JadefinUtils from "./JadefinUtils.js";
export default JadefinIntegrity("JadefinModules", import.meta.url, () => window["JadefinModules"] = new (class JadefinModules {
/** @type {{[id: string]: any}} */
_ = {};
/**
* @param {boolean} [border]
*/
_test_actionSheet(border) {
this.actionSheet.show({
border: !!border, /* Divider between every item, if not disabled by theme. */
dialogClass: "test",
title: "Test",
text: `This is a test dialog\nborder: ${!!border}`,
positionTo: null,
items: [
{id: "test1", name: "Test 1"},
{divider: true},
{id: "test2", name: "Test 2", selected: true},
{id: "test3", name: "Test 3", icon: "add", asideText: "Auto"},
{id: "test4", name: "Test 4", icon: "remove", selected: true, secondaryText: "Do something", asideText: "1x", itemClass: "test"},
],
// showCancel: true, // Seemingly unused, looks wrong
timeout: false
}).then(id => {
if (!id) {
return;
}
console.log(`test selected ${id} (${typeof(id)})`);
this._test_actionSheet(!border);
});
}
/** @type {import("./Jadefin.js").default} */
get Jadefin() {
if (!this._.Jadefin) {
throw new Error("JadefinModules.Jadefin == null!");
}
return this._.Jadefin;
}
set Jadefin(value) {
if (!value) {
throw new Error("JadefinModules.Jadefin = null!");
}
if (this._.Jadefin) {
value.log.w("Replacing JadefinModules.Jadefin");
}
this._.Jadefin = value;
}
// Emby
/**
@return {
any
}
*/
get Emby() {
return this._.Emby ??= window["Emby"];
}
// apiClient
/**
@return {
any
}
*/
get ApiClient() {
return this._.ApiClient ??= window["ApiClient"];
}
// ActionSheet
/**
@return {{
show: (options: any) => Promise<string>
}}
*/
get actionSheet() {
return this._.actionSheet ??= this.Jadefin.findWebpackModules(e => (e.show?.toString()?.indexOf(`actionSheetContent`) || -1) != -1)[0];
}
// escape-html
/** @return {(text: string) => string} */
get escapeHtml() {
return this._.escapeHtml ??= this.Jadefin.findWebpackFunctions(e => e.toString().indexOf(`charCodeAt(a)){case 34`) != -1)[0];
}
// toast
/** @return {(text: string) => void} */
get toast() {
return this._.toast ??= this.Jadefin.findWebpackRawLoad(e => JadefinUtils.findDeep(e, 1, (_, o) => o.toString().indexOf(`toast"),t.textContent=`) != -1))[0];
}
// plugins/syncPlay/core/index
/**
@return {{
Helper: any,
Manager: any,
PlayerFactory: any,
Players: any
}}
*/
get syncPlay() {
return this._.syncPlay ??= this.Jadefin.findWebpackModules(e => e.Manager?.isSyncPlayEnabled && 1)[0];
}
// inputManager
/**
@return {{
handleCommand: (commandName: string, options: any) => void,
notify: () => void,
notifyMouseMove: () => void,
idleTime: () => number,
on: (scope: string, fn: Function) => void,
off: (scope: string, fn: Function) => void
}}
*/
get inputManager() {
return this._.inputManager ??= this.Jadefin.findWebpackModules(e => e.handleCommand && e.notify && e.idleTime && 1)[0];
}
// playbackManager
/**
@return {any}
*/
get playbackManager() {
return this._.playbackManager ??= this.Jadefin.findWebpackRawLoad(e => JadefinUtils.findDeep(e, 1, (_, o) => o.canHandleOffsetOnCurrentSubtitle))[0];
}
// plugins/htmlVideoPlayer/plugin.js
/**
@return {any}
*/
get htmlVideoPlayer() {
return this._.htmlVideoPlayer ??= this.Jadefin.findWebpackModules(e => e.getDeviceProfileInternal && 1)[0];
}
// taskbutton
/**
@return {
(options: {
mode: string,
taskKey: string,
button: Element,
panel?: Element | undefined | null,
progressElem?: Element | undefined | null,
lastResultElem?: Element | undefined | null
}) => void
}
*/
get taskButton() {
return this._.taskButton ??= this.Jadefin.findWebpackRawLoad(e => JadefinUtils.findDeep(e, 1, (_, o) => o.toString().indexOf(`sendMessage("ScheduledTasksInfoStart","1000,1000")`) != -1))[0];
}
// browser
/**
@return {{
chrome: boolean,
edg: boolean,
edga: boolean,
edgios: boolean,
edge: boolean,
opera: boolean,
opr: boolean,
safari: boolean,
firefox: boolean,
mozilla: boolean,
version: boolean,
ipad: boolean,
iphone: boolean,
windows: boolean,
android: boolean,
versionMajor: number,
edgeChromium: boolean,
osx: boolean,
ps4: boolean,
tv: boolean,
mobile: boolean,
xboxOne: boolean,
animate: boolean,
hisense: boolean,
tizen: boolean,
vidaa: boolean,
web0s: boolean,
edgeUwp: boolean,
tizenVersion?: number,
orsay: boolean,
operaTv: boolean,
slow: boolean,
touch: boolean,
keyboard: boolean,
supportsCssAnimation: (allowPrefix: boolean) => boolean,
iOS: boolean,
iOSVersion: string
}}
*/
get browser() {
return this._.browser ??= this.Jadefin.findWebpackRawLoad(e => JadefinUtils.findDeep(e, 1, (_, o) => "supportsCssAnimation" in o && "version" in o))[0];
}
// datetime
/**
@return {{
parseISO8601Date: (s: string, [toLocal]: boolean) => Date,
getDisplayDuration: (ticks: number) => string,
getDisplayRunningTime: (ticks: number) => string,
toLocaleString: (date: Date, options: any) => string,
toLocaleDateString: (date: Date, options: any) => string,
toLocaleTimeString: (date: Date, options: any) => string,
getDisplayTime: (date: Date) => string,
isRelativeDay: (date: Date, offsetInDays: number) => boolean,
supportsLocalization: () => boolean
}}
*/
get datetime() {
return this._.datetime ??= this.Jadefin.findWebpackRawLoad(e => JadefinUtils.findDeep(e, 1, (_, o) => o.getDisplayRunningTime))[0];
}
// events
/**
@return {{
on: (obj: any, type: string, fn: (e: Event, ...args: any[]) => void) => void,
off: (obj: any, type: string, fn: (e: Event, ...args: any[]) => void) => void,
trigger: (obj: any, type: string, args: any[] = []) => void
}}
*/
get Events() {
return this._.events ??= this.Jadefin.findWebpackRawLoad(e => e.Events?.on && e.Events?.off && e.Events?.trigger && 1)[0]?.Events;
}
// index.jsx
/**
@return {any}
*/
get index() {
return this._.index ??= this.Jadefin.findWebpackRawLoad(e => JadefinUtils.findDeep(e, 1, (_, o) => o._minServerVersion))[0];
}
})());