(
scope: string,
options: TensorCacheAccessOptions = {},
)
| 812 | } |
| 813 | |
| 814 | export function createArtifactCache( |
| 815 | scope: string, |
| 816 | options: TensorCacheAccessOptions = {}, |
| 817 | ): ArtifactCacheTemplate { |
| 818 | if (options.artifactCache !== undefined) { |
| 819 | return options.artifactCache; |
| 820 | } |
| 821 | const cacheType = normalizeCacheType(options.cacheType); |
| 822 | if (cacheType === "indexeddb") { |
| 823 | return new ArtifactIndexedDBCache(scope); |
| 824 | } |
| 825 | if (cacheType === "cross-origin") { |
| 826 | if (CrossOriginStorage.isAvailable()) { |
| 827 | return new ArtifactCrossOriginStorageCache(scope); |
| 828 | } |
| 829 | if (!crossOriginFallbackWarningLogged) { |
| 830 | console.warn( |
| 831 | "Cross-origin storage backend is unavailable; falling back to ArtifactCache.", |
| 832 | ); |
| 833 | crossOriginFallbackWarningLogged = true; |
| 834 | } |
| 835 | } |
| 836 | if (cacheType === "opfs") { |
| 837 | return new ArtifactOPFSCache(scope, options.opfsAccessMode); |
| 838 | } |
| 839 | return new ArtifactCache(scope); |
| 840 | } |
| 841 | |
| 842 | |
| 843 | /** |
no test coverage detected
searching dependent graphs…