mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-29 12:45:37 +08:00
Initial web implementation
Summary: @public
This diff does a couple of things:
- Move all the code in a src/ folder
- Move bezier.js in the Animated folder
- Rename Animated.js into AnimatedImplementation.js and adds two entry points: AnimatedReactNative.js and AnimatedWeb.js
- Implement very dumb polyfills for flattenStyle, Set and InteractionManager
- Import my work in progress demo.html file to make sure that the code is actually working.
Everything is not working correctly:
- It calls forceUpdate on every frame and doesn't use bindings because setNativeProps is not implemented
- None of the style: {transform} are working because React web doesn't know about the array notation for transform
- The demo need more work
Reviewed By: @sahrens
Differential Revision: D2464277
This commit is contained in:
committed by
facebook-github-bot-5
parent
c45be4d55a
commit
a50b4ea7b9
160
Libraries/Animated/release/gulpfile.js
Normal file
160
Libraries/Animated/release/gulpfile.js
Normal file
@@ -0,0 +1,160 @@
|
||||
/**
|
||||
* Copyright 2013-2015, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var babel = require('gulp-babel');
|
||||
var babelPluginDEV = require('fbjs-scripts/babel/dev-expression');
|
||||
var babelPluginModules = require('fbjs-scripts/babel/rewrite-modules');
|
||||
var del = require('del');
|
||||
var derequire = require('gulp-derequire');
|
||||
var flatten = require('gulp-flatten');
|
||||
var gulp = require('gulp');
|
||||
var gulpUtil = require('gulp-util');
|
||||
var header = require('gulp-header');
|
||||
var objectAssign = require('object-assign');
|
||||
var runSequence = require('run-sequence');
|
||||
var webpackStream = require('webpack-stream');
|
||||
|
||||
var DEVELOPMENT_HEADER = [
|
||||
'/**',
|
||||
' * Animated v<%= version %>',
|
||||
' */'
|
||||
].join('\n') + '\n';
|
||||
var PRODUCTION_HEADER = [
|
||||
'/**',
|
||||
' * Animated v<%= version %>',
|
||||
' *',
|
||||
' * Copyright 2013-2015, Facebook, Inc.',
|
||||
' * All rights reserved.',
|
||||
' *',
|
||||
' * This source code is licensed under the BSD-style license found in the',
|
||||
' * LICENSE file in the root directory of this source tree. An additional grant',
|
||||
' * of patent rights can be found in the PATENTS file in the same directory.',
|
||||
' *',
|
||||
' */'
|
||||
].join('\n') + '\n';
|
||||
|
||||
var babelOpts = {
|
||||
nonStandard: true,
|
||||
loose: [
|
||||
'es6.classes'
|
||||
],
|
||||
stage: 1,
|
||||
plugins: [babelPluginDEV, babelPluginModules],
|
||||
_moduleMap: objectAssign({}, require('fbjs/module-map'), {
|
||||
'React': 'react',
|
||||
})
|
||||
};
|
||||
|
||||
var buildDist = function(opts) {
|
||||
var webpackOpts = {
|
||||
debug: opts.debug,
|
||||
externals: {
|
||||
'react': 'React',
|
||||
},
|
||||
module: {
|
||||
loaders: [
|
||||
{test: /\.js$/, loader: 'babel'}
|
||||
],
|
||||
},
|
||||
output: {
|
||||
filename: opts.output,
|
||||
library: 'Animated'
|
||||
},
|
||||
plugins: [
|
||||
new webpackStream.webpack.DefinePlugin({
|
||||
'process.env.NODE_ENV': JSON.stringify(
|
||||
opts.debug ? 'development' : 'production'
|
||||
),
|
||||
}),
|
||||
new webpackStream.webpack.optimize.OccurenceOrderPlugin(),
|
||||
new webpackStream.webpack.optimize.DedupePlugin()
|
||||
]
|
||||
};
|
||||
if (!opts.debug) {
|
||||
webpackOpts.plugins.push(
|
||||
new webpackStream.webpack.optimize.UglifyJsPlugin({
|
||||
compress: {
|
||||
hoist_vars: true,
|
||||
screw_ie8: true,
|
||||
warnings: false
|
||||
}
|
||||
})
|
||||
);
|
||||
}
|
||||
return webpackStream(webpackOpts, null, function(err, stats) {
|
||||
if (err) {
|
||||
throw new gulpUtil.PluginError('webpack', err);
|
||||
}
|
||||
if (stats.compilation.errors.length) {
|
||||
throw new gulpUtil.PluginError('webpack', stats.toString());
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
var paths = {
|
||||
dist: 'dist',
|
||||
entry: 'lib/AnimatedWeb.js',
|
||||
lib: 'lib',
|
||||
src: [
|
||||
'*src/**/*.js',
|
||||
'!src/**/__tests__/**/*.js',
|
||||
'!src/**/__mocks__/**/*.js'
|
||||
],
|
||||
};
|
||||
|
||||
gulp.task('clean', function(cb) {
|
||||
del([paths.dist, paths.lib], cb);
|
||||
});
|
||||
|
||||
gulp.task('modules', function() {
|
||||
return gulp
|
||||
.src(paths.src, {cwd: '../'})
|
||||
.pipe(babel(babelOpts))
|
||||
.pipe(flatten())
|
||||
.pipe(gulp.dest(paths.lib));
|
||||
});
|
||||
|
||||
gulp.task('dist', ['modules'], function () {
|
||||
var distOpts = {
|
||||
debug: true,
|
||||
output: 'animated.js'
|
||||
};
|
||||
return gulp
|
||||
.src(paths.entry)
|
||||
.pipe(buildDist(distOpts))
|
||||
.pipe(derequire())
|
||||
.pipe(header(DEVELOPMENT_HEADER, {
|
||||
version: process.env.npm_package_version
|
||||
}))
|
||||
.pipe(gulp.dest(paths.dist));
|
||||
});
|
||||
|
||||
gulp.task('dist:min', ['modules'], function () {
|
||||
var distOpts = {
|
||||
debug: false,
|
||||
output: 'animated.min.js'
|
||||
};
|
||||
return gulp
|
||||
.src(paths.entry)
|
||||
.pipe(buildDist(distOpts))
|
||||
.pipe(header(PRODUCTION_HEADER, {
|
||||
version: process.env.npm_package_version
|
||||
}))
|
||||
.pipe(gulp.dest(paths.dist));
|
||||
});
|
||||
|
||||
gulp.task('watch', function() {
|
||||
gulp.watch(paths.src, ['modules']);
|
||||
});
|
||||
|
||||
gulp.task('default', function(cb) {
|
||||
runSequence('clean', 'modules', ['dist', 'dist:min'], cb);
|
||||
});
|
||||
34
Libraries/Animated/release/package.json
Normal file
34
Libraries/Animated/release/package.json
Normal file
@@ -0,0 +1,34 @@
|
||||
{
|
||||
"name": "react-animated",
|
||||
"description": "Animated provides powerful mechanisms for animating your React views",
|
||||
"version": "0.1.0",
|
||||
"keywords": [
|
||||
"react",
|
||||
"animated",
|
||||
"animation"
|
||||
],
|
||||
"license": "BSD-3-Clause",
|
||||
"main": "Animated.js",
|
||||
"dependencies": {
|
||||
"fbjs": "^0.2.1"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "gulp"
|
||||
},
|
||||
"devDependencies": {
|
||||
"babel-core": "^5.8.25",
|
||||
"babel-loader": "^5.3.2",
|
||||
"del": "^1.2.0",
|
||||
"fbjs-scripts": "^0.2.0",
|
||||
"gulp": "^3.9.0",
|
||||
"gulp-babel": "^5.1.0",
|
||||
"gulp-derequire": "^2.1.0",
|
||||
"gulp-flatten": "^0.1.0",
|
||||
"gulp-header": "^1.2.2",
|
||||
"gulp-util": "^3.0.6",
|
||||
"object-assign": "^3.0.0",
|
||||
"run-sequence": "^1.1.2",
|
||||
"webpack": "1.11.0",
|
||||
"webpack-stream": "^2.1.0"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user