import type { BaseServer } from "../Server/BaseServer"; import { calculateRamUsage, RamUsageEntry } from "./RamCalculations"; import { LoadedModule, ScriptURL } from "./LoadedModule"; import { Generic_fromJSON, Generic_toJSON, IReviverValue, constructorsForReviver } from "../utils/JSONReviver"; import { roundToTwo } from "../utils/helpers/roundToTwo"; import { RamCostConstants } from "../Netscript/RamCostGenerator"; import { ScriptFilePath } from "../Paths/ScriptFilePath"; import { ContentFile } from "../Paths/ContentFile"; /** A script file as a file on a server. * For the execution of a script, see RunningScript and WorkerScript */ export class Script implements ContentFile { code: string; filename: ScriptFilePath; server: string; // Ram calculation, only exists after first poll of ram cost after updating ramUsage: number | null = null; ramUsageEntries: RamUsageEntry[] = []; // Runtime data that only exists when the script has been initiated. Cleared when script or a dependency script is updated. mod: LoadedModule | null = null; /** Scripts that directly import this one. Stored so we can invalidate these dependent scripts when this one is invalidated. */ dependents: Set