this repo has no description
1import type { Logger } from "./logger";
2import type { Config, ConfigExtension } from "./config";
3import type { DetectedExtension, IdentifiedPatch, IdentifiedWebpackModule, ProcessedExtensions } from "./extension";
4import type EventEmitter from "events";
5import type LunAST from "@moonlight-mod/lunast";
6import type Moonmap from "@moonlight-mod/moonmap";
7import type {
8 WebEventPayloads,
9 WebEventType,
10 MoonlightEventEmitter,
11 NodeEventType,
12 NodeEventPayloads
13} from "./core/event";
14import { MoonlightFS } from "./fs";
15
16export type MoonlightHost = {
17 config: Config;
18 extensions: DetectedExtension[];
19 processedExtensions: ProcessedExtensions;
20 asarPath: string;
21 events: EventEmitter;
22
23 version: string;
24 branch: MoonlightBranch;
25
26 getConfig: (ext: string) => ConfigExtension["config"];
27 getConfigPath: () => Promise<string>;
28 getConfigOption: <T>(ext: string, name: string) => T | undefined;
29 setConfigOption: <T>(ext: string, name: string, value: T) => void;
30 writeConfig: (config: Config) => Promise<void>;
31
32 getLogger: (id: string) => Logger;
33 getMoonlightDir: () => string;
34 getExtensionDir: (ext: string) => string;
35};
36
37export type MoonlightNode = {
38 config: Config;
39 extensions: DetectedExtension[];
40 processedExtensions: ProcessedExtensions;
41 nativesCache: Record<string, any>;
42 isBrowser: boolean;
43 events: MoonlightEventEmitter<NodeEventType, NodeEventPayloads>;
44
45 version: string;
46 branch: MoonlightBranch;
47
48 getConfig: (ext: string) => ConfigExtension["config"];
49 getConfigOption: <T>(ext: string, name: string) => T | undefined;
50 setConfigOption: <T>(ext: string, name: string, value: T) => Promise<void>;
51 writeConfig: (config: Config) => Promise<void>;
52
53 getNatives: (ext: string) => any | undefined;
54 getLogger: (id: string) => Logger;
55 getMoonlightDir: () => string;
56 getExtensionDir: (ext: string) => string;
57};
58
59export type MoonlightNodeSandboxed = {
60 fs: MoonlightFS;
61 addCors: (url: string) => void;
62 addBlocked: (url: string) => void;
63};
64
65export type MoonlightWeb = {
66 patched: Map<string, Set<string>>;
67 unpatched: Set<IdentifiedPatch>;
68 pendingModules: Set<IdentifiedWebpackModule>;
69 enabledExtensions: Set<string>;
70 events: MoonlightEventEmitter<WebEventType, WebEventPayloads>;
71 patchingInternals: {
72 onModuleLoad: (moduleId: string | string[], callback: (moduleId: string) => void) => void;
73 registerPatch: (patch: IdentifiedPatch) => void;
74 registerWebpackModule: (module: IdentifiedWebpackModule) => void;
75 };
76 localStorage: Storage;
77
78 version: string;
79 branch: MoonlightBranch;
80 apiLevel: number;
81
82 // Re-exports for ease of use
83 getConfig: MoonlightNode["getConfig"];
84 getConfigOption: MoonlightNode["getConfigOption"];
85 setConfigOption: MoonlightNode["setConfigOption"];
86 writeConfig: MoonlightNode["writeConfig"];
87
88 getNatives: (ext: string) => any | undefined;
89 getLogger: (id: string) => Logger;
90
91 lunast: LunAST;
92 moonmap: Moonmap;
93};
94
95export enum MoonlightEnv {
96 Injector = "injector",
97 NodePreload = "node-preload",
98 WebPreload = "web-preload"
99}
100
101export enum MoonlightBranch {
102 STABLE = "stable",
103 NIGHTLY = "nightly",
104 DEV = "dev"
105}