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 |
|---|---|---|---|---|---|---|---|
makeDisconnected(begin, end) {
return makeSegments(this, begin, end, CodePathSegment.newDisconnected);
} | Creates new segments from this context.
The new segments don't have connections for previous segments.
But these inherit the reachable flag from this context.
@param {number} begin The first index of previous segments.
@param {number} end The last index of previous segments.
@returns {CodePathSegment[]} New segments. | makeDisconnected | javascript | facebook/react | packages/eslint-plugin-react-hooks/src/code-path-analysis/fork-context.js | https://github.com/facebook/react/blob/master/packages/eslint-plugin-react-hooks/src/code-path-analysis/fork-context.js | MIT |
add(segments) {
assert(
segments.length >= this.count,
`${segments.length} >= ${this.count}`,
);
this.segmentsList.push(mergeExtraSegments(this, segments));
} | Adds segments into this context.
The added segments become the head.
@param {CodePathSegment[]} segments Segments to add.
@returns {void} | add | javascript | facebook/react | packages/eslint-plugin-react-hooks/src/code-path-analysis/fork-context.js | https://github.com/facebook/react/blob/master/packages/eslint-plugin-react-hooks/src/code-path-analysis/fork-context.js | MIT |
replaceHead(segments) {
assert(
segments.length >= this.count,
`${segments.length} >= ${this.count}`,
);
this.segmentsList.splice(-1, 1, mergeExtraSegments(this, segments));
} | Replaces the head segments with given segments.
The current head segments are removed.
@param {CodePathSegment[]} segments Segments to add.
@returns {void} | replaceHead | javascript | facebook/react | packages/eslint-plugin-react-hooks/src/code-path-analysis/fork-context.js | https://github.com/facebook/react/blob/master/packages/eslint-plugin-react-hooks/src/code-path-analysis/fork-context.js | MIT |
addAll(context) {
assert(context.count === this.count);
const source = context.segmentsList;
for (let i = 0; i < source.length; ++i) {
this.segmentsList.push(source[i]);
}
} | Adds all segments of a given fork context into this context.
@param {ForkContext} context A fork context to add.
@returns {void} | addAll | javascript | facebook/react | packages/eslint-plugin-react-hooks/src/code-path-analysis/fork-context.js | https://github.com/facebook/react/blob/master/packages/eslint-plugin-react-hooks/src/code-path-analysis/fork-context.js | MIT |
clear() {
this.segmentsList = [];
} | Clears all segments in this context.
@returns {void} | clear | javascript | facebook/react | packages/eslint-plugin-react-hooks/src/code-path-analysis/fork-context.js | https://github.com/facebook/react/blob/master/packages/eslint-plugin-react-hooks/src/code-path-analysis/fork-context.js | MIT |
static newRoot(idGenerator) {
const context = new ForkContext(idGenerator, null, 1);
context.add([CodePathSegment.newRoot(idGenerator.next())]);
return context;
} | Creates the root fork context.
@param {IdGenerator} idGenerator An identifier generator for segments.
@returns {ForkContext} New fork context. | newRoot | javascript | facebook/react | packages/eslint-plugin-react-hooks/src/code-path-analysis/fork-context.js | https://github.com/facebook/react/blob/master/packages/eslint-plugin-react-hooks/src/code-path-analysis/fork-context.js | MIT |
static newEmpty(parentContext, forkLeavingPath) {
return new ForkContext(
parentContext.idGenerator,
parentContext,
(forkLeavingPath ? 2 : 1) * parentContext.count,
);
} | Creates an empty fork context preceded by a given context.
@param {ForkContext} parentContext The parent fork context.
@param {boolean} forkLeavingPath A flag which shows inside of `finally` block.
@returns {ForkContext} New fork context. | newEmpty | javascript | facebook/react | packages/eslint-plugin-react-hooks/src/code-path-analysis/fork-context.js | https://github.com/facebook/react/blob/master/packages/eslint-plugin-react-hooks/src/code-path-analysis/fork-context.js | MIT |
constructor(prefix) {
this.prefix = String(prefix);
this.n = 0;
} | @param {string} prefix Optional. A prefix of generated ids. | constructor | javascript | facebook/react | packages/eslint-plugin-react-hooks/src/code-path-analysis/id-generator.js | https://github.com/facebook/react/blob/master/packages/eslint-plugin-react-hooks/src/code-path-analysis/id-generator.js | MIT |
next() {
this.n = (1 + this.n) | 0;
/* c8 ignore start */
if (this.n < 0) {
this.n = 1;
} /* c8 ignore stop */
return this.prefix + this.n;
} | Generates id.
@returns {string} A generated id. | next | javascript | facebook/react | packages/eslint-plugin-react-hooks/src/code-path-analysis/id-generator.js | https://github.com/facebook/react/blob/master/packages/eslint-plugin-react-hooks/src/code-path-analysis/id-generator.js | MIT |
function normalizeIndent(strings) {
const codeLines = strings[0].split('\n');
const leftPadding = codeLines[1].match(/\s+/)[0];
return codeLines.map(line => line.slice(leftPadding.length)).join('\n');
} | A string template tag that removes padding from the left side of multi-line strings
@param {Array} strings array of code strings (only one expected) | normalizeIndent | javascript | facebook/react | packages/eslint-plugin-react-hooks/__tests__/ESLintRuleExhaustiveDeps-test.js | https://github.com/facebook/react/blob/master/packages/eslint-plugin-react-hooks/__tests__/ESLintRuleExhaustiveDeps-test.js | MIT |
predicate = t => {
if (only.length > 0) {
return only.indexOf(t) !== -1;
}
if (skipped.length > 0) {
return skipped.indexOf(t) === -1;
}
return true;
} | A string template tag that removes padding from the left side of multi-line strings
@param {Array} strings array of code strings (only one expected) | predicate | javascript | facebook/react | packages/eslint-plugin-react-hooks/__tests__/ESLintRuleExhaustiveDeps-test.js | https://github.com/facebook/react/blob/master/packages/eslint-plugin-react-hooks/__tests__/ESLintRuleExhaustiveDeps-test.js | MIT |
predicate = t => {
if (only.length > 0) {
return only.indexOf(t) !== -1;
}
if (skipped.length > 0) {
return skipped.indexOf(t) === -1;
}
return true;
} | A string template tag that removes padding from the left side of multi-line strings
@param {Array} strings array of code strings (only one expected) | predicate | javascript | facebook/react | packages/eslint-plugin-react-hooks/__tests__/ESLintRuleExhaustiveDeps-test.js | https://github.com/facebook/react/blob/master/packages/eslint-plugin-react-hooks/__tests__/ESLintRuleExhaustiveDeps-test.js | MIT |
function normalizeIndent(strings) {
const codeLines = strings[0].split('\n');
const leftPadding = codeLines[1].match(/\s+/)[0];
return codeLines.map(line => line.slice(leftPadding.length)).join('\n');
} | A string template tag that removes padding from the left side of multi-line strings
@param {Array} strings array of code strings (only one expected) | normalizeIndent | javascript | facebook/react | packages/eslint-plugin-react-hooks/__tests__/ESLintRulesOfHooks-test.js | https://github.com/facebook/react/blob/master/packages/eslint-plugin-react-hooks/__tests__/ESLintRulesOfHooks-test.js | MIT |
function conditionalError(hook, hasPreviousFinalizer = false) {
return {
message:
`React Hook "${hook}" is called conditionally. React Hooks must be ` +
'called in the exact same order in every component render.' +
(hasPreviousFinalizer
? ' Did you accidentally call a React Hook after an... | A string template tag that removes padding from the left side of multi-line strings
@param {Array} strings array of code strings (only one expected) | conditionalError | javascript | facebook/react | packages/eslint-plugin-react-hooks/__tests__/ESLintRulesOfHooks-test.js | https://github.com/facebook/react/blob/master/packages/eslint-plugin-react-hooks/__tests__/ESLintRulesOfHooks-test.js | MIT |
function loopError(hook) {
return {
message:
`React Hook "${hook}" may be executed more than once. Possibly ` +
'because it is called in a loop. React Hooks must be called in the ' +
'exact same order in every component render.',
};
} | A string template tag that removes padding from the left side of multi-line strings
@param {Array} strings array of code strings (only one expected) | loopError | javascript | facebook/react | packages/eslint-plugin-react-hooks/__tests__/ESLintRulesOfHooks-test.js | https://github.com/facebook/react/blob/master/packages/eslint-plugin-react-hooks/__tests__/ESLintRulesOfHooks-test.js | MIT |
function functionError(hook, fn) {
return {
message:
`React Hook "${hook}" is called in function "${fn}" that is neither ` +
'a React function component nor a custom React Hook function.' +
' React component names must start with an uppercase letter.' +
' React Hook names must start with t... | A string template tag that removes padding from the left side of multi-line strings
@param {Array} strings array of code strings (only one expected) | functionError | javascript | facebook/react | packages/eslint-plugin-react-hooks/__tests__/ESLintRulesOfHooks-test.js | https://github.com/facebook/react/blob/master/packages/eslint-plugin-react-hooks/__tests__/ESLintRulesOfHooks-test.js | MIT |
function genericError(hook) {
return {
message:
`React Hook "${hook}" cannot be called inside a callback. React Hooks ` +
'must be called in a React function component or a custom React ' +
'Hook function.',
};
} | A string template tag that removes padding from the left side of multi-line strings
@param {Array} strings array of code strings (only one expected) | genericError | javascript | facebook/react | packages/eslint-plugin-react-hooks/__tests__/ESLintRulesOfHooks-test.js | https://github.com/facebook/react/blob/master/packages/eslint-plugin-react-hooks/__tests__/ESLintRulesOfHooks-test.js | MIT |
function topLevelError(hook) {
return {
message:
`React Hook "${hook}" cannot be called at the top level. React Hooks ` +
'must be called in a React function component or a custom React ' +
'Hook function.',
};
} | A string template tag that removes padding from the left side of multi-line strings
@param {Array} strings array of code strings (only one expected) | topLevelError | javascript | facebook/react | packages/eslint-plugin-react-hooks/__tests__/ESLintRulesOfHooks-test.js | https://github.com/facebook/react/blob/master/packages/eslint-plugin-react-hooks/__tests__/ESLintRulesOfHooks-test.js | MIT |
function classError(hook) {
return {
message:
`React Hook "${hook}" cannot be called in a class component. React Hooks ` +
'must be called in a React function component or a custom React ' +
'Hook function.',
};
} | A string template tag that removes padding from the left side of multi-line strings
@param {Array} strings array of code strings (only one expected) | classError | javascript | facebook/react | packages/eslint-plugin-react-hooks/__tests__/ESLintRulesOfHooks-test.js | https://github.com/facebook/react/blob/master/packages/eslint-plugin-react-hooks/__tests__/ESLintRulesOfHooks-test.js | MIT |
function useEffectEventError(fn) {
return {
message:
`\`${fn}\` is a function created with React Hook "useEffectEvent", and can only be called from ` +
'the same component. They cannot be assigned to variables or passed down.',
};
} | A string template tag that removes padding from the left side of multi-line strings
@param {Array} strings array of code strings (only one expected) | useEffectEventError | javascript | facebook/react | packages/eslint-plugin-react-hooks/__tests__/ESLintRulesOfHooks-test.js | https://github.com/facebook/react/blob/master/packages/eslint-plugin-react-hooks/__tests__/ESLintRulesOfHooks-test.js | MIT |
function asyncComponentHookError(fn) {
return {
message: `React Hook "${fn}" cannot be called in an async function.`,
};
} | A string template tag that removes padding from the left side of multi-line strings
@param {Array} strings array of code strings (only one expected) | asyncComponentHookError | javascript | facebook/react | packages/eslint-plugin-react-hooks/__tests__/ESLintRulesOfHooks-test.js | https://github.com/facebook/react/blob/master/packages/eslint-plugin-react-hooks/__tests__/ESLintRulesOfHooks-test.js | MIT |
predicate = t => {
if (only.length > 0) {
return only.indexOf(t) !== -1;
}
if (skipped.length > 0) {
return skipped.indexOf(t) === -1;
}
return true;
} | A string template tag that removes padding from the left side of multi-line strings
@param {Array} strings array of code strings (only one expected) | predicate | javascript | facebook/react | packages/eslint-plugin-react-hooks/__tests__/ESLintRulesOfHooks-test.js | https://github.com/facebook/react/blob/master/packages/eslint-plugin-react-hooks/__tests__/ESLintRulesOfHooks-test.js | MIT |
predicate = t => {
if (only.length > 0) {
return only.indexOf(t) !== -1;
}
if (skipped.length > 0) {
return skipped.indexOf(t) === -1;
}
return true;
} | A string template tag that removes padding from the left side of multi-line strings
@param {Array} strings array of code strings (only one expected) | predicate | javascript | facebook/react | packages/eslint-plugin-react-hooks/__tests__/ESLintRulesOfHooks-test.js | https://github.com/facebook/react/blob/master/packages/eslint-plugin-react-hooks/__tests__/ESLintRulesOfHooks-test.js | MIT |
function filteredTests(predicate) {
return {
valid: allTests.valid.filter(predicate),
invalid: allTests.invalid.filter(predicate),
};
} | A string template tag that removes padding from the left side of multi-line strings
@param {Array} strings array of code strings (only one expected) | filteredTests | javascript | facebook/react | packages/eslint-plugin-react-hooks/__tests__/ESLintRulesOfHooks-test.js | https://github.com/facebook/react/blob/master/packages/eslint-plugin-react-hooks/__tests__/ESLintRulesOfHooks-test.js | MIT |
defineDeprecationWarning = function (methodName, info) {
Object.defineProperty(Component.prototype, methodName, {
get: function () {
console.warn(
'%s(...) is deprecated in plain JavaScript React classes. %s',
info[0],
info[1],
);
return undefined;
}... | Deprecated APIs. These APIs used to exist on classic React classes but since
we would like to deprecate them, we're not going to move them over to this
modern base class. Instead, we define a getter that warns if it's accessed. | defineDeprecationWarning | javascript | facebook/react | packages/react/src/ReactBaseClasses.js | https://github.com/facebook/react/blob/master/packages/react/src/ReactBaseClasses.js | MIT |
defineDeprecationWarning = function (methodName, info) {
Object.defineProperty(Component.prototype, methodName, {
get: function () {
console.warn(
'%s(...) is deprecated in plain JavaScript React classes. %s',
info[0],
info[1],
);
return undefined;
}... | Deprecated APIs. These APIs used to exist on classic React classes but since
we would like to deprecate them, we're not going to move them over to this
modern base class. Instead, we define a getter that warns if it's accessed. | defineDeprecationWarning | javascript | facebook/react | packages/react/src/ReactBaseClasses.js | https://github.com/facebook/react/blob/master/packages/react/src/ReactBaseClasses.js | MIT |
function PureComponent(props, context, updater) {
this.props = props;
this.context = context;
// If a component has string refs, we will assign a different object later.
this.refs = emptyObject;
this.updater = updater || ReactNoopUpdateQueue;
} | Convenience component with default shallow equality check for sCU. | PureComponent | javascript | facebook/react | packages/react/src/ReactBaseClasses.js | https://github.com/facebook/react/blob/master/packages/react/src/ReactBaseClasses.js | MIT |
function escape(key: string): string {
const escapeRegex = /[=:]/g;
const escaperLookup = {
'=': '=0',
':': '=2',
};
const escapedString = key.replace(escapeRegex, function (match) {
// $FlowFixMe[invalid-computed-prop]
return escaperLookup[match];
});
return '$' + escapedString;
} | Escape and wrap key so it is safe to use as a reactid
@param {string} key to be escaped.
@return {string} the escaped key. | escape | javascript | facebook/react | packages/react/src/ReactChildren.js | https://github.com/facebook/react/blob/master/packages/react/src/ReactChildren.js | MIT |
function escapeUserProvidedKey(text: string): string {
return text.replace(userProvidedKeyEscapeRegex, '$&/');
} | TODO: Test that a single child and an array with one item have the same key
pattern. | escapeUserProvidedKey | javascript | facebook/react | packages/react/src/ReactChildren.js | https://github.com/facebook/react/blob/master/packages/react/src/ReactChildren.js | MIT |
function getElementKey(element: any, index: number): string {
// Do some typechecking here since we call this blindly. We want to ensure
// that we don't block potential future ES APIs.
if (typeof element === 'object' && element !== null && element.key != null) {
// Explicit key
if (__DEV__) {
check... | Generate a key string that identifies a element within a set.
@param {*} element A element that could contain a manual key.
@param {number} index Index that is used if a manual key is not provided.
@return {string} | getElementKey | javascript | facebook/react | packages/react/src/ReactChildren.js | https://github.com/facebook/react/blob/master/packages/react/src/ReactChildren.js | MIT |
if (typeof thenable.status === 'string') {
// Only instrument the thenable if the status if not defined. If
// it's defined, but an unknown value, assume it's been instrumented by
// some custom userspace implementation. We treat it as "pending".
// Attach a dummy listener, to ensure tha... | Generate a key string that identifies a element within a set.
@param {*} element A element that could contain a manual key.
@param {number} index Index that is used if a manual key is not provided.
@return {string} | if | javascript | facebook/react | packages/react/src/ReactChildren.js | https://github.com/facebook/react/blob/master/packages/react/src/ReactChildren.js | MIT |
if (isValidElement(mappedChild)) {
if (__DEV__) {
// The `if` statement here prevents auto-disabling of the safe
// coercion ESLint rule, so we must manually disable it below.
// $FlowFixMe[incompatible-type] Flow incorrectly thinks React.Portal doesn't have a key
if (map... | Generate a key string that identifies a element within a set.
@param {*} element A element that could contain a manual key.
@param {number} index Index that is used if a manual key is not provided.
@return {string} | if | javascript | facebook/react | packages/react/src/ReactChildren.js | https://github.com/facebook/react/blob/master/packages/react/src/ReactChildren.js | MIT |
if (iteratorFn === iterableChildren.entries) {
if (!didWarnAboutMaps) {
console.warn(
'Using Maps as children is not supported. ' +
'Use an array of keyed ReactElements instead.',
);
}
didWarnAboutMaps = true;
} | Generate a key string that identifies a element within a set.
@param {*} element A element that could contain a manual key.
@param {number} index Index that is used if a manual key is not provided.
@return {string} | if | javascript | facebook/react | packages/react/src/ReactChildren.js | https://github.com/facebook/react/blob/master/packages/react/src/ReactChildren.js | MIT |
function ReactElement(
type,
key,
self,
source,
owner,
props,
debugStack,
debugTask,
) {
// Ignore whatever was passed as the ref argument and treat `props.ref` as
// the source of truth. The only thing we use this for is `element.ref`,
// which will log a deprecation warning on access. In the nex... | Factory method to create a new React element. This no longer adheres to
the class pattern, so do not use new to call it. Also, instanceof check
will not work. Instead test $$typeof field against Symbol.for('react.transitional.element') to check
if something is a React Element.
@param {*} type
@param {*} props
@param {... | ReactElement | javascript | facebook/react | packages/react/src/jsx/ReactJSXElement.js | https://github.com/facebook/react/blob/master/packages/react/src/jsx/ReactJSXElement.js | MIT |
function jsxProd(type, config, maybeKey) {
let key = null;
// Currently, key can be spread in as a prop. This causes a potential
// issue if key is also explicitly declared (ie. <div {...props} key="Hi" />
// or <div key="Hi" {...props} /> ). We want to deprecate key spread,
// but as an intermediary step, w... | https://github.com/reactjs/rfcs/pull/107
@param {*} type
@param {object} props
@param {string} key | jsxProd | javascript | facebook/react | packages/react/src/jsx/ReactJSXElement.js | https://github.com/facebook/react/blob/master/packages/react/src/jsx/ReactJSXElement.js | MIT |
function jsxProdSignatureRunningInDevWithDynamicChildren(
type,
config,
maybeKey,
source,
self,
) {
if (__DEV__) {
const isStaticChildren = false;
const trackActualOwner =
__DEV__ &&
ReactSharedInternals.recentlyCreatedOwnerStacks++ < ownerStackLimit;
return jsxDEVImpl(
type,
... | https://github.com/reactjs/rfcs/pull/107
@param {*} type
@param {object} props
@param {string} key | jsxProdSignatureRunningInDevWithDynamicChildren | javascript | facebook/react | packages/react/src/jsx/ReactJSXElement.js | https://github.com/facebook/react/blob/master/packages/react/src/jsx/ReactJSXElement.js | MIT |
function jsxProdSignatureRunningInDevWithStaticChildren(
type,
config,
maybeKey,
source,
self,
) {
if (__DEV__) {
const isStaticChildren = true;
const trackActualOwner =
__DEV__ &&
ReactSharedInternals.recentlyCreatedOwnerStacks++ < ownerStackLimit;
return jsxDEVImpl(
type,
... | https://github.com/reactjs/rfcs/pull/107
@param {*} type
@param {object} props
@param {string} key | jsxProdSignatureRunningInDevWithStaticChildren | javascript | facebook/react | packages/react/src/jsx/ReactJSXElement.js | https://github.com/facebook/react/blob/master/packages/react/src/jsx/ReactJSXElement.js | MIT |
function jsxDEV(type, config, maybeKey, isStaticChildren, source, self) {
const trackActualOwner =
__DEV__ &&
ReactSharedInternals.recentlyCreatedOwnerStacks++ < ownerStackLimit;
return jsxDEVImpl(
type,
config,
maybeKey,
isStaticChildren,
source,
self,
__DEV__ &&
(trackAct... | https://github.com/reactjs/rfcs/pull/107
@param {*} type
@param {object} props
@param {string} key | jsxDEV | javascript | facebook/react | packages/react/src/jsx/ReactJSXElement.js | https://github.com/facebook/react/blob/master/packages/react/src/jsx/ReactJSXElement.js | MIT |
function jsxDEVImpl(
type,
config,
maybeKey,
isStaticChildren,
source,
self,
debugStack,
debugTask,
) {
if (__DEV__) {
// We don't warn for invalid element type here because with owner stacks,
// we error in the renderer. The renderer is the only one that knows what
// types are valid for ... | https://github.com/reactjs/rfcs/pull/107
@param {*} type
@param {object} props
@param {string} key | jsxDEVImpl | javascript | facebook/react | packages/react/src/jsx/ReactJSXElement.js | https://github.com/facebook/react/blob/master/packages/react/src/jsx/ReactJSXElement.js | MIT |
function createElement(type, config, children) {
if (__DEV__) {
// We don't warn for invalid element type here because with owner stacks,
// we error in the renderer. The renderer is the only one that knows what
// types are valid for this particular renderer so we let it error there.
// Skip key war... | Create and return a new ReactElement of the given type.
See https://reactjs.org/docs/react-api.html#createelement | createElement | javascript | facebook/react | packages/react/src/jsx/ReactJSXElement.js | https://github.com/facebook/react/blob/master/packages/react/src/jsx/ReactJSXElement.js | MIT |
function cloneAndReplaceKey(oldElement, newKey) {
const clonedElement = ReactElement(
oldElement.type,
newKey,
undefined,
undefined,
!__DEV__ ? undefined : oldElement._owner,
oldElement.props,
__DEV__ && oldElement._debugStack,
__DEV__ && oldElement._debugTask,
);
if (__DEV__) {
... | Create and return a new ReactElement of the given type.
See https://reactjs.org/docs/react-api.html#createelement | cloneAndReplaceKey | javascript | facebook/react | packages/react/src/jsx/ReactJSXElement.js | https://github.com/facebook/react/blob/master/packages/react/src/jsx/ReactJSXElement.js | MIT |
function cloneElement(element, config, children) {
if (element === null || element === undefined) {
throw new Error(
`The argument must be a React element, but you passed ${element}.`,
);
}
let propName;
// Original props are copied
const props = assign({}, element.props);
// Reserved names... | Clone and return a new ReactElement using element as the starting point.
See https://reactjs.org/docs/react-api.html#cloneelement | cloneElement | javascript | facebook/react | packages/react/src/jsx/ReactJSXElement.js | https://github.com/facebook/react/blob/master/packages/react/src/jsx/ReactJSXElement.js | MIT |
function validateChildKeys(node, parentType) {
if (__DEV__) {
// With owner stacks is, no warnings happens. All we do is
// mark elements as being in a valid static child position so they
// don't need keys.
if (isValidElement(node)) {
if (node._store) {
node._store.validated = 1;
... | 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/react | packages/react/src/jsx/ReactJSXElement.js | https://github.com/facebook/react/blob/master/packages/react/src/jsx/ReactJSXElement.js | MIT |
function isValidElement(object) {
return (
typeof object === 'object' &&
object !== null &&
object.$$typeof === REACT_ELEMENT_TYPE
);
} | Verifies the object is a ReactElement.
See https://reactjs.org/docs/react-api.html#isvalidelement
@param {?object} object
@return {boolean} True if `object` is a ReactElement.
@final | isValidElement | javascript | facebook/react | packages/react/src/jsx/ReactJSXElement.js | https://github.com/facebook/react/blob/master/packages/react/src/jsx/ReactJSXElement.js | MIT |
constructor(stops, x1, y1, x2, y2) {
this._args = slice.call(arguments);
} | Declarative fill-type objects; API design not finalized | constructor | javascript | facebook/react | packages/react-art/src/ReactART.js | https://github.com/facebook/react/blob/master/packages/react-art/src/ReactART.js | MIT |
applyFill(node) {
node.fillLinear.apply(node, this._args);
} | Declarative fill-type objects; API design not finalized | applyFill | javascript | facebook/react | packages/react-art/src/ReactART.js | https://github.com/facebook/react/blob/master/packages/react-art/src/ReactART.js | MIT |
constructor(stops, fx, fy, rx, ry, cx, cy) {
this._args = slice.call(arguments);
} | Declarative fill-type objects; API design not finalized | constructor | javascript | facebook/react | packages/react-art/src/ReactART.js | https://github.com/facebook/react/blob/master/packages/react-art/src/ReactART.js | MIT |
applyFill(node) {
node.fillRadial.apply(node, this._args);
} | Declarative fill-type objects; API design not finalized | applyFill | javascript | facebook/react | packages/react-art/src/ReactART.js | https://github.com/facebook/react/blob/master/packages/react-art/src/ReactART.js | MIT |
constructor(url, width, height, left, top) {
this._args = slice.call(arguments);
} | Declarative fill-type objects; API design not finalized | constructor | javascript | facebook/react | packages/react-art/src/ReactART.js | https://github.com/facebook/react/blob/master/packages/react-art/src/ReactART.js | MIT |
applyFill(node) {
node.fillImage.apply(node, this._args);
} | Declarative fill-type objects; API design not finalized | applyFill | javascript | facebook/react | packages/react-art/src/ReactART.js | https://github.com/facebook/react/blob/master/packages/react-art/src/ReactART.js | MIT |
ensureLocalBuild = async () => {
const buildDir = resolve(__dirname, '..', '..', 'build');
const nodeModulesDir = join(buildDir, 'node_modules');
// TODO: remove this check whenever the CI pipeline is complete.
// See build-all-release-channels.js
const currentBuildDir = resolve(
__dirname,
'..',
... | Ensures that a local build of the dependencies exist either by downloading
or running a local build via one of the `react-build-fordevtools*` scripts. | ensureLocalBuild | javascript | facebook/react | packages/react-devtools-extensions/build.js | https://github.com/facebook/react/blob/master/packages/react-devtools-extensions/build.js | MIT |
ensureLocalBuild = async () => {
const buildDir = resolve(__dirname, '..', '..', 'build');
const nodeModulesDir = join(buildDir, 'node_modules');
// TODO: remove this check whenever the CI pipeline is complete.
// See build-all-release-channels.js
const currentBuildDir = resolve(
__dirname,
'..',
... | Ensures that a local build of the dependencies exist either by downloading
or running a local build via one of the `react-build-fordevtools*` scripts. | ensureLocalBuild | javascript | facebook/react | packages/react-devtools-extensions/build.js | https://github.com/facebook/react/blob/master/packages/react-devtools-extensions/build.js | MIT |
preProcess = async (destinationPath, tempPath) => {
await remove(destinationPath); // Clean up from previously completed builds
await remove(tempPath); // Clean up from any previously failed builds
await ensureDir(tempPath); // Create temp dir for this new build
} | Ensures that a local build of the dependencies exist either by downloading
or running a local build via one of the `react-build-fordevtools*` scripts. | preProcess | javascript | facebook/react | packages/react-devtools-extensions/build.js | https://github.com/facebook/react/blob/master/packages/react-devtools-extensions/build.js | MIT |
preProcess = async (destinationPath, tempPath) => {
await remove(destinationPath); // Clean up from previously completed builds
await remove(tempPath); // Clean up from any previously failed builds
await ensureDir(tempPath); // Create temp dir for this new build
} | Ensures that a local build of the dependencies exist either by downloading
or running a local build via one of the `react-build-fordevtools*` scripts. | preProcess | javascript | facebook/react | packages/react-devtools-extensions/build.js | https://github.com/facebook/react/blob/master/packages/react-devtools-extensions/build.js | MIT |
build = async (tempPath, manifestPath, envExtension = {}) => {
const binPath = join(tempPath, 'bin');
const zipPath = join(tempPath, 'zip');
const mergedEnv = {...process.env, ...envExtension};
const webpackPath = join(__dirname, 'node_modules', '.bin', 'webpack');
execSync(
`${webpackPath} --config webp... | Ensures that a local build of the dependencies exist either by downloading
or running a local build via one of the `react-build-fordevtools*` scripts. | build | javascript | facebook/react | packages/react-devtools-extensions/build.js | https://github.com/facebook/react/blob/master/packages/react-devtools-extensions/build.js | MIT |
build = async (tempPath, manifestPath, envExtension = {}) => {
const binPath = join(tempPath, 'bin');
const zipPath = join(tempPath, 'zip');
const mergedEnv = {...process.env, ...envExtension};
const webpackPath = join(__dirname, 'node_modules', '.bin', 'webpack');
execSync(
`${webpackPath} --config webp... | Ensures that a local build of the dependencies exist either by downloading
or running a local build via one of the `react-build-fordevtools*` scripts. | build | javascript | facebook/react | packages/react-devtools-extensions/build.js | https://github.com/facebook/react/blob/master/packages/react-devtools-extensions/build.js | MIT |
postProcess = async (tempPath, destinationPath) => {
const unpackedSourcePath = join(tempPath, 'zip');
const packedSourcePath = join(tempPath, 'ReactDevTools.zip');
const packedDestPath = join(destinationPath, 'ReactDevTools.zip');
const unpackedDestPath = join(destinationPath, 'unpacked');
await move(unpack... | Ensures that a local build of the dependencies exist either by downloading
or running a local build via one of the `react-build-fordevtools*` scripts. | postProcess | javascript | facebook/react | packages/react-devtools-extensions/build.js | https://github.com/facebook/react/blob/master/packages/react-devtools-extensions/build.js | MIT |
postProcess = async (tempPath, destinationPath) => {
const unpackedSourcePath = join(tempPath, 'zip');
const packedSourcePath = join(tempPath, 'ReactDevTools.zip');
const packedDestPath = join(destinationPath, 'ReactDevTools.zip');
const unpackedDestPath = join(destinationPath, 'unpacked');
await move(unpack... | Ensures that a local build of the dependencies exist either by downloading
or running a local build via one of the `react-build-fordevtools*` scripts. | postProcess | javascript | facebook/react | packages/react-devtools-extensions/build.js | https://github.com/facebook/react/blob/master/packages/react-devtools-extensions/build.js | MIT |
main = async buildId => {
if (!SUPPORTED_BUILDS.includes(buildId)) {
throw new Error(
`Unexpected build id - "${buildId}". Use one of ${JSON.stringify(
SUPPORTED_BUILDS,
)}.`,
);
}
const root = join(__dirname, buildId);
const manifestPath = join(root, 'manifest.json');
const desti... | Ensures that a local build of the dependencies exist either by downloading
or running a local build via one of the `react-build-fordevtools*` scripts. | main | javascript | facebook/react | packages/react-devtools-extensions/build.js | https://github.com/facebook/react/blob/master/packages/react-devtools-extensions/build.js | MIT |
main = async buildId => {
if (!SUPPORTED_BUILDS.includes(buildId)) {
throw new Error(
`Unexpected build id - "${buildId}". Use one of ${JSON.stringify(
SUPPORTED_BUILDS,
)}.`,
);
}
const root = join(__dirname, buildId);
const manifestPath = join(root, 'manifest.json');
const desti... | Ensures that a local build of the dependencies exist either by downloading
or running a local build via one of the `react-build-fordevtools*` scripts. | main | javascript | facebook/react | packages/react-devtools-extensions/build.js | https://github.com/facebook/react/blob/master/packages/react-devtools-extensions/build.js | MIT |
if (i > 0) {
formatted += ', ';
} | Get a enhanced/artificial type string based on the object instance | if | javascript | facebook/react | packages/react-devtools-shared/src/utils.js | https://github.com/facebook/react/blob/master/packages/react-devtools-shared/src/utils.js | MIT |
if (i > 0) {
formatted += ', ';
} | Get a enhanced/artificial type string based on the object instance | if | javascript | facebook/react | packages/react-devtools-shared/src/utils.js | https://github.com/facebook/react/blob/master/packages/react-devtools-shared/src/utils.js | MIT |
function resolveBoxStyle(
prefix: string,
style: Object,
): BoxStyle | null {
let hasParts = false;
const result = {
bottom: 0,
left: 0,
right: 0,
top: 0,
};
const styleForAll = style[prefix];
if (styleForAll != null) {
// eslint-disable-next-line no-for-of-loops/no-for-of-loops
f... | This mirrors react-native/Libraries/Inspector/resolveBoxStyle.js (but without RTL support).
Resolve a style property into it's component parts, e.g.
resolveBoxStyle('margin', {margin: 5, marginBottom: 10})
-> {top: 5, left: 5, right: 5, bottom: 10} | resolveBoxStyle | javascript | facebook/react | packages/react-devtools-shared/src/backend/NativeStyleEditor/resolveBoxStyle.js | https://github.com/facebook/react/blob/master/packages/react-devtools-shared/src/backend/NativeStyleEditor/resolveBoxStyle.js | MIT |
function describeClassComponentFrame(
ctor: Function,
currentDispatcherRef: CurrentDispatcherRef,
): string {
return describeNativeComponentFrame(ctor, true, currentDispatcherRef);
} | Finding a common stack frame between sample and control errors can be
tricky given the different types and levels of stack trace truncation from
different JS VMs. So instead we'll attempt to control what that common
frame should be through this object method:
Having both the sample and control errors be in the function... | describeClassComponentFrame | javascript | facebook/react | packages/react-devtools-shared/src/backend/shared/DevToolsComponentStackFrame.js | https://github.com/facebook/react/blob/master/packages/react-devtools-shared/src/backend/shared/DevToolsComponentStackFrame.js | MIT |
function describeFunctionComponentFrame(
fn: Function,
currentDispatcherRef: CurrentDispatcherRef,
): string {
return describeNativeComponentFrame(fn, false, currentDispatcherRef);
} | Finding a common stack frame between sample and control errors can be
tricky given the different types and levels of stack trace truncation from
different JS VMs. So instead we'll attempt to control what that common
frame should be through this object method:
Having both the sample and control errors be in the function... | describeFunctionComponentFrame | javascript | facebook/react | packages/react-devtools-shared/src/backend/shared/DevToolsComponentStackFrame.js | https://github.com/facebook/react/blob/master/packages/react-devtools-shared/src/backend/shared/DevToolsComponentStackFrame.js | MIT |
if (__DEBUG__) {
debug('constructor', 'subscribing to Bridge');
} | The store is the single source of truth for updates from the backend.
ContextProviders can subscribe to the Store for specific things they want to provide. | if | javascript | facebook/react | packages/react-devtools-shared/src/devtools/store.js | https://github.com/facebook/react/blob/master/packages/react-devtools-shared/src/devtools/store.js | MIT |
if (config != null) {
isProfiling = config.isProfiling === true;
const {
supportsInspectMatchingDOMElement,
supportsClickToInspect,
supportsReloadAndProfile,
supportsTimeline,
supportsTraceUpdates,
checkBridgeProtocolCompatibility,
} = config;
if ... | The store is the single source of truth for updates from the backend.
ContextProviders can subscribe to the Store for specific things they want to provide. | if | javascript | facebook/react | packages/react-devtools-shared/src/devtools/store.js | https://github.com/facebook/react/blob/master/packages/react-devtools-shared/src/devtools/store.js | MIT |
if (this._profilerStore.isProfilingBasedOnUserInput) {
// Re-mounting a tree while profiling is in progress might break a lot of assumptions.
// If necessary, we could support this- but it doesn't seem like a necessary use case.
this._throwAndEmitError(
Error('Cannot modify filter preferences ... | The store is the single source of truth for updates from the backend.
ContextProviders can subscribe to the Store for specific things they want to provide. | if | javascript | facebook/react | packages/react-devtools-shared/src/devtools/store.js | https://github.com/facebook/react/blob/master/packages/react-devtools-shared/src/devtools/store.js | MIT |
for (let i = 0; i < nextEnabledComponentFilters.length; i++) {
const prevFilter = prevEnabledComponentFilters[i];
const nextFilter = nextEnabledComponentFilters[i];
if (shallowDiffers(prevFilter, nextFilter)) {
haveEnabledFiltersChanged = true;
break;
}
} | The store is the single source of truth for updates from the backend.
ContextProviders can subscribe to the Store for specific things they want to provide. | for | javascript | facebook/react | packages/react-devtools-shared/src/devtools/store.js | https://github.com/facebook/react/blob/master/packages/react-devtools-shared/src/devtools/store.js | MIT |
if (index < 0 || index >= this.numElements) {
console.warn(
`Invalid index ${index} specified; store contains ${this.numElements} items.`,
);
return null;
} | The store is the single source of truth for updates from the backend.
ContextProviders can subscribe to the Store for specific things they want to provide. | if | javascript | facebook/react | packages/react-devtools-shared/src/devtools/store.js | https://github.com/facebook/react/blob/master/packages/react-devtools-shared/src/devtools/store.js | MIT |
recursivelyDeleteElements = (elementID: number) => {
const element = this._idToElement.get(elementID);
this._idToElement.delete(elementID);
if (element) {
// Mostly for Flow's sake
for (let index = 0; index < element.children.length; index++) {
... | The store is the single source of truth for updates from the backend.
ContextProviders can subscribe to the Store for specific things they want to provide. | recursivelyDeleteElements | javascript | facebook/react | packages/react-devtools-shared/src/devtools/store.js | https://github.com/facebook/react/blob/master/packages/react-devtools-shared/src/devtools/store.js | MIT |
recursivelyDeleteElements = (elementID: number) => {
const element = this._idToElement.get(elementID);
this._idToElement.delete(elementID);
if (element) {
// Mostly for Flow's sake
for (let index = 0; index < element.children.length; index++) {
... | The store is the single source of truth for updates from the backend.
ContextProviders can subscribe to the Store for specific things they want to provide. | recursivelyDeleteElements | javascript | facebook/react | packages/react-devtools-shared/src/devtools/store.js | https://github.com/facebook/react/blob/master/packages/react-devtools-shared/src/devtools/store.js | MIT |
pushFrame = (name: string, node: Node) => {
const nameInfo = {name, start: {...node.loc.start}};
hookStack.unshift(nameInfo);
hookNames.push(nameInfo);
} | This function traverses the sourceAST and returns a mapping
that maps locations in the source code to their corresponding
Hook name, if there is a relevant Hook name for that location.
A location in the source code is represented by line and column
numbers as a Position object: { line, column }.
- line is 1-indexed.... | pushFrame | javascript | facebook/react | packages/react-devtools-shared/src/hooks/astUtils.js | https://github.com/facebook/react/blob/master/packages/react-devtools-shared/src/hooks/astUtils.js | MIT |
pushFrame = (name: string, node: Node) => {
const nameInfo = {name, start: {...node.loc.start}};
hookStack.unshift(nameInfo);
hookNames.push(nameInfo);
} | This function traverses the sourceAST and returns a mapping
that maps locations in the source code to their corresponding
Hook name, if there is a relevant Hook name for that location.
A location in the source code is represented by line and column
numbers as a Position object: { line, column }.
- line is 1-indexed.... | pushFrame | javascript | facebook/react | packages/react-devtools-shared/src/hooks/astUtils.js | https://github.com/facebook/react/blob/master/packages/react-devtools-shared/src/hooks/astUtils.js | MIT |
popFrame = (node: Node) => {
hookStack.shift();
const top = hookStack[0];
if (top != null) {
hookNames.push({name: top.name, start: {...node.loc.end}});
}
} | This function traverses the sourceAST and returns a mapping
that maps locations in the source code to their corresponding
Hook name, if there is a relevant Hook name for that location.
A location in the source code is represented by line and column
numbers as a Position object: { line, column }.
- line is 1-indexed.... | popFrame | javascript | facebook/react | packages/react-devtools-shared/src/hooks/astUtils.js | https://github.com/facebook/react/blob/master/packages/react-devtools-shared/src/hooks/astUtils.js | MIT |
popFrame = (node: Node) => {
hookStack.shift();
const top = hookStack[0];
if (top != null) {
hookNames.push({name: top.name, start: {...node.loc.end}});
}
} | This function traverses the sourceAST and returns a mapping
that maps locations in the source code to their corresponding
Hook name, if there is a relevant Hook name for that location.
A location in the source code is represented by line and column
numbers as a Position object: { line, column }.
- line is 1-indexed.... | popFrame | javascript | facebook/react | packages/react-devtools-shared/src/hooks/astUtils.js | https://github.com/facebook/react/blob/master/packages/react-devtools-shared/src/hooks/astUtils.js | MIT |
enter(path) {
pushFrame(NO_HOOK_NAME, path.node);
} | This function traverses the sourceAST and returns a mapping
that maps locations in the source code to their corresponding
Hook name, if there is a relevant Hook name for that location.
A location in the source code is represented by line and column
numbers as a Position object: { line, column }.
- line is 1-indexed.... | enter | javascript | facebook/react | packages/react-devtools-shared/src/hooks/astUtils.js | https://github.com/facebook/react/blob/master/packages/react-devtools-shared/src/hooks/astUtils.js | MIT |
enter(path) {
// Check if this variable declaration corresponds to a variable
// declared by calling a Hook.
if (isConfirmedHookDeclaration(path)) {
const hookDeclaredVariableName = getHookVariableName(path);
if (!hookDeclaredVariableName) {
return;
}
... | This function traverses the sourceAST and returns a mapping
that maps locations in the source code to their corresponding
Hook name, if there is a relevant Hook name for that location.
A location in the source code is represented by line and column
numbers as a Position object: { line, column }.
- line is 1-indexed.... | enter | javascript | facebook/react | packages/react-devtools-shared/src/hooks/astUtils.js | https://github.com/facebook/react/blob/master/packages/react-devtools-shared/src/hooks/astUtils.js | MIT |
exit(path) {
if (isConfirmedHookDeclaration(path)) {
const callExpressionNode = assertCallExpression(path.node.init);
popFrame(callExpressionNode);
}
} | This function traverses the sourceAST and returns a mapping
that maps locations in the source code to their corresponding
Hook name, if there is a relevant Hook name for that location.
A location in the source code is represented by line and column
numbers as a Position object: { line, column }.
- line is 1-indexed.... | exit | javascript | facebook/react | packages/react-devtools-shared/src/hooks/astUtils.js | https://github.com/facebook/react/blob/master/packages/react-devtools-shared/src/hooks/astUtils.js | MIT |
function isConfirmedHookDeclaration(path: NodePath): boolean {
const nodeInit = path.node.init;
if (nodeInit == null || nodeInit.type !== AST_NODE_TYPES.CALL_EXPRESSION) {
return false;
}
const callee = nodeInit.callee;
return isHook(callee);
} | This function traverses the sourceAST and returns a mapping
that maps locations in the source code to their corresponding
Hook name, if there is a relevant Hook name for that location.
A location in the source code is represented by line and column
numbers as a Position object: { line, column }.
- line is 1-indexed.... | isConfirmedHookDeclaration | javascript | facebook/react | packages/react-devtools-shared/src/hooks/astUtils.js | https://github.com/facebook/react/blob/master/packages/react-devtools-shared/src/hooks/astUtils.js | MIT |
function isHook(node: Node): boolean {
if (node.type === AST_NODE_TYPES.IDENTIFIER) {
return isHookName(node.name);
} else if (
node.type === AST_NODE_TYPES.MEMBER_EXPRESSION &&
!node.computed &&
isHook(node.property)
) {
const obj = node.object;
const isPascalCaseNameSpace = /^[A-Z].*/;
... | This function traverses the sourceAST and returns a mapping
that maps locations in the source code to their corresponding
Hook name, if there is a relevant Hook name for that location.
A location in the source code is represented by line and column
numbers as a Position object: { line, column }.
- line is 1-indexed.... | isHook | javascript | facebook/react | packages/react-devtools-shared/src/hooks/astUtils.js | https://github.com/facebook/react/blob/master/packages/react-devtools-shared/src/hooks/astUtils.js | MIT |
function isHookName(name: string): boolean {
return /^use[A-Z0-9].*$/.test(name);
} | This function traverses the sourceAST and returns a mapping
that maps locations in the source code to their corresponding
Hook name, if there is a relevant Hook name for that location.
A location in the source code is represented by line and column
numbers as a Position object: { line, column }.
- line is 1-indexed.... | isHookName | javascript | facebook/react | packages/react-devtools-shared/src/hooks/astUtils.js | https://github.com/facebook/react/blob/master/packages/react-devtools-shared/src/hooks/astUtils.js | MIT |
function isPotentialHookDeclaration(path: NodePath): boolean {
// The array potentialHooksFound will contain all potential hook declaration cases we support
const nodePathInit = path.node.init;
if (nodePathInit != null) {
if (nodePathInit.type === AST_NODE_TYPES.CALL_EXPRESSION) {
// CASE: CallExpressio... | This function traverses the sourceAST and returns a mapping
that maps locations in the source code to their corresponding
Hook name, if there is a relevant Hook name for that location.
A location in the source code is represented by line and column
numbers as a Position object: { line, column }.
- line is 1-indexed.... | isPotentialHookDeclaration | javascript | facebook/react | packages/react-devtools-shared/src/hooks/astUtils.js | https://github.com/facebook/react/blob/master/packages/react-devtools-shared/src/hooks/astUtils.js | MIT |
function isReactFunction(node: Node, functionName: string): boolean {
return (
node.name === functionName ||
(node.type === 'MemberExpression' &&
node.object.name === 'React' &&
node.property.name === functionName)
);
} | This function traverses the sourceAST and returns a mapping
that maps locations in the source code to their corresponding
Hook name, if there is a relevant Hook name for that location.
A location in the source code is represented by line and column
numbers as a Position object: { line, column }.
- line is 1-indexed.... | isReactFunction | javascript | facebook/react | packages/react-devtools-shared/src/hooks/astUtils.js | https://github.com/facebook/react/blob/master/packages/react-devtools-shared/src/hooks/astUtils.js | MIT |
function isBuiltInHookThatReturnsTuple(path: NodePath): boolean {
const callee = path.node.init.callee;
return (
isReactFunction(callee, 'useState') ||
isReactFunction(callee, 'useReducer') ||
isReactFunction(callee, 'useTransition')
);
} | This function traverses the sourceAST and returns a mapping
that maps locations in the source code to their corresponding
Hook name, if there is a relevant Hook name for that location.
A location in the source code is represented by line and column
numbers as a Position object: { line, column }.
- line is 1-indexed.... | isBuiltInHookThatReturnsTuple | javascript | facebook/react | packages/react-devtools-shared/src/hooks/astUtils.js | https://github.com/facebook/react/blob/master/packages/react-devtools-shared/src/hooks/astUtils.js | MIT |
function nodeContainsHookVariableName(hookNode: NodePath): boolean {
// We determine cases where variable names are obvious in declarations. Examples:
// const [tick, setTick] = useState(1); OR const ref = useRef(null);
// Here tick/ref are obvious hook variables in the hook declaration node itself
// 1. True f... | This function traverses the sourceAST and returns a mapping
that maps locations in the source code to their corresponding
Hook name, if there is a relevant Hook name for that location.
A location in the source code is represented by line and column
numbers as a Position object: { line, column }.
- line is 1-indexed.... | nodeContainsHookVariableName | javascript | facebook/react | packages/react-devtools-shared/src/hooks/astUtils.js | https://github.com/facebook/react/blob/master/packages/react-devtools-shared/src/hooks/astUtils.js | MIT |
function assertCallExpression(node: Node): Node {
if (node.type !== AST_NODE_TYPES.CALL_EXPRESSION) {
throw new Error('Expected a CallExpression node for a Hook declaration.');
}
return node;
} | This function traverses the sourceAST and returns a mapping
that maps locations in the source code to their corresponding
Hook name, if there is a relevant Hook name for that location.
A location in the source code is represented by line and column
numbers as a Position object: { line, column }.
- line is 1-indexed.... | assertCallExpression | javascript | facebook/react | packages/react-devtools-shared/src/hooks/astUtils.js | https://github.com/facebook/react/blob/master/packages/react-devtools-shared/src/hooks/astUtils.js | MIT |
function getHookNameForLocation(
location: Position,
hookMap: HookMap,
): string | null {
const {names, mappings} = hookMap;
// The HookMap mappings are grouped by lines, so first we look up
// which line of mappings covers the target location.
// Note that we expect to find a line since all the locations ... | Finds the Hook name assigned to a given location in the source code,
and a HookMap extracted from an extended source map.
The given location must correspond to the location in the *original*
source code (i.e. *not* the generated one).
Note that all locations in the source code are guaranteed to map
to a name, includin... | getHookNameForLocation | javascript | facebook/react | packages/react-devtools-shared/src/hooks/getHookNameForLocation.js | https://github.com/facebook/react/blob/master/packages/react-devtools-shared/src/hooks/getHookNameForLocation.js | MIT |
if (comparison.index == null) {
throw new Error('Expected an index when matching element is found.');
} | Finds the Hook name assigned to a given location in the source code,
and a HookMap extracted from an extended source map.
The given location must correspond to the location in the *original*
source code (i.e. *not* the generated one).
Note that all locations in the source code are guaranteed to map
to a name, includin... | if | javascript | facebook/react | packages/react-devtools-shared/src/hooks/getHookNameForLocation.js | https://github.com/facebook/react/blob/master/packages/react-devtools-shared/src/hooks/getHookNameForLocation.js | MIT |
function normalizeSourcePath(
sourceInput: string,
map: {+sourceRoot?: ?string, ...},
): string {
const {sourceRoot} = map;
let source = sourceInput;
source = String(source);
// Some source maps produce relative source paths like "./foo.js" instead of
// "foo.js". Normalize these first so that future co... | Extracted from the logic in source-map-js@0.6.2's SourceMapConsumer.
By default, source names are normalized using the same logic that the `source-map-js@0.6.2` package uses internally.
This is crucial for keeping the sources list in sync with a `SourceMapConsumer` instance. | normalizeSourcePath | javascript | facebook/react | packages/react-devtools-shared/src/hooks/SourceMapMetadataConsumer.js | https://github.com/facebook/react/blob/master/packages/react-devtools-shared/src/hooks/SourceMapMetadataConsumer.js | MIT |
updateMap = (metadata: ReactSourceMetadata, sourceIndex: number) => {
let source = basicMap.sources[sourceIndex];
if (source != null) {
source = normalizeSourcePath(source, basicMap);
metadataMap.set(source, metadata);
}
} | Collects source metadata from the given map using the current source name
normalization function. Handles both index maps (with sections) and plain
maps.
NOTE: If any sources are repeated in the map (which shouldn't usually happen,
but is technically possible because of index maps) we only keep the
metadata from the l... | updateMap | javascript | facebook/react | packages/react-devtools-shared/src/hooks/SourceMapMetadataConsumer.js | https://github.com/facebook/react/blob/master/packages/react-devtools-shared/src/hooks/SourceMapMetadataConsumer.js | MIT |
updateMap = (metadata: ReactSourceMetadata, sourceIndex: number) => {
let source = basicMap.sources[sourceIndex];
if (source != null) {
source = normalizeSourcePath(source, basicMap);
metadataMap.set(source, metadata);
}
} | Collects source metadata from the given map using the current source name
normalization function. Handles both index maps (with sections) and plain
maps.
NOTE: If any sources are repeated in the map (which shouldn't usually happen,
but is technically possible because of index maps) we only keep the
metadata from the l... | updateMap | javascript | facebook/react | packages/react-devtools-shared/src/hooks/SourceMapMetadataConsumer.js | https://github.com/facebook/react/blob/master/packages/react-devtools-shared/src/hooks/SourceMapMetadataConsumer.js | MIT |
if (resetIgnoredErrorOrWarningMessages) {
global._ignoredErrorOrWarningMessages = prev;
} | Runs `fn` while preventing console error and warnings that partially match any given `errorOrWarningMessages` from appearing in the console.
@param errorOrWarningMessages Messages are matched partially (i.e. indexOf), pre-formatting.
@param fn | if | javascript | facebook/react | packages/react-devtools-shared/src/__tests__/utils.js | https://github.com/facebook/react/blob/master/packages/react-devtools-shared/src/__tests__/utils.js | MIT |
constructor(
surface: Surface,
frame: Rect,
stackLayer: FlamechartStackLayer,
internalModuleSourceToRanges: InternalModuleSourceToRanges,
duration: number,
) {
super(surface, frame);
this._stackLayer = stackLayer;
this._stackFrameSet = new Set(stackLayer);
this._internalModuleSourc... | A set of `stackLayer`'s frames, for efficient lookup. | constructor | javascript | facebook/react | packages/react-devtools-timeline/src/content-views/FlamechartView.js | https://github.com/facebook/react/blob/master/packages/react-devtools-timeline/src/content-views/FlamechartView.js | MIT |
desiredSize(): Size {
return this._intrinsicSize;
} | A set of `stackLayer`'s frames, for efficient lookup. | desiredSize | javascript | facebook/react | packages/react-devtools-timeline/src/content-views/FlamechartView.js | https://github.com/facebook/react/blob/master/packages/react-devtools-timeline/src/content-views/FlamechartView.js | MIT |
setHoveredFlamechartStackFrame(
hoveredStackFrame: FlamechartStackFrame | null,
) {
if (this._hoveredStackFrame === hoveredStackFrame) {
return; // We're already hovering over this frame
}
// Only care about frames displayed by this view.
const stackFrameToSet =
hoveredStackFrame && t... | A set of `stackLayer`'s frames, for efficient lookup. | setHoveredFlamechartStackFrame | javascript | facebook/react | packages/react-devtools-timeline/src/content-views/FlamechartView.js | https://github.com/facebook/react/blob/master/packages/react-devtools-timeline/src/content-views/FlamechartView.js | MIT |
draw(context: CanvasRenderingContext2D) {
const {
frame,
_stackLayer,
_hoveredStackFrame,
_intrinsicSize,
visibleArea,
} = this;
context.fillStyle = COLORS.PRIORITY_BACKGROUND;
context.fillRect(
visibleArea.origin.x,
visibleArea.origin.y,
visibleArea.size... | A set of `stackLayer`'s frames, for efficient lookup. | draw | javascript | facebook/react | packages/react-devtools-timeline/src/content-views/FlamechartView.js | https://github.com/facebook/react/blob/master/packages/react-devtools-timeline/src/content-views/FlamechartView.js | MIT |
_drawSingleReactMeasure(
context: CanvasRenderingContext2D,
rect: Rect,
measure: ReactMeasure,
nextMeasure: ReactMeasure | null,
baseY: number,
scaleFactor: number,
showGroupHighlight: boolean,
showHoverHighlight: boolean,
): void {
const {frame, visibleArea} = this;
const {tim... | Draw a single `ReactMeasure` as a bar in the canvas. | _drawSingleReactMeasure | javascript | facebook/react | packages/react-devtools-timeline/src/content-views/ReactMeasuresView.js | https://github.com/facebook/react/blob/master/packages/react-devtools-timeline/src/content-views/ReactMeasuresView.js | MIT |
draw(context: CanvasRenderingContext2D): void {
const {frame, _hoveredMeasure, _lanesToRender, _profilerData, visibleArea} =
this;
context.fillStyle = COLORS.PRIORITY_BACKGROUND;
context.fillRect(
visibleArea.origin.x,
visibleArea.origin.y,
visibleArea.size.width,
visibleArea.... | Draw a single `ReactMeasure` as a bar in the canvas. | draw | javascript | facebook/react | packages/react-devtools-timeline/src/content-views/ReactMeasuresView.js | https://github.com/facebook/react/blob/master/packages/react-devtools-timeline/src/content-views/ReactMeasuresView.js | MIT |
_drawSingleSchedulingEvent(
context: CanvasRenderingContext2D,
rect: Rect,
event: SchedulingEvent,
baseY: number,
scaleFactor: number,
showHoverHighlight: boolean,
) {
const {frame} = this;
const {timestamp, type, warning} = event;
const x = timestampToPosition(timestamp, scaleFac... | Draw a single `SchedulingEvent` as a circle in the canvas. | _drawSingleSchedulingEvent | javascript | facebook/react | packages/react-devtools-timeline/src/content-views/SchedulingEventsView.js | https://github.com/facebook/react/blob/master/packages/react-devtools-timeline/src/content-views/SchedulingEventsView.js | MIT |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.