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

@qubic-js/react-native-alice

v0.6.1

Published

react native plugin for alice

Downloads

76

Readme

react-native-alice

rn plugin for alice

Installation

npm install react-native-alice

Usage

 createAccount(
    password: string,
    reqPayload: string,
    wsUrl: string,
    ticket: string
  ): Promise<string>;
  verifyPassword(
    password: string,
    reqPayload: string,
    wsUrl: string,
    ticket: string
  ): Promise<string>;
  reshare(
    oldPassword: string,
    newPassword: string,
    reqPayload: string,
    wsUrl: string,
    ticket: string
  ): Promise<string>;
  signMessage(
    password: string,
    reqPayload: string,
    wsUrl: string,
    ticket: string
  ): Promise<string>;
  signTypedData(
    password: string,
    reqPayload: string,
    wsUrl: string,
    ticket: string
  ): Promise<string>;
  signTransaction(
    password: string,
    reqPayload: string,
    wsUrl: string,
    ticket: string
  ): Promise<string>;

  echo(text: string): Promise<string>;
  getGoBenchmarkResult(): string;
  generateSafePrime(size: number): string;
  generatePrime(size: number): string;

Development

Prepare Go environment

git config --global url.“ssh://[email protected]/”.insteadOf “https://github.maicoin.site/”

Update ~/.zshrc

This including Go path and Android path

export GOPRIVATE=github.maicoin.site # tell GO this is private repo
export ANDROID_HOME=$HOME/Library/Android/sdk
export ANDROID_NDK_HOME=$HOME/Library/Android/sdk/ndk/29.0.13113456
export JAVA_HOME=$(/usr/libexec/java_home -v17)
export PATH="$JAVA_HOME/bin:$PATH"
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/tools/bin
export PATH=$PATH:$ANDROID_HOME/platform-tools
export PATH=$PATH:$HOME/go/bin

Install go mod

go mod tidy

# Install gomobile cli and init
make install-tools

Prepare gemfile for ios example

cd example/ios
bundle install

When go file changed

# Release
./build-go-lib.mjs

# Debug
./build-go-lib.mjs -d

# android
# it will rebuild including alice go library
yarn example android

# ios
# need to manually pod install
cd example/ios
pod install
cd ..
yarn example ios

Try in on simulator

You can see typescript file changed immediately. And the log from Go lang will show up in Android Studio

yarn example android
yarn example ios

假設要加一個新方法

1. 先在 src/NativeAlice.ts 定好 Spec

yarn example ios/android 時, turbo module 會確認是否有實作

echo(text: string): Promise<string>;

2. android/ios native 實作

android/src/java/AliceModule.kt

  override fun echo(message: String, promise: Promise) {
    try {
      val result = AliceGoLib.echo(message)
      promise.resolve(result)
    } catch (e: Exception) {
      promise.reject("ECHO_ERROR", e)
    }
  }

ios/Alice.mm

- (void)echo:(NSString *)text
   resolve:(RCTPromiseResolveBlock)resolve
   reject:(RCTPromiseRejectBlock)reject
{
  NSError *error = nil;
  NSString *result = AliceGoLibEcho(text, &error);
  if (error != nil) {
    reject(@"echo_error", error.localizedDescription, error);
  } else {
    resolve(result);
  }
}

3. 在 go 新增方法

// 原始方法
func echo(s string) (string, error) {
  return fmt.Sprintf("Echo: %s", s), nil
}

// 首字大寫,代表是 public function
func Echo(s string) (string, error) {
  // aliceUtils.SafeExecute 可以讓 panic 作為 error 傳去上一層
  return aliceUtils.SafeExecute(func() (string, error) {
    return echo(s)
  })
}

4. 編譯 go 成為 library,會生成 aar 和 xcframework

./build-go-lib.mjs

5. 確認是否正常運作

# android 直接會用新的 aar
yarn example android

# ios 需要手動再安裝一次
cd example/ios
pod install
cd ../..
yarn example ios

如果有改動 go 的話照上面方法執行, 只有改 kotlin/objectv 的話,就執行 yarn example android/ios, 只有 src/ts 的話,因為有 hot reload 機制不需要重 build, 也可以只執行 yarn example start,然後手動啟用模擬器之前已 build 過的 app

Release

  1. When .go files changed, execute ./build-prod.sh before release.
  2. type yarn release to update version tag and publish to npm

Use Go as library in kotlin


classDiagram
  class JavaScript {
    +React Native App
    +Calls Native Modules
  }

  class ReactNativePlugin {
    +@ReactMethod functions
    +Bridge Layer
  }

  class Kotlin {
    +Native Android Code
    +Can call Go via JNI or include Go logic
  }

  class Go {
    +WASM (JSC only)
  }

  JavaScript --> ReactNativePlugin : uses
  ReactNativePlugin --> Kotlin : implemented in
  Kotlin --> Go : calls (via JNI or shared lib)

Use Go as WASM

classDiagram
  class JavaScript {
    +React Native App
    +Uses WebAssembly
    +Calls Plugin bridge
  }

  class ReactNativePlugin {
    +Bridge to native layer
    +Handles file loading / FS
  }

  class WebAssembly {
    +Compiled from Go (.wasm)
    +Runs in JSC (not Hermes)
  }

  class Go {
    +Go source code
    +Built with GOARCH=wasm
  }

  JavaScript --> ReactNativePlugin : uses
  ReactNativePlugin --> WebAssembly : loads & instantiates
  WebAssembly --> JavaScript : exports functions
  Go --> WebAssembly : compiled to .wasm

go install

// put this in ~/.zshrc

export GOPRIVATE=github.maicoin.site
git config --global url.“ssh://[email protected]/”.insteadOf “https://github.maicoin.site/”

ios 安裝要求 new architecture, expo config 要啟用才能正常

  [
    'expo-build-properties',
    {
      ios: {
        newArchEnabled: true,
      },
    },
  ],

txt sign android 模擬器比較

android 目前 v8 - js 版本

HTSS sign duration: 3435 ms
HTSS sign duration: 3475 ms
HTSS sign duration: 3007 ms
HTSS sign duration: 2486 ms
HTSS sign duration: 2934 ms

android react-native-alice go

HTSS sign duration: 3335 ms
HTSS sign duration: 4161 ms
HTSS sign duration: 3282 ms
HTSS sign duration: 3239 ms
HTSS sign duration: 3067 ms

txt sign ios 模擬器比較

ios 目前 jsc - js 版本

HTSS sign duration: 3053 ms HTSS sign duration: 3095 ms HTSS sign duration: 3651 ms HTSS sign duration: 2696 ms HTSS sign duration: 3272 ms

ios react-native-alice go

HTSS sign duration: 2777 ms HTSS sign duration: 1966 ms HTSS sign duration: 3245 ms HTSS sign duration: 2971 ms HTSS sign duration: 3081 ms

TODO

  • web wasm
    • where to put source wasm file
    • how to ship *.wasm and wasm_exec.js
  • support node