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

xrails

v0.2.0

Published

Expose the public interface of your JavaScript or TypeScript library to native code

Downloads

18

Readme

Crossrails Compiler Gitter npm version Downloads Build status Coverage Status

The crossrails compiler is a command line tool which translates JavaScript or TypeScript libraries to other languages, namely Swift and Java with support for C# and PHP coming soon.

The public interface of your library is translated to native code providing the developer integrating your library with a fully native coding experience. Behind the scenes the generated native code executes your original source on a JavaScript engine.

The goal of the project is to enable seamless code sharing from native JavaScript environments such as Node.js and the browser to any platform capable of running a JavaScript virtual machine such as iOS, Android, Windows, macOS, tvOS and serverside environments.

Unlike similar tools such as ReactNative and NativeScript, it is not designed to let you build apps using only JavaScript and does not attempt to provide wrappers around native, platform specific APIs. It was designed to help multi discipline teams writing native apps to avoid duplicating non-UI code in multiple languages.

Installing

npm install -g xrails

Basic usage

Simply specify a JavaScript source file and the native language you want to translate to as an option

xrails myLibrary.js --swift

This would output the Swift files beside the original source files, utilising the default JavaScript engine for the language (JavaScriptCore in Swift's case).

You can specify multiple languages at once and also specify separate output directories for each

xrails myLibrary.js --swift.emit=src/swift --java.emit=src/java

Under the hood

The input JavaScript source file will be bundled with the native language output and should be the same file you would include in the browser, aka post any transpilation or module bundling as it will need to be capable of running on your chosen JavaScript engine.

To output the JavaScript source file to a specific location use the emitJS option

xrails myLibrary.js --java.emit=src/main/java --java.emitJS=src/main/res

The compiler uses the source map of your input file to parse your original JavaScript or TypeScript source code, in the example above it would look for myLibrary.js.map in the same directory.

If your source map is elsewhere you can specify its location

xrails myLibrary.js --sourceMap=gen/myLibrary.js.map --java.emit=src/java

Extra reading