Skip to content

Commit 6cc0630

Browse files
authored
refactor(cos): use singular requestFileHandle() instead of requestFileHandles() (#1709)
* refactor: use singular requestFileHandle() instead of requestFileHandles() Switch to the new singular API as adopted in: WICG/cross-origin-storage#61 * refactor: use singular requestFileHandle() instead of requestFileHandles() Switch to the new singular API as adopted in: WICG/cross-origin-storage#61
1 parent 2e14c1d commit 6cc0630

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

packages/transformers/src/utils/cache/CrossOriginStorageCache.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export class CrossOriginStorage {
5757
return undefined;
5858
}
5959
try {
60-
const [handle] = await navigator.crossOriginStorage.requestFileHandles([makeHashDescriptor(hashValue)]);
60+
const handle = await navigator.crossOriginStorage.requestFileHandle(makeHashDescriptor(hashValue));
6161
const blob = await handle.getFile();
6262
return new Response(blob, {
6363
headers: {
@@ -110,7 +110,7 @@ export class CrossOriginStorage {
110110
* @returns {Promise<void>}
111111
*/
112112
_storeBlobInCOS = async (blob, hashHex) => {
113-
const [handle] = await navigator.crossOriginStorage.requestFileHandles([makeHashDescriptor(hashHex)], {
113+
const handle = await navigator.crossOriginStorage.requestFileHandle(makeHashDescriptor(hashHex), {
114114
create: true,
115115
});
116116
const writableStream = await handle.createWritable();

packages/transformers/src/utils/cache/cross-origin-storage.d.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
*/
66

77
/**
8-
* Represents the dictionary for hash algorithms and values.
8+
* Represents the dictionary for hash algorithm and value.
99
*/
1010
interface CrossOriginStorageRequestFileHandleHash {
1111
value: string;
1212
algorithm: string;
1313
}
1414

1515
/**
16-
* Represents the options for requesting file handles.
16+
* Represents the options for requesting a file handle.
1717
*/
1818
interface CrossOriginStorageRequestFileHandleOptions {
1919
create?: boolean;
@@ -24,10 +24,10 @@ interface CrossOriginStorageRequestFileHandleOptions {
2424
* [SecureContext]
2525
*/
2626
interface CrossOriginStorageManager {
27-
requestFileHandles(
28-
hashes: CrossOriginStorageRequestFileHandleHash[],
27+
requestFileHandle(
28+
hash: CrossOriginStorageRequestFileHandleHash,
2929
options?: CrossOriginStorageRequestFileHandleOptions,
30-
): Promise<FileSystemFileHandle[]>;
30+
): Promise<FileSystemFileHandle>;
3131
}
3232

3333
/**

0 commit comments

Comments
 (0)