Skip to content

Commit 091127f

Browse files
author
dmp42
committed
jsBooting
1 parent 10e5ff5 commit 091127f

38 files changed

+1493
-499
lines changed

pukefile.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def doc():
4141

4242
@task("Lint")
4343
def lint():
44-
PH.linter("src")
44+
PH.linter("src", excluding = "*tests*")
4545

4646
@task("Hint")
4747
def hint():
@@ -257,13 +257,19 @@ def build():
257257
list = FileList('src/jsboot/debug', filter = '*.js', exclude = '*xxx*');
258258
combine(list, Yak.build_root + "/debug.js", replace=sed)
259259

260-
list = FileList('src/jsboot/core', filter = '*.js', exclude = '*xxx*');
260+
list = FileList('src/jsboot/gister', filter = '*.js', exclude = '*xxx*')
261+
list.merge(FileList('src/jsboot/core', filter = '*.js', exclude = '*xxx*'));
261262
# list.merge(FileList('src/jsboot/gister', filter = '*.js', exclude = '*xxx*'));
262-
list.merge(['src/jsboot/gister/amdadapter.js', 'src/jsboot/gister/packman.js'])
263263
list.merge(['src/jsboot/types/eventdispatcher.js'])
264264
combine(list, Yak.build_root + "/core.js", replace=sed)
265265

266-
list = FileList('src/jsboot/service', filter = '*.js', exclude = '*xxx*');
266+
list = [
267+
'src/jsboot/service/errors.js',
268+
'src/jsboot/service/client.js',
269+
'src/jsboot/service/core.js',
270+
'src/jsboot/service/flaves/account.js'
271+
]
272+
267273
combine(list, Yak.build_root + "/service.js", replace=sed)
268274

269275
list = FileList('src/jsboot/ui', filter = '*.js', exclude = '*xxx*');

src/jsboot/core/a.js

Lines changed: 0 additions & 16 deletions
This file was deleted.

src/jsboot/core/console.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,11 @@
1111
* @name {PUKE-GIT-ROOT}/jsboot/core/errorHandler.js{PUKE-GIT-REVISION}
1212
*/
1313

14-
(function() {
15-
/*global console*/
14+
/*global console*/
15+
jsBoot.add(console).as('nativeConsole');
16+
jsBoot.pack('jsBoot.core', function(api) {
1617
'use strict';
1718

18-
var scope = jsBoot.core;
19-
20-
var nativeConsole = console;
2119
var fakeConsole = {
2220
debug: function() {},
2321
log: function() {},
@@ -27,10 +25,10 @@
2725
error: console.error
2826
};
2927

30-
scope.toggleConsole = function(on) {
31-
var mesh = on ? nativeConsole : fakeConsole;
28+
this.toggleConsole = function(on) {
29+
var mesh = on ? api.nativeConsole : fakeConsole;
3230
Object.getOwnPropertyNames(mesh).forEach(function(i) {
3331
console[i] = mesh[i];
3432
});
3533
};
36-
})();
34+
});

src/jsboot/core/error.js

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,15 @@
1616
* @see http://stackoverflow.com/questions/332422/how-do-i-get-the-name-of-an-objects-type-in-javascript
1717
*/
1818

19-
(function() {
20-
/*global Error, window, printStackTrace*/
19+
/*global Error, window, printStackTrace*/
20+
jsBoot.add(Error).as('NativeError');
21+
jsBoot.pack('jsBoot.core', function(api) {
2122
'use strict';
2223

23-
var scope = jsBoot.core;
24-
2524
// Possibly pb related to X-Domain limitation shit
26-
scope.Error = function(name, message) {
25+
this.Error = function(name, message) {
2726
// Error behavior is strange...
28-
var b = Error.apply(this, [message]);
27+
var b = api.NativeError.apply(this, [message]);
2928
// Not too sure this leads anywhere safe though (google code fux...)
3029
if ((this == window) || (this === undefined))
3130
return;
@@ -36,22 +35,22 @@
3635
this.stack = (typeof 'printStackTrace' != 'undefined') ? printStackTrace() : [];
3736
};
3837

39-
Object.getOwnPropertyNames(Error.prototype).forEach(function(i) {
38+
Object.getOwnPropertyNames(api.NativeError.prototype).forEach(function(i) {
4039
if (i != 'constructor')
41-
scope.Error.prototype[i] = Error.prototype[i];
40+
this.Error.prototype[i] = api.NativeError.prototype[i];
4241
}, this);
4342

4443
['NOT_IMPLEMENTED', 'UNSPECIFIED', 'NOT_INITIALIZED', 'WRONG_ARGUMENTS',
4544
'UNSUPPORTED', 'NATURAL_BORN_CRASH'].forEach(function(item, idx) {
46-
scope.Error[item] = scope.Error.prototype[item] = idx;
47-
});
45+
this.Error[item] = this.Error.prototype[item] = idx;
46+
}, this);
4847

49-
scope.Error.prototype.toString = function() {
48+
this.Error.prototype.toString = function() {
5049
return this.name + ': ' + this.message + '\nStack: ' +
5150
((typeof this.stack == 'array') ? this.stack.join('\n') : this.stack);
5251
};
5352

54-
})();
53+
});
5554

5655
/**
5756
* @namespace

src/jsboot/core/errorHandler.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,10 @@
1212
* @name {PUKE-GIT-ROOT}/jsboot/core/errorHandler.js{PUKE-GIT-REVISION}
1313
*/
1414

15-
(function() {
15+
jsBoot.pack('jsBoot.core', function() {
1616
/*global window, console*/
1717
'use strict';
1818

19-
var scope = jsBoot.core;
20-
21-
2219
// Consumer may register an handler instead of the dumb one
2320
/**
2421
* Call this declare a callback for exceptions
@@ -29,7 +26,7 @@
2926
* @returns undefined
3027
*/
3128

32-
scope.registerErrorHandler = function(hnd) {
29+
this.registerErrorHandler = function(hnd) {
3330
handlers.push(hnd);
3431
};
3532

@@ -53,4 +50,4 @@
5350
}
5451
};
5552

56-
})();
53+
});

src/jsboot/debug/a.js

Lines changed: 0 additions & 16 deletions
This file was deleted.

src/jsboot/debug/console.js

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010
* @name {PUKE-GIT-ROOT}/jsboot/debug/console.js{PUKE-GIT-REVISION}
1111
*/
1212

13-
(function() {
13+
/*jshint devel:true*/
14+
jsBoot.add(console).as('nativeConsole');
15+
jsBoot.pack('jsBoot.debug', function(api) {
1416
'use strict';
1517

16-
var scope = jsBoot.debug;
17-
1818
// Verbosity controller
1919
var e = {
2020
'DEBUG': 1,
@@ -26,32 +26,31 @@
2626
'ALL': 63
2727
};
2828

29-
scope.console = {
29+
this.console = {
3030
VERBOSITY: e.ALL
3131
};
3232

3333
// console.time('start');
34-
var c = this.console;
3534
Object.keys(e).forEach(function(i) {
36-
var level = scope.console[i] = e[i];
37-
var meth = c[i.toLowerCase()];
38-
c[i.toLowerCase()] = function() {
39-
if (scope.console.VERBOSITY & level) {
35+
var level = this.console[i] = e[i];
36+
var nativeMeth = api.nativeConsole[i.toLowerCase()];
37+
api.nativeConsole[i.toLowerCase()] = (function() {
38+
if (this.console.VERBOSITY & level) {
4039
// var args = Array.prototype.slice(arguments);
4140
// args.push(Date.now());
4241
// console.timeEnd('start');
4342
// console.timeEnd('previous');
4443
// console.time('previous');
4544
// Might very well crash IE bitch
4645
try {
47-
meth.apply(c, arguments);
46+
nativeMeth.apply(api.nativeConsole, arguments);
4847
}catch (e) {
4948
Array.prototype.slice(arguments).forEach(function(arg) {
50-
meth.apply(c, [arg]);
49+
nativeMeth.apply(api.nativeConsole, [arg]);
5150
});
5251
}
5352
}
54-
};
55-
});
53+
}.bind(this));
54+
}, this);
5655

57-
}).apply(this);
56+
});

src/jsboot/debug/css.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,10 @@
1010
* @name {PUKE-GIT-ROOT}/jsboot/debug/css.js{PUKE-GIT-REVISION}
1111
*/
1212

13-
(function() {
13+
jsBoot.pack('jsBoot.debug', function() {
1414
/*jshint browser:true*/
1515
'use strict';
1616

17-
var scope = jsBoot.debug;
18-
1917
var cssReload = function() {
2018
Array.prototype.forEach.call(document.getElementsByTagName('link'), function(item) {
2119
if (item.rel && item.rel.match(/style/)) {
@@ -38,14 +36,14 @@
3836
};
3937

4038
var cssPollerTout;
41-
scope.cssPoller = new (function() {
39+
this.cssPoller = new (function() {
4240
this.start = function() {
4341
cssReload();
44-
cssPollerTout = window.setTimeout(this.start, 1000);
42+
cssPollerTout = setTimeout(this.start, 1000);
4543
};
4644

4745
this.stop = function() {
48-
window.clearTimeout(cssPollerTout);
46+
clearTimeout(cssPollerTout);
4947
cssPollerTout = null;
5048
};
5149

@@ -58,5 +56,5 @@
5856
};
5957
})();
6058

61-
})();
59+
});
6260

src/jsboot/debug/errorHandler.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,16 @@
1010
* @name {PUKE-GIT-ROOT}/jsboot/debug/console.js{PUKE-GIT-REVISION}
1111
*/
1212

13-
(function() {
13+
14+
jsBoot.use('jsBoot.core');
15+
jsBoot.pack('jsBoot.debug', function(api) {
1416
/*global console, location*/
1517
'use strict';
1618

17-
var core = jsBoot.core;
1819
// The default error handler is a stupid logger to console
1920
var markee = ' ┌∩┐(◣_◢)┌∩┐ ';
2021

21-
core.registerErrorHandler(function(str, fileName, lineNumber) {
22+
api.core.registerErrorHandler(function(str, fileName, lineNumber) {
2223
console.error(markee, markee, markee);
2324
console.warn('File:', fileName);
2425
console.warn('Number:', lineNumber);
@@ -28,5 +29,4 @@
2829
console.error(markee, markee, markee);
2930
return false;
3031
});
31-
32-
})();
32+
});

src/jsboot/debug/tick.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,12 @@
1010
* @name {PUKE-GIT-ROOT}/jsboot/debug/tick.js{PUKE-GIT-REVISION}
1111
*/
1212

13-
(function() {
13+
jsBoot.pack('jsBoot.debug', function() {
1414
/*global console*/
1515
'use strict';
16-
var scope = jsBoot.debug;
1716

1817
var started = false;
19-
scope.tick = function(message, end) {
18+
this.tick = function(message, end) {
2019
console.info(' [jsBoot.debug.tick]', message);
2120
if (started) {
2221
console.timeEnd('Time since last tick');
@@ -31,6 +30,6 @@
3130
}
3231
};
3332

34-
scope.tick('Debug module fully loaded. Starting time measurement');
33+
this.tick('Debug module fully loaded. Starting time measurement');
3534

36-
})();
35+
});

src/jsboot/gister/amdadapter.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,12 @@
3333
* @return {undefined} Doesn't return anything.
3434
*/
3535

36+
// Adapted from JSON3 (credit Oyvind Sean Kinsey)
37+
// Detect the "define" function exposed by asynchronous module loaders
38+
var isLoader = typeof define === 'function' && define.amd;
39+
var internalObj = typeof exports == 'object' && exports;
40+
3641
this.simpleRequire = (function(deps, factory) {
37-
var isLoader = typeof define === 'function' && define.amd;
38-
var internalObj = typeof exports == 'object' && exports;
3942

4043
// Export for asynchronous module loaders, CommonJS environments, web browsers, and JavaScript engines.
4144
if (isLoader || internalObj) {
@@ -50,6 +53,8 @@
5053
var sc = this;
5154
depName.split('.').map(function(fragment) {
5255
sc = sc[fragment];
56+
if (sc === undefined)
57+
throw new Error('MISSING', 'Trying to require something that doesn\'t exist');
5358
});
5459
return sc;
5560
}, this);
@@ -64,10 +69,6 @@
6469
factory = deps;
6570
deps = [];
6671
}
67-
// Adapted from JSON3 (credit Oyvind Sean Kinsey)
68-
// Detect the "define" function exposed by asynchronous module loaders
69-
var isLoader = typeof define === 'function' && define.amd;
70-
var internalObj = typeof exports == 'object' && exports;
7172

7273
// Export for asynchronous module loaders, CommonJS environments, web browsers, and JavaScript engines.
7374
if (isLoader || internalObj) {
@@ -87,6 +88,7 @@
8788
internalObj = {};
8889
internalObj = factory.apply(internalObj, deps) || internalObj;
8990
for (var i in internalObj) {
91+
// XXX is this anywhere near working naming?
9092
if (internalObj.hasOwnProperty(i))
9193
exports[i] = internalObj[i];
9294
}

0 commit comments

Comments
 (0)