@samitouri / QOS-React-2 / commits / 1d0c1b1817

Use fbjs package from npm, gulp

This reworks a few things in building and distributing React. The biggest change is using fbjs to share dependencies with other libraries. We're also using Gulp for some build steps.

Paul O’Shannessy committed Jul 17, 2015 at 18:20 UTC 1d0c1b18170768d71105dee55cb8bbd3674f8251
49 files changed +167 -1637
Gruntfile.js
+32 -11
@@ -1,5 +1,8 @@
1 'use strict';
2
3 +var assign = require('object-assign');
4 +var path = require('path');
5 +
6 module.exports = function(grunt) {
7
8 grunt.initConfig({
@@ -21,6 +24,21 @@ module.exports = function(grunt) {
24
25 grunt.config.set('compress', require('./grunt/config/compress'));
26
27 + function spawnGulp(args, opts, done) {
28 + grunt.util.spawn({
29 + // This could be more flexible (require.resolve & lookup bin in package)
30 + // but if it breaks we'll fix it then.
31 + cmd: path.join('node_modules', '.bin', 'gulpp'),
32 + args: args,
33 + opts: assign({stdio: 'inherit'}, opts),
34 + }, function(err, result, code) {
35 + if (err) {
36 + grunt.fail.fatal('Something went wrong running gulp: ', result);
37 + }
38 + done(code === 0);
39 + });
40 + }
41 +
42 Object.keys(grunt.file.readJSON('package.json').devDependencies)
43 .filter(function(npmTaskName) {
44 return npmTaskName.indexOf('grunt-') === 0;
@@ -37,9 +55,8 @@ module.exports = function(grunt) {
55 grunt.registerTask('lint', ['eslint']);
56
57 grunt.registerTask('delete-build-modules', function() {
40 - if (grunt.file.exists('build/modules')) {
41 - grunt.file.delete('build/modules');
42 - }
58 + // Use gulp here
59 + spawnGulp(['react:clean'], null, this.async());
60 });
61
62 // Register jsx:normal and :release tasks.
@@ -68,30 +85,30 @@ module.exports = function(grunt) {
85 grunt.registerTask('version-check', require('./grunt/tasks/version-check'));
86
87 grunt.registerTask('build:basic', [
71 - 'jsx:normal',
88 + 'build-modules',
89 'version-check',
90 'browserify:basic',
91 ]);
92 grunt.registerTask('build:addons', [
76 - 'jsx:normal',
93 + 'build-modules',
94 'browserify:addons',
95 ]);
96 grunt.registerTask('build:transformer', [
80 - 'jsx:normal',
97 + 'build-modules',
98 'browserify:transformer',
99 ]);
100 grunt.registerTask('build:min', [
84 - 'jsx:normal',
101 + 'build-modules',
102 'version-check',
103 'browserify:min',
104 ]);
105 grunt.registerTask('build:addons-min', [
89 - 'jsx:normal',
106 + 'build-modules',
107 'browserify:addonsMin',
108 ]);
109 grunt.registerTask('build:npm-react', [
110 'version-check',
94 - 'jsx:normal',
111 + 'build-modules',
112 'npm-react:release',
113 ]);
114
@@ -102,10 +119,10 @@ module.exports = function(grunt) {
119 grunt.registerTask('npm:test', ['build', 'npm:pack']);
120
121 // Optimized build task that does all of our builds. The subtasks will be run
105 - // in order so we can take advantage of that and only run jsx:normal once.
122 + // in order so we can take advantage of that and only run build-modules once.
123 grunt.registerTask('build', [
124 'delete-build-modules',
108 - 'jsx:normal',
125 + 'build-modules',
126 'version-check',
127 'browserify:basic',
128 'browserify:transformer',
@@ -141,6 +158,10 @@ module.exports = function(grunt) {
158 'release:msg',
159 ]);
160
161 + grunt.registerTask('build-modules', function() {
162 + spawnGulp(['react:modules'], null, this.async());
163 + });
164 +
165 // The default task - build - to keep setup easy.
166 grunt.registerTask('default', ['build']);
167 };
bin/jsx-internal
+7 -6
@@ -1,16 +1,17 @@
1 #!/usr/bin/env node
2 // -*- mode: js -*-
3 // vim: set ft=javascript :
4 -"use strict";
4 +
5 +'use strict';
6
7 var babel = require('babel');
8
8 -var constants = require('../vendor/constants')(babel);
9 +var devExpressionPlugin = require('fbjs/scripts/babel/dev-expression');
10
11 var TRANSFORM_IGNORE_RE = /^WebComponents$/;
12
12 -require("commoner").version(
13 - require("../package.json").version
13 +require('commoner').version(
14 + require('../package.json').version
15 ).resolve(function(id) {
16 var context = this;
17
@@ -38,8 +39,8 @@ require("commoner").version(
39 // This is where JSX, ES6, etc. desugaring happens.
40 source = babel.transform(source, {
41 blacklist: ['spec.functionName', 'validation.react'],
41 - plugins: [constants],
42 - filename: id
42 + plugins: [devExpressionPlugin],
43 + filename: id,
44 }).code;
45 }
46
grunt/tasks/browserify.js
+3
@@ -15,15 +15,18 @@ module.exports = function() {
15 config.transforms = config.transforms || [];
16 config.plugins = config.plugins || [];
17 config.after = config.after || [];
18 + config.paths = config.paths || [];
19
20 // create the bundle we'll work with
21 var entries = grunt.file.expand(config.entries);
22 + var paths = grunt.file.expand(config.paths);
23
24 // Extract other options
25 var options = {
26 entries: entries,
27 debug: config.debug, // sourcemaps
28 standalone: config.standalone, // global
29 + paths: paths,
30 };
31
32 var bundle = browserify(options);
gulpfile.js new
+56
@@ -0,0 +1,56 @@
1 +/**
2 + * Copyright 2013-2015, Facebook, Inc.
3 + * All rights reserved.
4 + *
5 + * This source code is licensed under the BSD-style license found in the
6 + * LICENSE file in the root directory of this source tree. An additional grant
7 + * of patent rights can be found in the PATENTS file in the same directory.
8 + */
9 +
10 +'use strict';
11 +
12 +var gulp = require('gulp');
13 +var babel = require('gulp-babel');
14 +var flatten = require('gulp-flatten');
15 +var del = require('del');
16 +
17 +var babelPluginDEV = require('fbjs/scripts/babel/dev-expression');
18 +var babelPluginRequires = require('fbjs/scripts/babel/rewrite-requires');
19 +
20 +var paths = {
21 + react: {
22 + src: [
23 + 'src/**/*.js',
24 + '!src/**/__tests__/**/*.js',
25 + '!src/**/__mocks__/**/*.js',
26 + ],
27 + lib: 'build/modules',
28 + },
29 +};
30 +
31 +var babelOpts = {
32 + nonStandard: true,
33 + blacklist: [
34 + 'spec.functionName',
35 + ],
36 + optional: [
37 + 'es7.trailingFunctionCommas',
38 + ],
39 + plugins: [babelPluginDEV, babelPluginRequires],
40 + ignore: ['third_party'],
41 + _moduleMap: require('fbjs/module-map'),
42 +};
43 +
44 +gulp.task('react:clean', function(cb) {
45 + del([paths.react.lib], cb);
46 +});
47 +
48 +gulp.task('react:modules', function() {
49 + return gulp
50 + .src(paths.react.src)
51 + .pipe(babel(babelOpts))
52 + .pipe(flatten())
53 + .pipe(gulp.dest(paths.react.lib));
54 +});
55 +
56 +gulp.task('default', ['react:modules']);
jest/preprocessor.js deleted
-32
@@ -1,32 +0,0 @@
1 -'use strict';
2 -
3 -var babel = require('babel');
4 -var coffee = require('coffee-script');
5 -
6 -var tsPreprocessor = require('./ts-preprocessor');
7 -
8 -var defaultLibraries = [
9 - require.resolve('./jest.d.ts'),
10 - require.resolve('../src/isomorphic/modern/class/React.d.ts'),
11 -];
12 -
13 -var ts = tsPreprocessor(defaultLibraries);
14 -
15 -module.exports = {
16 - process: function(src, path) {
17 - if (path.match(/\.coffee$/)) {
18 - return coffee.compile(src, {'bare': true});
19 - }
20 - if (path.match(/\.ts$/) && !path.match(/\.d\.ts$/)) {
21 - return ts.compile(src, path);
22 - }
23 - if (!path.match(/\/node_modules\//) && !path.match(/\/third_party\//)) {
24 - return babel.transform(src, {
25 - blacklist: ['spec.functionName', 'validation.react'],
26 - filename: path,
27 - retainLines: true,
28 - }).code;
29 - }
30 - return src;
31 - },
32 -};
package.json
+14 -6
@@ -35,23 +35,31 @@
35 "browserify": "^9.0.3",
36 "bundle-collapser": "^1.1.1",
37 "coffee-script": "^1.8.0",
38 + "del": "^1.2.0",
39 "derequire": "^2.0.0",
40 "envify": "^3.0.0",
41 "eslint": "^0.24.1",
42 "eslint-plugin-react": "^2.5.0",
43 "eslint-plugin-react-internal": "file:eslint-rules",
44 "eslint-tester": "^0.7.0",
45 + "fbjs": "^0.1.0-alpha.0",
46 "grunt": "^0.4.5",
47 "grunt-cli": "^0.1.13",
48 "grunt-compare-size": "^0.4.0",
49 "grunt-contrib-clean": "^0.6.0",
50 "grunt-contrib-compress": "^0.13.0",
51 "grunt-jest": "^0.1.3",
52 + "gulp": "^3.9.0",
53 + "gulp-babel": "^5.1.0",
54 + "gulp-flatten": "^0.1.0",
55 + "gulp-util": "^3.0.5",
56 "gzip-js": "~0.3.2",
57 "jest-cli": "^0.4.13",
58 "object-assign": "^3.0.0",
59 "optimist": "^0.6.1",
60 "platform": "^1.1.0",
61 + "run-sequence": "^1.1.0",
62 + "through2": "^2.0.0",
63 "tmp": "~0.0.18",
64 "typescript": "~1.4.0",
65 "uglify-js": "^2.4.23",
@@ -66,21 +74,20 @@
74 },
75 "scripts": {
76 "build": "grunt build",
69 - "jest": "jest",
77 + "jest": "test",
78 "linc": "git diff --name-only --diff-filter=ACMRTUB `git merge-base HEAD master` | grep '\\.js$' | xargs eslint --",
79 "lint": "grunt lint",
72 - "test": "jest"
80 + "test": "NODE_ENV=test jest"
81 },
82 "jest": {
83 "modulePathIgnorePatterns": [
84 "/.module-cache/",
77 - "/node_modules/",
85 "/react/build/"
86 ],
87 "persistModuleRegistryBetweenSpecs": true,
88 "rootDir": "",
82 - "scriptPreprocessor": "jest/preprocessor.js",
83 - "setupEnvScriptFile": "jest/environment.js",
89 + "scriptPreprocessor": "scripts/jest/preprocessor.js",
90 + "setupEnvScriptFile": "scripts/jest/environment.js",
91 "testFileExtensions": [
92 "coffee",
93 "js",
@@ -88,7 +95,8 @@
95 ],
96 "testPathDirs": [
97 "<rootDir>/eslint-rules",
91 - "<rootDir>/src"
98 + "<rootDir>/src",
99 + "node_modules/fbjs"
100 ],
101 "unmockedModulePathPatterns": [
102 ""
packages/react-dom/package.json
+1
@@ -16,6 +16,7 @@
16 },
17 "homepage": "https://github.com/facebook/react/tree/master/npm-react-dom",
18 "dependencies": {
19 + "fbjs": "0.1.0-alpha.0",
20 "react": "^0.14.0-beta1"
21 }
22 }
packages/react/package.json
+2 -1
@@ -24,7 +24,8 @@
24 "node": ">=0.10.0"
25 },
26 "dependencies": {
27 - "envify": "^3.0.0"
27 + "envify": "^3.0.0",
28 + "fbjs": "0.1.0-alpha.0"
29 },
30 "browserify": {
31 "transform": [
scripts/jest/environment.js renamed
scripts/jest/jest.d.ts renamed
scripts/jest/preprocessor.js new
+50
@@ -0,0 +1,50 @@
1 +'use strict';
2 +
3 +var babel = require('babel');
4 +var coffee = require('coffee-script');
5 +
6 +var tsPreprocessor = require('./ts-preprocessor');
7 +
8 +var defaultLibraries = [
9 + require.resolve('./jest.d.ts'),
10 + require.resolve('../../src/isomorphic/modern/class/React.d.ts'),
11 +];
12 +
13 +var ts = tsPreprocessor(defaultLibraries);
14 +
15 +// This assumes the module map has been built. This might not be safe.
16 +// We should consider consuming this from a built fbjs module from npm.
17 +var moduleMap = require('fbjs/module-map');
18 +var babelPluginDEV = require('fbjs/scripts/babel/dev-expression');
19 +var babelPluginRequires = require('fbjs/scripts/babel/rewrite-requires');
20 +
21 +module.exports = {
22 + process: function(src, path) {
23 + if (path.match(/\.coffee$/)) {
24 + return coffee.compile(src, {'bare': true});
25 + }
26 + if (path.match(/\.ts$/) && !path.match(/\.d\.ts$/)) {
27 + return ts.compile(src, path);
28 + }
29 + // TODO: make sure this stays in sync with gulpfile
30 + if (!path.match(/\/node_modules\//) && !path.match(/\/third_party\//)) {
31 + var rv = babel.transform(src, {
32 + nonStandard: true,
33 + blacklist: [
34 + 'spec.functionName',
35 + 'validation.react',
36 + ],
37 + optional: [
38 + 'es7.trailingFunctionCommas',
39 + ],
40 + plugins: [babelPluginDEV, babelPluginRequires],
41 + ignore: ['third_party'],
42 + filename: path,
43 + retainLines: true,
44 + _moduleMap: moduleMap,
45 + }).code;
46 + return rv;
47 + }
48 + return src;
49 + },
50 +};
scripts/jest/ts-preprocessor.js renamed
src/isomorphic/deprecated/__tests__/cloneWithProps-test.js
-4
@@ -11,10 +11,6 @@
11
12 'use strict';
13
14 -require('mock-modules')
15 - .dontMock('cloneWithProps')
16 - .dontMock('emptyObject');
17 -
14 var React;
15 var ReactTestUtils;
16
src/renderers/dom/client/__tests__/ReactBrowserEventEmitter-test.js
-11
@@ -11,17 +11,6 @@
11
12 'use strict';
13
14 -require('mock-modules')
15 - .dontMock('EventPluginHub')
16 - .dontMock('ReactMount')
17 - .dontMock('ReactBrowserEventEmitter')
18 - .dontMock('ReactInstanceHandles')
19 - .dontMock('EventPluginHub')
20 - .dontMock('TapEventPlugin')
21 - .dontMock('TouchEventUtils')
22 - .dontMock('keyOf');
23 -
24 -
14 var keyOf = require('keyOf');
15 var mocks = require('mocks');
16
src/renderers/dom/client/eventPlugins/__tests__/SelectEventPlugin-test.js
+2 -11
@@ -11,17 +11,12 @@
11
12 'use strict';
13
14 -var mockModules = require('mock-modules');
15 -mockModules.mock('getActiveElement');
16 -
14 var EventConstants;
15 var React;
16 var ReactMount;
17 var ReactTestUtils;
18 var SelectEventPlugin;
19
23 -var getActiveElement;
24 -
20 var topLevelTypes;
21
22 describe('SelectEventPlugin', function() {
@@ -36,16 +31,12 @@ describe('SelectEventPlugin', function() {
31 }
32
33 beforeEach(function() {
39 - mockModules.dumpCache();
40 -
34 EventConstants = require('EventConstants');
35 React = require('React');
36 ReactMount = require('ReactMount');
37 ReactTestUtils = require('ReactTestUtils');
38 SelectEventPlugin = require('SelectEventPlugin');
39
47 - getActiveElement = require('getActiveElement');
48 -
40 topLevelTypes = EventConstants.topLevelTypes;
41 });
42
@@ -58,7 +49,7 @@ describe('SelectEventPlugin', function() {
49
50 var rendered = ReactTestUtils.renderIntoDocument(<WithoutSelect />);
51 var node = React.findDOMNode(rendered);
61 - getActiveElement.mockReturnValue(node);
52 + node.focus();
53
54 var mousedown = extract(node, topLevelTypes.topMouseDown);
55 expect(mousedown).toBe(null);
@@ -85,7 +76,7 @@ describe('SelectEventPlugin', function() {
76
77 node.selectionStart = 0;
78 node.selectionEnd = 0;
88 - getActiveElement.mockReturnValue(node);
79 + node.focus();
80
81 var focus = extract(node, topLevelTypes.topFocus);
82 expect(focus).toBe(null);
src/renderers/dom/server/__tests__/ReactServerRendering-test.js
-7
@@ -11,13 +11,6 @@
11
12 'use strict';
13
14 -require('mock-modules')
15 - .dontMock('ExecutionEnvironment')
16 - .dontMock('React')
17 - .dontMock('ReactServerRendering')
18 - .dontMock('ReactTestUtils')
19 - .dontMock('ReactMarkupChecksum');
20 -
14 var mocks = require('mocks');
15
16 var ExecutionEnvironment;
src/shared/vendor/README.md deleted
-1
@@ -1 +0,0 @@
1 -The files in this directory are not related to React's core functionality. They are shared utility modules that are also used in other parts of Facebook's front-end. Changes to these files need more consideration than changes to React itself.
src/shared/vendor/core/CSSCore.js deleted
-108
@@ -1,108 +0,0 @@
1 -/**
2 - * Copyright 2013-2015, Facebook, Inc.
3 - * All rights reserved.
4 - *
5 - * This source code is licensed under the BSD-style license found in the
6 - * LICENSE file in the root directory of this source tree. An additional grant
7 - * of patent rights can be found in the PATENTS file in the same directory.
8 - *
9 - * @providesModule CSSCore
10 - * @typechecks
11 - */
12 -
13 -var invariant = require('invariant');
14 -
15 -/**
16 - * The CSSCore module specifies the API (and implements most of the methods)
17 - * that should be used when dealing with the display of elements (via their
18 - * CSS classes and visibility on screen. It is an API focused on mutating the
19 - * display and not reading it as no logical state should be encoded in the
20 - * display of elements.
21 - */
22 -
23 -var CSSCore = {
24 -
25 - /**
26 - * Adds the class passed in to the element if it doesn't already have it.
27 - *
28 - * @param {DOMElement} element the element to set the class on
29 - * @param {string} className the CSS className
30 - * @return {DOMElement} the element passed in
31 - */
32 - addClass: function(element, className) {
33 - invariant(
34 - !/\s/.test(className),
35 - 'CSSCore.addClass takes only a single class name. "%s" contains ' +
36 - 'multiple classes.', className
37 - );
38 -
39 - if (className) {
40 - if (element.classList) {
41 - element.classList.add(className);
42 - } else if (!CSSCore.hasClass(element, className)) {
43 - element.className = element.className + ' ' + className;
44 - }
45 - }
46 - return element;
47 - },
48 -
49 - /**
50 - * Removes the class passed in from the element
51 - *
52 - * @param {DOMElement} element the element to set the class on
53 - * @param {string} className the CSS className
54 - * @return {DOMElement} the element passed in
55 - */
56 - removeClass: function(element, className) {
57 - invariant(
58 - !/\s/.test(className),
59 - 'CSSCore.removeClass takes only a single class name. "%s" contains ' +
60 - 'multiple classes.', className
61 - );
62 -
63 - if (className) {
64 - if (element.classList) {
65 - element.classList.remove(className);
66 - } else if (CSSCore.hasClass(element, className)) {
67 - element.className = element.className
68 - .replace(new RegExp('(^|\\s)' + className + '(?:\\s|$)', 'g'), '$1')
69 - .replace(/\s+/g, ' ') // multiple spaces to one
70 - .replace(/^\s*|\s*$/g, ''); // trim the ends
71 - }
72 - }
73 - return element;
74 - },
75 -
76 - /**
77 - * Helper to add or remove a class from an element based on a condition.
78 - *
79 - * @param {DOMElement} element the element to set the class on
80 - * @param {string} className the CSS className
81 - * @param {*} bool condition to whether to add or remove the class
82 - * @return {DOMElement} the element passed in
83 - */
84 - conditionClass: function(element, className, bool) {
85 - return (bool ? CSSCore.addClass : CSSCore.removeClass)(element, className);
86 - },
87 -
88 - /**
89 - * Tests whether the element has the class specified.
90 - *
91 - * @param {DOMNode|DOMWindow} element the element to set the class on
92 - * @param {string} className the CSS className
93 - * @return {boolean} true if the element has the class, false if not
94 - */
95 - hasClass: function(element, className) {
96 - invariant(
97 - !/\s/.test(className),
98 - 'CSS.hasClass takes only a single class name.'
99 - );
100 - if (element.classList) {
101 - return !!className && element.classList.contains(className);
102 - }
103 - return (' ' + element.className + ' ').indexOf(' ' + className + ' ') > -1;
104 - }
105 -
106 -};
107 -
108 -module.exports = CSSCore;
src/shared/vendor/core/ExecutionEnvironment.js deleted
-43
@@ -1,43 +0,0 @@
1 -/**
2 - * Copyright 2013-2015, Facebook, Inc.
3 - * All rights reserved.
4 - *
5 - * This source code is licensed under the BSD-style license found in the
6 - * LICENSE file in the root directory of this source tree. An additional grant
7 - * of patent rights can be found in the PATENTS file in the same directory.
8 - *
9 - * @providesModule ExecutionEnvironment
10 - */
11 -
12 -/*jslint evil: true */
13 -
14 -"use strict";
15 -
16 -var canUseDOM = !!(
17 - typeof window !== 'undefined' &&
18 - window.document &&
19 - window.document.createElement
20 -);
21 -
22 -/**
23 - * Simple, lightweight module assisting with the detection and context of
24 - * Worker. Helps avoid circular dependencies and allows code to reason about
25 - * whether or not they are in a Worker, even if they never include the main
26 - * `ReactWorker` dependency.
27 - */
28 -var ExecutionEnvironment = {
29 -
30 - canUseDOM: canUseDOM,
31 -
32 - canUseWorkers: typeof Worker !== 'undefined',
33 -
34 - canUseEventListeners:
35 - canUseDOM && !!(window.addEventListener || window.attachEvent),
36 -
37 - canUseViewport: canUseDOM && !!window.screen,
38 -
39 - isInWorker: !canUseDOM // For now, this is true - might change in the future.
40 -
41 -};
42 -
43 -module.exports = ExecutionEnvironment;
src/shared/vendor/core/TouchEventUtils.js deleted
-35
@@ -1,35 +0,0 @@
1 -/**
2 - * Copyright 2013-2015, Facebook, Inc.
3 - * All rights reserved.
4 - *
5 - * This source code is licensed under the BSD-style license found in the
6 - * LICENSE file in the root directory of this source tree. An additional grant
7 - * of patent rights can be found in the PATENTS file in the same directory.
8 - *
9 - * @providesModule TouchEventUtils
10 - */
11 -
12 -var TouchEventUtils = {
13 - /**
14 - * Utility function for common case of extracting out the primary touch from a
15 - * touch event.
16 - * - `touchEnd` events usually do not have the `touches` property.
17 - * http://stackoverflow.com/questions/3666929/
18 - * mobile-sarai-touchend-event-not-firing-when-last-touch-is-removed
19 - *
20 - * @param {Event} nativeEvent Native event that may or may not be a touch.
21 - * @return {TouchesObject?} an object with pageX and pageY or null.
22 - */
23 - extractSingleTouch: function(nativeEvent) {
24 - var touches = nativeEvent.touches;
25 - var changedTouches = nativeEvent.changedTouches;
26 - var hasTouches = touches && touches.length > 0;
27 - var hasChangedTouches = changedTouches && changedTouches.length > 0;
28 -
29 - return !hasTouches && hasChangedTouches ? changedTouches[0] :
30 - hasTouches ? touches[0] :
31 - nativeEvent;
32 - }
33 -};
34 -
35 -module.exports = TouchEventUtils;
src/shared/vendor/core/camelize.js deleted
-30
@@ -1,30 +0,0 @@
1 -/**
2 - * Copyright 2013-2015, Facebook, Inc.
3 - * All rights reserved.
4 - *
5 - * This source code is licensed under the BSD-style license found in the
6 - * LICENSE file in the root directory of this source tree. An additional grant
7 - * of patent rights can be found in the PATENTS file in the same directory.
8 - *
9 - * @providesModule camelize
10 - * @typechecks
11 - */
12 -
13 -var _hyphenPattern = /-(.)/g;
14 -
15 -/**
16 - * Camelcases a hyphenated string, for example:
17 - *
18 - * > camelize('background-color')
19 - * < "backgroundColor"
20 - *
21 - * @param {string} string
22 - * @return {string}
23 - */
24 -function camelize(string) {
25 - return string.replace(_hyphenPattern, function(_, character) {
26 - return character.toUpperCase();
27 - });
28 -}
29 -
30 -module.exports = camelize;
src/shared/vendor/core/camelizeStyleName.js deleted
-40
@@ -1,40 +0,0 @@
1 -/**
2 - * Copyright 2014-2015, Facebook, Inc.
3 - * All rights reserved.
4 - *
5 - * This source code is licensed under the BSD-style license found in the
6 - * LICENSE file in the root directory of this source tree. An additional grant
7 - * of patent rights can be found in the PATENTS file in the same directory.
8 - *
9 - * @providesModule camelizeStyleName
10 - * @typechecks
11 - */
12 -
13 -"use strict";
14 -
15 -var camelize = require('camelize');
16 -
17 -var msPattern = /^-ms-/;
18 -
19 -/**
20 - * Camelcases a hyphenated CSS property name, for example:
21 - *
22 - * > camelizeStyleName('background-color')
23 - * < "backgroundColor"
24 - * > camelizeStyleName('-moz-transition')
25 - * < "MozTransition"
26 - * > camelizeStyleName('-ms-transition')
27 - * < "msTransition"
28 - *
29 - * As Andi Smith suggests
30 - * (http://www.andismith.com/blog/2012/02/modernizr-prefixed/), an `-ms` prefix
31 - * is converted to lowercase `ms`.
32 - *
33 - * @param {string} string
34 - * @return {string}
35 - */
36 -function camelizeStyleName(string) {
37 - return camelize(string.replace(msPattern, 'ms-'));
38 -}
39 -
40 -module.exports = camelizeStyleName;
src/shared/vendor/core/createArrayFromMixed.js deleted
-85
@@ -1,85 +0,0 @@
1 -/**
2 - * Copyright 2013-2015, Facebook, Inc.
3 - * All rights reserved.
4 - *
5 - * This source code is licensed under the BSD-style license found in the
6 - * LICENSE file in the root directory of this source tree. An additional grant
7 - * of patent rights can be found in the PATENTS file in the same directory.
8 - *
9 - * @providesModule createArrayFromMixed
10 - * @typechecks
11 - */
12 -
13 -var toArray = require('toArray');
14 -
15 -/**
16 - * Perform a heuristic test to determine if an object is "array-like".
17 - *
18 - * A monk asked Joshu, a Zen master, "Has a dog Buddha nature?"
19 - * Joshu replied: "Mu."
20 - *
21 - * This function determines if its argument has "array nature": it returns
22 - * true if the argument is an actual array, an `arguments' object, or an
23 - * HTMLCollection (e.g. node.childNodes or node.getElementsByTagName()).
24 - *
25 - * It will return false for other array-like objects like Filelist.
26 - *
27 - * @param {*} obj
28 - * @return {boolean}
29 - */
30 -function hasArrayNature(obj) {
31 - return (
32 - // not null/false
33 - !!obj &&
34 - // arrays are objects, NodeLists are functions in Safari
35 - (typeof obj == 'object' || typeof obj == 'function') &&
36 - // quacks like an array
37 - ('length' in obj) &&
38 - // not window
39 - !('setInterval' in obj) &&
40 - // no DOM node should be considered an array-like
41 - // a 'select' element has 'length' and 'item' properties on IE8
42 - (typeof obj.nodeType != 'number') &&
43 - (
44 - // a real array
45 - Array.isArray(obj) ||
46 - // arguments
47 - ('callee' in obj) ||
48 - // HTMLCollection/NodeList
49 - ('item' in obj)
50 - )
51 - );
52 -}
53 -
54 -/**
55 - * Ensure that the argument is an array by wrapping it in an array if it is not.
56 - * Creates a copy of the argument if it is already an array.
57 - *
58 - * This is mostly useful idiomatically:
59 - *
60 - * var createArrayFromMixed = require('createArrayFromMixed');
61 - *
62 - * function takesOneOrMoreThings(things) {
63 - * things = createArrayFromMixed(things);
64 - * ...
65 - * }
66 - *
67 - * This allows you to treat `things' as an array, but accept scalars in the API.
68 - *
69 - * If you need to convert an array-like object, like `arguments`, into an array
70 - * use toArray instead.
71 - *
72 - * @param {*} obj
73 - * @return {array}
74 - */
75 -function createArrayFromMixed(obj) {
76 - if (!hasArrayNature(obj)) {
77 - return [obj];
78 - } else if (Array.isArray(obj)) {
79 - return obj.slice();
80 - } else {
81 - return toArray(obj);
82 - }
83 -}
84 -
85 -module.exports = createArrayFromMixed;
src/shared/vendor/core/createNodesFromMarkup.js deleted
-86
@@ -1,86 +0,0 @@
1 -/**
2 - * Copyright 2013-2015, Facebook, Inc.
3 - * All rights reserved.
4 - *
5 - * This source code is licensed under the BSD-style license found in the
6 - * LICENSE file in the root directory of this source tree. An additional grant
7 - * of patent rights can be found in the PATENTS file in the same directory.
8 - *
9 - * @providesModule createNodesFromMarkup
10 - * @typechecks
11 - */
12 -
13 -/*jslint evil: true, sub: true */
14 -
15 -var ExecutionEnvironment = require('ExecutionEnvironment');
16 -
17 -var createArrayFromMixed = require('createArrayFromMixed');
18 -var getMarkupWrap = require('getMarkupWrap');
19 -var invariant = require('invariant');
20 -
21 -/**
22 - * Dummy container used to render all markup.
23 - */
24 -var dummyNode =
25 - ExecutionEnvironment.canUseDOM ? document.createElement('div') : null;
26 -
27 -/**
28 - * Pattern used by `getNodeName`.
29 - */
30 -var nodeNamePattern = /^\s*<(\w+)/;
31 -
32 -/**
33 - * Extracts the `nodeName` of the first element in a string of markup.
34 - *
35 - * @param {string} markup String of markup.
36 - * @return {?string} Node name of the supplied markup.
37 - */
38 -function getNodeName(markup) {
39 - var nodeNameMatch = markup.match(nodeNamePattern);
40 - return nodeNameMatch && nodeNameMatch[1].toLowerCase();
41 -}
42 -
43 -/**
44 - * Creates an array containing the nodes rendered from the supplied markup. The
45 - * optionally supplied `handleScript` function will be invoked once for each
46 - * <script> element that is rendered. If no `handleScript` function is supplied,
47 - * an exception is thrown if any <script> elements are rendered.
48 - *
49 - * @param {string} markup A string of valid HTML markup.
50 - * @param {?function} handleScript Invoked once for each rendered <script>.
51 - * @return {array<DOMElement|DOMTextNode>} An array of rendered nodes.
52 - */
53 -function createNodesFromMarkup(markup, handleScript) {
54 - var node = dummyNode;
55 - invariant(!!dummyNode, 'createNodesFromMarkup dummy not initialized');
56 - var nodeName = getNodeName(markup);
57 -
58 - var wrap = nodeName && getMarkupWrap(nodeName);
59 - if (wrap) {
60 - node.innerHTML = wrap[1] + markup + wrap[2];
61 -
62 - var wrapDepth = wrap[0];
63 - while (wrapDepth--) {
64 - node = node.lastChild;
65 - }
66 - } else {
67 - node.innerHTML = markup;
68 - }
69 -
70 - var scripts = node.getElementsByTagName('script');
71 - if (scripts.length) {
72 - invariant(
73 - handleScript,
74 - 'createNodesFromMarkup(...): Unexpected <script> element rendered.'
75 - );
76 - createArrayFromMixed(scripts).forEach(handleScript);
77 - }
78 -
79 - var nodes = createArrayFromMixed(node.childNodes);
80 - while (node.lastChild) {
81 - node.removeChild(node.lastChild);
82 - }
83 - return nodes;
84 -}
85 -
86 -module.exports = createNodesFromMarkup;
src/shared/vendor/core/dom/containsNode.js deleted
-42
@@ -1,42 +0,0 @@
1 -/**
2 - * Copyright 2013-2015, Facebook, Inc.
3 - * All rights reserved.
4 - *
5 - * This source code is licensed under the BSD-style license found in the
6 - * LICENSE file in the root directory of this source tree. An additional grant
7 - * of patent rights can be found in the PATENTS file in the same directory.
8 - *
9 - * @providesModule containsNode
10 - * @typechecks
11 - */
12 -
13 -var isTextNode = require('isTextNode');
14 -
15 -/*jslint bitwise:true */
16 -
17 -/**
18 - * Checks if a given DOM node contains or is another DOM node.
19 - *
20 - * @param {?DOMNode} outerNode Outer DOM node.
21 - * @param {?DOMNode} innerNode Inner DOM node.
22 - * @return {boolean} True if `outerNode` contains or is `innerNode`.
23 - */
24 -function containsNode(outerNode, innerNode) {
25 - if (!outerNode || !innerNode) {
26 - return false;
27 - } else if (outerNode === innerNode) {
28 - return true;
29 - } else if (isTextNode(outerNode)) {
30 - return false;
31 - } else if (isTextNode(innerNode)) {
32 - return containsNode(outerNode, innerNode.parentNode);
33 - } else if (outerNode.contains) {
34 - return outerNode.contains(innerNode);
35 - } else if (outerNode.compareDocumentPosition) {
36 - return !!(outerNode.compareDocumentPosition(innerNode) & 16);
37 - } else {
38 - return false;
39 - }
40 -}
41 -
42 -module.exports = containsNode;
src/shared/vendor/core/dom/focusNode.js deleted
-27
@@ -1,27 +0,0 @@
1 -/**
2 - * Copyright 2014-2015, Facebook, Inc.
3 - * All rights reserved.
4 - *
5 - * This source code is licensed under the BSD-style license found in the
6 - * LICENSE file in the root directory of this source tree. An additional grant
7 - * of patent rights can be found in the PATENTS file in the same directory.
8 - *
9 - * @providesModule focusNode
10 - */
11 -
12 -"use strict";
13 -
14 -/**
15 - * @param {DOMElement} node input/textarea to focus
16 - */
17 -function focusNode(node) {
18 - // IE8 can throw "Can't move focus to the control because it is invisible,
19 - // not enabled, or of a type that does not accept the focus." for all kinds of
20 - // reasons that are too expensive and fragile to test.
21 - try {
22 - node.focus();
23 - } catch(e) {
24 - }
25 -}
26 -
27 -module.exports = focusNode;
src/shared/vendor/core/dom/getActiveElement.js deleted
-27
@@ -1,27 +0,0 @@
1 -/**
2 - * Copyright 2013-2015, Facebook, Inc.
3 - * All rights reserved.
4 - *
5 - * This source code is licensed under the BSD-style license found in the
6 - * LICENSE file in the root directory of this source tree. An additional grant
7 - * of patent rights can be found in the PATENTS file in the same directory.
8 - *
9 - * @providesModule getActiveElement
10 - * @typechecks
11 - */
12 -
13 -/**
14 - * Same as document.activeElement but wraps in a try-catch block. In IE it is
15 - * not safe to call document.activeElement if there is nothing focused.
16 - *
17 - * The activeElement will be null only if the document body is not yet defined.
18 - */
19 -function getActiveElement() /*?DOMElement*/ {
20 - try {
21 - return document.activeElement || document.body;
22 - } catch (e) {
23 - return document.body;
24 - }
25 -}
26 -
27 -module.exports = getActiveElement;
src/shared/vendor/core/dom/getUnboundedScrollPosition.js deleted
-38
@@ -1,38 +0,0 @@
1 -/**
2 - * Copyright 2013-2015, Facebook, Inc.
3 - * All rights reserved.
4 - *
5 - * This source code is licensed under the BSD-style license found in the
6 - * LICENSE file in the root directory of this source tree. An additional grant
7 - * of patent rights can be found in the PATENTS file in the same directory.
8 - *
9 - * @providesModule getUnboundedScrollPosition
10 - * @typechecks
11 - */
12 -
13 -"use strict";
14 -
15 -/**
16 - * Gets the scroll position of the supplied element or window.
17 - *
18 - * The return values are unbounded, unlike `getScrollPosition`. This means they
19 - * may be negative or exceed the element boundaries (which is possible using
20 - * inertial scrolling).
21 - *
22 - * @param {DOMWindow|DOMElement} scrollable
23 - * @return {object} Map with `x` and `y` keys.
24 - */
25 -function getUnboundedScrollPosition(scrollable) {
26 - if (scrollable === window) {
27 - return {
28 - x: window.pageXOffset || document.documentElement.scrollLeft,
29 - y: window.pageYOffset || document.documentElement.scrollTop
30 - };
31 - }
32 - return {
33 - x: scrollable.scrollLeft,
34 - y: scrollable.scrollTop
35 - };
36 -}
37 -
38 -module.exports = getUnboundedScrollPosition;
src/shared/vendor/core/dom/isNode.js deleted
-26
@@ -1,26 +0,0 @@
1 -/**
2 - * Copyright 2013-2015, Facebook, Inc.
3 - * All rights reserved.
4 - *
5 - * This source code is licensed under the BSD-style license found in the
6 - * LICENSE file in the root directory of this source tree. An additional grant
7 - * of patent rights can be found in the PATENTS file in the same directory.
8 - *
9 - * @providesModule isNode
10 - * @typechecks
11 - */
12 -
13 -/**
14 - * @param {*} object The object to check.
15 - * @return {boolean} Whether or not the object is a DOM node.
16 - */
17 -function isNode(object) {
18 - return !!(object && (
19 - typeof Node === 'function' ? object instanceof Node :
20 - typeof object === 'object' &&
21 - typeof object.nodeType === 'number' &&
22 - typeof object.nodeName === 'string'
23 - ));
24 -}
25 -
26 -module.exports = isNode;
src/shared/vendor/core/dom/isTextNode.js deleted
-23
@@ -1,23 +0,0 @@
1 -/**
2 - * Copyright 2013-2015, Facebook, Inc.
3 - * All rights reserved.
4 - *
5 - * This source code is licensed under the BSD-style license found in the
6 - * LICENSE file in the root directory of this source tree. An additional grant
7 - * of patent rights can be found in the PATENTS file in the same directory.
8 - *
9 - * @providesModule isTextNode
10 - * @typechecks
11 - */
12 -
13 -var isNode = require('isNode');
14 -
15 -/**
16 - * @param {*} object The object to check.
17 - * @return {boolean} Whether or not the object is a DOM text node.
18 - */
19 -function isTextNode(object) {
20 - return isNode(object) && object.nodeType == 3;
21 -}
22 -
23 -module.exports = isTextNode;
src/shared/vendor/core/emptyFunction.js deleted
-32
@@ -1,32 +0,0 @@
1 -/**
2 - * Copyright 2013-2015, Facebook, Inc.
3 - * All rights reserved.
4 - *
5 - * This source code is licensed under the BSD-style license found in the
6 - * LICENSE file in the root directory of this source tree. An additional grant
7 - * of patent rights can be found in the PATENTS file in the same directory.
8 - *
9 - * @providesModule emptyFunction
10 - */
11 -
12 -function makeEmptyFunction(arg) {
13 - return function() {
14 - return arg;
15 - };
16 -}
17 -
18 -/**
19 - * This function accepts and discards inputs; it has no side effects. This is
20 - * primarily useful idiomatically for overridable function endpoints which
21 - * always need to be callable, since JS lacks a null-call idiom ala Cocoa.
22 - */
23 -function emptyFunction() {}
24 -
25 -emptyFunction.thatReturns = makeEmptyFunction;
26 -emptyFunction.thatReturnsFalse = makeEmptyFunction(false);
27 -emptyFunction.thatReturnsTrue = makeEmptyFunction(true);
28 -emptyFunction.thatReturnsNull = makeEmptyFunction(null);
29 -emptyFunction.thatReturnsThis = function() { return this; };
30 -emptyFunction.thatReturnsArgument = function(arg) { return arg; };
31 -
32 -module.exports = emptyFunction;
src/shared/vendor/core/emptyObject.js deleted
-20
@@ -1,20 +0,0 @@
1 -/**
2 - * Copyright 2013-2015, Facebook, Inc.
3 - * All rights reserved.
4 - *
5 - * This source code is licensed under the BSD-style license found in the
6 - * LICENSE file in the root directory of this source tree. An additional grant
7 - * of patent rights can be found in the PATENTS file in the same directory.
8 - *
9 - * @providesModule emptyObject
10 - */
11 -
12 -"use strict";
13 -
14 -var emptyObject = {};
15 -
16 -if (__DEV__) {
17 - Object.freeze(emptyObject);
18 -}
19 -
20 -module.exports = emptyObject;
src/shared/vendor/core/getMarkupWrap.js deleted
-112
@@ -1,112 +0,0 @@
1 -/**
2 - * Copyright 2013-2015, Facebook, Inc.
3 - * All rights reserved.
4 - *
5 - * This source code is licensed under the BSD-style license found in the
6 - * LICENSE file in the root directory of this source tree. An additional grant
7 - * of patent rights can be found in the PATENTS file in the same directory.
8 - *
9 - * @providesModule getMarkupWrap
10 - */
11 -
12 -var ExecutionEnvironment = require('ExecutionEnvironment');
13 -
14 -var invariant = require('invariant');
15 -
16 -/**
17 - * Dummy container used to detect which wraps are necessary.
18 - */
19 -var dummyNode =
20 - ExecutionEnvironment.canUseDOM ? document.createElement('div') : null;
21 -
22 -/**
23 - * Some browsers cannot use `innerHTML` to render certain elements standalone,
24 - * so we wrap them, render the wrapped nodes, then extract the desired node.
25 - *
26 - * In IE8, certain elements cannot render alone, so wrap all elements ('*').
27 - */
28 -
29 -var shouldWrap = {};
30 -
31 -var selectWrap = [1, '<select multiple="true">', '</select>'];
32 -var tableWrap = [1, '<table>', '</table>'];
33 -var trWrap = [3, '<table><tbody><tr>', '</tr></tbody></table>'];
34 -
35 -var svgWrap = [1, '<svg xmlns="http://www.w3.org/2000/svg">', '</svg>'];
36 -
37 -var markupWrap = {
38 - '*': [1, '?<div>', '</div>'],
39 -
40 - 'area': [1, '<map>', '</map>'],
41 - 'col': [2, '<table><tbody></tbody><colgroup>', '</colgroup></table>'],
42 - 'legend': [1, '<fieldset>', '</fieldset>'],
43 - 'param': [1, '<object>', '</object>'],
44 - 'tr': [2, '<table><tbody>', '</tbody></table>'],
45 -
46 - 'optgroup': selectWrap,
47 - 'option': selectWrap,
48 -
49 - 'caption': tableWrap,
50 - 'colgroup': tableWrap,
51 - 'tbody': tableWrap,
52 - 'tfoot': tableWrap,
53 - 'thead': tableWrap,
54 -
55 - 'td': trWrap,
56 - 'th': trWrap,
57 -};
58 -
59 -// Initilize the SVG elements since we know they'll always need to be wrapped
60 -// consistently. If they are created inside a <div> they will be initialized in
61 -// the wrong namespace (and will not display).
62 -var svgElements = [
63 - 'circle',
64 - 'clipPath',
65 - 'defs',
66 - 'ellipse',
67 - 'g',
68 - 'image',
69 - 'line',
70 - 'linearGradient',
71 - 'mask',
72 - 'path',
73 - 'pattern',
74 - 'polygon',
75 - 'polyline',
76 - 'radialGradient',
77 - 'rect',
78 - 'stop',
79 - 'text',
80 - 'tspan',
81 -];
82 -svgElements.forEach((nodeName) => {
83 - markupWrap[nodeName] = svgWrap;
84 - shouldWrap[nodeName] = true;
85 -});
86 -
87 -/**
88 - * Gets the markup wrap configuration for the supplied `nodeName`.
89 - *
90 - * NOTE: This lazily detects which wraps are necessary for the current browser.
91 - *
92 - * @param {string} nodeName Lowercase `nodeName`.
93 - * @return {?array} Markup wrap configuration, if applicable.
94 - */
95 -function getMarkupWrap(nodeName) {
96 - invariant(!!dummyNode, 'Markup wrapping node not initialized');
97 - if (!markupWrap.hasOwnProperty(nodeName)) {
98 - nodeName = '*';
99 - }
100 - if (!shouldWrap.hasOwnProperty(nodeName)) {
101 - if (nodeName === '*') {
102 - dummyNode.innerHTML = '<link />';
103 - } else {
104 - dummyNode.innerHTML = '<' + nodeName + '></' + nodeName + '>';
105 - }
106 - shouldWrap[nodeName] = !dummyNode.firstChild;
107 - }
108 - return shouldWrap[nodeName] ? markupWrap[nodeName] : null;
109 -}
110 -
111 -
112 -module.exports = getMarkupWrap;
src/shared/vendor/core/hyphenate.js deleted
-31
@@ -1,31 +0,0 @@
1 -/**
2 - * Copyright 2013-2015, Facebook, Inc.
3 - * All rights reserved.
4 - *
5 - * This source code is licensed under the BSD-style license found in the
6 - * LICENSE file in the root directory of this source tree. An additional grant
7 - * of patent rights can be found in the PATENTS file in the same directory.
8 - *
9 - * @providesModule hyphenate
10 - * @typechecks
11 - */
12 -
13 -var _uppercasePattern = /([A-Z])/g;
14 -
15 -/**
16 - * Hyphenates a camelcased string, for example:
17 - *
18 - * > hyphenate('backgroundColor')
19 - * < "background-color"
20 - *
21 - * For CSS style names, use `hyphenateStyleName` instead which works properly
22 - * with all vendor prefixes, including `ms`.
23 - *
24 - * @param {string} string
25 - * @return {string}
26 - */
27 -function hyphenate(string) {
28 - return string.replace(_uppercasePattern, '-$1').toLowerCase();
29 -}
30 -
31 -module.exports = hyphenate;
src/shared/vendor/core/hyphenateStyleName.js deleted
-39
@@ -1,39 +0,0 @@
1 -/**
2 - * Copyright 2013-2015, Facebook, Inc.
3 - * All rights reserved.
4 - *
5 - * This source code is licensed under the BSD-style license found in the
6 - * LICENSE file in the root directory of this source tree. An additional grant
7 - * of patent rights can be found in the PATENTS file in the same directory.
8 - *
9 - * @providesModule hyphenateStyleName
10 - * @typechecks
11 - */
12 -
13 -"use strict";
14 -
15 -var hyphenate = require('hyphenate');
16 -
17 -var msPattern = /^ms-/;
18 -
19 -/**
20 - * Hyphenates a camelcased CSS property name, for example:
21 - *
22 - * > hyphenateStyleName('backgroundColor')
23 - * < "background-color"
24 - * > hyphenateStyleName('MozTransition')
25 - * < "-moz-transition"
26 - * > hyphenateStyleName('msTransition')
27 - * < "-ms-transition"
28 - *
29 - * As Modernizr suggests (http://modernizr.com/docs/#prefixed), an `ms` prefix
30 - * is converted to `-ms-`.
31 - *
32 - * @param {string} string
33 - * @return {string}
34 - */
35 -function hyphenateStyleName(string) {
36 - return hyphenate(string).replace(msPattern, '-ms-');
37 -}
38 -
39 -module.exports = hyphenateStyleName;
src/shared/vendor/core/invariant.js deleted
-53
@@ -1,53 +0,0 @@
1 -/**
2 - * Copyright 2013-2015, Facebook, Inc.
3 - * All rights reserved.
4 - *
5 - * This source code is licensed under the BSD-style license found in the
6 - * LICENSE file in the root directory of this source tree. An additional grant
7 - * of patent rights can be found in the PATENTS file in the same directory.
8 - *
9 - * @providesModule invariant
10 - */
11 -
12 -"use strict";
13 -
14 -/**
15 - * Use invariant() to assert state which your program assumes to be true.
16 - *
17 - * Provide sprintf-style format (only %s is supported) and arguments
18 - * to provide information about what broke and what you were
19 - * expecting.
20 - *
21 - * The invariant message will be stripped in production, but the invariant
22 - * will remain to ensure logic does not differ in production.
23 - */
24 -
25 -var invariant = function(condition, format, a, b, c, d, e, f) {
26 - if (__DEV__) {
27 - if (format === undefined) {
28 - throw new Error('invariant requires an error message argument');
29 - }
30 - }
31 -
32 - if (!condition) {
33 - var error;
34 - if (format === undefined) {
35 - error = new Error(
36 - 'Minified exception occurred; use the non-minified dev environment ' +
37 - 'for the full error message and additional helpful warnings.'
38 - );
39 - } else {
40 - var args = [a, b, c, d, e, f];
41 - var argIndex = 0;
42 - error = new Error(
43 - 'Invariant Violation: ' +
44 - format.replace(/%s/g, function() { return args[argIndex++]; })
45 - );
46 - }
47 -
48 - error.framesToPop = 1; // we don't care about invariant's own frame
49 - throw error;
50 - }
51 -};
52 -
53 -module.exports = invariant;
src/shared/vendor/core/mapObject.js deleted
-51
@@ -1,51 +0,0 @@
1 -/**
2 - * Copyright 2013-2015, Facebook, Inc.
3 - * All rights reserved.
4 - *
5 - * This source code is licensed under the BSD-style license found in the
6 - * LICENSE file in the root directory of this source tree. An additional grant
7 - * of patent rights can be found in the PATENTS file in the same directory.
8 - *
9 - * @providesModule mapObject
10 - */
11 -
12 -'use strict';
13 -
14 -var hasOwnProperty = Object.prototype.hasOwnProperty;
15 -
16 -/**
17 - * Executes the provided `callback` once for each enumerable own property in the
18 - * object and constructs a new object from the results. The `callback` is
19 - * invoked with three arguments:
20 - *
21 - * - the property value
22 - * - the property name
23 - * - the object being traversed
24 - *
25 - * Properties that are added after the call to `mapObject` will not be visited
26 - * by `callback`. If the values of existing properties are changed, the value
27 - * passed to `callback` will be the value at the time `mapObject` visits them.
28 - * Properties that are deleted before being visited are not visited.
29 - *
30 - * @grep function objectMap()
31 - * @grep function objMap()
32 - *
33 - * @param {?object} object
34 - * @param {function} callback
35 - * @param {*} context
36 - * @return {?object}
37 - */
38 -function mapObject(object, callback, context) {
39 - if (!object) {
40 - return null;
41 - }
42 - var result = {};
43 - for (var name in object) {
44 - if (hasOwnProperty.call(object, name)) {
45 - result[name] = callback.call(context, object[name], name, object);
46 - }
47 - }
48 - return result;
49 -}
50 -
51 -module.exports = mapObject;
src/shared/vendor/core/monitorCodeUse.js deleted
-30
@@ -1,30 +0,0 @@
1 -/**
2 - * Copyright 2014-2015, Facebook, Inc.
3 - * All rights reserved.
4 - *
5 - * This source code is licensed under the BSD-style license found in the
6 - * LICENSE file in the root directory of this source tree. An additional grant
7 - * of patent rights can be found in the PATENTS file in the same directory.
8 - *
9 - * @providesModule monitorCodeUse
10 - */
11 -
12 -"use strict";
13 -
14 -var invariant = require('invariant');
15 -
16 -/**
17 - * Provides open-source compatible instrumentation for monitoring certain API
18 - * uses before we're ready to issue a warning or refactor. It accepts an event
19 - * name which may only contain the characters [a-z0-9_] and an optional data
20 - * object with further information.
21 - */
22 -
23 -function monitorCodeUse(eventName, data) {
24 - invariant(
25 - eventName && !/[^a-z0-9_]/.test(eventName),
26 - 'You must provide an eventName using only the characters [a-z0-9_]'
27 - );
28 -}
29 -
30 -module.exports = monitorCodeUse;
src/shared/vendor/core/nativeRequestAnimationFrame.js deleted
-19
@@ -1,19 +0,0 @@
1 -/**
2 - * Copyright 2014-2015, Facebook, Inc.
3 - * All rights reserved.
4 - *
5 - * This source code is licensed under the BSD-style license found in the
6 - * LICENSE file in the root directory of this source tree. An additional grant
7 - * of patent rights can be found in the PATENTS file in the same directory.
8 - *
9 - * @providesModule nativeRequestAnimationFrame
10 - */
11 -
12 -var nativeRequestAnimationFrame =
13 - global.requestAnimationFrame ||
14 - global.webkitRequestAnimationFrame ||
15 - global.mozRequestAnimationFrame ||
16 - global.oRequestAnimationFrame ||
17 - global.msRequestAnimationFrame;
18 -
19 -module.exports = nativeRequestAnimationFrame;
src/shared/vendor/core/requestAnimationFrame.js deleted
-31
@@ -1,31 +0,0 @@
1 -/**
2 - * Copyright 2014-2015, Facebook, Inc.
3 - * All rights reserved.
4 - *
5 - * This source code is licensed under the BSD-style license found in the
6 - * LICENSE file in the root directory of this source tree. An additional grant
7 - * of patent rights can be found in the PATENTS file in the same directory.
8 - *
9 - * @providesModule requestAnimationFrame
10 - */
11 -
12 -var emptyFunction = require('emptyFunction');
13 -var nativeRequestAnimationFrame = require('nativeRequestAnimationFrame');
14 -
15 -var lastTime = 0;
16 -
17 -var requestAnimationFrame =
18 - nativeRequestAnimationFrame ||
19 - function(callback) {
20 - var currTime = Date.now();
21 - var timeDelay = Math.max(0, 16 - (currTime - lastTime));
22 - lastTime = currTime + timeDelay;
23 - return global.setTimeout(function() {
24 - callback(Date.now());
25 - }, timeDelay);
26 - };
27 -
28 -// Works around a rare bug in Safari 6 where the first request is never invoked.
29 -requestAnimationFrame(emptyFunction);
30 -
31 -module.exports = requestAnimationFrame;
src/shared/vendor/core/toArray.js deleted
-66
@@ -1,66 +0,0 @@
1 -/**
2 - * Copyright 2014-2015, Facebook, Inc.
3 - * All rights reserved.
4 - *
5 - * This source code is licensed under the BSD-style license found in the
6 - * LICENSE file in the root directory of this source tree. An additional grant
7 - * of patent rights can be found in the PATENTS file in the same directory.
8 - *
9 - * @providesModule toArray
10 - * @typechecks
11 - */
12 -
13 -var invariant = require('invariant');
14 -
15 -/**
16 - * Convert array-like objects to arrays.
17 - *
18 - * This API assumes the caller knows the contents of the data type. For less
19 - * well defined inputs use createArrayFromMixed.
20 - *
21 - * @param {object|function|filelist} obj
22 - * @return {array}
23 - */
24 -function toArray(obj) {
25 - var length = obj.length;
26 -
27 - // Some browse builtin objects can report typeof 'function' (e.g. NodeList in
28 - // old versions of Safari).
29 - invariant(
30 - !Array.isArray(obj) &&
31 - (typeof obj === 'object' || typeof obj === 'function'),
32 - 'toArray: Array-like object expected'
33 - );
34 -
35 - invariant(
36 - typeof length === 'number',
37 - 'toArray: Object needs a length property'
38 - );
39 -
40 - invariant(
41 - length === 0 ||
42 - (length - 1) in obj,
43 - 'toArray: Object should have keys for indices'
44 - );
45 -
46 - // Old IE doesn't give collections access to hasOwnProperty. Assume inputs
47 - // without method will throw during the slice call and skip straight to the
48 - // fallback.
49 - if (obj.hasOwnProperty) {
50 - try {
51 - return Array.prototype.slice.call(obj);
52 - } catch (e) {
53 - // IE < 9 does not support Array#slice on collections objects
54 - }
55 - }
56 -
57 - // Fall back to copying key by key. This assumes all keys have a value,
58 - // so will not preserve sparsely populated inputs.
59 - var ret = Array(length);
60 - for (var ii = 0; ii < length; ii++) {
61 - ret[ii] = obj[ii];
62 - }
63 - return ret;
64 -}
65 -
66 -module.exports = toArray;
src/shared/vendor/core/warning.js deleted
-54
@@ -1,54 +0,0 @@
1 -/**
2 - * Copyright 2014-2015, Facebook, Inc.
3 - * All rights reserved.
4 - *
5 - * This source code is licensed under the BSD-style license found in the
6 - * LICENSE file in the root directory of this source tree. An additional grant
7 - * of patent rights can be found in the PATENTS file in the same directory.
8 - *
9 - * @providesModule warning
10 - */
11 -
12 -"use strict";
13 -
14 -var emptyFunction = require('emptyFunction');
15 -
16 -/**
17 - * Similar to invariant but only logs a warning if the condition is not met.
18 - * This can be used to log issues in development environments in critical
19 - * paths. Removing the logging code for production environments will keep the
20 - * same logic and follow the same code paths.
21 - */
22 -
23 -var warning = emptyFunction;
24 -
25 -if (__DEV__) {
26 - warning = function(condition, format, ...args) {
27 - if (format === undefined) {
28 - throw new Error(
29 - '`warning(condition, format, ...args)` requires a warning ' +
30 - 'message argument'
31 - );
32 - }
33 -
34 - if (format.indexOf('Failed Composite propType: ') === 0) {
35 - return; // Ignore CompositeComponent proptype check.
36 - }
37 -
38 - if (!condition) {
39 - var argIndex = 0;
40 - var message = 'Warning: ' + format.replace(/%s/g, () => args[argIndex++]);
41 - if (typeof console !== 'undefined') {
42 - console.error(message);
43 - }
44 - try {
45 - // --- Welcome to debugging React ---
46 - // This error was thrown as a convenience so that you can use this stack
47 - // to find the callsite that caused this warning to fire.
48 - throw new Error(message);
49 - } catch(x) {}
50 - }
51 - };
52 -}
53 -
54 -module.exports = warning;
src/shared/vendor/key-mirror/__tests__/keyMirror-test.js deleted
-64
@@ -1,64 +0,0 @@
1 -/**
2 - * Copyright 2013-2015, Facebook, Inc.
3 - * All rights reserved.
4 - *
5 - * This source code is licensed under the BSD-style license found in the
6 - * LICENSE file in the root directory of this source tree. An additional grant
7 - * of patent rights can be found in the PATENTS file in the same directory.
8 - *
9 - * @emails react-core
10 - */
11 -
12 -'use strict';
13 -
14 -require('mock-modules').dontMock('keyMirror');
15 -
16 -var keyMirror = require('keyMirror');
17 -
18 -describe('keyMirror', function() {
19 - it('should create an object with values matching keys provided', function() {
20 - var mirror = keyMirror({
21 - foo: null,
22 - bar: true,
23 - "baz": {some: "object"},
24 - qux: undefined
25 - });
26 - expect('foo' in mirror).toBe(true);
27 - expect(mirror.foo).toBe('foo');
28 - expect('bar' in mirror).toBe(true);
29 - expect(mirror.bar).toBe('bar');
30 - expect('baz' in mirror).toBe(true);
31 - expect(mirror.baz).toBe('baz');
32 - expect('qux' in mirror).toBe(true);
33 - expect(mirror.qux).toBe('qux');
34 - });
35 -
36 - it('should not use properties from prototypes', function() {
37 - function Klass() {
38 - this.useMeToo = true;
39 - }
40 - Klass.prototype.doNotUse = true;
41 - var instance = new Klass();
42 - instance.useMe = true;
43 -
44 - var mirror = keyMirror(instance);
45 -
46 - expect('doNotUse' in mirror).toBe(false);
47 - expect('useMe' in mirror).toBe(true);
48 - expect('useMeToo' in mirror).toBe(true);
49 - });
50 -
51 - it('should throw when a non-object argument is used', function() {
52 - [null, undefined, 0, 7, ['uno'], true, "string"].forEach(function(testVal) {
53 - expect(keyMirror.bind(null, testVal)).toThrow();
54 - });
55 - });
56 -
57 - it('should work when "constructor" is a key', function() {
58 - var obj = {constructor: true};
59 - expect(keyMirror.bind(null, obj)).not.toThrow();
60 - var mirror = keyMirror(obj);
61 - expect('constructor' in mirror).toBe(true);
62 - });
63 -});
64 -
src/shared/vendor/key-mirror/keyMirror.js deleted
-51
@@ -1,51 +0,0 @@
1 -/**
2 - * Copyright 2013-2015, Facebook, Inc.
3 - * All rights reserved.
4 - *
5 - * This source code is licensed under the BSD-style license found in the
6 - * LICENSE file in the root directory of this source tree. An additional grant
7 - * of patent rights can be found in the PATENTS file in the same directory.
8 - *
9 - * @providesModule keyMirror
10 - * @typechecks static-only
11 - */
12 -
13 -'use strict';
14 -
15 -var invariant = require('invariant');
16 -
17 -/**
18 - * Constructs an enumeration with keys equal to their value.
19 - *
20 - * For example:
21 - *
22 - * var COLORS = keyMirror({blue: null, red: null});
23 - * var myColor = COLORS.blue;
24 - * var isColorValid = !!COLORS[myColor];
25 - *
26 - * The last line could not be performed if the values of the generated enum were
27 - * not equal to their keys.
28 - *
29 - * Input: {key1: val1, key2: val2}
30 - * Output: {key1: key1, key2: key2}
31 - *
32 - * @param {object} obj
33 - * @return {object}
34 - */
35 -var keyMirror = function(obj) {
36 - var ret = {};
37 - var key;
38 - invariant(
39 - obj instanceof Object && !Array.isArray(obj),
40 - 'keyMirror(...): Argument must be an object.'
41 - );
42 - for (key in obj) {
43 - if (!obj.hasOwnProperty(key)) {
44 - continue;
45 - }
46 - ret[key] = key;
47 - }
48 - return ret;
49 -};
50 -
51 -module.exports = keyMirror;
src/shared/vendor/key-mirror/keyOf.js deleted
-34
@@ -1,34 +0,0 @@
1 -/**
2 - * Copyright 2013-2015, Facebook, Inc.
3 - * All rights reserved.
4 - *
5 - * This source code is licensed under the BSD-style license found in the
6 - * LICENSE file in the root directory of this source tree. An additional grant
7 - * of patent rights can be found in the PATENTS file in the same directory.
8 - *
9 - * @providesModule keyOf
10 - */
11 -
12 -/**
13 - * Allows extraction of a minified key. Let's the build system minify keys
14 - * without loosing the ability to dynamically use key strings as values
15 - * themselves. Pass in an object with a single key/val pair and it will return
16 - * you the string key of that single record. Suppose you want to grab the
17 - * value for a key 'className' inside of an object. Key/val minification may
18 - * have aliased that key to be 'xa12'. keyOf({className: null}) will return
19 - * 'xa12' in that case. Resolve keys you want to use once at startup time, then
20 - * reuse those resolutions.
21 - */
22 -var keyOf = function(oneKeyObj) {
23 - var key;
24 - for (key in oneKeyObj) {
25 - if (!oneKeyObj.hasOwnProperty(key)) {
26 - continue;
27 - }
28 - return key;
29 - }
30 - return null;
31 -};
32 -
33 -
34 -module.exports = keyOf;
src/shared/vendor/performance/performance.js deleted
-26
@@ -1,26 +0,0 @@
1 -/**
2 - * Copyright 2013-2015, Facebook, Inc.
3 - * All rights reserved.
4 - *
5 - * This source code is licensed under the BSD-style license found in the
6 - * LICENSE file in the root directory of this source tree. An additional grant
7 - * of patent rights can be found in the PATENTS file in the same directory.
8 - *
9 - * @providesModule performance
10 - * @typechecks
11 - */
12 -
13 -"use strict";
14 -
15 -var ExecutionEnvironment = require('ExecutionEnvironment');
16 -
17 -var performance;
18 -
19 -if (ExecutionEnvironment.canUseDOM) {
20 - performance =
21 - window.performance ||
22 - window.msPerformance ||
23 - window.webkitPerformance;
24 -}
25 -
26 -module.exports = performance || {};
src/shared/vendor/performance/performanceNow.js deleted
-26
@@ -1,26 +0,0 @@
1 -/**
2 - * Copyright 2013-2015, Facebook, Inc.
3 - * All rights reserved.
4 - *
5 - * This source code is licensed under the BSD-style license found in the
6 - * LICENSE file in the root directory of this source tree. An additional grant
7 - * of patent rights can be found in the PATENTS file in the same directory.
8 - *
9 - * @providesModule performanceNow
10 - * @typechecks
11 - */
12 -
13 -var performance = require('performance');
14 -
15 -/**
16 - * Detect if we can use `window.performance.now()` and gracefully fallback to
17 - * `Date.now()` if it doesn't exist. We need to support Firefox < 15 for now
18 - * because of Facebook's testing infrastructure.
19 - */
20 -if (!performance || !performance.now) {
21 - performance = Date;
22 -}
23 -
24 -var performanceNow = performance.now.bind(performance);
25 -
26 -module.exports = performanceNow;
src/shared/vendor/stubs/EventListener.js deleted
-86
@@ -1,86 +0,0 @@
1 -/**
2 - * Copyright 2013-2015, 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 EventListener
17 - * @typechecks
18 - */
19 -
20 -var emptyFunction = require('emptyFunction');
21 -
22 -/**
23 - * Upstream version of event listener. Does not take into account specific
24 - * nature of platform.
25 - */
26 -var EventListener = {
27 - /**
28 - * Listen to DOM events during the bubble phase.
29 - *
30 - * @param {DOMEventTarget} target DOM element to register listener on.
31 - * @param {string} eventType Event type, e.g. 'click' or 'mouseover'.
32 - * @param {function} callback Callback function.
33 - * @return {object} Object with a `remove` method.
34 - */
35 - listen: function(target, eventType, callback) {
36 - if (target.addEventListener) {
37 - target.addEventListener(eventType, callback, false);
38 - return {
39 - remove: function() {
40 - target.removeEventListener(eventType, callback, false);
41 - }
42 - };
43 - } else if (target.attachEvent) {
44 - target.attachEvent('on' + eventType, callback);
45 - return {
46 - remove: function() {
47 - target.detachEvent('on' + eventType, callback);
48 - }
49 - };
50 - }
51 - },
52 -
53 - /**
54 - * Listen to DOM events during the capture phase.
55 - *
56 - * @param {DOMEventTarget} target DOM element to register listener on.
57 - * @param {string} eventType Event type, e.g. 'click' or 'mouseover'.
58 - * @param {function} callback Callback function.
59 - * @return {object} Object with a `remove` method.
60 - */
61 - capture: function(target, eventType, callback) {
62 - if (target.addEventListener) {
63 - target.addEventListener(eventType, callback, true);
64 - return {
65 - remove: function () {
66 - target.removeEventListener(eventType, callback, true);
67 - }
68 - };
69 - } else {
70 - if (__DEV__) {
71 - console.error(
72 - 'Attempted to listen to events during the capture phase on a ' +
73 - 'browser that does not support the capture phase. Your application ' +
74 - 'will not receive some events.'
75 - );
76 - }
77 - return {
78 - remove: emptyFunction
79 - };
80 - }
81 - },
82 -
83 - registerDefault: function() {}
84 -};
85 -
86 -module.exports = EventListener;
vendor/constants.js deleted
-112
@@ -1,112 +0,0 @@
1 -/**
2 - * Copyright 2013-2015, Facebook, Inc.
3 - * All rights reserved.
4 - *
5 - * This source code is licensed under the BSD-style license found in the
6 - * LICENSE file in the root directory of this source tree. An additional grant
7 - * of patent rights can be found in the PATENTS file in the same directory.
8 - */
9 -'use strict';
10 -
11 -module.exports = function(babel) {
12 - var t = babel.types;
13 -
14 - var DEV_EXPRESSION = t.binaryExpression(
15 - '!==',
16 - t.literal('production'),
17 - t.memberExpression(
18 - t.memberExpression(
19 - t.identifier('process'),
20 - t.identifier('env'),
21 - false
22 - ),
23 - t.identifier('NODE_ENV'),
24 - false
25 - )
26 - );
27 -
28 - return new babel.Transformer('react.constants', {
29 - Identifier: {
30 - enter: function(node, parent) {
31 - // replace __DEV__ with process.env.NODE_ENV !== 'production'
32 - if (this.isIdentifier({name: '__DEV__'})) {
33 - return DEV_EXPRESSION;
34 - }
35 - },
36 - },
37 - CallExpression: {
38 - exit: function(node, parent) {
39 - if (this.get('callee').isIdentifier({name: 'invariant'})) {
40 - // Turns this code:
41 - //
42 - // invariant(condition, argument, argument);
43 - //
44 - // into this:
45 - //
46 - // if (!condition) {
47 - // if ("production" !== process.env.NODE_ENV) {
48 - // invariant(false, argument, argument);
49 - // } else {
50 - // invariant(false);
51 - // }
52 - // }
53 - //
54 - // Specifically this does 2 things:
55 - // 1. Checks the condition first, preventing an extra function call.
56 - // 2. Adds an environment check so that verbose error messages aren't
57 - // shipped to production.
58 - // The generated code is longer than the original code but will dead
59 - // code removal in a minifier will strip that out.
60 - var condition = node.arguments[0];
61 - return t.ifStatement(
62 - t.unaryExpression('!', condition),
63 - t.blockStatement([
64 - t.ifStatement(
65 - DEV_EXPRESSION,
66 - t.blockStatement([
67 - t.expressionStatement(
68 - t.callExpression(
69 - node.callee,
70 - [t.literal(false)].concat(node.arguments.slice(1))
71 - )
72 - ),
73 - ]),
74 - t.blockStatement([
75 - t.expressionStatement(
76 - t.callExpression(
77 - node.callee,
78 - [t.literal(false)]
79 - )
80 - ),
81 - ])
82 - ),
83 - ])
84 - );
85 - } else if (this.get('callee').isIdentifier({name: 'warning'})) {
86 - // Turns this code:
87 - //
88 - // warning(condition, argument, argument);
89 - //
90 - // into this:
91 - //
92 - // if ("production" !== process.env.NODE_ENV) {
93 - // warning(condition, argument, argument);
94 - // }
95 - //
96 - // The goal is to strip out warning calls entirely in production. We
97 - // don't need the same optimizations for conditions that we use for
98 - // invariant because we don't care about an extra call in __DEV__
99 -
100 - return t.ifStatement(
101 - DEV_EXPRESSION,
102 - t.blockStatement([
103 - t.expressionStatement(
104 - node
105 - ),
106 - ])
107 - );
108 - }
109 - },
110 - },
111 - });
112 -};