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

link-lab

v1.0.4

Published

A library for native integrations in web applications

Downloads

193

Readme

Native Interface Library

This library facilitates seamless communication between a web application and native modules, enabling various actions such as interacting with native device features, fetching app data, and handling notifications.

Features

  • Webview Initialization: Notify native layers when the webview is ready.
  • App Info Fetching: Retrieve app-specific information.
  • Deep Linking: Open specific app sections via deep links.
  • URL Handling: Open URLs in a browser or native layers.
  • Social Sharing: Share content across social platforms.
  • Camera & Gallery Access: Open front/back cameras or the device gallery.
  • Notification Management: Schedule notifications.
  • QR Code Scanning: Scan QR codes using the device camera.
  • Device Features: Trigger vibrations, capture screenshots, toggle loaders, and more.

Installation

To include this library in your project:

npm install dining-native-bridge-client

Usage

Import the Library

import NativeBridge from 'dining-native-bridge-client';

Initialize the Native Interface

Ensure the interface is properly initialized before invoking any native calls:

NativeBridge.init()
  .then(() => console.log('Native interface initialized!'))
  .catch((error) => console.error('Initialization failed:', error));

Check Initialization Status

if (NativeBridge.isNativeInitialized()) {
  console.log('Native interface is active.');
} else {
  console.log('Native support not available.');
}

Example API Calls

Open a Deep Link

NativeBridge.openDeeplink('myapp://home')
  .then(() => console.log('Deep link opened!'))
  .catch((error) => console.error('Failed to open deep link:', error));

Share Content via Social Media

NativeBridge.socialShare(
  'https://example.com',
  'Awesome Content',
  'Check out this amazing content!',
  'https://example.com/image.jpg'
)
  .then(() => console.log('Content shared!'))
  .catch((error) => console.error('Sharing failed:', error));

Schedule a Notification

NativeBridge.scheduleNotification(
  'Reminder',
  'Don\'t forget to check the app!',
  '2024-12-12T10:00:00Z'
)
  .then(() => console.log('Notification scheduled!'))
  .catch((error) => console.error('Notification scheduling failed:', error));

Capture a Screenshot

NativeBridge.captureScreenshot()
  .then((screenshotPath) => console.log('Screenshot saved at:', screenshotPath))
  .catch((error) => console.error('Screenshot failed:', error));

API Reference

Initialization

  • init(): Initializes the native interface. Returns a promise.
  • isNativeInitialized(): Checks if the native interface is active. Returns a boolean.

Native Callback Map

  • webviewInitComplete(): Notifies the native layer that the webview is ready.
  • getAppInfo(): Fetches app information from the native layer.
  • openDeeplink(url): Opens a deep link in the app.
  • openUrl(url): Opens a URL in the browser or native layer.
  • socialShare(url, title, description, image): Shares content on social platforms.
  • openFrontCamera(): Opens the front camera.
  • openBackCamera(): Opens the back camera.
  • closeWebView(url): Closes the webview.
  • showLoader(): Displays a loader.
  • hideLoader(): Hides the loader.
  • openGallery(): Opens the device gallery.
  • scheduleNotification(title, message, time): Schedules a notification.
  • scanQRCode(): Scans a QR code.
  • haptics(): Triggers device vibration.
  • isDarkModeEnabled(): Checks if dark mode is enabled.
  • captureScreenshot(): Captures a screenshot.
  • logoutUser(): Logs the user out of the app.
  • downloadFile(url): Downloads a file from the specified URL.

Error Handling

This library includes built-in error handling for common issues:

  • NATIVE_NOT_SUPPORT: Native capability is not supported.
  • BAD_REQUEST: Invalid input or request payload.
  • REQUEST_TIMEOUT: Native request timeout after 10 seconds.

Contribution

We welcome contributions! Please submit issues or pull requests to improve this library.


License