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

103
node_modules/react-proxy/src/bindAutoBindMethods.js generated vendored Normal file
View File

@@ -0,0 +1,103 @@
/**
* 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 React source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* Original:
* https://github.com/facebook/react/blob/6508b1ad273a6f371e8d90ae676e5390199461b4/src/isomorphic/classic/class/ReactClass.js#L650-L713
*/
function bindAutoBindMethod(component, method) {
var boundMethod = method.bind(component);
boundMethod.__reactBoundContext = component;
boundMethod.__reactBoundMethod = method;
boundMethod.__reactBoundArguments = null;
var componentName = component.constructor.displayName,
_bind = boundMethod.bind;
boundMethod.bind = function (newThis) {
var args = Array.prototype.slice.call(arguments, 1);
if (newThis !== component && newThis !== null) {
console.warn(
'bind(): React component methods may only be bound to the ' +
'component instance. See ' + componentName
);
} else if (!args.length) {
console.warn(
'bind(): You are binding a component method to the component. ' +
'React does this for you automatically in a high-performance ' +
'way, so you can safely remove this call. See ' + componentName
);
return boundMethod;
}
var reboundMethod = _bind.apply(boundMethod, arguments);
reboundMethod.__reactBoundContext = component;
reboundMethod.__reactBoundMethod = method;
reboundMethod.__reactBoundArguments = args;
return reboundMethod;
};
return boundMethod;
}
function bindAutoBindMethodsFromMap(component) {
for (var autoBindKey in component.__reactAutoBindMap) {
if (!component.__reactAutoBindMap.hasOwnProperty(autoBindKey)) {
return;
}
// Tweak: skip methods that are already bound.
// This is to preserve method reference in case it is used
// as a subscription handler that needs to be detached later.
if (
component.hasOwnProperty(autoBindKey) &&
component[autoBindKey].__reactBoundContext === component
) {
continue;
}
var method = component.__reactAutoBindMap[autoBindKey];
component[autoBindKey] = bindAutoBindMethod(component, method);
}
}
export default function bindAutoBindMethods(component) {
if (component.__reactAutoBindPairs) {
bindAutoBindMethodsFromArray(component);
} else if (component.__reactAutoBindMap) {
bindAutoBindMethodsFromMap(component);
}
}
function bindAutoBindMethodsFromArray(component) {
var pairs = component.__reactAutoBindPairs;
if (!pairs) {
return;
}
for (var i = 0; i < pairs.length; i += 2) {
var autoBindKey = pairs[i];
if (
component.hasOwnProperty(autoBindKey) &&
component[autoBindKey].__reactBoundContext === component
) {
continue;
}
var method = pairs[i + 1];
component[autoBindKey] = bindAutoBindMethod(
component,
method
);
}
}

217
node_modules/react-proxy/src/createClassProxy.js generated vendored Normal file
View File

@@ -0,0 +1,217 @@
import find from 'lodash/find';
import createPrototypeProxy from './createPrototypeProxy';
import bindAutoBindMethods from './bindAutoBindMethods';
import deleteUnknownAutoBindMethods from './deleteUnknownAutoBindMethods';
import supportsProtoAssignment from './supportsProtoAssignment';
const RESERVED_STATICS = [
'length',
'name',
'arguments',
'caller',
'prototype',
'toString'
];
function isEqualDescriptor(a, b) {
if (!a && !b) {
return true;
}
if (!a || !b) {
return false;
}
for (let key in a) {
if (a[key] !== b[key]) {
return false;
}
}
return true;
}
// This was originally a WeakMap but we had issues with React Native:
// https://github.com/gaearon/react-proxy/issues/50#issuecomment-192928066
let allProxies = [];
function findProxy(Component) {
const pair = find(allProxies, ([key]) => key === Component);
return pair ? pair[1] : null;
}
function addProxy(Component, proxy) {
allProxies.push([Component, proxy]);
}
export default function proxyClass(InitialComponent) {
// Prevent double wrapping.
// Given a proxy class, return the existing proxy managing it.
var existingProxy = findProxy(InitialComponent);
if (existingProxy) {
return existingProxy;
}
const prototypeProxy = createPrototypeProxy();
let CurrentComponent;
let ProxyComponent;
let staticDescriptors = {};
function wasStaticModifiedByUser(key) {
// Compare the descriptor with the one we previously set ourselves.
const currentDescriptor = Object.getOwnPropertyDescriptor(ProxyComponent, key);
return !isEqualDescriptor(staticDescriptors[key], currentDescriptor);
}
function instantiate(factory, context, params) {
const component = factory();
try {
return component.apply(context, params);
} catch (err) {
// Native ES6 class instantiation
const instance = new component(...params);
Object.keys(instance).forEach(key => {
if (RESERVED_STATICS.indexOf(key) > -1) {
return;
}
context[key] = instance[key];
})
}
}
try {
// Create a proxy constructor with matching name
ProxyComponent = new Function('factory', 'instantiate',
`return function ${InitialComponent.name || 'ProxyComponent'}() {
return instantiate(factory, this, arguments);
}`
)(() => CurrentComponent, instantiate);
} catch (err) {
// Some environments may forbid dynamic evaluation
ProxyComponent = function () {
return instantiate(() => CurrentComponent, this, arguments);
};
}
// Point proxy constructor to the proxy prototype
ProxyComponent.prototype = prototypeProxy.get();
// Proxy toString() to the current constructor
ProxyComponent.toString = function toString() {
return CurrentComponent.toString();
};
function update(NextComponent) {
if (typeof NextComponent !== 'function') {
throw new Error('Expected a constructor.');
}
// Prevent proxy cycles
var existingProxy = findProxy(NextComponent);
if (existingProxy) {
return update(existingProxy.__getCurrent());
}
// Save the next constructor so we call it
CurrentComponent = NextComponent;
// Update the prototype proxy with new methods
const mountedInstances = prototypeProxy.update(NextComponent.prototype);
// Set up the constructor property so accessing the statics work
ProxyComponent.prototype.constructor = ProxyComponent;
// Set up the same prototype for inherited statics
ProxyComponent.__proto__ = NextComponent.__proto__;
// Copy static methods and properties
Object.getOwnPropertyNames(NextComponent).forEach(key => {
if (RESERVED_STATICS.indexOf(key) > -1) {
return;
}
const staticDescriptor = {
...Object.getOwnPropertyDescriptor(NextComponent, key),
configurable: true
};
// Copy static unless user has redefined it at runtime
if (!wasStaticModifiedByUser(key)) {
Object.defineProperty(ProxyComponent, key, staticDescriptor);
staticDescriptors[key] = staticDescriptor;
}
});
// Remove old static methods and properties
Object.getOwnPropertyNames(ProxyComponent).forEach(key => {
if (RESERVED_STATICS.indexOf(key) > -1) {
return;
}
// Skip statics that exist on the next class
if (NextComponent.hasOwnProperty(key)) {
return;
}
// Skip non-configurable statics
const descriptor = Object.getOwnPropertyDescriptor(ProxyComponent, key);
if (descriptor && !descriptor.configurable) {
return;
}
// Delete static unless user has redefined it at runtime
if (!wasStaticModifiedByUser(key)) {
delete ProxyComponent[key];
delete staticDescriptors[key];
}
});
// Try to infer displayName
ProxyComponent.displayName = NextComponent.displayName || NextComponent.name;
// We might have added new methods that need to be auto-bound
mountedInstances.forEach(bindAutoBindMethods);
mountedInstances.forEach(deleteUnknownAutoBindMethods);
// Let the user take care of redrawing
return mountedInstances;
};
function get() {
return ProxyComponent;
}
function getCurrent() {
return CurrentComponent;
}
update(InitialComponent);
const proxy = { get, update };
addProxy(ProxyComponent, proxy);
Object.defineProperty(proxy, '__getCurrent', {
configurable: false,
writable: false,
enumerable: false,
value: getCurrent
});
return proxy;
}
function createFallback(Component) {
let CurrentComponent = Component;
return {
get() {
return CurrentComponent;
},
update(NextComponent) {
CurrentComponent = NextComponent;
}
};
}
export default function createClassProxy(Component) {
return Component.__proto__ && supportsProtoAssignment() ?
proxyClass(Component) :
createFallback(Component);
}

185
node_modules/react-proxy/src/createPrototypeProxy.js generated vendored Normal file
View File

@@ -0,0 +1,185 @@
import assign from 'lodash/assign';
import difference from 'lodash/difference';
export default function createPrototypeProxy() {
let proxy = {};
let current = null;
let mountedInstances = [];
/**
* Creates a proxied toString() method pointing to the current version's toString().
*/
function proxyToString(name) {
// Wrap to always call the current version
return function toString() {
if (typeof current[name] === 'function') {
return current[name].toString();
} else {
return '<method was deleted>';
}
};
}
/**
* Creates a proxied method that calls the current version, whenever available.
*/
function proxyMethod(name) {
// Wrap to always call the current version
const proxiedMethod = function () {
if (typeof current[name] === 'function') {
return current[name].apply(this, arguments);
}
};
// Copy properties of the original function, if any
assign(proxiedMethod, current[name]);
proxiedMethod.toString = proxyToString(name);
return proxiedMethod;
}
/**
* Augments the original componentDidMount with instance tracking.
*/
function proxiedComponentDidMount() {
mountedInstances.push(this);
if (typeof current.componentDidMount === 'function') {
return current.componentDidMount.apply(this, arguments);
}
}
proxiedComponentDidMount.toString = proxyToString('componentDidMount');
/**
* Augments the original componentWillUnmount with instance tracking.
*/
function proxiedComponentWillUnmount() {
const index = mountedInstances.indexOf(this);
// Unless we're in a weird environment without componentDidMount
if (index !== -1) {
mountedInstances.splice(index, 1);
}
if (typeof current.componentWillUnmount === 'function') {
return current.componentWillUnmount.apply(this, arguments);
}
}
proxiedComponentWillUnmount.toString = proxyToString('componentWillUnmount');
/**
* Defines a property on the proxy.
*/
function defineProxyProperty(name, descriptor) {
Object.defineProperty(proxy, name, descriptor);
}
/**
* Defines a property, attempting to keep the original descriptor configuration.
*/
function defineProxyPropertyWithValue(name, value) {
const {
enumerable = false,
writable = true
} = Object.getOwnPropertyDescriptor(current, name) || {};
defineProxyProperty(name, {
configurable: true,
enumerable,
writable,
value
});
}
/**
* Creates an auto-bind map mimicking the original map, but directed at proxy.
*/
function createAutoBindMap() {
if (!current.__reactAutoBindMap) {
return;
}
let __reactAutoBindMap = {};
for (let name in current.__reactAutoBindMap) {
if (typeof proxy[name] === 'function' && current.__reactAutoBindMap.hasOwnProperty(name)) {
__reactAutoBindMap[name] = proxy[name];
}
}
return __reactAutoBindMap;
}
/**
* Creates an auto-bind map mimicking the original map, but directed at proxy.
*/
function createAutoBindPairs() {
let __reactAutoBindPairs = [];
for (let i = 0; i < current.__reactAutoBindPairs.length; i += 2) {
const name = current.__reactAutoBindPairs[i];
const method = proxy[name];
if (typeof method === 'function') {
__reactAutoBindPairs.push(name, method);
}
}
return __reactAutoBindPairs;
}
/**
* Applies the updated prototype.
*/
function update(next) {
// Save current source of truth
current = next;
// Find changed property names
const currentNames = Object.getOwnPropertyNames(current);
const previousName = Object.getOwnPropertyNames(proxy);
const removedNames = difference(previousName, currentNames);
// Remove properties and methods that are no longer there
removedNames.forEach(name => {
delete proxy[name];
});
// Copy every descriptor
currentNames.forEach(name => {
const descriptor = Object.getOwnPropertyDescriptor(current, name);
if (typeof descriptor.value === 'function') {
// Functions require additional wrapping so they can be bound later
defineProxyPropertyWithValue(name, proxyMethod(name));
} else {
// Other values can be copied directly
defineProxyProperty(name, descriptor);
}
});
// Track mounting and unmounting
defineProxyPropertyWithValue('componentDidMount', proxiedComponentDidMount);
defineProxyPropertyWithValue('componentWillUnmount', proxiedComponentWillUnmount);
if (current.hasOwnProperty('__reactAutoBindMap')) {
defineProxyPropertyWithValue('__reactAutoBindMap', createAutoBindMap());
}
if (current.hasOwnProperty('__reactAutoBindPairs')) {
defineProxyPropertyWithValue('__reactAutoBindPairs', createAutoBindPairs());
}
// Set up the prototype chain
proxy.__proto__ = next;
return mountedInstances;
}
/**
* Returns the up-to-date proxy prototype.
*/
function get() {
return proxy;
}
return {
update,
get
};
};

View File

@@ -0,0 +1,76 @@
function shouldDeleteClassicInstanceMethod(component, name) {
if (component.__reactAutoBindMap && component.__reactAutoBindMap.hasOwnProperty(name)) {
// It's a known autobound function, keep it
return false;
}
if (component.__reactAutoBindPairs && component.__reactAutoBindPairs.indexOf(name) >= 0) {
// It's a known autobound function, keep it
return false;
}
if (component[name].__reactBoundArguments !== null) {
// It's a function bound to specific args, keep it
return false;
}
// It's a cached bound method for a function
// that was deleted by user, so we delete it from component.
return true;
}
function shouldDeleteModernInstanceMethod(component, name) {
const { prototype } = component.constructor;
const prototypeDescriptor = Object.getOwnPropertyDescriptor(prototype, name);
if (!prototypeDescriptor || !prototypeDescriptor.get) {
// This is definitely not an autobinding getter
return false;
}
if (prototypeDescriptor.get().length !== component[name].length) {
// The length doesn't match, bail out
return false;
}
// This seems like a method bound using an autobinding getter on the prototype
// Hopefully we won't run into too many false positives.
return true;
}
function shouldDeleteInstanceMethod(component, name) {
const descriptor = Object.getOwnPropertyDescriptor(component, name);
if (typeof descriptor.value !== 'function') {
// Not a function, or something fancy: bail out
return;
}
if (component.__reactAutoBindMap || component.__reactAutoBindPairs) {
// Classic
return shouldDeleteClassicInstanceMethod(component, name);
} else {
// Modern
return shouldDeleteModernInstanceMethod(component, name);
}
}
/**
* Deletes autobound methods from the instance.
*
* For classic React classes, we only delete the methods that no longer exist in map.
* This means the user actually deleted them in code.
*
* For modern classes, we delete methods that exist on prototype with the same length,
* and which have getters on prototype, but are normal values on the instance.
* This is usually an indication that an autobinding decorator is being used,
* and the getter will re-generate the memoized handler on next access.
*/
export default function deleteUnknownAutoBindMethods(component) {
const names = Object.getOwnPropertyNames(component);
names.forEach(name => {
if (shouldDeleteInstanceMethod(component, name)) {
delete component[name];
}
});
}

14
node_modules/react-proxy/src/index.js generated vendored Normal file
View File

@@ -0,0 +1,14 @@
import supportsProtoAssignment from './supportsProtoAssignment';
if (!supportsProtoAssignment()) {
console.warn(
'This JavaScript environment does not support __proto__. ' +
'This means that react-proxy is unable to proxy React components. ' +
'Features that rely on react-proxy, such as react-transform-hmr, ' +
'will not function as expected.'
);
}
import createProxy from './createClassProxy';
import getForceUpdate from 'react-deep-force-update';
export { createProxy, getForceUpdate };

View File

@@ -0,0 +1,9 @@
const x = {};
const y = { supports: true };
try {
x.__proto__ = y;
} catch (err) {}
export default function supportsProtoAssignment() {
return x.supports || false;
};