2 Commits

Author SHA1 Message Date
d4401172e6 2.0.1 2023-06-10 16:38:25 +02:00
1887645625 fix(core): update 2023-06-10 16:38:25 +02:00
5 changed files with 20 additions and 5 deletions

View File

@ -1,6 +1,6 @@
{
"name": "@pushrocks/webdetector",
"version": "2.0.0",
"version": "2.0.1",
"private": false,
"description": "detect different environments within the browser",
"main": "dist_ts/index.js",

View File

@ -1,10 +1,10 @@
import { tap, expect } from '@pushrocks/tapbundle';
import * as webdetector from '../ts/index';
import * as webdetector from '../ts/index.js';
let testWebDetector: webdetector.WebDetector;
tap.test('first test', async () => {
const testWebDetector = new webdetector.WebDetector({
testWebDetector = new webdetector.WebDetector({
checkOnlineUrl: 'https://pubapi.lossless.one',
});
@ -21,6 +21,11 @@ tap.test('should be online', async () => {
});
});
tap.test('should detect the platform', async () => {
const platform = testWebDetector.platform.detectPlatform();
console.log(platform);
});
console.log('hi');
tap.start();

View File

@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@pushrocks/webdetector',
version: '2.0.0',
version: '2.0.1',
description: 'detect different environments within the browser'
}

View File

@ -2,7 +2,7 @@ export type TWebPlatform = 'android' | 'ios' | 'windows' | 'mac' | 'linux' | 'un
export class Platform {
public detectPlatform(): TWebPlatform {
const userAgent = navigator?.userAgent?.toLowerCase();
const userAgent = globalThis?.navigator?.userAgent?.toLowerCase();
if (!userAgent) {
return 'unknown';

10
tsconfig.json Normal file
View File

@ -0,0 +1,10 @@
{
"compilerOptions": {
"experimentalDecorators": true,
"useDefineForClassFields": false,
"target": "ES2022",
"module": "ES2022",
"moduleResolution": "nodenext",
"esModuleInterop": true
}
}