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

@alpakaio/alpaka-native-useragent

v1.1.0

Published

User Agent builder used by Alpaka React Native apps

Downloads

9

Readme

alpaka-native-useragent

npm version

User Agent builder used by Alpaka React Native apps.

TOC

Installation

Using npm:

npm install --save @alpakaio/alpaka-native-useragent

⚠️ This package has a peer dependency of React Native Device Info at version 2.0.0 or higher.

Usage

import UserAgent from '@alpakaio/alpaka-native-useragent';

API

| Method | Return Type |  iOS | Android | Windows | Since | | ----------------------------------------------------------------- | ------------------- | :--: | :-----: | :-----: | ------ | | getUserAgentAsync() | Promise<string> | ✅ | ✅ | ✅ | 1.0.0 |

getUserAgentAsync()

Gets the appropriate user-agent string to use with Alpaka services.

Examples

const userAgentString = await UserAgent.getUserAgentAsync(); 
// "Alpaka Punch; 1.0.0; b.17; en-GB; (Apple; iOS; 12.1; Handset; iPhone10,6)"
UserAgent.getUserAgentAsync().then((userAgentString) => {
    // "Alpaka Punch; 1.0.0; b.17; en-GB; (Apple; iOS; 12.1; Handset; iPhone10,6)"
});

Troubleshooting

When installing or using alpaka-native-useragent, you may encounter the following problems:

alpaka-native-useragent relies on react-native-device-info which contains native code, and needs to be mocked. Jest Snapshot support may work though.

Here's how to do it with jest for example:

// in your package.json:
"jest": {
  "setupFiles": [
    "./testenv.js"
  ],


// testenv.js:
jest.mock('@alpakaio/alpaka-native-useragent', () => {
  return {
    getUserAgentAsync: jest.fn(),
  };
});

Some of the APIs internally used will throw warnings in certain conditions like on tvOS or the iOS emulator. This won't be visible in production but even in development it may be irritating. It is useful to have the warnings because these devices return no state, and that can be surprising, leading to github support issues. The warnings is intended to educate you as a developer. If the warnings are troublesome you may try this in your code to suppress them:

import { YellowBox } from 'react-native';
YellowBox.ignoreWarnings(['Required dispatch_sync to load constants for RNDeviceInfo']);

Release Notes

See the CHANGELOG.md.

react-native-dom

This library was made compatible with react-native-dom and react-native-web by providing an empty polyfill in order to avoid breaking builds.