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

code-send-plugin

v1.0.6

Published

Hot code update plugin

Downloads

5

Readme

code-send-plugin

Plugin for implementing hot code update with react native using code send platform

1. Setup

  1. Install code send plugin and react native geolocation for implementing regional update
$ npm install code-send-plugin @react-native-community/geolocation
  1. Link package
$ npx react-native link code-send-plugin @react-native-community/geolocation
  1. Add Permission to access geolocation and file system to store bundle on AndroidManifest.xml
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
  1. Add bundle resolver in react native host in android/app/src/main/java/com/packageName/MainApplication.java
package com.packageName;

import android.app.Application;
import com.facebook.react.PackageList;
import com.facebook.react.ReactApplication;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.soloader.SoLoader;
import java.util.List;
import com.reactlibrary.CodeSendModule; // import CodeSendModule

public class MainApplication extends Application implements ReactApplication {

  private final ReactNativeHost mReactNativeHost =
      new ReactNativeHost(this) {
        @Override
        public boolean getUseDeveloperSupport() {
          return BuildConfig.DEBUG;
        }

        @Override
        protected List<ReactPackage> getPackages() {
          @SuppressWarnings("UnnecessaryLocalVariable")
          List<ReactPackage> packages = new PackageList(this).getPackages();
          return packages;
        }

        @Override
        protected String getJSMainModuleName() {
          return "index";
        }

        // add this method to load bundle from code send platform
        @Nullable
        @Override
        protected String getJSBundleFile() {
            return CodeSendModule.launchResolveBundlePath(MainApplication.this);
        }
      };

  @Override
  public ReactNativeHost getReactNativeHost() {
    return mReactNativeHost;
  }

  @Override
  public void onCreate() {
    super.onCreate();
    SoLoader.init(this, /* native exopackage */ false);
    initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
  }
}
  1. Use code send hook to automatically check for update when application start. You can get projectId by creating a project on code send platform
import React from "react";
import { StyleSheet, Text, View } from "react-native";
import { useCodeSend } from "code-send"; // import useCodeSend hook

const App = () => {
  // run useCodeSend hook
  useCodeSend("projectId");
  return (
    <View>
      <Text>CodeSend initial app</Text>
    </View>
  );
};

export default App;

useCodeSend has second optional parameters to manage update behaviour. Here is the

| Parameter | Default | Description | | ------------------------ | ------- | ----------------------------------------------------------- | | showDownloadConfirmation | true | show confirmation dialog to download update if update found | | showDownloadProgress | true | show download update progress in notification | | showErrorMessage | true | show error message if checking or download update failed |

  1. Release your react native application and upload it to marketplace. To make a signed apk, follow tutorial from react native website

2. Release New Update

  1. Update your project source code on javascript side, and make a new bundle using following command
$ npx react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle
  1. Create a new update on code send platform and upload your bundle

  2. All running application should be notified that there is new update from you