Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions packages/utoo-web/src/project/Project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
ServiceWorkerOptions,
Stats,
} from "../types";
import { checkCompatibility } from "./checkCompatibility";
import { ForkedProject } from "./ForkedProject";

let ProjectWorker: Worker;
Expand Down Expand Up @@ -251,4 +252,8 @@ export class Project implements ProjectEndpoint {

return new ForkedProject(channel.port1);
}

public static checkCompatibility() {
return checkCompatibility();
}
}
42 changes: 42 additions & 0 deletions packages/utoo-web/src/project/checkCompatibility.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
export function checkCompatibility(): {
compatible: boolean;
minimalVersion: { chrome: number };
details: {
sharedArrayBuffer: boolean;
atomics: boolean;
worker: boolean;
serviceWorker: boolean;
opfs: boolean;
fileSystemObserver: boolean;
};
missing: string[];
} {
Comment thread
xusd320 marked this conversation as resolved.
Resolved
const details = {
sharedArrayBuffer:
typeof SharedArrayBuffer !== "undefined" && crossOriginIsolated,
atomics: typeof Atomics !== "undefined",
worker: typeof Worker !== "undefined",
serviceWorker: "serviceWorker" in navigator,
opfs: "storage" in navigator && "getDirectory" in navigator.storage,
fileSystemObserver: "FileSystemObserver" in window,
};

const missing: string[] = [];

if (!details.sharedArrayBuffer) missing.push("SharedArrayBuffer (COOP/COEP)");
if (!details.atomics) missing.push("Atomics");
if (!details.worker) missing.push("Worker");
if (!details.serviceWorker) missing.push("ServiceWorker");
if (!details.opfs) missing.push("OPFS");
if (!details.fileSystemObserver) missing.push("FileSystemObserver");
Comment thread
xusd320 marked this conversation as resolved.
Resolved

const compatible = missing.length === 0;
const minimalVersion = { chrome: 137 };
Comment thread
xusd320 marked this conversation as resolved.
Resolved

return {
compatible,
minimalVersion,
details,
missing,
};
}
Loading