code
stringlengths 24
2.07M
| docstring
stringlengths 25
85.3k
| func_name
stringlengths 1
92
| language
stringclasses 1
value | repo
stringlengths 5
64
| path
stringlengths 4
172
| url
stringlengths 44
218
| license
stringclasses 7
values |
---|---|---|---|---|---|---|---|
function useRef(initialValue) {
var dispatcher = resolveDispatcher();
return dispatcher.useRef(initialValue);
}
|
Returns the first child in a collection of children and verifies that there
is only one child in the collection.
See https://reactjs.org/docs/react-api.html#reactchildrenonly
The current implementation of this function assumes that a single child gets
passed without a wrapper, but the purpose of this helper function is to
abstract away the particular structure of children.
@param {?object} children Child collection structure.
@return {ReactElement} The first and only `ReactElement` contained in the
structure.
|
useRef
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-v18.dev.js
|
MIT
|
function useEffect(create, deps) {
var dispatcher = resolveDispatcher();
return dispatcher.useEffect(create, deps);
}
|
Returns the first child in a collection of children and verifies that there
is only one child in the collection.
See https://reactjs.org/docs/react-api.html#reactchildrenonly
The current implementation of this function assumes that a single child gets
passed without a wrapper, but the purpose of this helper function is to
abstract away the particular structure of children.
@param {?object} children Child collection structure.
@return {ReactElement} The first and only `ReactElement` contained in the
structure.
|
useEffect
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-v18.dev.js
|
MIT
|
function useInsertionEffect(create, deps) {
var dispatcher = resolveDispatcher();
return dispatcher.useInsertionEffect(create, deps);
}
|
Returns the first child in a collection of children and verifies that there
is only one child in the collection.
See https://reactjs.org/docs/react-api.html#reactchildrenonly
The current implementation of this function assumes that a single child gets
passed without a wrapper, but the purpose of this helper function is to
abstract away the particular structure of children.
@param {?object} children Child collection structure.
@return {ReactElement} The first and only `ReactElement` contained in the
structure.
|
useInsertionEffect
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-v18.dev.js
|
MIT
|
function useLayoutEffect(create, deps) {
var dispatcher = resolveDispatcher();
return dispatcher.useLayoutEffect(create, deps);
}
|
Returns the first child in a collection of children and verifies that there
is only one child in the collection.
See https://reactjs.org/docs/react-api.html#reactchildrenonly
The current implementation of this function assumes that a single child gets
passed without a wrapper, but the purpose of this helper function is to
abstract away the particular structure of children.
@param {?object} children Child collection structure.
@return {ReactElement} The first and only `ReactElement` contained in the
structure.
|
useLayoutEffect
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-v18.dev.js
|
MIT
|
function useCallback(callback, deps) {
var dispatcher = resolveDispatcher();
return dispatcher.useCallback(callback, deps);
}
|
Returns the first child in a collection of children and verifies that there
is only one child in the collection.
See https://reactjs.org/docs/react-api.html#reactchildrenonly
The current implementation of this function assumes that a single child gets
passed without a wrapper, but the purpose of this helper function is to
abstract away the particular structure of children.
@param {?object} children Child collection structure.
@return {ReactElement} The first and only `ReactElement` contained in the
structure.
|
useCallback
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-v18.dev.js
|
MIT
|
function useMemo(create, deps) {
var dispatcher = resolveDispatcher();
return dispatcher.useMemo(create, deps);
}
|
Returns the first child in a collection of children and verifies that there
is only one child in the collection.
See https://reactjs.org/docs/react-api.html#reactchildrenonly
The current implementation of this function assumes that a single child gets
passed without a wrapper, but the purpose of this helper function is to
abstract away the particular structure of children.
@param {?object} children Child collection structure.
@return {ReactElement} The first and only `ReactElement` contained in the
structure.
|
useMemo
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-v18.dev.js
|
MIT
|
function useImperativeHandle(ref, create, deps) {
var dispatcher = resolveDispatcher();
return dispatcher.useImperativeHandle(ref, create, deps);
}
|
Returns the first child in a collection of children and verifies that there
is only one child in the collection.
See https://reactjs.org/docs/react-api.html#reactchildrenonly
The current implementation of this function assumes that a single child gets
passed without a wrapper, but the purpose of this helper function is to
abstract away the particular structure of children.
@param {?object} children Child collection structure.
@return {ReactElement} The first and only `ReactElement` contained in the
structure.
|
useImperativeHandle
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-v18.dev.js
|
MIT
|
function useDebugValue(value, formatterFn) {
{
var dispatcher = resolveDispatcher();
return dispatcher.useDebugValue(value, formatterFn);
}
}
|
Returns the first child in a collection of children and verifies that there
is only one child in the collection.
See https://reactjs.org/docs/react-api.html#reactchildrenonly
The current implementation of this function assumes that a single child gets
passed without a wrapper, but the purpose of this helper function is to
abstract away the particular structure of children.
@param {?object} children Child collection structure.
@return {ReactElement} The first and only `ReactElement` contained in the
structure.
|
useDebugValue
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-v18.dev.js
|
MIT
|
function useTransition() {
var dispatcher = resolveDispatcher();
return dispatcher.useTransition();
}
|
Returns the first child in a collection of children and verifies that there
is only one child in the collection.
See https://reactjs.org/docs/react-api.html#reactchildrenonly
The current implementation of this function assumes that a single child gets
passed without a wrapper, but the purpose of this helper function is to
abstract away the particular structure of children.
@param {?object} children Child collection structure.
@return {ReactElement} The first and only `ReactElement` contained in the
structure.
|
useTransition
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-v18.dev.js
|
MIT
|
function useDeferredValue(value) {
var dispatcher = resolveDispatcher();
return dispatcher.useDeferredValue(value);
}
|
Returns the first child in a collection of children and verifies that there
is only one child in the collection.
See https://reactjs.org/docs/react-api.html#reactchildrenonly
The current implementation of this function assumes that a single child gets
passed without a wrapper, but the purpose of this helper function is to
abstract away the particular structure of children.
@param {?object} children Child collection structure.
@return {ReactElement} The first and only `ReactElement` contained in the
structure.
|
useDeferredValue
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-v18.dev.js
|
MIT
|
function useId() {
var dispatcher = resolveDispatcher();
return dispatcher.useId();
}
|
Returns the first child in a collection of children and verifies that there
is only one child in the collection.
See https://reactjs.org/docs/react-api.html#reactchildrenonly
The current implementation of this function assumes that a single child gets
passed without a wrapper, but the purpose of this helper function is to
abstract away the particular structure of children.
@param {?object} children Child collection structure.
@return {ReactElement} The first and only `ReactElement` contained in the
structure.
|
useId
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-v18.dev.js
|
MIT
|
function useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) {
var dispatcher = resolveDispatcher();
return dispatcher.useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
}
|
Returns the first child in a collection of children and verifies that there
is only one child in the collection.
See https://reactjs.org/docs/react-api.html#reactchildrenonly
The current implementation of this function assumes that a single child gets
passed without a wrapper, but the purpose of this helper function is to
abstract away the particular structure of children.
@param {?object} children Child collection structure.
@return {ReactElement} The first and only `ReactElement` contained in the
structure.
|
useSyncExternalStore
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-v18.dev.js
|
MIT
|
function disableLogs() {
{
if (disabledDepth === 0) {
/* eslint-disable react-internal/no-production-logging */
prevLog = console.log;
prevInfo = console.info;
prevWarn = console.warn;
prevError = console.error;
prevGroup = console.group;
prevGroupCollapsed = console.groupCollapsed;
prevGroupEnd = console.groupEnd; // https://github.com/facebook/react/issues/19099
var props = {
configurable: true,
enumerable: true,
value: disabledLog,
writable: true
}; // $FlowFixMe Flow thinks console is immutable.
Object.defineProperties(console, {
info: props,
log: props,
warn: props,
error: props,
group: props,
groupCollapsed: props,
groupEnd: props
});
/* eslint-enable react-internal/no-production-logging */
}
disabledDepth++;
}
}
|
Returns the first child in a collection of children and verifies that there
is only one child in the collection.
See https://reactjs.org/docs/react-api.html#reactchildrenonly
The current implementation of this function assumes that a single child gets
passed without a wrapper, but the purpose of this helper function is to
abstract away the particular structure of children.
@param {?object} children Child collection structure.
@return {ReactElement} The first and only `ReactElement` contained in the
structure.
|
disableLogs
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-v18.dev.js
|
MIT
|
function reenableLogs() {
{
disabledDepth--;
if (disabledDepth === 0) {
/* eslint-disable react-internal/no-production-logging */
var props = {
configurable: true,
enumerable: true,
writable: true
}; // $FlowFixMe Flow thinks console is immutable.
Object.defineProperties(console, {
log: assign({}, props, {
value: prevLog
}),
info: assign({}, props, {
value: prevInfo
}),
warn: assign({}, props, {
value: prevWarn
}),
error: assign({}, props, {
value: prevError
}),
group: assign({}, props, {
value: prevGroup
}),
groupCollapsed: assign({}, props, {
value: prevGroupCollapsed
}),
groupEnd: assign({}, props, {
value: prevGroupEnd
})
});
/* eslint-enable react-internal/no-production-logging */
}
if (disabledDepth < 0) {
error('disabledDepth fell below zero. ' + 'This is a bug in React. Please file an issue.');
}
}
}
|
Returns the first child in a collection of children and verifies that there
is only one child in the collection.
See https://reactjs.org/docs/react-api.html#reactchildrenonly
The current implementation of this function assumes that a single child gets
passed without a wrapper, but the purpose of this helper function is to
abstract away the particular structure of children.
@param {?object} children Child collection structure.
@return {ReactElement} The first and only `ReactElement` contained in the
structure.
|
reenableLogs
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-v18.dev.js
|
MIT
|
function describeBuiltInComponentFrame(name, source, ownerFn) {
{
if (prefix === undefined) {
// Extract the VM specific prefix used by each line.
try {
throw Error();
} catch (x) {
var match = x.stack.trim().match(/\n( *(at )?)/);
prefix = match && match[1] || '';
}
} // We use the prefix to ensure our stacks line up with native stack frames.
return '\n' + prefix + name;
}
}
|
Returns the first child in a collection of children and verifies that there
is only one child in the collection.
See https://reactjs.org/docs/react-api.html#reactchildrenonly
The current implementation of this function assumes that a single child gets
passed without a wrapper, but the purpose of this helper function is to
abstract away the particular structure of children.
@param {?object} children Child collection structure.
@return {ReactElement} The first and only `ReactElement` contained in the
structure.
|
describeBuiltInComponentFrame
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-v18.dev.js
|
MIT
|
function describeNativeComponentFrame(fn, construct) {
// If something asked for a stack inside a fake render, it should get ignored.
if ( !fn || reentry) {
return '';
}
{
var frame = componentFrameCache.get(fn);
if (frame !== undefined) {
return frame;
}
}
var control;
reentry = true;
var previousPrepareStackTrace = Error.prepareStackTrace; // $FlowFixMe It does accept undefined.
Error.prepareStackTrace = undefined;
var previousDispatcher;
{
previousDispatcher = ReactCurrentDispatcher$1.current; // Set the dispatcher in DEV because this might be call in the render function
// for warnings.
ReactCurrentDispatcher$1.current = null;
disableLogs();
}
try {
// This should throw.
if (construct) {
// Something should be setting the props in the constructor.
var Fake = function () {
throw Error();
}; // $FlowFixMe
Object.defineProperty(Fake.prototype, 'props', {
set: function () {
// We use a throwing setter instead of frozen or non-writable props
// because that won't throw in a non-strict mode function.
throw Error();
}
});
if (typeof Reflect === 'object' && Reflect.construct) {
// We construct a different control for this case to include any extra
// frames added by the construct call.
try {
Reflect.construct(Fake, []);
} catch (x) {
control = x;
}
Reflect.construct(fn, [], Fake);
} else {
try {
Fake.call();
} catch (x) {
control = x;
}
fn.call(Fake.prototype);
}
} else {
try {
throw Error();
} catch (x) {
control = x;
}
fn();
}
} catch (sample) {
// This is inlined manually because closure doesn't do it for us.
if (sample && control && typeof sample.stack === 'string') {
// This extracts the first frame from the sample that isn't also in the control.
// Skipping one frame that we assume is the frame that calls the two.
var sampleLines = sample.stack.split('\n');
var controlLines = control.stack.split('\n');
var s = sampleLines.length - 1;
var c = controlLines.length - 1;
while (s >= 1 && c >= 0 && sampleLines[s] !== controlLines[c]) {
// We expect at least one stack frame to be shared.
// Typically this will be the root most one. However, stack frames may be
// cut off due to maximum stack limits. In this case, one maybe cut off
// earlier than the other. We assume that the sample is longer or the same
// and there for cut off earlier. So we should find the root most frame in
// the sample somewhere in the control.
c--;
}
for (; s >= 1 && c >= 0; s--, c--) {
// Next we find the first one that isn't the same which should be the
// frame that called our sample function and the control.
if (sampleLines[s] !== controlLines[c]) {
// In V8, the first line is describing the message but other VMs don't.
// If we're about to return the first line, and the control is also on the same
// line, that's a pretty good indicator that our sample threw at same line as
// the control. I.e. before we entered the sample frame. So we ignore this result.
// This can happen if you passed a class to function component, or non-function.
if (s !== 1 || c !== 1) {
do {
s--;
c--; // We may still have similar intermediate frames from the construct call.
// The next one that isn't the same should be our match though.
if (c < 0 || sampleLines[s] !== controlLines[c]) {
// V8 adds a "new" prefix for native classes. Let's remove it to make it prettier.
var _frame = '\n' + sampleLines[s].replace(' at new ', ' at '); // If our component frame is labeled "<anonymous>"
// but we have a user-provided "displayName"
// splice it in to make the stack more readable.
if (fn.displayName && _frame.includes('<anonymous>')) {
_frame = _frame.replace('<anonymous>', fn.displayName);
}
{
if (typeof fn === 'function') {
componentFrameCache.set(fn, _frame);
}
} // Return the line we found.
return _frame;
}
} while (s >= 1 && c >= 0);
}
break;
}
}
}
} finally {
reentry = false;
{
ReactCurrentDispatcher$1.current = previousDispatcher;
reenableLogs();
}
Error.prepareStackTrace = previousPrepareStackTrace;
} // Fallback to just using the name if we couldn't make it throw.
var name = fn ? fn.displayName || fn.name : '';
var syntheticFrame = name ? describeBuiltInComponentFrame(name) : '';
{
if (typeof fn === 'function') {
componentFrameCache.set(fn, syntheticFrame);
}
}
return syntheticFrame;
}
|
Returns the first child in a collection of children and verifies that there
is only one child in the collection.
See https://reactjs.org/docs/react-api.html#reactchildrenonly
The current implementation of this function assumes that a single child gets
passed without a wrapper, but the purpose of this helper function is to
abstract away the particular structure of children.
@param {?object} children Child collection structure.
@return {ReactElement} The first and only `ReactElement` contained in the
structure.
|
describeNativeComponentFrame
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-v18.dev.js
|
MIT
|
Fake = function () {
throw Error();
}
|
Returns the first child in a collection of children and verifies that there
is only one child in the collection.
See https://reactjs.org/docs/react-api.html#reactchildrenonly
The current implementation of this function assumes that a single child gets
passed without a wrapper, but the purpose of this helper function is to
abstract away the particular structure of children.
@param {?object} children Child collection structure.
@return {ReactElement} The first and only `ReactElement` contained in the
structure.
|
Fake
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-v18.dev.js
|
MIT
|
function describeFunctionComponentFrame(fn, source, ownerFn) {
{
return describeNativeComponentFrame(fn, false);
}
}
|
Returns the first child in a collection of children and verifies that there
is only one child in the collection.
See https://reactjs.org/docs/react-api.html#reactchildrenonly
The current implementation of this function assumes that a single child gets
passed without a wrapper, but the purpose of this helper function is to
abstract away the particular structure of children.
@param {?object} children Child collection structure.
@return {ReactElement} The first and only `ReactElement` contained in the
structure.
|
describeFunctionComponentFrame
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-v18.dev.js
|
MIT
|
function shouldConstruct(Component) {
var prototype = Component.prototype;
return !!(prototype && prototype.isReactComponent);
}
|
Returns the first child in a collection of children and verifies that there
is only one child in the collection.
See https://reactjs.org/docs/react-api.html#reactchildrenonly
The current implementation of this function assumes that a single child gets
passed without a wrapper, but the purpose of this helper function is to
abstract away the particular structure of children.
@param {?object} children Child collection structure.
@return {ReactElement} The first and only `ReactElement` contained in the
structure.
|
shouldConstruct
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-v18.dev.js
|
MIT
|
function describeUnknownElementTypeFrameInDEV(type, source, ownerFn) {
if (type == null) {
return '';
}
if (typeof type === 'function') {
{
return describeNativeComponentFrame(type, shouldConstruct(type));
}
}
if (typeof type === 'string') {
return describeBuiltInComponentFrame(type);
}
switch (type) {
case REACT_SUSPENSE_TYPE:
return describeBuiltInComponentFrame('Suspense');
case REACT_SUSPENSE_LIST_TYPE:
return describeBuiltInComponentFrame('SuspenseList');
}
if (typeof type === 'object') {
switch (type.$$typeof) {
case REACT_FORWARD_REF_TYPE:
return describeFunctionComponentFrame(type.render);
case REACT_MEMO_TYPE:
// Memo may contain any component type so we recursively resolve it.
return describeUnknownElementTypeFrameInDEV(type.type, source, ownerFn);
case REACT_LAZY_TYPE:
{
var lazyComponent = type;
var payload = lazyComponent._payload;
var init = lazyComponent._init;
try {
// Lazy may contain any component type so we recursively resolve it.
return describeUnknownElementTypeFrameInDEV(init(payload), source, ownerFn);
} catch (x) {}
}
}
}
return '';
}
|
Returns the first child in a collection of children and verifies that there
is only one child in the collection.
See https://reactjs.org/docs/react-api.html#reactchildrenonly
The current implementation of this function assumes that a single child gets
passed without a wrapper, but the purpose of this helper function is to
abstract away the particular structure of children.
@param {?object} children Child collection structure.
@return {ReactElement} The first and only `ReactElement` contained in the
structure.
|
describeUnknownElementTypeFrameInDEV
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-v18.dev.js
|
MIT
|
function setCurrentlyValidatingElement(element) {
{
if (element) {
var owner = element._owner;
var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null);
ReactDebugCurrentFrame$1.setExtraStackFrame(stack);
} else {
ReactDebugCurrentFrame$1.setExtraStackFrame(null);
}
}
}
|
Returns the first child in a collection of children and verifies that there
is only one child in the collection.
See https://reactjs.org/docs/react-api.html#reactchildrenonly
The current implementation of this function assumes that a single child gets
passed without a wrapper, but the purpose of this helper function is to
abstract away the particular structure of children.
@param {?object} children Child collection structure.
@return {ReactElement} The first and only `ReactElement` contained in the
structure.
|
setCurrentlyValidatingElement
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-v18.dev.js
|
MIT
|
function checkPropTypes(typeSpecs, values, location, componentName, element) {
{
// $FlowFixMe This is okay but Flow doesn't know it.
var has = Function.call.bind(hasOwnProperty);
for (var typeSpecName in typeSpecs) {
if (has(typeSpecs, typeSpecName)) {
var error$1 = void 0; // Prop type validation may throw. In case they do, we don't want to
// fail the render phase where it didn't fail before. So we log it.
// After these have been cleaned up, we'll let them throw.
try {
// This is intentionally an invariant that gets caught. It's the same
// behavior as without this statement except with a better message.
if (typeof typeSpecs[typeSpecName] !== 'function') {
// eslint-disable-next-line react-internal/prod-error-codes
var err = Error((componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' + 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.' + 'This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.');
err.name = 'Invariant Violation';
throw err;
}
error$1 = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED');
} catch (ex) {
error$1 = ex;
}
if (error$1 && !(error$1 instanceof Error)) {
setCurrentlyValidatingElement(element);
error('%s: type specification of %s' + ' `%s` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a %s. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).', componentName || 'React class', location, typeSpecName, typeof error$1);
setCurrentlyValidatingElement(null);
}
if (error$1 instanceof Error && !(error$1.message in loggedTypeFailures)) {
// Only monitor this failure once because there tends to be a lot of the
// same error.
loggedTypeFailures[error$1.message] = true;
setCurrentlyValidatingElement(element);
error('Failed %s type: %s', location, error$1.message);
setCurrentlyValidatingElement(null);
}
}
}
}
}
|
Returns the first child in a collection of children and verifies that there
is only one child in the collection.
See https://reactjs.org/docs/react-api.html#reactchildrenonly
The current implementation of this function assumes that a single child gets
passed without a wrapper, but the purpose of this helper function is to
abstract away the particular structure of children.
@param {?object} children Child collection structure.
@return {ReactElement} The first and only `ReactElement` contained in the
structure.
|
checkPropTypes
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-v18.dev.js
|
MIT
|
function setCurrentlyValidatingElement$1(element) {
{
if (element) {
var owner = element._owner;
var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null);
setExtraStackFrame(stack);
} else {
setExtraStackFrame(null);
}
}
}
|
Returns the first child in a collection of children and verifies that there
is only one child in the collection.
See https://reactjs.org/docs/react-api.html#reactchildrenonly
The current implementation of this function assumes that a single child gets
passed without a wrapper, but the purpose of this helper function is to
abstract away the particular structure of children.
@param {?object} children Child collection structure.
@return {ReactElement} The first and only `ReactElement` contained in the
structure.
|
setCurrentlyValidatingElement$1
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-v18.dev.js
|
MIT
|
function getDeclarationErrorAddendum() {
if (ReactCurrentOwner.current) {
var name = getComponentNameFromType(ReactCurrentOwner.current.type);
if (name) {
return '\n\nCheck the render method of `' + name + '`.';
}
}
return '';
}
|
Returns the first child in a collection of children and verifies that there
is only one child in the collection.
See https://reactjs.org/docs/react-api.html#reactchildrenonly
The current implementation of this function assumes that a single child gets
passed without a wrapper, but the purpose of this helper function is to
abstract away the particular structure of children.
@param {?object} children Child collection structure.
@return {ReactElement} The first and only `ReactElement` contained in the
structure.
|
getDeclarationErrorAddendum
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-v18.dev.js
|
MIT
|
function getSourceInfoErrorAddendum(source) {
if (source !== undefined) {
var fileName = source.fileName.replace(/^.*[\\\/]/, '');
var lineNumber = source.lineNumber;
return '\n\nCheck your code at ' + fileName + ':' + lineNumber + '.';
}
return '';
}
|
Returns the first child in a collection of children and verifies that there
is only one child in the collection.
See https://reactjs.org/docs/react-api.html#reactchildrenonly
The current implementation of this function assumes that a single child gets
passed without a wrapper, but the purpose of this helper function is to
abstract away the particular structure of children.
@param {?object} children Child collection structure.
@return {ReactElement} The first and only `ReactElement` contained in the
structure.
|
getSourceInfoErrorAddendum
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-v18.dev.js
|
MIT
|
function getSourceInfoErrorAddendumForProps(elementProps) {
if (elementProps !== null && elementProps !== undefined) {
return getSourceInfoErrorAddendum(elementProps.__source);
}
return '';
}
|
Returns the first child in a collection of children and verifies that there
is only one child in the collection.
See https://reactjs.org/docs/react-api.html#reactchildrenonly
The current implementation of this function assumes that a single child gets
passed without a wrapper, but the purpose of this helper function is to
abstract away the particular structure of children.
@param {?object} children Child collection structure.
@return {ReactElement} The first and only `ReactElement` contained in the
structure.
|
getSourceInfoErrorAddendumForProps
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-v18.dev.js
|
MIT
|
function getCurrentComponentErrorInfo(parentType) {
var info = getDeclarationErrorAddendum();
if (!info) {
var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name;
if (parentName) {
info = "\n\nCheck the top-level render call using <" + parentName + ">.";
}
}
return info;
}
|
Warn if there's no key explicitly set on dynamic arrays of children or
object keys are not valid. This allows us to keep track of children between
updates.
|
getCurrentComponentErrorInfo
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-v18.dev.js
|
MIT
|
function validateExplicitKey(element, parentType) {
if (!element._store || element._store.validated || element.key != null) {
return;
}
element._store.validated = true;
var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType);
if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {
return;
}
ownerHasKeyUseWarning[currentComponentErrorInfo] = true; // Usually the current owner is the offender, but if it accepts children as a
// property, it may be the creator of the child that's responsible for
// assigning it a key.
var childOwner = '';
if (element && element._owner && element._owner !== ReactCurrentOwner.current) {
// Give the component that originally created this child.
childOwner = " It was passed a child from " + getComponentNameFromType(element._owner.type) + ".";
}
{
setCurrentlyValidatingElement$1(element);
error('Each child in a list should have a unique "key" prop.' + '%s%s See https://reactjs.org/link/warning-keys for more information.', currentComponentErrorInfo, childOwner);
setCurrentlyValidatingElement$1(null);
}
}
|
Warn if the element doesn't have an explicit key assigned to it.
This element is in an array. The array could grow and shrink or be
reordered. All children that haven't already been validated are required to
have a "key" property assigned to it. Error statuses are cached so a warning
will only be shown once.
@internal
@param {ReactElement} element Element that requires a key.
@param {*} parentType element's parent's type.
|
validateExplicitKey
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-v18.dev.js
|
MIT
|
function validateChildKeys(node, parentType) {
if (typeof node !== 'object') {
return;
}
if (isArray(node)) {
for (var i = 0; i < node.length; i++) {
var child = node[i];
if (isValidElement(child)) {
validateExplicitKey(child, parentType);
}
}
} else if (isValidElement(node)) {
// This element was passed in a valid location.
if (node._store) {
node._store.validated = true;
}
} else if (node) {
var iteratorFn = getIteratorFn(node);
if (typeof iteratorFn === 'function') {
// Entry iterators used to provide implicit keys,
// but now we print a separate warning for them later.
if (iteratorFn !== node.entries) {
var iterator = iteratorFn.call(node);
var step;
while (!(step = iterator.next()).done) {
if (isValidElement(step.value)) {
validateExplicitKey(step.value, parentType);
}
}
}
}
}
}
|
Ensure that every element either is passed in a static location, in an
array with an explicit keys property defined, or in an object literal
with valid key property.
@internal
@param {ReactNode} node Statically passed child of any type.
@param {*} parentType node's parent's type.
|
validateChildKeys
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-v18.dev.js
|
MIT
|
function validatePropTypes(element) {
{
var type = element.type;
if (type === null || type === undefined || typeof type === 'string') {
return;
}
var propTypes;
if (typeof type === 'function') {
propTypes = type.propTypes;
} else if (typeof type === 'object' && (type.$$typeof === REACT_FORWARD_REF_TYPE || // Note: Memo only checks outer props here.
// Inner props are checked in the reconciler.
type.$$typeof === REACT_MEMO_TYPE)) {
propTypes = type.propTypes;
} else {
return;
}
if (propTypes) {
// Intentionally inside to avoid triggering lazy initializers:
var name = getComponentNameFromType(type);
checkPropTypes(propTypes, element.props, 'prop', name, element);
} else if (type.PropTypes !== undefined && !propTypesMisspellWarningShown) {
propTypesMisspellWarningShown = true; // Intentionally inside to avoid triggering lazy initializers:
var _name = getComponentNameFromType(type);
error('Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?', _name || 'Unknown');
}
if (typeof type.getDefaultProps === 'function' && !type.getDefaultProps.isReactClassApproved) {
error('getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.');
}
}
}
|
Given an element, validate that its props follow the propTypes definition,
provided by the type.
@param {ReactElement} element
|
validatePropTypes
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-v18.dev.js
|
MIT
|
function validateFragmentProps(fragment) {
{
var keys = Object.keys(fragment.props);
for (var i = 0; i < keys.length; i++) {
var key = keys[i];
if (key !== 'children' && key !== 'key') {
setCurrentlyValidatingElement$1(fragment);
error('Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', key);
setCurrentlyValidatingElement$1(null);
break;
}
}
if (fragment.ref !== null) {
setCurrentlyValidatingElement$1(fragment);
error('Invalid attribute `ref` supplied to `React.Fragment`.');
setCurrentlyValidatingElement$1(null);
}
}
}
|
Given a fragment, validate that it can only be provided with fragment props
@param {ReactElement} fragment
|
validateFragmentProps
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-v18.dev.js
|
MIT
|
function createElementWithValidation(type, props, children) {
var validType = isValidElementType(type); // We warn in this case but don't throw. We expect the element creation to
// succeed and there will likely be errors in render.
if (!validType) {
var info = '';
if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) {
info += ' You likely forgot to export your component from the file ' + "it's defined in, or you might have mixed up default and named imports.";
}
var sourceInfo = getSourceInfoErrorAddendumForProps(props);
if (sourceInfo) {
info += sourceInfo;
} else {
info += getDeclarationErrorAddendum();
}
var typeString;
if (type === null) {
typeString = 'null';
} else if (isArray(type)) {
typeString = 'array';
} else if (type !== undefined && type.$$typeof === REACT_ELEMENT_TYPE) {
typeString = "<" + (getComponentNameFromType(type.type) || 'Unknown') + " />";
info = ' Did you accidentally export a JSX literal instead of a component?';
} else {
typeString = typeof type;
}
{
error('React.createElement: type is invalid -- expected a string (for ' + 'built-in components) or a class/function (for composite ' + 'components) but got: %s.%s', typeString, info);
}
}
var element = createElement.apply(this, arguments); // The result can be nullish if a mock or a custom function is used.
// TODO: Drop this when these are no longer allowed as the type argument.
if (element == null) {
return element;
} // Skip key warning if the type isn't valid since our key validation logic
// doesn't expect a non-string/function type and can throw confusing errors.
// We don't want exception behavior to differ between dev and prod.
// (Rendering will throw with a helpful message and as soon as the type is
// fixed, the key warnings will appear.)
if (validType) {
for (var i = 2; i < arguments.length; i++) {
validateChildKeys(arguments[i], type);
}
}
if (type === REACT_FRAGMENT_TYPE) {
validateFragmentProps(element);
} else {
validatePropTypes(element);
}
return element;
}
|
Given a fragment, validate that it can only be provided with fragment props
@param {ReactElement} fragment
|
createElementWithValidation
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-v18.dev.js
|
MIT
|
function createFactoryWithValidation(type) {
var validatedFactory = createElementWithValidation.bind(null, type);
validatedFactory.type = type;
{
if (!didWarnAboutDeprecatedCreateFactory) {
didWarnAboutDeprecatedCreateFactory = true;
warn('React.createFactory() is deprecated and will be removed in ' + 'a future major release. Consider using JSX ' + 'or use React.createElement() directly instead.');
} // Legacy hook: remove it
Object.defineProperty(validatedFactory, 'type', {
enumerable: false,
get: function () {
warn('Factory.type is deprecated. Access the class directly ' + 'before passing it to createFactory.');
Object.defineProperty(this, 'type', {
value: type
});
return type;
}
});
}
return validatedFactory;
}
|
Given a fragment, validate that it can only be provided with fragment props
@param {ReactElement} fragment
|
createFactoryWithValidation
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-v18.dev.js
|
MIT
|
function cloneElementWithValidation(element, props, children) {
var newElement = cloneElement.apply(this, arguments);
for (var i = 2; i < arguments.length; i++) {
validateChildKeys(arguments[i], newElement.type);
}
validatePropTypes(newElement);
return newElement;
}
|
Given a fragment, validate that it can only be provided with fragment props
@param {ReactElement} fragment
|
cloneElementWithValidation
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-v18.dev.js
|
MIT
|
function push(heap, node) {
var index = heap.length;
heap.push(node);
siftUp(heap, node, index);
}
|
Given a fragment, validate that it can only be provided with fragment props
@param {ReactElement} fragment
|
push
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-v18.dev.js
|
MIT
|
function peek(heap) {
return heap.length === 0 ? null : heap[0];
}
|
Given a fragment, validate that it can only be provided with fragment props
@param {ReactElement} fragment
|
peek
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-v18.dev.js
|
MIT
|
function pop(heap) {
if (heap.length === 0) {
return null;
}
var first = heap[0];
var last = heap.pop();
if (last !== first) {
heap[0] = last;
siftDown(heap, last, 0);
}
return first;
}
|
Given a fragment, validate that it can only be provided with fragment props
@param {ReactElement} fragment
|
pop
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-v18.dev.js
|
MIT
|
function siftUp(heap, node, i) {
var index = i;
while (index > 0) {
var parentIndex = index - 1 >>> 1;
var parent = heap[parentIndex];
if (compare(parent, node) > 0) {
// The parent is larger. Swap positions.
heap[parentIndex] = node;
heap[index] = parent;
index = parentIndex;
} else {
// The parent is smaller. Exit.
return;
}
}
}
|
Given a fragment, validate that it can only be provided with fragment props
@param {ReactElement} fragment
|
siftUp
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-v18.dev.js
|
MIT
|
function siftDown(heap, node, i) {
var index = i;
var length = heap.length;
var halfLength = length >>> 1;
while (index < halfLength) {
var leftIndex = (index + 1) * 2 - 1;
var left = heap[leftIndex];
var rightIndex = leftIndex + 1;
var right = heap[rightIndex]; // If the left or right node is smaller, swap with the smaller of those.
if (compare(left, node) < 0) {
if (rightIndex < length && compare(right, left) < 0) {
heap[index] = right;
heap[rightIndex] = node;
index = rightIndex;
} else {
heap[index] = left;
heap[leftIndex] = node;
index = leftIndex;
}
} else if (rightIndex < length && compare(right, node) < 0) {
heap[index] = right;
heap[rightIndex] = node;
index = rightIndex;
} else {
// Neither child is smaller. Exit.
return;
}
}
}
|
Given a fragment, validate that it can only be provided with fragment props
@param {ReactElement} fragment
|
siftDown
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-v18.dev.js
|
MIT
|
function compare(a, b) {
// Compare sort index first, then task id.
var diff = a.sortIndex - b.sortIndex;
return diff !== 0 ? diff : a.id - b.id;
}
|
Given a fragment, validate that it can only be provided with fragment props
@param {ReactElement} fragment
|
compare
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-v18.dev.js
|
MIT
|
function advanceTimers(currentTime) {
// Check for tasks that are no longer delayed and add them to the queue.
var timer = peek(timerQueue);
while (timer !== null) {
if (timer.callback === null) {
// Timer was cancelled.
pop(timerQueue);
} else if (timer.startTime <= currentTime) {
// Timer fired. Transfer to the task queue.
pop(timerQueue);
timer.sortIndex = timer.expirationTime;
push(taskQueue, timer);
} else {
// Remaining timers are pending.
return;
}
timer = peek(timerQueue);
}
}
|
Given a fragment, validate that it can only be provided with fragment props
@param {ReactElement} fragment
|
advanceTimers
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-v18.dev.js
|
MIT
|
function handleTimeout(currentTime) {
isHostTimeoutScheduled = false;
advanceTimers(currentTime);
if (!isHostCallbackScheduled) {
if (peek(taskQueue) !== null) {
isHostCallbackScheduled = true;
requestHostCallback(flushWork);
} else {
var firstTimer = peek(timerQueue);
if (firstTimer !== null) {
requestHostTimeout(handleTimeout, firstTimer.startTime - currentTime);
}
}
}
}
|
Given a fragment, validate that it can only be provided with fragment props
@param {ReactElement} fragment
|
handleTimeout
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-v18.dev.js
|
MIT
|
function flushWork(hasTimeRemaining, initialTime) {
isHostCallbackScheduled = false;
if (isHostTimeoutScheduled) {
// We scheduled a timeout but it's no longer needed. Cancel it.
isHostTimeoutScheduled = false;
cancelHostTimeout();
}
isPerformingWork = true;
var previousPriorityLevel = currentPriorityLevel;
try {
if (enableProfiling) {
try {
return workLoop(hasTimeRemaining, initialTime);
} catch (error) {
if (currentTask !== null) {
var currentTime = getCurrentTime();
markTaskErrored(currentTask, currentTime);
currentTask.isQueued = false;
}
throw error;
}
} else {
// No catch in prod code path.
return workLoop(hasTimeRemaining, initialTime);
}
} finally {
currentTask = null;
currentPriorityLevel = previousPriorityLevel;
isPerformingWork = false;
}
}
|
Given a fragment, validate that it can only be provided with fragment props
@param {ReactElement} fragment
|
flushWork
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-v18.dev.js
|
MIT
|
function workLoop(hasTimeRemaining, initialTime) {
var currentTime = initialTime;
advanceTimers(currentTime);
currentTask = peek(taskQueue);
while (currentTask !== null && !(enableSchedulerDebugging )) {
if (currentTask.expirationTime > currentTime && (!hasTimeRemaining || shouldYieldToHost())) {
// This currentTask hasn't expired, and we've reached the deadline.
break;
}
var callback = currentTask.callback;
if (typeof callback === 'function') {
currentTask.callback = null;
currentPriorityLevel = currentTask.priorityLevel;
var didUserCallbackTimeout = currentTask.expirationTime <= currentTime;
var continuationCallback = callback(didUserCallbackTimeout);
currentTime = getCurrentTime();
if (typeof continuationCallback === 'function') {
currentTask.callback = continuationCallback;
} else {
if (currentTask === peek(taskQueue)) {
pop(taskQueue);
}
}
advanceTimers(currentTime);
} else {
pop(taskQueue);
}
currentTask = peek(taskQueue);
} // Return whether there's additional work
if (currentTask !== null) {
return true;
} else {
var firstTimer = peek(timerQueue);
if (firstTimer !== null) {
requestHostTimeout(handleTimeout, firstTimer.startTime - currentTime);
}
return false;
}
}
|
Given a fragment, validate that it can only be provided with fragment props
@param {ReactElement} fragment
|
workLoop
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-v18.dev.js
|
MIT
|
function unstable_runWithPriority(priorityLevel, eventHandler) {
switch (priorityLevel) {
case ImmediatePriority:
case UserBlockingPriority:
case NormalPriority:
case LowPriority:
case IdlePriority:
break;
default:
priorityLevel = NormalPriority;
}
var previousPriorityLevel = currentPriorityLevel;
currentPriorityLevel = priorityLevel;
try {
return eventHandler();
} finally {
currentPriorityLevel = previousPriorityLevel;
}
}
|
Given a fragment, validate that it can only be provided with fragment props
@param {ReactElement} fragment
|
unstable_runWithPriority
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-v18.dev.js
|
MIT
|
function unstable_next(eventHandler) {
var priorityLevel;
switch (currentPriorityLevel) {
case ImmediatePriority:
case UserBlockingPriority:
case NormalPriority:
// Shift down to normal priority
priorityLevel = NormalPriority;
break;
default:
// Anything lower than normal priority should remain at the current level.
priorityLevel = currentPriorityLevel;
break;
}
var previousPriorityLevel = currentPriorityLevel;
currentPriorityLevel = priorityLevel;
try {
return eventHandler();
} finally {
currentPriorityLevel = previousPriorityLevel;
}
}
|
Given a fragment, validate that it can only be provided with fragment props
@param {ReactElement} fragment
|
unstable_next
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-v18.dev.js
|
MIT
|
function unstable_wrapCallback(callback) {
var parentPriorityLevel = currentPriorityLevel;
return function () {
// This is a fork of runWithPriority, inlined for performance.
var previousPriorityLevel = currentPriorityLevel;
currentPriorityLevel = parentPriorityLevel;
try {
return callback.apply(this, arguments);
} finally {
currentPriorityLevel = previousPriorityLevel;
}
};
}
|
Given a fragment, validate that it can only be provided with fragment props
@param {ReactElement} fragment
|
unstable_wrapCallback
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-v18.dev.js
|
MIT
|
function unstable_scheduleCallback(priorityLevel, callback, options) {
var currentTime = getCurrentTime();
var startTime;
if (typeof options === 'object' && options !== null) {
var delay = options.delay;
if (typeof delay === 'number' && delay > 0) {
startTime = currentTime + delay;
} else {
startTime = currentTime;
}
} else {
startTime = currentTime;
}
var timeout;
switch (priorityLevel) {
case ImmediatePriority:
timeout = IMMEDIATE_PRIORITY_TIMEOUT;
break;
case UserBlockingPriority:
timeout = USER_BLOCKING_PRIORITY_TIMEOUT;
break;
case IdlePriority:
timeout = IDLE_PRIORITY_TIMEOUT;
break;
case LowPriority:
timeout = LOW_PRIORITY_TIMEOUT;
break;
case NormalPriority:
default:
timeout = NORMAL_PRIORITY_TIMEOUT;
break;
}
var expirationTime = startTime + timeout;
var newTask = {
id: taskIdCounter++,
callback: callback,
priorityLevel: priorityLevel,
startTime: startTime,
expirationTime: expirationTime,
sortIndex: -1
};
if (startTime > currentTime) {
// This is a delayed task.
newTask.sortIndex = startTime;
push(timerQueue, newTask);
if (peek(taskQueue) === null && newTask === peek(timerQueue)) {
// All tasks are delayed, and this is the task with the earliest delay.
if (isHostTimeoutScheduled) {
// Cancel an existing timeout.
cancelHostTimeout();
} else {
isHostTimeoutScheduled = true;
} // Schedule a timeout.
requestHostTimeout(handleTimeout, startTime - currentTime);
}
} else {
newTask.sortIndex = expirationTime;
push(taskQueue, newTask);
// wait until the next time we yield.
if (!isHostCallbackScheduled && !isPerformingWork) {
isHostCallbackScheduled = true;
requestHostCallback(flushWork);
}
}
return newTask;
}
|
Given a fragment, validate that it can only be provided with fragment props
@param {ReactElement} fragment
|
unstable_scheduleCallback
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-v18.dev.js
|
MIT
|
function unstable_continueExecution() {
if (!isHostCallbackScheduled && !isPerformingWork) {
isHostCallbackScheduled = true;
requestHostCallback(flushWork);
}
}
|
Given a fragment, validate that it can only be provided with fragment props
@param {ReactElement} fragment
|
unstable_continueExecution
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-v18.dev.js
|
MIT
|
function unstable_getFirstCallbackNode() {
return peek(taskQueue);
}
|
Given a fragment, validate that it can only be provided with fragment props
@param {ReactElement} fragment
|
unstable_getFirstCallbackNode
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-v18.dev.js
|
MIT
|
function unstable_cancelCallback(task) {
// remove from the queue because you can't remove arbitrary nodes from an
// array based heap, only the first one.)
task.callback = null;
}
|
Given a fragment, validate that it can only be provided with fragment props
@param {ReactElement} fragment
|
unstable_cancelCallback
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-v18.dev.js
|
MIT
|
function unstable_getCurrentPriorityLevel() {
return currentPriorityLevel;
}
|
Given a fragment, validate that it can only be provided with fragment props
@param {ReactElement} fragment
|
unstable_getCurrentPriorityLevel
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-v18.dev.js
|
MIT
|
function shouldYieldToHost() {
var timeElapsed = getCurrentTime() - startTime;
if (timeElapsed < frameInterval) {
// The main thread has only been blocked for a really short amount of time;
// smaller than a single frame. Don't yield yet.
return false;
} // The main thread has been blocked for a non-negligible amount of time. We
return true;
}
|
Given a fragment, validate that it can only be provided with fragment props
@param {ReactElement} fragment
|
shouldYieldToHost
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-v18.dev.js
|
MIT
|
function forceFrameRate(fps) {
if (fps < 0 || fps > 125) {
// Using console['error'] to evade Babel and ESLint
console['error']('forceFrameRate takes a positive int between 0 and 125, ' + 'forcing frame rates higher than 125 fps is not supported');
return;
}
if (fps > 0) {
frameInterval = Math.floor(1000 / fps);
} else {
// reset the framerate
frameInterval = frameYieldMs;
}
}
|
Given a fragment, validate that it can only be provided with fragment props
@param {ReactElement} fragment
|
forceFrameRate
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-v18.dev.js
|
MIT
|
performWorkUntilDeadline = function () {
if (scheduledHostCallback !== null) {
var currentTime = getCurrentTime(); // Keep track of the start time so we can measure how long the main thread
// has been blocked.
startTime = currentTime;
var hasTimeRemaining = true; // If a scheduler task throws, exit the current browser task so the
// error can be observed.
//
// Intentionally not using a try-catch, since that makes some debugging
// techniques harder. Instead, if `scheduledHostCallback` errors, then
// `hasMoreWork` will remain true, and we'll continue the work loop.
var hasMoreWork = true;
try {
hasMoreWork = scheduledHostCallback(hasTimeRemaining, currentTime);
} finally {
if (hasMoreWork) {
// If there's more work, schedule the next message event at the end
// of the preceding one.
schedulePerformWorkUntilDeadline();
} else {
isMessageLoopRunning = false;
scheduledHostCallback = null;
}
}
} else {
isMessageLoopRunning = false;
} // Yielding to the browser will give it a chance to paint, so we can
}
|
Given a fragment, validate that it can only be provided with fragment props
@param {ReactElement} fragment
|
performWorkUntilDeadline
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-v18.dev.js
|
MIT
|
function requestHostCallback(callback) {
scheduledHostCallback = callback;
if (!isMessageLoopRunning) {
isMessageLoopRunning = true;
schedulePerformWorkUntilDeadline();
}
}
|
Given a fragment, validate that it can only be provided with fragment props
@param {ReactElement} fragment
|
requestHostCallback
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-v18.dev.js
|
MIT
|
function requestHostTimeout(callback, ms) {
taskTimeoutID = localSetTimeout(function () {
callback(getCurrentTime());
}, ms);
}
|
Given a fragment, validate that it can only be provided with fragment props
@param {ReactElement} fragment
|
requestHostTimeout
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-v18.dev.js
|
MIT
|
function cancelHostTimeout() {
localClearTimeout(taskTimeoutID);
taskTimeoutID = -1;
}
|
Given a fragment, validate that it can only be provided with fragment props
@param {ReactElement} fragment
|
cancelHostTimeout
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-v18.dev.js
|
MIT
|
function startTransition(scope, options) {
var prevTransition = ReactCurrentBatchConfig.transition;
ReactCurrentBatchConfig.transition = {};
var currentTransition = ReactCurrentBatchConfig.transition;
{
ReactCurrentBatchConfig.transition._updatedFibers = new Set();
}
try {
scope();
} finally {
ReactCurrentBatchConfig.transition = prevTransition;
{
if (prevTransition === null && currentTransition._updatedFibers) {
var updatedFibersCount = currentTransition._updatedFibers.size;
if (updatedFibersCount > 10) {
warn('Detected a large number of updates inside startTransition. ' + 'If this is due to a subscription please re-write it to use React provided hooks. ' + 'Otherwise concurrent mode guarantees are off the table.');
}
currentTransition._updatedFibers.clear();
}
}
}
}
|
Given a fragment, validate that it can only be provided with fragment props
@param {ReactElement} fragment
|
startTransition
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-v18.dev.js
|
MIT
|
function enqueueTask(task) {
if (enqueueTaskImpl === null) {
try {
// read require off the module object to get around the bundlers.
// we don't want them to detect a require and bundle a Node polyfill.
var requireString = ('require' + Math.random()).slice(0, 7);
var nodeRequire = module && module[requireString]; // assuming we're in node, let's try to get node's
// version of setImmediate, bypassing fake timers if any.
enqueueTaskImpl = nodeRequire.call(module, 'timers').setImmediate;
} catch (_err) {
// we're in a browser
// we can't use regular timers because they may still be faked
// so we try MessageChannel+postMessage instead
enqueueTaskImpl = function (callback) {
{
if (didWarnAboutMessageChannel === false) {
didWarnAboutMessageChannel = true;
if (typeof MessageChannel === 'undefined') {
error('This browser does not have a MessageChannel implementation, ' + 'so enqueuing tasks via await act(async () => ...) will fail. ' + 'Please file an issue at https://github.com/facebook/react/issues ' + 'if you encounter this warning.');
}
}
}
var channel = new MessageChannel();
channel.port1.onmessage = callback;
channel.port2.postMessage(undefined);
};
}
}
return enqueueTaskImpl(task);
}
|
Given a fragment, validate that it can only be provided with fragment props
@param {ReactElement} fragment
|
enqueueTask
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-v18.dev.js
|
MIT
|
function act(callback) {
{
// `act` calls can be nested, so we track the depth. This represents the
// number of `act` scopes on the stack.
var prevActScopeDepth = actScopeDepth;
actScopeDepth++;
if (ReactCurrentActQueue.current === null) {
// This is the outermost `act` scope. Initialize the queue. The reconciler
// will detect the queue and use it instead of Scheduler.
ReactCurrentActQueue.current = [];
}
var prevIsBatchingLegacy = ReactCurrentActQueue.isBatchingLegacy;
var result;
try {
// Used to reproduce behavior of `batchedUpdates` in legacy mode. Only
// set to `true` while the given callback is executed, not for updates
// triggered during an async event, because this is how the legacy
// implementation of `act` behaved.
ReactCurrentActQueue.isBatchingLegacy = true;
result = callback(); // Replicate behavior of original `act` implementation in legacy mode,
// which flushed updates immediately after the scope function exits, even
// if it's an async function.
if (!prevIsBatchingLegacy && ReactCurrentActQueue.didScheduleLegacyUpdate) {
var queue = ReactCurrentActQueue.current;
if (queue !== null) {
ReactCurrentActQueue.didScheduleLegacyUpdate = false;
flushActQueue(queue);
}
}
} catch (error) {
popActScope(prevActScopeDepth);
throw error;
} finally {
ReactCurrentActQueue.isBatchingLegacy = prevIsBatchingLegacy;
}
if (result !== null && typeof result === 'object' && typeof result.then === 'function') {
var thenableResult = result; // The callback is an async function (i.e. returned a promise). Wait
// for it to resolve before exiting the current scope.
var wasAwaited = false;
var thenable = {
then: function (resolve, reject) {
wasAwaited = true;
thenableResult.then(function (returnValue) {
popActScope(prevActScopeDepth);
if (actScopeDepth === 0) {
// We've exited the outermost act scope. Recursively flush the
// queue until there's no remaining work.
recursivelyFlushAsyncActWork(returnValue, resolve, reject);
} else {
resolve(returnValue);
}
}, function (error) {
// The callback threw an error.
popActScope(prevActScopeDepth);
reject(error);
});
}
};
{
if (!didWarnNoAwaitAct && typeof Promise !== 'undefined') {
// eslint-disable-next-line no-undef
Promise.resolve().then(function () {}).then(function () {
if (!wasAwaited) {
didWarnNoAwaitAct = true;
error('You called act(async () => ...) without await. ' + 'This could lead to unexpected testing behaviour, ' + 'interleaving multiple act calls and mixing their ' + 'scopes. ' + 'You should - await act(async () => ...);');
}
});
}
}
return thenable;
} else {
var returnValue = result; // The callback is not an async function. Exit the current scope
// immediately, without awaiting.
popActScope(prevActScopeDepth);
if (actScopeDepth === 0) {
// Exiting the outermost act scope. Flush the queue.
var _queue = ReactCurrentActQueue.current;
if (_queue !== null) {
flushActQueue(_queue);
ReactCurrentActQueue.current = null;
} // Return a thenable. If the user awaits it, we'll flush again in
// case additional work was scheduled by a microtask.
var _thenable = {
then: function (resolve, reject) {
// Confirm we haven't re-entered another `act` scope, in case
// the user does something weird like await the thenable
// multiple times.
if (ReactCurrentActQueue.current === null) {
// Recursively flush the queue until there's no remaining work.
ReactCurrentActQueue.current = [];
recursivelyFlushAsyncActWork(returnValue, resolve, reject);
} else {
resolve(returnValue);
}
}
};
return _thenable;
} else {
// Since we're inside a nested `act` scope, the returned thenable
// immediately resolves. The outer scope will flush the queue.
var _thenable2 = {
then: function (resolve, reject) {
resolve(returnValue);
}
};
return _thenable2;
}
}
}
}
|
Given a fragment, validate that it can only be provided with fragment props
@param {ReactElement} fragment
|
act
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-v18.dev.js
|
MIT
|
function popActScope(prevActScopeDepth) {
{
if (prevActScopeDepth !== actScopeDepth - 1) {
error('You seem to have overlapping act() calls, this is not supported. ' + 'Be sure to await previous act() calls before making a new one. ');
}
actScopeDepth = prevActScopeDepth;
}
}
|
Given a fragment, validate that it can only be provided with fragment props
@param {ReactElement} fragment
|
popActScope
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-v18.dev.js
|
MIT
|
function recursivelyFlushAsyncActWork(returnValue, resolve, reject) {
{
var queue = ReactCurrentActQueue.current;
if (queue !== null) {
try {
flushActQueue(queue);
enqueueTask(function () {
if (queue.length === 0) {
// No additional work was scheduled. Finish.
ReactCurrentActQueue.current = null;
resolve(returnValue);
} else {
// Keep flushing work until there's none left.
recursivelyFlushAsyncActWork(returnValue, resolve, reject);
}
});
} catch (error) {
reject(error);
}
} else {
resolve(returnValue);
}
}
}
|
Given a fragment, validate that it can only be provided with fragment props
@param {ReactElement} fragment
|
recursivelyFlushAsyncActWork
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-v18.dev.js
|
MIT
|
function flushActQueue(queue) {
{
if (!isFlushing) {
// Prevent re-entrance.
isFlushing = true;
var i = 0;
try {
for (; i < queue.length; i++) {
var callback = queue[i];
do {
callback = callback(true);
} while (callback !== null);
}
queue.length = 0;
} catch (error) {
// If something throws, leave the remaining callbacks on the queue.
queue = queue.slice(i + 1);
throw error;
} finally {
isFlushing = false;
}
}
}
}
|
Given a fragment, validate that it can only be provided with fragment props
@param {ReactElement} fragment
|
flushActQueue
|
javascript
|
facebook/memlab
|
packages/lens/src/tests/lib/react-v18.dev.js
|
https://github.com/facebook/memlab/blob/master/packages/lens/src/tests/lib/react-v18.dev.js
|
MIT
|
function initialise() {
if (window.innerWidth >= 996) {
createRenderer();
createScene();
createMesh();
createLights();
addEventListeners();
resize(container.offsetWidth, container.offsetHeight);
animate();
container.style.background = 'transparent';
}
}
|
@class SVG Renderer
@author Matthew Wagerfield
|
initialise
|
javascript
|
facebook/memlab
|
website/src/lib/ContainerAnimation.js
|
https://github.com/facebook/memlab/blob/master/website/src/lib/ContainerAnimation.js
|
MIT
|
function createRenderer() {
canvasRenderer = new FSS.CanvasRenderer();
setRenderer(RENDER.renderer);
}
|
@class SVG Renderer
@author Matthew Wagerfield
|
createRenderer
|
javascript
|
facebook/memlab
|
website/src/lib/ContainerAnimation.js
|
https://github.com/facebook/memlab/blob/master/website/src/lib/ContainerAnimation.js
|
MIT
|
function setRenderer(index) {
if (renderer) {
output.removeChild(renderer.element);
}
renderer = canvasRenderer;
renderer.setSize(container.offsetWidth, container.offsetHeight);
output.appendChild(renderer.element);
}
|
@class SVG Renderer
@author Matthew Wagerfield
|
setRenderer
|
javascript
|
facebook/memlab
|
website/src/lib/ContainerAnimation.js
|
https://github.com/facebook/memlab/blob/master/website/src/lib/ContainerAnimation.js
|
MIT
|
function createScene() {
scene = new FSS.Scene();
}
|
@class SVG Renderer
@author Matthew Wagerfield
|
createScene
|
javascript
|
facebook/memlab
|
website/src/lib/ContainerAnimation.js
|
https://github.com/facebook/memlab/blob/master/website/src/lib/ContainerAnimation.js
|
MIT
|
function createMesh() {
scene.remove(mesh);
renderer.clear();
geometry = new FSS.Plane(
MESH.width * renderer.width,
MESH.height * renderer.height,
MESH.segments,
MESH.slices,
);
material = new FSS.Material(MESH.ambient, MESH.diffuse);
mesh = new FSS.Mesh(geometry, material);
scene.add(mesh);
// Augment vertices for animation
let v, vertex;
for (v = geometry.vertices.length - 1; v >= 0; v--) {
vertex = geometry.vertices[v];
vertex.anchor = FSS.Vector3.clone(vertex.position);
vertex.step = FSS.Vector3.create(
Math.randomInRange(0.2, 1.0),
Math.randomInRange(0.2, 1.0),
Math.randomInRange(0.2, 1.0),
);
vertex.time = Math.randomInRange(0, Math.PIM2);
}
}
|
@class SVG Renderer
@author Matthew Wagerfield
|
createMesh
|
javascript
|
facebook/memlab
|
website/src/lib/ContainerAnimation.js
|
https://github.com/facebook/memlab/blob/master/website/src/lib/ContainerAnimation.js
|
MIT
|
function createLights() {
let l, light;
for (l = scene.lights.length - 1; l >= 0; l--) {
light = scene.lights[l];
scene.remove(light);
}
renderer.clear();
for (l = 0; l < LIGHT.count; l++) {
light = new FSS.Light(LIGHT.ambient, LIGHT.diffuse);
light.ambientHex = light.ambient.format();
light.diffuseHex = light.diffuse.format();
scene.add(light);
// Augment light for animation
light.mass = Math.randomInRange(0.5, 1);
light.velocity = FSS.Vector3.create();
light.acceleration = FSS.Vector3.create();
light.force = FSS.Vector3.create();
// Ring SVG Circle
light.ring = document.createElementNS(FSS.SVGNS, 'circle');
light.ring.setAttributeNS(null, 'stroke', light.ambientHex);
light.ring.setAttributeNS(null, 'stroke-width', '0.5');
light.ring.setAttributeNS(null, 'fill', 'none');
light.ring.setAttributeNS(null, 'r', '10');
// Core SVG Circle
light.core = document.createElementNS(FSS.SVGNS, 'circle');
light.core.setAttributeNS(null, 'fill', light.diffuseHex);
light.core.setAttributeNS(null, 'r', '4');
}
}
|
@class SVG Renderer
@author Matthew Wagerfield
|
createLights
|
javascript
|
facebook/memlab
|
website/src/lib/ContainerAnimation.js
|
https://github.com/facebook/memlab/blob/master/website/src/lib/ContainerAnimation.js
|
MIT
|
function resize(width, height) {
renderer.setSize(width, height);
FSS.Vector3.set(center, renderer.halfWidth, renderer.halfHeight);
createMesh();
}
|
@class SVG Renderer
@author Matthew Wagerfield
|
resize
|
javascript
|
facebook/memlab
|
website/src/lib/ContainerAnimation.js
|
https://github.com/facebook/memlab/blob/master/website/src/lib/ContainerAnimation.js
|
MIT
|
function animate() {
now = Date.now() - start;
update();
render();
setTimeout(() => requestAnimationFrame(animate), 160);
}
|
@class SVG Renderer
@author Matthew Wagerfield
|
animate
|
javascript
|
facebook/memlab
|
website/src/lib/ContainerAnimation.js
|
https://github.com/facebook/memlab/blob/master/website/src/lib/ContainerAnimation.js
|
MIT
|
function update() {
let ox,
oy,
oz,
l,
light,
v,
vertex,
offset = MESH.depth / 2;
// Update Bounds
FSS.Vector3.copy(LIGHT.bounds, center);
FSS.Vector3.multiplyScalar(LIGHT.bounds, LIGHT.xyScalar);
// Update Attractor
FSS.Vector3.setZ(attractor, LIGHT.zOffset);
// Overwrite the Attractor position
if (LIGHT.autopilot) {
ox = Math.sin(LIGHT.step[0] * now * LIGHT.speed);
oy = Math.cos(LIGHT.step[1] * now * LIGHT.speed);
FSS.Vector3.set(
attractor,
LIGHT.bounds[0] * ox,
LIGHT.bounds[1] * oy,
LIGHT.zOffset,
);
}
// Animate Lights
for (l = scene.lights.length - 1; l >= 0; l--) {
light = scene.lights[l];
// Reset the z position of the light
FSS.Vector3.setZ(light.position, LIGHT.zOffset);
// Calculate the force Luke!
const D = Math.clamp(
FSS.Vector3.distanceSquared(light.position, attractor),
LIGHT.minDistance,
LIGHT.maxDistance,
);
const F = (LIGHT.gravity * light.mass) / D;
FSS.Vector3.subtractVectors(light.force, attractor, light.position);
FSS.Vector3.normalise(light.force);
FSS.Vector3.multiplyScalar(light.force, F);
// Update the light position
FSS.Vector3.set(light.acceleration);
FSS.Vector3.add(light.acceleration, light.force);
FSS.Vector3.add(light.velocity, light.acceleration);
FSS.Vector3.multiplyScalar(light.velocity, LIGHT.dampening);
FSS.Vector3.limit(light.velocity, LIGHT.minLimit, LIGHT.maxLimit);
FSS.Vector3.add(light.position, light.velocity);
}
// Animate Vertices
for (v = geometry.vertices.length - 1; v >= 0; v--) {
vertex = geometry.vertices[v];
ox = Math.sin(vertex.time + vertex.step[0] * now * MESH.speed);
oy = Math.cos(vertex.time + vertex.step[1] * now * MESH.speed);
oz = Math.sin(vertex.time + vertex.step[2] * now * MESH.speed);
FSS.Vector3.set(
vertex.position,
MESH.xRange * geometry.segmentWidth * ox,
MESH.yRange * geometry.sliceHeight * oy,
MESH.zRange * offset * oz - offset,
);
FSS.Vector3.add(vertex.position, vertex.anchor);
}
// Set the Geometry to dirty
geometry.dirty = true;
}
|
@class SVG Renderer
@author Matthew Wagerfield
|
update
|
javascript
|
facebook/memlab
|
website/src/lib/ContainerAnimation.js
|
https://github.com/facebook/memlab/blob/master/website/src/lib/ContainerAnimation.js
|
MIT
|
function render() {
renderer.render(scene);
// Draw Lights
if (LIGHT.draw) {
let l, lx, ly, light;
for (l = scene.lights.length - 1; l >= 0; l--) {
light = scene.lights[l];
lx = light.position[0];
ly = light.position[1];
renderer.context.lineWidth = 0.5;
renderer.context.beginPath();
renderer.context.arc(lx, ly, 10, 0, Math.PIM2);
renderer.context.strokeStyle = light.ambientHex;
renderer.context.stroke();
renderer.context.beginPath();
renderer.context.arc(lx, ly, 4, 0, Math.PIM2);
renderer.context.fillStyle = light.diffuseHex;
renderer.context.fill();
}
}
}
|
@class SVG Renderer
@author Matthew Wagerfield
|
render
|
javascript
|
facebook/memlab
|
website/src/lib/ContainerAnimation.js
|
https://github.com/facebook/memlab/blob/master/website/src/lib/ContainerAnimation.js
|
MIT
|
function addEventListeners() {
window.addEventListener('resize', onWindowResize);
//container.addEventListener('mousemove', onMouseMove);
}
|
@class SVG Renderer
@author Matthew Wagerfield
|
addEventListeners
|
javascript
|
facebook/memlab
|
website/src/lib/ContainerAnimation.js
|
https://github.com/facebook/memlab/blob/master/website/src/lib/ContainerAnimation.js
|
MIT
|
function onMouseMove(event) {
FSS.Vector3.set(attractor, event.x, renderer.height - event.y);
FSS.Vector3.subtract(attractor, center);
}
|
@class SVG Renderer
@author Matthew Wagerfield
|
onMouseMove
|
javascript
|
facebook/memlab
|
website/src/lib/ContainerAnimation.js
|
https://github.com/facebook/memlab/blob/master/website/src/lib/ContainerAnimation.js
|
MIT
|
function onWindowResize(event) {
resize(container.offsetWidth, container.offsetHeight);
render();
}
|
@class SVG Renderer
@author Matthew Wagerfield
|
onWindowResize
|
javascript
|
facebook/memlab
|
website/src/lib/ContainerAnimation.js
|
https://github.com/facebook/memlab/blob/master/website/src/lib/ContainerAnimation.js
|
MIT
|
constructor(config) {
super();
const cwd = config.cwd;
const registry = config.registry;
const packageManager = config.use === undefined ?
USE_OPTIONS[0] :
config.use;
const updateTo = config.updateTo === undefined ?
UPDATE_TO_OPTIONS[0] :
config.updateTo;
const exclude = Array.isArray(config.exclude) === true ?
config.exclude :
[];
const save = config.save === undefined ? SAVE_OPTIONS[0] : config.save;
checkCwd(cwd);
checkUse(packageManager);
checkForYarnWithCustomReg(packageManager, registry);
checkUpdateTo(updateTo);
checkSave(save);
this.config = {
cwd,
use: packageManager,
exclude,
test: config.test,
registry,
updateTo,
save,
interactive: config.interactive,
};
this.cmds = cmds[packageManager];
this.parse = parse[packageManager];
if (typeof config.test === "string") {
this.cmds = {
...this.cmds,
test: () => config.test,
};
}
}
|
The config passed-in here should look identically to the CLI config.
Dash-cased properties should be renamed to camelCased.
The goal is to replicate the API of the CLI as close as possible so users don't
have to guess the options.
@param {UpdtrConfig} config
|
constructor
|
javascript
|
peerigon/updtr
|
src/Updtr.js
|
https://github.com/peerigon/updtr/blob/master/src/Updtr.js
|
Unlicense
|
async canAccessPackageJson() {
let result = true;
try {
await fs.access(
path.join(this.config.cwd, "package.json"),
FS_CONSTANTS.R_OK | FS_CONSTANTS.W_OK // eslint-disable-line no-bitwise
);
} catch (err) {
result = false;
}
return result;
}
|
The config passed-in here should look identically to the CLI config.
Dash-cased properties should be renamed to camelCased.
The goal is to replicate the API of the CLI as close as possible so users don't
have to guess the options.
@param {UpdtrConfig} config
|
canAccessPackageJson
|
javascript
|
peerigon/updtr
|
src/Updtr.js
|
https://github.com/peerigon/updtr/blob/master/src/Updtr.js
|
Unlicense
|
exec(cmd) {
return exec(this.config.cwd, cmd);
}
|
The config passed-in here should look identically to the CLI config.
Dash-cased properties should be renamed to camelCased.
The goal is to replicate the API of the CLI as close as possible so users don't
have to guess the options.
@param {UpdtrConfig} config
|
exec
|
javascript
|
peerigon/updtr
|
src/Updtr.js
|
https://github.com/peerigon/updtr/blob/master/src/Updtr.js
|
Unlicense
|
readFile(filenameInCwd) {
return fs.readFile(path.join(this.config.cwd, filenameInCwd), "utf8");
}
|
The config passed-in here should look identically to the CLI config.
Dash-cased properties should be renamed to camelCased.
The goal is to replicate the API of the CLI as close as possible so users don't
have to guess the options.
@param {UpdtrConfig} config
|
readFile
|
javascript
|
peerigon/updtr
|
src/Updtr.js
|
https://github.com/peerigon/updtr/blob/master/src/Updtr.js
|
Unlicense
|
writeFile(filenameInCwd, contents) {
return fs.writeFile(
path.join(this.config.cwd, filenameInCwd),
contents
);
}
|
The config passed-in here should look identically to the CLI config.
Dash-cased properties should be renamed to camelCased.
The goal is to replicate the API of the CLI as close as possible so users don't
have to guess the options.
@param {UpdtrConfig} config
|
writeFile
|
javascript
|
peerigon/updtr
|
src/Updtr.js
|
https://github.com/peerigon/updtr/blob/master/src/Updtr.js
|
Unlicense
|
function updateVersionRange(oldRange, newVersion) {
const parsedOldRange = parse(oldRange.trim());
if (parsedOldRange !== null) {
if (isPinned(parsedOldRange) === true) {
// The old version was pinned, so the new should also be pinned
return newVersion;
}
const parsedNewVersion = parse(newVersion);
if (isExpectedNewVersion(parsedNewVersion) === false) {
return newVersion;
}
const newVersionRange = tryVersionRangeUpdate(
parsedOldRange,
parsedNewVersion
);
// All this is kind of error prone so let's do a sanity check if everything's ok
if (semver.satisfies(newVersion, newVersionRange) === true) {
return newVersionRange;
}
}
return fallbackRange(newVersion);
}
|
Tries to apply the newVersion while maintaining the range (see https://github.com/peerigon/updtr/issues/47)
This is kind of risky because there are tons of semver possibilities. That's why this
function is very conservative in accepting semver ranges. If the range is not easily updatable,
we opt-out to npm's default caret operator.
@param {string} oldRange
@param {string} newVersion
@returns {string}
|
updateVersionRange
|
javascript
|
peerigon/updtr
|
src/tasks/util/updateVersionRange.js
|
https://github.com/peerigon/updtr/blob/master/src/tasks/util/updateVersionRange.js
|
Unlicense
|
cleanReposUrl = reposUrl =>
reposUrl
.replace('\n', '')
.replace('git+', '')
.replace('.git', '')
|
Clean repository url by removing '.git' and 'git+'
@param {string} reposUrl
|
cleanReposUrl
|
javascript
|
kefranabg/readme-md-generator
|
src/project-infos.js
|
https://github.com/kefranabg/readme-md-generator/blob/master/src/project-infos.js
|
MIT
|
cleanReposUrl = reposUrl =>
reposUrl
.replace('\n', '')
.replace('git+', '')
.replace('.git', '')
|
Clean repository url by removing '.git' and 'git+'
@param {string} reposUrl
|
cleanReposUrl
|
javascript
|
kefranabg/readme-md-generator
|
src/project-infos.js
|
https://github.com/kefranabg/readme-md-generator/blob/master/src/project-infos.js
|
MIT
|
getReposUrlFromPackageJson = async packageJson => {
const reposUrl = get(packageJson, 'repository.url', undefined)
return isNil(reposUrl) ? undefined : cleanReposUrl(reposUrl)
}
|
Get repository url from pakage json
@param {Object} reposUrl
|
getReposUrlFromPackageJson
|
javascript
|
kefranabg/readme-md-generator
|
src/project-infos.js
|
https://github.com/kefranabg/readme-md-generator/blob/master/src/project-infos.js
|
MIT
|
getReposUrlFromPackageJson = async packageJson => {
const reposUrl = get(packageJson, 'repository.url', undefined)
return isNil(reposUrl) ? undefined : cleanReposUrl(reposUrl)
}
|
Get repository url from pakage json
@param {Object} reposUrl
|
getReposUrlFromPackageJson
|
javascript
|
kefranabg/readme-md-generator
|
src/project-infos.js
|
https://github.com/kefranabg/readme-md-generator/blob/master/src/project-infos.js
|
MIT
|
getReposUrl = async packageJson =>
(await getReposUrlFromPackageJson(packageJson)) || getReposUrlFromGit()
|
Get repository url from package.json or git
@param {Object} packageJson
|
getReposUrl
|
javascript
|
kefranabg/readme-md-generator
|
src/project-infos.js
|
https://github.com/kefranabg/readme-md-generator/blob/master/src/project-infos.js
|
MIT
|
getReposUrl = async packageJson =>
(await getReposUrlFromPackageJson(packageJson)) || getReposUrlFromGit()
|
Get repository url from package.json or git
@param {Object} packageJson
|
getReposUrl
|
javascript
|
kefranabg/readme-md-generator
|
src/project-infos.js
|
https://github.com/kefranabg/readme-md-generator/blob/master/src/project-infos.js
|
MIT
|
getReposIssuesUrl = async packageJson => {
let reposIssuesUrl = get(packageJson, 'bugs.url', undefined)
if (isNil(reposIssuesUrl)) {
const reposUrl = await getReposUrl()
if (!isNil(reposUrl)) {
reposIssuesUrl = `${reposUrl}/issues`
}
}
return reposIssuesUrl
}
|
Get repository issues url from package.json or git
@param {Object} packageJson
|
getReposIssuesUrl
|
javascript
|
kefranabg/readme-md-generator
|
src/project-infos.js
|
https://github.com/kefranabg/readme-md-generator/blob/master/src/project-infos.js
|
MIT
|
getReposIssuesUrl = async packageJson => {
let reposIssuesUrl = get(packageJson, 'bugs.url', undefined)
if (isNil(reposIssuesUrl)) {
const reposUrl = await getReposUrl()
if (!isNil(reposUrl)) {
reposIssuesUrl = `${reposUrl}/issues`
}
}
return reposIssuesUrl
}
|
Get repository issues url from package.json or git
@param {Object} packageJson
|
getReposIssuesUrl
|
javascript
|
kefranabg/readme-md-generator
|
src/project-infos.js
|
https://github.com/kefranabg/readme-md-generator/blob/master/src/project-infos.js
|
MIT
|
isGithubRepository = repositoryUrl =>
!isNil(repositoryUrl) && repositoryUrl.includes(GITHUB_URL)
|
Check if repository is a Github repository
@param {string} repositoryUrl
|
isGithubRepository
|
javascript
|
kefranabg/readme-md-generator
|
src/project-infos.js
|
https://github.com/kefranabg/readme-md-generator/blob/master/src/project-infos.js
|
MIT
|
isGithubRepository = repositoryUrl =>
!isNil(repositoryUrl) && repositoryUrl.includes(GITHUB_URL)
|
Check if repository is a Github repository
@param {string} repositoryUrl
|
isGithubRepository
|
javascript
|
kefranabg/readme-md-generator
|
src/project-infos.js
|
https://github.com/kefranabg/readme-md-generator/blob/master/src/project-infos.js
|
MIT
|
getAuthorName = packageJson => {
if (has(packageJson, 'author.name')) {
return get(packageJson, 'author.name', undefined)
}
if (has(packageJson, 'author') && typeof packageJson.author === 'string') {
return get(packageJson, 'author', undefined)
}
return undefined
}
|
Get project author name from package.json
@param packageJson
@returns {string} authorName
|
getAuthorName
|
javascript
|
kefranabg/readme-md-generator
|
src/project-infos.js
|
https://github.com/kefranabg/readme-md-generator/blob/master/src/project-infos.js
|
MIT
|
getAuthorName = packageJson => {
if (has(packageJson, 'author.name')) {
return get(packageJson, 'author.name', undefined)
}
if (has(packageJson, 'author') && typeof packageJson.author === 'string') {
return get(packageJson, 'author', undefined)
}
return undefined
}
|
Get project author name from package.json
@param packageJson
@returns {string} authorName
|
getAuthorName
|
javascript
|
kefranabg/readme-md-generator
|
src/project-infos.js
|
https://github.com/kefranabg/readme-md-generator/blob/master/src/project-infos.js
|
MIT
|
getProjectInfos = async () => {
const spinner = ora('Gathering project infos').start()
const packageJson = await getPackageJson()
const isJSProject = !!packageJson
const packageManager = isJSProject
? getPackageManagerFromLockFile()
: undefined
const name = getProjectName(packageJson)
const description = get(packageJson, 'description', undefined)
const engines = get(packageJson, 'engines', undefined)
const author = getAuthorName(packageJson)
const version = get(packageJson, 'version', undefined)
const licenseName = get(packageJson, 'license', undefined)
const homepage = get(packageJson, 'homepage', undefined)
const hasStartCommand = has(packageJson, 'scripts.start')
const hasTestCommand = has(packageJson, 'scripts.test')
const repositoryUrl = await getReposUrl(packageJson)
const issuesUrl = await getReposIssuesUrl(packageJson)
const isGithubRepos = isGithubRepository(repositoryUrl)
const contributingUrl = repositoryUrl
? getContributingUrlFromRepositoryUrl(repositoryUrl)
: undefined
const documentationUrl = isGithubRepos
? getReadmeUrlFromGithubRepositoryUrl(repositoryUrl)
: undefined
const githubUsername = isGithubRepos
? getGithubUsernameFromRepositoryUrl(repositoryUrl)
: undefined
const authorWebsite = githubUsername
? await getAuthorWebsiteFromGithubAPI(githubUsername)
: undefined
const licenseUrl = isGithubRepos
? getLicenseUrlFromGithubRepositoryUrl(repositoryUrl)
: undefined
spinner.succeed('Project infos gathered')
return {
name,
description,
version,
author,
authorWebsite,
homepage,
repositoryUrl,
issuesUrl,
contributingUrl,
githubUsername,
engines,
licenseName,
licenseUrl,
documentationUrl,
isGithubRepos,
hasStartCommand,
hasTestCommand,
isJSProject,
packageManager
}
}
|
Get project informations from git and package.json
|
getProjectInfos
|
javascript
|
kefranabg/readme-md-generator
|
src/project-infos.js
|
https://github.com/kefranabg/readme-md-generator/blob/master/src/project-infos.js
|
MIT
|
getProjectInfos = async () => {
const spinner = ora('Gathering project infos').start()
const packageJson = await getPackageJson()
const isJSProject = !!packageJson
const packageManager = isJSProject
? getPackageManagerFromLockFile()
: undefined
const name = getProjectName(packageJson)
const description = get(packageJson, 'description', undefined)
const engines = get(packageJson, 'engines', undefined)
const author = getAuthorName(packageJson)
const version = get(packageJson, 'version', undefined)
const licenseName = get(packageJson, 'license', undefined)
const homepage = get(packageJson, 'homepage', undefined)
const hasStartCommand = has(packageJson, 'scripts.start')
const hasTestCommand = has(packageJson, 'scripts.test')
const repositoryUrl = await getReposUrl(packageJson)
const issuesUrl = await getReposIssuesUrl(packageJson)
const isGithubRepos = isGithubRepository(repositoryUrl)
const contributingUrl = repositoryUrl
? getContributingUrlFromRepositoryUrl(repositoryUrl)
: undefined
const documentationUrl = isGithubRepos
? getReadmeUrlFromGithubRepositoryUrl(repositoryUrl)
: undefined
const githubUsername = isGithubRepos
? getGithubUsernameFromRepositoryUrl(repositoryUrl)
: undefined
const authorWebsite = githubUsername
? await getAuthorWebsiteFromGithubAPI(githubUsername)
: undefined
const licenseUrl = isGithubRepos
? getLicenseUrlFromGithubRepositoryUrl(repositoryUrl)
: undefined
spinner.succeed('Project infos gathered')
return {
name,
description,
version,
author,
authorWebsite,
homepage,
repositoryUrl,
issuesUrl,
contributingUrl,
githubUsername,
engines,
licenseName,
licenseUrl,
documentationUrl,
isGithubRepos,
hasStartCommand,
hasTestCommand,
isJSProject,
packageManager
}
}
|
Get project informations from git and package.json
|
getProjectInfos
|
javascript
|
kefranabg/readme-md-generator
|
src/project-infos.js
|
https://github.com/kefranabg/readme-md-generator/blob/master/src/project-infos.js
|
MIT
|
writeReadme = async readmeContent => {
const spinner = ora('Creating README').start()
try {
await promisify(fs.writeFile)(README_PATH, unescape(readmeContent))
spinner.succeed('README created')
} catch (err) {
spinner.fail('README creation fail')
throw err
}
}
|
Create readme file from the given readmeContent
@param {string} readmeContent
|
writeReadme
|
javascript
|
kefranabg/readme-md-generator
|
src/readme.js
|
https://github.com/kefranabg/readme-md-generator/blob/master/src/readme.js
|
MIT
|
writeReadme = async readmeContent => {
const spinner = ora('Creating README').start()
try {
await promisify(fs.writeFile)(README_PATH, unescape(readmeContent))
spinner.succeed('README created')
} catch (err) {
spinner.fail('README creation fail')
throw err
}
}
|
Create readme file from the given readmeContent
@param {string} readmeContent
|
writeReadme
|
javascript
|
kefranabg/readme-md-generator
|
src/readme.js
|
https://github.com/kefranabg/readme-md-generator/blob/master/src/readme.js
|
MIT
|
getReadmeTemplate = async templatePath => {
const spinner = ora('Loading README template').start()
try {
const template = await promisify(fs.readFile)(templatePath, 'utf8')
spinner.succeed('README template loaded')
return template
} catch (err) {
spinner.fail('README template loading fail')
throw err
}
}
|
Get README template content from the given templatePath
@param {string} templatePath
|
getReadmeTemplate
|
javascript
|
kefranabg/readme-md-generator
|
src/readme.js
|
https://github.com/kefranabg/readme-md-generator/blob/master/src/readme.js
|
MIT
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.