2024-04-24 02:21:05 +02:00
|
|
|
import type { NSFull } from "../NetscriptFunctions";
|
|
|
|
import type { AutocompleteData, ScriptArg } from "@nsdefs";
|
2023-04-08 03:08:39 +02:00
|
|
|
|
|
|
|
// The object portion of this type is not runtime information, it's only to ensure type validation
|
|
|
|
// And make it harder to overwrite a url with a random non-url string.
|
|
|
|
export type ScriptURL = string & { __type: "ScriptURL" };
|
|
|
|
|
|
|
|
export interface ScriptModule {
|
2024-04-24 02:21:05 +02:00
|
|
|
main?: (ns: NSFull, ...args: ScriptArg[]) => unknown;
|
2023-04-08 03:08:39 +02:00
|
|
|
autocomplete?: (data: AutocompleteData, flags: string[]) => unknown;
|
|
|
|
}
|
|
|
|
|
|
|
|
export class LoadedModule {
|
|
|
|
url: ScriptURL;
|
|
|
|
module: Promise<ScriptModule>;
|
|
|
|
|
|
|
|
constructor(url: ScriptURL, module: Promise<ScriptModule>) {
|
|
|
|
this.url = url;
|
|
|
|
this.module = module;
|
|
|
|
}
|
|
|
|
}
|