npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@hbtv/browser-detect

v1.0.1

Published

浏览器检查工具

Downloads

1

Readme

hbtv/browser-detect

安装方法

npm install @hbtv/browser-detect --save

使用方法-useBrowserDetect

import useBrowserDetect from '@hbtv/browser-detect'
const {browserInfo,browserValid,OSvalid,error}=useBrowserDetect(option)

API-useBrowserDetect

Params

| 参数 | 说明 | 类型 | 默认值 | | --- | --- | --- | --- | | option | | Option |undefined |

Result

| 参数 | 说明 | 类型 | 默认值 | | --- | --- | --- | --- | | browserInfo|浏览器的信息|BrowserInfo|| | browserValid|是否通过browserRules的检查|boolean|true | OSvalid|是否通过OSRules的检查|boolean|true | error|一些错误信息|string|null

使用方法-BrowserDetectModal

import BrowserDetectModal from '@hbtv/browser-detect'

const ShouleDetectBrowserComponent=()=>{
    return <><BrowserDetectModal /></>
}

API-BrowserDetectModal

| 参数 | 说明 | 类型 |必填|默认值 | | --- | --- | --- | --- | --- | | onOk | 弹窗的ok回调 | ()=>void | false | | | onCancel | 弹窗的cancel回调 | ()=>void | false | | content | 自定义提示内容 | ReactNode | false | null
| title | 自定义标题 | ReactNode | false | null | | browserRules | 浏览器规则 | BrowserRule | false | [] | | OSRules | 操作系统规则 | OSRules | false | [] | | strict | 严格模式 | strict | false | false | | modalMode | 弹窗模式 | ModalMode | fasle | remind | | checkMode | 检查模式 | CheckMode | false | once | | location | 浏览器的location | Location | false |null | | disable | 不启用检查 | boolean | false | false |

Interface & Type


type Compare = 'lte'|'gte'|'eq'|'ne'|'ex';

type BrowserName = 'aol'|'edge'|'yandexbrowser'|'wechat'|'qq'|'vivaldi'|'kakaotalk'|'samsung'|'chrome'|'phantomjs'|'crios'|'firefox'|'fxios'|'opera'|'opera'|'ie'|'bb10'|'android'|'ios'|'safari'|'facebook'|'instagram'|'ios-webview'|'unknown';

type OSName = 'iOS'|'Android OS'|'BlackBerry OS'|'Windows Mobile'|'Amazon OS'|'Windows 3.11'|'Windows 95'|'Windows 98'|'Windows 2000'|'Windows XP'|'Windows Server 2003'|'Windows Vista'|'Windows 7'|'Windows 8'|'Windows 8.1'|'Windows 10'|'Windows ME'|'Open BSD'|'Sun OS'|'Linux'|'Mac OS'|'QNX'|'BeOS'|'OS/2'|'Search Bot'|'unknown';

type CheckMode = 'once'|'onceBySession'|'eachPage';
/**
 * @type once
 * 仅第一次使用时进行检查
 * @type onceBySession
 * 每次打开会话时进行检查
 * @type eachPage
 * url变化时进行检查
 */
type ModalMode = 'remind'|'forcus';
/**
 * @type remind
 * 仅提示,弹窗可观
 * @type forcus
 * 弹窗不可关闭
 */

interface Option{
    userAgent?: string; //navigator.useAgent
    browserRules?: BrowserRule[]; //浏览器检查规则
    OSRules?: OSName[]; //操作系统检查规则
    strict?: boolean; //严格模式,开启时,仅允许规则内浏览器通过检查,关闭时则只对规则内进行检查,不在规则内的直接通过
}

interface BrowserRule{
    name: BrowserName; //常见浏览器
    rule: Compare; //比较规则
    version: string; //版本号
}

Acknowledgment

joo-browser-detect

LICENCE

The MIT License (MIT)

Copyright (c) 2021 yugongjie [email protected]