1/*! ***************************************************************************** 2Copyright (c) Microsoft Corporation. All rights reserved. 3Licensed under the Apache License, Version 2.0 (the "License"); you may not use 4this file except in compliance with the License. You may obtain a copy of the 5License at http://www.apache.org/licenses/LICENSE-2.0 6 7THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 8KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 9WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 10MERCHANTABLITY OR NON-INFRINGEMENT. 11 12See the Apache Version 2.0 License for specific language governing permissions 13and limitations under the License. 14***************************************************************************** */ 15 16 17 18/// <reference no-default-lib="true"/> 19 20 21interface WeakRef<T extends object> { 22 readonly [Symbol.toStringTag]: "WeakRef"; 23 24 /** 25 * Returns the WeakRef instance's target object, or undefined if the target object has been 26 * reclaimed. 27 */ 28 deref(): T | undefined; 29} 30 31interface WeakRefConstructor { 32 readonly prototype: WeakRef<any>; 33 34 /** 35 * Creates a WeakRef instance for the given target object. 36 * @param target The target object for the WeakRef instance. 37 */ 38 new<T extends object>(target: T): WeakRef<T>; 39} 40 41declare var WeakRef: WeakRefConstructor; 42 43interface FinalizationRegistry<T> { 44 readonly [Symbol.toStringTag]: "FinalizationRegistry"; 45 46 /** 47 * Registers an object with the registry. 48 * @param target The target object to register. 49 * @param heldValue The value to pass to the finalizer for this object. This cannot be the 50 * target object. 51 * @param unregisterToken The token to pass to the unregister method to unregister the target 52 * object. If provided (and not undefined), this must be an object. If not provided, the target 53 * cannot be unregistered. 54 */ 55 register(target: object, heldValue: T, unregisterToken?: object): void; 56 57 /** 58 * Unregisters an object from the registry. 59 * @param unregisterToken The token that was used as the unregisterToken argument when calling 60 * register to register the target object. 61 */ 62 unregister(unregisterToken: object): void; 63} 64 65interface FinalizationRegistryConstructor { 66 readonly prototype: FinalizationRegistry<any>; 67 68 /** 69 * Creates a finalization registry with an associated cleanup callback 70 * @param cleanupCallback The callback to call after an object in the registry has been reclaimed. 71 */ 72 new<T>(cleanupCallback: (heldValue: T) => void): FinalizationRegistry<T>; 73} 74 75declare var FinalizationRegistry: FinalizationRegistryConstructor; 76