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

jsx-linker

v0.1.8

Published

JSX postprocessor to support various environment

Downloads

73

Readme

jsx-linker

Synopsis

JSX postprocessor to support various environments.

Motivation

JavaScript is an infrastructure language for many environments (like SQL, Lua, Visual Basic etc...). Each environment uses a different code structure and assumptions because JavaScript doesn't have a standard module system or entry points.

This program converts the resulting code of JSX into the environment specific code.

Supported Output

You can select the output format with -t option. This tool supports the following output formats:

commonjs-lib, amd-lib, export-global

Add exports or define statements. export-global exports classes to global namespace. The classes that have an __export__ qualifier are exported.

Your Library

__export__ class Fib {
    static function calc(value : int) : int {
        // some code;
    }
}

Client Code

var Fib = require('fib').Fib;
Fib.calc(value);

extjs-app (experimental)

It supports config parameter, entry point function (main), and callback funcion for updating (onUpdate):

class _Main
{
    static const config = {
        name: 'sencha-touch-app',
        icon: {
            '57': 'resources/icons/Icon.png',
            '72': 'resources/icons/Icon~ipad.png',
            '114': 'resources/icons/[email protected]',
            '144': 'resources/icons/[email protected]'
        },
        isIconPrecomposed: true,
        startupImage: {
            '320x460': 'resources/startup/320x460.jpg',
            '640x920': 'resources/startup/640x920.png',
            '768x1004': 'resources/startup/768x1004.png',
            '748x1024': 'resources/startup/748x1024.png',
            '1536x2008': 'resources/startup/1536x2008.png',
            '1496x2048': 'resources/startup/1496x2048.png'
        },
        requires: [
            'Ext.MessageBox'
        ],
        views: [] : string[]
    };

    static function main (argv : string[]) : void
    {
        // Destroy the #appLoadingIndicator element
        Ext.fly('appLoadingIndicator').destroy();
        // Initialize the main view
        var view = new MainView();
        Ext.Viewport.add(view as Ext.Component);
    }

    static function onUpdate () : void
    {
        Ext.Msg.confirm(
            "Application Update",
            "This application has just successfully been updated to the latest version. Reload now?",
            (buttonId, value, opt) -> {
                if (buttonId == 'yes') {
                    dom.window.location.reload();
                }
            }
        );
    }
}

WebWorker

import "js/web.jsx";
import "webworker.jsx";

class _Main
{
    static function main(argv : string[]) : void
    {
        // called when this worker is initialized
    }

    __export static function onmessage(event : MessageEvent) : void
    {
        // called when `postMessage` is called from main script
        self.postMessage("message");
    }
}

ngCore

import "ngcore.jsx";

class _Main
{
    static var game : Game;
    static var hud : DebugControl;

    static function main (argv : string[]) : void
    {
        var glView = new UI.GLView();
        glView.setOpenGLESVersion(UI.Commands.OpenGLESVersion.OpenGLES2);

        var w = Core.Capabilities.getScreenWidth();
        var h = Core.Capabilities.getScreenHeight();

        glView.onload = function() {
            _Main.hud = new DebugControl(glView);
            Core.UpdateEmitter.setTickRate(1/60);
            _Main.game = new Game();
            _Main.game.start();
        };

        glView.setAttribute('frame', [0, 0, w, h]);
        glView.setAttribute('active', true);
    }
}

Installation

$ npm install -g jsx-linker

Usage

$ jsx-linker [option] [inputjsfile]

option

  • -t templateName, --tempalte=templateName

    Select template name. You can see all possible template names on the help description.

  • -s, --stdin

    Read source code from standard input.

  • -o, --output

    Output file name. If this option is not specified, it dumps resulting code to standard output.

  • -h, `--help``

    Display help

Usage Sample

Direct conversion with JSX

$ jsx --minify sample-class.jsx | jsx-linker -s -t nodejs-lib > sample-nodelib.js

Convert from file

$ jsx-linker -s -t nodejs-lib -o sample-nodelib.js sample.js

Show Help

$ jsx-linker --help

Development

Repository

  • Repository: git://github.com/shibukawa/jsx-linker.git
  • Issues: https://github.com/shibukawa/jsx-linker/issues

Run Test

$ grunt test

Build

# Build application or library for JS project
$ grunt build

# Generate API reference
$ grunt doc

Author

License

MIT

Complete license is written in LICENSE.md.