summaryrefslogtreecommitdiffstats
path: root/third_party/webkit/PerformanceTests/Speedometer/resources/todomvc/labs/architecture-examples/react/bower_components/director
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/webkit/PerformanceTests/Speedometer/resources/todomvc/labs/architecture-examples/react/bower_components/director')
-rw-r--r--third_party/webkit/PerformanceTests/Speedometer/resources/todomvc/labs/architecture-examples/react/bower_components/director/LICENSE19
-rw-r--r--third_party/webkit/PerformanceTests/Speedometer/resources/todomvc/labs/architecture-examples/react/bower_components/director/README.md822
-rw-r--r--third_party/webkit/PerformanceTests/Speedometer/resources/todomvc/labs/architecture-examples/react/bower_components/director/build/director.js712
-rw-r--r--third_party/webkit/PerformanceTests/Speedometer/resources/todomvc/labs/architecture-examples/react/bower_components/director/build/director.min.js7
-rw-r--r--third_party/webkit/PerformanceTests/Speedometer/resources/todomvc/labs/architecture-examples/react/bower_components/director/build/ender.js3
5 files changed, 1563 insertions, 0 deletions
diff --git a/third_party/webkit/PerformanceTests/Speedometer/resources/todomvc/labs/architecture-examples/react/bower_components/director/LICENSE b/third_party/webkit/PerformanceTests/Speedometer/resources/todomvc/labs/architecture-examples/react/bower_components/director/LICENSE
new file mode 100644
index 0000000000..1f01e2b36c
--- /dev/null
+++ b/third_party/webkit/PerformanceTests/Speedometer/resources/todomvc/labs/architecture-examples/react/bower_components/director/LICENSE
@@ -0,0 +1,19 @@
+Copyright (c) 2011 Nodejitsu Inc.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE. \ No newline at end of file
diff --git a/third_party/webkit/PerformanceTests/Speedometer/resources/todomvc/labs/architecture-examples/react/bower_components/director/README.md b/third_party/webkit/PerformanceTests/Speedometer/resources/todomvc/labs/architecture-examples/react/bower_components/director/README.md
new file mode 100644
index 0000000000..522d146c47
--- /dev/null
+++ b/third_party/webkit/PerformanceTests/Speedometer/resources/todomvc/labs/architecture-examples/react/bower_components/director/README.md
@@ -0,0 +1,822 @@
+<img src="https://github.com/flatiron/director/raw/master/img/director.png" />
+
+# Synopsis
+Director is a router. Routing is the process of determining what code to run when a URL is requested.
+
+# Motivation
+A routing library that works in both the browser and node.js environments with as few differences as possible. Simplifies the development of Single Page Apps and Node.js applications. Dependency free (doesn't require jQuery or Express, etc).
+
+# Status
+[![Build Status](https://secure.travis-ci.org/flatiron/director.png?branch=master)](http://travis-ci.org/flatiron/director)
+
+# Features
+* [Client-Side Routing](#client-side)
+* [Server-Side HTTP Routing](#http-routing)
+* [Server-Side CLI Routing](#cli-routing)
+
+
+# Usage
+* [API Documentation](#api-documentation)
+* [Frequently Asked Questions](#faq)
+
+<a name="client-side"></a>
+## Client-side Routing
+It simply watches the hash of the URL to determine what to do, for example:
+
+```
+http://foo.com/#/bar
+```
+
+Client-side routing (aka hash-routing) allows you to specify some information about the state of the application using the URL. So that when the user visits a specific URL, the application can be transformed accordingly.
+
+<img src="https://github.com/flatiron/director/raw/master/img/hashRoute.png" />
+
+Here is a simple example:
+
+```html
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>A Gentle Introduction</title>
+ <script src="https://raw.github.com/flatiron/director/master/build/director.min.js"></script>
+ <script>
+
+ var author = function () { console.log("author"); },
+ books = function () { console.log("books"); },
+ viewBook = function(bookId) { console.log("viewBook: bookId is populated: " + bookId); };
+
+ var routes = {
+ '/author': author,
+ '/books': [books, function() { console.log("An inline route handler."); }],
+ '/books/view/:bookId': viewBook
+ };
+
+ var router = Router(routes);
+ router.init();
+
+ </script>
+ </head>
+ <body>
+ <ul>
+ <li><a href="#/author">#/author</a></li>
+ <li><a href="#/books">#/books</a></li>
+ <li><a href="#/books/view/1">#/books/view/1</a></li>
+ </ul>
+ </body>
+</html>
+```
+
+Director works great with your favorite DOM library, such as jQuery.
+
+```html
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>A Gentle Introduction 2</title>
+ <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
+ <script src="https://raw.github.com/flatiron/director/master/build/director.min.js"></script>
+ <script>
+ $('document').ready(function(){
+ //
+ // create some functions to be executed when
+ // the correct route is issued by the user.
+ //
+ var showAuthorInfo = function () { console.log("showAuthorInfo"); },
+ listBooks = function () { console.log("listBooks"); },
+ allroutes = function() {
+ var route = window.location.hash.slice(2),
+ sections = $('section'),
+ section;
+ if ((section = sections.filter('[data-route=' + route + ']')).length) {
+ sections.hide(250);
+ section.show(250);
+ }
+ };
+
+ //
+ // define the routing table.
+ //
+ var routes = {
+ '/author': showAuthorInfo,
+ '/books': listBooks
+ };
+
+ //
+ // instantiate the router.
+ //
+ var router = Router(routes);
+
+ //
+ // a global configuration setting.
+ //
+ router.configure({
+ on: allroutes
+ });
+ router.init();
+ });
+ </script>
+ </head>
+ <body>
+ <section data-route="author">Author Name</section>
+ <section data-route="books">Book1, Book2, Book3</section>
+ <ul>
+ <li><a href="#/author">#/author</a></li>
+ <li><a href="#/books">#/books</a></li>
+ </ul>
+ </body>
+</html>
+```
+
+You can find a browser-specific build of `director` [here][1] which has all of the server code stripped away.
+
+<a name="http-routing"></a>
+## Server-Side HTTP Routing
+
+Director handles routing for HTTP requests similar to `journey` or `express`:
+
+```js
+ //
+ // require the native http module, as well as director.
+ //
+ var http = require('http'),
+ director = require('director');
+
+ //
+ // create some logic to be routed to.
+ //
+ function helloWorld() {
+ this.res.writeHead(200, { 'Content-Type': 'text/plain' })
+ this.res.end('hello world');
+ }
+
+ //
+ // define a routing table.
+ //
+ var router = new director.http.Router({
+ '/hello': {
+ get: helloWorld
+ }
+ });
+
+ //
+ // setup a server and when there is a request, dispatch the
+ // route that was requested in the request object.
+ //
+ var server = http.createServer(function (req, res) {
+ router.dispatch(req, res, function (err) {
+ if (err) {
+ res.writeHead(404);
+ res.end();
+ }
+ });
+ });
+
+ //
+ // You can also do ad-hoc routing, similar to `journey` or `express`.
+ // This can be done with a string or a regexp.
+ //
+ router.get('/bonjour', helloWorld);
+ router.get(/hola/, helloWorld);
+
+ //
+ // set the server to listen on port `8080`.
+ //
+ server.listen(8080);
+```
+
+### See Also:
+
+ - Auto-generated Node.js API Clients for routers using [Director-Reflector](http://github.com/flatiron/director-reflector)
+ - RESTful Resource routing using [restful](http://github.com/flatiron/restful)
+ - HTML / Plain Text views of routers using [Director-Explorer](http://github.com/flatiron/director-explorer)
+
+<a name="cli-routing"></a>
+## CLI Routing
+
+Director supports Command Line Interface routing. Routes for cli options are based on command line input (i.e. `process.argv`) instead of a URL.
+
+``` js
+ var director = require('director');
+
+ var router = new director.cli.Router();
+
+ router.on('create', function () {
+ console.log('create something');
+ });
+
+ router.on(/destroy/, function () {
+ console.log('destroy something');
+ });
+
+ // You will need to dispatch the cli arguments yourself
+ router.dispatch('on', process.argv.slice(2).join(' '));
+```
+
+Using the cli router, you can dispatch commands by passing them as a string. For example, if this example is in a file called `foo.js`:
+
+``` bash
+$ node foo.js create
+create something
+$ node foo.js destroy
+destroy something
+```
+
+<a name="api-documentation"></a>
+# API Documentation
+
+* [Constructor](#constructor)
+* [Routing Table](#routing-table)
+* [Adhoc Routing](#adhoc-routing)
+* [Scoped Routing](#scoped-routing)
+* [Routing Events](#routing-events)
+* [Configuration](#configuration)
+* [URL Matching](#url-matching)
+* [URL Params](#url-params)
+* [Route Recursion](#route-recursion)
+* [Async Routing](#async-routing)
+* [Resources](#resources)
+* [History API](#history-api)
+* [Instance Methods](#instance-methods)
+* [Attach Properties to `this`](#attach-to-this)
+* [HTTP Streaming and Body Parsing](#http-streaming-body-parsing)
+
+<a name="constructor"></a>
+## Constructor
+
+``` js
+ var router = Router(routes);
+```
+
+<a name="routing-table"></a>
+## Routing Table
+
+An object literal that contains nested route definitions. A potentially nested set of key/value pairs. The keys in the object literal represent each potential part of the URL. The values in the object literal contain references to the functions that should be associated with them. *bark* and *meow* are two functions that you have defined in your code.
+
+``` js
+ //
+ // Assign routes to an object literal.
+ //
+ var routes = {
+ //
+ // a route which assigns the function `bark`.
+ //
+ '/dog': bark,
+ //
+ // a route which assigns the functions `meow` and `scratch`.
+ //
+ '/cat': [meow, scratch]
+ };
+
+ //
+ // Instantiate the router.
+ //
+ var router = Router(routes);
+```
+
+<a name="adhoc-routing"></a>
+## Adhoc Routing
+
+When developing large client-side or server-side applications it is not always possible to define routes in one location. Usually individual decoupled components register their own routes with the application router. We refer to this as _Adhoc Routing._ Lets take a look at the API `director` exposes for adhoc routing:
+
+**Client-side Routing**
+
+``` js
+ var router = new Router().init();
+
+ router.on('/some/resource', function () {
+ //
+ // Do something on `/#/some/resource`
+ //
+ });
+```
+
+**HTTP Routing**
+
+``` js
+ var router = new director.http.Router();
+
+ router.get(/\/some\/resource/, function () {
+ //
+ // Do something on an GET to `/some/resource`
+ //
+ });
+```
+
+<a name="scoped-routing"></a>
+## Scoped Routing
+
+In large web appliations, both [Client-side](#client-side) and [Server-side](#http-routing), routes are often scoped within a few individual resources. Director exposes a simple way to do this for [Adhoc Routing](#adhoc-routing) scenarios:
+
+``` js
+ var router = new director.http.Router();
+
+ //
+ // Create routes inside the `/users` scope.
+ //
+ router.path(/\/users\/(\w+)/, function () {
+ //
+ // The `this` context of the function passed to `.path()`
+ // is the Router itself.
+ //
+
+ this.post(function (id) {
+ //
+ // Create the user with the specified `id`.
+ //
+ });
+
+ this.get(function (id) {
+ //
+ // Retreive the user with the specified `id`.
+ //
+ });
+
+ this.get(/\/friends/, function (id) {
+ //
+ // Get the friends for the user with the specified `id`.
+ //
+ });
+ });
+```
+
+<a name="routing-events"></a>
+## Routing Events
+
+In `director`, a "routing event" is a named property in the [Routing Table](#routing-table) which can be assigned to a function or an Array of functions to be called when a route is matched in a call to `router.dispatch()`.
+
+* **on:** A function or Array of functions to execute when the route is matched.
+* **before:** A function or Array of functions to execute before calling the `on` method(s).
+
+**Client-side only**
+
+* **after:** A function or Array of functions to execute when leaving a particular route.
+* **once:** A function or Array of functions to execute only once for a particular route.
+
+<a name="configuration"></a>
+## Configuration
+
+Given the flexible nature of `director` there are several options available for both the [Client-side](#client-side) and [Server-side](#http-routing). These options can be set using the `.configure()` method:
+
+``` js
+ var router = new director.Router(routes).configure(options);
+```
+
+The `options` are:
+
+* **recurse:** Controls [route recursion](#route-recursion). Use `forward`, `backward`, or `false`. Default is `false` Client-side, and `backward` Server-side.
+* **strict:** If set to `false`, then trailing slashes (or other delimiters) are allowed in routes. Default is `true`.
+* **async:** Controls [async routing](#async-routing). Use `true` or `false`. Default is `false`.
+* **delimiter:** Character separator between route fragments. Default is `/`.
+* **notfound:** A function to call if no route is found on a call to `router.dispatch()`.
+* **on:** A function (or list of functions) to call on every call to `router.dispatch()` when a route is found.
+* **before:** A function (or list of functions) to call before every call to `router.dispatch()` when a route is found.
+
+**Client-side only**
+
+* **resource:** An object to which string-based routes will be bound. This can be especially useful for late-binding to route functions (such as async client-side requires).
+* **after:** A function (or list of functions) to call when a given route is no longer the active route.
+* **html5history:** If set to `true` and client supports `pushState()`, then uses HTML5 History API instead of hash fragments. See [History API](#history-api) for more information.
+* **run_handler_in_init:** If `html5history` is enabled, the route handler by default is executed upon `Router.init()` since with real URIs the router can not know if it should call a route handler or not. Setting this to `false` disables the route handler initial execution.
+
+<a name="url-matching"></a>
+## URL Matching
+
+``` js
+ var router = Router({
+ //
+ // given the route '/dog/yella'.
+ //
+ '/dog': {
+ '/:color': {
+ //
+ // this function will return the value 'yella'.
+ //
+ on: function (color) { console.log(color) }
+ }
+ }
+ });
+```
+
+Routes can sometimes become very complex, `simple/:tokens` don't always suffice. Director supports regular expressions inside the route names. The values captured from the regular expressions are passed to your listener function.
+
+``` js
+ var router = Router({
+ //
+ // given the route '/hello/world'.
+ //
+ '/hello': {
+ '/(\\w+)': {
+ //
+ // this function will return the value 'world'.
+ //
+ on: function (who) { console.log(who) }
+ }
+ }
+ });
+```
+
+``` js
+ var router = Router({
+ //
+ // given the route '/hello/world/johny/appleseed'.
+ //
+ '/hello': {
+ '/world/?([^\/]*)\/([^\/]*)/?': function (a, b) {
+ console.log(a, b);
+ }
+ }
+ });
+```
+
+<a name="url-params"></a>
+## URL Parameters
+
+When you are using the same route fragments it is more descriptive to define these fragments by name and then use them in your [Routing Table](#routing-table) or [Adhoc Routes](#adhoc-routing). Consider a simple example where a `userId` is used repeatedly.
+
+``` js
+ //
+ // Create a router. This could also be director.cli.Router() or
+ // director.http.Router().
+ //
+ var router = new director.Router();
+
+ //
+ // A route could be defined using the `userId` explicitly.
+ //
+ router.on(/([\w-_]+)/, function (userId) { });
+
+ //
+ // Define a shorthand for this fragment called `userId`.
+ //
+ router.param('userId', /([\\w\\-]+)/);
+
+ //
+ // Now multiple routes can be defined with the same
+ // regular expression.
+ //
+ router.on('/anything/:userId', function (userId) { });
+ router.on('/something-else/:userId', function (userId) { });
+```
+
+<a name="route-recursion"></a>
+## Route Recursion
+
+Can be assigned the value of `forward` or `backward`. The recurse option will determine the order in which to fire the listeners that are associated with your routes. If this option is NOT specified or set to null, then only the listeners associated with an exact match will be fired.
+
+### No recursion, with the URL /dog/angry
+
+``` js
+ var routes = {
+ '/dog': {
+ '/angry': {
+ //
+ // Only this method will be fired.
+ //
+ on: growl
+ },
+ on: bark
+ }
+ };
+
+ var router = Router(routes);
+```
+
+### Recursion set to `backward`, with the URL /dog/angry
+
+``` js
+ var routes = {
+ '/dog': {
+ '/angry': {
+ //
+ // This method will be fired first.
+ //
+ on: growl
+ },
+ //
+ // This method will be fired second.
+ //
+ on: bark
+ }
+ };
+
+ var router = Router(routes).configure({ recurse: 'backward' });
+```
+
+### Recursion set to `forward`, with the URL /dog/angry
+
+``` js
+ var routes = {
+ '/dog': {
+ '/angry': {
+ //
+ // This method will be fired second.
+ //
+ on: growl
+ },
+ //
+ // This method will be fired first.
+ //
+ on: bark
+ }
+ };
+
+ var router = Router(routes).configure({ recurse: 'forward' });
+```
+
+### Breaking out of recursion, with the URL /dog/angry
+
+``` js
+ var routes = {
+ '/dog': {
+ '/angry': {
+ //
+ // This method will be fired first.
+ //
+ on: function() { return false; }
+ },
+ //
+ // This method will not be fired.
+ //
+ on: bark
+ }
+ };
+
+ //
+ // This feature works in reverse with recursion set to true.
+ //
+ var router = Router(routes).configure({ recurse: 'backward' });
+```
+
+<a name="async-routing"></a>
+## Async Routing
+
+Before diving into how Director exposes async routing, you should understand [Route Recursion](#route-recursion). At it's core route recursion is about evaluating a series of functions gathered when traversing the [Routing Table](#routing-table).
+
+Normally this series of functions is evaluated synchronously. In async routing, these functions are evaluated asynchronously. Async routing can be extremely useful both on the client-side and the server-side:
+
+* **Client-side:** To ensure an animation or other async operations (such as HTTP requests for authentication) have completed before continuing evaluation of a route.
+* **Server-side:** To ensure arbitrary async operations (such as performing authentication) have completed before continuing the evaluation of a route.
+
+The method signatures for route functions in synchronous and asynchronous evaluation are different: async route functions take an additional `next()` callback.
+
+### Synchronous route functions
+
+``` js
+ var router = new director.Router();
+
+ router.on('/:foo/:bar/:bazz', function (foo, bar, bazz) {
+ //
+ // Do something asynchronous with `foo`, `bar`, and `bazz`.
+ //
+ });
+```
+
+### Asynchronous route functions
+
+``` js
+ var router = new director.http.Router().configure({ async: true });
+
+ router.on('/:foo/:bar/:bazz', function (foo, bar, bazz, next) {
+ //
+ // Go do something async, and determine that routing should stop
+ //
+ next(false);
+ });
+```
+
+<a name="resources"></a>
+## Resources
+
+**Available on the Client-side only.** An object literal containing functions. If a host object is specified, your route definitions can provide string literals that represent the function names inside the host object. A host object can provide the means for better encapsulation and design.
+
+``` js
+
+ var router = Router({
+
+ '/hello': {
+ '/usa': 'americas',
+ '/china': 'asia'
+ }
+
+ }).configure({ resource: container }).init();
+
+ var container = {
+ americas: function() { return true; },
+ china: function() { return true; }
+ };
+
+```
+
+<a name="history-api"></a>
+## History API
+
+**Available on the Client-side only.** Director supports using HTML5 History API instead of hash fragments for navigation. To use the API, pass `{html5history: true}` to `configure()`. Use of the API is enabled only if the client supports `pushState()`.
+
+Using the API gives you cleaner URIs but they come with a cost. Unlike with hash fragments your route URIs must exist. When the client enters a page, say http://foo.com/bar/baz, the web server must respond with something meaningful. Usually this means that your web server checks the URI points to something that, in a sense, exists, and then serves the client the JavaScript application.
+
+If you're after a single-page application you can not use plain old `<a href="/bar/baz">` tags for navigation anymore. When such link is clicked, web browsers try to ask for the resource from server which is not of course desired for a single-page application. Instead you need to use e.g. click handlers and call the `setRoute()` method yourself.
+
+<a name="attach-to-this"></a>
+## Attach Properties To `this`
+
+Generally, the `this` object bound to route handlers, will contain the request in `this.req` and the response in `this.res`. One may attach additional properties to `this` with the `router.attach` method:
+
+```js
+ var director = require('director');
+
+ var router = new director.http.Router().configure(options);
+
+ //
+ // Attach properties to `this`
+ //
+ router.attach(function () {
+ this.data = [1,2,3];
+ });
+
+ //
+ // Access properties attached to `this` in your routes!
+ //
+ router.get('/hello', function () {
+ this.res.writeHead(200, { 'content-type': 'text/plain' });
+
+ //
+ // Response will be `[1,2,3]`!
+ //
+ this.res.end(this.data);
+ });
+```
+
+This API may be used to attach convenience methods to the `this` context of route handlers.
+
+<a name="http-streaming-body-parsing">
+## HTTP Streaming and Body Parsing
+
+When you are performing HTTP routing there are two common scenarios:
+
+* Buffer the request body and parse it according to the `Content-Type` header (usually `application/json` or `application/x-www-form-urlencoded`).
+* Stream the request body by manually calling `.pipe` or listening to the `data` and `end` events.
+
+By default `director.http.Router()` will attempt to parse either the `.chunks` or `.body` properties set on the request parameter passed to `router.dispatch(request, response, callback)`. The router instance will also wait for the `end` event before firing any routes.
+
+**Default Behavior**
+
+``` js
+ var director = require('director');
+
+ var router = new director.http.Router();
+
+ router.get('/', function () {
+ //
+ // This will not work, because all of the data
+ // events and the end event have already fired.
+ //
+ this.req.on('data', function (chunk) {
+ console.log(chunk)
+ });
+ });
+```
+
+In [flatiron][2], `director` is used in conjunction with [union][3] which uses a `BufferedStream` proxy to the raw `http.Request` instance. [union][3] will set the `req.chunks` property for you and director will automatically parse the body. If you wish to perform this buffering yourself directly with `director` you can use a simple request handler in your http server:
+
+``` js
+ var http = require('http'),
+ director = require('director');
+
+ var router = new director.http.Router();
+
+ var server = http.createServer(function (req, res) {
+ req.chunks = [];
+ req.on('data', function (chunk) {
+ req.chunks.push(chunk.toString());
+ });
+
+ router.dispatch(req, res, function (err) {
+ if (err) {
+ res.writeHead(404);
+ res.end();
+ }
+
+ console.log('Served ' + req.url);
+ });
+ });
+
+ router.post('/', function () {
+ this.res.writeHead(200, { 'Content-Type': 'application/json' })
+ this.res.end(JSON.stringify(this.req.body));
+ });
+```
+
+**Streaming Support**
+
+If you wish to get access to the request stream before the `end` event is fired, you can pass the `{ stream: true }` options to the route.
+
+``` js
+ var director = require('director');
+
+ var router = new director.http.Router();
+
+ router.get('/', { stream: true }, function () {
+ //
+ // This will work because the route handler is invoked
+ // immediately without waiting for the `end` event.
+ //
+ this.req.on('data', function (chunk) {
+ console.log(chunk);
+ });
+ });
+```
+
+<a name="instance-methods"></a>
+## Instance methods
+
+### configure(options)
+* `options` {Object}: Options to configure this instance with.
+
+Configures the Router instance with the specified `options`. See [Configuration](#configuration) for more documentation.
+
+### param(token, matcher)
+* token {string}: Named parameter token to set to the specified `matcher`
+* matcher {string|Regexp}: Matcher for the specified `token`.
+
+Adds a route fragment for the given string `token` to the specified regex `matcher` to this Router instance. See [URL Parameters](#url-params) for more documentation.
+
+### on(method, path, route)
+* `method` {string}: Method to insert within the Routing Table (e.g. `on`, `get`, etc.).
+* `path` {string}: Path within the Routing Table to set the `route` to.
+* `route` {function|Array}: Route handler to invoke for the `method` and `path`.
+
+Adds the `route` handler for the specified `method` and `path` within the [Routing Table](#routing-table).
+
+### path(path, routesFn)
+* `path` {string|Regexp}: Scope within the Routing Table to invoke the `routesFn` within.
+* `routesFn` {function}: Adhoc Routing function with calls to `this.on()`, `this.get()` etc.
+
+Invokes the `routesFn` within the scope of the specified `path` for this Router instance.
+
+### dispatch(method, path[, callback])
+* method {string}: Method to invoke handlers for within the Routing Table
+* path {string}: Path within the Routing Table to match
+* callback {function}: Invoked once all route handlers have been called.
+
+Dispatches the route handlers matched within the [Routing Table](#routing-table) for this instance for the specified `method` and `path`.
+
+### mount(routes, path)
+* routes {object}: Partial routing table to insert into this instance.
+* path {string|Regexp}: Path within the Routing Table to insert the `routes` into.
+
+Inserts the partial [Routing Table](#routing-table), `routes`, into the Routing Table for this Router instance at the specified `path`.
+
+## Instance methods (Client-side only)
+
+### init([redirect])
+* `redirect` {String}: This value will be used if '/#/' is not found in the URL. (e.g., init('/') will resolve to '/#/', init('foo') will resolve to '/#foo').
+
+Initialize the router, start listening for changes to the URL.
+
+### getRoute([index])
+* `index` {Number}: The hash value is divided by forward slashes, each section then has an index, if this is provided, only that section of the route will be returned.
+
+Returns the entire route or just a section of it.
+
+### setRoute(route)
+* `route` {String}: Supply a route value, such as `home/stats`.
+
+Set the current route.
+
+### setRoute(start, length)
+* `start` {Number} - The position at which to start removing items.
+* `length` {Number} - The number of items to remove from the route.
+
+Remove a segment from the current route.
+
+### setRoute(index, value)
+* `index` {Number} - The hash value is divided by forward slashes, each section then has an index.
+* `value` {String} - The new value to assign the the position indicated by the first parameter.
+
+Set a segment of the current route.
+
+<a name="faq"></a>
+# Frequently Asked Questions
+
+## What About SEO?
+
+Is using a Client-side router a problem for SEO? Yes. If advertising is a requirement, you are probably building a "Web Page" and not a "Web Application". Director on the client is meant for script-heavy Web Applications.
+
+# Licence
+
+(The MIT License)
+
+Copyright (c) 2010 Nodejitsu Inc. <http://www.twitter.com/nodejitsu>
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+[0]: http://github.com/flatiron/director
+[1]: https://github.com/flatiron/director/blob/master/build/director.min.js
+[2]: http://github.com/flatiron/flatiron
+[3]: http://github.com/flatiron/union
diff --git a/third_party/webkit/PerformanceTests/Speedometer/resources/todomvc/labs/architecture-examples/react/bower_components/director/build/director.js b/third_party/webkit/PerformanceTests/Speedometer/resources/todomvc/labs/architecture-examples/react/bower_components/director/build/director.js
new file mode 100644
index 0000000000..0befbe0751
--- /dev/null
+++ b/third_party/webkit/PerformanceTests/Speedometer/resources/todomvc/labs/architecture-examples/react/bower_components/director/build/director.js
@@ -0,0 +1,712 @@
+
+
+//
+// Generated on Sun Dec 16 2012 22:47:05 GMT-0500 (EST) by Nodejitsu, Inc (Using Codesurgeon).
+// Version 1.1.9
+//
+
+(function (exports) {
+
+
+/*
+ * browser.js: Browser specific functionality for director.
+ *
+ * (C) 2011, Nodejitsu Inc.
+ * MIT LICENSE
+ *
+ */
+
+if (!Array.prototype.filter) {
+ Array.prototype.filter = function(filter, that) {
+ var other = [], v;
+ for (var i = 0, n = this.length; i < n; i++) {
+ if (i in this && filter.call(that, v = this[i], i, this)) {
+ other.push(v);
+ }
+ }
+ return other;
+ };
+}
+
+if (!Array.isArray){
+ Array.isArray = function(obj) {
+ return Object.prototype.toString.call(obj) === '[object Array]';
+ };
+}
+
+var dloc = document.location;
+
+function dlocHashEmpty() {
+ // Non-IE browsers return '' when the address bar shows '#'; Director's logic
+ // assumes both mean empty.
+ return dloc.hash === '' || dloc.hash === '#';
+}
+
+var listener = {
+ mode: 'modern',
+ hash: dloc.hash,
+ history: false,
+
+ check: function () {
+ var h = dloc.hash;
+ if (h != this.hash) {
+ this.hash = h;
+ this.onHashChanged();
+ }
+ },
+
+ fire: function () {
+ if (this.mode === 'modern') {
+ this.history === true ? window.onpopstate() : window.onhashchange();
+ }
+ else {
+ this.onHashChanged();
+ }
+ },
+
+ init: function (fn, history) {
+ var self = this;
+ this.history = history;
+
+ if (!Router.listeners) {
+ Router.listeners = [];
+ }
+
+ function onchange(onChangeEvent) {
+ for (var i = 0, l = Router.listeners.length; i < l; i++) {
+ Router.listeners[i](onChangeEvent);
+ }
+ }
+
+ //note IE8 is being counted as 'modern' because it has the hashchange event
+ if ('onhashchange' in window && (document.documentMode === undefined
+ || document.documentMode > 7)) {
+ // At least for now HTML5 history is available for 'modern' browsers only
+ if (this.history === true) {
+ // There is an old bug in Chrome that causes onpopstate to fire even
+ // upon initial page load. Since the handler is run manually in init(),
+ // this would cause Chrome to run it twise. Currently the only
+ // workaround seems to be to set the handler after the initial page load
+ // http://code.google.com/p/chromium/issues/detail?id=63040
+ setTimeout(function() {
+ window.onpopstate = onchange;
+ }, 500);
+ }
+ else {
+ window.onhashchange = onchange;
+ }
+ this.mode = 'modern';
+ }
+ else {
+ //
+ // IE support, based on a concept by Erik Arvidson ...
+ //
+ var frame = document.createElement('iframe');
+ frame.id = 'state-frame';
+ frame.style.display = 'none';
+ document.body.appendChild(frame);
+ this.writeFrame('');
+
+ if ('onpropertychange' in document && 'attachEvent' in document) {
+ document.attachEvent('onpropertychange', function () {
+ if (event.propertyName === 'location') {
+ self.check();
+ }
+ });
+ }
+
+ window.setInterval(function () { self.check(); }, 50);
+
+ this.onHashChanged = onchange;
+ this.mode = 'legacy';
+ }
+
+ Router.listeners.push(fn);
+
+ return this.mode;
+ },
+
+ destroy: function (fn) {
+ if (!Router || !Router.listeners) {
+ return;
+ }
+
+ var listeners = Router.listeners;
+
+ for (var i = listeners.length - 1; i >= 0; i--) {
+ if (listeners[i] === fn) {
+ listeners.splice(i, 1);
+ }
+ }
+ },
+
+ setHash: function (s) {
+ // Mozilla always adds an entry to the history
+ if (this.mode === 'legacy') {
+ this.writeFrame(s);
+ }
+
+ if (this.history === true) {
+ window.history.pushState({}, document.title, s);
+ // Fire an onpopstate event manually since pushing does not obviously
+ // trigger the pop event.
+ this.fire();
+ } else {
+ dloc.hash = (s[0] === '/') ? s : '/' + s;
+ }
+ return this;
+ },
+
+ writeFrame: function (s) {
+ // IE support...
+ var f = document.getElementById('state-frame');
+ var d = f.contentDocument || f.contentWindow.document;
+ d.open();
+ d.write("<script>_hash = '" + s + "'; onload = parent.listener.syncHash;<script>");
+ d.close();
+ },
+
+ syncHash: function () {
+ // IE support...
+ var s = this._hash;
+ if (s != dloc.hash) {
+ dloc.hash = s;
+ }
+ return this;
+ },
+
+ onHashChanged: function () {}
+};
+
+var Router = exports.Router = function (routes) {
+ if (!(this instanceof Router)) return new Router(routes);
+
+ this.params = {};
+ this.routes = {};
+ this.methods = ['on', 'once', 'after', 'before'];
+ this.scope = [];
+ this._methods = {};
+
+ this._insert = this.insert;
+ this.insert = this.insertEx;
+
+ this.historySupport = (window.history != null ? window.history.pushState : null) != null
+
+ this.configure();
+ this.mount(routes || {});
+};
+
+Router.prototype.init = function (r) {
+ var self = this;
+ this.handler = function(onChangeEvent) {
+ var newURL = onChangeEvent && onChangeEvent.newURL || window.location.hash;
+ var url = self.history === true ? self.getPath() : newURL.replace(/.*#/, '');
+ self.dispatch('on', url);
+ };
+
+ listener.init(this.handler, this.history);
+
+ if (this.history === false) {
+ if (dlocHashEmpty() && r) {
+ dloc.hash = r;
+ } else if (!dlocHashEmpty()) {
+ self.dispatch('on', dloc.hash.replace(/^#/, ''));
+ }
+ }
+ else {
+ var routeTo = dlocHashEmpty() && r ? r : !dlocHashEmpty() ? dloc.hash.replace(/^#/, '') : null;
+ if (routeTo) {
+ window.history.replaceState({}, document.title, routeTo);
+ }
+
+ // Router has been initialized, but due to the chrome bug it will not
+ // yet actually route HTML5 history state changes. Thus, decide if should route.
+ if (routeTo || this.run_in_init === true) {
+ this.handler();
+ }
+ }
+
+ return this;
+};
+
+Router.prototype.explode = function () {
+ var v = this.history === true ? this.getPath() : dloc.hash;
+ if (v.charAt(1) === '/') { v=v.slice(1) }
+ return v.slice(1, v.length).split("/");
+};
+
+Router.prototype.setRoute = function (i, v, val) {
+ var url = this.explode();
+
+ if (typeof i === 'number' && typeof v === 'string') {
+ url[i] = v;
+ }
+ else if (typeof val === 'string') {
+ url.splice(i, v, s);
+ }
+ else {
+ url = [i];
+ }
+
+ listener.setHash(url.join('/'));
+ return url;
+};
+
+//
+// ### function insertEx(method, path, route, parent)
+// #### @method {string} Method to insert the specific `route`.
+// #### @path {Array} Parsed path to insert the `route` at.
+// #### @route {Array|function} Route handlers to insert.
+// #### @parent {Object} **Optional** Parent "routes" to insert into.
+// insert a callback that will only occur once per the matched route.
+//
+Router.prototype.insertEx = function(method, path, route, parent) {
+ if (method === "once") {
+ method = "on";
+ route = function(route) {
+ var once = false;
+ return function() {
+ if (once) return;
+ once = true;
+ return route.apply(this, arguments);
+ };
+ }(route);
+ }
+ return this._insert(method, path, route, parent);
+};
+
+Router.prototype.getRoute = function (v) {
+ var ret = v;
+
+ if (typeof v === "number") {
+ ret = this.explode()[v];
+ }
+ else if (typeof v === "string"){
+ var h = this.explode();
+ ret = h.indexOf(v);
+ }
+ else {
+ ret = this.explode();
+ }
+
+ return ret;
+};
+
+Router.prototype.destroy = function () {
+ listener.destroy(this.handler);
+ return this;
+};
+
+Router.prototype.getPath = function () {
+ var path = window.location.pathname;
+ if (path.substr(0, 1) !== '/') {
+ path = '/' + path;
+ }
+ return path;
+};
+function _every(arr, iterator) {
+ for (var i = 0; i < arr.length; i += 1) {
+ if (iterator(arr[i], i, arr) === false) {
+ return;
+ }
+ }
+}
+
+function _flatten(arr) {
+ var flat = [];
+ for (var i = 0, n = arr.length; i < n; i++) {
+ flat = flat.concat(arr[i]);
+ }
+ return flat;
+}
+
+function _asyncEverySeries(arr, iterator, callback) {
+ if (!arr.length) {
+ return callback();
+ }
+ var completed = 0;
+ (function iterate() {
+ iterator(arr[completed], function(err) {
+ if (err || err === false) {
+ callback(err);
+ callback = function() {};
+ } else {
+ completed += 1;
+ if (completed === arr.length) {
+ callback();
+ } else {
+ iterate();
+ }
+ }
+ });
+ })();
+}
+
+function paramifyString(str, params, mod) {
+ mod = str;
+ for (var param in params) {
+ if (params.hasOwnProperty(param)) {
+ mod = params[param](str);
+ if (mod !== str) {
+ break;
+ }
+ }
+ }
+ return mod === str ? "([._a-zA-Z0-9-]+)" : mod;
+}
+
+function regifyString(str, params) {
+ var matches, last = 0, out = "";
+ while (matches = str.substr(last).match(/[^\w\d\- %@&]*\*[^\w\d\- %@&]*/)) {
+ last = matches.index + matches[0].length;
+ matches[0] = matches[0].replace(/^\*/, "([_.()!\\ %@&a-zA-Z0-9-]+)");
+ out += str.substr(0, matches.index) + matches[0];
+ }
+ str = out += str.substr(last);
+ var captures = str.match(/:([^\/]+)/ig), length;
+ if (captures) {
+ length = captures.length;
+ for (var i = 0; i < length; i++) {
+ str = str.replace(captures[i], paramifyString(captures[i], params));
+ }
+ }
+ return str;
+}
+
+function terminator(routes, delimiter, start, stop) {
+ var last = 0, left = 0, right = 0, start = (start || "(").toString(), stop = (stop || ")").toString(), i;
+ for (i = 0; i < routes.length; i++) {
+ var chunk = routes[i];
+ if (chunk.indexOf(start, last) > chunk.indexOf(stop, last) || ~chunk.indexOf(start, last) && !~chunk.indexOf(stop, last) || !~chunk.indexOf(start, last) && ~chunk.indexOf(stop, last)) {
+ left = chunk.indexOf(start, last);
+ right = chunk.indexOf(stop, last);
+ if (~left && !~right || !~left && ~right) {
+ var tmp = routes.slice(0, (i || 1) + 1).join(delimiter);
+ routes = [ tmp ].concat(routes.slice((i || 1) + 1));
+ }
+ last = (right > left ? right : left) + 1;
+ i = 0;
+ } else {
+ last = 0;
+ }
+ }
+ return routes;
+}
+
+Router.prototype.configure = function(options) {
+ options = options || {};
+ for (var i = 0; i < this.methods.length; i++) {
+ this._methods[this.methods[i]] = true;
+ }
+ this.recurse = options.recurse || this.recurse || false;
+ this.async = options.async || false;
+ this.delimiter = options.delimiter || "/";
+ this.strict = typeof options.strict === "undefined" ? true : options.strict;
+ this.notfound = options.notfound;
+ this.resource = options.resource;
+ this.history = options.html5history && this.historySupport || false;
+ this.run_in_init = this.history === true && options.run_handler_in_init !== false;
+ this.every = {
+ after: options.after || null,
+ before: options.before || null,
+ on: options.on || null
+ };
+ return this;
+};
+
+Router.prototype.param = function(token, matcher) {
+ if (token[0] !== ":") {
+ token = ":" + token;
+ }
+ var compiled = new RegExp(token, "g");
+ this.params[token] = function(str) {
+ return str.replace(compiled, matcher.source || matcher);
+ };
+};
+
+Router.prototype.on = Router.prototype.route = function(method, path, route) {
+ var self = this;
+ if (!route && typeof path == "function") {
+ route = path;
+ path = method;
+ method = "on";
+ }
+ if (Array.isArray(path)) {
+ return path.forEach(function(p) {
+ self.on(method, p, route);
+ });
+ }
+ if (path.source) {
+ path = path.source.replace(/\\\//ig, "/");
+ }
+ if (Array.isArray(method)) {
+ return method.forEach(function(m) {
+ self.on(m.toLowerCase(), path, route);
+ });
+ }
+ path = path.split(new RegExp(this.delimiter));
+ path = terminator(path, this.delimiter);
+ this.insert(method, this.scope.concat(path), route);
+};
+
+Router.prototype.dispatch = function(method, path, callback) {
+ var self = this, fns = this.traverse(method, path, this.routes, ""), invoked = this._invoked, after;
+ this._invoked = true;
+ if (!fns || fns.length === 0) {
+ this.last = [];
+ if (typeof this.notfound === "function") {
+ this.invoke([ this.notfound ], {
+ method: method,
+ path: path
+ }, callback);
+ }
+ return false;
+ }
+ if (this.recurse === "forward") {
+ fns = fns.reverse();
+ }
+ function updateAndInvoke() {
+ self.last = fns.after;
+ self.invoke(self.runlist(fns), self, callback);
+ }
+ after = this.every && this.every.after ? [ this.every.after ].concat(this.last) : [ this.last ];
+ if (after && after.length > 0 && invoked) {
+ if (this.async) {
+ this.invoke(after, this, updateAndInvoke);
+ } else {
+ this.invoke(after, this);
+ updateAndInvoke();
+ }
+ return true;
+ }
+ updateAndInvoke();
+ return true;
+};
+
+Router.prototype.invoke = function(fns, thisArg, callback) {
+ var self = this;
+ if (this.async) {
+ _asyncEverySeries(fns, function apply(fn, next) {
+ if (Array.isArray(fn)) {
+ return _asyncEverySeries(fn, apply, next);
+ } else if (typeof fn == "function") {
+ fn.apply(thisArg, fns.captures.concat(next));
+ }
+ }, function() {
+ if (callback) {
+ callback.apply(thisArg, arguments);
+ }
+ });
+ } else {
+ _every(fns, function apply(fn) {
+ if (Array.isArray(fn)) {
+ return _every(fn, apply);
+ } else if (typeof fn === "function") {
+ return fn.apply(thisArg, fns.captures || []);
+ } else if (typeof fn === "string" && self.resource) {
+ self.resource[fn].apply(thisArg, fns.captures || []);
+ }
+ });
+ }
+};
+
+Router.prototype.traverse = function(method, path, routes, regexp, filter) {
+ var fns = [], current, exact, match, next, that;
+ function filterRoutes(routes) {
+ if (!filter) {
+ return routes;
+ }
+ function deepCopy(source) {
+ var result = [];
+ for (var i = 0; i < source.length; i++) {
+ result[i] = Array.isArray(source[i]) ? deepCopy(source[i]) : source[i];
+ }
+ return result;
+ }
+ function applyFilter(fns) {
+ for (var i = fns.length - 1; i >= 0; i--) {
+ if (Array.isArray(fns[i])) {
+ applyFilter(fns[i]);
+ if (fns[i].length === 0) {
+ fns.splice(i, 1);
+ }
+ } else {
+ if (!filter(fns[i])) {
+ fns.splice(i, 1);
+ }
+ }
+ }
+ }
+ var newRoutes = deepCopy(routes);
+ newRoutes.matched = routes.matched;
+ newRoutes.captures = routes.captures;
+ newRoutes.after = routes.after.filter(filter);
+ applyFilter(newRoutes);
+ return newRoutes;
+ }
+ if (path === this.delimiter && routes[method]) {
+ next = [ [ routes.before, routes[method] ].filter(Boolean) ];
+ next.after = [ routes.after ].filter(Boolean);
+ next.matched = true;
+ next.captures = [];
+ return filterRoutes(next);
+ }
+ for (var r in routes) {
+ if (routes.hasOwnProperty(r) && (!this._methods[r] || this._methods[r] && typeof routes[r] === "object" && !Array.isArray(routes[r]))) {
+ current = exact = regexp + this.delimiter + r;
+ if (!this.strict) {
+ exact += "[" + this.delimiter + "]?";
+ }
+ match = path.match(new RegExp("^" + exact));
+ if (!match) {
+ continue;
+ }
+ if (match[0] && match[0] == path && routes[r][method]) {
+ next = [ [ routes[r].before, routes[r][method] ].filter(Boolean) ];
+ next.after = [ routes[r].after ].filter(Boolean);
+ next.matched = true;
+ next.captures = match.slice(1);
+ if (this.recurse && routes === this.routes) {
+ next.push([ routes.before, routes.on ].filter(Boolean));
+ next.after = next.after.concat([ routes.after ].filter(Boolean));
+ }
+ return filterRoutes(next);
+ }
+ next = this.traverse(method, path, routes[r], current);
+ if (next.matched) {
+ if (next.length > 0) {
+ fns = fns.concat(next);
+ }
+ if (this.recurse) {
+ fns.push([ routes[r].before, routes[r].on ].filter(Boolean));
+ next.after = next.after.concat([ routes[r].after ].filter(Boolean));
+ if (routes === this.routes) {
+ fns.push([ routes["before"], routes["on"] ].filter(Boolean));
+ next.after = next.after.concat([ routes["after"] ].filter(Boolean));
+ }
+ }
+ fns.matched = true;
+ fns.captures = next.captures;
+ fns.after = next.after;
+ return filterRoutes(fns);
+ }
+ }
+ }
+ return false;
+};
+
+Router.prototype.insert = function(method, path, route, parent) {
+ var methodType, parentType, isArray, nested, part;
+ path = path.filter(function(p) {
+ return p && p.length > 0;
+ });
+ parent = parent || this.routes;
+ part = path.shift();
+ if (/\:|\*/.test(part) && !/\\d|\\w/.test(part)) {
+ part = regifyString(part, this.params);
+ }
+ if (path.length > 0) {
+ parent[part] = parent[part] || {};
+ return this.insert(method, path, route, parent[part]);
+ }
+ if (!part && !path.length && parent === this.routes) {
+ methodType = typeof parent[method];
+ switch (methodType) {
+ case "function":
+ parent[method] = [ parent[method], route ];
+ return;
+ case "object":
+ parent[method].push(route);
+ return;
+ case "undefined":
+ parent[method] = route;
+ return;
+ }
+ return;
+ }
+ parentType = typeof parent[part];
+ isArray = Array.isArray(parent[part]);
+ if (parent[part] && !isArray && parentType == "object") {
+ methodType = typeof parent[part][method];
+ switch (methodType) {
+ case "function":
+ parent[part][method] = [ parent[part][method], route ];
+ return;
+ case "object":
+ parent[part][method].push(route);
+ return;
+ case "undefined":
+ parent[part][method] = route;
+ return;
+ }
+ } else if (parentType == "undefined") {
+ nested = {};
+ nested[method] = route;
+ parent[part] = nested;
+ return;
+ }
+ throw new Error("Invalid route context: " + parentType);
+};
+
+
+
+Router.prototype.extend = function(methods) {
+ var self = this, len = methods.length, i;
+ function extend(method) {
+ self._methods[method] = true;
+ self[method] = function() {
+ var extra = arguments.length === 1 ? [ method, "" ] : [ method ];
+ self.on.apply(self, extra.concat(Array.prototype.slice.call(arguments)));
+ };
+ }
+ for (i = 0; i < len; i++) {
+ extend(methods[i]);
+ }
+};
+
+Router.prototype.runlist = function(fns) {
+ var runlist = this.every && this.every.before ? [ this.every.before ].concat(_flatten(fns)) : _flatten(fns);
+ if (this.every && this.every.on) {
+ runlist.push(this.every.on);
+ }
+ runlist.captures = fns.captures;
+ runlist.source = fns.source;
+ return runlist;
+};
+
+Router.prototype.mount = function(routes, path) {
+ if (!routes || typeof routes !== "object" || Array.isArray(routes)) {
+ return;
+ }
+ var self = this;
+ path = path || [];
+ if (!Array.isArray(path)) {
+ path = path.split(self.delimiter);
+ }
+ function insertOrMount(route, local) {
+ var rename = route, parts = route.split(self.delimiter), routeType = typeof routes[route], isRoute = parts[0] === "" || !self._methods[parts[0]], event = isRoute ? "on" : rename;
+ if (isRoute) {
+ rename = rename.slice((rename.match(new RegExp(self.delimiter)) || [ "" ])[0].length);
+ parts.shift();
+ }
+ if (isRoute && routeType === "object" && !Array.isArray(routes[route])) {
+ local = local.concat(parts);
+ self.mount(routes[route], local);
+ return;
+ }
+ if (isRoute) {
+ local = local.concat(rename.split(self.delimiter));
+ local = terminator(local, self.delimiter);
+ }
+ self.insert(event, local, routes[route]);
+ }
+ for (var route in routes) {
+ if (routes.hasOwnProperty(route)) {
+ insertOrMount(route, path.slice(0));
+ }
+ }
+};
+
+
+
+}(typeof exports === "object" ? exports : window)); \ No newline at end of file
diff --git a/third_party/webkit/PerformanceTests/Speedometer/resources/todomvc/labs/architecture-examples/react/bower_components/director/build/director.min.js b/third_party/webkit/PerformanceTests/Speedometer/resources/todomvc/labs/architecture-examples/react/bower_components/director/build/director.min.js
new file mode 100644
index 0000000000..63ec288fc1
--- /dev/null
+++ b/third_party/webkit/PerformanceTests/Speedometer/resources/todomvc/labs/architecture-examples/react/bower_components/director/build/director.min.js
@@ -0,0 +1,7 @@
+
+
+//
+// Generated on Sun Dec 16 2012 22:47:05 GMT-0500 (EST) by Nodejitsu, Inc (Using Codesurgeon).
+// Version 1.1.9
+//
+(function(a){function k(a,b,c,d){var e=0,f=0,g=0,c=(c||"(").toString(),d=(d||")").toString(),h;for(h=0;h<a.length;h++){var i=a[h];if(i.indexOf(c,e)>i.indexOf(d,e)||~i.indexOf(c,e)&&!~i.indexOf(d,e)||!~i.indexOf(c,e)&&~i.indexOf(d,e)){f=i.indexOf(c,e),g=i.indexOf(d,e);if(~f&&!~g||!~f&&~g){var j=a.slice(0,(h||1)+1).join(b);a=[j].concat(a.slice((h||1)+1))}e=(g>f?g:f)+1,h=0}else e=0}return a}function j(a,b){var c,d=0,e="";while(c=a.substr(d).match(/[^\w\d\- %@&]*\*[^\w\d\- %@&]*/))d=c.index+c[0].length,c[0]=c[0].replace(/^\*/,"([_.()!\\ %@&a-zA-Z0-9-]+)"),e+=a.substr(0,c.index)+c[0];a=e+=a.substr(d);var f=a.match(/:([^\/]+)/ig),g;if(f){g=f.length;for(var h=0;h<g;h++)a=a.replace(f[h],i(f[h],b))}return a}function i(a,b,c){c=a;for(var d in b)if(b.hasOwnProperty(d)){c=b[d](a);if(c!==a)break}return c===a?"([._a-zA-Z0-9-]+)":c}function h(a,b,c){if(!a.length)return c();var d=0;(function e(){b(a[d],function(b){b||b===!1?(c(b),c=function(){}):(d+=1,d===a.length?c():e())})})()}function g(a){var b=[];for(var c=0,d=a.length;c<d;c++)b=b.concat(a[c]);return b}function f(a,b){for(var c=0;c<a.length;c+=1)if(b(a[c],c,a)===!1)return}function c(){return b.hash===""||b.hash==="#"}Array.prototype.filter||(Array.prototype.filter=function(a,b){var c=[],d;for(var e=0,f=this.length;e<f;e++)e in this&&a.call(b,d=this[e],e,this)&&c.push(d);return c}),Array.isArray||(Array.isArray=function(a){return Object.prototype.toString.call(a)==="[object Array]"});var b=document.location,d={mode:"modern",hash:b.hash,history:!1,check:function(){var a=b.hash;a!=this.hash&&(this.hash=a,this.onHashChanged())},fire:function(){this.mode==="modern"?this.history===!0?window.onpopstate():window.onhashchange():this.onHashChanged()},init:function(a,b){function d(a){for(var b=0,c=e.listeners.length;b<c;b++)e.listeners[b](a)}var c=this;this.history=b,e.listeners||(e.listeners=[]);if("onhashchange"in window&&(document.documentMode===undefined||document.documentMode>7))this.history===!0?setTimeout(function(){window.onpopstate=d},500):window.onhashchange=d,this.mode="modern";else{var f=document.createElement("iframe");f.id="state-frame",f.style.display="none",document.body.appendChild(f),this.writeFrame(""),"onpropertychange"in document&&"attachEvent"in document&&document.attachEvent("onpropertychange",function(){event.propertyName==="location"&&c.check()}),window.setInterval(function(){c.check()},50),this.onHashChanged=d,this.mode="legacy"}e.listeners.push(a);return this.mode},destroy:function(a){if(!!e&&!!e.listeners){var b=e.listeners;for(var c=b.length-1;c>=0;c--)b[c]===a&&b.splice(c,1)}},setHash:function(a){this.mode==="legacy"&&this.writeFrame(a),this.history===!0?(window.history.pushState({},document.title,a),this.fire()):b.hash=a[0]==="/"?a:"/"+a;return this},writeFrame:function(a){var b=document.getElementById("state-frame"),c=b.contentDocument||b.contentWindow.document;c.open(),c.write("<script>_hash = '"+a+"'; onload = parent.listener.syncHash;<script>"),c.close()},syncHash:function(){var a=this._hash;a!=b.hash&&(b.hash=a);return this},onHashChanged:function(){}},e=a.Router=function(a){if(this instanceof e)this.params={},this.routes={},this.methods=["on","once","after","before"],this.scope=[],this._methods={},this._insert=this.insert,this.insert=this.insertEx,this.historySupport=(window.history!=null?window.history.pushState:null)!=null,this.configure(),this.mount(a||{});else return new e(a)};e.prototype.init=function(a){var e=this;this.handler=function(a){var b=a&&a.newURL||window.location.hash,c=e.history===!0?e.getPath():b.replace(/.*#/,"");e.dispatch("on",c)},d.init(this.handler,this.history);if(this.history===!1)c()&&a?b.hash=a:c()||e.dispatch("on",b.hash.replace(/^#/,""));else{var f=c()&&a?a:c()?null:b.hash.replace(/^#/,"");f&&window.history.replaceState({},document.title,f),(f||this.run_in_init===!0)&&this.handler()}return this},e.prototype.explode=function(){var a=this.history===!0?this.getPath():b.hash;a.charAt(1)==="/"&&(a=a.slice(1));return a.slice(1,a.length).split("/")},e.prototype.setRoute=function(a,b,c){var e=this.explode();typeof a=="number"&&typeof b=="string"?e[a]=b:typeof c=="string"?e.splice(a,b,s):e=[a],d.setHash(e.join("/"));return e},e.prototype.insertEx=function(a,b,c,d){a==="once"&&(a="on",c=function(a){var b=!1;return function(){if(!b){b=!0;return a.apply(this,arguments)}}}(c));return this._insert(a,b,c,d)},e.prototype.getRoute=function(a){var b=a;if(typeof a=="number")b=this.explode()[a];else if(typeof a=="string"){var c=this.explode();b=c.indexOf(a)}else b=this.explode();return b},e.prototype.destroy=function(){d.destroy(this.handler);return this},e.prototype.getPath=function(){var a=window.location.pathname;a.substr(0,1)!=="/"&&(a="/"+a);return a},e.prototype.configure=function(a){a=a||{};for(var b=0;b<this.methods.length;b++)this._methods[this.methods[b]]=!0;this.recurse=a.recurse||this.recurse||!1,this.async=a.async||!1,this.delimiter=a.delimiter||"/",this.strict=typeof a.strict=="undefined"?!0:a.strict,this.notfound=a.notfound,this.resource=a.resource,this.history=a.html5history&&this.historySupport||!1,this.run_in_init=this.history===!0&&a.run_handler_in_init!==!1,this.every={after:a.after||null,before:a.before||null,on:a.on||null};return this},e.prototype.param=function(a,b){a[0]!==":"&&(a=":"+a);var c=new RegExp(a,"g");this.params[a]=function(a){return a.replace(c,b.source||b)}},e.prototype.on=e.prototype.route=function(a,b,c){var d=this;!c&&typeof b=="function"&&(c=b,b=a,a="on");if(Array.isArray(b))return b.forEach(function(b){d.on(a,b,c)});b.source&&(b=b.source.replace(/\\\//ig,"/"));if(Array.isArray(a))return a.forEach(function(a){d.on(a.toLowerCase(),b,c)});b=b.split(new RegExp(this.delimiter)),b=k(b,this.delimiter),this.insert(a,this.scope.concat(b),c)},e.prototype.dispatch=function(a,b,c){function h(){d.last=e.after,d.invoke(d.runlist(e),d,c)}var d=this,e=this.traverse(a,b,this.routes,""),f=this._invoked,g;this._invoked=!0;if(!e||e.length===0){this.last=[],typeof this.notfound=="function"&&this.invoke([this.notfound],{method:a,path:b},c);return!1}this.recurse==="forward"&&(e=e.reverse()),g=this.every&&this.every.after?[this.every.after].concat(this.last):[this.last];if(g&&g.length>0&&f){this.async?this.invoke(g,this,h):(this.invoke(g,this),h());return!0}h();return!0},e.prototype.invoke=function(a,b,c){var d=this;this.async?h(a,function e(c,d){if(Array.isArray(c))return h(c,e,d);typeof c=="function"&&c.apply(b,a.captures.concat(d))},function(){c&&c.apply(b,arguments)}):f(a,function g(c){if(Array.isArray(c))return f(c,g);if(typeof c=="function")return c.apply(b,a.captures||[]);typeof c=="string"&&d.resource&&d.resource[c].apply(b,a.captures||[])})},e.prototype.traverse=function(a,b,c,d,e){function l(a){function c(a){for(var b=a.length-1;b>=0;b--)Array.isArray(a[b])?(c(a[b]),a[b].length===0&&a.splice(b,1)):e(a[b])||a.splice(b,1)}function b(a){var c=[];for(var d=0;d<a.length;d++)c[d]=Array.isArray(a[d])?b(a[d]):a[d];return c}if(!e)return a;var d=b(a);d.matched=a.matched,d.captures=a.captures,d.after=a.after.filter(e),c(d);return d}var f=[],g,h,i,j,k;if(b===this.delimiter&&c[a]){j=[[c.before,c[a]].filter(Boolean)],j.after=[c.after].filter(Boolean),j.matched=!0,j.captures=[];return l(j)}for(var m in c)if(c.hasOwnProperty(m)&&(!this._methods[m]||this._methods[m]&&typeof c[m]=="object"&&!Array.isArray(c[m]))){g=h=d+this.delimiter+m,this.strict||(h+="["+this.delimiter+"]?"),i=b.match(new RegExp("^"+h));if(!i)continue;if(i[0]&&i[0]==b&&c[m][a]){j=[[c[m].before,c[m][a]].filter(Boolean)],j.after=[c[m].after].filter(Boolean),j.matched=!0,j.captures=i.slice(1),this.recurse&&c===this.routes&&(j.push([c.before,c.on].filter(Boolean)),j.after=j.after.concat([c.after].filter(Boolean)));return l(j)}j=this.traverse(a,b,c[m],g);if(j.matched){j.length>0&&(f=f.concat(j)),this.recurse&&(f.push([c[m].before,c[m].on].filter(Boolean)),j.after=j.after.concat([c[m].after].filter(Boolean)),c===this.routes&&(f.push([c.before,c.on].filter(Boolean)),j.after=j.after.concat([c.after].filter(Boolean)))),f.matched=!0,f.captures=j.captures,f.after=j.after;return l(f)}}return!1},e.prototype.insert=function(a,b,c,d){var e,f,g,h,i;b=b.filter(function(a){return a&&a.length>0}),d=d||this.routes,i=b.shift(),/\:|\*/.test(i)&&!/\\d|\\w/.test(i)&&(i=j(i,this.params));if(b.length>0){d[i]=d[i]||{};return this.insert(a,b,c,d[i])}{if(!!i||!!b.length||d!==this.routes){f=typeof d[i],g=Array.isArray(d[i]);if(d[i]&&!g&&f=="object"){e=typeof d[i][a];switch(e){case"function":d[i][a]=[d[i][a],c];return;case"object":d[i][a].push(c);return;case"undefined":d[i][a]=c;return}}else if(f=="undefined"){h={},h[a]=c,d[i]=h;return}throw new Error("Invalid route context: "+f)}e=typeof d[a];switch(e){case"function":d[a]=[d[a],c];return;case"object":d[a].push(c);return;case"undefined":d[a]=c;return}}},e.prototype.extend=function(a){function e(a){b._methods[a]=!0,b[a]=function(){var c=arguments.length===1?[a,""]:[a];b.on.apply(b,c.concat(Array.prototype.slice.call(arguments)))}}var b=this,c=a.length,d;for(d=0;d<c;d++)e(a[d])},e.prototype.runlist=function(a){var b=this.every&&this.every.before?[this.every.before].concat(g(a)):g(a);this.every&&this.every.on&&b.push(this.every.on),b.captures=a.captures,b.source=a.source;return b},e.prototype.mount=function(a,b){function d(b,d){var e=b,f=b.split(c.delimiter),g=typeof a[b],h=f[0]===""||!c._methods[f[0]],i=h?"on":e;h&&(e=e.slice((e.match(new RegExp(c.delimiter))||[""])[0].length),f.shift());h&&g==="object"&&!Array.isArray(a[b])?(d=d.concat(f),c.mount(a[b],d)):(h&&(d=d.concat(e.split(c.delimiter)),d=k(d,c.delimiter)),c.insert(i,d,a[b]))}if(!!a&&typeof a=="object"&&!Array.isArray(a)){var c=this;b=b||[],Array.isArray(b)||(b=b.split(c.delimiter));for(var e in a)a.hasOwnProperty(e)&&d(e,b.slice(0))}}})(typeof exports=="object"?exports:window) \ No newline at end of file
diff --git a/third_party/webkit/PerformanceTests/Speedometer/resources/todomvc/labs/architecture-examples/react/bower_components/director/build/ender.js b/third_party/webkit/PerformanceTests/Speedometer/resources/todomvc/labs/architecture-examples/react/bower_components/director/build/ender.js
new file mode 100644
index 0000000000..fe3ebc41b0
--- /dev/null
+++ b/third_party/webkit/PerformanceTests/Speedometer/resources/todomvc/labs/architecture-examples/react/bower_components/director/build/ender.js
@@ -0,0 +1,3 @@
+$.ender({
+ router: Router
+});