Split out injectable dependencies

This commit is contained in:
Jordan Eldredge 2024-05-07 15:51:01 -07:00
parent b2306c8f92
commit 3f3808c717
2 changed files with 9 additions and 5 deletions

View File

@ -27,6 +27,7 @@ import availableSkins from "./availableSkins";
import { initialTracks, initialState } from "./config";
import screenshotInitialState from "./screenshotInitialState";
import { InjectableDependencies } from "../../js/webampLazy.jsx";
const NOISY_ACTION_TYPES = new Set([
STEP_MARQUEE,
@ -60,7 +61,7 @@ export async function getWebampConfig(
screenshot: boolean,
skinUrl: string | null,
soundCloudPlaylist: SoundCloud.SoundCloudPlaylist | null
): Promise<Options & PrivateOptions> {
): Promise<Options & PrivateOptions & InjectableDependencies> {
let __butterchurnOptions;
let windowLayout: WindowLayout | undefined;
if (isButterchurnSupported()) {

View File

@ -40,8 +40,6 @@ import { SerializedStateV1 } from "./serializedStates/v1Types";
import Disposable from "./Disposable";
export interface PrivateOptions {
requireJSZip(): Promise<any>; // TODO: Type JSZip
requireMusicMetadata(): Promise<any>; // TODO: Type musicmetadata
__initialState?: PartialState;
__customMiddlewares?: Middleware[];
__butterchurnOptions?: ButterchurnOptions;
@ -49,12 +47,17 @@ export interface PrivateOptions {
__customMediaClass?: typeof Media; // This should have the same interface as Media
}
export interface InjectableDependencies {
requireJSZip: () => Promise<any>; // TODO: Type JSZip
requireMusicMetadata: () => Promise<any>; // TODO: Type music-metadata-browser
}
class Webamp {
static VERSION = "1.5.0";
_actionEmitter: Emitter;
_root: ReactDOM.Root | null;
_disposable: Disposable;
options: Options & PrivateOptions; // TODO: Make this _private
options: Options & PrivateOptions & InjectableDependencies; // TODO: Make this _private
media: Media; // TODO: Make this _private
store: Store; // TODO: Make this _private
@ -74,7 +77,7 @@ class Webamp {
return supportsAudioApi && supportsCanvas && supportsPromises;
}
constructor(options: Options & PrivateOptions) {
constructor(options: Options & PrivateOptions & InjectableDependencies) {
this._root = null;
this._disposable = new Disposable();
this._actionEmitter = new Emitter();