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 🙏

© 2026 – Pkg Stats / Ryan Hefner

webviews

v1.0.1

Published

![WebViews Icon](http://i.imgur.com/Qwba5TC.png)

Downloads

20

Readme

WebViews Icon

WebViews

An Angular2 NativeScript WebView Module that works on iOS and Android as well.

Requirements

  • NativeScript 3.0.1
  • Angular 2+
  • Typescript 2.2.2

Features

  • Template Bindings with Handlebars
  • Bi Directional communication between the WebView and the Parent NativeScript Component
  • Works on real iOS Devices as well not just the emulator

Install

npm install webviews --save

or:

tns plugin add webviews

Usage

// ~/myProject/app/MyComponent/MyComponent.component.ts
import { Component, ElementRef, OnInit, OnDestroy } from '@angular/core';
import { WebViews } from 'webviews';

@Component({
    template: `
        <GroupLayout>
            <WebView #webView></WebView>
        </GroupLayout>
    `
})

export class MyComponent implements OnInit, OnDestroy  {
    // Get an Element Reference to a WebView Directive
    @ViewChild('webView') WebViewElement: ElementRef;

    // Variable for the WebView Service Instance
    webview: any;

    ngOnInit(): void {
        // Create WebView Service Instance
        this.webview = new WebView(this.webViewElement, 'www', 'index.html')
        
        // Set context paramaeter
        this.webview.set('name', 'John Doe');

        // Load WebView Template
        this.webview.load().then(() => {
            this.webview.interface.emit('init', 'hello from the parent')
            this.webview.interface.on('message', (message) => {
                alert(message);
            })
        })
    }

    ngOnDestroy(): void {
        this.webview.dispatch();
    }
}
<!-- ~/myProject/app/www/index.html -->
<h1>Hello {{name}}!</h1>
<script>
    window.onload = function(){
        var webViewInterface = window.nsWebViewInterface;

        webViewInterface.emit('message', 'loading')
        webViewInterface.on('update', function(message){
            alert(message);
        })
    }
</script>

<!--
Result:
<h1>Hello John Doe</h1>
-->

API

WebView Class

var webViewInstance = new WebViews(webViewElementRef: any, folder: any, file: any)

  • webViewElementRef: An ElementRef object from @ViewChild
  • folder: The folder name where the html file is located
  • file: The name of the html file to load within the folder

WebView Instance Parameters

webview.interface

An Object that containing methods that allow bi-directional communication between the Web View and the nativescript parent.

webview.interface.on(eventName: string, callback: Function): void

Listen on events

  • eventName: The event name to listen to
  • eventData: A callback function that gets called when it is emitted

webview.interface.emit(eventName: string, eventData: any): void

  • eventName: The event name to listen to
  • eventData: Data to send to the listener callback

WebView Instance Methods

webview.set(key: string, value: any): void

Set context parameter

  • key: The context parameter name
  • value: The context parameter value

Usage in TypeScript:

// in ts
webview.set('name', 'John Doe')

HTML File:

<!-- in html -->
<h1>Hello {{name}}</h1>

Will Become:

<h1>Hello John Doe</h1>

webview.load(initialContext?: any): Promise

Load the HTML File.

  • initialContext: An object that sets context parameters.

webview.addScript(folderName: string, fileName: string, params?: any): Promise

Attach a Script

  • folderName: The folder name where the script is located
  • fileName: The script file name to load within the folder
  • params: An array of key-value objects for settings parameters on the script tag

webview.addStyle(folderName: string, fileName: string, params?: any): Promise

Attach a Stylesheet

  • folderName: The folder name where the stylesheet is located
  • fileName: The stylesheet file to load within the folder

webview.dispatch(): void

Dispatch Event Listeners. This method should be called within ngOnDestroy event in a component.

License

MIT License

Copyright (c) 2017 Adam Halasz [email protected]

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.