jsPax is a JavaScript Pakagesystem. The Core of jsPax is the File "package.js"
.
To use jsPax Packages you need to load the Script into your HTML:
<SCRIPT SRC="package.js" TYPE="text/javascript"></script>
Then jsPax needs to know where your packages can be found:
$package.packageBase = 'http://www.example.com/packages/';
Now you can use packages:
$using('com.example.test',function() {com.example.test.doTest();});
$using(names,f)
names
f
$using()
returns immediatelly and loads the Packages assynchonously. You can not expect the Packages
to be loaded after $using()
returns.
That is all you need to use existing packages.
Basically a jsPax package is simply a JavaScript File, which at least creates an Object that has the same name as
the packages name. package.js
provides the function $package(name,object)
to make that
easier. The most simple package would then be:
$package('com.example.test',{});
$package(name,object)
name
object
Of course you can just create this Object at the end of an existing JS-File to make Packages from legacy code.
Packages are installed simply by copying them to the correct directory. The directory can be determined by $package.packageBase and the packages name:
Take the packages name and replace all '.' with '/'. Then append '.js' to that string and append the result to the package base. Then you have the URL where your package will be loaded from.
An Example: Your package is named 'com.example.test' and your package base is 'http://www.example.com/packages/'. Then you replaceall '.' with '/' in the Packagename: 'com/example/test', append '.js': 'com/example/test.js'. Now append this string to your package base: http://www.example.com/packages/com/example/test.js - that is the URL where jsPax will look for your package.
package.js
package.js
package_src.js
I have used JSquash for compression.
You can use jsPax under the terms of the GNU LGPL
There is a testsuite for jspax as well. Please go ahead, test the server installation and report any problems to me.