From 1887645625600b2dfcb22324930bb3f8b276a545 Mon Sep 17 00:00:00 2001 From: Philipp Kunz Date: Sat, 10 Jun 2023 16:38:25 +0200 Subject: [PATCH] fix(core): update --- test/test.both.ts | 9 +++++++-- ts/00_commitinfo_data.ts | 2 +- ts/webdetector.classes.platform.ts | 2 +- tsconfig.json | 10 ++++++++++ 4 files changed, 19 insertions(+), 4 deletions(-) create mode 100644 tsconfig.json diff --git a/test/test.both.ts b/test/test.both.ts index 8a1cf8f..d3fda03 100644 --- a/test/test.both.ts +++ b/test/test.both.ts @@ -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(); diff --git a/ts/00_commitinfo_data.ts b/ts/00_commitinfo_data.ts index be7b0b6..db3a2ba 100644 --- a/ts/00_commitinfo_data.ts +++ b/ts/00_commitinfo_data.ts @@ -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' } diff --git a/ts/webdetector.classes.platform.ts b/ts/webdetector.classes.platform.ts index b89574c..a226f5d 100644 --- a/ts/webdetector.classes.platform.ts +++ b/ts/webdetector.classes.platform.ts @@ -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'; diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..0e331cc --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,10 @@ +{ + "compilerOptions": { + "experimentalDecorators": true, + "useDefineForClassFields": false, + "target": "ES2022", + "module": "ES2022", + "moduleResolution": "nodenext", + "esModuleInterop": true + } +}