react 0.6.2 → 0.8.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.
Files changed (204) hide show
  1. package/README.md +15 -217
  2. package/ReactJSErrors.js +40 -0
  3. package/addons.js +4 -0
  4. package/lib/$.js +46 -0
  5. package/lib/CSSCore.js +114 -0
  6. package/lib/CSSProperty.js +90 -0
  7. package/lib/CSSPropertyOperations.js +97 -0
  8. package/lib/CallbackRegistry.js +91 -0
  9. package/lib/ChangeEventPlugin.js +365 -0
  10. package/lib/CompositionEventPlugin.js +212 -0
  11. package/lib/DOMChildrenOperations.js +135 -0
  12. package/lib/DOMProperty.js +266 -0
  13. package/lib/DOMPropertyOperations.js +168 -0
  14. package/lib/Danger.js +186 -0
  15. package/lib/DefaultDOMPropertyConfig.js +187 -0
  16. package/lib/DefaultEventPluginOrder.js +44 -0
  17. package/lib/EnterLeaveEventPlugin.js +112 -0
  18. package/lib/EventConstants.js +73 -0
  19. package/lib/EventListener.js +61 -0
  20. package/lib/EventPluginHub.js +190 -0
  21. package/lib/EventPluginRegistry.js +237 -0
  22. package/lib/EventPluginUtils.js +185 -0
  23. package/lib/EventPropagators.js +179 -0
  24. package/lib/ExecutionEnvironment.js +41 -0
  25. package/lib/LinkedStateMixin.js +46 -0
  26. package/lib/LinkedValueMixin.js +68 -0
  27. package/lib/MobileSafariClickEventPlugin.js +63 -0
  28. package/lib/PooledClass.js +113 -0
  29. package/lib/React.js +71 -0
  30. package/lib/ReactChildren.js +132 -0
  31. package/lib/ReactComponent.js +515 -0
  32. package/lib/ReactComponentBrowserEnvironment.js +140 -0
  33. package/lib/ReactComponentEnvironment.js +24 -0
  34. package/lib/ReactCompositeComponent.js +1020 -0
  35. package/lib/ReactCurrentOwner.js +39 -0
  36. package/lib/ReactDOM.js +194 -0
  37. package/lib/ReactDOMButton.js +64 -0
  38. package/lib/ReactDOMComponent.js +374 -0
  39. package/lib/ReactDOMForm.js +52 -0
  40. package/lib/ReactDOMIDOperations.js +173 -0
  41. package/lib/ReactDOMInput.js +169 -0
  42. package/lib/ReactDOMOption.js +50 -0
  43. package/lib/ReactDOMSelect.js +160 -0
  44. package/lib/ReactDOMSelection.js +189 -0
  45. package/lib/ReactDOMTextarea.js +136 -0
  46. package/lib/ReactDefaultBatchingStrategy.js +75 -0
  47. package/lib/ReactDefaultInjection.js +91 -0
  48. package/lib/ReactDefaultPerf.js +407 -0
  49. package/lib/ReactErrorUtils.js +46 -0
  50. package/lib/ReactEventEmitter.js +341 -0
  51. package/lib/ReactEventEmitterMixin.js +89 -0
  52. package/lib/ReactEventTopLevelCallback.js +89 -0
  53. package/lib/ReactInputSelection.js +140 -0
  54. package/lib/ReactInstanceHandles.js +322 -0
  55. package/lib/ReactLink.js +54 -0
  56. package/lib/ReactMarkupChecksum.js +53 -0
  57. package/lib/ReactMount.js +617 -0
  58. package/lib/ReactMountReady.js +95 -0
  59. package/lib/ReactMultiChild.js +441 -0
  60. package/lib/ReactMultiChildUpdateTypes.js +36 -0
  61. package/lib/ReactOwner.js +146 -0
  62. package/lib/ReactPerf.js +88 -0
  63. package/lib/ReactPropTransferer.js +128 -0
  64. package/lib/ReactPropTypes.js +158 -0
  65. package/lib/ReactReconcileTransaction.js +161 -0
  66. package/lib/ReactServerRendering.js +62 -0
  67. package/lib/ReactStateSetters.js +111 -0
  68. package/lib/ReactTextComponent.js +94 -0
  69. package/lib/ReactTransitionEvents.js +97 -0
  70. package/lib/ReactTransitionGroup.js +112 -0
  71. package/lib/ReactTransitionKeySet.js +111 -0
  72. package/lib/ReactTransitionableChild.js +152 -0
  73. package/lib/ReactUpdates.js +145 -0
  74. package/lib/ReactWithAddons.js +41 -0
  75. package/lib/SelectEventPlugin.js +217 -0
  76. package/lib/SimpleEventPlugin.js +365 -0
  77. package/lib/SyntheticClipboardEvent.js +45 -0
  78. package/lib/SyntheticCompositionEvent.js +51 -0
  79. package/lib/SyntheticEvent.js +163 -0
  80. package/lib/SyntheticFocusEvent.js +44 -0
  81. package/lib/SyntheticKeyboardEvent.js +56 -0
  82. package/lib/SyntheticMouseEvent.js +85 -0
  83. package/lib/SyntheticTouchEvent.js +50 -0
  84. package/lib/SyntheticUIEvent.js +45 -0
  85. package/lib/SyntheticWheelEvent.js +63 -0
  86. package/lib/Transaction.js +251 -0
  87. package/lib/ViewportMetrics.js +37 -0
  88. package/lib/accumulate.js +54 -0
  89. package/lib/adler32.js +39 -0
  90. package/lib/containsNode.js +49 -0
  91. package/lib/copyProperties.js +54 -0
  92. package/lib/createArrayFrom.js +94 -0
  93. package/lib/createNodesFromMarkup.js +93 -0
  94. package/lib/createObjectFrom.js +61 -0
  95. package/lib/cx.js +44 -0
  96. package/lib/dangerousStyleValue.js +57 -0
  97. package/lib/emptyFunction.js +43 -0
  98. package/lib/escapeTextForBrowser.js +47 -0
  99. package/lib/ex.js +49 -0
  100. package/lib/filterAttributes.js +45 -0
  101. package/lib/flattenChildren.js +54 -0
  102. package/lib/forEachAccumulated.js +36 -0
  103. package/lib/ge.js +76 -0
  104. package/lib/getActiveElement.js +33 -0
  105. package/lib/getEventTarget.js +36 -0
  106. package/lib/getMarkupWrap.js +108 -0
  107. package/lib/getNodeForCharacterOffset.js +80 -0
  108. package/lib/getReactRootElementInContainer.js +40 -0
  109. package/lib/getTextContentAccessor.js +40 -0
  110. package/lib/getUnboundedScrollPosition.js +45 -0
  111. package/lib/hyphenate.js +35 -0
  112. package/lib/invariant.js +54 -0
  113. package/lib/isEventSupported.js +74 -0
  114. package/lib/isNode.js +33 -0
  115. package/lib/isTextInputElement.js +49 -0
  116. package/lib/isTextNode.js +30 -0
  117. package/lib/joinClasses.js +44 -0
  118. package/lib/keyMirror.js +58 -0
  119. package/lib/keyOf.js +41 -0
  120. package/lib/memoizeStringOnly.js +39 -0
  121. package/lib/merge.js +37 -0
  122. package/lib/mergeHelpers.js +137 -0
  123. package/lib/mergeInto.js +45 -0
  124. package/lib/mixInto.js +34 -0
  125. package/lib/mutateHTMLNodeWithMarkup.js +100 -0
  126. package/lib/objMap.js +47 -0
  127. package/lib/objMapKeyVal.js +47 -0
  128. package/lib/performanceNow.js +42 -0
  129. package/lib/shallowEqual.js +49 -0
  130. package/lib/traverseAllChildren.js +127 -0
  131. package/package.json +33 -21
  132. package/react.js +4 -0
  133. package/.npmignore +0 -7
  134. package/.travis.yml +0 -5
  135. package/Jakefile.js +0 -39
  136. package/LICENSE +0 -19
  137. package/browser-test/dist.html +0 -89
  138. package/browser-test/index.html +0 -85
  139. package/browser-test/min.html +0 -89
  140. package/dist/react.js +0 -3094
  141. package/dist/react.min.js +0 -22
  142. package/doc/advanced.md +0 -166
  143. package/doc/color-def.graffle +0 -938
  144. package/doc/color-def.png +0 -0
  145. package/doc/simple.dot +0 -25
  146. package/doc/simple.png +0 -0
  147. package/examples/longer-example.js +0 -41
  148. package/examples/simple.js +0 -45
  149. package/examples/using-ast-directly.js +0 -30
  150. package/examples/using-events1.js +0 -79
  151. package/examples/using-log-events.js +0 -43
  152. package/lib/base-task.js +0 -123
  153. package/lib/cb-task.js +0 -84
  154. package/lib/core.js +0 -138
  155. package/lib/dsl.js +0 -138
  156. package/lib/error.js +0 -55
  157. package/lib/event-collector.js +0 -81
  158. package/lib/event-manager.js +0 -85
  159. package/lib/eventemitter.js +0 -20
  160. package/lib/finalcb-first-task.js +0 -68
  161. package/lib/finalcb-task.js +0 -65
  162. package/lib/id.js +0 -22
  163. package/lib/input-parser.js +0 -56
  164. package/lib/log-events.js +0 -92
  165. package/lib/parse.js +0 -41
  166. package/lib/promise-resolve.js +0 -50
  167. package/lib/promise-task.js +0 -93
  168. package/lib/react.js +0 -59
  169. package/lib/ret-task.js +0 -71
  170. package/lib/sprintf.js +0 -18
  171. package/lib/status.js +0 -14
  172. package/lib/task.js +0 -251
  173. package/lib/track-tasks.js +0 -74
  174. package/lib/validate.js +0 -159
  175. package/lib/vcon.js +0 -90
  176. package/lib/when-task.js +0 -85
  177. package/src/dist.build.requirejs +0 -20
  178. package/test/ast.mocha.js +0 -136
  179. package/test/cb-task.mocha.js +0 -220
  180. package/test/core-deferred.mocha.js +0 -143
  181. package/test/core-when.mocha.js +0 -96
  182. package/test/core.mocha.js +0 -589
  183. package/test/dsl.mocha.js +0 -350
  184. package/test/event-manager.mocha.js +0 -119
  185. package/test/exec-options.mocha.js +0 -48
  186. package/test/finalcb-task.mocha.js +0 -58
  187. package/test/input-parser.mocha.js +0 -86
  188. package/test/mocha.opts +0 -2
  189. package/test/module-use.mocha.js +0 -147
  190. package/test/promise-auto-resolve.mocha.js +0 -68
  191. package/test/ret-task.mocha.js +0 -220
  192. package/test/task.mocha.js +0 -42
  193. package/test/validate-cb-task.mocha.js +0 -100
  194. package/test/validate-ret-task.mocha.js +0 -110
  195. package/test/validate.mocha.js +0 -324
  196. package/test/vcon.mocha.js +0 -193
  197. package/vendor/chai/chai.js +0 -2038
  198. package/vendor/jquery/jquery-1.7.1.js +0 -9266
  199. package/vendor/jquery/jquery-1.7.1.min.js +0 -4
  200. package/vendor/mocha/mocha.css +0 -135
  201. package/vendor/mocha/mocha.js +0 -3589
  202. package/vendor/node/util.js +0 -531
  203. package/vendor/requirejs/require.js +0 -2053
  204. package/vendor/requirejs/require.min.js +0 -33
package/lib/validate.js DELETED
@@ -1,159 +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', './sprintf', 'ensure-array', './task'], function (util, sprintf, array, taskUtil) {
9
- /*jshint latedef:false */
10
-
11
- var AST_IS_OBJECT = 'ast must be an object with inParams, tasks, and outTask';
12
- var INPARAMS_ARR_STR = 'ast.inParams must be an array of strings';
13
- var TASKS_ARR = 'ast.tasks must be an array of tasks';
14
- var NAMES_UNIQUE = 'ast.tasks that specify name need to be unique, duplicate:';
15
- var LOCALS_NOTNULL = 'ast.locals should not be null';
16
- var DUP_OUTPUTS = 'multiple tasks output the same param, must be unique. param';
17
- var MISSING_INPUTS = 'missing or mispelled variable referenced in flow definition: %s';
18
-
19
- // match any of our literals true, false, int, float, quoted strings, or is property (has dot), match vcon.js
20
- var LITERAL_OR_PROP_RE = /^(true|false|this|null|\-?[0-9\.]+)$|'|"|\./i;
21
-
22
- function format_error(errmsg, obj) {
23
- return sprintf('%s - %s', errmsg, util.inspect(obj));
24
- }
25
-
26
- /**
27
- true if is a literal name
28
- */
29
- function isLiteralOrProp(name) { // need to match what is in vcon.js, TODO consolidate?
30
- return LITERAL_OR_PROP_RE.test(name);
31
- }
32
-
33
- /**
34
- validate the AST return Errors
35
- @example
36
- var validate = require('./validate');
37
- var errors = validate(ast);
38
- @returns array of errors, could be empty
39
- */
40
- function validate(ast) {
41
- if (!ast || !ast.inParams || !ast.tasks || !ast.outTask) return [AST_IS_OBJECT];
42
- var errors = [];
43
- errors = errors.concat(validateInParams(ast.inParams));
44
- errors = errors.concat(validateTasks(ast.tasks));
45
- errors = errors.concat(validateTaskNamesUnique(ast.tasks));
46
- errors = errors.concat(taskUtil.validateOutTask(ast.outTask));
47
- errors = errors.concat(validateLocals(ast.locals));
48
- if (errors.length === 0) { // if no errors do additional validation
49
- if (ast.outTask.type !== 'finalcbFirst') errors = errors.concat(validateOuputsUnique(ast.tasks));
50
- errors = errors.concat(taskUtil.validateLocalFunctions(ast.inParams, ast.tasks, ast.locals));
51
- errors = errors.concat(validateNoMissingNames(ast));
52
- }
53
- return errors;
54
- }
55
-
56
- /**
57
- @returns array of errors, could be empty
58
- */
59
- function validateInParams(inParams) {
60
- if (!Array.isArray(inParams) ||
61
- !inParams.every(function (x) { return (typeof(x) === 'string'); })) {
62
- return [INPARAMS_ARR_STR];
63
- }
64
- return [];
65
- }
66
-
67
- /**
68
- @returns array of errors, could be empty
69
- */
70
- function validateTasks(tasks) {
71
- if (!Array.isArray(tasks)) return [TASKS_ARR];
72
- var errors = [];
73
- tasks.forEach(function (t) {
74
- errors = errors.concat(taskUtil.validate(t));
75
- });
76
- return errors;
77
- }
78
-
79
- function validateTaskNamesUnique(tasks) {
80
- if (!Array.isArray(tasks)) return [];
81
- var errors = [];
82
- var namedTasks = tasks.filter(function (t) { return (t.name); });
83
- var names = namedTasks.map(function (t) { return t.name; });
84
- names.reduce(function (accum, name) {
85
- if (accum[name]) errors.push(sprintf('%s %s', NAMES_UNIQUE, name));
86
- else accum[name] = true;
87
- return accum;
88
- }, {});
89
- return errors;
90
- }
91
-
92
- function validateLocals(locals) {
93
- var errors = [];
94
- if (locals === null) errors.push(LOCALS_NOTNULL);
95
- return errors;
96
- }
97
-
98
- function getOutputParams(taskDef) {
99
- return array(taskDef.out); //ensure array
100
- }
101
-
102
- function validateOuputsUnique(taskDefs) {
103
- var errors = [];
104
- taskDefs.reduce(function (accum, t) {
105
- getOutputParams(t).forEach(function (param) {
106
- if (accum[param] !== undefined) errors.push(sprintf('%s: %s', DUP_OUTPUTS, param));
107
- else accum[param] = true;
108
- });
109
- return accum;
110
- }, {});
111
- return errors;
112
- }
113
-
114
-
115
- /**
116
- validate there are no missing or mispelled param names in any task inputs
117
- or the final task output
118
-
119
- @return array of errors, or empty array if none
120
- */
121
- function validateNoMissingNames(ast) {
122
- var errors = [];
123
- var names = {};
124
- if (ast.locals) {
125
- names = Object.keys(ast.locals).reduce(function (accum, k) { // start with locals
126
- accum[k] = true;
127
- return accum;
128
- }, names);
129
- }
130
- ast.inParams.reduce(function (accum, p) { // add input params
131
- accum[p] = true;
132
- return accum;
133
- }, names);
134
- ast.tasks.reduce(function (accum, t) { // add task outputs
135
- return t.out.reduce(function (innerAccum, p) {
136
- innerAccum[p] = true;
137
- return innerAccum;
138
- }, accum);
139
- }, names);
140
-
141
- // now we have all possible provided vars, check task inputs are accounted for
142
- ast.tasks.reduce(function (accum, t) { // for all tasks
143
- return t.a.reduce(function (innerAccum, p) { // for all in params, except property
144
- if (!isLiteralOrProp(p) && !names[p]) innerAccum.push(sprintf(MISSING_INPUTS, p)); // add error if missing
145
- return innerAccum;
146
- }, accum);
147
- }, errors);
148
-
149
- // now check the final task outputs
150
- ast.outTask.a.reduce(function (accum, p) { // for final task out params
151
- if (!isLiteralOrProp(p) && !names[p]) accum.push(sprintf(MISSING_INPUTS, p)); // add error if missing
152
- return accum;
153
- }, errors);
154
- return errors;
155
- }
156
-
157
- return validate;
158
-
159
- });
package/lib/vcon.js DELETED
@@ -1,90 +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
- var LAST_RESULTS_KEY = ':LAST_RESULTS';
11
-
12
- function VContext() {
13
- }
14
-
15
- VContext.prototype.getLastResults = function () { return this.getVar(LAST_RESULTS_KEY); };
16
- VContext.prototype.setLastResults = function (args) { this.setVar(LAST_RESULTS_KEY, args); };
17
-
18
- VContext.prototype.getVar = function (name) { //name might be simple or obj.prop, also literals
19
- /*jshint regexp: false */
20
- var vConValues = this.values;
21
- if (typeof(name) !== 'string') return name; // literal boolean or number
22
- name = name.trim();
23
- // literal checks need to match what is in validate.js
24
- if (name === 'true') return true;
25
- if (name === 'false') return false;
26
- if (name === 'null') return null;
27
- if (/^-?[0-9]+$/.test(name)) return parseInt(name, 10); //int
28
- if (/^-?[0-9.]+$/.test(name)) return parseFloat(name); //float
29
- var m = /^("|')([^\1]*)\1$/.exec(name); //check for quoted string " or '
30
- if (m) return m[2]; // if is quoted str, return inside of the quotes
31
- var nameAndProps = name.split('.');
32
- return nameAndProps.reduce(function (accObj, prop) {
33
- if (accObj === undefined || accObj === null) return undefined; // prevent exception
34
- return accObj[prop];
35
- }, vConValues); // vCon['foo']['bar']
36
- };
37
-
38
- /**
39
- Saves all the results from a task as a unit, also sets special
40
- variable :LAST_RESULTS which keeps an array of the last values
41
- which can be used for chaining and testing last results, etc.
42
- */
43
- VContext.prototype.saveResults = function (paramArr, valuesArr) { // set values for params
44
- var self = this;
45
- paramArr.forEach(function (k, idx) { //save values to v context
46
- self.setVar(k, (valuesArr[idx] !== undefined) ? valuesArr[idx] : null); //upgrade any undefined to null
47
- });
48
- this.setLastResults(valuesArr);
49
- };
50
-
51
- VContext.prototype.setVar = function (name, value) { //name might be simple or obj.prop
52
- if (!name) return; // if name is undefined or null, then discard
53
- var vConValues = this.values;
54
- var nameAndProps = name.split('.');
55
- var lastProp = nameAndProps.pop();
56
- var obj = nameAndProps.reduce(function (accObj, prop) {
57
- var o = accObj[prop];
58
- if (o === undefined || o === null) { // if doesn't exist create it
59
- o = accObj[prop] = { };
60
- }
61
- return o;
62
- }, vConValues); // vCon['foo']['bar']
63
- obj[lastProp] = value;
64
- };
65
-
66
-
67
- /**
68
- Create Variable Context using arguments passed in.
69
- Ignore extra arguments passed in. Locals can be
70
- passed into seed the VContext otherwise empty {}
71
- will be used
72
- @param self used to pass 'this' context in
73
- */
74
- VContext.create = function (args, inParams, locals, self) {
75
- var initValues = {};
76
- if (self) initValues['this'] = self;
77
- if (locals) Object.keys(locals).forEach(function (k) { initValues[k] = locals[k]; }); // copy over keys
78
- var vContext = new VContext();
79
- vContext.values = args.reduce(function (vcon, x, idx) { // create vCon start with input args
80
- var param = inParams[idx];
81
- if (param) vcon[param] = (x !== undefined) ? x : null; // upgrade undefined to null
82
- return vcon;
83
- }, initValues);
84
- return vContext;
85
- };
86
-
87
-
88
- return VContext;
89
-
90
- });
package/lib/when-task.js DELETED
@@ -1,85 +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', './sprintf', './base-task'], function (util, sprintf, BaseTask) {
9
-
10
- /**
11
- When task which checks if is a promise (has a then method)
12
- and waits for it to resolve.
13
-
14
- If argument does not have a then method, it resolves immediately
15
- */
16
-
17
- function format_error(errmsg, obj) {
18
- return sprintf('%s - %s', errmsg, util.inspect(obj));
19
- }
20
-
21
- var REQ = 'whenTask requires a, out';
22
- var A_REQ = 'whenTask requires a to be an array[1] of string param names';
23
- var OUT_REQ = 'whenTask requires out to be an array[1] of string param names';
24
-
25
- function WhenTask(taskDef) {
26
- var self = this;
27
- Object.keys(taskDef).forEach(function (k) { self[k] = taskDef[k]; });
28
- }
29
-
30
- WhenTask.prototype = new BaseTask();
31
- WhenTask.prototype.constructor = WhenTask;
32
-
33
- WhenTask.prototype.f = function when() { // just here to keep validations happy
34
- }
35
-
36
- WhenTask.validate = function (taskDef) {
37
- var errors = [];
38
- if (!taskDef.a || !taskDef.out) {
39
- errors.push(format_error(REQ, taskDef));
40
- } else {
41
- if (! (Array.isArray(taskDef.a) && taskDef.a.length === 1 &&
42
- taskDef.a.every(function (x) { return (typeof(x) === 'string'); }))) {
43
- errors.push(format_error(A_REQ, taskDef));
44
- }
45
- if (! (Array.isArray(taskDef.out) && taskDef.out.length <= 1 &&
46
- taskDef.out.every(function (x) { return (typeof(x) === 'string'); }))) {
47
- errors.push(format_error(OUT_REQ, taskDef));
48
- }
49
- }
50
- return errors;
51
- };
52
-
53
- WhenTask.prototype.prepare = function prepare(handleTaskError, vCon, contExec) {
54
- var self = this;
55
- this.nextFn = function (arg) {
56
- var args = Array.prototype.slice.call(arguments);
57
- vCon.saveResults(self.out, args);
58
- self.complete(args);
59
- contExec();
60
- };
61
- this.failFn = function (err) {
62
- handleTaskError(self, err);
63
- };
64
- };
65
-
66
- WhenTask.prototype.exec = function exec(vCon, handleError, contExec) {
67
- try {
68
- var args = this.a.map(function (k) { return vCon.getVar(k); }); //get args from vCon
69
- //console.error('WhenTask.exec.args=', args);
70
- //console.error('WhenTask.exec.vCon=', vCon);
71
- this.start(args); //note the start time, args
72
- var arg = args[0]; // one value allowed
73
- if (arg && typeof(arg.then) === 'function') { // is a promise
74
- arg.then(this.nextFn, this.failFn);
75
- } else { // not a promise continue immediately
76
- this.nextFn(arg);
77
- }
78
- } catch (err) { //catch and handle the task error, calling final cb
79
- handleError(this, err);
80
- }
81
- };
82
-
83
- return WhenTask;
84
-
85
- });
@@ -1,20 +0,0 @@
1
- ({
2
- baseUrl: "..",
3
- optimize: "none",
4
- packages: [
5
- {
6
- name: "react",
7
- location: "lib",
8
- main: "react"
9
- }
10
- ],
11
- paths: {
12
- jQuery: "empty:",
13
- eventemitter2: "node_modules/eventemitter2/lib/eventemitter2",
14
- util: "vendor/node/util",
15
- sprint: "node_modules/sprint/lib/sprint",
16
- "ensure-array": "node_modules/ensure-array/ensure-array"
17
- },
18
- name: "react",
19
- out: "dist/react.js"
20
- })
package/test/ast.mocha.js DELETED
@@ -1,136 +0,0 @@
1
- 'use strict';
2
- /*global react:true */
3
-
4
- if (typeof(chai) === 'undefined') {
5
- var chai = require('chai');
6
- }
7
-
8
- if (typeof(react) === 'undefined') {
9
- var react = require('../'); //require('react');
10
- }
11
-
12
- (function () {
13
-
14
- var t = chai.assert;
15
-
16
- /**
17
- Testing ast
18
- */
19
-
20
-
21
- suite('ast');
22
-
23
- function load(res, cb) { cb(null, res + '-loaded'); }
24
- function prefix(prefstr, str, cb) { cb(null, prefstr + str); }
25
- function postfix(str, poststr, cb) { cb(null, str + poststr); }
26
- function upper(str) { return str.toUpperCase(); }
27
- function makeError(str, cb) { cb(new Error('makeErr-' + str)); }
28
-
29
- test('mixed', function (done) {
30
- var fn = react();
31
- var errors = fn.setAndValidateAST({
32
- inParams: ['res', 'prefstr', 'poststr'],
33
- tasks: [
34
- { f: load, a: ['res'], out: ['lres'] },
35
- { f: upper, a: ['lres'], out: ['ulres'], type: 'ret' },
36
- { f: prefix, a: ['prefstr', 'ulres'], out: ['plres'] },
37
- { f: postfix, a: ['plres', 'poststr'], out: ['plresp'] }
38
- ],
39
- outTask: { a: ['plresp'] }
40
- });
41
-
42
- t.deepEqual(errors, []);
43
-
44
- fn('foo', 'pre-', '-post', function cb(err, lres) {
45
- t.equal(err, null);
46
- t.equal(lres, 'pre-FOO-LOADED-post');
47
- });
48
-
49
- fn('bar', 'PRE-', '-POST', function cb(err, lres) {
50
- t.equal(err, null);
51
- t.equal(lres, 'PRE-BAR-LOADED-POST');
52
- done();
53
- });
54
- });
55
-
56
- test('ast.defined event called when ast is defined', function (done) {
57
- var fn = react();
58
- var collector = react.createEventCollector();
59
- collector.capture(fn, 'ast.*');
60
-
61
- var errors = fn.setAndValidateAST({
62
- inParams: ['res', 'prefstr', 'poststr'],
63
- tasks: [
64
- { f: load, a: ['res'], out: ['lres'] },
65
- { f: upper, a: ['lres'], out: ['ulres'], type: 'ret' },
66
- { f: prefix, a: ['prefstr', 'ulres'], out: ['plres'] },
67
- { f: postfix, a: ['plres', 'poststr'], out: ['plresp'] }
68
- ],
69
- outTask: { a: ['plresp'] }
70
- });
71
-
72
- var events = collector.list();
73
- t.equal(events.length, 1);
74
- t.isObject(events[0].ast);
75
- t.isNotNull(events[0].ast.inParams);
76
- t.isNotNull(events[0].ast.tasks);
77
- t.isNotNull(events[0].ast.outTask);
78
- done();
79
- });
80
-
81
- test('ast.defined event is passed to process', function (done) {
82
- // browser might not have this, so only if process is an eventemitter
83
- if (process && process.once) {
84
- var fn = react();
85
- process.once('ast.defined', function (ast) {
86
- t.isObject(ast);
87
- t.isNotNull(ast.inParams);
88
- t.isNotNull(ast.tasks);
89
- t.isNotNull(ast.outTask);
90
- t.deepEqual(ast.inParams, ['res', 'prefstr', 'poststr']);
91
- done();
92
- });
93
- var errors = fn.setAndValidateAST({
94
- inParams: ['res', 'prefstr', 'poststr'],
95
- tasks: [
96
- { f: load, a: ['res'], out: ['lres'] },
97
- { f: upper, a: ['lres'], out: ['ulres'], type: 'ret' },
98
- { f: prefix, a: ['prefstr', 'ulres'], out: ['plres'] },
99
- { f: postfix, a: ['plres', 'poststr'], out: ['plresp'] }
100
- ],
101
- outTask: { a: ['plresp'] }
102
- });
103
- } else {
104
- done(); //skipping in browser
105
- }
106
- });
107
-
108
- test('cb with err', function (done) {
109
- var fn = react();
110
- var errors = fn.setAndValidateAST({
111
- inParams: ['res', 'prefstr', 'poststr'],
112
- tasks: [
113
- { f: load, a: ['res'], out: ['lres'] },
114
- { f: upper, a: ['lres'], out: ['ulres'], type: 'ret' },
115
- { f: makeError, a: ['ulres'], out: ['na'] },
116
- { f: prefix, a: ['prefstr', 'na'], out: ['plres'] },
117
- { f: postfix, a: ['plres', 'poststr'], out: ['plresp'] }
118
- ],
119
- outTask: { a: ['plresp'] }
120
- });
121
-
122
- t.deepEqual(errors, []);
123
-
124
- fn('foo', 'pre-', '-post', function cb(err, lres) {
125
- t.equal(err.message, 'makeErr-FOO-LOADED');
126
- t.equal(lres, undefined);
127
- });
128
-
129
- fn('bar', 'PRE-', '-POST', function cb(err, lres) {
130
- t.equal(err.message, 'makeErr-BAR-LOADED');
131
- t.equal(lres, undefined);
132
- done();
133
- });
134
- });
135
-
136
- }());