react 0.5.1 → 0.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/.travis.yml +5 -0
  2. package/Jakefile.js +39 -0
  3. package/README.md +17 -24
  4. package/browser-test/dist.html +89 -0
  5. package/browser-test/index.html +85 -0
  6. package/browser-test/min.html +89 -0
  7. package/dist/react.js +3094 -0
  8. package/dist/react.min.js +22 -0
  9. package/doc/advanced.md +2 -2
  10. package/doc/simple.dot +25 -0
  11. package/doc/simple.png +0 -0
  12. package/examples/using-events1.js +1 -1
  13. package/lib/base-task.js +116 -110
  14. package/lib/cb-task.js +71 -67
  15. package/lib/core.js +116 -117
  16. package/lib/dsl.js +120 -115
  17. package/lib/error.js +44 -36
  18. package/lib/event-collector.js +69 -56
  19. package/lib/event-manager.js +69 -56
  20. package/lib/eventemitter.js +20 -0
  21. package/lib/finalcb-first-task.js +56 -53
  22. package/lib/finalcb-task.js +55 -51
  23. package/lib/id.js +18 -7
  24. package/lib/input-parser.js +49 -41
  25. package/lib/log-events.js +79 -73
  26. package/lib/parse.js +34 -25
  27. package/lib/promise-resolve.js +42 -27
  28. package/lib/promise-task.js +78 -74
  29. package/lib/react.js +59 -0
  30. package/lib/ret-task.js +59 -55
  31. package/lib/sprintf.js +18 -0
  32. package/lib/status.js +11 -2
  33. package/lib/task.js +215 -217
  34. package/lib/track-tasks.js +72 -58
  35. package/lib/validate.js +136 -136
  36. package/lib/vcon.js +78 -69
  37. package/lib/when-task.js +69 -65
  38. package/package.json +10 -9
  39. package/src/dist.build.requirejs +20 -0
  40. package/test/ast.mocha.js +136 -0
  41. package/test/cb-task.mocha.js +220 -0
  42. package/test/core-deferred.mocha.js +143 -0
  43. package/test/core-when.mocha.js +96 -0
  44. package/test/core.mocha.js +589 -0
  45. package/test/dsl.mocha.js +350 -0
  46. package/test/event-manager.mocha.js +119 -0
  47. package/test/exec-options.mocha.js +48 -0
  48. package/test/finalcb-task.mocha.js +58 -0
  49. package/test/input-parser.mocha.js +86 -0
  50. package/test/mocha.opts +2 -0
  51. package/test/module-use.mocha.js +147 -0
  52. package/test/promise-auto-resolve.mocha.js +68 -0
  53. package/test/ret-task.mocha.js +220 -0
  54. package/test/task.mocha.js +42 -0
  55. package/test/validate-cb-task.mocha.js +100 -0
  56. package/test/validate-ret-task.mocha.js +110 -0
  57. package/test/validate.mocha.js +324 -0
  58. package/test/vcon.mocha.js +193 -0
  59. package/vendor/chai/chai.js +2038 -0
  60. package/vendor/jquery/jquery-1.7.1.js +9266 -0
  61. package/vendor/jquery/jquery-1.7.1.min.js +4 -0
  62. package/vendor/mocha/mocha.css +135 -0
  63. package/vendor/mocha/mocha.js +3589 -0
  64. package/vendor/node/util.js +531 -0
  65. package/vendor/requirejs/require.js +2053 -0
  66. package/vendor/requirejs/require.min.js +33 -0
  67. package/doc/default-simple.dot +0 -19
  68. package/doc/default-simple.dot.png +0 -0
  69. package/react.js +0 -40
  70. package/test/ast.test.js +0 -95
  71. package/test/cb-task.test.js +0 -197
  72. package/test/core-deferred.test.js +0 -134
  73. package/test/core-promised.test.js +0 -132
  74. package/test/core-when.test.js +0 -84
  75. package/test/core.test.js +0 -593
  76. package/test/dsl.test.js +0 -330
  77. package/test/event-manager.test.js +0 -102
  78. package/test/exec-options.test.js +0 -33
  79. package/test/finalcb-task.test.js +0 -38
  80. package/test/input-parser.test.js +0 -66
  81. package/test/module-use.test.js +0 -134
  82. package/test/promise-auto-resolve.test.js +0 -52
  83. package/test/ret-task.test.js +0 -199
  84. package/test/task.test.js +0 -21
  85. package/test/validate-cb-task.test.js +0 -74
  86. package/test/validate-ret-task.test.js +0 -83
  87. package/test/validate.test.js +0 -295
  88. package/test/vcon.test.js +0 -173
@@ -0,0 +1,531 @@
1
+ /*global define:true */
2
+
3
+ if (typeof define !== 'function') {
4
+ var define = require('amdefine')(module);
5
+ }
6
+
7
+ // Copyright Joyent, Inc. and other Node contributors.
8
+ //
9
+ // Permission is hereby granted, free of charge, to any person obtaining a
10
+ // copy of this software and associated documentation files (the
11
+ // "Software"), to deal in the Software without restriction, including
12
+ // without limitation the rights to use, copy, modify, merge, publish,
13
+ // distribute, sublicense, and/or sell copies of the Software, and to permit
14
+ // persons to whom the Software is furnished to do so, subject to the
15
+ // following conditions:
16
+ //
17
+ // The above copyright notice and this permission notice shall be included
18
+ // in all copies or substantial portions of the Software.
19
+ //
20
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21
+ // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22
+ // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
23
+ // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
24
+ // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
25
+ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
26
+ // USE OR OTHER DEALINGS IN THE SOFTWARE.
27
+
28
+ define(function (require, exports, module) {
29
+ /*jshint white:false */
30
+
31
+ var formatRegExp = /%[sdj%]/g;
32
+ exports.format = function(f) {
33
+ if (typeof f !== 'string') {
34
+ var objects = [];
35
+ for (var j = 0; j < arguments.length; j++) {
36
+ objects.push(inspect(arguments[j]));
37
+ }
38
+ return objects.join(' ');
39
+ }
40
+
41
+ var i = 1;
42
+ var args = arguments;
43
+ var len = args.length;
44
+ var str = String(f).replace(formatRegExp, function(x) {
45
+ if (x === '%%') return '%';
46
+ if (i >= len) return x;
47
+ switch (x) {
48
+ case '%s': return String(args[i++]);
49
+ case '%d': return Number(args[i++]);
50
+ case '%j': return JSON.stringify(args[i++]);
51
+ default:
52
+ return x;
53
+ }
54
+ });
55
+ for (var x = args[i]; i < len; x = args[++i]) {
56
+ if (x === null || typeof x !== 'object') {
57
+ str += ' ' + x;
58
+ } else {
59
+ str += ' ' + inspect(x);
60
+ }
61
+ }
62
+ return str;
63
+ };
64
+
65
+
66
+ exports.print = function() {
67
+ for (var i = 0, len = arguments.length; i < len; ++i) {
68
+ process.stdout.write(String(arguments[i]));
69
+ }
70
+ };
71
+
72
+
73
+ exports.puts = function() {
74
+ for (var i = 0, len = arguments.length; i < len; ++i) {
75
+ process.stdout.write(arguments[i] + '\n');
76
+ }
77
+ };
78
+
79
+
80
+ exports.debug = function(x) {
81
+ process.stderr.write('DEBUG: ' + x + '\n');
82
+ };
83
+
84
+
85
+ var error = exports.error = function(x) {
86
+ for (var i = 0, len = arguments.length; i < len; ++i) {
87
+ process.stderr.write(arguments[i] + '\n');
88
+ }
89
+ };
90
+
91
+
92
+ /**
93
+ * Echos the value of a value. Trys to print the value out
94
+ * in the best way possible given the different types.
95
+ *
96
+ * @param {Object} obj The object to print out.
97
+ * @param {Boolean} showHidden Flag that shows hidden (not enumerable)
98
+ * properties of objects.
99
+ * @param {Number} depth Depth in which to descend in object. Default is 2.
100
+ * @param {Boolean} colors Flag to turn on ANSI escape codes to color the
101
+ * output. Default is false (no coloring).
102
+ */
103
+ function inspect(obj, showHidden, depth, colors) {
104
+ var ctx = {
105
+ showHidden: showHidden,
106
+ seen: [],
107
+ stylize: colors ? stylizeWithColor : stylizeNoColor
108
+ };
109
+ return formatValue(ctx, obj, (typeof depth === 'undefined' ? 2 : depth));
110
+ }
111
+ exports.inspect = inspect;
112
+
113
+
114
+ // http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
115
+ var colors = {
116
+ 'bold' : [1, 22],
117
+ 'italic' : [3, 23],
118
+ 'underline' : [4, 24],
119
+ 'inverse' : [7, 27],
120
+ 'white' : [37, 39],
121
+ 'grey' : [90, 39],
122
+ 'black' : [30, 39],
123
+ 'blue' : [34, 39],
124
+ 'cyan' : [36, 39],
125
+ 'green' : [32, 39],
126
+ 'magenta' : [35, 39],
127
+ 'red' : [31, 39],
128
+ 'yellow' : [33, 39]
129
+ };
130
+
131
+ // Don't use 'blue' not visible on cmd.exe
132
+ var styles = {
133
+ 'special': 'cyan',
134
+ 'number': 'yellow',
135
+ 'boolean': 'yellow',
136
+ 'undefined': 'grey',
137
+ 'null': 'bold',
138
+ 'string': 'green',
139
+ 'date': 'magenta',
140
+ // "name": intentionally not styling
141
+ 'regexp': 'red'
142
+ };
143
+
144
+
145
+ function stylizeWithColor(str, styleType) {
146
+ var style = styles[styleType];
147
+
148
+ if (style) {
149
+ return '\033[' + colors[style][0] + 'm' + str +
150
+ '\033[' + colors[style][1] + 'm';
151
+ } else {
152
+ return str;
153
+ }
154
+ }
155
+
156
+
157
+ function stylizeNoColor(str, styleType) {
158
+ return str;
159
+ }
160
+
161
+
162
+ function formatValue(ctx, value, recurseTimes) {
163
+ // Provide a hook for user-specified inspect functions.
164
+ // Check that value is an object with an inspect function on it
165
+ if (value && typeof value.inspect === 'function' &&
166
+ // Filter out the util module, it's inspect function is special
167
+ value.inspect !== exports.inspect &&
168
+ // Also filter out any prototype objects using the circular check.
169
+ !(value.constructor && value.constructor.prototype === value)) {
170
+ return value.inspect(recurseTimes);
171
+ }
172
+
173
+ // Primitive types cannot have properties
174
+ var primitive = formatPrimitive(ctx, value);
175
+ if (primitive) {
176
+ return primitive;
177
+ }
178
+
179
+ // Look up the keys of the object.
180
+ var visibleKeys = Object.keys(value);
181
+ var keys = ctx.showHidden ? Object.getOwnPropertyNames(value) : visibleKeys;
182
+
183
+ // Some type of object without properties can be shortcutted.
184
+ if (keys.length === 0) {
185
+ if (typeof value === 'function') {
186
+ var name = value.name ? ': ' + value.name : '';
187
+ return ctx.stylize('[Function' + name + ']', 'special');
188
+ }
189
+ if (isRegExp(value)) {
190
+ return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
191
+ }
192
+ if (isDate(value)) {
193
+ return ctx.stylize(Date.prototype.toString.call(value), 'date');
194
+ }
195
+ if (isError(value)) {
196
+ return formatError(value);
197
+ }
198
+ }
199
+
200
+ var base = '', array = false, braces = ['{', '}'];
201
+
202
+ // Make Array say that they are Array
203
+ if (isArray(value)) {
204
+ array = true;
205
+ braces = ['[', ']'];
206
+ }
207
+
208
+ // Make functions say that they are functions
209
+ if (typeof value === 'function') {
210
+ var n = value.name ? ': ' + value.name : '';
211
+ base = ' [Function' + n + ']';
212
+ }
213
+
214
+ // Make RegExps say that they are RegExps
215
+ if (isRegExp(value)) {
216
+ base = ' ' + RegExp.prototype.toString.call(value);
217
+ }
218
+
219
+ // Make dates with properties first say the date
220
+ if (isDate(value)) {
221
+ base = ' ' + Date.prototype.toUTCString.call(value);
222
+ }
223
+
224
+ // Make error with message first say the error
225
+ if (isError(value)) {
226
+ base = ' ' + formatError(value);
227
+ }
228
+
229
+ if (keys.length === 0 && (!array || value.length === 0)) {
230
+ return braces[0] + base + braces[1];
231
+ }
232
+
233
+ if (recurseTimes < 0) {
234
+ if (isRegExp(value)) {
235
+ return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
236
+ } else {
237
+ return ctx.stylize('[Object]', 'special');
238
+ }
239
+ }
240
+
241
+ ctx.seen.push(value);
242
+
243
+ var output;
244
+ if (array) {
245
+ output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
246
+ } else {
247
+ output = keys.map(function(key) {
248
+ return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
249
+ });
250
+ }
251
+
252
+ ctx.seen.pop();
253
+
254
+ return reduceToSingleString(output, base, braces);
255
+ }
256
+
257
+
258
+ function formatPrimitive(ctx, value) {
259
+ switch (typeof value) {
260
+ case 'undefined':
261
+ return ctx.stylize('undefined', 'undefined');
262
+
263
+ case 'string':
264
+ var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
265
+ .replace(/'/g, "\\'")
266
+ .replace(/\\"/g, '"') + '\'';
267
+ return ctx.stylize(simple, 'string');
268
+
269
+ case 'number':
270
+ return ctx.stylize('' + value, 'number');
271
+
272
+ case 'boolean':
273
+ return ctx.stylize('' + value, 'boolean');
274
+ }
275
+ // For some reason typeof null is "object", so special case here.
276
+ if (value === null) {
277
+ return ctx.stylize('null', 'null');
278
+ }
279
+ }
280
+
281
+
282
+ function formatError(value) {
283
+ return '[' + Error.prototype.toString.call(value) + ']';
284
+ }
285
+
286
+
287
+ function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
288
+ var output = [];
289
+ for (var i = 0, l = value.length; i < l; ++i) {
290
+ if (Object.prototype.hasOwnProperty.call(value, String(i))) {
291
+ output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
292
+ String(i), true));
293
+ } else {
294
+ output.push('');
295
+ }
296
+ }
297
+ keys.forEach(function(key) {
298
+ if (!key.match(/^\d+$/)) {
299
+ output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
300
+ key, true));
301
+ }
302
+ });
303
+ return output;
304
+ }
305
+
306
+
307
+ function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
308
+ var name, str, desc;
309
+ desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };
310
+ if (desc.get) {
311
+ if (desc.set) {
312
+ str = ctx.stylize('[Getter/Setter]', 'special');
313
+ } else {
314
+ str = ctx.stylize('[Getter]', 'special');
315
+ }
316
+ } else {
317
+ if (desc.set) {
318
+ str = ctx.stylize('[Setter]', 'special');
319
+ }
320
+ }
321
+ if (visibleKeys.indexOf(key) < 0) {
322
+ name = '[' + key + ']';
323
+ }
324
+ if (!str) {
325
+ if (ctx.seen.indexOf(desc.value) < 0) {
326
+ if (recurseTimes === null) {
327
+ str = formatValue(ctx, desc.value, null);
328
+ } else {
329
+ str = formatValue(ctx, desc.value, recurseTimes - 1);
330
+ }
331
+ if (str.indexOf('\n') > -1) {
332
+ if (array) {
333
+ str = str.split('\n').map(function(line) {
334
+ return ' ' + line;
335
+ }).join('\n').substr(2);
336
+ } else {
337
+ str = '\n' + str.split('\n').map(function(line) {
338
+ return ' ' + line;
339
+ }).join('\n');
340
+ }
341
+ }
342
+ } else {
343
+ str = ctx.stylize('[Circular]', 'special');
344
+ }
345
+ }
346
+ if (typeof name === 'undefined') {
347
+ if (array && key.match(/^\d+$/)) {
348
+ return str;
349
+ }
350
+ name = JSON.stringify('' + key);
351
+ if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
352
+ name = name.substr(1, name.length - 2);
353
+ name = ctx.stylize(name, 'name');
354
+ } else {
355
+ name = name.replace(/'/g, "\\'")
356
+ .replace(/\\"/g, '"')
357
+ .replace(/(^"|"$)/g, "'");
358
+ name = ctx.stylize(name, 'string');
359
+ }
360
+ }
361
+
362
+ return name + ': ' + str;
363
+ }
364
+
365
+
366
+ function reduceToSingleString(output, base, braces) {
367
+ var numLinesEst = 0;
368
+ var length = output.reduce(function(prev, cur) {
369
+ numLinesEst++;
370
+ if (cur.indexOf('\n') >= 0) numLinesEst++;
371
+ return prev + cur.length + 1;
372
+ }, 0);
373
+
374
+ if (length > 60) {
375
+ return braces[0] +
376
+ (base === '' ? '' : base + '\n ') +
377
+ ' ' +
378
+ output.join(',\n ') +
379
+ ' ' +
380
+ braces[1];
381
+ }
382
+
383
+ return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
384
+ }
385
+
386
+
387
+ // NOTE: These type checking functions intentionally don't use `instanceof`
388
+ // because it is fragile and can be easily faked with `Object.create()`.
389
+ function isArray(ar) {
390
+ return Array.isArray(ar) ||
391
+ (typeof ar === 'object' && objectToString(ar) === '[object Array]');
392
+ }
393
+ exports.isArray = isArray;
394
+
395
+
396
+ function isRegExp(re) {
397
+ return typeof re === 'object' && objectToString(re) === '[object RegExp]';
398
+ }
399
+ exports.isRegExp = isRegExp;
400
+
401
+
402
+ function isDate(d) {
403
+ return typeof d === 'object' && objectToString(d) === '[object Date]';
404
+ }
405
+ exports.isDate = isDate;
406
+
407
+
408
+ function isError(e) {
409
+ return typeof e === 'object' && objectToString(e) === '[object Error]';
410
+ }
411
+ exports.isError = isError;
412
+
413
+
414
+ function objectToString(o) {
415
+ return Object.prototype.toString.call(o);
416
+ }
417
+
418
+
419
+ // exports.p = function() {
420
+ // for (var i = 0, len = arguments.length; i < len; ++i) {
421
+ // error(exports.inspect(arguments[i]));
422
+ // }
423
+ // };
424
+ // module.deprecate('p', 'Use `util.puts(util.inspect())` instead.');
425
+
426
+
427
+ function pad(n) {
428
+ return n < 10 ? '0' + n.toString(10) : n.toString(10);
429
+ }
430
+
431
+
432
+ var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
433
+ 'Oct', 'Nov', 'Dec'];
434
+
435
+ // 26 Feb 16:19:34
436
+ function timestamp() {
437
+ var d = new Date();
438
+ var time = [pad(d.getHours()),
439
+ pad(d.getMinutes()),
440
+ pad(d.getSeconds())].join(':');
441
+ return [d.getDate(), months[d.getMonth()], time].join(' ');
442
+ }
443
+
444
+
445
+ exports.log = function(msg) {
446
+ exports.puts(timestamp() + ' - ' + msg.toString());
447
+ };
448
+
449
+
450
+ // exports.exec = function() {
451
+ // return require('child_process').exec.apply(this, arguments);
452
+ // };
453
+ // module.deprecate('exec', 'It is now called `child_process.exec`.');
454
+
455
+
456
+ exports.pump = function(readStream, writeStream, callback) {
457
+ var callbackCalled = false;
458
+
459
+ function call(a, b, c) {
460
+ if (callback && !callbackCalled) {
461
+ callback(a, b, c);
462
+ callbackCalled = true;
463
+ }
464
+ }
465
+
466
+ readStream.addListener('data', function(chunk) {
467
+ if (writeStream.write(chunk) === false) readStream.pause();
468
+ });
469
+
470
+ writeStream.addListener('drain', function() {
471
+ readStream.resume();
472
+ });
473
+
474
+ readStream.addListener('end', function() {
475
+ writeStream.end();
476
+ });
477
+
478
+ readStream.addListener('close', function() {
479
+ call();
480
+ });
481
+
482
+ readStream.addListener('error', function(err) {
483
+ writeStream.end();
484
+ call(err);
485
+ });
486
+
487
+ writeStream.addListener('error', function(err) {
488
+ readStream.destroy();
489
+ call(err);
490
+ });
491
+ };
492
+
493
+
494
+ /**
495
+ * Inherit the prototype methods from one constructor into another.
496
+ *
497
+ * The Function.prototype.inherits from lang.js rewritten as a standalone
498
+ * function (not on Function.prototype). NOTE: If this file is to be loaded
499
+ * during bootstrapping this function needs to be rewritten using some native
500
+ * functions as prototype setup using normal JavaScript does not work as
501
+ * expected during bootstrapping (see mirror.js in r114903).
502
+ *
503
+ * @param {function} ctor Constructor function which needs to inherit the
504
+ * prototype.
505
+ * @param {function} superCtor Constructor function to inherit prototype from.
506
+ */
507
+ exports.inherits = function(ctor, superCtor) {
508
+ ctor.super_ = superCtor;
509
+ ctor.prototype = Object.create(superCtor.prototype, {
510
+ constructor: {
511
+ value: ctor,
512
+ enumerable: false,
513
+ writable: true,
514
+ configurable: true
515
+ }
516
+ });
517
+ };
518
+
519
+ exports._extend = function(origin, add) {
520
+ // Don't do anything if add isn't an object
521
+ if (!add) return origin;
522
+
523
+ var keys = Object.keys(add);
524
+ var i = keys.length;
525
+ while (i--) {
526
+ origin[keys[i]] = add[keys[i]];
527
+ }
528
+ return origin;
529
+ };
530
+
531
+ });