react 0.6.0 → 0.7.0
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.
- package/.travis.yml +5 -2
- package/README.md +16 -2
- package/browser-test/dist.html +1 -1
- package/browser-test/index.html +3 -3
- package/browser-test/min.html +1 -1
- package/dist/react.js +407 -557
- package/dist/react.min.js +22 -1
- package/doc/advanced.md +9 -1
- package/lib/base-task.js +16 -19
- package/lib/cb-task.js +5 -5
- package/lib/core.js +7 -7
- package/lib/dsl.js +29 -29
- package/lib/error.js +4 -4
- package/lib/event-collector.js +6 -6
- package/lib/event-manager.js +13 -6
- package/lib/eventemitter.js +3 -3
- package/lib/finalcb-first-task.js +4 -4
- package/lib/finalcb-task.js +4 -4
- package/lib/id.js +3 -3
- package/lib/input-parser.js +10 -10
- package/lib/log-events.js +23 -14
- package/lib/parse.js +3 -3
- package/lib/promise-resolve.js +4 -4
- package/lib/promise-task.js +4 -4
- package/lib/react.js +7 -7
- package/lib/ret-task.js +4 -4
- package/lib/sprintf.js +8 -8
- package/lib/status.js +3 -3
- package/lib/task.js +44 -47
- package/lib/track-tasks.js +4 -4
- package/lib/validate.js +8 -8
- package/lib/vcon.js +31 -8
- package/lib/when-task.js +7 -8
- package/package.json +7 -8
- package/test/ast.mocha.js +4 -4
- package/test/cb-task.mocha.js +17 -17
- package/test/core-deferred.mocha.js +8 -8
- package/test/core-when.mocha.js +7 -7
- package/test/core.mocha.js +52 -52
- package/test/dsl.mocha.js +45 -43
- package/test/event-manager.mocha.js +2 -2
- package/test/exec-options.mocha.js +4 -4
- package/test/finalcb-task.mocha.js +6 -6
- package/test/input-parser.mocha.js +1 -1
- package/test/log-events.mocha.js +88 -0
- package/test/module-use.mocha.js +24 -7
- package/test/promise-auto-resolve.mocha.js +4 -4
- package/test/ret-task.mocha.js +18 -18
- package/test/task.mocha.js +3 -3
- package/test/validate-cb-task.mocha.js +11 -11
- package/test/validate-ret-task.mocha.js +14 -14
- package/test/validate.mocha.js +57 -57
- package/test/vcon.mocha.js +13 -13
- package/vendor/chai/chai.js +3371 -1158
- package/vendor/requirejs/require.js +1447 -1455
- package/vendor/requirejs/require.min.js +31 -28
- package/vendor/mocha/mocha.css +0 -135
- package/vendor/mocha/mocha.js +0 -3589
package/.travis.yml
CHANGED
package/README.md
CHANGED
|
@@ -16,9 +16,15 @@ Also "Reactive Programming" or "Dataflow" describe defining flow which reacts to
|
|
|
16
16
|
|
|
17
17
|
It takes inspiration from several projects including:
|
|
18
18
|
|
|
19
|
-
- Tim Caswell and Elijah Insua's [conductor](https://github.com/
|
|
19
|
+
- Tim Caswell and Elijah Insua's [conductor](https://github.com/tmpvar/conductor) - [Article](http://howtonode.org/step-of-conductor)
|
|
20
20
|
- Caolan McMahon's [async](https://github.com/caolan/async)
|
|
21
21
|
|
|
22
|
+
## Example Video and Comparison
|
|
23
|
+
|
|
24
|
+
Ryan Atkinson did a nice job of demonstrating some of the power of react as compared to async and native callback code. http://www.youtube.com/embed/5EDucc56UnA?rel=0
|
|
25
|
+
|
|
26
|
+
You can read more and see his example site here https://github.com/ryanatkn/react-writeup
|
|
27
|
+
|
|
22
28
|
|
|
23
29
|
## Goals
|
|
24
30
|
|
|
@@ -39,8 +45,10 @@ It takes inspiration from several projects including:
|
|
|
39
45
|
- selectFirst flow where the first task that returns defined, non-null value is used
|
|
40
46
|
- promise style functions - also automatic resolution of promise inputs (optionally loaded with `react.resolvePromises();`)
|
|
41
47
|
- use of resulting flow function as callback style or promise style (if no callback provided) (provided via plugin corresponding to the promise library used) See https://github.com/jeffbski/react-deferred
|
|
48
|
+
- supports ES5 browsers (can work with others by using polyfills)
|
|
42
49
|
- (planned) iteration on arrays, streams, sockets
|
|
43
50
|
- (planned) event emitter integration
|
|
51
|
+
- tested on node 0.8, 0.10, 0.11
|
|
44
52
|
|
|
45
53
|
The tasks can be mixed, meaning you can use async, sync, object method calls, class method calls, etc in the same flow.
|
|
46
54
|
|
|
@@ -156,7 +164,7 @@ var fn = react('loadRender', 'fooPath, barPath, barP2, cb -> err, renderedOut',
|
|
|
156
164
|
|
|
157
165
|
1. **flow/function name** - string - represents the name of the flow or function that will be created. React will use the name when generating events so you can monitor progress and performance and also when errors occur.
|
|
158
166
|
2. **in/out flow parameter definition** - string - the inputs and outputs for the flow function. The parameters are specified in one single string for easy typing, separated by commas. The output follows the input after being separated by a `->`. Use the parameter name `cb` or `callback` to specify the Node style callback and `err` to represent the error parameter as the first output parameter of the callback. Literal values can also be specified directly (true, false, numbers, this, null). Literal strings can simply be quoted using single or double quotes.
|
|
159
|
-
3. **optional flow options** - object - If an object is provided immediately after the in/out flow def, then these options will be provided to react to customize the flow.
|
|
167
|
+
3. **optional flow options** - object - If an object is provided immediately after the in/out flow def, then these options will be provided to react to customize the flow. The `locals` property can contain an object map of any local variables you want to reference in the flow (other than what is passed in as parameters). For example: `{ locals: { foo: foo, bar: bar }}` would make local vars available in the flow. Note that global variables are already available in the flow.
|
|
160
168
|
4. **function reference or method string** - Specify the function to be called for this task, or if calling a method off of an object being passed in or returned by a task, use a string to specify like `'obj.method'`. These can be asynchronous Node-style callback `cb(err, ...)` functions or synchronous functions which simply return values directly.
|
|
161
169
|
5. **in/out task parameter definition** - string - similar to the in/out flow parameter definition above, these are the inputs and outputs that are passed to a task function and returned from a task function. The inputs will need to match either those from the flow inputs or outputs from other tasks that will run before this task. React will use the inputs as dependencies, so it will invoke and wait for response from the tasks that provide the dependent inputs. So simply by specifying inputs and outputs for the tasks, React will prioritize and parallelize tasks to run as fast as possible. Use `cb` or `callback` along with `err` to specify asynchronous Node style `cb(err, ...)` task, or omit both to specify a synchronous task.A synchronous task can only have a single return parameter.
|
|
162
170
|
6. **optional task options** - object - if an object is provided this can be used to specify additional options for this task. Currently the valid options for a task are:
|
|
@@ -186,6 +194,12 @@ See the [Advanced React](https://github.com/jeffbski/react/blob/master/doc/advan
|
|
|
186
194
|
|
|
187
195
|
## Status
|
|
188
196
|
|
|
197
|
+
- 2013-05-23 - Allow use of globals without needing to specify in locals, move 'use strict' into define, upgrade amdefine@0.0.5, eventemitter@0.4.11, requirejs@2.1.6, mocha@1.10.0, chai@1.6.0, jake@0.5.15 (v0.7.0)
|
|
198
|
+
- 2013-04-12 - Update to test on node 0.8, 0.10, 0.11
|
|
199
|
+
- 2012-10-17 - Fix issue with logEvents and provide way to disable logEvents(false) (v0.6.3)
|
|
200
|
+
- 2012-09-12 - Upgrade RequireJS@2.0.6, mocha@1.4.2, chai@1.2.0, jake@0.3.16. Update travis config to include Node 0.8 (v0.6.2)
|
|
201
|
+
- 2012-04-25 - Browser compatibility issue with process check, (v0.6.1)
|
|
202
|
+
- 2012-04-05 - Remove dependency on sprint, use util.format
|
|
189
203
|
- 2012-03-28 - Make react AMD-enabled and compatible with ES5 browsers and node.js, provide single file dist and min, add browser tests (v0.6.0)
|
|
190
204
|
- 2012-03-24 - Add Travis-CI, remove promised-io since failing to install in travis-ci for node 0.6/0.7, switch from tap to mocha/chai
|
|
191
205
|
- 2012-03-12 - Pass ast.define events to process (v0.5.2)
|
package/browser-test/dist.html
CHANGED
|
@@ -22,7 +22,6 @@
|
|
|
22
22
|
jQuery: "vendor/jquery/jquery-1.7.1",
|
|
23
23
|
eventemitter2: "dist/react",
|
|
24
24
|
util: "dist/react",
|
|
25
|
-
sprint: "dist/react",
|
|
26
25
|
"ensure-array": "dist/react",
|
|
27
26
|
test: "test"
|
|
28
27
|
}
|
|
@@ -63,6 +62,7 @@
|
|
|
63
62
|
"test/exec-options.mocha",
|
|
64
63
|
"test/finalcb-task.mocha",
|
|
65
64
|
"test/input-parser.mocha",
|
|
65
|
+
"test/log-events.mocha",
|
|
66
66
|
"test/module-use.mocha",
|
|
67
67
|
"test/promise-auto-resolve.mocha",
|
|
68
68
|
"test/ret-task.mocha",
|
package/browser-test/index.html
CHANGED
|
@@ -19,10 +19,9 @@
|
|
|
19
19
|
}
|
|
20
20
|
],
|
|
21
21
|
paths: {
|
|
22
|
-
|
|
22
|
+
jquery: "vendor/jquery/jquery-1.7.1",
|
|
23
23
|
eventemitter2: "node_modules/eventemitter2/lib/eventemitter2",
|
|
24
24
|
util: "vendor/node/util",
|
|
25
|
-
sprint: "node_modules/sprint/lib/sprint",
|
|
26
25
|
"ensure-array": "node_modules/ensure-array/ensure-array",
|
|
27
26
|
test: "test"
|
|
28
27
|
}
|
|
@@ -30,7 +29,7 @@
|
|
|
30
29
|
|
|
31
30
|
require(["react", "react/sprintf", "util", "react/validate", "react/task",
|
|
32
31
|
"react/cb-task", "react/vcon", "react/event-manager", "react/input-parser",
|
|
33
|
-
"react/base-task", "react/ret-task", "react/validate", "
|
|
32
|
+
"react/base-task", "react/ret-task", "react/validate", "jquery"],
|
|
34
33
|
function (react, sprintf, util, validate, taskUtil,
|
|
35
34
|
CbTask, VContext, EventManager, inputParser,
|
|
36
35
|
BaseTask, RetTask, validate, jquery) {
|
|
@@ -60,6 +59,7 @@
|
|
|
60
59
|
"test/exec-options.mocha",
|
|
61
60
|
"test/finalcb-task.mocha",
|
|
62
61
|
"test/input-parser.mocha",
|
|
62
|
+
"test/log-events.mocha",
|
|
63
63
|
"test/module-use.mocha",
|
|
64
64
|
"test/promise-auto-resolve.mocha",
|
|
65
65
|
"test/ret-task.mocha",
|
package/browser-test/min.html
CHANGED
|
@@ -22,7 +22,6 @@
|
|
|
22
22
|
jQuery: "vendor/jquery/jquery-1.7.1.min",
|
|
23
23
|
eventemitter2: "dist/react.min",
|
|
24
24
|
util: "dist/react.min",
|
|
25
|
-
sprint: "dist/react.min",
|
|
26
25
|
"ensure-array": "dist/react.min",
|
|
27
26
|
test: "test"
|
|
28
27
|
}
|
|
@@ -63,6 +62,7 @@
|
|
|
63
62
|
"test/exec-options.mocha",
|
|
64
63
|
"test/finalcb-task.mocha",
|
|
65
64
|
"test/input-parser.mocha",
|
|
65
|
+
"test/log-events.mocha",
|
|
66
66
|
"test/module-use.mocha",
|
|
67
67
|
"test/promise-auto-resolve.mocha",
|
|
68
68
|
"test/ret-task.mocha",
|
package/dist/react.js
CHANGED
|
@@ -7,21 +7,31 @@
|
|
|
7
7
|
var defaultMaxListeners = 10;
|
|
8
8
|
|
|
9
9
|
function init() {
|
|
10
|
-
this._events =
|
|
10
|
+
this._events = {};
|
|
11
|
+
if (this._conf) {
|
|
12
|
+
configure.call(this, this._conf);
|
|
13
|
+
}
|
|
11
14
|
}
|
|
12
15
|
|
|
13
16
|
function configure(conf) {
|
|
14
17
|
if (conf) {
|
|
18
|
+
|
|
19
|
+
this._conf = conf;
|
|
20
|
+
|
|
15
21
|
conf.delimiter && (this.delimiter = conf.delimiter);
|
|
22
|
+
conf.maxListeners && (this._events.maxListeners = conf.maxListeners);
|
|
16
23
|
conf.wildcard && (this.wildcard = conf.wildcard);
|
|
24
|
+
conf.newListener && (this.newListener = conf.newListener);
|
|
25
|
+
|
|
17
26
|
if (this.wildcard) {
|
|
18
|
-
this.listenerTree =
|
|
27
|
+
this.listenerTree = {};
|
|
19
28
|
}
|
|
20
29
|
}
|
|
21
30
|
}
|
|
22
31
|
|
|
23
32
|
function EventEmitter(conf) {
|
|
24
|
-
this._events =
|
|
33
|
+
this._events = {};
|
|
34
|
+
this.newListener = false;
|
|
25
35
|
configure.call(this, conf);
|
|
26
36
|
}
|
|
27
37
|
|
|
@@ -155,7 +165,7 @@
|
|
|
155
165
|
while (name) {
|
|
156
166
|
|
|
157
167
|
if (!tree[name]) {
|
|
158
|
-
tree[name] =
|
|
168
|
+
tree[name] = {};
|
|
159
169
|
}
|
|
160
170
|
|
|
161
171
|
tree = tree[name];
|
|
@@ -210,6 +220,8 @@
|
|
|
210
220
|
EventEmitter.prototype.setMaxListeners = function(n) {
|
|
211
221
|
this._events || init.call(this);
|
|
212
222
|
this._events.maxListeners = n;
|
|
223
|
+
if (!this._conf) this._conf = {};
|
|
224
|
+
this._conf.maxListeners = n;
|
|
213
225
|
};
|
|
214
226
|
|
|
215
227
|
EventEmitter.prototype.event = '';
|
|
@@ -241,11 +253,12 @@
|
|
|
241
253
|
};
|
|
242
254
|
|
|
243
255
|
EventEmitter.prototype.emit = function() {
|
|
256
|
+
|
|
244
257
|
this._events || init.call(this);
|
|
245
258
|
|
|
246
259
|
var type = arguments[0];
|
|
247
260
|
|
|
248
|
-
if (type === 'newListener') {
|
|
261
|
+
if (type === 'newListener' && !this.newListener) {
|
|
249
262
|
if (!this._events.newListener) { return false; }
|
|
250
263
|
}
|
|
251
264
|
|
|
@@ -547,12 +560,12 @@
|
|
|
547
560
|
|
|
548
561
|
}(typeof process !== 'undefined' && typeof process.title !== 'undefined' && typeof exports !== 'undefined' ? exports : window);
|
|
549
562
|
|
|
550
|
-
|
|
551
563
|
/*global define:true EventEmitter2:true */
|
|
552
564
|
|
|
553
565
|
|
|
554
566
|
|
|
555
567
|
define('react/eventemitter',['eventemitter2'], function (EventEmitterMod) {
|
|
568
|
+
|
|
556
569
|
|
|
557
570
|
/**
|
|
558
571
|
Abstract the details of getting an EventEmitter
|
|
@@ -563,8 +576,8 @@ define('react/eventemitter',['eventemitter2'], function (EventEmitterMod) {
|
|
|
563
576
|
var EventEmitter = (EventEmitterMod) ?
|
|
564
577
|
((EventEmitterMod.EventEmitter2) ? EventEmitterMod.EventEmitter2 : EventEmitterMod) : EventEmitter2;
|
|
565
578
|
return EventEmitter;
|
|
566
|
-
|
|
567
|
-
});
|
|
579
|
+
|
|
580
|
+
});
|
|
568
581
|
/*global define:true */
|
|
569
582
|
|
|
570
583
|
|
|
@@ -1094,12 +1107,12 @@ exports._extend = function(origin, add) {
|
|
|
1094
1107
|
};
|
|
1095
1108
|
|
|
1096
1109
|
});
|
|
1097
|
-
|
|
1098
1110
|
/*global define:true */
|
|
1099
1111
|
|
|
1100
1112
|
|
|
1101
1113
|
|
|
1102
1114
|
define('react/error',['util'], function (util) {
|
|
1115
|
+
|
|
1103
1116
|
|
|
1104
1117
|
function ensureStackTraceLimitSet(stackTraceLimit) {
|
|
1105
1118
|
if (!Error.stackTraceLimit || Error.stackTraceLimit < stackTraceLimit) {
|
|
@@ -1130,7 +1143,7 @@ define('react/error',['util'], function (util) {
|
|
|
1130
1143
|
errString += task.f.toString(); //TODO need to pretty print function, gets collapsed
|
|
1131
1144
|
errString += '\n\n';
|
|
1132
1145
|
}
|
|
1133
|
-
return errString;
|
|
1146
|
+
return errString;
|
|
1134
1147
|
}
|
|
1135
1148
|
|
|
1136
1149
|
function augmentError(err, meta) {
|
|
@@ -1143,10 +1156,26 @@ define('react/error',['util'], function (util) {
|
|
|
1143
1156
|
|
|
1144
1157
|
return {
|
|
1145
1158
|
ensureStackTraceLimitSet: ensureStackTraceLimitSet,
|
|
1146
|
-
augmentError: augmentError
|
|
1159
|
+
augmentError: augmentError
|
|
1147
1160
|
};
|
|
1148
1161
|
|
|
1149
|
-
});
|
|
1162
|
+
});
|
|
1163
|
+
/*global define:true sprint:true */
|
|
1164
|
+
|
|
1165
|
+
|
|
1166
|
+
|
|
1167
|
+
define('react/sprintf',['util'], function (util) {
|
|
1168
|
+
|
|
1169
|
+
|
|
1170
|
+
/**
|
|
1171
|
+
Abstract the details of getting a sprintf function.
|
|
1172
|
+
Currently using the simple format capabilities of node's util.format
|
|
1173
|
+
*/
|
|
1174
|
+
|
|
1175
|
+
var sprintf = util.format;
|
|
1176
|
+
return sprintf;
|
|
1177
|
+
|
|
1178
|
+
});
|
|
1150
1179
|
(function (root, factory) {
|
|
1151
1180
|
/*global define:true */
|
|
1152
1181
|
|
|
@@ -1178,120 +1207,33 @@ define('react/error',['util'], function (util) {
|
|
|
1178
1207
|
}));
|
|
1179
1208
|
|
|
1180
1209
|
|
|
1181
|
-
|
|
1182
1210
|
/*global define:true */
|
|
1183
1211
|
|
|
1184
1212
|
|
|
1185
1213
|
|
|
1186
1214
|
define('react/status',[], function () {
|
|
1187
1215
|
|
|
1216
|
+
|
|
1188
1217
|
var STATUS = { READY: 'ready', RUNNING: 'running', ERRORED: 'errored', COMPLETE: 'complete' };
|
|
1189
1218
|
|
|
1190
1219
|
return STATUS;
|
|
1191
1220
|
|
|
1192
|
-
});
|
|
1193
|
-
|
|
1194
|
-
/*global define:true */
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
define('react/vcon',[], function () {
|
|
1199
|
-
|
|
1200
|
-
var LAST_RESULTS_KEY = ':LAST_RESULTS';
|
|
1201
|
-
|
|
1202
|
-
function VContext() {
|
|
1203
|
-
}
|
|
1204
|
-
|
|
1205
|
-
VContext.prototype.getLastResults = function () { return this.getVar(LAST_RESULTS_KEY); };
|
|
1206
|
-
VContext.prototype.setLastResults = function (args) { this.setVar(LAST_RESULTS_KEY, args); };
|
|
1207
|
-
|
|
1208
|
-
VContext.prototype.getVar = function (name) { //name might be simple or obj.prop, also literals
|
|
1209
|
-
/*jshint regexp: false */
|
|
1210
|
-
var vConValues = this.values;
|
|
1211
|
-
if (typeof(name) !== 'string') return name; // literal boolean or number
|
|
1212
|
-
name = name.trim();
|
|
1213
|
-
// literal checks need to match what is in validate.js
|
|
1214
|
-
if (name === 'true') return true;
|
|
1215
|
-
if (name === 'false') return false;
|
|
1216
|
-
if (name === 'null') return null;
|
|
1217
|
-
if (/^-?[0-9]+$/.test(name)) return parseInt(name, 10); //int
|
|
1218
|
-
if (/^-?[0-9.]+$/.test(name)) return parseFloat(name); //float
|
|
1219
|
-
var m = /^("|')([^\1]*)\1$/.exec(name); //check for quoted string " or '
|
|
1220
|
-
if (m) return m[2]; // if is quoted str, return inside of the quotes
|
|
1221
|
-
var nameAndProps = name.split('.');
|
|
1222
|
-
return nameAndProps.reduce(function (accObj, prop) {
|
|
1223
|
-
if (accObj === undefined || accObj === null) return undefined; // prevent exception
|
|
1224
|
-
return accObj[prop];
|
|
1225
|
-
}, vConValues); // vCon['foo']['bar']
|
|
1226
|
-
};
|
|
1227
|
-
|
|
1228
|
-
/**
|
|
1229
|
-
Saves all the results from a task as a unit, also sets special
|
|
1230
|
-
variable :LAST_RESULTS which keeps an array of the last values
|
|
1231
|
-
which can be used for chaining and testing last results, etc.
|
|
1232
|
-
*/
|
|
1233
|
-
VContext.prototype.saveResults = function (paramArr, valuesArr) { // set values for params
|
|
1234
|
-
var self = this;
|
|
1235
|
-
paramArr.forEach(function (k, idx) { //save values to v context
|
|
1236
|
-
self.setVar(k, (valuesArr[idx] !== undefined) ? valuesArr[idx] : null); //upgrade any undefined to null
|
|
1237
|
-
});
|
|
1238
|
-
this.setLastResults(valuesArr);
|
|
1239
|
-
};
|
|
1240
|
-
|
|
1241
|
-
VContext.prototype.setVar = function (name, value) { //name might be simple or obj.prop
|
|
1242
|
-
if (!name) return; // if name is undefined or null, then discard
|
|
1243
|
-
var vConValues = this.values;
|
|
1244
|
-
var nameAndProps = name.split('.');
|
|
1245
|
-
var lastProp = nameAndProps.pop();
|
|
1246
|
-
var obj = nameAndProps.reduce(function (accObj, prop) {
|
|
1247
|
-
var o = accObj[prop];
|
|
1248
|
-
if (o === undefined || o === null) { // if doesn't exist create it
|
|
1249
|
-
o = accObj[prop] = { };
|
|
1250
|
-
}
|
|
1251
|
-
return o;
|
|
1252
|
-
}, vConValues); // vCon['foo']['bar']
|
|
1253
|
-
obj[lastProp] = value;
|
|
1254
|
-
};
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
/**
|
|
1258
|
-
Create Variable Context using arguments passed in.
|
|
1259
|
-
Ignore extra arguments passed in. Locals can be
|
|
1260
|
-
passed into seed the VContext otherwise empty {}
|
|
1261
|
-
will be used
|
|
1262
|
-
@param self used to pass 'this' context in
|
|
1263
|
-
*/
|
|
1264
|
-
VContext.create = function (args, inParams, locals, self) {
|
|
1265
|
-
var initValues = {};
|
|
1266
|
-
if (self) initValues['this'] = self;
|
|
1267
|
-
if (locals) Object.keys(locals).forEach(function (k) { initValues[k] = locals[k]; }); // copy over keys
|
|
1268
|
-
var vContext = new VContext();
|
|
1269
|
-
vContext.values = args.reduce(function (vcon, x, idx) { // create vCon start with input args
|
|
1270
|
-
var param = inParams[idx];
|
|
1271
|
-
if (param) vcon[param] = (x !== undefined) ? x : null; // upgrade undefined to null
|
|
1272
|
-
return vcon;
|
|
1273
|
-
}, initValues);
|
|
1274
|
-
return vContext;
|
|
1275
|
-
};
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
return VContext;
|
|
1279
|
-
|
|
1280
|
-
});
|
|
1281
|
-
|
|
1221
|
+
});
|
|
1282
1222
|
/*global define:true process:false*/
|
|
1283
1223
|
|
|
1284
1224
|
|
|
1285
1225
|
|
|
1286
1226
|
define('react/event-manager',['./eventemitter'], function (EventEmitter) {
|
|
1227
|
+
|
|
1228
|
+
/*jshint regexp:false */
|
|
1287
1229
|
|
|
1288
1230
|
var EVENT_EMITTER2_CONFIG = {
|
|
1289
1231
|
wildcard: true, // should the event emitter use wildcards.
|
|
1290
1232
|
delimiter: '.', // the delimiter used to segment namespaces, defaults to `.`.
|
|
1291
1233
|
maxListeners: 30 // the max number of listeners that can be assigned to an event, defaults to 10.
|
|
1292
|
-
|
|
1234
|
+
};
|
|
1293
1235
|
|
|
1294
|
-
|
|
1236
|
+
var PASS_EVENTS_PROCESS_RE = /^ast.defined$/; // events to pass up to global process
|
|
1295
1237
|
|
|
1296
1238
|
var TYPES = {
|
|
1297
1239
|
// Flow monitoring events and their params
|
|
@@ -1346,19 +1288,24 @@ define('react/event-manager',['./eventemitter'], function (EventEmitter) {
|
|
|
1346
1288
|
if (event === undefined) throw new Error('event is undefined');
|
|
1347
1289
|
if (this.emitter) this.emitter.emit.apply(this.emitter, arguments);
|
|
1348
1290
|
if (this.parent && this.parent.isEnabled()) this.parent.emit.apply(this.parent, arguments);
|
|
1349
|
-
if (PASS_EVENTS_PROCESS_RE.test(event) && process && process.emit)
|
|
1291
|
+
if (PASS_EVENTS_PROCESS_RE.test(event) && typeof(process) !== 'undefined' && process.emit) {
|
|
1292
|
+
process.emit.apply(process, arguments); // pass some to process
|
|
1293
|
+
}
|
|
1350
1294
|
};
|
|
1351
1295
|
|
|
1352
1296
|
EventManager.prototype.removeListener = function (event, listener) {
|
|
1353
1297
|
if (this.emitter) this.emitter.removeListener.apply(this.emitter, arguments);
|
|
1354
1298
|
};
|
|
1355
1299
|
|
|
1300
|
+
EventManager.prototype.removeAllListeners = function (event) {
|
|
1301
|
+
if (this.emitter) this.emitter.removeAllListeners.apply(this.emitter, arguments);
|
|
1302
|
+
};
|
|
1303
|
+
|
|
1356
1304
|
|
|
1357
1305
|
EventManager.global = EventManager.create(); // create one top level emitter
|
|
1358
1306
|
return EventManager;
|
|
1359
|
-
|
|
1360
|
-
});
|
|
1361
1307
|
|
|
1308
|
+
});
|
|
1362
1309
|
/*global define:true */
|
|
1363
1310
|
|
|
1364
1311
|
|
|
@@ -1366,6 +1313,7 @@ define('react/event-manager',['./eventemitter'], function (EventEmitter) {
|
|
|
1366
1313
|
define('react/base-task',['ensure-array', './status', './event-manager'],
|
|
1367
1314
|
function (array, STATUS, EventManager) {
|
|
1368
1315
|
|
|
1316
|
+
|
|
1369
1317
|
function BaseTask() {
|
|
1370
1318
|
}
|
|
1371
1319
|
|
|
@@ -1425,7 +1373,7 @@ define('react/base-task',['ensure-array', './status', './event-manager'],
|
|
|
1425
1373
|
to this if they want to do this check.
|
|
1426
1374
|
*/
|
|
1427
1375
|
BaseTask.prototype.parentExists = function (objPropStr, vCon) {
|
|
1428
|
-
|
|
1376
|
+
if (!isObjProperty(objPropStr)) return true; // NOT obj prop, just simple arg, ret true
|
|
1429
1377
|
var nameAndProps = objPropStr.split('.');
|
|
1430
1378
|
nameAndProps.pop(); // pop off final prop
|
|
1431
1379
|
var parent = nameAndProps.reduce(function (accObj, prop) {
|
|
@@ -1461,318 +1409,28 @@ define('react/base-task',['ensure-array', './status', './event-manager'],
|
|
|
1461
1409
|
BaseTask.prototype.isMethodCall = function () {
|
|
1462
1410
|
/*jshint regexp: false */
|
|
1463
1411
|
return (typeof(this.f) === 'string' && /^.*\..*$/.test(this.f)); //str contains .
|
|
1464
|
-
};
|
|
1465
|
-
|
|
1466
|
-
BaseTask.prototype.getMethodObj = function (vCon) { //obj.prop.prop2, returns obj.prop or undefined
|
|
1467
|
-
var name = this.f;
|
|
1468
|
-
if (!name) return undefined;
|
|
1469
|
-
var nameAndProps = name.split('.');
|
|
1470
|
-
nameAndProps.pop(); // pop off last one
|
|
1471
|
-
if (!nameAndProps.length) return undefined;
|
|
1472
|
-
var result = nameAndProps.reduce(function (accObj, prop) {
|
|
1473
|
-
if (accObj === undefined || accObj === null) return undefined; // prevent exception
|
|
1474
|
-
return accObj[prop];
|
|
1475
|
-
}, vCon.values); // vCon['foo']['bar']
|
|
1476
|
-
return result;
|
|
1477
|
-
};
|
|
1478
|
-
|
|
1479
|
-
return BaseTask;
|
|
1480
|
-
|
|
1481
|
-
});
|
|
1482
|
-
|
|
1483
|
-
/*global define:true */
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
define('react/input-parser',['./event-manager'], function (EventManager) {
|
|
1488
|
-
|
|
1489
|
-
var defaultExecOptions = {
|
|
1490
|
-
reactExecOptions: true,
|
|
1491
|
-
outputStyle: 'cb',
|
|
1492
1412
|
};
|
|
1493
1413
|
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
function nonExecOptionsFilter(x) { return !isExecOptions(x); }
|
|
1502
|
-
function mergeExecOptions(accum, options) {
|
|
1503
|
-
Object.keys(options).forEach(function (k) { accum[k] = options[k]; });
|
|
1504
|
-
return accum;
|
|
1505
|
-
}
|
|
1506
|
-
|
|
1507
|
-
function splitArgs(args, inParams, style) {
|
|
1508
|
-
var result = { };
|
|
1509
|
-
result.args = inParams.map(function (p) { return args.shift(); }); // take args for input params first
|
|
1510
|
-
if (style === OUTPUT_STYLES.CALLBACK && args.length) result.cb = args.shift(); // next take the cb
|
|
1511
|
-
result.extra = args; // these remaining were after the callback
|
|
1414
|
+
BaseTask.prototype.getMethodObj = function (vCon) { //obj.prop.prop2, returns obj.prop or undefined
|
|
1415
|
+
var name = this.f;
|
|
1416
|
+
if (!name) return undefined;
|
|
1417
|
+
var nameAndProps = name.split('.');
|
|
1418
|
+
nameAndProps.pop(); // pop off last one
|
|
1419
|
+
if (!nameAndProps.length) return undefined;
|
|
1420
|
+
var result = vCon.resolveNameArr(nameAndProps);
|
|
1512
1421
|
return result;
|
|
1513
|
-
}
|
|
1514
|
-
|
|
1515
|
-
function inputParser(inputArgs, ast) {
|
|
1516
|
-
var parsedInput = { };
|
|
1517
|
-
var execOptionsArr = inputArgs.filter(execOptionsFilter);
|
|
1518
|
-
execOptionsArr.unshift(defaultExecOptions);
|
|
1519
|
-
parsedInput.options = execOptionsArr.reduce(mergeExecOptions, {});
|
|
1520
|
-
|
|
1521
|
-
var args = inputArgs.filter(nonExecOptionsFilter);
|
|
1522
|
-
var splitResult = splitArgs(args, ast.inParams, parsedInput.options.outputStyle);
|
|
1523
|
-
parsedInput.args = splitResult.args;
|
|
1524
|
-
parsedInput.cb = splitResult.cb;
|
|
1525
|
-
if (splitResult.outputStyle) parsedInput.options.outputStyle = splitResult.outputStyle;
|
|
1526
|
-
if (splitResult.extra) parsedInput.extraArgs = splitResult.extra;
|
|
1527
|
-
EventManager.global.emit(EventManager.TYPES.EXEC_INPUT_PREPROCESS, parsedInput); // hook
|
|
1528
|
-
return parsedInput;
|
|
1529
|
-
}
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
inputParser.defaultExecOptions = defaultExecOptions;
|
|
1533
|
-
return inputParser;
|
|
1534
|
-
|
|
1535
|
-
});
|
|
1536
|
-
|
|
1537
|
-
/*global define:true */
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
define('react/id',[], function () {
|
|
1542
|
-
|
|
1543
|
-
var startingId = 0;
|
|
1544
|
-
|
|
1545
|
-
function createUniqueId() {
|
|
1546
|
-
startingId += 1;
|
|
1547
|
-
if (startingId === Number.MAX_VALUE) startingId = 0; // if hits this start over //TODO need something better?
|
|
1548
|
-
return startingId;
|
|
1549
|
-
}
|
|
1550
|
-
|
|
1551
|
-
return {
|
|
1552
|
-
createUniqueId: createUniqueId
|
|
1553
|
-
};
|
|
1554
|
-
|
|
1555
|
-
});
|
|
1556
|
-
(function() {
|
|
1557
|
-
var errorMessage, format, intSizeTable, sprint, _ref,
|
|
1558
|
-
__slice = Array.prototype.slice,
|
|
1559
|
-
__indexOf = Array.prototype.indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
|
|
1560
|
-
|
|
1561
|
-
format = /%(\d+[$])?((?:[+\x20\-#0])*)((?:[*](?:\d+[$])?)?v)?(\d*|[*](?:\d+[$])?)(?:[.](\d+|[*](?:\d+[$])?))?(hh?|ll?|[Lzjtq]|I(?:32|64)?)?([diuDUfFeEgGxXoOscpnbB])|%%/g;
|
|
1562
|
-
|
|
1563
|
-
errorMessage = "64-bit numbers aren't supported by sprint()!";
|
|
1564
|
-
|
|
1565
|
-
intSizeTable = {
|
|
1566
|
-
h: 2,
|
|
1567
|
-
hh: 1,
|
|
1568
|
-
l: 4,
|
|
1569
|
-
ll: new RangeError(errorMessage),
|
|
1570
|
-
L: 4,
|
|
1571
|
-
z: 4,
|
|
1572
|
-
j: 4,
|
|
1573
|
-
t: 4,
|
|
1574
|
-
I: 4,
|
|
1575
|
-
I32: 4,
|
|
1576
|
-
I64: new RangeError(errorMessage),
|
|
1577
|
-
q: new RangeError(errorMessage)
|
|
1578
|
-
};
|
|
1579
|
-
|
|
1580
|
-
sprint = function() {
|
|
1581
|
-
var arrayObjects, i, padString, string, toString, values, _ref;
|
|
1582
|
-
string = arguments[0], values = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
|
|
1583
|
-
arrayObjects = ['[object Array]', '[object Arguments]'];
|
|
1584
|
-
toString = Object.prototype.toString;
|
|
1585
|
-
if ((_ref = toString.call(values[0]), __indexOf.call(arrayObjects, _ref) >= 0) && values.length === 1) {
|
|
1586
|
-
values = values[0];
|
|
1587
|
-
}
|
|
1588
|
-
i = -1;
|
|
1589
|
-
padString = function(string, length, joiner, leftPad) {
|
|
1590
|
-
string = "" + string;
|
|
1591
|
-
if (string.length > length) {
|
|
1592
|
-
return string;
|
|
1593
|
-
} else if (leftPad) {
|
|
1594
|
-
return "" + string + (new Array(length - string.length + 1).join(joiner));
|
|
1595
|
-
} else {
|
|
1596
|
-
return "" + (new Array(length - string.length + 1).join(joiner)) + string;
|
|
1597
|
-
}
|
|
1598
|
-
};
|
|
1599
|
-
return ("" + string).replace(format, function() {
|
|
1600
|
-
var abs, alignCharacter, argument, character, defaultPrecision, flags, intSize, leftPad, length, letter, matches, padInteger, precision, prefix, result, special, string, toExponential, type, vector;
|
|
1601
|
-
string = arguments[0], matches = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
|
|
1602
|
-
argument = matches[0], flags = matches[1], vector = matches[2], length = matches[3], precision = matches[4], intSize = matches[5], type = matches[6];
|
|
1603
|
-
if (intSize == null) intSize = 'L';
|
|
1604
|
-
if (string === '%%') return '%';
|
|
1605
|
-
leftPad = __indexOf.call(flags, '-') >= 0;
|
|
1606
|
-
alignCharacter = __indexOf.call(flags, '0') >= 0 && !leftPad ? '0' : ' ';
|
|
1607
|
-
abs = function(int, signed) {
|
|
1608
|
-
var bits, entry, highValue;
|
|
1609
|
-
if (signed == null) signed = false;
|
|
1610
|
-
if (intSize === 'L' && (int >= 0 || signed)) return parseInt(int, 10);
|
|
1611
|
-
entry = intSizeTable[intSize];
|
|
1612
|
-
if (entry instanceof Error) throw entry;
|
|
1613
|
-
bits = entry * 8;
|
|
1614
|
-
int = parseInt(int, 10) % Math.pow(2, bits);
|
|
1615
|
-
highValue = Math.pow(2, bits) - 1;
|
|
1616
|
-
if (signed && int >= Math.pow(2, bits - 1)) int = -Math.pow(2, bits) + int;
|
|
1617
|
-
if (signed) {
|
|
1618
|
-
return int;
|
|
1619
|
-
} else {
|
|
1620
|
-
return int >>> 0;
|
|
1621
|
-
}
|
|
1622
|
-
};
|
|
1623
|
-
toExponential = function() {
|
|
1624
|
-
argument = (+argument).toExponential(precision);
|
|
1625
|
-
if (special && __indexOf.call(argument, '.') < 0) {
|
|
1626
|
-
argument = argument.replace('e', '.e');
|
|
1627
|
-
}
|
|
1628
|
-
return argument.toLowerCase().replace(/\d+$/, function(string) {
|
|
1629
|
-
return padString(string, 3, 0);
|
|
1630
|
-
});
|
|
1631
|
-
};
|
|
1632
|
-
padInteger = function(string) {
|
|
1633
|
-
if (+string === 0 && +precision === 0) {
|
|
1634
|
-
return '';
|
|
1635
|
-
} else if (defaultPrecision) {
|
|
1636
|
-
return string;
|
|
1637
|
-
} else {
|
|
1638
|
-
alignCharacter = ' ';
|
|
1639
|
-
return padString(string, precision, '0');
|
|
1640
|
-
}
|
|
1641
|
-
};
|
|
1642
|
-
if (vector) {
|
|
1643
|
-
character = vector[0] === '*' ? vector.length > 2 ? values[parseInt(vector.slice(1), 10) - 1] : values[++i] : '.';
|
|
1644
|
-
}
|
|
1645
|
-
length = length[0] === '*' ? length.length === 1 ? values[++i] : values[parseInt(length.slice(1)) - 1] : !length ? 0 : length;
|
|
1646
|
-
precision = precision && precision[0] === '*' ? precision.length === 1 ? values[++i] : values[parseInt(precision.slice(1), 10) - 1] : !precision ? (defaultPrecision = true, 6) : precision;
|
|
1647
|
-
argument = values[(parseInt(argument, 10) || ++i + 1) - 1];
|
|
1648
|
-
if (argument === 0) if (1 / argument === -Infinity) argument = '-0';
|
|
1649
|
-
argument = argument != null ? "" + argument : '';
|
|
1650
|
-
special = __indexOf.call(flags, '#') >= 0;
|
|
1651
|
-
arguments = (function() {
|
|
1652
|
-
var _i, _len, _results;
|
|
1653
|
-
if (vector) {
|
|
1654
|
-
_results = [];
|
|
1655
|
-
for (_i = 0, _len = argument.length; _i < _len; _i++) {
|
|
1656
|
-
letter = argument[_i];
|
|
1657
|
-
_results.push(letter.charCodeAt(0));
|
|
1658
|
-
}
|
|
1659
|
-
return _results;
|
|
1660
|
-
} else {
|
|
1661
|
-
return [argument];
|
|
1662
|
-
}
|
|
1663
|
-
})();
|
|
1664
|
-
result = (function() {
|
|
1665
|
-
var _i, _len, _results;
|
|
1666
|
-
_results = [];
|
|
1667
|
-
for (_i = 0, _len = arguments.length; _i < _len; _i++) {
|
|
1668
|
-
argument = arguments[_i];
|
|
1669
|
-
argument = (function() {
|
|
1670
|
-
var _ref2;
|
|
1671
|
-
switch (type) {
|
|
1672
|
-
case 'd':
|
|
1673
|
-
case 'i':
|
|
1674
|
-
case 'D':
|
|
1675
|
-
return padInteger(abs(argument, true));
|
|
1676
|
-
case 'u':
|
|
1677
|
-
case 'U':
|
|
1678
|
-
return padInteger(abs(argument));
|
|
1679
|
-
case 'f':
|
|
1680
|
-
case 'F':
|
|
1681
|
-
argument = (+argument).toFixed(precision).toLowerCase();
|
|
1682
|
-
if (special && __indexOf.call(argument, '.') < 0 && !/^-?[a-z]+$/.test(argument)) {
|
|
1683
|
-
argument += '.';
|
|
1684
|
-
}
|
|
1685
|
-
return argument;
|
|
1686
|
-
case 'e':
|
|
1687
|
-
case 'E':
|
|
1688
|
-
return toExponential();
|
|
1689
|
-
case 'g':
|
|
1690
|
-
case 'G':
|
|
1691
|
-
if (+argument === 0 || (0.0001 <= (_ref2 = Math.abs(argument)) && _ref2 < Math.pow(10, precision))) {
|
|
1692
|
-
argument = ("" + argument).substr(0, +precision + 1);
|
|
1693
|
-
if (special) {
|
|
1694
|
-
return argument.replace(/[.]?$/, '.');
|
|
1695
|
-
} else {
|
|
1696
|
-
return argument.replace(/[.]$/, '');
|
|
1697
|
-
}
|
|
1698
|
-
} else {
|
|
1699
|
-
return toExponential().replace(/[.]?0+e/, 'e');
|
|
1700
|
-
}
|
|
1701
|
-
break;
|
|
1702
|
-
case 'x':
|
|
1703
|
-
case 'X':
|
|
1704
|
-
prefix = special && +argument !== 0 ? '0x' : '';
|
|
1705
|
-
return "" + prefix + (padInteger(abs(argument).toString(16)));
|
|
1706
|
-
case 'b':
|
|
1707
|
-
case 'B':
|
|
1708
|
-
prefix = special && +argument !== 0 ? '0b' : '';
|
|
1709
|
-
return "" + prefix + (padInteger(abs(argument).toString(2)));
|
|
1710
|
-
case 'o':
|
|
1711
|
-
case 'O':
|
|
1712
|
-
prefix = special ? '0' : '';
|
|
1713
|
-
return "" + prefix + (padInteger(abs(argument).toString(8)));
|
|
1714
|
-
case 's':
|
|
1715
|
-
if (defaultPrecision) {
|
|
1716
|
-
return argument;
|
|
1717
|
-
} else {
|
|
1718
|
-
return argument.substr(0, precision);
|
|
1719
|
-
}
|
|
1720
|
-
break;
|
|
1721
|
-
case 'c':
|
|
1722
|
-
return String.fromCharCode(argument);
|
|
1723
|
-
default:
|
|
1724
|
-
throw new Exception("Unrecognized %type (?). Shouldn't happen.");
|
|
1725
|
-
}
|
|
1726
|
-
})();
|
|
1727
|
-
argument = "" + argument;
|
|
1728
|
-
if (type === type.toUpperCase()) argument = argument.toUpperCase();
|
|
1729
|
-
if (argument[0] !== '-') {
|
|
1730
|
-
if (__indexOf.call(flags, '+') >= 0) {
|
|
1731
|
-
argument = "+" + argument;
|
|
1732
|
-
} else if (__indexOf.call(flags, ' ') >= 0) {
|
|
1733
|
-
argument = " " + argument;
|
|
1734
|
-
}
|
|
1735
|
-
}
|
|
1736
|
-
_results.push(padString(argument, length, alignCharacter, leftPad));
|
|
1737
|
-
}
|
|
1738
|
-
return _results;
|
|
1739
|
-
}).apply(this, arguments);
|
|
1740
|
-
return result.join(character);
|
|
1741
|
-
});
|
|
1742
1422
|
};
|
|
1743
1423
|
|
|
1744
|
-
|
|
1745
|
-
module.exports = sprint;
|
|
1746
|
-
}
|
|
1747
|
-
|
|
1748
|
-
((_ref = typeof module !== "undefined" && module !== null ? module.exports : void 0) != null ? _ref : this).sprint = sprint;
|
|
1749
|
-
|
|
1750
|
-
}).call(this);
|
|
1751
|
-
|
|
1752
|
-
define("sprint", function(){});
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
/*global define:true sprint:true */
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
define('react/sprintf',['sprint'], function (sprintfMod) {
|
|
1424
|
+
return BaseTask;
|
|
1760
1425
|
|
|
1761
|
-
|
|
1762
|
-
Abstract the details of getting a sprintf function
|
|
1763
|
-
*/
|
|
1764
|
-
|
|
1765
|
-
// Sprint doesn't return itself in browser so need to get the global
|
|
1766
|
-
var sprintf = (sprintfMod) ? sprintfMod : sprint;
|
|
1767
|
-
return sprintf;
|
|
1768
|
-
|
|
1769
|
-
});
|
|
1426
|
+
});
|
|
1770
1427
|
|
|
1771
1428
|
/*global define:true */
|
|
1772
1429
|
|
|
1773
1430
|
|
|
1774
1431
|
|
|
1775
1432
|
define('react/cb-task',['util', './sprintf', './base-task'], function (util, sprintf, BaseTask) {
|
|
1433
|
+
|
|
1776
1434
|
|
|
1777
1435
|
function format_error(errmsg, obj) {
|
|
1778
1436
|
return sprintf('%s - %s', errmsg, util.inspect(obj));
|
|
@@ -1822,7 +1480,7 @@ define('react/cb-task',['util', './sprintf', './base-task'], function (util, spr
|
|
|
1822
1480
|
vCon.saveResults(self.out, args);
|
|
1823
1481
|
self.complete(args);
|
|
1824
1482
|
contExec();
|
|
1825
|
-
};
|
|
1483
|
+
};
|
|
1826
1484
|
};
|
|
1827
1485
|
|
|
1828
1486
|
CbTask.prototype.exec = function exec(vCon, handleError, contExec) {
|
|
@@ -1840,22 +1498,22 @@ define('react/cb-task',['util', './sprintf', './base-task'], function (util, spr
|
|
|
1840
1498
|
} else if (typeof(func) === 'string') {
|
|
1841
1499
|
func = vCon.getVar(func); // we want the actual fn from this string
|
|
1842
1500
|
}
|
|
1843
|
-
func.apply(bindObj, args);
|
|
1501
|
+
func.apply(bindObj, args);
|
|
1844
1502
|
} catch (err) { //catch and handle the task error, calling final cb
|
|
1845
1503
|
handleError(this, err);
|
|
1846
|
-
}
|
|
1504
|
+
}
|
|
1847
1505
|
};
|
|
1848
1506
|
|
|
1849
1507
|
return CbTask;
|
|
1850
1508
|
|
|
1851
|
-
});
|
|
1852
|
-
|
|
1509
|
+
});
|
|
1853
1510
|
|
|
1854
1511
|
/*global define:true */
|
|
1855
1512
|
|
|
1856
1513
|
|
|
1857
1514
|
|
|
1858
1515
|
define('react/promise-task',['util', './sprintf', './base-task'], function (util, sprintf, BaseTask) {
|
|
1516
|
+
|
|
1859
1517
|
|
|
1860
1518
|
/**
|
|
1861
1519
|
PromiseTask is a task which executes a fn that returns a promise
|
|
@@ -1892,7 +1550,7 @@ define('react/promise-task',['util', './sprintf', './base-task'], function (util
|
|
|
1892
1550
|
taskDef.a.every(function (x) { return (typeof(x) === 'string'); }))) {
|
|
1893
1551
|
errors.push(format_error(A_REQ, taskDef));
|
|
1894
1552
|
}
|
|
1895
|
-
if (! (Array.isArray(taskDef.out) && taskDef.out.length <= 1 &&
|
|
1553
|
+
if (! (Array.isArray(taskDef.out) && taskDef.out.length <= 1 &&
|
|
1896
1554
|
taskDef.out.every(function (x) { return (typeof(x) === 'string'); }))) {
|
|
1897
1555
|
errors.push(format_error(OUT_REQ, taskDef));
|
|
1898
1556
|
}
|
|
@@ -1935,19 +1593,19 @@ define('react/promise-task',['util', './sprintf', './base-task'], function (util
|
|
|
1935
1593
|
}
|
|
1936
1594
|
} catch (err) { //catch and handle the task error, calling final cb
|
|
1937
1595
|
handleError(this, err);
|
|
1938
|
-
}
|
|
1596
|
+
}
|
|
1939
1597
|
};
|
|
1940
1598
|
|
|
1941
1599
|
return PromiseTask;
|
|
1942
1600
|
|
|
1943
|
-
});
|
|
1944
|
-
|
|
1601
|
+
});
|
|
1945
1602
|
/*global define:true */
|
|
1946
1603
|
|
|
1947
1604
|
|
|
1948
1605
|
|
|
1949
1606
|
define('react/ret-task',['util', './sprintf', './base-task'], function (util, sprintf, BaseTask) {
|
|
1950
1607
|
|
|
1608
|
+
|
|
1951
1609
|
function format_error(errmsg, obj) {
|
|
1952
1610
|
return sprintf('%s - %s', errmsg, util.inspect(obj));
|
|
1953
1611
|
}
|
|
@@ -1991,7 +1649,7 @@ define('react/ret-task',['util', './sprintf', './base-task'], function (util, sp
|
|
|
1991
1649
|
RetTask.prototype.exec = function exec(vCon, handleError, contExec) {
|
|
1992
1650
|
try {
|
|
1993
1651
|
var args = this.a.map(function (k) { return vCon.getVar(k); }); //get args from vCon
|
|
1994
|
-
this.start(args); //note the start time, args
|
|
1652
|
+
this.start(args); //note the start time, args
|
|
1995
1653
|
var func = this.f;
|
|
1996
1654
|
var bindObj = vCon.getVar('this'); //global space or the original this
|
|
1997
1655
|
if (this.isMethodCall()) { //if method call then reset func and bindObj
|
|
@@ -2009,14 +1667,14 @@ define('react/ret-task',['util', './sprintf', './base-task'], function (util, sp
|
|
|
2009
1667
|
|
|
2010
1668
|
return RetTask;
|
|
2011
1669
|
|
|
2012
|
-
});
|
|
2013
|
-
|
|
1670
|
+
});
|
|
2014
1671
|
/*global define:true */
|
|
2015
1672
|
|
|
2016
1673
|
|
|
2017
1674
|
|
|
2018
1675
|
define('react/when-task',['util', './sprintf', './base-task'], function (util, sprintf, BaseTask) {
|
|
2019
1676
|
|
|
1677
|
+
|
|
2020
1678
|
/**
|
|
2021
1679
|
When task which checks if is a promise (has a then method)
|
|
2022
1680
|
and waits for it to resolve.
|
|
@@ -2040,19 +1698,18 @@ define('react/when-task',['util', './sprintf', './base-task'], function (util, s
|
|
|
2040
1698
|
WhenTask.prototype = new BaseTask();
|
|
2041
1699
|
WhenTask.prototype.constructor = WhenTask;
|
|
2042
1700
|
|
|
2043
|
-
WhenTask.prototype.f = function when() { // just here to keep validations happy
|
|
2044
|
-
}
|
|
1701
|
+
WhenTask.prototype.f = function when() { }; // just here to keep validations happy
|
|
2045
1702
|
|
|
2046
1703
|
WhenTask.validate = function (taskDef) {
|
|
2047
1704
|
var errors = [];
|
|
2048
1705
|
if (!taskDef.a || !taskDef.out) {
|
|
2049
1706
|
errors.push(format_error(REQ, taskDef));
|
|
2050
1707
|
} else {
|
|
2051
|
-
if (! (Array.isArray(taskDef.a) && taskDef.a.length === 1 &&
|
|
1708
|
+
if (! (Array.isArray(taskDef.a) && taskDef.a.length === 1 &&
|
|
2052
1709
|
taskDef.a.every(function (x) { return (typeof(x) === 'string'); }))) {
|
|
2053
1710
|
errors.push(format_error(A_REQ, taskDef));
|
|
2054
1711
|
}
|
|
2055
|
-
if (! (Array.isArray(taskDef.out) && taskDef.out.length <= 1 &&
|
|
1712
|
+
if (! (Array.isArray(taskDef.out) && taskDef.out.length <= 1 &&
|
|
2056
1713
|
taskDef.out.every(function (x) { return (typeof(x) === 'string'); }))) {
|
|
2057
1714
|
errors.push(format_error(OUT_REQ, taskDef));
|
|
2058
1715
|
}
|
|
@@ -2087,25 +1744,25 @@ define('react/when-task',['util', './sprintf', './base-task'], function (util, s
|
|
|
2087
1744
|
}
|
|
2088
1745
|
} catch (err) { //catch and handle the task error, calling final cb
|
|
2089
1746
|
handleError(this, err);
|
|
2090
|
-
}
|
|
1747
|
+
}
|
|
2091
1748
|
};
|
|
2092
1749
|
|
|
2093
1750
|
return WhenTask;
|
|
2094
1751
|
|
|
2095
|
-
});
|
|
2096
|
-
|
|
1752
|
+
});
|
|
2097
1753
|
/*global define:true */
|
|
2098
1754
|
|
|
2099
1755
|
|
|
2100
1756
|
|
|
2101
1757
|
define('react/finalcb-task',['./sprintf', 'util', './status', './event-manager'],
|
|
2102
1758
|
function (sprintf, util, STATUS, EventManager) {
|
|
1759
|
+
|
|
2103
1760
|
|
|
2104
1761
|
var OUTTASK_A_REQ = 'ast.outTask.a should be an array of string param names';
|
|
2105
1762
|
|
|
2106
1763
|
function FinalCbTask(outTaskOptions) {
|
|
2107
|
-
|
|
2108
|
-
if (typeof(outTaskOptions.cbFunc) !== 'function') throw new Error('callback is not a function');
|
|
1764
|
+
var taskDef = outTaskOptions.taskDef;
|
|
1765
|
+
if (typeof(outTaskOptions.cbFunc) !== 'function') throw new Error('callback is not a function');
|
|
2109
1766
|
var self = this;
|
|
2110
1767
|
for (var k in taskDef) {
|
|
2111
1768
|
if (true) self[k] = taskDef[k]; // if to make jshint happy
|
|
@@ -2155,7 +1812,118 @@ define('react/finalcb-task',['./sprintf', 'util', './status', './event-manager']
|
|
|
2155
1812
|
|
|
2156
1813
|
return FinalCbTask;
|
|
2157
1814
|
|
|
2158
|
-
});
|
|
1815
|
+
});
|
|
1816
|
+
/*global define:true */
|
|
1817
|
+
|
|
1818
|
+
|
|
1819
|
+
|
|
1820
|
+
define('react/vcon',[], function () {
|
|
1821
|
+
|
|
1822
|
+
|
|
1823
|
+
var LAST_RESULTS_KEY = ':LAST_RESULTS';
|
|
1824
|
+
|
|
1825
|
+
function VContext() {
|
|
1826
|
+
}
|
|
1827
|
+
|
|
1828
|
+
VContext.prototype.getLastResults = function () { return this.getVar(LAST_RESULTS_KEY); };
|
|
1829
|
+
VContext.prototype.setLastResults = function (args) { this.setVar(LAST_RESULTS_KEY, args); };
|
|
1830
|
+
|
|
1831
|
+
VContext.prototype.getVar = function (name) { //name might be simple or obj.prop, also literals
|
|
1832
|
+
/*jshint regexp: false */
|
|
1833
|
+
var vConValues = this.values;
|
|
1834
|
+
if (typeof(name) !== 'string') return name; // literal boolean or number
|
|
1835
|
+
name = name.trim();
|
|
1836
|
+
// literal checks need to match what is in validate.js
|
|
1837
|
+
if (name === 'true') return true;
|
|
1838
|
+
if (name === 'false') return false;
|
|
1839
|
+
if (name === 'null') return null;
|
|
1840
|
+
if (/^-?[0-9]+$/.test(name)) return parseInt(name, 10); //int
|
|
1841
|
+
if (/^-?[0-9.]+$/.test(name)) return parseFloat(name); //float
|
|
1842
|
+
var m = /^("|')([^\1]*)\1$/.exec(name); //check for quoted string " or '
|
|
1843
|
+
if (m) return m[2]; // if is quoted str, return inside of the quotes
|
|
1844
|
+
var nameAndProps = name.split('.');
|
|
1845
|
+
var result = this.resolveNameArr(nameAndProps);
|
|
1846
|
+
return result;
|
|
1847
|
+
};
|
|
1848
|
+
|
|
1849
|
+
VContext.prototype.resolveNameArr = function (nameAndProps) {
|
|
1850
|
+
var vConValues = this.values;
|
|
1851
|
+
var result = nameAndProps.reduce(function (accObj, prop) {
|
|
1852
|
+
if (accObj === undefined || accObj === null) return undefined; // prevent exception
|
|
1853
|
+
return accObj[prop];
|
|
1854
|
+
}, vConValues); // vCon['foo']['bar']
|
|
1855
|
+
if (result === undefined && this.global !== undefined) { // see if matches any global
|
|
1856
|
+
result = nameAndProps.reduce(function (accObj, prop) {
|
|
1857
|
+
if (accObj === undefined || accObj === null) return undefined; // prevent exception
|
|
1858
|
+
return accObj[prop];
|
|
1859
|
+
}, this.global); // global['foo']['bar']
|
|
1860
|
+
}
|
|
1861
|
+
return result;
|
|
1862
|
+
};
|
|
1863
|
+
|
|
1864
|
+
/**
|
|
1865
|
+
Saves all the results from a task as a unit, also sets special
|
|
1866
|
+
variable :LAST_RESULTS which keeps an array of the last values
|
|
1867
|
+
which can be used for chaining and testing last results, etc.
|
|
1868
|
+
*/
|
|
1869
|
+
VContext.prototype.saveResults = function (paramArr, valuesArr) { // set values for params
|
|
1870
|
+
var self = this;
|
|
1871
|
+
paramArr.forEach(function (k, idx) { //save values to v context
|
|
1872
|
+
self.setVar(k, (valuesArr[idx] !== undefined) ? valuesArr[idx] : null); //upgrade any undefined to null
|
|
1873
|
+
});
|
|
1874
|
+
this.setLastResults(valuesArr);
|
|
1875
|
+
};
|
|
1876
|
+
|
|
1877
|
+
VContext.prototype.setVar = function (name, value) { //name might be simple or obj.prop
|
|
1878
|
+
if (!name) return; // if name is undefined or null, then discard
|
|
1879
|
+
var vConValues = this.values;
|
|
1880
|
+
var nameAndProps = name.split('.');
|
|
1881
|
+
var lastProp = nameAndProps.pop();
|
|
1882
|
+
var obj = nameAndProps.reduce(function (accObj, prop) {
|
|
1883
|
+
var o = accObj[prop];
|
|
1884
|
+
if (o === undefined || o === null) { // if doesn't exist create it
|
|
1885
|
+
o = accObj[prop] = { };
|
|
1886
|
+
}
|
|
1887
|
+
return o;
|
|
1888
|
+
}, vConValues); // vCon['foo']['bar']
|
|
1889
|
+
obj[lastProp] = value;
|
|
1890
|
+
};
|
|
1891
|
+
|
|
1892
|
+
|
|
1893
|
+
/**
|
|
1894
|
+
Create Variable Context using arguments passed in.
|
|
1895
|
+
Ignore extra arguments passed in. Locals can be
|
|
1896
|
+
passed into seed the VContext otherwise empty {}
|
|
1897
|
+
will be used
|
|
1898
|
+
@param self used to pass 'this' context in
|
|
1899
|
+
*/
|
|
1900
|
+
VContext.create = function (args, inParams, locals, self) {
|
|
1901
|
+
/*jshint validthis:true, evil:true */
|
|
1902
|
+
var initValues = {};
|
|
1903
|
+
if (self) initValues['this'] = self;
|
|
1904
|
+
if (locals) Object.keys(locals).forEach(function (k) { initValues[k] = locals[k]; }); // copy over keys
|
|
1905
|
+
var vContext = new VContext();
|
|
1906
|
+
vContext.values = args.reduce(function (vcon, x, idx) { // create vCon start with input args
|
|
1907
|
+
var param = inParams[idx];
|
|
1908
|
+
if (param) vcon[param] = (x !== undefined) ? x : null; // upgrade undefined to null
|
|
1909
|
+
return vcon;
|
|
1910
|
+
}, initValues);
|
|
1911
|
+
|
|
1912
|
+
// add in global
|
|
1913
|
+
if (typeof global === 'object') { // node.js and modern browsers expose global
|
|
1914
|
+
vContext.global = global;
|
|
1915
|
+
} else { // try to access this using Function eval of this
|
|
1916
|
+
// http://stackoverflow.com/questions/3277182/how-to-get-the-global-object-in-javascript
|
|
1917
|
+
vContext.global = new Function('return this')();
|
|
1918
|
+
}
|
|
1919
|
+
|
|
1920
|
+
return vContext;
|
|
1921
|
+
};
|
|
1922
|
+
|
|
1923
|
+
|
|
1924
|
+
return VContext;
|
|
1925
|
+
|
|
1926
|
+
});
|
|
2159
1927
|
|
|
2160
1928
|
/*global define:true */
|
|
2161
1929
|
|
|
@@ -2163,12 +1931,13 @@ define('react/finalcb-task',['./sprintf', 'util', './status', './event-manager']
|
|
|
2163
1931
|
|
|
2164
1932
|
define('react/finalcb-first-task',['./sprintf', 'util', './status', './vcon', './event-manager'],
|
|
2165
1933
|
function (sprintf, util, STATUS, VContext, EventManager) {
|
|
1934
|
+
|
|
2166
1935
|
|
|
2167
1936
|
var OUTTASK_A_REQ = 'ast.outTask.a should be an array of string param names';
|
|
2168
1937
|
|
|
2169
1938
|
function FinalCbFirstSuccTask(outTaskOptions) {
|
|
2170
|
-
|
|
2171
|
-
if (typeof(outTaskOptions.cbFunc) !== 'function') throw new Error('callback is not a function');
|
|
1939
|
+
var taskDef = outTaskOptions.taskDef;
|
|
1940
|
+
if (typeof(outTaskOptions.cbFunc) !== 'function') throw new Error('callback is not a function');
|
|
2172
1941
|
var self = this;
|
|
2173
1942
|
for (var k in taskDef) {
|
|
2174
1943
|
if (true) self[k] = taskDef[k]; // if to make jshint happy
|
|
@@ -2221,8 +1990,7 @@ define('react/finalcb-first-task',['./sprintf', 'util', './status', './vcon', '.
|
|
|
2221
1990
|
|
|
2222
1991
|
return FinalCbFirstSuccTask;
|
|
2223
1992
|
|
|
2224
|
-
});
|
|
2225
|
-
|
|
1993
|
+
});
|
|
2226
1994
|
/*global define:true */
|
|
2227
1995
|
|
|
2228
1996
|
|
|
@@ -2234,14 +2002,15 @@ function (util, sprintf, array, CbTask, PromiseTask,
|
|
|
2234
2002
|
RetTask, WhenTask, FinalCbTask, FinalCbFirstSuccTask,
|
|
2235
2003
|
STATUS, error, VContext, EventManager) {
|
|
2236
2004
|
|
|
2005
|
+
|
|
2237
2006
|
var TASK_TYPES = {
|
|
2238
2007
|
cb: CbTask,
|
|
2239
2008
|
ret: RetTask,
|
|
2240
2009
|
promise: PromiseTask,
|
|
2241
2010
|
when: WhenTask
|
|
2242
|
-
|
|
2011
|
+
};
|
|
2243
2012
|
|
|
2244
|
-
|
|
2013
|
+
var DEFAULT_TASK_NAME = 'task_%s'; // for unnamed tasks use task_idx, like task_0
|
|
2245
2014
|
|
|
2246
2015
|
function taskTypeKeys() { return Object.keys(TASK_TYPES); }
|
|
2247
2016
|
|
|
@@ -2257,9 +2026,6 @@ function (util, sprintf, array, CbTask, PromiseTask,
|
|
|
2257
2026
|
var TASK_TYPE_SHOULD_MATCH = 'task.type should match one of ' +
|
|
2258
2027
|
Object.keys(TASK_TYPES).join(', ');
|
|
2259
2028
|
|
|
2260
|
-
var validateTaskType, validateTask, create;
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
2029
|
function format_error(errmsg, obj) {
|
|
2264
2030
|
return sprintf('%s - %s', errmsg, util.inspect(obj));
|
|
2265
2031
|
}
|
|
@@ -2271,13 +2037,13 @@ function (util, sprintf, array, CbTask, PromiseTask,
|
|
|
2271
2037
|
*/
|
|
2272
2038
|
function setMissingType(taskDef) {
|
|
2273
2039
|
if (taskDef.type) return taskDef; //already set, return
|
|
2274
|
-
taskDef.type = 'cb';
|
|
2040
|
+
taskDef.type = 'cb';
|
|
2275
2041
|
return taskDef;
|
|
2276
2042
|
}
|
|
2277
2043
|
|
|
2278
2044
|
function setMissingOutTaskType(taskDef) {
|
|
2279
2045
|
if (!taskDef.type) taskDef.type = Object.keys(OUT_TASK_TYPES)[0]; //use first outTask type as default
|
|
2280
|
-
}
|
|
2046
|
+
}
|
|
2281
2047
|
|
|
2282
2048
|
function ensureAfterArrStrings(taskDef) { // convert any fn to str, and make sure is array
|
|
2283
2049
|
if (!taskDef.after) return;
|
|
@@ -2290,14 +2056,14 @@ function (util, sprintf, array, CbTask, PromiseTask,
|
|
|
2290
2056
|
@returns array of errors for taskDef, could be empty
|
|
2291
2057
|
*/
|
|
2292
2058
|
function validate(taskDef) {
|
|
2293
|
-
if (!taskDef || typeof(taskDef) !== 'object') {
|
|
2059
|
+
if (!taskDef || typeof(taskDef) !== 'object') {
|
|
2294
2060
|
return [format_error(TASKDEF_IS_OBJECT, taskDef)];
|
|
2295
2061
|
}
|
|
2296
2062
|
setMissingType(taskDef);
|
|
2297
2063
|
ensureAfterArrStrings(taskDef);
|
|
2298
2064
|
var errors = [];
|
|
2299
2065
|
errors = errors.concat(validateTaskType(taskDef));
|
|
2300
|
-
errors = errors.concat(validateTask(taskDef));
|
|
2066
|
+
errors = errors.concat(validateTask(taskDef));
|
|
2301
2067
|
return errors;
|
|
2302
2068
|
}
|
|
2303
2069
|
|
|
@@ -2324,30 +2090,30 @@ function (util, sprintf, array, CbTask, PromiseTask,
|
|
|
2324
2090
|
setMissingOutTaskType(taskDef);
|
|
2325
2091
|
var taskCons = OUT_TASK_TYPES[taskDef.type];
|
|
2326
2092
|
errors = errors.concat(taskCons.validate(taskDef));
|
|
2327
|
-
return errors;
|
|
2093
|
+
return errors;
|
|
2328
2094
|
}
|
|
2329
2095
|
|
|
2330
2096
|
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
}
|
|
2097
|
+
function validateLocalFunctions(inParams, taskDefs, locals) {
|
|
2098
|
+
var errors = [];
|
|
2099
|
+
function foo() { } //used to mock args as fns for validation check
|
|
2100
|
+
var mock_args = inParams.map(function (p) { return foo; }); //mock args with fns
|
|
2101
|
+
var vCon = VContext.create(mock_args, inParams, locals);
|
|
2102
|
+
var tasks = taskDefs.map(create);
|
|
2103
|
+
var tasksWFunctions = tasks.filter(function (t) { return (t.type !== 'when'); }); // non-when tasks need f
|
|
2104
|
+
tasksWFunctions.forEach(function (t, idx) {
|
|
2105
|
+
if (!t.functionExists(vCon)) { // error if function doesnt exist AND
|
|
2106
|
+
if (!t.isMethodCall()) errors.push(sprintf(LOCAL_FN_MISSING, t.f, idx)); // not method OR
|
|
2107
|
+
else {
|
|
2108
|
+
var obj = t.getMethodObj(vCon);
|
|
2109
|
+
if (obj && obj !== foo) { // (has parent but not our mock)
|
|
2110
|
+
errors.push(sprintf(LOCAL_FN_MISSING, t.f, idx));
|
|
2346
2111
|
}
|
|
2347
2112
|
}
|
|
2348
|
-
}
|
|
2349
|
-
|
|
2350
|
-
|
|
2113
|
+
}
|
|
2114
|
+
});
|
|
2115
|
+
return errors;
|
|
2116
|
+
}
|
|
2351
2117
|
|
|
2352
2118
|
function fName(fn) {
|
|
2353
2119
|
if (typeof(fn) === 'function') {
|
|
@@ -2377,7 +2143,7 @@ function (util, sprintf, array, CbTask, PromiseTask,
|
|
|
2377
2143
|
name = sprintf('%s_%s', name, idx); //if empty or already used, postfix with _idx
|
|
2378
2144
|
}
|
|
2379
2145
|
t.name = name;
|
|
2380
|
-
|
|
2146
|
+
namesMap[name] = t;
|
|
2381
2147
|
}
|
|
2382
2148
|
});
|
|
2383
2149
|
return namesMap;
|
|
@@ -2390,20 +2156,20 @@ function (util, sprintf, array, CbTask, PromiseTask,
|
|
|
2390
2156
|
|
|
2391
2157
|
function createOutTask(taskDef, cbFunc, tasks, vCon, execOptions, env) {
|
|
2392
2158
|
setMissingOutTaskType(taskDef);
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2159
|
+
var outTaskOptions = {
|
|
2160
|
+
taskDef: taskDef,
|
|
2161
|
+
cbFunc: cbFunc,
|
|
2162
|
+
tasks: tasks,
|
|
2163
|
+
vCon: vCon,
|
|
2164
|
+
execOptions: execOptions,
|
|
2165
|
+
env: env,
|
|
2166
|
+
TaskConstructor: OUT_TASK_TYPES[taskDef.type]
|
|
2167
|
+
};
|
|
2402
2168
|
EventManager.global.emit(EventManager.TYPES.EXEC_OUTTASK_CREATE, outTaskOptions); // hook
|
|
2403
2169
|
var TaskConstructor = outTaskOptions.TaskConstructor; // hook could have changed
|
|
2404
2170
|
return new TaskConstructor(outTaskOptions);
|
|
2405
2171
|
}
|
|
2406
|
-
|
|
2172
|
+
|
|
2407
2173
|
function createErrorHandler(vCon, outTask) {
|
|
2408
2174
|
return function handleError(task, err) {
|
|
2409
2175
|
task.status = STATUS.ERRORED;
|
|
@@ -2421,7 +2187,7 @@ function (util, sprintf, array, CbTask, PromiseTask,
|
|
|
2421
2187
|
|
|
2422
2188
|
function execTasks(tasksReady, vCon, handleError, contExec) {
|
|
2423
2189
|
tasksReady.forEach(function (t) { t.status = STATUS.READY; }); //set ready first, no double exec
|
|
2424
|
-
tasksReady.forEach(function (t) { t.exec(vCon, handleError, contExec); });
|
|
2190
|
+
tasksReady.forEach(function (t) { t.exec(vCon, handleError, contExec); });
|
|
2425
2191
|
}
|
|
2426
2192
|
|
|
2427
2193
|
/**
|
|
@@ -2452,7 +2218,7 @@ function (util, sprintf, array, CbTask, PromiseTask,
|
|
|
2452
2218
|
|
|
2453
2219
|
function serializeTasks(tasks) { // conveniently set after for each task idx > 0
|
|
2454
2220
|
nameTasks(tasks);
|
|
2455
|
-
tasks.forEach(function (t, idx, arr) { if (idx !== 0) t.after = [arr[idx - 1].name]; });
|
|
2221
|
+
tasks.forEach(function (t, idx, arr) { if (idx !== 0) t.after = [arr[idx - 1].name]; });
|
|
2456
2222
|
return tasks;
|
|
2457
2223
|
}
|
|
2458
2224
|
|
|
@@ -2473,15 +2239,15 @@ function (util, sprintf, array, CbTask, PromiseTask,
|
|
|
2473
2239
|
findReadyAndExec: findReadyAndExec
|
|
2474
2240
|
};
|
|
2475
2241
|
|
|
2476
|
-
});
|
|
2477
|
-
|
|
2242
|
+
});
|
|
2478
2243
|
/*global define:true */
|
|
2479
2244
|
|
|
2480
2245
|
|
|
2481
2246
|
|
|
2482
2247
|
define('react/validate',['util', './sprintf', 'ensure-array', './task'], function (util, sprintf, array, taskUtil) {
|
|
2483
|
-
/*jshint latedef:false */
|
|
2484
2248
|
|
|
2249
|
+
/*jshint latedef:false */
|
|
2250
|
+
|
|
2485
2251
|
var AST_IS_OBJECT = 'ast must be an object with inParams, tasks, and outTask';
|
|
2486
2252
|
var INPARAMS_ARR_STR = 'ast.inParams must be an array of strings';
|
|
2487
2253
|
var TASKS_ARR = 'ast.tasks must be an array of tasks';
|
|
@@ -2491,7 +2257,7 @@ define('react/validate',['util', './sprintf', 'ensure-array', './task'], functio
|
|
|
2491
2257
|
var MISSING_INPUTS = 'missing or mispelled variable referenced in flow definition: %s';
|
|
2492
2258
|
|
|
2493
2259
|
// match any of our literals true, false, int, float, quoted strings, or is property (has dot), match vcon.js
|
|
2494
|
-
var LITERAL_OR_PROP_RE = /^(true|false|this|null|\-?[0-9\.]+)$|'|"|\./i;
|
|
2260
|
+
var LITERAL_OR_PROP_RE = /^(true|false|this|null|\-?[0-9\.]+)$|'|"|\./i;
|
|
2495
2261
|
|
|
2496
2262
|
function format_error(errmsg, obj) {
|
|
2497
2263
|
return sprintf('%s - %s', errmsg, util.inspect(obj));
|
|
@@ -2547,11 +2313,11 @@ define('react/validate',['util', './sprintf', 'ensure-array', './task'], functio
|
|
|
2547
2313
|
tasks.forEach(function (t) {
|
|
2548
2314
|
errors = errors.concat(taskUtil.validate(t));
|
|
2549
2315
|
});
|
|
2550
|
-
|
|
2316
|
+
return errors;
|
|
2551
2317
|
}
|
|
2552
2318
|
|
|
2553
2319
|
function validateTaskNamesUnique(tasks) {
|
|
2554
|
-
|
|
2320
|
+
if (!Array.isArray(tasks)) return [];
|
|
2555
2321
|
var errors = [];
|
|
2556
2322
|
var namedTasks = tasks.filter(function (t) { return (t.name); });
|
|
2557
2323
|
var names = namedTasks.map(function (t) { return t.name; });
|
|
@@ -2559,7 +2325,7 @@ define('react/validate',['util', './sprintf', 'ensure-array', './task'], functio
|
|
|
2559
2325
|
if (accum[name]) errors.push(sprintf('%s %s', NAMES_UNIQUE, name));
|
|
2560
2326
|
else accum[name] = true;
|
|
2561
2327
|
return accum;
|
|
2562
|
-
}, {});
|
|
2328
|
+
}, {});
|
|
2563
2329
|
return errors;
|
|
2564
2330
|
}
|
|
2565
2331
|
|
|
@@ -2625,13 +2391,86 @@ define('react/validate',['util', './sprintf', 'ensure-array', './task'], functio
|
|
|
2625
2391
|
if (!isLiteralOrProp(p) && !names[p]) accum.push(sprintf(MISSING_INPUTS, p)); // add error if missing
|
|
2626
2392
|
return accum;
|
|
2627
2393
|
}, errors);
|
|
2628
|
-
return errors;
|
|
2394
|
+
return errors;
|
|
2629
2395
|
}
|
|
2630
2396
|
|
|
2631
2397
|
return validate;
|
|
2632
2398
|
|
|
2633
|
-
});
|
|
2399
|
+
});
|
|
2400
|
+
/*global define:true */
|
|
2401
|
+
|
|
2402
|
+
|
|
2634
2403
|
|
|
2404
|
+
define('react/input-parser',['./event-manager'], function (EventManager) {
|
|
2405
|
+
|
|
2406
|
+
|
|
2407
|
+
var defaultExecOptions = {
|
|
2408
|
+
reactExecOptions: true,
|
|
2409
|
+
outputStyle: 'cb',
|
|
2410
|
+
};
|
|
2411
|
+
|
|
2412
|
+
var OUTPUT_STYLES = {
|
|
2413
|
+
CALLBACK: 'cb',
|
|
2414
|
+
NONE: 'none'
|
|
2415
|
+
};
|
|
2416
|
+
|
|
2417
|
+
function isExecOptions(x) { return (x && x.reactExecOptions); }
|
|
2418
|
+
function execOptionsFilter(x) { return isExecOptions(x); }
|
|
2419
|
+
function nonExecOptionsFilter(x) { return !isExecOptions(x); }
|
|
2420
|
+
function mergeExecOptions(accum, options) {
|
|
2421
|
+
Object.keys(options).forEach(function (k) { accum[k] = options[k]; });
|
|
2422
|
+
return accum;
|
|
2423
|
+
}
|
|
2424
|
+
|
|
2425
|
+
function splitArgs(args, inParams, style) {
|
|
2426
|
+
var result = { };
|
|
2427
|
+
result.args = inParams.map(function (p) { return args.shift(); }); // take args for input params first
|
|
2428
|
+
if (style === OUTPUT_STYLES.CALLBACK && args.length) result.cb = args.shift(); // next take the cb
|
|
2429
|
+
result.extra = args; // these remaining were after the callback
|
|
2430
|
+
return result;
|
|
2431
|
+
}
|
|
2432
|
+
|
|
2433
|
+
function inputParser(inputArgs, ast) {
|
|
2434
|
+
var parsedInput = { };
|
|
2435
|
+
var execOptionsArr = inputArgs.filter(execOptionsFilter);
|
|
2436
|
+
execOptionsArr.unshift(defaultExecOptions);
|
|
2437
|
+
parsedInput.options = execOptionsArr.reduce(mergeExecOptions, {});
|
|
2438
|
+
|
|
2439
|
+
var args = inputArgs.filter(nonExecOptionsFilter);
|
|
2440
|
+
var splitResult = splitArgs(args, ast.inParams, parsedInput.options.outputStyle);
|
|
2441
|
+
parsedInput.args = splitResult.args;
|
|
2442
|
+
parsedInput.cb = splitResult.cb;
|
|
2443
|
+
if (splitResult.outputStyle) parsedInput.options.outputStyle = splitResult.outputStyle;
|
|
2444
|
+
if (splitResult.extra) parsedInput.extraArgs = splitResult.extra;
|
|
2445
|
+
EventManager.global.emit(EventManager.TYPES.EXEC_INPUT_PREPROCESS, parsedInput); // hook
|
|
2446
|
+
return parsedInput;
|
|
2447
|
+
}
|
|
2448
|
+
|
|
2449
|
+
|
|
2450
|
+
inputParser.defaultExecOptions = defaultExecOptions;
|
|
2451
|
+
return inputParser;
|
|
2452
|
+
|
|
2453
|
+
});
|
|
2454
|
+
/*global define:true */
|
|
2455
|
+
|
|
2456
|
+
|
|
2457
|
+
|
|
2458
|
+
define('react/id',[], function () {
|
|
2459
|
+
|
|
2460
|
+
|
|
2461
|
+
var startingId = 0;
|
|
2462
|
+
|
|
2463
|
+
function createUniqueId() {
|
|
2464
|
+
startingId += 1;
|
|
2465
|
+
if (startingId === Number.MAX_VALUE) startingId = 0; // if hits this start over //TODO need something better?
|
|
2466
|
+
return startingId;
|
|
2467
|
+
}
|
|
2468
|
+
|
|
2469
|
+
return {
|
|
2470
|
+
createUniqueId: createUniqueId
|
|
2471
|
+
};
|
|
2472
|
+
|
|
2473
|
+
});
|
|
2635
2474
|
/*global define:true */
|
|
2636
2475
|
|
|
2637
2476
|
|
|
@@ -2640,6 +2479,7 @@ define('react/core',['./eventemitter', './error', './validate', './task', './sta
|
|
|
2640
2479
|
'./vcon', './event-manager', './input-parser', './id', './sprintf'],
|
|
2641
2480
|
function (EventEmitter, error, validate, taskUtil, STATUS,
|
|
2642
2481
|
VContext, EventManager, inputParser, idGenerator, sprintf) {
|
|
2482
|
+
|
|
2643
2483
|
|
|
2644
2484
|
var reactOptions = {
|
|
2645
2485
|
stackTraceLimitMin: 30
|
|
@@ -2654,7 +2494,7 @@ define('react/core',['./eventemitter', './error', './validate', './task', './sta
|
|
|
2654
2494
|
return Object.keys(reactOptions).reduce(function (accum, k) {
|
|
2655
2495
|
if (!accum[k]) accum[k] = reactOptions[k];
|
|
2656
2496
|
return accum;
|
|
2657
|
-
}, parsedOptions);
|
|
2497
|
+
}, parsedOptions);
|
|
2658
2498
|
}
|
|
2659
2499
|
|
|
2660
2500
|
/**
|
|
@@ -2711,9 +2551,9 @@ define('react/core',['./eventemitter', './error', './validate', './task', './sta
|
|
|
2711
2551
|
});
|
|
2712
2552
|
Object.freeze(newAST);
|
|
2713
2553
|
}
|
|
2714
|
-
flowEmitter.emit(EventManager.TYPES.AST_DEFINED, ast);
|
|
2554
|
+
flowEmitter.emit(EventManager.TYPES.AST_DEFINED, ast);
|
|
2715
2555
|
return errors;
|
|
2716
|
-
|
|
2556
|
+
}
|
|
2717
2557
|
|
|
2718
2558
|
function exec(arg1, arg2, argN, cb) { // called to execute the flow
|
|
2719
2559
|
/*jshint validthis: true */
|
|
@@ -2733,9 +2573,9 @@ define('react/core',['./eventemitter', './error', './validate', './task', './sta
|
|
|
2733
2573
|
env.options = mergeOptions(parsedInput.options);
|
|
2734
2574
|
env.vCon = vCon;
|
|
2735
2575
|
env.taskDefs = ast.tasks.slice(); // create copy
|
|
2736
|
-
|
|
2576
|
+
env.outTaskDef = Object.create(ast.outTask); // create copy
|
|
2737
2577
|
reactEmitter.emit(EventManager.TYPES.EXEC_TASKS_PRECREATE, env); // hook
|
|
2738
|
-
|
|
2578
|
+
|
|
2739
2579
|
var tasks = env.taskDefs.map(taskUtil.create);
|
|
2740
2580
|
var tasksByName = taskUtil.nameTasks(tasks); // map names to working tasks
|
|
2741
2581
|
var outTask = taskUtil.createOutTask(env.outTaskDef, parsedInput.cb, tasks, vCon, env.options, env);
|
|
@@ -2766,13 +2606,13 @@ define('react/core',['./eventemitter', './error', './validate', './task', './sta
|
|
|
2766
2606
|
reactFactory.options = reactOptions; // global react options
|
|
2767
2607
|
reactFactory.events = reactEmitter; // global react emitter
|
|
2768
2608
|
return reactFactory; // module returns reactFactory to create a react fn
|
|
2769
|
-
});
|
|
2770
|
-
|
|
2609
|
+
});
|
|
2771
2610
|
/*global define:true */
|
|
2772
2611
|
|
|
2773
2612
|
|
|
2774
2613
|
|
|
2775
2614
|
define('react/parse',['./sprintf'], function (sprintf) {
|
|
2615
|
+
|
|
2776
2616
|
|
|
2777
2617
|
function splitTrimFilterArgs(commaSepArgs) { //parse 'one, two' into ['one', 'two']
|
|
2778
2618
|
if (!commaSepArgs) return [];
|
|
@@ -2797,7 +2637,7 @@ define('react/parse',['./sprintf'], function (sprintf) {
|
|
|
2797
2637
|
return result;
|
|
2798
2638
|
} else { // no match
|
|
2799
2639
|
throw new Error(sprintf(errStr, str));
|
|
2800
|
-
}
|
|
2640
|
+
}
|
|
2801
2641
|
}
|
|
2802
2642
|
|
|
2803
2643
|
return {
|
|
@@ -2805,8 +2645,7 @@ define('react/parse',['./sprintf'], function (sprintf) {
|
|
|
2805
2645
|
parseStr: parseStr
|
|
2806
2646
|
};
|
|
2807
2647
|
|
|
2808
|
-
});
|
|
2809
|
-
|
|
2648
|
+
});
|
|
2810
2649
|
|
|
2811
2650
|
/*global define:true */
|
|
2812
2651
|
|
|
@@ -2814,7 +2653,8 @@ define('react/parse',['./sprintf'], function (sprintf) {
|
|
|
2814
2653
|
|
|
2815
2654
|
define('react/dsl',['./sprintf', './core', './parse', './task'],
|
|
2816
2655
|
function (sprintf, core, parse, taskUtil) {
|
|
2817
|
-
|
|
2656
|
+
|
|
2657
|
+
/*jshint regexp: false */
|
|
2818
2658
|
|
|
2819
2659
|
var MISSING_NAME = 'first flow parameter should be the flow name, but found in/out def: %s';
|
|
2820
2660
|
var INOUT_PARAMS_NO_MATCH = 'params in wrong format, wanted "foo, bar, cb -> err, baz" - found: %s';
|
|
@@ -2838,23 +2678,23 @@ define('react/dsl',['./sprintf', './core', './parse', './task'],
|
|
|
2838
2678
|
|
|
2839
2679
|
var inOutDefParse = {
|
|
2840
2680
|
splitStr: '->',
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
|
|
2848
|
-
|
|
2849
|
-
|
|
2850
|
-
|
|
2851
|
-
}
|
|
2852
|
-
return {
|
|
2853
|
-
type: type,
|
|
2854
|
-
inDef: filterOutTrailingCbParam(inParams),
|
|
2855
|
-
outDef: filterOutLeadingErrParam(outParams)
|
|
2856
|
-
};
|
|
2681
|
+
fn: function (m, origStr) {
|
|
2682
|
+
var inParams = parse.splitTrimFilterArgs(m[0]);
|
|
2683
|
+
var lastParam = inParams[inParams.length - 1];
|
|
2684
|
+
var type = (lastParam && CB_NAMES_RE.test(lastParam)) ? 'cb' : 'ret';
|
|
2685
|
+
var outParams = parse.splitTrimFilterArgs(m[1]);
|
|
2686
|
+
var firstOutParam = outParams[0];
|
|
2687
|
+
if (type === 'cb' && (!firstOutParam || !ERR_NAMES_RE.test(firstOutParam))) {
|
|
2688
|
+
throw new Error(sprintf(MISSING_ERR, origStr)); // found cb, but no err param
|
|
2689
|
+
} else if (type === 'ret' && firstOutParam && ERR_NAMES_RE.test(firstOutParam)) {
|
|
2690
|
+
throw new Error(sprintf(MISSING_CB, origStr)); // found err but not cb param
|
|
2857
2691
|
}
|
|
2692
|
+
return {
|
|
2693
|
+
type: type,
|
|
2694
|
+
inDef: filterOutTrailingCbParam(inParams),
|
|
2695
|
+
outDef: filterOutLeadingErrParam(outParams)
|
|
2696
|
+
};
|
|
2697
|
+
}
|
|
2858
2698
|
};
|
|
2859
2699
|
|
|
2860
2700
|
function parseInOutParams(str) {
|
|
@@ -2890,11 +2730,11 @@ define('react/dsl',['./sprintf', './core', './parse', './task'],
|
|
|
2890
2730
|
// if next arg is object, shift it off as options
|
|
2891
2731
|
var options = (vargs.length && typeof(vargs[0]) === 'object') ? vargs.shift() : { };
|
|
2892
2732
|
var taskDefArr = vargs; // rest are for the tasks
|
|
2893
|
-
var defObj = {
|
|
2733
|
+
var defObj = {
|
|
2894
2734
|
inOutParamStr: inOutParamStr,
|
|
2895
2735
|
taskDefArr: taskDefArr,
|
|
2896
2736
|
options: options
|
|
2897
|
-
|
|
2737
|
+
};
|
|
2898
2738
|
return defObj;
|
|
2899
2739
|
}
|
|
2900
2740
|
|
|
@@ -2902,7 +2742,7 @@ define('react/dsl',['./sprintf', './core', './parse', './task'],
|
|
|
2902
2742
|
function dslDefine(name, arg1, arg2, argN) {
|
|
2903
2743
|
var reactFn = core();
|
|
2904
2744
|
if (name && INOUT_RE.test(name)) throw new Error(sprintf(MISSING_NAME, name));
|
|
2905
|
-
var defObj = parseVargs(Array.prototype.slice.call(arguments, 1)); // name, already used
|
|
2745
|
+
var defObj = parseVargs(Array.prototype.slice.call(arguments, 1)); // name, already used
|
|
2906
2746
|
var inOutDef = parseInOutParams(defObj.inOutParamStr);
|
|
2907
2747
|
var ast = {
|
|
2908
2748
|
name: name,
|
|
@@ -2911,18 +2751,18 @@ define('react/dsl',['./sprintf', './core', './parse', './task'],
|
|
|
2911
2751
|
outTask: { a: inOutDef.outDef }
|
|
2912
2752
|
};
|
|
2913
2753
|
if (defObj.options) Object.keys(defObj.options).forEach(function (k) { ast[k] = defObj.options[k]; });
|
|
2914
|
-
|
|
2754
|
+
var errors = reactFn.setAndValidateAST(ast);
|
|
2915
2755
|
if (errors.length) {
|
|
2916
2756
|
var errorStr = errors.join('\n');
|
|
2917
|
-
|
|
2757
|
+
throw new Error(errorStr);
|
|
2918
2758
|
}
|
|
2919
2759
|
return reactFn;
|
|
2920
|
-
|
|
2760
|
+
}
|
|
2921
2761
|
|
|
2922
2762
|
function selectFirst(name, arg1, arg2, argN) {
|
|
2923
2763
|
var reactFn = core();
|
|
2924
|
-
var defObj = parseVargs(Array.prototype.slice.call(arguments, 1)); // name, already used
|
|
2925
|
-
var inOutDef = parseInOutParams(defObj.inOutParamStr);
|
|
2764
|
+
var defObj = parseVargs(Array.prototype.slice.call(arguments, 1)); // name, already used
|
|
2765
|
+
var inOutDef = parseInOutParams(defObj.inOutParamStr);
|
|
2926
2766
|
var tasks = taskUtil.serializeTasks(parseTasks(defObj.taskDefArr));
|
|
2927
2767
|
var ast = {
|
|
2928
2768
|
name: name,
|
|
@@ -2930,7 +2770,7 @@ define('react/dsl',['./sprintf', './core', './parse', './task'],
|
|
|
2930
2770
|
tasks: tasks,
|
|
2931
2771
|
outTask: { type: 'finalcbFirst', a: inOutDef.outDef },
|
|
2932
2772
|
};
|
|
2933
|
-
if (defObj.options) Object.keys(defObj.options).forEach(function (k) { ast[k] = defObj.options[k]; });
|
|
2773
|
+
if (defObj.options) Object.keys(defObj.options).forEach(function (k) { ast[k] = defObj.options[k]; });
|
|
2934
2774
|
var errors = reactFn.setAndValidateAST(ast);
|
|
2935
2775
|
if (errors.length) {
|
|
2936
2776
|
var errorStr = errors.join('\n');
|
|
@@ -2941,15 +2781,15 @@ define('react/dsl',['./sprintf', './core', './parse', './task'],
|
|
|
2941
2781
|
|
|
2942
2782
|
dslDefine.selectFirst = selectFirst;
|
|
2943
2783
|
return dslDefine;
|
|
2944
|
-
|
|
2945
|
-
});
|
|
2946
2784
|
|
|
2785
|
+
});
|
|
2947
2786
|
/*global define:true */
|
|
2948
2787
|
|
|
2949
2788
|
|
|
2950
2789
|
|
|
2951
2790
|
define('react/track-tasks',[], function () {
|
|
2952
2791
|
|
|
2792
|
+
|
|
2953
2793
|
/**
|
|
2954
2794
|
Track the tasks, start, complete, args, results, elapsed time
|
|
2955
2795
|
Emits events that can be monitored
|
|
@@ -3012,18 +2852,18 @@ define('react/track-tasks',[], function () {
|
|
|
3012
2852
|
|
|
3013
2853
|
}
|
|
3014
2854
|
|
|
3015
|
-
return trackTasks;
|
|
3016
|
-
|
|
3017
|
-
});
|
|
2855
|
+
return trackTasks;
|
|
3018
2856
|
|
|
2857
|
+
});
|
|
3019
2858
|
/*global define:true */
|
|
3020
2859
|
|
|
3021
2860
|
|
|
3022
2861
|
|
|
3023
2862
|
define('react/log-events',['util'], function (util) { // TODO replace util.inspect with something portable to browser
|
|
2863
|
+
|
|
3024
2864
|
|
|
3025
2865
|
var logEventsMod = { };
|
|
3026
|
-
|
|
2866
|
+
|
|
3027
2867
|
/**
|
|
3028
2868
|
Log events to console.error
|
|
3029
2869
|
|
|
@@ -3035,31 +2875,31 @@ define('react/log-events',['util'], function (util) { // TODO replace util.inspe
|
|
|
3035
2875
|
react.logEvents(flowFn, 'flow.*'); // log all flow events on flowFn only
|
|
3036
2876
|
*/
|
|
3037
2877
|
|
|
3038
|
-
|
|
2878
|
+
var ALL_FLOW_EVENTS = 'flow.*';
|
|
3039
2879
|
var ALL_TASK_EVENTS = 'task.*';
|
|
3040
2880
|
var FLOW_RE = /^flow\./;
|
|
3041
2881
|
|
|
3042
2882
|
function flowLog(obj) {
|
|
3043
2883
|
/*jshint validthis: true */
|
|
3044
2884
|
var time = new Date();
|
|
3045
|
-
|
|
2885
|
+
time.setTime(obj.startTime);
|
|
3046
2886
|
var argsNoCb = obj.args.filter(function (a) { return (typeof(a) !== 'function'); });
|
|
3047
2887
|
var eventTimeStr = time.toISOString();
|
|
3048
2888
|
if (this.event === 'flow.complete') {
|
|
3049
|
-
var env = obj;
|
|
2889
|
+
var env = obj;
|
|
3050
2890
|
console.error('%s: %s \tmsecs: %s \n\targs: %s \n\tresults: %s\n',
|
|
3051
|
-
this.event, env.name, env.elapsedTime, util.inspect(argsNoCb), util.inspect(env.results));
|
|
2891
|
+
this.event, env.name, env.elapsedTime, util.inspect(argsNoCb), util.inspect(env.results));
|
|
3052
2892
|
} else {
|
|
3053
2893
|
var name = obj.name;
|
|
3054
2894
|
var args = obj.args;
|
|
3055
2895
|
console.error('%s: %s \n\targs: %s\n', this.event, name, util.inspect(argsNoCb));
|
|
3056
|
-
}
|
|
2896
|
+
}
|
|
3057
2897
|
}
|
|
3058
2898
|
|
|
3059
2899
|
function taskLog(obj) {
|
|
3060
2900
|
/*jshint validthis: true */
|
|
3061
2901
|
var time = new Date();
|
|
3062
|
-
time.setTime(obj.
|
|
2902
|
+
time.setTime(obj.startTime);
|
|
3063
2903
|
var argsNoCb = obj.args.filter(function (a) { return (typeof(a) !== 'function'); });
|
|
3064
2904
|
var eventTimeStr = time.toISOString();
|
|
3065
2905
|
if (this.event === 'task.complete') {
|
|
@@ -3071,46 +2911,55 @@ define('react/log-events',['util'], function (util) { // TODO replace util.inspe
|
|
|
3071
2911
|
var args = obj.args;
|
|
3072
2912
|
console.error('%s: %s:%s \n\targs: %s\n', this.event, obj.env.name, obj.name, util.inspect(argsNoCb));
|
|
3073
2913
|
}
|
|
3074
|
-
|
|
2914
|
+
|
|
3075
2915
|
}
|
|
3076
2916
|
|
|
3077
2917
|
/**
|
|
3078
2918
|
Log flow and task events for a flowFn or all of react.
|
|
3079
2919
|
If called multiple times, remove previous listener (if any) before
|
|
3080
2920
|
adding.
|
|
3081
|
-
|
|
2921
|
+
|
|
3082
2922
|
@example
|
|
3083
2923
|
var react = require('react');
|
|
3084
2924
|
react.logEvents(flowFn, eventWildcard); //log events on flowfn matching wildcard
|
|
3085
|
-
|
|
2925
|
+
|
|
3086
2926
|
@param flowFn Flow function or global react object
|
|
3087
2927
|
@param eventWildcard wildcarded event type, if not provided use flow.* and task.*
|
|
3088
2928
|
*/
|
|
3089
2929
|
function logEvents(flowFn, eventWildcard) {
|
|
3090
2930
|
if (!flowFn) throw new Error('flowFn is required');
|
|
3091
|
-
if (
|
|
2931
|
+
if (!flowFn.events._loggingEvents) flowFn.events._loggingEvents = [];
|
|
2932
|
+
if (eventWildcard === false) { // turn off logging
|
|
2933
|
+
flowFn.events._loggingEvents.forEach(function (evt) {
|
|
2934
|
+
flowFn.events.removeAllListeners(evt);
|
|
2935
|
+
});
|
|
2936
|
+
flowFn.events._loggingEvents.length = 0; // clear
|
|
2937
|
+
} else if (eventWildcard && eventWildcard !== '*') {
|
|
3092
2938
|
var logFn = (FLOW_RE.test(eventWildcard)) ? flowLog : taskLog;
|
|
3093
2939
|
flowFn.events.removeListener(eventWildcard, logFn);
|
|
3094
2940
|
flowFn.events.on(eventWildcard, logFn);
|
|
2941
|
+
flowFn.events._loggingEvents.push(eventWildcard);
|
|
3095
2942
|
} else { // none provided, use flow.* and task.*
|
|
3096
2943
|
//output events as tasks start and complete
|
|
3097
2944
|
flowFn.events.removeListener(ALL_FLOW_EVENTS, flowLog);
|
|
3098
2945
|
flowFn.events.on(ALL_FLOW_EVENTS, flowLog);
|
|
2946
|
+
flowFn.events._loggingEvents.push(ALL_FLOW_EVENTS);
|
|
3099
2947
|
flowFn.events.removeListener(ALL_TASK_EVENTS, taskLog);
|
|
3100
|
-
flowFn.events.on(ALL_TASK_EVENTS, taskLog);
|
|
2948
|
+
flowFn.events.on(ALL_TASK_EVENTS, taskLog);
|
|
2949
|
+
flowFn.events._loggingEvents.push(ALL_TASK_EVENTS);
|
|
3101
2950
|
}
|
|
3102
2951
|
}
|
|
3103
2952
|
|
|
3104
2953
|
logEventsMod.logEvents = logEvents;
|
|
3105
2954
|
return logEventsMod;
|
|
3106
2955
|
|
|
3107
|
-
});
|
|
3108
|
-
|
|
2956
|
+
});
|
|
3109
2957
|
/*global define:true */
|
|
3110
2958
|
|
|
3111
2959
|
|
|
3112
2960
|
|
|
3113
2961
|
define('react/promise-resolve',[], function () {
|
|
2962
|
+
|
|
3114
2963
|
|
|
3115
2964
|
/**
|
|
3116
2965
|
Auto resolve promises passed in as arguments to the flow
|
|
@@ -3122,9 +2971,9 @@ define('react/promise-resolve',[], function () {
|
|
|
3122
2971
|
*/
|
|
3123
2972
|
|
|
3124
2973
|
|
|
3125
|
-
|
|
2974
|
+
var PROMISE_SUFFIX = '__promise'; // added to param names that are promises
|
|
3126
2975
|
|
|
3127
|
-
|
|
2976
|
+
var resolvingPromises = false;
|
|
3128
2977
|
|
|
3129
2978
|
function resolvePromises(react) {
|
|
3130
2979
|
if (resolvingPromises) return; // already resolving
|
|
@@ -3152,13 +3001,13 @@ define('react/promise-resolve',[], function () {
|
|
|
3152
3001
|
|
|
3153
3002
|
return resolvePromises;
|
|
3154
3003
|
|
|
3155
|
-
});
|
|
3156
|
-
|
|
3004
|
+
});
|
|
3157
3005
|
/*global define:true */
|
|
3158
3006
|
|
|
3159
3007
|
|
|
3160
3008
|
|
|
3161
3009
|
define('react/event-collector',[], function () {
|
|
3010
|
+
|
|
3162
3011
|
|
|
3163
3012
|
/**
|
|
3164
3013
|
create an instance of the event collector
|
|
@@ -3211,9 +3060,9 @@ define('react/event-collector',[], function () {
|
|
|
3211
3060
|
} else if (TASK_EVENTS_RE.test(this.event)) {
|
|
3212
3061
|
eventObject.task = obj;
|
|
3213
3062
|
} else if (AST_EVENTS_RE.test(this.event)) {
|
|
3214
|
-
eventObject.ast = obj;
|
|
3063
|
+
eventObject.ast = obj;
|
|
3215
3064
|
}
|
|
3216
|
-
self.events.push(eventObject);
|
|
3065
|
+
self.events.push(eventObject);
|
|
3217
3066
|
}
|
|
3218
3067
|
emitter.on(eventId, accumEvents);
|
|
3219
3068
|
};
|
|
@@ -3226,22 +3075,22 @@ define('react/event-collector',[], function () {
|
|
|
3226
3075
|
this.events = []; // clear
|
|
3227
3076
|
};
|
|
3228
3077
|
|
|
3229
|
-
return new EventCollector();
|
|
3078
|
+
return new EventCollector();
|
|
3230
3079
|
}
|
|
3231
3080
|
|
|
3232
3081
|
return instantiate; // return the factory for creating EventCollector
|
|
3233
|
-
|
|
3234
|
-
});
|
|
3235
3082
|
|
|
3083
|
+
});
|
|
3236
3084
|
/*global define:true */
|
|
3237
3085
|
|
|
3238
3086
|
|
|
3239
3087
|
|
|
3240
|
-
define('react',['./core', './dsl', './track-tasks', './log-events', './promise-resolve', './event-collector'],
|
|
3088
|
+
define('react/react',['./core', './dsl', './track-tasks', './log-events', './promise-resolve', './event-collector'],
|
|
3241
3089
|
function (core, dsl, trackTasksFn, logEventsMod, resolvePromisesFn, eventCollectorFactory) {
|
|
3090
|
+
|
|
3242
3091
|
|
|
3243
3092
|
var react = dsl; // core + default dsl
|
|
3244
|
-
|
|
3093
|
+
|
|
3245
3094
|
/**
|
|
3246
3095
|
Enable detection of promises and resolution
|
|
3247
3096
|
*/
|
|
@@ -3255,8 +3104,8 @@ define('react',['./core', './dsl', './track-tasks', './log-events', './promise-r
|
|
|
3255
3104
|
*/
|
|
3256
3105
|
function trackTasks() {
|
|
3257
3106
|
trackTasksFn(react);
|
|
3258
|
-
}
|
|
3259
|
-
|
|
3107
|
+
}
|
|
3108
|
+
|
|
3260
3109
|
/**
|
|
3261
3110
|
If called, load the built-in plugin for log events and invoke
|
|
3262
3111
|
|
|
@@ -3264,7 +3113,7 @@ define('react',['./core', './dsl', './track-tasks', './log-events', './promise-r
|
|
|
3264
3113
|
@param eventWildcard [string] pattern to log events for
|
|
3265
3114
|
*/
|
|
3266
3115
|
function logEvents(flowFn, eventWildcard) {
|
|
3267
|
-
if (
|
|
3116
|
+
if (typeof(flowFn) !== 'function') { // only wildcard provided
|
|
3268
3117
|
eventWildcard = flowFn;
|
|
3269
3118
|
flowFn = undefined;
|
|
3270
3119
|
}
|
|
@@ -3285,7 +3134,8 @@ define('react',['./core', './dsl', './track-tasks', './log-events', './promise-r
|
|
|
3285
3134
|
react.logEvents = logEvents; // enable event logging
|
|
3286
3135
|
react.resolvePromises = resolvePromises; // enable promise resolution
|
|
3287
3136
|
react.trackTasks = trackTasks; // enable tracking of tasks
|
|
3288
|
-
react.createEventCollector = createEventCollector; // create instance of EventCollector
|
|
3137
|
+
react.createEventCollector = createEventCollector; // create instance of EventCollector
|
|
3289
3138
|
return react;
|
|
3290
|
-
|
|
3291
|
-
});
|
|
3139
|
+
|
|
3140
|
+
});
|
|
3141
|
+
define('react', ['react/react'], function (main) { return main; });
|