28 lines
918 B
TypeScript
28 lines
918 B
TypeScript
export const SCRIPT_SANDBOX_DISPOSE_SCHEMA = 1 as const;
|
|
|
|
export interface ScriptSandboxDisposeReceipt {
|
|
schemaVersion: typeof SCRIPT_SANDBOX_DISPOSE_SCHEMA;
|
|
disposeCount: number;
|
|
idempotent: boolean;
|
|
resources: {
|
|
messagePorts: 0;
|
|
timers: 0;
|
|
abortControllers: 0;
|
|
transferableBuffers: 0;
|
|
pendingRequests: 0;
|
|
cacheReferences: 0;
|
|
};
|
|
lateTimerMessages: 0;
|
|
}
|
|
|
|
export function createScriptSandboxDisposeReceipt(disposeCount: number): ScriptSandboxDisposeReceipt {
|
|
if (!Number.isSafeInteger(disposeCount) || disposeCount < 1) throw new Error("SCRIPT_SANDBOX_DISPOSE_INVALID: dispose count must be positive");
|
|
return {
|
|
schemaVersion: SCRIPT_SANDBOX_DISPOSE_SCHEMA,
|
|
disposeCount,
|
|
idempotent: disposeCount > 1,
|
|
resources: { messagePorts: 0, timers: 0, abortControllers: 0, transferableBuffers: 0, pendingRequests: 0, cacheReferences: 0 },
|
|
lateTimerMessages: 0,
|
|
};
|
|
}
|