You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/** The ejection command is successful -- the application can prompt the user to remove the device. */
10161
+
SUCCESS = "success",
10162
+
/** The device is in use by another application. The ejection did not succeed; the user should not remove the device until the other application is done with the device. */
10163
+
IN_USE = "in_use",
10164
+
/** There is no such device known. */
10165
+
NO_SUCH_DEVICE = "no_such_device",
10166
+
/** The ejection command failed. */
10167
+
FAILURE = "failure",
10168
+
}
10169
+
10159
10170
export interface StorageUnitInfo {
10160
10171
/** The transient ID that uniquely identifies the storage device. This ID will be persistent within the same run of a single application. It will not be a persistent identifier between different runs of an application, or between different applications. */
10161
10172
id: string;
10162
10173
/** The name of the storage unit. */
10163
10174
name: string;
10164
-
/**
10165
-
* The media type of the storage unit.
10166
-
* fixed: The storage has fixed media, e.g. hard disk or SSD.
10167
-
* removable: The storage is removable, e.g. USB flash drive.
10168
-
* unknown: The storage type is unknown.
10169
-
*/
10170
-
type: string;
10175
+
/** The media type of the storage unit. */
10176
+
type: `${StorageUnitType}`;
10171
10177
/** The total amount of the storage space, in bytes. */
10172
10178
capacity: number;
10173
10179
}
10174
10180
10175
-
export interface StorageCapacityInfo {
10176
-
/** A copied |id| of getAvailableCapacity function parameter |id|. */
10181
+
export enum StorageUnitType {
10182
+
/** The storage has fixed media, e.g. hard disk or SSD. */
10183
+
FIXED = "fixed",
10184
+
/** The storage is removable, e.g. USB flash drive. */
10185
+
REMOVABLE = "removable",
10186
+
/** The storage type is unknown. */
10187
+
UNKNOWN = "unknown",
10188
+
}
10189
+
10190
+
export interface StorageAvailableCapacityInfo {
10191
+
/** A copied `id` of getAvailableCapacity function parameter `id`. */
10177
10192
id: string;
10178
10193
/** The available capacity of the storage device, in bytes. */
/** Get the storage information from the system. The argument passed to the callback is an array of StorageUnitInfo objects. */
10187
-
export function getInfo(callback: (info: StorageUnitInfo[]) => void): void;
10188
10197
/**
10189
10198
* Get the storage information from the system. The argument passed to the callback is an array of StorageUnitInfo objects.
10190
-
* @return The `getInfo` method provides its result via callback or returned as a `Promise` (MV3 only).
10199
+
*
10200
+
* Can return its result via Promise in Manifest V3 or later since Chrome 91.
10191
10201
*/
10192
10202
export function getInfo(): Promise<StorageUnitInfo[]>;
10203
+
export function getInfo(callback: (info: StorageUnitInfo[]) => void): void;
10204
+
10193
10205
/**
10194
10206
* Ejects a removable storage device.
10195
-
* @param callback
10196
-
* Parameter result: success: The ejection command is successful -- the application can prompt the user to remove the device; in_use: The device is in use by another application. The ejection did not succeed; the user should not remove the device until the other application is done with the device; no_such_device: There is no such device known. failure: The ejection command failed.
10197
-
*/
10198
-
export function ejectDevice(id: string, callback: (result: string) => void): void;
10199
-
/**
10200
-
* Ejects a removable storage device.
10201
-
* @param callback
10202
-
* Parameter result: success: The ejection command is successful -- the application can prompt the user to remove the device; in_use: The device is in use by another application. The ejection did not succeed; the user should not remove the device until the other application is done with the device; no_such_device: There is no such device known. failure: The ejection command failed.
10203
-
* @return The `ejectDevice` method provides its result via callback or returned as a `Promise` (MV3 only).
10204
-
*/
10205
-
export function ejectDevice(id: string): Promise<string>;
10206
-
/**
10207
-
* Get the available capacity of a specified |id| storage device. The |id| is the transient device ID from StorageUnitInfo.
10208
-
* @since Dev channel only.
10207
+
*
10208
+
* Can return its result via Promise in Manifest V3 or later since Chrome 91.
10209
10209
*/
10210
-
export function getAvailableCapacity(id: string, callback: (info: StorageCapacityInfo) => void): void;
10210
+
export function ejectDevice(id: string): Promise<`${EjectDeviceResultCode}`>;
10211
+
export function ejectDevice(id: string, callback: (result: `${EjectDeviceResultCode}`) => void): void;
10212
+
10211
10213
/**
10212
-
* Get the available capacity of a specified |id| storage device. The |id| is the transient device ID from StorageUnitInfo.
10214
+
* Get the available capacity of a specified `id` storage device. The `id` is the transient device ID from StorageUnitInfo.
10215
+
*
10216
+
* Can return its result via Promise in Manifest V3.
10213
10217
* @since Dev channel only.
10214
-
* @return The `getAvailableCapacity` method provides its result via callback or returned as a `Promise` (MV3 only).
10215
10218
*/
10216
-
export function getAvailableCapacity(id: string): Promise<StorageCapacityInfo>;
10219
+
export function getAvailableCapacity(id: string): Promise<StorageAvailableCapacityInfo>;
10220
+
export function getAvailableCapacity(id: string, callback: (info: StorageAvailableCapacityInfo) => void): void;
10217
10221
10218
10222
/** Fired when a new removable storage is attached to the system. */
10219
-
export var onAttached: SystemStorageAttachedEvent;
0 commit comments