initial commit taken from gitlab.lrz.de

This commit is contained in:
privatereese
2018-08-24 18:09:42 +02:00
parent ae54ed4c48
commit fc05486403
28494 changed files with 2159823 additions and 0 deletions

141
node_modules/react-transform-hmr/README.md generated vendored Normal file
View File

@@ -0,0 +1,141 @@
# react-transform-hmr
[![react-transform channel on discord](https://img.shields.io/badge/discord-react--transform%40reactiflux-61DAFB.svg?style=flat-square)](http://www.reactiflux.com)
A [React Transform](https://github.com/gaearon/babel-plugin-react-transform) that enables hot reloading React classes using Hot Module Replacement API. Hot module replacement is [supported natively by Webpack](http://webpack.github.io/docs/hot-module-replacement-with-webpack.html) and available in Browserify with [browserify-hmr](https://github.com/AgentME/browserify-hmr).
## 🚧🚧🚧🚧🚧
This is **highly experimental tech**. If youre enthusiastic about hot reloading, by all means, give it a try, but dont bet your project on it. Either of the technologies it relies upon may change drastically or get deprecated any day. Youve been warned 😉 .
**This technology exists to prototype next-generation React developer experience**. Please dont use it blindly if you dont know the underlying technologies well. Otherwise you are likely to get disillusioned with JavaScript tooling.
**No effort went into making this user-friendly yet. The goal is to eventually kill this technology** in favor of less hacky technologies baked into React. These projects are not long term.
## Installation
First, install the [Babel plugin](https://github.com/gaearon/babel-plugin-react-transform):
```
npm install --save-dev babel-plugin-react-transform
```
Then, install the transform:
```
npm install --save-dev react-transform-hmr
```
### React
Edit your `.babelrc` to include a plugin configuration for `react-transform`. It contains array of the transforms you want to use:
```js
{
"presets": ["es2015", "stage-0"],
"env": {
// only enable it when process.env.NODE_ENV is 'development' or undefined
"development": {
"plugins": [["react-transform", {
"transforms": [{
"transform": "react-transform-hmr",
// if you use React Native, pass "react-native" instead:
"imports": ["react"],
// this is important for Webpack HMR:
"locals": ["module"]
}]
// note: you can put more transforms into array
// this is just one of them!
}]]
}
}
}
```
Make sure you process files with `babel-loader`, and that you *dont* use React Hot Loader (its not needed with this transform).
**It is up to you to ensure that the transform is not enabled when you compile the app in production mode.** The easiest way to do this is to put React Transform configuration inside `env.development` in `.babelrc` and ensure youre calling `babel` with `NODE_ENV=production`. See [babelrc documentation](https://babeljs.io/docs/usage/babelrc/#env-option) for more details about using `env` option.
**Warning!** This doesn't currently work for stateless functional components that were introduced in [React 0.14](https://facebook.github.io/react/blog/2015/10/07/react-v0.14.html#stateless-functional-components)!
### React Native
This transform enables hot reloading when used together with [React Native Webpack Server](https://github.com/mjohnston/react-native-webpack-server). **However note that you should not use `.babelrc` to configure it with React Native.** Otherwise youll get [`Uncaught SyntaxError: Unexpected reserved word` in `ActivityIndicatorIOS.ios.js`](https://github.com/mjohnston/react-native-webpack-server/issues/57#issuecomment-141487449).
There are two problems why `.babelrc` doesnt work well in React Native:
* Changes in it [arent picked up by packagers aggressive caching](https://github.com/mjohnston/react-native-webpack-server/issues/63).
* Another unknown problem causes `import` generated by `babel-plugin-react-transform` to not be compiled into a `require` call.
Until we have better `.babelrc` support in React Native, **you should configure React Transform together with `babel-loader`**:
```js
var fs = require('fs');
var path = require('path');
var webpack = require('webpack');
var config = {
debug: true,
devtool: 'source-map',
entry: {
'index.ios': ['./src/main.js'],
},
output: {
path: path.resolve(__dirname, 'build'),
filename: '[name].js',
},
module: {
loaders: [{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel',
query: {
stage: 0,
plugins: []
}
}]
},
plugins: []
};
// Hot mode
if (process.env.HOT) {
config.devtool = 'eval';
config.entry['index.ios'].unshift('react-native-webpack-server/hot/entry');
config.entry['index.ios'].unshift('webpack/hot/only-dev-server');
config.entry['index.ios'].unshift('webpack-dev-server/client?http://localhost:8082');
config.output.publicPath = 'http://localhost:8082/';
config.plugins.unshift(new webpack.HotModuleReplacementPlugin());
// Note: enabling React Transform and React Transform HMR:
config.module.loaders[0].query.plugins.push([
'react-transform', {
transforms: [{
transform : 'react-transform-hmr',
imports : ['react'],
locals : ['module']
}]
}
]);
}
if (process.env.NODE_ENV === 'production') {
config.plugins.push(new webpack.optimize.OccurrenceOrderPlugin());
config.plugins.push(new webpack.optimize.UglifyJsPlugin());
}
module.exports = config;
```
See [React Native Webpack Server examples](https://github.com/mjohnston/react-native-webpack-server/tree/master/Examples/) for details.
## License
MIT

95
node_modules/react-transform-hmr/lib/index.js generated vendored Normal file
View File

@@ -0,0 +1,95 @@
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
var _slicedToArray = (function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i['return']) _i['return'](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError('Invalid attempt to destructure non-iterable instance'); } }; })();
exports['default'] = proxyReactComponents;
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
var _reactProxy = require('react-proxy');
var _globalWindow = require('global/window');
var _globalWindow2 = _interopRequireDefault(_globalWindow);
var componentProxies = undefined;
if (_globalWindow2['default'].__reactComponentProxies) {
componentProxies = _globalWindow2['default'].__reactComponentProxies;
} else {
componentProxies = {};
Object.defineProperty(_globalWindow2['default'], '__reactComponentProxies', {
configurable: true,
enumerable: false,
writable: false,
value: componentProxies
});
}
function proxyReactComponents(_ref) {
var filename = _ref.filename;
var components = _ref.components;
var imports = _ref.imports;
var locals = _ref.locals;
var _imports = _slicedToArray(imports, 1);
var React = _imports[0];
var _locals = _slicedToArray(locals, 1);
var hot = _locals[0].hot;
if (!React.Component) {
throw new Error('imports[0] for react-transform-hmr does not look like React.');
}
if (!hot || typeof hot.accept !== 'function') {
throw new Error('locals[0] does not appear to be a `module` object with Hot Module ' + 'replacement API enabled. You should disable react-transform-hmr in ' + 'production by using `env` section in Babel configuration. See the ' + 'example in README: https://github.com/gaearon/react-transform-hmr');
}
if (Object.keys(components).some(function (key) {
return !components[key].isInFunction;
})) {
hot.accept(function (err) {
if (err) {
console.warn('[React Transform HMR] There was an error updating ' + filename + ':');
console.error(err);
}
});
}
var forceUpdate = (0, _reactProxy.getForceUpdate)(React);
return function wrapWithProxy(ReactClass, uniqueId) {
var _components$uniqueId = components[uniqueId];
var _components$uniqueId$isInFunction = _components$uniqueId.isInFunction;
var isInFunction = _components$uniqueId$isInFunction === undefined ? false : _components$uniqueId$isInFunction;
var _components$uniqueId$displayName = _components$uniqueId.displayName;
var displayName = _components$uniqueId$displayName === undefined ? uniqueId : _components$uniqueId$displayName;
if (isInFunction) {
return ReactClass;
}
var globalUniqueId = filename + '$' + uniqueId;
if (componentProxies[globalUniqueId]) {
(function () {
console.info('[React Transform HMR] Patching ' + displayName);
var instances = componentProxies[globalUniqueId].update(ReactClass);
setTimeout(function () {
return instances.forEach(forceUpdate);
});
})();
} else {
componentProxies[globalUniqueId] = (0, _reactProxy.createProxy)(ReactClass);
}
return componentProxies[globalUniqueId].get();
};
}
module.exports = exports['default'];

105
node_modules/react-transform-hmr/package.json generated vendored Normal file
View File

@@ -0,0 +1,105 @@
{
"_args": [
[
"react-transform-hmr@^1.0.4",
"/home/bernhard/freifunk-app/node_modules/babel-preset-react-native"
]
],
"_from": "react-transform-hmr@>=1.0.4 <2.0.0",
"_id": "react-transform-hmr@1.0.4",
"_inCache": true,
"_installable": true,
"_location": "/react-transform-hmr",
"_nodeVersion": "5.3.0",
"_npmOperationalInternal": {
"host": "packages-13-west.internal.npmjs.com",
"tmp": "tmp/react-transform-hmr-1.0.4.tgz_1457287427851_0.17050196835771203"
},
"_npmUser": {
"email": "dan.abramov@gmail.com",
"name": "gaearon"
},
"_npmVersion": "3.3.12",
"_phantomChildren": {},
"_requested": {
"name": "react-transform-hmr",
"raw": "react-transform-hmr@^1.0.4",
"rawSpec": "^1.0.4",
"scope": null,
"spec": ">=1.0.4 <2.0.0",
"type": "range"
},
"_requiredBy": [
"/babel-preset-react-native"
],
"_resolved": "https://registry.npmjs.org/react-transform-hmr/-/react-transform-hmr-1.0.4.tgz",
"_shasum": "e1a40bd0aaefc72e8dfd7a7cda09af85066397bb",
"_shrinkwrap": null,
"_spec": "react-transform-hmr@^1.0.4",
"_where": "/home/bernhard/freifunk-app/node_modules/babel-preset-react-native",
"author": {
"email": "dan.abramov@me.com",
"name": "Dan Abramov"
},
"bugs": {
"url": "https://github.com/gaearon/react-transform-hmr/issues"
},
"dependencies": {
"global": "^4.3.0",
"react-proxy": "^1.1.7"
},
"description": "A React Transform that enables hot reloading React classes using Hot Module Replacement API",
"devDependencies": {
"babel": "^5.8.23",
"rimraf": "^2.4.3"
},
"directories": {},
"dist": {
"shasum": "e1a40bd0aaefc72e8dfd7a7cda09af85066397bb",
"tarball": "https://registry.npmjs.org/react-transform-hmr/-/react-transform-hmr-1.0.4.tgz"
},
"files": [
"lib",
"src"
],
"gitHead": "1ab7759a0b0700e71895dabc6a94e2f819455bd3",
"homepage": "https://github.com/gaearon/react-transform-hmr#readme",
"keywords": [
"dx",
"edit",
"hmr",
"hot",
"live",
"react",
"react-transform",
"reactjs",
"reload",
"rhl",
"webpack"
],
"license": "MIT",
"main": "lib/index.js",
"maintainers": [
{
"name": "gaearon",
"email": "dan.abramov@gmail.com"
},
{
"name": "thejameskyle",
"email": "me@thejameskyle.com"
}
],
"name": "react-transform-hmr",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git+https://github.com/gaearon/react-transform-hmr.git"
},
"scripts": {
"build": "babel src --out-dir lib",
"clean": "rimraf lib",
"prepublish": "npm run clean && npm run build"
},
"version": "1.0.4"
}

68
node_modules/react-transform-hmr/src/index.js generated vendored Normal file
View File

@@ -0,0 +1,68 @@
import { getForceUpdate, createProxy } from 'react-proxy';
import window from 'global/window';
let componentProxies;
if (window.__reactComponentProxies) {
componentProxies = window.__reactComponentProxies;
} else {
componentProxies = {};
Object.defineProperty(window, '__reactComponentProxies', {
configurable: true,
enumerable: false,
writable: false,
value: componentProxies
});
}
export default function proxyReactComponents({ filename, components, imports, locals }) {
const [React] = imports;
const [{ hot }] = locals;
if (!React.Component) {
throw new Error(
'imports[0] for react-transform-hmr does not look like React.'
);
}
if (!hot || typeof hot.accept !== 'function') {
throw new Error(
'locals[0] does not appear to be a `module` object with Hot Module ' +
'replacement API enabled. You should disable react-transform-hmr in ' +
'production by using `env` section in Babel configuration. See the ' +
'example in README: https://github.com/gaearon/react-transform-hmr'
);
}
if (Object.keys(components).some(key => !components[key].isInFunction)) {
hot.accept(err => {
if (err) {
console.warn(`[React Transform HMR] There was an error updating ${filename}:`);
console.error(err);
}
});
}
const forceUpdate = getForceUpdate(React);
return function wrapWithProxy(ReactClass, uniqueId) {
const {
isInFunction = false,
displayName = uniqueId
} = components[uniqueId];
if (isInFunction) {
return ReactClass;
}
const globalUniqueId = filename + '$' + uniqueId;
if (componentProxies[globalUniqueId]) {
console.info('[React Transform HMR] Patching ' + displayName);
const instances = componentProxies[globalUniqueId].update(ReactClass);
setTimeout(() => instances.forEach(forceUpdate));
} else {
componentProxies[globalUniqueId] = createProxy(ReactClass);
}
return componentProxies[globalUniqueId].get();
};
}