fix: add app-barowser for browser

This commit is contained in:
2025-06-12 15:02:16 +08:00
parent 324c4e9862
commit d2ebb5f488
4 changed files with 30 additions and 5 deletions

15
src/utils/is-engine.ts Normal file
View File

@@ -0,0 +1,15 @@
export const isNode = typeof process !== 'undefined' && process.versions != null && process.versions.node != null;
export const isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined' && typeof document.createElement === 'function';
// @ts-ignore
export const isDeno = typeof Deno !== 'undefined' && typeof Deno.version === 'object' && typeof Deno.version.deno === 'string';
export const getEngine = () => {
if (isNode) {
return 'node';
} else if (isBrowser) {
return 'browser';
} else if (isDeno) {
return 'deno';
}
return 'unknown';
};