This is an automated email from the ASF dual-hosted git repository.
akaashrp pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tvm.git
The following commit(s) were added to refs/heads/main by this push:
new aa7ad03f17 [Web][COS] Rename requestFileHandle() to getFileHandle()
(#20597)
aa7ad03f17 is described below
commit aa7ad03f17f4b7028da1dce89ffc68c88fdfd6f6
Author: Thomas Steiner <[email protected]>
AuthorDate: Thu Oct 8 02:36:26 2026 +0200
[Web][COS] Rename requestFileHandle() to getFileHandle() (#20597)
The Cross-Origin Storage API renamed `requestFileHandle()` to
`getFileHandle()` in
https://github.com/WICG/cross-origin-storage/pull/86. This follows the
rename, and `isAvailable()` now checks for `getFileHandle()` itself, so
an implementation without it falls back to the default cache.
---
web/src/artifact_cache.ts | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/web/src/artifact_cache.ts b/web/src/artifact_cache.ts
index 4c2932739e..087cd3d1e7 100644
--- a/web/src/artifact_cache.ts
+++ b/web/src/artifact_cache.ts
@@ -138,7 +138,7 @@ interface CrossOriginStorageHandle {
createWritable(): Promise<CrossOriginStorageWritable>;
}
-interface CrossOriginStorageRequestFileHandleOptions {
+interface CrossOriginStorageGetFileHandleOptions {
create?: boolean;
origins?: string[] | string | undefined;
}
@@ -149,9 +149,9 @@ interface CrossOriginStorageWritable {
}
interface CrossOriginStorageAPI {
- requestFileHandle(
+ getFileHandle(
descriptor: CrossOriginHashDescriptor,
- options?: CrossOriginStorageRequestFileHandleOptions,
+ options?: CrossOriginStorageGetFileHandleOptions,
): Promise<CrossOriginStorageHandle>;
}
@@ -185,7 +185,10 @@ class CrossOriginStorage {
if (typeof navigator === "undefined") {
return false;
}
- return navigator.crossOriginStorage !== undefined;
+ // Check for `getFileHandle()` itself, so that an implementation exposing
+ // `navigator.crossOriginStorage` without the method falls back to the
+ // default cache.
+ return typeof navigator.crossOriginStorage?.getFileHandle === "function";
}
async match(request: RequestLike): Promise<Response | undefined> {
@@ -199,7 +202,7 @@ class CrossOriginStorage {
if (!api) {
return undefined;
}
- const handle = await api.requestFileHandle(hash);
+ const handle = await api.getFileHandle(hash);
if (!handle) {
return undefined;
}
@@ -218,7 +221,7 @@ class CrossOriginStorage {
if (!api) {
throw new Error("Cross-origin storage API unavailable.");
}
- const handle = await api.requestFileHandle(hash, { create: true, origins:
"*" /* All origins */ });
+ const handle = await api.getFileHandle(hash, { create: true, origins: "*"
/* All origins */ });
if (!handle) {
throw new Error("Cross-origin storage API returned no handle.");
}