react 0.7.1 → 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.
- package/README.md +15 -228
- package/ReactJSErrors.js +40 -0
- package/addons.js +4 -0
- package/lib/$.js +46 -0
- package/lib/CSSCore.js +114 -0
- package/lib/CSSProperty.js +90 -0
- package/lib/CSSPropertyOperations.js +97 -0
- package/lib/CallbackRegistry.js +91 -0
- package/lib/ChangeEventPlugin.js +365 -0
- package/lib/CompositionEventPlugin.js +212 -0
- package/lib/DOMChildrenOperations.js +135 -0
- package/lib/DOMProperty.js +266 -0
- package/lib/DOMPropertyOperations.js +168 -0
- package/lib/Danger.js +186 -0
- package/lib/DefaultDOMPropertyConfig.js +187 -0
- package/lib/DefaultEventPluginOrder.js +44 -0
- package/lib/EnterLeaveEventPlugin.js +112 -0
- package/lib/EventConstants.js +73 -0
- package/lib/EventListener.js +61 -0
- package/lib/EventPluginHub.js +190 -0
- package/lib/EventPluginRegistry.js +237 -0
- package/lib/EventPluginUtils.js +185 -0
- package/lib/EventPropagators.js +179 -0
- package/lib/ExecutionEnvironment.js +41 -0
- package/lib/LinkedStateMixin.js +46 -0
- package/lib/LinkedValueMixin.js +68 -0
- package/lib/MobileSafariClickEventPlugin.js +63 -0
- package/lib/PooledClass.js +113 -0
- package/lib/React.js +71 -0
- package/lib/ReactChildren.js +132 -0
- package/lib/ReactComponent.js +515 -0
- package/lib/ReactComponentBrowserEnvironment.js +140 -0
- package/lib/ReactComponentEnvironment.js +24 -0
- package/lib/ReactCompositeComponent.js +1020 -0
- package/lib/ReactCurrentOwner.js +39 -0
- package/lib/ReactDOM.js +194 -0
- package/lib/ReactDOMButton.js +64 -0
- package/lib/ReactDOMComponent.js +374 -0
- package/lib/ReactDOMForm.js +52 -0
- package/lib/ReactDOMIDOperations.js +173 -0
- package/lib/ReactDOMInput.js +169 -0
- package/lib/ReactDOMOption.js +50 -0
- package/lib/ReactDOMSelect.js +160 -0
- package/lib/ReactDOMSelection.js +189 -0
- package/lib/ReactDOMTextarea.js +136 -0
- package/lib/ReactDefaultBatchingStrategy.js +75 -0
- package/lib/ReactDefaultInjection.js +91 -0
- package/lib/ReactDefaultPerf.js +407 -0
- package/lib/ReactErrorUtils.js +46 -0
- package/lib/ReactEventEmitter.js +341 -0
- package/lib/ReactEventEmitterMixin.js +89 -0
- package/lib/ReactEventTopLevelCallback.js +89 -0
- package/lib/ReactInputSelection.js +140 -0
- package/lib/ReactInstanceHandles.js +322 -0
- package/lib/ReactLink.js +54 -0
- package/lib/ReactMarkupChecksum.js +53 -0
- package/lib/ReactMount.js +617 -0
- package/lib/ReactMountReady.js +95 -0
- package/lib/ReactMultiChild.js +441 -0
- package/lib/ReactMultiChildUpdateTypes.js +36 -0
- package/lib/ReactOwner.js +146 -0
- package/lib/ReactPerf.js +88 -0
- package/lib/ReactPropTransferer.js +128 -0
- package/lib/ReactPropTypes.js +158 -0
- package/lib/ReactReconcileTransaction.js +161 -0
- package/lib/ReactServerRendering.js +62 -0
- package/lib/ReactStateSetters.js +111 -0
- package/lib/ReactTextComponent.js +94 -0
- package/lib/ReactTransitionEvents.js +97 -0
- package/lib/ReactTransitionGroup.js +112 -0
- package/lib/ReactTransitionKeySet.js +111 -0
- package/lib/ReactTransitionableChild.js +152 -0
- package/lib/ReactUpdates.js +145 -0
- package/lib/ReactWithAddons.js +41 -0
- package/lib/SelectEventPlugin.js +217 -0
- package/lib/SimpleEventPlugin.js +365 -0
- package/lib/SyntheticClipboardEvent.js +45 -0
- package/lib/SyntheticCompositionEvent.js +51 -0
- package/lib/SyntheticEvent.js +163 -0
- package/lib/SyntheticFocusEvent.js +44 -0
- package/lib/SyntheticKeyboardEvent.js +56 -0
- package/lib/SyntheticMouseEvent.js +85 -0
- package/lib/SyntheticTouchEvent.js +50 -0
- package/lib/SyntheticUIEvent.js +45 -0
- package/lib/SyntheticWheelEvent.js +63 -0
- package/lib/Transaction.js +251 -0
- package/lib/ViewportMetrics.js +37 -0
- package/lib/accumulate.js +54 -0
- package/lib/adler32.js +39 -0
- package/lib/containsNode.js +49 -0
- package/lib/copyProperties.js +54 -0
- package/lib/createArrayFrom.js +94 -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/ex.js +49 -0
- package/lib/filterAttributes.js +45 -0
- package/lib/flattenChildren.js +54 -0
- package/lib/forEachAccumulated.js +36 -0
- package/lib/ge.js +76 -0
- package/lib/getActiveElement.js +33 -0
- package/lib/getEventTarget.js +36 -0
- package/lib/getMarkupWrap.js +108 -0
- package/lib/getNodeForCharacterOffset.js +80 -0
- package/lib/getReactRootElementInContainer.js +40 -0
- package/lib/getTextContentAccessor.js +40 -0
- package/lib/getUnboundedScrollPosition.js +45 -0
- package/lib/hyphenate.js +35 -0
- package/lib/invariant.js +54 -0
- package/lib/isEventSupported.js +74 -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 +137 -0
- package/lib/mergeInto.js +45 -0
- package/lib/mixInto.js +34 -0
- package/lib/mutateHTMLNodeWithMarkup.js +100 -0
- package/lib/objMap.js +47 -0
- package/lib/objMapKeyVal.js +47 -0
- package/lib/performanceNow.js +42 -0
- package/lib/shallowEqual.js +49 -0
- package/lib/traverseAllChildren.js +127 -0
- package/package.json +33 -31
- package/react.js +4 -0
- package/.npmignore +0 -7
- package/.travis.yml +0 -7
- 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 -3141
- package/dist/react.min.js +0 -22
- package/doc/advanced.md +0 -175
- 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 -120
- 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 -113
- package/lib/when-task.js +0 -84
- 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 -352
- 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 -164
- 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 -4251
- package/vendor/jquery/jquery-1.7.1.js +0 -9266
- package/vendor/jquery/jquery-1.7.1.min.js +0 -4
- package/vendor/node/util.js +0 -531
- package/vendor/requirejs/require.js +0 -2045
- package/vendor/requirejs/require.min.js +0 -36
package/README.md
CHANGED
|
@@ -1,238 +1,25 @@
|
|
|
1
|
-
#
|
|
1
|
+
# react
|
|
2
2
|
|
|
3
|
-
[
|
|
3
|
+
An npm package to get you immediate access to [React](http://facebook.github.io/react/),
|
|
4
|
+
without also requiring the JSX transformer. This is especially useful for cases where you
|
|
5
|
+
want to [`browserify`](https://github.com/substack/node-browserify) your module using
|
|
6
|
+
`React`.
|
|
4
7
|
|
|
5
|
-
|
|
8
|
+
## The `react` npm package has recently changed!
|
|
6
9
|
|
|
7
|
-
|
|
10
|
+
If you're looking for jeffbski's [React.js](https://github.com/jeffbski/react) project, it's now in `npm` as `autoflow` rather than `react`.
|
|
8
11
|
|
|
9
|
-
|
|
12
|
+
## Example Usage
|
|
10
13
|
|
|
11
|
-
|
|
14
|
+
```js
|
|
12
15
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
- Dataflow Programming: Handling Huge Data Loads Without Adding Complexity (Dr. Dobb's Sept 19, 2011) - <http://drdobbs.com/database/231400148>
|
|
16
|
+
// Previously, you might access React with react-tools.
|
|
17
|
+
var React = require('react-tools').React;
|
|
16
18
|
|
|
17
|
-
|
|
19
|
+
// Now you can access React directly with react-core.
|
|
20
|
+
var React = require('react');
|
|
18
21
|
|
|
19
|
-
|
|
20
|
-
|
|
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
|
-
|
|
28
|
-
|
|
29
|
-
## Goals
|
|
30
|
-
|
|
31
|
-
- Minimize boilerplate code needed for working with asynchronous functions
|
|
32
|
-
- Minimize the need to customize your code simply to use async flow control. The use of a flow control module ideally should not affect the way you write your code, it should only help take over some of the burden.
|
|
33
|
-
- Improved error and exception handling
|
|
34
|
-
- Provide useful stack traces and context information for easier debugging
|
|
35
|
-
- Make code more readable and easier to understand which should translate to less defects
|
|
36
|
-
- Provide the right level of abstraction to make it easier to refactor code, without being too magical
|
|
37
|
-
- Allow the mixing of pure functions, method calls, and callback style functions in the flow
|
|
38
|
-
|
|
39
|
-
## Supports
|
|
40
|
-
|
|
41
|
-
- async node-style callback(err, arg...) functions
|
|
42
|
-
- sync functions which directly return value
|
|
43
|
-
- object instance method calls
|
|
44
|
-
- class method calls
|
|
45
|
-
- selectFirst flow where the first task that returns defined, non-null value is used
|
|
46
|
-
- promise style functions - also automatic resolution of promise inputs (optionally loaded with `react.resolvePromises();`)
|
|
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 and https://github.com/jeffbski/react-q
|
|
48
|
-
- supports ES5 browsers (can work with others by using polyfills)
|
|
49
|
-
- (planned) iteration on arrays, streams, sockets
|
|
50
|
-
- (planned) event emitter integration
|
|
51
|
-
- tested on node 0.8, 0.10, 0.11
|
|
52
|
-
|
|
53
|
-
The tasks can be mixed, meaning you can use async, sync, object method calls, class method calls, etc in the same flow.
|
|
54
|
-
|
|
55
|
-
## Concept
|
|
56
|
-
|
|
57
|
-
Borrowing heavily from Tim and Elijah's ideas for conductor, this async flow control module provides a way to construct a flow from a
|
|
58
|
-
collection of rules based on functions or methods (referred to as _tasks_ in this module). It allows dependencies to be defined between the tasks so they can run in parallel as their dependencies are satisfied. React can us both variable dependencies and task dependencies.
|
|
59
|
-
|
|
60
|
-
As tasks complete, React watches the dependencies and kicks off additional tasks that have all their dependencies met and are ready to execute. This allows the flow to run at maximum speed without needing to arbitrarily block tasks into groups of parallel and serial flow.
|
|
61
|
-
|
|
62
|
-
To reduce the boilerplate code needed and improve error handling, React automatically provides callback functions for your asynchronous code. These React-provided callback functions perform these steps:
|
|
63
|
-
|
|
64
|
-
1. check for error and handle by calling outer callback function with this error after augmenting it with additional context information for easier debugging
|
|
65
|
-
2. save the callback variables into a context for future reference
|
|
66
|
-
3. call back into React (and it will kick off additional tasks that are now ready to go)
|
|
67
|
-
4. Using the dependencies specified for each
|
|
68
|
-
|
|
69
|
-
## Design
|
|
70
|
-
|
|
71
|
-
- Parse and validate DSL rules at module load time creating AST
|
|
72
|
-
- Validate the flow AST at module load time - determine if dependencies can all be met as defined
|
|
73
|
-
- Execute the flow AST by calling the function with arguments
|
|
74
|
-
|
|
75
|
-
## Installing
|
|
76
|
-
|
|
77
|
-
npm install react
|
|
78
|
-
|
|
79
|
-
OR
|
|
80
|
-
|
|
81
|
-
Pull from github - http://github.com/jeffbski/react
|
|
82
|
-
|
|
83
|
-
## Examples
|
|
84
|
-
|
|
85
|
-
<a name="defaultDSL"/>
|
|
86
|
-
### Example using default DSL interface
|
|
87
|
-
|
|
88
|
-
- Simple example showing flow definition of two async functions feeding a
|
|
89
|
-
synchronous function.
|
|
90
|
-
|
|
91
|
-
- First two async functions inputs are satisfied by the flow inputs, so
|
|
92
|
-
they will both run immediately in parallel.
|
|
93
|
-
|
|
94
|
-
- The last function waits for the outputs of the previous ones, then
|
|
95
|
-
executes synchronously.
|
|
96
|
-
|
|
97
|
-
- Finally the flow calls the callback with the output values once all
|
|
98
|
-
the tasks have completed.
|
|
99
|
-
|
|
100
|
-
```javascript
|
|
101
|
-
// in your foobar module
|
|
102
|
-
var react = require('react');
|
|
103
|
-
|
|
104
|
-
// some normal async and sync functions
|
|
105
|
-
function loadFoo(fooPath, cb) {
|
|
106
|
-
setTimeout(function () {
|
|
107
|
-
cb(null, [fooPath, 'data'].join(':'));
|
|
108
|
-
}, 10);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
function loadBar(barPath, barP2, cb) {
|
|
112
|
-
setTimeout(function () {
|
|
113
|
-
cb(null, [barPath, barP2, 'data'].join(':'));
|
|
114
|
-
}, 10);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
function render(foo, bar) {
|
|
118
|
-
return ['<html>', foo, '/', bar, '</html>'].join('');
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
// define fn, glue together with react, it will parallelize
|
|
122
|
-
// starts with name and in/out params, then the tasks
|
|
123
|
-
var loadRender = react('loadRender', 'fooPath, barPath, barP2, cb -> err, renderedOut',
|
|
124
|
-
loadFoo, 'fooPath, cb -> err, foo', // async cb function
|
|
125
|
-
loadBar, 'barPath, barP2, cb -> err, bar', // async cb function
|
|
126
|
-
render, 'foo, bar -> renderedOut' // sync function using outputs from first two
|
|
127
|
-
);
|
|
128
|
-
|
|
129
|
-
exports.loadRender = loadRender; // is a normal fn created by react
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
// in a different module far far away, use this as any other node function
|
|
133
|
-
var foobar = require('foobar');
|
|
134
|
-
foobar.loadRender('foo.txt', 'bar.txt', 'BBB', function (err, renderedOut) {
|
|
135
|
-
// tasks in loadRender were parallelized based on their input dependencies
|
|
136
|
-
console.error('results:', renderedOut);
|
|
137
|
-
});
|
|
22
|
+
// You can also access ReactWithAddons.
|
|
23
|
+
var React = require('react/addons');
|
|
138
24
|
```
|
|
139
25
|
|
|
140
|
-
Below is a graph of how the dependencies are mapped by React which
|
|
141
|
-
also indicates how the tasks will be executed. This was generated by the
|
|
142
|
-
react plugin [react-graphviz](https://github.com/jeffbski/react-graphviz)
|
|
143
|
-
which you can use to also graph your flows.
|
|
144
|
-
|
|
145
|
-

|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
## User API
|
|
150
|
-
|
|
151
|
-
The main function returned from require('react') can be used to define the AST used for the processing of the rules or flow.
|
|
152
|
-
|
|
153
|
-
It takes the following arguments to define a flow function:
|
|
154
|
-
|
|
155
|
-
```javascript
|
|
156
|
-
var fn = react('loadRender', 'fooPath, barPath, barP2, cb -> err, renderedOut',
|
|
157
|
-
loadFoo, 'fooPath, cb -> err, foo',
|
|
158
|
-
loadBar, 'barPath, barP2, cb -> err, bar',
|
|
159
|
-
render, 'foo, bar -> renderedOut'
|
|
160
|
-
);
|
|
161
|
-
```
|
|
162
|
-
|
|
163
|
-

|
|
164
|
-
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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:
|
|
171
|
-
- **name** - string - specifies a name for a task, otherwise React will try to use the function name or method string if it is unique in the flow. If a name is not unique subsequent tasks will have `_index` (zero based index of the task) added to create unique name. If you specify a name, you will also want to indicate a unique name for within the flow otherwise it will get a suffix as well. Example: `{ name: 'myTaskName' }`
|
|
172
|
-
- **after** - string, function reference, or array of string or function refs - specify additional preconditions that need to be complete before this task can run. In addition to the input dependencies being met, wait for these named tasks to complete before running. The preconditions are specified using the name of the task or if the task function was only used once and is a named function (not anonymous), you can just provide the function reference and it will determine name from it. Example: `{ after: 'foo' }` or `{ after: ['foo', 'bar'] }`
|
|
173
|
-
7. **repeat 4-6** - repeat steps 4-6 to specify additional tasks in this flow. As dependencies are met for tasks, React will invoke additional tasks that are ready to run in the order they are defined in this flow definition. So while the order does have some influence on the execution, it is primarily defined by the input dependencies and any other additonal preconditions specified with the `after` option. If you want to guarantee that something only runs after something else completes, then it will need to use an output from that task or specify the dependency with an `after`.
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
The flow function created by react from the input definition is a normal Node-style function which can be used like any other. These flow functions can be defined in a module and exported, they can be passed into other functions, used as methods on objects (the `this` context is passed in and available).
|
|
177
|
-
|
|
178
|
-
### Debugging React
|
|
179
|
-
|
|
180
|
-
React has a built-in plugin which can be loaded that will enable logging of tasks and flow as it executes very useful for debugging. For full details see [Advanced React - LogEvents](https://github.com/jeffbski/react/blob/master/doc/advanced.md#LogEvents) along with the other plugins and an explanation of the AST React uses.
|
|
181
|
-
|
|
182
|
-
```javascript
|
|
183
|
-
var react = require('react');
|
|
184
|
-
react.logEvents(); // turn on flow and task logging for all react functions
|
|
185
|
-
```
|
|
186
|
-
|
|
187
|
-
### Advanced React
|
|
188
|
-
|
|
189
|
-
React has many additional plugins and features which enable logging, monitoring, promise resolution, etc.
|
|
190
|
-
|
|
191
|
-
See the [Advanced React](https://github.com/jeffbski/react/blob/master/doc/advanced.md) for details on the AST React uses for processing and other plugins that are available.
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
## Status
|
|
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
|
|
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)
|
|
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
|
|
205
|
-
- 2012-03-12 - Pass ast.define events to process (v0.5.2)
|
|
206
|
-
- 2012-01-18 - Remove old DSL interfaces, improve plugin loading, log flow name with task name, ast.defined event, test with node 0.7.0 (v0.5.1)
|
|
207
|
-
- 2012-01-17 - Additional documentation (v0.3.5)
|
|
208
|
-
- 2012-01-16 - Refine events and create logging plugin (v0.3.3)
|
|
209
|
-
- 2012-01-13 - Add promise tasks, promise resolution, refactor alternate DSL interfaces as optional requires (v0.3.0)
|
|
210
|
-
- 2012-01-11 - Provide warning/error when name is skipped in default DSL, literal check in validate (v0.2.5)
|
|
211
|
-
- 2012-01-10 - Create default DSL for react(), create error for missing variables, list remaining tasks when flow won't complete
|
|
212
|
-
- 2011-12-21 - Refactor from ground up with tests, changes to the interfaces
|
|
213
|
-
- 2011-10-26 - React is in active development and interface may change frequently in these early stages. Current code is functional but does not perform validation yet. Additional interfaces are planned to make it easy to define flows in a variety of ways. Documentation and examples forthcoming.
|
|
214
|
-
|
|
215
|
-
## Test Results
|
|
216
|
-
|
|
217
|
-
[](http://travis-ci.org/jeffbski/react)
|
|
218
|
-
|
|
219
|
-
```bash
|
|
220
|
-
mocha
|
|
221
|
-
|
|
222
|
-
178 tests complete
|
|
223
|
-
```
|
|
224
|
-
|
|
225
|
-
## License
|
|
226
|
-
|
|
227
|
-
- [MIT license](http://github.com/jeffbski/react/raw/master/LICENSE)
|
|
228
|
-
|
|
229
|
-
## Contributors
|
|
230
|
-
|
|
231
|
-
- Author: Jeff Barczewski (@jeffbski)
|
|
232
|
-
|
|
233
|
-
## Contributing
|
|
234
|
-
|
|
235
|
-
- Source code repository: http://github.com/jeffbski/react
|
|
236
|
-
- Ideas and pull requests are encouraged - http://github.com/jeffbski/react/issues
|
|
237
|
-
|
|
238
|
-
- You may contact me at @jeffbski or through github at http://github.com/jeffbski
|
package/ReactJSErrors.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var copyProperties = require('./lib/copyProperties');
|
|
4
|
+
|
|
5
|
+
var WARNING_MESSAGE = (
|
|
6
|
+
'It looks like you\'re trying to use jeffbski\'s React.js project.\n' +
|
|
7
|
+
'The `react` npm package now points to the React JavaScript library for ' +
|
|
8
|
+
'building user interfaces, not the React.js project for managing asynchronous ' +
|
|
9
|
+
'control flow. If you\'re looking for that library, please npm install autoflow.'
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
function error() {
|
|
13
|
+
throw new Error(WARNING_MESSAGE);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// Model the React.js project's public interface exactly.
|
|
17
|
+
|
|
18
|
+
function ReactJSShim() {
|
|
19
|
+
error();
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
ReactJSShim.logEvents = error;
|
|
23
|
+
ReactJSShim.resolvePromises = error;
|
|
24
|
+
ReactJSShim.trackTasks = error;
|
|
25
|
+
ReactJSShim.createEventCollector = error;
|
|
26
|
+
|
|
27
|
+
// These could throw using defineProperty() but supporting older browsers will
|
|
28
|
+
// be painful. Additionally any error messages around this will contain the string
|
|
29
|
+
// so I think this is sufficient.
|
|
30
|
+
ReactJSShim.options = WARNING_MESSAGE;
|
|
31
|
+
ReactJSShim.events = WARNING_MESSAGE;
|
|
32
|
+
|
|
33
|
+
var ReactJSErrors = {
|
|
34
|
+
wrap: function(module) {
|
|
35
|
+
copyProperties(ReactJSShim, module);
|
|
36
|
+
return ReactJSShim;
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
module.exports = ReactJSErrors;
|
package/addons.js
ADDED
package/lib/$.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2013 Facebook, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*
|
|
16
|
+
* @providesModule $
|
|
17
|
+
* @typechecks
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
var ge = require("./ge");
|
|
21
|
+
var ex = require("./ex");
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Find a node by ID.
|
|
25
|
+
*
|
|
26
|
+
* If your application code depends on the existence of the element, use $,
|
|
27
|
+
* which will throw if the element doesn't exist.
|
|
28
|
+
*
|
|
29
|
+
* If you're not sure whether or not the element exists, use ge instead, and
|
|
30
|
+
* manually check for the element's existence in your application code.
|
|
31
|
+
*
|
|
32
|
+
* @param {string|DOMDocument|DOMElement|DOMTextNode|Comment} id
|
|
33
|
+
* @return {DOMDocument|DOMElement|DOMTextNode|Comment}
|
|
34
|
+
*/
|
|
35
|
+
function $(id) {
|
|
36
|
+
var element = ge(id);
|
|
37
|
+
if (!element) {
|
|
38
|
+
throw new Error(ex(
|
|
39
|
+
'Tried to get element with id of "%s" but it is not present on the page.',
|
|
40
|
+
id
|
|
41
|
+
));
|
|
42
|
+
}
|
|
43
|
+
return element;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
module.exports = $;
|
package/lib/CSSCore.js
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2013 Facebook, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*
|
|
16
|
+
* @providesModule CSSCore
|
|
17
|
+
* @typechecks
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
var invariant = require("./invariant");
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* The CSSCore module specifies the API (and implements most of the methods)
|
|
24
|
+
* that should be used when dealing with the display of elements (via their
|
|
25
|
+
* CSS classes and visibility on screeni. It is an API focused on mutating the
|
|
26
|
+
* display and not reading it as no logical state should be encoded in the
|
|
27
|
+
* display of elements.
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Tests whether the element has the class specified.
|
|
32
|
+
*
|
|
33
|
+
* Note: This function is not exported in CSSCore because CSS classNames should
|
|
34
|
+
* not store any logical information about the element. Use DataStore to store
|
|
35
|
+
* information on an element.
|
|
36
|
+
*
|
|
37
|
+
* @param {DOMElement} element the element to set the class on
|
|
38
|
+
* @param {string} className the CSS className
|
|
39
|
+
* @returns {boolean} true if the element has the class, false if not
|
|
40
|
+
*/
|
|
41
|
+
function hasClass(element, className) {
|
|
42
|
+
if (element.classList) {
|
|
43
|
+
return !!className && element.classList.contains(className);
|
|
44
|
+
}
|
|
45
|
+
return (' ' + element.className + ' ').indexOf(' ' + className + ' ') > -1;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
var CSSCore = {
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Adds the class passed in to the element if it doesn't already have it.
|
|
52
|
+
*
|
|
53
|
+
* @param {DOMElement} element the element to set the class on
|
|
54
|
+
* @param {string} className the CSS className
|
|
55
|
+
* @return {DOMElement} the element passed in
|
|
56
|
+
*/
|
|
57
|
+
addClass: function(element, className) {
|
|
58
|
+
("production" !== process.env.NODE_ENV ? invariant(
|
|
59
|
+
!/\s/.test(className),
|
|
60
|
+
'CSSCore.addClass takes only a single class name. "%s" contains ' +
|
|
61
|
+
'multiple classes.', className
|
|
62
|
+
) : invariant(!/\s/.test(className)));
|
|
63
|
+
|
|
64
|
+
if (className) {
|
|
65
|
+
if (element.classList) {
|
|
66
|
+
element.classList.add(className);
|
|
67
|
+
} else if (!hasClass(element, className)) {
|
|
68
|
+
element.className = element.className + ' ' + className;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return element;
|
|
72
|
+
},
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Removes the class passed in from the element
|
|
76
|
+
*
|
|
77
|
+
* @param {DOMElement} element the element to set the class on
|
|
78
|
+
* @param {string} className the CSS className
|
|
79
|
+
* @return {DOMElement} the element passed in
|
|
80
|
+
*/
|
|
81
|
+
removeClass: function(element, className) {
|
|
82
|
+
("production" !== process.env.NODE_ENV ? invariant(
|
|
83
|
+
!/\s/.test(className),
|
|
84
|
+
'CSSCore.removeClass takes only a single class name. "%s" contains ' +
|
|
85
|
+
'multiple classes.', className
|
|
86
|
+
) : invariant(!/\s/.test(className)));
|
|
87
|
+
|
|
88
|
+
if (className) {
|
|
89
|
+
if (element.classList) {
|
|
90
|
+
element.classList.remove(className);
|
|
91
|
+
} else if (hasClass(element, className)) {
|
|
92
|
+
element.className = element.className
|
|
93
|
+
.replace(new RegExp('(^|\\s)' + className + '(?:\\s|$)', 'g'), '$1')
|
|
94
|
+
.replace(/\s+/g, ' ') // multiple spaces to one
|
|
95
|
+
.replace(/^\s*|\s*$/g, ''); // trim the ends
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return element;
|
|
99
|
+
},
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Helper to add or remove a class from an element based on a condition.
|
|
103
|
+
*
|
|
104
|
+
* @param {DOMElement} element the element to set the class on
|
|
105
|
+
* @param {string} className the CSS className
|
|
106
|
+
* @param {*} bool condition to whether to add or remove the class
|
|
107
|
+
* @return {DOMElement} the element passed in
|
|
108
|
+
*/
|
|
109
|
+
conditionClass: function(element, className, bool) {
|
|
110
|
+
return (bool ? CSSCore.addClass : CSSCore.removeClass)(element, className);
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
module.exports = CSSCore;
|