mirror of
https://github.com/imputnet/cobalt.git
synced 2025-12-18 22:18:50 +00:00
web: add uuid() function with fallback if randomUUID is missing
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { AbstractStorage } from "./storage";
|
||||
import { uuid } from "$lib/util";
|
||||
|
||||
export class MemoryStorage extends AbstractStorage {
|
||||
#chunkSize: number;
|
||||
@@ -48,7 +49,7 @@ export class MemoryStorage extends AbstractStorage {
|
||||
}
|
||||
}
|
||||
|
||||
return new File(outputView, crypto.randomUUID());
|
||||
return new File(outputView, uuid());
|
||||
}
|
||||
|
||||
#expand(size: number) {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { AbstractStorage } from "./storage";
|
||||
import { uuid } from "$lib/util";
|
||||
|
||||
const COBALT_PROCESSING_DIR = "cobalt-processing-data";
|
||||
|
||||
@@ -19,7 +20,7 @@ export class OPFSStorage extends AbstractStorage {
|
||||
static async init() {
|
||||
const root = await navigator.storage.getDirectory();
|
||||
const cobaltDir = await root.getDirectoryHandle(COBALT_PROCESSING_DIR, { create: true });
|
||||
const handle = await cobaltDir.getFileHandle(crypto.randomUUID(), { create: true });
|
||||
const handle = await cobaltDir.getFileHandle(uuid(), { create: true });
|
||||
const reader = await handle.createSyncAccessHandle();
|
||||
|
||||
return new this(cobaltDir, handle, reader);
|
||||
|
||||
Reference in New Issue
Block a user