239 lines
7.1 KiB
JavaScript
239 lines
7.1 KiB
JavaScript
//@ts-check
|
|
|
|
import JadefinIntegrity from "./JadefinIntegrity.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(`{switch(r.charCodeAt(a)){case 34`) != -1)[0];
|
|
}
|
|
|
|
// toast
|
|
/** @return {(text: string) => void} */
|
|
get toast() {
|
|
return this._.toast ??= this.Jadefin.findWebpackRawLoad(e => (e.Z?.toString().indexOf(`toast"),t.textContent=`) || -1) != -1)[0]?.Z;
|
|
}
|
|
|
|
// plugins/syncPlay/core/index
|
|
/**
|
|
@return {{
|
|
Helper: any,
|
|
Manager: any,
|
|
PlayerFactory: any,
|
|
Players: any
|
|
}}
|
|
*/
|
|
get syncPlay() {
|
|
return this._.syncPlay ??= this.Jadefin.findWebpackRawLoad(e => e.Z?.Manager?.isSyncPlayEnabled)[0]?.Z;
|
|
}
|
|
|
|
// 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)[0];
|
|
}
|
|
|
|
// playbackManager
|
|
/**
|
|
@return {any}
|
|
*/
|
|
get playbackManager() {
|
|
return this._.playbackManager ??= this.Jadefin.findWebpackRawLoad(e => e.O?.canHandleOffsetOnCurrentSubtitle)[0]?.O;
|
|
}
|
|
|
|
// plugins/htmlVideoPlayer/plugin.js
|
|
/**
|
|
@return {any}
|
|
*/
|
|
get htmlVideoPlayer() {
|
|
return this._.htmlVideoPlayer ??= this.Jadefin.findWebpackModules(e => e.getDeviceProfileInternal)[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 => (e.Z?.toString().indexOf(`sendMessage("ScheduledTasksInfoStart","1000,1000")`) || -1) != -1)[0]?.Z;
|
|
}
|
|
|
|
// 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 => e.Z && "supportsCssAnimation" in e.Z && "version" in e.Z)[0]?.Z;
|
|
}
|
|
|
|
// 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 => e.ZP?.getDisplayRunningTime)[0]?.ZP;
|
|
}
|
|
|
|
// 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)[0]?.Events;
|
|
}
|
|
|
|
})());
|