Skip to content

pinf/loader-js

Repository files navigation

EARLY STALLED EXPLORATION

New implementation: github.com/pinf/pinf-loader-js

Versatile & Complete Cross-Platform CommonJS JavaScript Module, Package & Program Loader

Status: BETA - Mostly stable API undergoing wider testing.

The PINF JavaScript Loader asynchronously combines what you would traditionally call a package installer and class loader and is intended to be used as the core to all your JavaScript applications no matter what platform they run on.

The loader allows for bootstrapping a state-of-the-art, consistent and portable CommonJS environment for any supported platform (on servers, in browsers, desktop applications, secure sandboxes, and embedded) and thus is ideally suited to be used as the target for the commonjs command (currently being standardized) and the development of cross-platform JavaScript applications and libraries that may be shared with the CommonJS ecosystem.

Loader overview image

This module loader brings CommonJS Modules/2 (currently in draft) plus CommonJS Packages, Package Mappings and further concepts to the following platforms:

  • commonjs - Use it as a target for the commonjs command being standardized
  • NodeJS - Use it in any NodeJS application (Default CLI and utility platform until API adapters come along)
  • Jetpack - Use it in any Gecko/XULRunner extension or application
  • v8cgi - Use it in any v8cgi application
  • GPSEE - Use it in any GPSEE application
  • RingoJS - Use it in any RingoJS application
  • Narwhal - Use it with any Narwhal engine platform
  • Titanium - Use it in any Appcelerator Titanium application
  • AdobeAir - Use it in any AdobeAir application
  • Wakanda (In Progress)
  • CouchApp (Initial exploration)
  • PhoneGap (Initial exploration)
  • PhantomJS (Not Yet Implemented)
  • IronJS (Not Yet Implemented)
  • SilkJS (Not Yet Implemented)
  • Rhino (Not Yet Implemented)
  • JSPL (Not Yet Implemented)
  • PSLib (Not Yet Implemented)
  • Browser - For development and optimized production purposes
    • BravoJS - Default browser loader with full CommonJS package support (11.8 KB minified & gziped)
    • PINF Browser Loader - Optimized production browser loader with goal of < 3 to 5 KB minified & gziped (Not Yet Implemented)
    • NobleJS (Not Yet Implemented)
    • RequireJS (Not Yet Implemented)
    • bdLoad (Not Yet Implemented)
    • Dojo (Not Yet Implemented)
  • Services

The loader implements or is compatible with the following specs:

The loader extends the core CommonJS platform defined by the above specifications with the following additions:

  • CommonJS Programs/A (strawman) (Not Yet Documented)
  • Various additions and generalizations to be able to load a wide range of packages. (Not Yet Documented)

The loader can be used:

  • By calling it from the command line to run a program
  • By require()ing it from any CommonJS module to load a sub-program
  • By setting it up as a package server to load programs into a browser
  • To export CommonJS programs to be loaded by CommonJS compliant loaders

The loader:

  • Aims to be complete and fully specification compliant where possible.
  • Aims to validate the CommonJS Program and Mappings approaches and inform CommonJS specifications.
  • Provisions and executes programs by downloading and linking dependencies on first use.
  • By default isolates the dependencies for each program.
  • Can provision complex applications (programs) composed of hundreds of packages by contacting an open network of public registry and repository servers. (Not Yet Implemented)
  • Can load complex applications (programs) composed of hundreds of packages from Content Delivery Networks fed by a simple program server. (Not Yet Implemented)
  • Supports REMOTE LIVE application DEBUGGING and EDITING for DEPLOYED applications running on any ANY PLATFORM (eval() or equivalent required). (Not Yet Implemented)

The loader is a sub-project of the PINF Toolchain Automation Platform where an application (program) is a view into the toolchain that statically links package-based dependencies.

The toolchain is an organized body of code & services maintained collectively for the purpose of automating software production and system operation. Any CommonJS package may be used as part of the toolchain.

Platform overview image

Install

Minimum Requirements:

  • UNIX system (Windows support is under development but still has some way to go)
  • NodeJS: http://nodejs.org/

Use any one of the following install solutions:

npm install -g pinf-loader-js

cd ~/
wget -O pinf-loader-js.tar.gz https://github.com/pinf/loader-js/tarball/master
tar -zxf pinf-loader-js.tar.gz
mv pinf-loader-js-* pinf-loader-js
alias commonjs='~/pinf-loader-js/pinf-loader.sh'

cd ~/
git clone git://github.com/pinf/loader-js.git pinf-loader-js
alias commonjs='~/pinf-loader-js/pinf-loader.sh'

Make sure it works:

commonjs -h

To install additional platforms (other than node) see:

To run the loader on a different platform (other than node) use:

commonjs --platform <PlatformAlias> ...

Where <PlatformAlias> is any of node, gpsee, v8cgi, narwhal or ringo.

NOTE: Not all features are supported on all platforms yet due to incomplete API adapters.

Demo: Hello World

commonjs -v --platform node https://github.com/pinf/test-programs-js/zipball/master --port 8081 HelloWorld

More demos:

Presentations

  1. CommonJS Everywhere (Wakanday 2011, Boston) (Video: 30m)
  2. CommonJS via PINF JavaScript Loader ~ Introduction (Boston JavaScript 2011, Boston) (Video: 1h 39m)

Documentation

Related Projects:

Support, Feedback & News

TODO

Enhancements

  • pinf/insight-js/NEXT will be incorporated for logging/output (do not spend much time on improving log/output messages until this is in place)
  • pinf/test-js/NEXT will be incorporated for advanced testing (do not spend much time on improving testing until this is in place)

Priority: High

Priority: Medium

  • Remove color characters when printing to browser consoles and buffer until newline
  • Profiling code in loader to time various things with an option to monitor interpreter spawn/load time as well.
  • PhantomJS adapter

Priority: Low

  • Refactor to leverage Q promises throughout.
  • Run exported programs on all platforms (not just browser).
  • Refactor, abstract and simplify various concepts like descriptors, locators, mapping resolver.

Contribute

You can find a list of things to get involved with here: ./NOTES.md

Collaboration Platform: https://github.com/pinf/loader-js/

Collaboration Process:

  1. Discuss your change on the mailing list
  2. Write a patch on your own
  3. Send pull request on github & ping mailing list
  4. Discuss pull request on github to refine

You must explicitly license your patch by adding the following to the top of any file you modify in order for your patch to be accepted:

//  - <GithubUsername>, First Last <Email>, Copyright YYYY, MIT License

Author

This project is a part of the PINF project maintained by Christoph Dorn.

Credits

This project would not be possible without the following:

  • CommonJS - For framing requirements into specifications
  • BravoJS - For a pure and clean CommonJS Modules/2 loader implementation
  • NodeJS - For providing a solid runtime used by default
  • Firefox - For providing an amazing browser platform
  • Jetpack - For providing a decent extension environment, API and tooling
  • Firebug - For the amazing developer tool it is
  • nodules - For implementing and refining CommonJS Packages/Mappings/C
  • pinf - For implementing and refining various designs and specifications
  • Narwhal - For providing an experimentation ground while prototyping conceps
  • Github - For igniting a generation of collaborative development
  • JavaScript - For the awesome language it is

This project uses code from:

Documentation License

Creative Commons Attribution-NonCommercial-ShareAlike 3.0

Copyright (c) 2011+ Christoph Dorn

Code License

MIT License

Copyright (c) 2011+ Christoph Dorn

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Packages

No packages published

Languages