import type { Resource } from './utility-types'; /** Maps an external API back to the resource that created it. */ export const resources = new WeakMap(); /** * Identifies if an object is a Wardens resource. Carries no metadata and * objects are never deleted. This is separate from `resources` to avoid * retaining associated objects in memory. */ export const constructed = new WeakSet(); export interface RevokableResource { resource: Resource; /** All the resources this resource personally allocated. */ children: Set; /** * Destroys outer references to the API and frees the object for garbage * collection. */ revoke(): void; /** * A flag preventing the resource context from provisioning new child * resources after the parent is destroyed. */ curfew: { enforced: boolean }; }