react 0.6.3 → 0.9.0-rc1
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/README.md +10 -222
- package/addons.js +1 -0
- package/lib/AutoFocusMixin.js +30 -0
- package/lib/CSSCore.js +115 -0
- package/lib/CSSProperty.js +121 -0
- package/lib/CSSPropertyOperations.js +97 -0
- package/lib/ChangeEventPlugin.js +387 -0
- package/lib/ClientReactRootIndex.js +30 -0
- package/lib/CompositionEventPlugin.js +260 -0
- package/lib/DOMChildrenOperations.js +165 -0
- package/lib/DOMProperty.js +268 -0
- package/lib/DOMPropertyOperations.js +181 -0
- package/lib/Danger.js +187 -0
- package/lib/DefaultDOMPropertyConfig.js +197 -0
- package/lib/DefaultEventPluginOrder.js +44 -0
- package/lib/EnterLeaveEventPlugin.js +145 -0
- package/lib/EventConstants.js +76 -0
- package/lib/EventListener.js +69 -0
- package/lib/EventPluginHub.js +291 -0
- package/lib/EventPluginRegistry.js +260 -0
- package/lib/EventPluginUtils.js +214 -0
- package/lib/EventPropagators.js +143 -0
- package/lib/ExecutionEnvironment.js +44 -0
- package/lib/LinkedStateMixin.js +46 -0
- package/lib/LinkedValueUtils.js +161 -0
- package/lib/MobileSafariClickEventPlugin.js +63 -0
- package/lib/PooledClass.js +119 -0
- package/lib/React.js +95 -0
- package/lib/ReactCSSTransitionGroup.js +65 -0
- package/lib/ReactCSSTransitionGroupChild.js +138 -0
- package/lib/ReactChildren.js +132 -0
- package/lib/ReactComponent.js +550 -0
- package/lib/ReactComponentBrowserEnvironment.js +158 -0
- package/lib/ReactComponentEnvironment.js +26 -0
- package/lib/ReactCompositeComponent.js +1455 -0
- package/lib/ReactContext.js +67 -0
- package/lib/ReactCurrentOwner.js +39 -0
- package/lib/ReactDOM.js +207 -0
- package/lib/ReactDOMButton.js +68 -0
- package/lib/ReactDOMComponent.js +399 -0
- package/lib/ReactDOMForm.js +59 -0
- package/lib/ReactDOMIDOperations.js +218 -0
- package/lib/ReactDOMImg.js +58 -0
- package/lib/ReactDOMInput.js +181 -0
- package/lib/ReactDOMOption.js +51 -0
- package/lib/ReactDOMSelect.js +179 -0
- package/lib/ReactDOMSelection.js +189 -0
- package/lib/ReactDOMTextarea.js +140 -0
- package/lib/ReactDefaultBatchingStrategy.js +75 -0
- package/lib/ReactDefaultInjection.js +115 -0
- package/lib/ReactDefaultPerf.js +244 -0
- package/lib/ReactDefaultPerfAnalysis.js +199 -0
- package/lib/ReactErrorUtils.js +37 -0
- package/lib/ReactEventEmitter.js +337 -0
- package/lib/ReactEventEmitterMixin.js +57 -0
- package/lib/ReactEventTopLevelCallback.js +109 -0
- package/lib/ReactInjection.js +39 -0
- package/lib/ReactInputSelection.js +140 -0
- package/lib/ReactInstanceHandles.js +338 -0
- package/lib/ReactLink.js +54 -0
- package/lib/ReactMarkupChecksum.js +53 -0
- package/lib/ReactMount.js +641 -0
- package/lib/ReactMountReady.js +95 -0
- package/lib/ReactMultiChild.js +425 -0
- package/lib/ReactMultiChildUpdateTypes.js +38 -0
- package/lib/ReactOwner.js +154 -0
- package/lib/ReactPerf.js +85 -0
- package/lib/ReactPropTransferer.js +147 -0
- package/lib/ReactPropTypeLocationNames.js +31 -0
- package/lib/ReactPropTypeLocations.js +29 -0
- package/lib/ReactPropTypes.js +359 -0
- package/lib/ReactPutListenerQueue.js +61 -0
- package/lib/ReactReconcileTransaction.js +181 -0
- package/lib/ReactRootIndex.js +36 -0
- package/lib/ReactServerRendering.js +59 -0
- package/lib/ReactStateSetters.js +111 -0
- package/lib/ReactTextComponent.js +99 -0
- package/lib/ReactTransitionChildMapping.js +106 -0
- package/lib/ReactTransitionEvents.js +97 -0
- package/lib/ReactTransitionGroup.js +187 -0
- package/lib/ReactUpdates.js +148 -0
- package/lib/ReactWithAddons.js +46 -0
- package/lib/SelectEventPlugin.js +200 -0
- package/lib/ServerReactRootIndex.js +36 -0
- package/lib/SimpleEventPlugin.js +413 -0
- package/lib/SyntheticClipboardEvent.js +51 -0
- package/lib/SyntheticCompositionEvent.js +51 -0
- package/lib/SyntheticDragEvent.js +44 -0
- package/lib/SyntheticEvent.js +164 -0
- package/lib/SyntheticFocusEvent.js +44 -0
- package/lib/SyntheticKeyboardEvent.js +58 -0
- package/lib/SyntheticMouseEvent.js +85 -0
- package/lib/SyntheticTouchEvent.js +50 -0
- package/lib/SyntheticUIEvent.js +45 -0
- package/lib/SyntheticWheelEvent.js +66 -0
- package/lib/Transaction.js +276 -0
- package/lib/ViewportMetrics.js +37 -0
- package/lib/accumulate.js +54 -0
- package/lib/adler32.js +39 -0
- package/lib/cloneWithProps.js +59 -0
- package/lib/containsNode.js +49 -0
- package/lib/copyProperties.js +54 -0
- package/lib/createArrayFrom.js +91 -0
- package/lib/createFullPageComponent.js +63 -0
- package/lib/createNodesFromMarkup.js +93 -0
- package/lib/createObjectFrom.js +61 -0
- package/lib/cx.js +44 -0
- package/lib/dangerousStyleValue.js +57 -0
- package/lib/emptyFunction.js +43 -0
- package/lib/escapeTextForBrowser.js +47 -0
- package/lib/flattenChildren.js +57 -0
- package/lib/forEachAccumulated.js +36 -0
- package/lib/getActiveElement.js +34 -0
- package/lib/getEventKey.js +85 -0
- package/lib/getEventTarget.js +36 -0
- package/lib/getMarkupWrap.js +118 -0
- package/lib/getNodeForCharacterOffset.js +80 -0
- package/lib/getReactRootElementInContainer.js +40 -0
- package/lib/getTextContentAccessor.js +42 -0
- package/lib/getUnboundedScrollPosition.js +45 -0
- package/lib/hyphenate.js +35 -0
- package/lib/invariant.js +62 -0
- package/lib/isEventSupported.js +70 -0
- package/lib/isNode.js +33 -0
- package/lib/isTextInputElement.js +49 -0
- package/lib/isTextNode.js +30 -0
- package/lib/joinClasses.js +44 -0
- package/lib/keyMirror.js +58 -0
- package/lib/keyOf.js +41 -0
- package/lib/memoizeStringOnly.js +39 -0
- package/lib/merge.js +37 -0
- package/lib/mergeHelpers.js +136 -0
- package/lib/mergeInto.js +45 -0
- package/lib/mixInto.js +34 -0
- package/lib/objMap.js +47 -0
- package/lib/objMapKeyVal.js +47 -0
- package/lib/onlyChild.js +43 -0
- package/lib/performanceNow.js +42 -0
- package/lib/shallowEqual.js +49 -0
- package/lib/shouldUpdateReactComponent.js +58 -0
- package/lib/toArray.js +75 -0
- package/lib/traverseAllChildren.js +189 -0
- package/lib/warning.js +40 -0
- package/package.json +32 -21
- package/react.js +1 -0
- package/.npmignore +0 -7
- package/.travis.yml +0 -5
- package/Jakefile.js +0 -39
- package/LICENSE +0 -19
- package/browser-test/dist.html +0 -90
- package/browser-test/index.html +0 -86
- package/browser-test/min.html +0 -90
- package/dist/react.js +0 -3107
- package/dist/react.min.js +0 -22
- package/doc/advanced.md +0 -174
- package/doc/color-def.graffle +0 -938
- package/doc/color-def.png +0 -0
- package/doc/simple.dot +0 -25
- package/doc/simple.png +0 -0
- package/examples/longer-example.js +0 -41
- package/examples/simple.js +0 -45
- package/examples/using-ast-directly.js +0 -30
- package/examples/using-events1.js +0 -79
- package/examples/using-log-events.js +0 -43
- package/lib/base-task.js +0 -123
- package/lib/cb-task.js +0 -84
- package/lib/core.js +0 -138
- package/lib/dsl.js +0 -138
- package/lib/error.js +0 -55
- package/lib/event-collector.js +0 -81
- package/lib/event-manager.js +0 -89
- package/lib/eventemitter.js +0 -20
- package/lib/finalcb-first-task.js +0 -68
- package/lib/finalcb-task.js +0 -65
- package/lib/id.js +0 -22
- package/lib/input-parser.js +0 -56
- package/lib/log-events.js +0 -101
- package/lib/parse.js +0 -41
- package/lib/promise-resolve.js +0 -50
- package/lib/promise-task.js +0 -93
- package/lib/react.js +0 -59
- package/lib/ret-task.js +0 -71
- package/lib/sprintf.js +0 -18
- package/lib/status.js +0 -14
- package/lib/task.js +0 -251
- package/lib/track-tasks.js +0 -74
- package/lib/validate.js +0 -159
- package/lib/vcon.js +0 -90
- package/lib/when-task.js +0 -85
- package/src/dist.build.requirejs +0 -20
- package/test/ast.mocha.js +0 -136
- package/test/cb-task.mocha.js +0 -220
- package/test/core-deferred.mocha.js +0 -143
- package/test/core-when.mocha.js +0 -96
- package/test/core.mocha.js +0 -589
- package/test/dsl.mocha.js +0 -350
- package/test/event-manager.mocha.js +0 -119
- package/test/exec-options.mocha.js +0 -48
- package/test/finalcb-task.mocha.js +0 -58
- package/test/input-parser.mocha.js +0 -86
- package/test/log-events.mocha.js +0 -88
- package/test/mocha.opts +0 -2
- package/test/module-use.mocha.js +0 -147
- package/test/promise-auto-resolve.mocha.js +0 -68
- package/test/ret-task.mocha.js +0 -220
- package/test/task.mocha.js +0 -42
- package/test/validate-cb-task.mocha.js +0 -100
- package/test/validate-ret-task.mocha.js +0 -110
- package/test/validate.mocha.js +0 -324
- package/test/vcon.mocha.js +0 -193
- package/vendor/chai/chai.js +0 -2038
- package/vendor/jquery/jquery-1.7.1.js +0 -9266
- package/vendor/jquery/jquery-1.7.1.min.js +0 -4
- package/vendor/mocha/mocha.css +0 -135
- package/vendor/mocha/mocha.js +0 -3589
- package/vendor/node/util.js +0 -531
- package/vendor/requirejs/require.js +0 -2053
- package/vendor/requirejs/require.min.js +0 -33
package/lib/core.js
DELETED
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
/*global define:true */
|
|
3
|
-
|
|
4
|
-
if (typeof define !== 'function') {
|
|
5
|
-
var define = require('amdefine')(module);
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
define(['./eventemitter', './error', './validate', './task', './status',
|
|
9
|
-
'./vcon', './event-manager', './input-parser', './id', './sprintf'],
|
|
10
|
-
function (EventEmitter, error, validate, taskUtil, STATUS,
|
|
11
|
-
VContext, EventManager, inputParser, idGenerator, sprintf) {
|
|
12
|
-
|
|
13
|
-
var reactOptions = {
|
|
14
|
-
stackTraceLimitMin: 30
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
var reactEmitter = EventManager.global; // the top emitter
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
merge global react options with parsed options
|
|
21
|
-
*/
|
|
22
|
-
function mergeOptions(parsedOptions) {
|
|
23
|
-
return Object.keys(reactOptions).reduce(function (accum, k) {
|
|
24
|
-
if (!accum[k]) accum[k] = reactOptions[k];
|
|
25
|
-
return accum;
|
|
26
|
-
}, parsedOptions);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
generate a flow name when one is not provided
|
|
31
|
-
*/
|
|
32
|
-
function generateFlowName() {
|
|
33
|
-
return sprintf('flow_%s', idGenerator.createUniqueId());
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
Creates react function which the AST can be manipulated and then
|
|
38
|
-
is ready to be executed. Can be used directly or a DSL can wrap this
|
|
39
|
-
to provide the AST.
|
|
40
|
-
|
|
41
|
-
@example
|
|
42
|
-
var react = require('react');
|
|
43
|
-
var fn = react();
|
|
44
|
-
var valid2 = fn.setAndValidateAST({
|
|
45
|
-
name: 'optionalName',
|
|
46
|
-
inParams: ['a', 'b'],
|
|
47
|
-
tasks: [
|
|
48
|
-
{ type: 'cb', f: multiply, a: ['a', 'b'], out: ['c'] }
|
|
49
|
-
],
|
|
50
|
-
outTask: { a: ['c'] }
|
|
51
|
-
});
|
|
52
|
-
console.log(fn.ast); // view
|
|
53
|
-
fn(123, 456, cb);
|
|
54
|
-
*/
|
|
55
|
-
function reactFactory() {
|
|
56
|
-
if (arguments.length) throw new Error('react() takes no args, check API');
|
|
57
|
-
|
|
58
|
-
error.ensureStackTraceLimitSet(reactOptions.stackTraceLimitMin);
|
|
59
|
-
var flowEmitter = EventManager.create();
|
|
60
|
-
flowEmitter.parent = reactEmitter;
|
|
61
|
-
|
|
62
|
-
var ast = {
|
|
63
|
-
name: undefined,
|
|
64
|
-
inParams: [],
|
|
65
|
-
tasks: [],
|
|
66
|
-
outTask: {},
|
|
67
|
-
locals: {}
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
function setAndValidateAST(newAST) { //set AST then validate, ret error[]
|
|
71
|
-
Object.keys(newAST).forEach(function (k) { ast[k] = newAST[k]; }); // copy all properties
|
|
72
|
-
var errors = validate(ast);
|
|
73
|
-
if (!errors.length) {
|
|
74
|
-
if (!ast.name) ast.name = generateFlowName();
|
|
75
|
-
taskUtil.nameTasks(ast.tasks); //run this so names can be checked in ast
|
|
76
|
-
}
|
|
77
|
-
if (Object.freeze) { //lets freeze the AST so plugin writers don't accidentally manip the ast
|
|
78
|
-
Object.keys(newAST).forEach(function (k) {
|
|
79
|
-
if (typeof(newAST[k]) === 'object') Object.freeze(newAST[k]);
|
|
80
|
-
});
|
|
81
|
-
Object.freeze(newAST);
|
|
82
|
-
}
|
|
83
|
-
flowEmitter.emit(EventManager.TYPES.AST_DEFINED, ast);
|
|
84
|
-
return errors;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
function exec(arg1, arg2, argN, cb) { // called to execute the flow
|
|
88
|
-
/*jshint validthis: true */
|
|
89
|
-
var args = Array.prototype.slice.call(arguments);
|
|
90
|
-
var env = {
|
|
91
|
-
execId: idGenerator.createUniqueId(),
|
|
92
|
-
args: args,
|
|
93
|
-
ast: ast,
|
|
94
|
-
flowEmitter: flowEmitter
|
|
95
|
-
};
|
|
96
|
-
env.name = ast.name || env.execId;
|
|
97
|
-
flowEmitter.emit(EventManager.TYPES.EXEC_FLOW_START, env); // hook
|
|
98
|
-
var parsedInput = inputParser(args, ast);
|
|
99
|
-
var vCon = VContext.create(parsedInput.args, ast.inParams, ast.locals, this); // create var ctx with in args & locals
|
|
100
|
-
|
|
101
|
-
env.parsedInput = parsedInput;
|
|
102
|
-
env.options = mergeOptions(parsedInput.options);
|
|
103
|
-
env.vCon = vCon;
|
|
104
|
-
env.taskDefs = ast.tasks.slice(); // create copy
|
|
105
|
-
env.outTaskDef = Object.create(ast.outTask); // create copy
|
|
106
|
-
reactEmitter.emit(EventManager.TYPES.EXEC_TASKS_PRECREATE, env); // hook
|
|
107
|
-
|
|
108
|
-
var tasks = env.taskDefs.map(taskUtil.create);
|
|
109
|
-
var tasksByName = taskUtil.nameTasks(tasks); // map names to working tasks
|
|
110
|
-
var outTask = taskUtil.createOutTask(env.outTaskDef, parsedInput.cb, tasks, vCon, env.options, env);
|
|
111
|
-
var handleError = taskUtil.createErrorHandler(vCon, outTask);
|
|
112
|
-
|
|
113
|
-
function contExec() {
|
|
114
|
-
if (!outTask.f) { return; } //stop execution, we already hit an error, f was cleared
|
|
115
|
-
if (outTask.isReady()) return outTask.exec(); // all tasks done, exec cb, return
|
|
116
|
-
taskUtil.findReadyAndExec(vCon, tasks, tasksByName, handleError, contExec, env); //exec tasks that ready to run
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
tasks.forEach(function (t) {
|
|
120
|
-
t.id = idGenerator.createUniqueId();
|
|
121
|
-
t.env = env;
|
|
122
|
-
if (t.prepare) t.prepare(handleError, vCon, contExec, flowEmitter);
|
|
123
|
-
}); // create callbacks
|
|
124
|
-
contExec(); // start things off
|
|
125
|
-
return outTask.retValue; // could return promise
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
var reactFn = exec; // make the exec() the function returned
|
|
129
|
-
reactFn.ast = ast; // put AST hanging off the fn so it can be inspected
|
|
130
|
-
reactFn.setAndValidateAST = setAndValidateAST; // call to set AST and then validate
|
|
131
|
-
reactFn.events = flowEmitter; // used to listen to execution events for this flow
|
|
132
|
-
return reactFn;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
reactFactory.options = reactOptions; // global react options
|
|
136
|
-
reactFactory.events = reactEmitter; // global react emitter
|
|
137
|
-
return reactFactory; // module returns reactFactory to create a react fn
|
|
138
|
-
});
|
package/lib/dsl.js
DELETED
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
/*global define:true */
|
|
3
|
-
|
|
4
|
-
if (typeof define !== 'function') {
|
|
5
|
-
var define = require('amdefine')(module);
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
define(['./sprintf', './core', './parse', './task'],
|
|
9
|
-
function (sprintf, core, parse, taskUtil) {
|
|
10
|
-
/*jshint regexp: false */
|
|
11
|
-
|
|
12
|
-
var MISSING_NAME = 'first flow parameter should be the flow name, but found in/out def: %s';
|
|
13
|
-
var INOUT_PARAMS_NO_MATCH = 'params in wrong format, wanted "foo, bar, cb -> err, baz" - found: %s';
|
|
14
|
-
var MISSING_ERR = 'callback specified, but first out param was not "err", use for clarity. Found in/out def: %s';
|
|
15
|
-
var MISSING_CB = 'found err param, but cb/callback is not specified, is this cb-style async or sync function? Found in/out def: %s';
|
|
16
|
-
var EXTRA_TASKARG = 'extra unmatched task arg: %s';
|
|
17
|
-
|
|
18
|
-
var INOUT_RE = /\->/; // used to detect missing name, in/out as first arg
|
|
19
|
-
var CB_NAMES_RE = /^cb|callback$/i; //cb, Cb, CB, callback, Callback
|
|
20
|
-
var ERR_NAMES_RE = /^err$/i; // err, ERR, Err, ...
|
|
21
|
-
|
|
22
|
-
function filterOutTrailingCbParam(args) { // if has trailing cb | callback param, filter it out
|
|
23
|
-
if (args.length && args[args.length - 1].match(CB_NAMES_RE)) args.pop();
|
|
24
|
-
return args;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function filterOutLeadingErrParam(args) { // if leading err param, filter it out
|
|
28
|
-
if (args.length && args[0].match(ERR_NAMES_RE)) args.shift();
|
|
29
|
-
return args;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
var inOutDefParse = {
|
|
33
|
-
splitStr: '->',
|
|
34
|
-
fn: function (m, origStr) {
|
|
35
|
-
var inParams = parse.splitTrimFilterArgs(m[0]);
|
|
36
|
-
var lastParam = inParams[inParams.length - 1];
|
|
37
|
-
var type = (lastParam && CB_NAMES_RE.test(lastParam)) ? 'cb' : 'ret';
|
|
38
|
-
var outParams = parse.splitTrimFilterArgs(m[1]);
|
|
39
|
-
var firstOutParam = outParams[0];
|
|
40
|
-
if (type === 'cb' && (!firstOutParam || !ERR_NAMES_RE.test(firstOutParam))) {
|
|
41
|
-
throw new Error(sprintf(MISSING_ERR, origStr)); // found cb, but no err param
|
|
42
|
-
} else if (type === 'ret' && firstOutParam && ERR_NAMES_RE.test(firstOutParam)) {
|
|
43
|
-
throw new Error(sprintf(MISSING_CB, origStr)); // found err but not cb param
|
|
44
|
-
}
|
|
45
|
-
return {
|
|
46
|
-
type: type,
|
|
47
|
-
inDef: filterOutTrailingCbParam(inParams),
|
|
48
|
-
outDef: filterOutLeadingErrParam(outParams)
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
function parseInOutParams(str) {
|
|
54
|
-
var objDef = parse.parseStr(str, [inOutDefParse], INOUT_PARAMS_NO_MATCH);
|
|
55
|
-
objDef.inDef = filterOutTrailingCbParam(objDef.inDef);
|
|
56
|
-
return objDef;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
function parseTasks(arr) {
|
|
60
|
-
var tasks = [];
|
|
61
|
-
var fn, obj, result;
|
|
62
|
-
while (arr.length >= 2) {
|
|
63
|
-
obj = {};
|
|
64
|
-
fn = arr.shift();
|
|
65
|
-
result = parseInOutParams(arr.shift());
|
|
66
|
-
if (typeof(arr[0]) === 'object') obj = arr.shift(); // has options, use as obj
|
|
67
|
-
obj.f = fn;
|
|
68
|
-
obj.a = result.inDef;
|
|
69
|
-
var type = result.type;
|
|
70
|
-
obj.out = result.outDef;
|
|
71
|
-
obj.type = type;
|
|
72
|
-
tasks.push(obj);
|
|
73
|
-
}
|
|
74
|
-
if (arr.length) throw new Error(sprintf(EXTRA_TASKARG, arr[0]));
|
|
75
|
-
return tasks;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
Parse the variable arguments into in/out params, options, tasks
|
|
80
|
-
*/
|
|
81
|
-
function parseVargs(vargs) {
|
|
82
|
-
var inOutParamStr = vargs.shift() || '';
|
|
83
|
-
// if next arg is object, shift it off as options
|
|
84
|
-
var options = (vargs.length && typeof(vargs[0]) === 'object') ? vargs.shift() : { };
|
|
85
|
-
var taskDefArr = vargs; // rest are for the tasks
|
|
86
|
-
var defObj = {
|
|
87
|
-
inOutParamStr: inOutParamStr,
|
|
88
|
-
taskDefArr: taskDefArr,
|
|
89
|
-
options: options
|
|
90
|
-
};
|
|
91
|
-
return defObj;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
function dslDefine(name, arg1, arg2, argN) {
|
|
96
|
-
var reactFn = core();
|
|
97
|
-
if (name && INOUT_RE.test(name)) throw new Error(sprintf(MISSING_NAME, name));
|
|
98
|
-
var defObj = parseVargs(Array.prototype.slice.call(arguments, 1)); // name, already used
|
|
99
|
-
var inOutDef = parseInOutParams(defObj.inOutParamStr);
|
|
100
|
-
var ast = {
|
|
101
|
-
name: name,
|
|
102
|
-
inParams: inOutDef.inDef,
|
|
103
|
-
tasks: parseTasks(defObj.taskDefArr),
|
|
104
|
-
outTask: { a: inOutDef.outDef }
|
|
105
|
-
};
|
|
106
|
-
if (defObj.options) Object.keys(defObj.options).forEach(function (k) { ast[k] = defObj.options[k]; });
|
|
107
|
-
var errors = reactFn.setAndValidateAST(ast);
|
|
108
|
-
if (errors.length) {
|
|
109
|
-
var errorStr = errors.join('\n');
|
|
110
|
-
throw new Error(errorStr);
|
|
111
|
-
}
|
|
112
|
-
return reactFn;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
function selectFirst(name, arg1, arg2, argN) {
|
|
116
|
-
var reactFn = core();
|
|
117
|
-
var defObj = parseVargs(Array.prototype.slice.call(arguments, 1)); // name, already used
|
|
118
|
-
var inOutDef = parseInOutParams(defObj.inOutParamStr);
|
|
119
|
-
var tasks = taskUtil.serializeTasks(parseTasks(defObj.taskDefArr));
|
|
120
|
-
var ast = {
|
|
121
|
-
name: name,
|
|
122
|
-
inParams: inOutDef.inDef,
|
|
123
|
-
tasks: tasks,
|
|
124
|
-
outTask: { type: 'finalcbFirst', a: inOutDef.outDef },
|
|
125
|
-
};
|
|
126
|
-
if (defObj.options) Object.keys(defObj.options).forEach(function (k) { ast[k] = defObj.options[k]; });
|
|
127
|
-
var errors = reactFn.setAndValidateAST(ast);
|
|
128
|
-
if (errors.length) {
|
|
129
|
-
var errorStr = errors.join('\n');
|
|
130
|
-
throw new Error(errorStr);
|
|
131
|
-
}
|
|
132
|
-
return reactFn;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
dslDefine.selectFirst = selectFirst;
|
|
136
|
-
return dslDefine;
|
|
137
|
-
|
|
138
|
-
});
|
package/lib/error.js
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
/*global define:true */
|
|
3
|
-
|
|
4
|
-
if (typeof define !== 'function') {
|
|
5
|
-
var define = require('amdefine')(module);
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
define(['util'], function (util) {
|
|
9
|
-
|
|
10
|
-
function ensureStackTraceLimitSet(stackTraceLimit) {
|
|
11
|
-
if (!Error.stackTraceLimit || Error.stackTraceLimit < stackTraceLimit) {
|
|
12
|
-
Error.stackTraceLimit = stackTraceLimit;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
function fName(fn) {
|
|
17
|
-
if (!fn) return 'undefined';
|
|
18
|
-
return (fn && fn.name) ? fn.name : fn;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function formatErrorMeta(err) {
|
|
22
|
-
if (!err.meta) return;
|
|
23
|
-
var vcon = err.meta.vcon;
|
|
24
|
-
var task = err.meta.task;
|
|
25
|
-
var errString = '\n\n';
|
|
26
|
-
if (task && task.f && task.a) {
|
|
27
|
-
errString += ('Error occurs in Task function: ' + fName(task.f) + '(' + task.a.join(',') + ')\n\n');
|
|
28
|
-
}
|
|
29
|
-
if (vcon) {
|
|
30
|
-
errString += 'Variable Context: \n';
|
|
31
|
-
errString += util.inspect(vcon);
|
|
32
|
-
errString += '\n\n';
|
|
33
|
-
}
|
|
34
|
-
if (task && task.f) {
|
|
35
|
-
errString += 'Task Source:\n\n';
|
|
36
|
-
errString += task.f.toString(); //TODO need to pretty print function, gets collapsed
|
|
37
|
-
errString += '\n\n';
|
|
38
|
-
}
|
|
39
|
-
return errString;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
function augmentError(err, meta) {
|
|
43
|
-
if (typeof(err) === 'string') { err = new Error(err); } //props will be lost on non-objects
|
|
44
|
-
var origMsg = err.toString();
|
|
45
|
-
err.meta = meta;
|
|
46
|
-
err.toString = function () { return origMsg + formatErrorMeta(err); };
|
|
47
|
-
return err;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
return {
|
|
51
|
-
ensureStackTraceLimitSet: ensureStackTraceLimitSet,
|
|
52
|
-
augmentError: augmentError
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
});
|
package/lib/event-collector.js
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
/*global define:true */
|
|
3
|
-
|
|
4
|
-
if (typeof define !== 'function') {
|
|
5
|
-
var define = require('amdefine')(module);
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
define([], function () {
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
create an instance of the event collector
|
|
12
|
-
*/
|
|
13
|
-
function instantiate(react) {
|
|
14
|
-
react.trackTasks(); // enable task tracking
|
|
15
|
-
|
|
16
|
-
var AST_EVENTS_RE = /^ast\./;
|
|
17
|
-
var TASK_EVENTS_RE = /^task\./;
|
|
18
|
-
var FLOW_EVENTS_RE = /^flow\./;
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
Accumulator to make it easy to capture events
|
|
22
|
-
|
|
23
|
-
@example
|
|
24
|
-
var react = require('react');
|
|
25
|
-
var collector = react.createEventCollector();
|
|
26
|
-
collector.capture(); // capture all flow and task events for all react flows
|
|
27
|
-
collector.capture('flow.*'); // capture all flow events for all react flows
|
|
28
|
-
collector.capture(flowFn, 'task.*'); // capture task events on a flow
|
|
29
|
-
collector.capture(flowFn, 'flow.*'); // add capture flow events on a flow
|
|
30
|
-
var events = collector.list(); // retrieve the list of events
|
|
31
|
-
collector.clear(); // clear the list of events;
|
|
32
|
-
*/
|
|
33
|
-
function EventCollector() {
|
|
34
|
-
this.events = [];
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
register listener to capture events for a specific flow
|
|
39
|
-
@param flowFn the react flow function or can pass global react
|
|
40
|
-
@param eventId event id or wildcarded id
|
|
41
|
-
*/
|
|
42
|
-
EventCollector.prototype.capture = function (flowFn, eventId) {
|
|
43
|
-
/*jshint validthis: true */
|
|
44
|
-
if (!eventId && typeof(flowFn) === 'string') { // only eventId provided
|
|
45
|
-
eventId = flowFn;
|
|
46
|
-
flowFn = react; // global react
|
|
47
|
-
} else if (!flowFn) flowFn = react; // global react
|
|
48
|
-
if (!eventId) eventId = '*'; // default to all
|
|
49
|
-
var emitter = flowFn.events;
|
|
50
|
-
var self = this;
|
|
51
|
-
function accumEvents(obj) {
|
|
52
|
-
var eventObject = {
|
|
53
|
-
event: this.event,
|
|
54
|
-
time: Date.now()
|
|
55
|
-
};
|
|
56
|
-
if (FLOW_EVENTS_RE.test(this.event)) {
|
|
57
|
-
eventObject.env = obj;
|
|
58
|
-
} else if (TASK_EVENTS_RE.test(this.event)) {
|
|
59
|
-
eventObject.task = obj;
|
|
60
|
-
} else if (AST_EVENTS_RE.test(this.event)) {
|
|
61
|
-
eventObject.ast = obj;
|
|
62
|
-
}
|
|
63
|
-
self.events.push(eventObject);
|
|
64
|
-
}
|
|
65
|
-
emitter.on(eventId, accumEvents);
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
EventCollector.prototype.list = function () {
|
|
69
|
-
return this.events;
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
EventCollector.prototype.clear = function () {
|
|
73
|
-
this.events = []; // clear
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
return new EventCollector();
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
return instantiate; // return the factory for creating EventCollector
|
|
80
|
-
|
|
81
|
-
});
|
package/lib/event-manager.js
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
/*global define:true process:false*/
|
|
3
|
-
|
|
4
|
-
if (typeof define !== 'function') {
|
|
5
|
-
var define = require('amdefine')(module);
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
define(['./eventemitter'], function (EventEmitter) {
|
|
9
|
-
/*jshint regexp:false */
|
|
10
|
-
|
|
11
|
-
var EVENT_EMITTER2_CONFIG = {
|
|
12
|
-
wildcard: true, // should the event emitter use wildcards.
|
|
13
|
-
delimiter: '.', // the delimiter used to segment namespaces, defaults to `.`.
|
|
14
|
-
maxListeners: 30 // the max number of listeners that can be assigned to an event, defaults to 10.
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
var PASS_EVENTS_PROCESS_RE = /^ast.defined$/; // events to pass up to global process
|
|
18
|
-
|
|
19
|
-
var TYPES = {
|
|
20
|
-
// Flow monitoring events and their params
|
|
21
|
-
AST_DEFINED: 'ast.defined', // ast
|
|
22
|
-
FLOW_BEGIN: 'flow.begin', // env
|
|
23
|
-
TASK_BEGIN: 'task.begin', // task
|
|
24
|
-
TASK_COMPLETE: 'task.complete', // task
|
|
25
|
-
TASK_ERRORED: 'task.errored', // task
|
|
26
|
-
FLOW_COMPLETE: 'flow.complete', // env
|
|
27
|
-
FLOW_ERRORED: 'flow.errored', // env
|
|
28
|
-
|
|
29
|
-
// Internal Hooks
|
|
30
|
-
EXEC_FLOW_START: 'exec.flow.start', // env
|
|
31
|
-
EXEC_INPUT_PREPROCESS: 'exec.input.preprocess', // parsedInput
|
|
32
|
-
EXEC_TASKS_PRECREATE: 'exec.tasks.precreate', // env
|
|
33
|
-
EXEC_OUTTASK_CREATE: 'exec.outTask.create', // outTaskOptions
|
|
34
|
-
EXEC_TASK_START: 'exec.task.start', // task
|
|
35
|
-
EXEC_TASK_COMPLETE: 'exec.task.complete', // task
|
|
36
|
-
EXEC_TASK_ERRORED: 'exec.task.errored', // task
|
|
37
|
-
EXEC_FLOW_COMPLETE: 'exec.flow.complete', // env
|
|
38
|
-
EXEC_FLOW_ERRORED: 'exec.flow.errored' // env
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
Event manager which emits events up to its parent if exists.
|
|
43
|
-
Allows a hierarchy of emitters, which communicate up the
|
|
44
|
-
chain.
|
|
45
|
-
*/
|
|
46
|
-
function EventManager() {
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
EventManager.create = function () { return new EventManager(); };
|
|
50
|
-
|
|
51
|
-
EventManager.TYPES = TYPES;
|
|
52
|
-
EventManager.prototype.TYPES = TYPES;
|
|
53
|
-
|
|
54
|
-
EventManager.prototype.isEnabled = function () { // if has listener or an ancestor has listener
|
|
55
|
-
return !!(this.emitter || (this.parent && this.parent.isEnabled()));
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
Add listener. Wildcard events are allowed like 'foo.*'
|
|
60
|
-
Use '*' to listen to any event
|
|
61
|
-
*/
|
|
62
|
-
EventManager.prototype.on = function (event, listener) {
|
|
63
|
-
if (!this.emitter) this.emitter = new EventEmitter(EVENT_EMITTER2_CONFIG);
|
|
64
|
-
if (event === '*') this.emitter.onAny(listener);
|
|
65
|
-
else this.emitter.on(event, listener);
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
EventManager.prototype.emit = function (event, arg1, arg2, argN) {
|
|
69
|
-
if (event === undefined) throw new Error('event is undefined');
|
|
70
|
-
if (this.emitter) this.emitter.emit.apply(this.emitter, arguments);
|
|
71
|
-
if (this.parent && this.parent.isEnabled()) this.parent.emit.apply(this.parent, arguments);
|
|
72
|
-
if (PASS_EVENTS_PROCESS_RE.test(event) && typeof(process) !== 'undefined' && process.emit) {
|
|
73
|
-
process.emit.apply(process, arguments); // pass some to process
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
EventManager.prototype.removeListener = function (event, listener) {
|
|
78
|
-
if (this.emitter) this.emitter.removeListener.apply(this.emitter, arguments);
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
EventManager.prototype.removeAllListeners = function (event) {
|
|
82
|
-
if (this.emitter) this.emitter.removeAllListeners.apply(this.emitter, arguments);
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
EventManager.global = EventManager.create(); // create one top level emitter
|
|
87
|
-
return EventManager;
|
|
88
|
-
|
|
89
|
-
});
|