WIP - add extractor, generate snippet_data

This commit is contained in:
Stefan Fejes
2019-08-20 15:52:05 +02:00
parent 88084d3d30
commit cc8f1d8a7a
37396 changed files with 4588842 additions and 133 deletions

29
node_modules/react-redux/es/hooks/useDispatch.js generated vendored Normal file
View File

@@ -0,0 +1,29 @@
import { useStore } from './useStore';
/**
* A hook to access the redux `dispatch` function. Note that in most cases where you
* might want to use this hook it is recommended to use `useActions` instead to bind
* action creators to the `dispatch` function.
*
* @returns {any|function} redux store's `dispatch` function
*
* @example
*
* import React, { useCallback } from 'react'
* import { useReduxDispatch } from 'react-redux'
*
* export const CounterComponent = ({ value }) => {
* const dispatch = useDispatch()
* const increaseCounter = useCallback(() => dispatch({ type: 'increase-counter' }), [])
* return (
* <div>
* <span>{value}</span>
* <button onClick={increaseCounter}>Increase counter</button>
* </div>
* )
* }
*/
export function useDispatch() {
var store = useStore();
return store.dispatch;
}

25
node_modules/react-redux/es/hooks/useReduxContext.js generated vendored Normal file
View File

@@ -0,0 +1,25 @@
import { useContext } from 'react';
import invariant from 'invariant';
import { ReactReduxContext } from '../components/Context';
/**
* A hook to access the value of the `ReactReduxContext`. This is a low-level
* hook that you should usually not need to call directly.
*
* @returns {any} the value of the `ReactReduxContext`
*
* @example
*
* import React from 'react'
* import { useReduxContext } from 'react-redux'
*
* export const CounterComponent = ({ value }) => {
* const { store } = useReduxContext()
* return <div>{store.getState()}</div>
* }
*/
export function useReduxContext() {
var contextValue = useContext(ReactReduxContext);
invariant(contextValue, 'could not find react-redux context value; please ensure the component is wrapped in a <Provider>');
return contextValue;
}

117
node_modules/react-redux/es/hooks/useSelector.js generated vendored Normal file
View File

@@ -0,0 +1,117 @@
import { useReducer, useRef, useEffect, useMemo, useLayoutEffect } from 'react';
import invariant from 'invariant';
import { useReduxContext } from './useReduxContext';
import Subscription from '../utils/Subscription'; // React currently throws a warning when using useLayoutEffect on the server.
// To get around it, we can conditionally useEffect on the server (no-op) and
// useLayoutEffect in the browser. We need useLayoutEffect to ensure the store
// subscription callback always has the selector from the latest render commit
// available, otherwise a store update may happen between render and the effect,
// which may cause missed updates; we also must ensure the store subscription
// is created synchronously, otherwise a store update may occur before the
// subscription is created and an inconsistent state may be observed
var useIsomorphicLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect;
var refEquality = function refEquality(a, b) {
return a === b;
};
/**
* A hook to access the redux store's state. This hook takes a selector function
* as an argument. The selector is called with the store state.
*
* This hook takes an optional equality comparison function as the second parameter
* that allows you to customize the way the selected state is compared to determine
* whether the component needs to be re-rendered.
*
* @param {Function} selector the selector function
* @param {Function=} equalityFn the function that will be used to determine equality
*
* @returns {any} the selected state
*
* @example
*
* import React from 'react'
* import { useSelector } from 'react-redux'
*
* export const CounterComponent = () => {
* const counter = useSelector(state => state.counter)
* return <div>{counter}</div>
* }
*/
export function useSelector(selector, equalityFn) {
if (equalityFn === void 0) {
equalityFn = refEquality;
}
invariant(selector, "You must pass a selector to useSelectors");
var _useReduxContext = useReduxContext(),
store = _useReduxContext.store,
contextSub = _useReduxContext.subscription;
var _useReducer = useReducer(function (s) {
return s + 1;
}, 0),
forceRender = _useReducer[1];
var subscription = useMemo(function () {
return new Subscription(store, contextSub);
}, [store, contextSub]);
var latestSubscriptionCallbackError = useRef();
var latestSelector = useRef();
var latestSelectedState = useRef();
var selectedState;
try {
if (selector !== latestSelector.current || latestSubscriptionCallbackError.current) {
selectedState = selector(store.getState());
} else {
selectedState = latestSelectedState.current;
}
} catch (err) {
var errorMessage = "An error occured while selecting the store state: " + err.message + ".";
if (latestSubscriptionCallbackError.current) {
errorMessage += "\nThe error may be correlated with this previous error:\n" + latestSubscriptionCallbackError.current.stack + "\n\nOriginal stack trace:";
}
throw new Error(errorMessage);
}
useIsomorphicLayoutEffect(function () {
latestSelector.current = selector;
latestSelectedState.current = selectedState;
latestSubscriptionCallbackError.current = undefined;
});
useIsomorphicLayoutEffect(function () {
function checkForUpdates() {
try {
var newSelectedState = latestSelector.current(store.getState());
if (equalityFn(newSelectedState, latestSelectedState.current)) {
return;
}
latestSelectedState.current = newSelectedState;
} catch (err) {
// we ignore all errors here, since when the component
// is re-rendered, the selectors are called again, and
// will throw again, if neither props nor store state
// changed
latestSubscriptionCallbackError.current = err;
}
forceRender({});
}
subscription.onStateChange = checkForUpdates;
subscription.trySubscribe();
checkForUpdates();
return function () {
return subscription.tryUnsubscribe();
};
}, [store, subscription]);
return selectedState;
}

23
node_modules/react-redux/es/hooks/useStore.js generated vendored Normal file
View File

@@ -0,0 +1,23 @@
import { useReduxContext } from './useReduxContext';
/**
* A hook to access the redux store.
*
* @returns {any} the redux store
*
* @example
*
* import React from 'react'
* import { useStore } from 'react-redux'
*
* export const ExampleComponent = () => {
* const store = useStore()
* return <div>{store.getState()}</div>
* }
*/
export function useStore() {
var _useReduxContext = useReduxContext(),
store = _useReduxContext.store;
return store;
}