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

cordova-browsersync-primitives

v1.3.0

Published

Various tweaks needed to enable browsersync for cordova apps

Downloads

10

Readme

cordova-browsersync-primitives

This npm package contains common code used to implement browsersync with cordova. It exports the following APIs:

addCSP(filename)

###Parameters

  • String filename - name of the HTML file to update.

###Returns

  • Nothing.

Description

Reads the HTML file specified by filename, updates the Content-Security-Policy, and saves the file in place.

createIndexHtml(servers, platform, cordovaDir, [dest])

###Parameters

  • Object servers - The list of IP addresses supplied by browsersync that it is listening on.
  • String platform - Which platform (android or ios) the page should be built for. Affects the URLs embedded in the generated HTML file.
  • String cordovaDir - Base directory of the cordova project.
  • String dest (optional) - Location to save the start page. If not specified, defaults to <cordovaDir>/www/index.html.

###Returns

  • Nothing.

Description

Creates an HTML page that is embedded inside the application's APK or IPA file. When loaded, the HTML page redirects to the index.html served by browsersync.

This function embeds the IP addresses that the browsersync server is listening on into the HTML file that is built.

fixATS(cordovaDir, projectName)

###Parameters

  • String cordovaDir - Base directory of the cordova project.
  • String projectName - The name given to the cordova project at creation i.e. cordova create <PATH> <ID> <NAME>

###Returns

  • Nothing.

Description

Updates the iOS platform's <projectName>-Info.plist file to disable AppTransportSecurity, and allow loading external HTTP files.

startBrowserSync(cordovaDir, platforms, opts, cb)

###Parameters

  • String cordovaDir - Base directory of the cordova project.
  • String[] platforms - Array of strings, each of which is a Cordova platform name to serve.
  • Object | Function opts - Options object to be passed to browserSync. If this is a function, the function is called with default values and should return the final options to be passed to browser-sync.
  • Function(err, browserSyncInfo) cb - A callback when server is ready.

###Returns

  • Object - The browsersync instance created.

Description

Creates and initializes a browsersync instance. When the instance is ready, cb is called. cb will be passed 2 parameters:

  • Object err - An error object given by browsersync.
  • Object browserSyncInfo - Info about the browsersync instance. Format:
Object {
	Object bsInstance - The browsersync instance.
	Object servers {
		String local (optional) - Base URL to localhost.  Example: http://localhost:3000
		String external (optional) - Base URL for external address.  Example: http://10.128.64.174:3000
	}
}

getWWWFolder(platform)

###Parameters

  • String platform - Specifies which platform's path (android or ios) is desired.

###Returns

  • String - The path of the platform www directory. Note: This path always uses / delimiters.

Description

Returns the path of platform's www directory relative to the cordova root directory. For example: platforms/android/assets/www.

updateConfigXml(cordovaDir, platform, projectName, hostedPage)

###Parameters

  • String cordovaDir - Base directory of the cordova project.
  • String platform - Specifies which platform's config.xml file (android or ios) should be updated.
  • String projectName - The name given to the cordova project at creation i.e. cordova create <PATH> <ID> <NAME>
  • String hostedPage - Name of the starting HTML file that is embedded in the APK or IPA file.

###Returns

  • Nothing.

Description

Updates platform's config.xml file. Two things are changed:

  1. The starting page is changed to hostedPage (<content src='...'>).
  2. An <allow-navigation href="*" /> element is added to allow the app to navigate to http URLs inside the embedded web view.

isPlatformSupported(platform)

###Parameters

  • String platform - Specifies the name of the platform to test for support.

###Returns

  • Boolean - Returns true if the platform is supported; false otherwise.

Description

Returns true if a supported platform (android or ios) is passed in platform; false otherwise.