Spaces:
Sleeping
Sleeping
File size: 1,494 Bytes
43a06dc |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
import { browser } from "$app/environment";
const app = {
is: {
installed: false,
}
}
const device = {
is: {
iPhone: false,
iPad: false,
iOS: false,
android: false,
mobile: false,
},
prefers: {
language: "en",
reducedMotion: false,
reducedTransparency: false,
},
supports: {
share: false,
directDownload: false,
},
userAgent: "sveltekit server",
}
if (browser) {
const ua = navigator.userAgent.toLowerCase();
const iPhone = ua.includes("iphone os");
const iPad = !iPhone && ua.includes("mac os") && navigator.maxTouchPoints > 0;
const iOS = iPhone || iPad;
const android = ua.includes("android") || ua.includes("diordna");
const installed = window.matchMedia('(display-mode: standalone)').matches;
app.is = {
installed,
};
device.is = {
iPhone,
iPad,
iOS,
android,
mobile: iOS || android,
};
device.prefers = {
language: navigator.language.toLowerCase().slice(0, 2) || "en",
reducedMotion: window.matchMedia('(prefers-reduced-motion: reduce)').matches,
reducedTransparency: window.matchMedia('(prefers-reduced-transparency: reduce)').matches,
};
device.supports = {
share: navigator.share !== undefined,
directDownload: !(installed && iOS),
};
device.userAgent = navigator.userAgent;
}
export { device, app };
|