Add support LiveScript

This commit is contained in:
Namhyeon Go 2022-11-29 14:22:58 +09:00
parent 68457609d9
commit 6a9127baa9
4 changed files with 1690 additions and 10 deletions

View File

@ -30,7 +30,7 @@ WelsonJS - Build a Windows desktop apps with JavaScript, HTML, and CSS based on
- [Includes binaries](https://github.com/gnh1201/welsonjs/blob/master/bin/README.MD)
- [module.exports](https://nodejs.org/en/knowledge/getting-started/what-is-require/), CommonJS, UMD compatibility
- [NPM](https://www.npmjs.com/) compatibility
- [CoffeeScript 2](https://coffeescript.org/) compatibility
- [CoffeeScript 2](https://coffeescript.org/)/[LiveScript](https://livescript.net/) compatibility
- Ready to use on Windows machine immediately. No require additional softwares installation.
## Included libraries

29
app.js
View File

@ -208,7 +208,7 @@ function require(FN) {
var cache = require.__cache__ = require.__cache__ || {};
var suffix = FN.substr(FN.lastIndexOf('.'));
if (suffix !== '.js' && suffix !== '.coffee') FN += ".js";
if ('.js$.coffee$.ls$'.indexOf(suffix + '$') < 0) FN += ".js";
if (cache[FN]) return cache[FN];
// get file and directory name
@ -216,15 +216,26 @@ function require(FN) {
var __dirname__ = require.__getDirName__(__filename__);
var T = require.__load__(FN);
// pre-compile if CoffeeScript v2.7.0
if (suffix === '.coffee') {
T = require.__msie9__("app/assets/js/coffeescript-legacy-2.7.0.min", [T], function(p, w, d) {
return w.CoffeeScript.compile(p[0], {
"header": true,
"sourceMap": false,
"bare": true
// pre-compile if use Transpiler
switch (suffix) {
case '.coffee': // CoffeeScript 2
T = require.__msie9__("app/assets/js/coffeescript-legacy-2.7.0.min", [T], function(p, w, d) {
return w.CoffeeScript.compile(p[0], {
"header": true,
"sourceMap": false,
"bare": true
});
});
});
break;
case ".ls": // LiveScript
T = require.__msie9__("app/assets/js/livescript-1.6.1.min", [T], function(p, w, d) {
return w.require("livescript").compile(p[0], {
"header": true,
"bare": true
});
});
break;
}
// compile

1646
app/assets/js/livescript-1.6.1.min.js vendored Normal file

File diff suppressed because one or more lines are too long

23
helloworld.ls Normal file
View File

@ -0,0 +1,23 @@
# Easy listing of implicit objects
table1 =
* id: 1
name: 'george'
* id: 2
name: 'mike'
* id: 3
name: 'donald'
table2 =
* id: 2
age: 21
* id: 1
age: 20
* id: 3
age: 26
main = (args) ->
console.log JSON.stringify(table1)
console.log JSON.stringify(table2)
console.log "Hello world, LiveScript"
exports.main = main