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 spanInPreviousNode(node) {
return spanInNode(ts.findPrecedingToken(node.pos, sourceFile));
}
|
Get the breakpoint span in given sourceFile
|
spanInPreviousNode
|
javascript
|
amol-/dukpy
|
dukpy/jsmodules/typescriptServices.js
|
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
|
MIT
|
function spanInNextNode(node) {
return spanInNode(ts.findNextToken(node, node.parent));
}
|
Get the breakpoint span in given sourceFile
|
spanInNextNode
|
javascript
|
amol-/dukpy
|
dukpy/jsmodules/typescriptServices.js
|
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
|
MIT
|
function spanInNode(node) {
if (node) {
if (ts.isExpression(node)) {
if (node.parent.kind === 197 /* DoStatement */) {
// Set span as if on while keyword
return spanInPreviousNode(node);
}
if (node.parent.kind === 199 /* ForStatement */) {
// For now lets set the span on this expression, fix it later
return textSpan(node);
}
if (node.parent.kind === 181 /* BinaryExpression */ && node.parent.operatorToken.kind === 24 /* CommaToken */) {
// if this is comma expression, the breakpoint is possible in this expression
return textSpan(node);
}
if (node.parent.kind === 174 /* ArrowFunction */ && node.parent.body === node) {
// If this is body of arrow function, it is allowed to have the breakpoint
return textSpan(node);
}
}
switch (node.kind) {
case 193 /* VariableStatement */:
// Span on first variable declaration
return spanInVariableDeclaration(node.declarationList.declarations[0]);
case 211 /* VariableDeclaration */:
case 141 /* PropertyDeclaration */:
case 140 /* PropertySignature */:
return spanInVariableDeclaration(node);
case 138 /* Parameter */:
return spanInParameterDeclaration(node);
case 213 /* FunctionDeclaration */:
case 143 /* MethodDeclaration */:
case 142 /* MethodSignature */:
case 145 /* GetAccessor */:
case 146 /* SetAccessor */:
case 144 /* Constructor */:
case 173 /* FunctionExpression */:
case 174 /* ArrowFunction */:
return spanInFunctionDeclaration(node);
case 192 /* Block */:
if (ts.isFunctionBlock(node)) {
return spanInFunctionBlock(node);
}
// Fall through
case 219 /* ModuleBlock */:
return spanInBlock(node);
case 244 /* CatchClause */:
return spanInBlock(node.block);
case 195 /* ExpressionStatement */:
// span on the expression
return textSpan(node.expression);
case 204 /* ReturnStatement */:
// span on return keyword and expression if present
return textSpan(node.getChildAt(0), node.expression);
case 198 /* WhileStatement */:
// Span on while(...)
return textSpan(node, ts.findNextToken(node.expression, node));
case 197 /* DoStatement */:
// span in statement of the do statement
return spanInNode(node.statement);
case 210 /* DebuggerStatement */:
// span on debugger keyword
return textSpan(node.getChildAt(0));
case 196 /* IfStatement */:
// set on if(..) span
return textSpan(node, ts.findNextToken(node.expression, node));
case 207 /* LabeledStatement */:
// span in statement
return spanInNode(node.statement);
case 203 /* BreakStatement */:
case 202 /* ContinueStatement */:
// On break or continue keyword and label if present
return textSpan(node.getChildAt(0), node.label);
case 199 /* ForStatement */:
return spanInForStatement(node);
case 200 /* ForInStatement */:
case 201 /* ForOfStatement */:
// span on for (a in ...)
return textSpan(node, ts.findNextToken(node.expression, node));
case 206 /* SwitchStatement */:
// span on switch(...)
return textSpan(node, ts.findNextToken(node.expression, node));
case 241 /* CaseClause */:
case 242 /* DefaultClause */:
// span in first statement of the clause
return spanInNode(node.statements[0]);
case 209 /* TryStatement */:
// span in try block
return spanInBlock(node.tryBlock);
case 208 /* ThrowStatement */:
// span in throw ...
return textSpan(node, node.expression);
case 227 /* ExportAssignment */:
// span on export = id
return textSpan(node, node.expression);
case 221 /* ImportEqualsDeclaration */:
// import statement without including semicolon
return textSpan(node, node.moduleReference);
case 222 /* ImportDeclaration */:
// import statement without including semicolon
return textSpan(node, node.moduleSpecifier);
case 228 /* ExportDeclaration */:
// import statement without including semicolon
return textSpan(node, node.moduleSpecifier);
case 218 /* ModuleDeclaration */:
// span on complete module if it is instantiated
if (ts.getModuleInstanceState(node) !== 1 /* Instantiated */) {
return undefined;
}
case 214 /* ClassDeclaration */:
case 217 /* EnumDeclaration */:
case 247 /* EnumMember */:
case 168 /* CallExpression */:
case 169 /* NewExpression */:
// span on complete node
return textSpan(node);
case 205 /* WithStatement */:
// span in statement
return spanInNode(node.statement);
// No breakpoint in interface, type alias
case 215 /* InterfaceDeclaration */:
case 216 /* TypeAliasDeclaration */:
return undefined;
// Tokens:
case 23 /* SemicolonToken */:
case 1 /* EndOfFileToken */:
return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile));
case 24 /* CommaToken */:
return spanInPreviousNode(node);
case 15 /* OpenBraceToken */:
return spanInOpenBraceToken(node);
case 16 /* CloseBraceToken */:
return spanInCloseBraceToken(node);
case 17 /* OpenParenToken */:
return spanInOpenParenToken(node);
case 18 /* CloseParenToken */:
return spanInCloseParenToken(node);
case 54 /* ColonToken */:
return spanInColonToken(node);
case 27 /* GreaterThanToken */:
case 25 /* LessThanToken */:
return spanInGreaterThanOrLessThanToken(node);
// Keywords:
case 104 /* WhileKeyword */:
return spanInWhileKeyword(node);
case 80 /* ElseKeyword */:
case 72 /* CatchKeyword */:
case 85 /* FinallyKeyword */:
return spanInNextNode(node);
default:
// If this is name of property assignment, set breakpoint in the initializer
if (node.parent.kind === 245 /* PropertyAssignment */ && node.parent.name === node) {
return spanInNode(node.parent.initializer);
}
// Breakpoint in type assertion goes to its operand
if (node.parent.kind === 171 /* TypeAssertionExpression */ && node.parent.type === node) {
return spanInNode(node.parent.expression);
}
// return type of function go to previous token
if (ts.isFunctionLike(node.parent) && node.parent.type === node) {
return spanInPreviousNode(node);
}
// Default go to parent to set the breakpoint
return spanInNode(node.parent);
}
}
function spanInVariableDeclaration(variableDeclaration) {
// If declaration of for in statement, just set the span in parent
if (variableDeclaration.parent.parent.kind === 200 /* ForInStatement */ ||
variableDeclaration.parent.parent.kind === 201 /* ForOfStatement */) {
return spanInNode(variableDeclaration.parent.parent);
}
var isParentVariableStatement = variableDeclaration.parent.parent.kind === 193 /* VariableStatement */;
var isDeclarationOfForStatement = variableDeclaration.parent.parent.kind === 199 /* ForStatement */ && ts.contains(variableDeclaration.parent.parent.initializer.declarations, variableDeclaration);
var declarations = isParentVariableStatement
? variableDeclaration.parent.parent.declarationList.declarations
: isDeclarationOfForStatement
? variableDeclaration.parent.parent.initializer.declarations
: undefined;
// Breakpoint is possible in variableDeclaration only if there is initialization
if (variableDeclaration.initializer || (variableDeclaration.flags & 2 /* Export */)) {
if (declarations && declarations[0] === variableDeclaration) {
if (isParentVariableStatement) {
// First declaration - include let keyword
return textSpan(variableDeclaration.parent, variableDeclaration);
}
else {
ts.Debug.assert(isDeclarationOfForStatement);
// Include let keyword from for statement declarations in the span
return textSpan(ts.findPrecedingToken(variableDeclaration.pos, sourceFile, variableDeclaration.parent), variableDeclaration);
}
}
else {
// Span only on this declaration
return textSpan(variableDeclaration);
}
}
else if (declarations && declarations[0] !== variableDeclaration) {
// If we cant set breakpoint on this declaration, set it on previous one
var indexOfCurrentDeclaration = ts.indexOf(declarations, variableDeclaration);
return spanInVariableDeclaration(declarations[indexOfCurrentDeclaration - 1]);
}
}
function canHaveSpanInParameterDeclaration(parameter) {
// Breakpoint is possible on parameter only if it has initializer, is a rest parameter, or has public or private modifier
return !!parameter.initializer || parameter.dotDotDotToken !== undefined ||
!!(parameter.flags & 8 /* Public */) || !!(parameter.flags & 16 /* Private */);
}
function spanInParameterDeclaration(parameter) {
if (canHaveSpanInParameterDeclaration(parameter)) {
return textSpan(parameter);
}
else {
var functionDeclaration = parameter.parent;
var indexOfParameter = ts.indexOf(functionDeclaration.parameters, parameter);
if (indexOfParameter) {
// Not a first parameter, go to previous parameter
return spanInParameterDeclaration(functionDeclaration.parameters[indexOfParameter - 1]);
}
else {
// Set breakpoint in the function declaration body
return spanInNode(functionDeclaration.body);
}
}
}
function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) {
return !!(functionDeclaration.flags & 2 /* Export */) ||
(functionDeclaration.parent.kind === 214 /* ClassDeclaration */ && functionDeclaration.kind !== 144 /* Constructor */);
}
function spanInFunctionDeclaration(functionDeclaration) {
// No breakpoints in the function signature
if (!functionDeclaration.body) {
return undefined;
}
if (canFunctionHaveSpanInWholeDeclaration(functionDeclaration)) {
// Set the span on whole function declaration
return textSpan(functionDeclaration);
}
// Set span in function body
return spanInNode(functionDeclaration.body);
}
function spanInFunctionBlock(block) {
var nodeForSpanInBlock = block.statements.length ? block.statements[0] : block.getLastToken();
if (canFunctionHaveSpanInWholeDeclaration(block.parent)) {
return spanInNodeIfStartsOnSameLine(block.parent, nodeForSpanInBlock);
}
return spanInNode(nodeForSpanInBlock);
}
function spanInBlock(block) {
switch (block.parent.kind) {
case 218 /* ModuleDeclaration */:
if (ts.getModuleInstanceState(block.parent) !== 1 /* Instantiated */) {
return undefined;
}
// Set on parent if on same line otherwise on first statement
case 198 /* WhileStatement */:
case 196 /* IfStatement */:
case 200 /* ForInStatement */:
case 201 /* ForOfStatement */:
return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]);
// Set span on previous token if it starts on same line otherwise on the first statement of the block
case 199 /* ForStatement */:
return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(block.pos, sourceFile, block.parent), block.statements[0]);
}
// Default action is to set on first statement
return spanInNode(block.statements[0]);
}
function spanInForStatement(forStatement) {
if (forStatement.initializer) {
if (forStatement.initializer.kind === 212 /* VariableDeclarationList */) {
var variableDeclarationList = forStatement.initializer;
if (variableDeclarationList.declarations.length > 0) {
return spanInNode(variableDeclarationList.declarations[0]);
}
}
else {
return spanInNode(forStatement.initializer);
}
}
if (forStatement.condition) {
return textSpan(forStatement.condition);
}
if (forStatement.incrementor) {
return textSpan(forStatement.incrementor);
}
}
// Tokens:
function spanInOpenBraceToken(node) {
switch (node.parent.kind) {
case 217 /* EnumDeclaration */:
var enumDeclaration = node.parent;
return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile));
case 214 /* ClassDeclaration */:
var classDeclaration = node.parent;
return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile));
case 220 /* CaseBlock */:
return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]);
}
// Default to parent node
return spanInNode(node.parent);
}
function spanInCloseBraceToken(node) {
switch (node.parent.kind) {
case 219 /* ModuleBlock */:
// If this is not instantiated module block no bp span
if (ts.getModuleInstanceState(node.parent.parent) !== 1 /* Instantiated */) {
return undefined;
}
case 217 /* EnumDeclaration */:
case 214 /* ClassDeclaration */:
// Span on close brace token
return textSpan(node);
case 192 /* Block */:
if (ts.isFunctionBlock(node.parent)) {
// Span on close brace token
return textSpan(node);
}
// fall through.
case 244 /* CatchClause */:
return spanInNode(ts.lastOrUndefined(node.parent.statements));
case 220 /* CaseBlock */:
// breakpoint in last statement of the last clause
var caseBlock = node.parent;
var lastClause = ts.lastOrUndefined(caseBlock.clauses);
if (lastClause) {
return spanInNode(ts.lastOrUndefined(lastClause.statements));
}
return undefined;
// Default to parent node
default:
return spanInNode(node.parent);
}
}
function spanInOpenParenToken(node) {
if (node.parent.kind === 197 /* DoStatement */) {
// Go to while keyword and do action instead
return spanInPreviousNode(node);
}
// Default to parent node
return spanInNode(node.parent);
}
function spanInCloseParenToken(node) {
// Is this close paren token of parameter list, set span in previous token
switch (node.parent.kind) {
case 173 /* FunctionExpression */:
case 213 /* FunctionDeclaration */:
case 174 /* ArrowFunction */:
case 143 /* MethodDeclaration */:
case 142 /* MethodSignature */:
case 145 /* GetAccessor */:
case 146 /* SetAccessor */:
case 144 /* Constructor */:
case 198 /* WhileStatement */:
case 197 /* DoStatement */:
case 199 /* ForStatement */:
return spanInPreviousNode(node);
// Default to parent node
default:
return spanInNode(node.parent);
}
}
function spanInColonToken(node) {
// Is this : specifying return annotation of the function declaration
if (ts.isFunctionLike(node.parent) || node.parent.kind === 245 /* PropertyAssignment */) {
return spanInPreviousNode(node);
}
return spanInNode(node.parent);
}
function spanInGreaterThanOrLessThanToken(node) {
if (node.parent.kind === 171 /* TypeAssertionExpression */) {
return spanInNode(node.parent.expression);
}
return spanInNode(node.parent);
}
function spanInWhileKeyword(node) {
if (node.parent.kind === 197 /* DoStatement */) {
// Set span on while expression
return textSpan(node, ts.findNextToken(node.parent.expression, node.parent));
}
// Default to parent node
return spanInNode(node.parent);
}
}
|
Get the breakpoint span in given sourceFile
|
spanInNode
|
javascript
|
amol-/dukpy
|
dukpy/jsmodules/typescriptServices.js
|
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
|
MIT
|
function spanInVariableDeclaration(variableDeclaration) {
// If declaration of for in statement, just set the span in parent
if (variableDeclaration.parent.parent.kind === 200 /* ForInStatement */ ||
variableDeclaration.parent.parent.kind === 201 /* ForOfStatement */) {
return spanInNode(variableDeclaration.parent.parent);
}
var isParentVariableStatement = variableDeclaration.parent.parent.kind === 193 /* VariableStatement */;
var isDeclarationOfForStatement = variableDeclaration.parent.parent.kind === 199 /* ForStatement */ && ts.contains(variableDeclaration.parent.parent.initializer.declarations, variableDeclaration);
var declarations = isParentVariableStatement
? variableDeclaration.parent.parent.declarationList.declarations
: isDeclarationOfForStatement
? variableDeclaration.parent.parent.initializer.declarations
: undefined;
// Breakpoint is possible in variableDeclaration only if there is initialization
if (variableDeclaration.initializer || (variableDeclaration.flags & 2 /* Export */)) {
if (declarations && declarations[0] === variableDeclaration) {
if (isParentVariableStatement) {
// First declaration - include let keyword
return textSpan(variableDeclaration.parent, variableDeclaration);
}
else {
ts.Debug.assert(isDeclarationOfForStatement);
// Include let keyword from for statement declarations in the span
return textSpan(ts.findPrecedingToken(variableDeclaration.pos, sourceFile, variableDeclaration.parent), variableDeclaration);
}
}
else {
// Span only on this declaration
return textSpan(variableDeclaration);
}
}
else if (declarations && declarations[0] !== variableDeclaration) {
// If we cant set breakpoint on this declaration, set it on previous one
var indexOfCurrentDeclaration = ts.indexOf(declarations, variableDeclaration);
return spanInVariableDeclaration(declarations[indexOfCurrentDeclaration - 1]);
}
}
|
Get the breakpoint span in given sourceFile
|
spanInVariableDeclaration
|
javascript
|
amol-/dukpy
|
dukpy/jsmodules/typescriptServices.js
|
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
|
MIT
|
function canHaveSpanInParameterDeclaration(parameter) {
// Breakpoint is possible on parameter only if it has initializer, is a rest parameter, or has public or private modifier
return !!parameter.initializer || parameter.dotDotDotToken !== undefined ||
!!(parameter.flags & 8 /* Public */) || !!(parameter.flags & 16 /* Private */);
}
|
Get the breakpoint span in given sourceFile
|
canHaveSpanInParameterDeclaration
|
javascript
|
amol-/dukpy
|
dukpy/jsmodules/typescriptServices.js
|
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
|
MIT
|
function spanInParameterDeclaration(parameter) {
if (canHaveSpanInParameterDeclaration(parameter)) {
return textSpan(parameter);
}
else {
var functionDeclaration = parameter.parent;
var indexOfParameter = ts.indexOf(functionDeclaration.parameters, parameter);
if (indexOfParameter) {
// Not a first parameter, go to previous parameter
return spanInParameterDeclaration(functionDeclaration.parameters[indexOfParameter - 1]);
}
else {
// Set breakpoint in the function declaration body
return spanInNode(functionDeclaration.body);
}
}
}
|
Get the breakpoint span in given sourceFile
|
spanInParameterDeclaration
|
javascript
|
amol-/dukpy
|
dukpy/jsmodules/typescriptServices.js
|
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
|
MIT
|
function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) {
return !!(functionDeclaration.flags & 2 /* Export */) ||
(functionDeclaration.parent.kind === 214 /* ClassDeclaration */ && functionDeclaration.kind !== 144 /* Constructor */);
}
|
Get the breakpoint span in given sourceFile
|
canFunctionHaveSpanInWholeDeclaration
|
javascript
|
amol-/dukpy
|
dukpy/jsmodules/typescriptServices.js
|
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
|
MIT
|
function spanInFunctionDeclaration(functionDeclaration) {
// No breakpoints in the function signature
if (!functionDeclaration.body) {
return undefined;
}
if (canFunctionHaveSpanInWholeDeclaration(functionDeclaration)) {
// Set the span on whole function declaration
return textSpan(functionDeclaration);
}
// Set span in function body
return spanInNode(functionDeclaration.body);
}
|
Get the breakpoint span in given sourceFile
|
spanInFunctionDeclaration
|
javascript
|
amol-/dukpy
|
dukpy/jsmodules/typescriptServices.js
|
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
|
MIT
|
function spanInFunctionBlock(block) {
var nodeForSpanInBlock = block.statements.length ? block.statements[0] : block.getLastToken();
if (canFunctionHaveSpanInWholeDeclaration(block.parent)) {
return spanInNodeIfStartsOnSameLine(block.parent, nodeForSpanInBlock);
}
return spanInNode(nodeForSpanInBlock);
}
|
Get the breakpoint span in given sourceFile
|
spanInFunctionBlock
|
javascript
|
amol-/dukpy
|
dukpy/jsmodules/typescriptServices.js
|
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
|
MIT
|
function spanInBlock(block) {
switch (block.parent.kind) {
case 218 /* ModuleDeclaration */:
if (ts.getModuleInstanceState(block.parent) !== 1 /* Instantiated */) {
return undefined;
}
// Set on parent if on same line otherwise on first statement
case 198 /* WhileStatement */:
case 196 /* IfStatement */:
case 200 /* ForInStatement */:
case 201 /* ForOfStatement */:
return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]);
// Set span on previous token if it starts on same line otherwise on the first statement of the block
case 199 /* ForStatement */:
return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(block.pos, sourceFile, block.parent), block.statements[0]);
}
// Default action is to set on first statement
return spanInNode(block.statements[0]);
}
|
Get the breakpoint span in given sourceFile
|
spanInBlock
|
javascript
|
amol-/dukpy
|
dukpy/jsmodules/typescriptServices.js
|
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
|
MIT
|
function spanInForStatement(forStatement) {
if (forStatement.initializer) {
if (forStatement.initializer.kind === 212 /* VariableDeclarationList */) {
var variableDeclarationList = forStatement.initializer;
if (variableDeclarationList.declarations.length > 0) {
return spanInNode(variableDeclarationList.declarations[0]);
}
}
else {
return spanInNode(forStatement.initializer);
}
}
if (forStatement.condition) {
return textSpan(forStatement.condition);
}
if (forStatement.incrementor) {
return textSpan(forStatement.incrementor);
}
}
|
Get the breakpoint span in given sourceFile
|
spanInForStatement
|
javascript
|
amol-/dukpy
|
dukpy/jsmodules/typescriptServices.js
|
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
|
MIT
|
function spanInCloseBraceToken(node) {
switch (node.parent.kind) {
case 219 /* ModuleBlock */:
// If this is not instantiated module block no bp span
if (ts.getModuleInstanceState(node.parent.parent) !== 1 /* Instantiated */) {
return undefined;
}
case 217 /* EnumDeclaration */:
case 214 /* ClassDeclaration */:
// Span on close brace token
return textSpan(node);
case 192 /* Block */:
if (ts.isFunctionBlock(node.parent)) {
// Span on close brace token
return textSpan(node);
}
// fall through.
case 244 /* CatchClause */:
return spanInNode(ts.lastOrUndefined(node.parent.statements));
case 220 /* CaseBlock */:
// breakpoint in last statement of the last clause
var caseBlock = node.parent;
var lastClause = ts.lastOrUndefined(caseBlock.clauses);
if (lastClause) {
return spanInNode(ts.lastOrUndefined(lastClause.statements));
}
return undefined;
// Default to parent node
default:
return spanInNode(node.parent);
}
}
|
Get the breakpoint span in given sourceFile
|
spanInCloseBraceToken
|
javascript
|
amol-/dukpy
|
dukpy/jsmodules/typescriptServices.js
|
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
|
MIT
|
function spanInOpenParenToken(node) {
if (node.parent.kind === 197 /* DoStatement */) {
// Go to while keyword and do action instead
return spanInPreviousNode(node);
}
// Default to parent node
return spanInNode(node.parent);
}
|
Get the breakpoint span in given sourceFile
|
spanInOpenParenToken
|
javascript
|
amol-/dukpy
|
dukpy/jsmodules/typescriptServices.js
|
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
|
MIT
|
function spanInCloseParenToken(node) {
// Is this close paren token of parameter list, set span in previous token
switch (node.parent.kind) {
case 173 /* FunctionExpression */:
case 213 /* FunctionDeclaration */:
case 174 /* ArrowFunction */:
case 143 /* MethodDeclaration */:
case 142 /* MethodSignature */:
case 145 /* GetAccessor */:
case 146 /* SetAccessor */:
case 144 /* Constructor */:
case 198 /* WhileStatement */:
case 197 /* DoStatement */:
case 199 /* ForStatement */:
return spanInPreviousNode(node);
// Default to parent node
default:
return spanInNode(node.parent);
}
}
|
Get the breakpoint span in given sourceFile
|
spanInCloseParenToken
|
javascript
|
amol-/dukpy
|
dukpy/jsmodules/typescriptServices.js
|
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
|
MIT
|
function spanInColonToken(node) {
// Is this : specifying return annotation of the function declaration
if (ts.isFunctionLike(node.parent) || node.parent.kind === 245 /* PropertyAssignment */) {
return spanInPreviousNode(node);
}
return spanInNode(node.parent);
}
|
Get the breakpoint span in given sourceFile
|
spanInColonToken
|
javascript
|
amol-/dukpy
|
dukpy/jsmodules/typescriptServices.js
|
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
|
MIT
|
function spanInGreaterThanOrLessThanToken(node) {
if (node.parent.kind === 171 /* TypeAssertionExpression */) {
return spanInNode(node.parent.expression);
}
return spanInNode(node.parent);
}
|
Get the breakpoint span in given sourceFile
|
spanInGreaterThanOrLessThanToken
|
javascript
|
amol-/dukpy
|
dukpy/jsmodules/typescriptServices.js
|
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
|
MIT
|
function spanInWhileKeyword(node) {
if (node.parent.kind === 197 /* DoStatement */) {
// Set span on while expression
return textSpan(node, ts.findNextToken(node.parent.expression, node.parent));
}
// Default to parent node
return spanInNode(node.parent);
}
|
Get the breakpoint span in given sourceFile
|
spanInWhileKeyword
|
javascript
|
amol-/dukpy
|
dukpy/jsmodules/typescriptServices.js
|
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
|
MIT
|
function logInternalError(logger, err) {
if (logger) {
logger.log("*INTERNAL ERROR* - Exception in typescript services: " + err.message);
}
}
|
Get the breakpoint span in given sourceFile
|
logInternalError
|
javascript
|
amol-/dukpy
|
dukpy/jsmodules/typescriptServices.js
|
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
|
MIT
|
function ScriptSnapshotShimAdapter(scriptSnapshotShim) {
this.scriptSnapshotShim = scriptSnapshotShim;
this.lineStartPositions = null;
}
|
Get the breakpoint span in given sourceFile
|
ScriptSnapshotShimAdapter
|
javascript
|
amol-/dukpy
|
dukpy/jsmodules/typescriptServices.js
|
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
|
MIT
|
function LanguageServiceShimHostAdapter(shimHost) {
var _this = this;
this.shimHost = shimHost;
this.loggingEnabled = false;
this.tracingEnabled = false;
// if shimHost is a COM object then property check will become method call with no arguments.
// 'in' does not have this effect.
if ("getModuleResolutionsForFile" in this.shimHost) {
this.resolveModuleNames = function (moduleNames, containingFile) {
var resolutionsInFile = JSON.parse(_this.shimHost.getModuleResolutionsForFile(containingFile));
return ts.map(moduleNames, function (name) {
var result = ts.lookUp(resolutionsInFile, name);
return result ? { resolvedFileName: result } : undefined;
});
};
}
}
|
Get the breakpoint span in given sourceFile
|
LanguageServiceShimHostAdapter
|
javascript
|
amol-/dukpy
|
dukpy/jsmodules/typescriptServices.js
|
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
|
MIT
|
function ThrottledCancellationToken(hostCancellationToken) {
this.hostCancellationToken = hostCancellationToken;
// Store when we last tried to cancel. Checking cancellation can be expensive (as we have
// to marshall over to the host layer). So we only bother actually checking once enough
// time has passed.
this.lastCancellationCheckTime = 0;
}
|
A cancellation that throttles calls to the host
|
ThrottledCancellationToken
|
javascript
|
amol-/dukpy
|
dukpy/jsmodules/typescriptServices.js
|
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
|
MIT
|
function CoreServicesShimHostAdapter(shimHost) {
this.shimHost = shimHost;
}
|
A cancellation that throttles calls to the host
|
CoreServicesShimHostAdapter
|
javascript
|
amol-/dukpy
|
dukpy/jsmodules/typescriptServices.js
|
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
|
MIT
|
function simpleForwardCall(logger, actionDescription, action, logPerformance) {
if (logPerformance) {
logger.log(actionDescription);
var start = Date.now();
}
var result = action();
if (logPerformance) {
var end = Date.now();
logger.log(actionDescription + " completed in " + (end - start) + " msec");
if (typeof (result) === "string") {
var str = result;
if (str.length > 128) {
str = str.substring(0, 128) + "...";
}
logger.log(" result.length=" + str.length + ", result='" + JSON.stringify(str) + "'");
}
}
return result;
}
|
A cancellation that throttles calls to the host
|
simpleForwardCall
|
javascript
|
amol-/dukpy
|
dukpy/jsmodules/typescriptServices.js
|
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
|
MIT
|
function forwardJSONCall(logger, actionDescription, action, logPerformance) {
try {
var result = simpleForwardCall(logger, actionDescription, action, logPerformance);
return JSON.stringify({ result: result });
}
catch (err) {
if (err instanceof ts.OperationCanceledException) {
return JSON.stringify({ canceled: true });
}
logInternalError(logger, err);
err.description = actionDescription;
return JSON.stringify({ error: err });
}
}
|
A cancellation that throttles calls to the host
|
forwardJSONCall
|
javascript
|
amol-/dukpy
|
dukpy/jsmodules/typescriptServices.js
|
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
|
MIT
|
function ShimBase(factory) {
this.factory = factory;
factory.registerShim(this);
}
|
A cancellation that throttles calls to the host
|
ShimBase
|
javascript
|
amol-/dukpy
|
dukpy/jsmodules/typescriptServices.js
|
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
|
MIT
|
function realizeDiagnostics(diagnostics, newLine) {
return diagnostics.map(function (d) { return realizeDiagnostic(d, newLine); });
}
|
A cancellation that throttles calls to the host
|
realizeDiagnostics
|
javascript
|
amol-/dukpy
|
dukpy/jsmodules/typescriptServices.js
|
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
|
MIT
|
function realizeDiagnostic(diagnostic, newLine) {
return {
message: ts.flattenDiagnosticMessageText(diagnostic.messageText, newLine),
start: diagnostic.start,
length: diagnostic.length,
/// TODO: no need for the tolowerCase call
category: ts.DiagnosticCategory[diagnostic.category].toLowerCase(),
code: diagnostic.code
};
}
|
A cancellation that throttles calls to the host
|
realizeDiagnostic
|
javascript
|
amol-/dukpy
|
dukpy/jsmodules/typescriptServices.js
|
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
|
MIT
|
function LanguageServiceShimObject(factory, host, languageService) {
_super.call(this, factory);
this.host = host;
this.languageService = languageService;
this.logPerformance = false;
this.logger = this.host;
}
|
A cancellation that throttles calls to the host
|
LanguageServiceShimObject
|
javascript
|
amol-/dukpy
|
dukpy/jsmodules/typescriptServices.js
|
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
|
MIT
|
function convertClassifications(classifications) {
return { spans: classifications.spans.join(","), endOfLineState: classifications.endOfLineState };
}
|
Return a list of symbols that are interesting to navigate to
|
convertClassifications
|
javascript
|
amol-/dukpy
|
dukpy/jsmodules/typescriptServices.js
|
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
|
MIT
|
function ClassifierShimObject(factory, logger) {
_super.call(this, factory);
this.logger = logger;
this.logPerformance = false;
this.classifier = ts.createClassifier();
}
|
Return a list of symbols that are interesting to navigate to
|
ClassifierShimObject
|
javascript
|
amol-/dukpy
|
dukpy/jsmodules/typescriptServices.js
|
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
|
MIT
|
function CoreServicesShimObject(factory, logger, host) {
_super.call(this, factory);
this.logger = logger;
this.host = host;
this.logPerformance = false;
}
|
Return a list of symbols that are interesting to navigate to
|
CoreServicesShimObject
|
javascript
|
amol-/dukpy
|
dukpy/jsmodules/typescriptServices.js
|
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
|
MIT
|
function TypeScriptServicesFactory() {
this._shims = [];
}
|
Return a list of symbols that are interesting to navigate to
|
TypeScriptServicesFactory
|
javascript
|
amol-/dukpy
|
dukpy/jsmodules/typescriptServices.js
|
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/typescriptServices.js
|
MIT
|
fileParsedFunc = function (e, root, fullPath) {
importManager.queue.splice(importManager.queue.indexOf(path), 1); // Remove the path from the queue
var importedEqualsRoot = fullPath === importManager.rootFilename;
if (importOptions.optional && e) {
callback(null, {rules:[]}, false, null);
}
else {
importManager.files[fullPath] = root;
if (e && !importManager.error) { importManager.error = e; }
callback(e, root, importedEqualsRoot, fullPath);
}
}
|
Add an import to be imported
@param path - the raw path
@param tryAppendLessExtension - whether to try appending the less extension (if the path has no extension)
@param currentFileInfo - the current file info (used for instance to work out relative paths)
@param importOptions - import options
@param callback - callback for when it is imported
|
fileParsedFunc
|
javascript
|
amol-/dukpy
|
dukpy/jsmodules/less/less/import-manager.js
|
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/less/less/import-manager.js
|
MIT
|
loadFileCallback = function(loadedFile) {
var resolvedFilename = loadedFile.filename,
contents = loadedFile.contents.replace(/^\uFEFF/, '');
// Pass on an updated rootpath if path of imported file is relative and file
// is in a (sub|sup) directory
//
// Examples:
// - If path of imported file is 'module/nav/nav.less' and rootpath is 'less/',
// then rootpath should become 'less/module/nav/'
// - If path of imported file is '../mixins.less' and rootpath is 'less/',
// then rootpath should become 'less/../'
newFileInfo.currentDirectory = fileManager.getPath(resolvedFilename);
if (newFileInfo.relativeUrls) {
newFileInfo.rootpath = fileManager.join(
(importManager.context.rootpath || ""),
fileManager.pathDiff(newFileInfo.currentDirectory, newFileInfo.entryPath));
if (!fileManager.isPathAbsolute(newFileInfo.rootpath) && fileManager.alwaysMakePathsAbsolute()) {
newFileInfo.rootpath = fileManager.join(newFileInfo.entryPath, newFileInfo.rootpath);
}
}
newFileInfo.filename = resolvedFilename;
var newEnv = new contexts.Parse(importManager.context);
newEnv.processImports = false;
importManager.contents[resolvedFilename] = contents;
if (currentFileInfo.reference || importOptions.reference) {
newFileInfo.reference = true;
}
if (importOptions.plugin) {
new FunctionImporter(newEnv, newFileInfo).eval(contents, function (e, root) {
fileParsedFunc(e, root, resolvedFilename);
});
} else if (importOptions.inline) {
fileParsedFunc(null, contents, resolvedFilename);
} else {
new Parser(newEnv, importManager, newFileInfo).parse(contents, function (e, root) {
fileParsedFunc(e, root, resolvedFilename);
});
}
}
|
Add an import to be imported
@param path - the raw path
@param tryAppendLessExtension - whether to try appending the less extension (if the path has no extension)
@param currentFileInfo - the current file info (used for instance to work out relative paths)
@param importOptions - import options
@param callback - callback for when it is imported
|
loadFileCallback
|
javascript
|
amol-/dukpy
|
dukpy/jsmodules/less/less/import-manager.js
|
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/less/less/import-manager.js
|
MIT
|
function isPresto() {
var opera = window.opera;
return typeof opera === 'object' && typeof opera.version === 'function' && parseInt(opera.version(), 10) <= 12;
}
|
Opera <= 12 includes TextEvent in window, but does not fire
text input events. Rely on keypress instead.
|
isPresto
|
javascript
|
amol-/dukpy
|
dukpy/jsmodules/react/react.js
|
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/react/react.js
|
MIT
|
function isKeypressCommand(nativeEvent) {
return (nativeEvent.ctrlKey || nativeEvent.altKey || nativeEvent.metaKey) &&
// ctrlKey && altKey is equivalent to AltGr, and is not a command.
!(nativeEvent.ctrlKey && nativeEvent.altKey);
}
|
Return whether a native keypress event is assumed to be a command.
This is required because Firefox fires `keypress` events for key commands
(cut, copy, select-all, etc.) even though no character is inserted.
|
isKeypressCommand
|
javascript
|
amol-/dukpy
|
dukpy/jsmodules/react/react.js
|
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/react/react.js
|
MIT
|
function getCompositionEventType(topLevelType) {
switch (topLevelType) {
case topLevelTypes.topCompositionStart:
return eventTypes.compositionStart;
case topLevelTypes.topCompositionEnd:
return eventTypes.compositionEnd;
case topLevelTypes.topCompositionUpdate:
return eventTypes.compositionUpdate;
}
}
|
Translate native top level events into event types.
@param {string} topLevelType
@return {object}
|
getCompositionEventType
|
javascript
|
amol-/dukpy
|
dukpy/jsmodules/react/react.js
|
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/react/react.js
|
MIT
|
function isFallbackCompositionStart(topLevelType, nativeEvent) {
return topLevelType === topLevelTypes.topKeyDown && nativeEvent.keyCode === START_KEYCODE;
}
|
Does our fallback best-guess model think this event signifies that
composition has begun?
@param {string} topLevelType
@param {object} nativeEvent
@return {boolean}
|
isFallbackCompositionStart
|
javascript
|
amol-/dukpy
|
dukpy/jsmodules/react/react.js
|
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/react/react.js
|
MIT
|
function isFallbackCompositionEnd(topLevelType, nativeEvent) {
switch (topLevelType) {
case topLevelTypes.topKeyUp:
// Command keys insert or clear IME input.
return END_KEYCODES.indexOf(nativeEvent.keyCode) !== -1;
case topLevelTypes.topKeyDown:
// Expect IME keyCode on each keydown. If we get any other
// code we must have exited earlier.
return nativeEvent.keyCode !== START_KEYCODE;
case topLevelTypes.topKeyPress:
case topLevelTypes.topMouseDown:
case topLevelTypes.topBlur:
// Events are not possible without cancelling IME.
return true;
default:
return false;
}
}
|
Does our fallback mode think that this event is the end of composition?
@param {string} topLevelType
@param {object} nativeEvent
@return {boolean}
|
isFallbackCompositionEnd
|
javascript
|
amol-/dukpy
|
dukpy/jsmodules/react/react.js
|
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/react/react.js
|
MIT
|
function getDataFromCustomEvent(nativeEvent) {
var detail = nativeEvent.detail;
if (typeof detail === 'object' && 'data' in detail) {
return detail.data;
}
return null;
}
|
Google Input Tools provides composition data via a CustomEvent,
with the `data` property populated in the `detail` object. If this
is available on the event object, use it. If not, this is a plain
composition event and we have nothing special to extract.
@param {object} nativeEvent
@return {?string}
|
getDataFromCustomEvent
|
javascript
|
amol-/dukpy
|
dukpy/jsmodules/react/react.js
|
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/react/react.js
|
MIT
|
function extractCompositionEvent(topLevelType, topLevelTarget, topLevelTargetID, nativeEvent, nativeEventTarget) {
var eventType;
var fallbackData;
if (canUseCompositionEvent) {
eventType = getCompositionEventType(topLevelType);
} else if (!currentComposition) {
if (isFallbackCompositionStart(topLevelType, nativeEvent)) {
eventType = eventTypes.compositionStart;
}
} else if (isFallbackCompositionEnd(topLevelType, nativeEvent)) {
eventType = eventTypes.compositionEnd;
}
if (!eventType) {
return null;
}
if (useFallbackCompositionData) {
// The current composition is stored statically and must not be
// overwritten while composition continues.
if (!currentComposition && eventType === eventTypes.compositionStart) {
currentComposition = FallbackCompositionState.getPooled(topLevelTarget);
} else if (eventType === eventTypes.compositionEnd) {
if (currentComposition) {
fallbackData = currentComposition.getData();
}
}
}
var event = SyntheticCompositionEvent.getPooled(eventType, topLevelTargetID, nativeEvent, nativeEventTarget);
if (fallbackData) {
// Inject data generated from fallback path into the synthetic event.
// This matches the property of native CompositionEventInterface.
event.data = fallbackData;
} else {
var customData = getDataFromCustomEvent(nativeEvent);
if (customData !== null) {
event.data = customData;
}
}
EventPropagators.accumulateTwoPhaseDispatches(event);
return event;
}
|
@param {string} topLevelType Record from `EventConstants`.
@param {DOMEventTarget} topLevelTarget The listening component root node.
@param {string} topLevelTargetID ID of `topLevelTarget`.
@param {object} nativeEvent Native browser event.
@return {?object} A SyntheticCompositionEvent.
|
extractCompositionEvent
|
javascript
|
amol-/dukpy
|
dukpy/jsmodules/react/react.js
|
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/react/react.js
|
MIT
|
function getNativeBeforeInputChars(topLevelType, nativeEvent) {
switch (topLevelType) {
case topLevelTypes.topCompositionEnd:
return getDataFromCustomEvent(nativeEvent);
case topLevelTypes.topKeyPress:
/**
* If native `textInput` events are available, our goal is to make
* use of them. However, there is a special case: the spacebar key.
* In Webkit, preventing default on a spacebar `textInput` event
* cancels character insertion, but it *also* causes the browser
* to fall back to its default spacebar behavior of scrolling the
* page.
*
* Tracking at:
* https://code.google.com/p/chromium/issues/detail?id=355103
*
* To avoid this issue, use the keypress event as if no `textInput`
* event is available.
*/
var which = nativeEvent.which;
if (which !== SPACEBAR_CODE) {
return null;
}
hasSpaceKeypress = true;
return SPACEBAR_CHAR;
case topLevelTypes.topTextInput:
// Record the characters to be added to the DOM.
var chars = nativeEvent.data;
// If it's a spacebar character, assume that we have already handled
// it at the keypress level and bail immediately. Android Chrome
// doesn't give us keycodes, so we need to blacklist it.
if (chars === SPACEBAR_CHAR && hasSpaceKeypress) {
return null;
}
return chars;
default:
// For other native event types, do nothing.
return null;
}
}
|
@param {string} topLevelType Record from `EventConstants`.
@param {object} nativeEvent Native browser event.
@return {?string} The string corresponding to this `beforeInput` event.
|
getNativeBeforeInputChars
|
javascript
|
amol-/dukpy
|
dukpy/jsmodules/react/react.js
|
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/react/react.js
|
MIT
|
function getFallbackBeforeInputChars(topLevelType, nativeEvent) {
// If we are currently composing (IME) and using a fallback to do so,
// try to extract the composed characters from the fallback object.
if (currentComposition) {
if (topLevelType === topLevelTypes.topCompositionEnd || isFallbackCompositionEnd(topLevelType, nativeEvent)) {
var chars = currentComposition.getData();
FallbackCompositionState.release(currentComposition);
currentComposition = null;
return chars;
}
return null;
}
switch (topLevelType) {
case topLevelTypes.topPaste:
// If a paste event occurs after a keypress, throw out the input
// chars. Paste events should not lead to BeforeInput events.
return null;
case topLevelTypes.topKeyPress:
/**
* As of v27, Firefox may fire keypress events even when no character
* will be inserted. A few possibilities:
*
* - `which` is `0`. Arrow keys, Esc key, etc.
*
* - `which` is the pressed key code, but no char is available.
* Ex: 'AltGr + d` in Polish. There is no modified character for
* this key combination and no character is inserted into the
* document, but FF fires the keypress for char code `100` anyway.
* No `input` event will occur.
*
* - `which` is the pressed key code, but a command combination is
* being used. Ex: `Cmd+C`. No character is inserted, and no
* `input` event will occur.
*/
if (nativeEvent.which && !isKeypressCommand(nativeEvent)) {
return String.fromCharCode(nativeEvent.which);
}
return null;
case topLevelTypes.topCompositionEnd:
return useFallbackCompositionData ? null : nativeEvent.data;
default:
return null;
}
}
|
For browsers that do not provide the `textInput` event, extract the
appropriate string to use for SyntheticInputEvent.
@param {string} topLevelType Record from `EventConstants`.
@param {object} nativeEvent Native browser event.
@return {?string} The fallback string for this `beforeInput` event.
|
getFallbackBeforeInputChars
|
javascript
|
amol-/dukpy
|
dukpy/jsmodules/react/react.js
|
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/react/react.js
|
MIT
|
function extractBeforeInputEvent(topLevelType, topLevelTarget, topLevelTargetID, nativeEvent, nativeEventTarget) {
var chars;
if (canUseTextInputEvent) {
chars = getNativeBeforeInputChars(topLevelType, nativeEvent);
} else {
chars = getFallbackBeforeInputChars(topLevelType, nativeEvent);
}
// If no characters are being inserted, no BeforeInput event should
// be fired.
if (!chars) {
return null;
}
var event = SyntheticInputEvent.getPooled(eventTypes.beforeInput, topLevelTargetID, nativeEvent, nativeEventTarget);
event.data = chars;
EventPropagators.accumulateTwoPhaseDispatches(event);
return event;
}
|
Extract a SyntheticInputEvent for `beforeInput`, based on either native
`textInput` or fallback behavior.
@param {string} topLevelType Record from `EventConstants`.
@param {DOMEventTarget} topLevelTarget The listening component root node.
@param {string} topLevelTargetID ID of `topLevelTarget`.
@param {object} nativeEvent Native browser event.
@return {?object} A SyntheticInputEvent.
|
extractBeforeInputEvent
|
javascript
|
amol-/dukpy
|
dukpy/jsmodules/react/react.js
|
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/react/react.js
|
MIT
|
function prefixKey(prefix, key) {
return prefix + key.charAt(0).toUpperCase() + key.substring(1);
}
|
@param {string} prefix vendor-specific prefix, eg: Webkit
@param {string} key style name, eg: transitionDuration
@return {string} style name prefixed with `prefix`, properly camelCased, eg:
WebkitTransitionDuration
|
prefixKey
|
javascript
|
amol-/dukpy
|
dukpy/jsmodules/react/react.js
|
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/react/react.js
|
MIT
|
function CallbackQueue() {
this._callbacks = null;
this._contexts = null;
}
|
A specialized pseudo-event module to help keep track of components waiting to
be notified when their DOM representations are available for use.
This implements `PooledClass`, so you should never need to instantiate this.
Instead, use `CallbackQueue.getPooled()`.
@class ReactMountReady
@implements PooledClass
@internal
|
CallbackQueue
|
javascript
|
amol-/dukpy
|
dukpy/jsmodules/react/react.js
|
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/react/react.js
|
MIT
|
function startWatchingForValueChange(target, targetID) {
activeElement = target;
activeElementID = targetID;
activeElementValue = target.value;
activeElementValueProp = Object.getOwnPropertyDescriptor(target.constructor.prototype, 'value');
// Not guarded in a canDefineProperty check: IE8 supports defineProperty only
// on DOM elements
Object.defineProperty(activeElement, 'value', newValueProp);
activeElement.attachEvent('onpropertychange', handlePropertyChange);
}
|
(For old IE.) Starts tracking propertychange events on the passed-in element
and override the value property so that we can distinguish user events from
value changes in JS.
|
startWatchingForValueChange
|
javascript
|
amol-/dukpy
|
dukpy/jsmodules/react/react.js
|
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/react/react.js
|
MIT
|
function stopWatchingForValueChange() {
if (!activeElement) {
return;
}
// delete restores the original property definition
delete activeElement.value;
activeElement.detachEvent('onpropertychange', handlePropertyChange);
activeElement = null;
activeElementID = null;
activeElementValue = null;
activeElementValueProp = null;
}
|
(For old IE.) Removes the event listeners from the currently-tracked element,
if any exists.
|
stopWatchingForValueChange
|
javascript
|
amol-/dukpy
|
dukpy/jsmodules/react/react.js
|
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/react/react.js
|
MIT
|
function handlePropertyChange(nativeEvent) {
if (nativeEvent.propertyName !== 'value') {
return;
}
var value = nativeEvent.srcElement.value;
if (value === activeElementValue) {
return;
}
activeElementValue = value;
manualDispatchChangeEvent(nativeEvent);
}
|
(For old IE.) Handles a propertychange event, sending a `change` event if
the value of the active element has changed.
|
handlePropertyChange
|
javascript
|
amol-/dukpy
|
dukpy/jsmodules/react/react.js
|
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/react/react.js
|
MIT
|
function getTargetIDForInputEvent(topLevelType, topLevelTarget, topLevelTargetID) {
if (topLevelType === topLevelTypes.topInput) {
// In modern browsers (i.e., not IE8 or IE9), the input event is exactly
// what we want so fall through here and trigger an abstract event
return topLevelTargetID;
}
}
|
If a `change` event should be fired, returns the target's ID.
|
getTargetIDForInputEvent
|
javascript
|
amol-/dukpy
|
dukpy/jsmodules/react/react.js
|
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/react/react.js
|
MIT
|
function handleEventsForInputEventIE(topLevelType, topLevelTarget, topLevelTargetID) {
if (topLevelType === topLevelTypes.topFocus) {
// In IE8, we can capture almost all .value changes by adding a
// propertychange handler and looking for events with propertyName
// equal to 'value'
// In IE9, propertychange fires for most input events but is buggy and
// doesn't fire when text is deleted, but conveniently, selectionchange
// appears to fire in all of the remaining cases so we catch those and
// forward the event if the value has changed
// In either case, we don't want to call the event handler if the value
// is changed from JS so we redefine a setter for `.value` that updates
// our activeElementValue variable, allowing us to ignore those changes
//
// stopWatching() should be a noop here but we call it just in case we
// missed a blur event somehow.
stopWatchingForValueChange();
startWatchingForValueChange(topLevelTarget, topLevelTargetID);
} else if (topLevelType === topLevelTypes.topBlur) {
stopWatchingForValueChange();
}
}
|
If a `change` event should be fired, returns the target's ID.
|
handleEventsForInputEventIE
|
javascript
|
amol-/dukpy
|
dukpy/jsmodules/react/react.js
|
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/react/react.js
|
MIT
|
function getTargetIDForInputEventIE(topLevelType, topLevelTarget, topLevelTargetID) {
if (topLevelType === topLevelTypes.topSelectionChange || topLevelType === topLevelTypes.topKeyUp || topLevelType === topLevelTypes.topKeyDown) {
// On the selectionchange event, the target is just document which isn't
// helpful for us so just check activeElement instead.
//
// 99% of the time, keydown and keyup aren't necessary. IE8 fails to fire
// propertychange on the first input event after setting `value` from a
// script and fires only keydown, keypress, keyup. Catching keyup usually
// gets it and catching keydown lets us fire an event for the first
// keystroke if user does a key repeat (it'll be a little delayed: right
// before the second keystroke). Other input methods (e.g., paste) seem to
// fire selectionchange normally.
if (activeElement && activeElement.value !== activeElementValue) {
activeElementValue = activeElement.value;
return activeElementID;
}
}
}
|
If a `change` event should be fired, returns the target's ID.
|
getTargetIDForInputEventIE
|
javascript
|
amol-/dukpy
|
dukpy/jsmodules/react/react.js
|
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/react/react.js
|
MIT
|
function insertChildAt(parentNode, childNode, index) {
// By exploiting arrays returning `undefined` for an undefined index, we can
// rely exclusively on `insertBefore(node, null)` instead of also using
// `appendChild(node)`. However, using `undefined` is not allowed by all
// browsers so we must replace it with `null`.
// fix render order error in safari
// IE8 will throw error when index out of list size.
var beforeChild = index >= parentNode.childNodes.length ? null : parentNode.childNodes.item(index);
parentNode.insertBefore(childNode, beforeChild);
}
|
Inserts `childNode` as a child of `parentNode` at the `index`.
@param {DOMElement} parentNode Parent node in which to insert.
@param {DOMElement} childNode Child node to insert.
@param {number} index Index at which to insert the child.
@internal
|
insertChildAt
|
javascript
|
amol-/dukpy
|
dukpy/jsmodules/react/react.js
|
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/react/react.js
|
MIT
|
function getNodeName(markup) {
return markup.substring(1, markup.indexOf(' '));
}
|
Extracts the `nodeName` from a string of markup.
NOTE: Extracting the `nodeName` does not require a regular expression match
because we make assumptions about React-generated markup (i.e. there are no
spaces surrounding the opening tag and there is at least one attribute).
@param {string} markup String of markup.
@return {string} Node name of the supplied markup.
@see http://jsperf.com/extract-nodename
|
getNodeName
|
javascript
|
amol-/dukpy
|
dukpy/jsmodules/react/react.js
|
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/react/react.js
|
MIT
|
executeDispatchesAndRelease = function (event, simulated) {
if (event) {
EventPluginUtils.executeDispatchesInOrder(event, simulated);
if (!event.isPersistent()) {
event.constructor.release(event);
}
}
}
|
Dispatches an event and releases it back into the pool, unless persistent.
@param {?object} event Synthetic event to be dispatched.
@param {boolean} simulated If the event is simulated (changes exn behavior)
@private
|
executeDispatchesAndRelease
|
javascript
|
amol-/dukpy
|
dukpy/jsmodules/react/react.js
|
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/react/react.js
|
MIT
|
executeDispatchesAndReleaseSimulated = function (e) {
return executeDispatchesAndRelease(e, true);
}
|
Dispatches an event and releases it back into the pool, unless persistent.
@param {?object} event Synthetic event to be dispatched.
@param {boolean} simulated If the event is simulated (changes exn behavior)
@private
|
executeDispatchesAndReleaseSimulated
|
javascript
|
amol-/dukpy
|
dukpy/jsmodules/react/react.js
|
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/react/react.js
|
MIT
|
executeDispatchesAndReleaseTopLevel = function (e) {
return executeDispatchesAndRelease(e, false);
}
|
Dispatches an event and releases it back into the pool, unless persistent.
@param {?object} event Synthetic event to be dispatched.
@param {boolean} simulated If the event is simulated (changes exn behavior)
@private
|
executeDispatchesAndReleaseTopLevel
|
javascript
|
amol-/dukpy
|
dukpy/jsmodules/react/react.js
|
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/react/react.js
|
MIT
|
function validateInstanceHandle() {
var valid = InstanceHandle && InstanceHandle.traverseTwoPhase && InstanceHandle.traverseEnterLeave;
"development" !== 'production' ? warning(valid, 'InstanceHandle not injected before use!') : undefined;
}
|
- `InstanceHandle`: [required] Module that performs logical traversals of DOM
hierarchy given ids of the logical DOM elements involved.
|
validateInstanceHandle
|
javascript
|
amol-/dukpy
|
dukpy/jsmodules/react/react.js
|
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/react/react.js
|
MIT
|
function recomputePluginOrdering() {
if (!EventPluginOrder) {
// Wait until an `EventPluginOrder` is injected.
return;
}
for (var pluginName in namesToPlugins) {
var PluginModule = namesToPlugins[pluginName];
var pluginIndex = EventPluginOrder.indexOf(pluginName);
!(pluginIndex > -1) ? "development" !== 'production' ? invariant(false, 'EventPluginRegistry: Cannot inject event plugins that do not exist in ' + 'the plugin ordering, `%s`.', pluginName) : invariant(false) : undefined;
if (EventPluginRegistry.plugins[pluginIndex]) {
continue;
}
!PluginModule.extractEvents ? "development" !== 'production' ? invariant(false, 'EventPluginRegistry: Event plugins must implement an `extractEvents` ' + 'method, but `%s` does not.', pluginName) : invariant(false) : undefined;
EventPluginRegistry.plugins[pluginIndex] = PluginModule;
var publishedEvents = PluginModule.eventTypes;
for (var eventName in publishedEvents) {
!publishEventForPlugin(publishedEvents[eventName], PluginModule, eventName) ? "development" !== 'production' ? invariant(false, 'EventPluginRegistry: Failed to publish event `%s` for plugin `%s`.', eventName, pluginName) : invariant(false) : undefined;
}
}
}
|
Recomputes the plugin list using the injected plugins and plugin ordering.
@private
|
recomputePluginOrdering
|
javascript
|
amol-/dukpy
|
dukpy/jsmodules/react/react.js
|
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/react/react.js
|
MIT
|
function publishEventForPlugin(dispatchConfig, PluginModule, eventName) {
!!EventPluginRegistry.eventNameDispatchConfigs.hasOwnProperty(eventName) ? "development" !== 'production' ? invariant(false, 'EventPluginHub: More than one plugin attempted to publish the same ' + 'event name, `%s`.', eventName) : invariant(false) : undefined;
EventPluginRegistry.eventNameDispatchConfigs[eventName] = dispatchConfig;
var phasedRegistrationNames = dispatchConfig.phasedRegistrationNames;
if (phasedRegistrationNames) {
for (var phaseName in phasedRegistrationNames) {
if (phasedRegistrationNames.hasOwnProperty(phaseName)) {
var phasedRegistrationName = phasedRegistrationNames[phaseName];
publishRegistrationName(phasedRegistrationName, PluginModule, eventName);
}
}
return true;
} else if (dispatchConfig.registrationName) {
publishRegistrationName(dispatchConfig.registrationName, PluginModule, eventName);
return true;
}
return false;
}
|
Publishes an event so that it can be dispatched by the supplied plugin.
@param {object} dispatchConfig Dispatch configuration for the event.
@param {object} PluginModule Plugin publishing the event.
@return {boolean} True if the event was successfully published.
@private
|
publishEventForPlugin
|
javascript
|
amol-/dukpy
|
dukpy/jsmodules/react/react.js
|
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/react/react.js
|
MIT
|
function publishRegistrationName(registrationName, PluginModule, eventName) {
!!EventPluginRegistry.registrationNameModules[registrationName] ? "development" !== 'production' ? invariant(false, 'EventPluginHub: More than one plugin attempted to publish the same ' + 'registration name, `%s`.', registrationName) : invariant(false) : undefined;
EventPluginRegistry.registrationNameModules[registrationName] = PluginModule;
EventPluginRegistry.registrationNameDependencies[registrationName] = PluginModule.eventTypes[eventName].dependencies;
}
|
Publishes a registration name that is used to identify dispatched events and
can be used with `EventPluginHub.putListener` to register listeners.
@param {string} registrationName Registration name to add.
@param {object} PluginModule Plugin publishing the event.
@private
|
publishRegistrationName
|
javascript
|
amol-/dukpy
|
dukpy/jsmodules/react/react.js
|
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/react/react.js
|
MIT
|
function isEndish(topLevelType) {
return topLevelType === topLevelTypes.topMouseUp || topLevelType === topLevelTypes.topTouchEnd || topLevelType === topLevelTypes.topTouchCancel;
}
|
- `Mount`: [required] Module that can convert between React dom IDs and
actual node references.
|
isEndish
|
javascript
|
amol-/dukpy
|
dukpy/jsmodules/react/react.js
|
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/react/react.js
|
MIT
|
function isMoveish(topLevelType) {
return topLevelType === topLevelTypes.topMouseMove || topLevelType === topLevelTypes.topTouchMove;
}
|
- `Mount`: [required] Module that can convert between React dom IDs and
actual node references.
|
isMoveish
|
javascript
|
amol-/dukpy
|
dukpy/jsmodules/react/react.js
|
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/react/react.js
|
MIT
|
function isStartish(topLevelType) {
return topLevelType === topLevelTypes.topMouseDown || topLevelType === topLevelTypes.topTouchStart;
}
|
- `Mount`: [required] Module that can convert between React dom IDs and
actual node references.
|
isStartish
|
javascript
|
amol-/dukpy
|
dukpy/jsmodules/react/react.js
|
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/react/react.js
|
MIT
|
function executeDispatch(event, simulated, listener, domID) {
var type = event.type || 'unknown-event';
event.currentTarget = injection.Mount.getNode(domID);
if (simulated) {
ReactErrorUtils.invokeGuardedCallbackWithCatch(type, listener, event, domID);
} else {
ReactErrorUtils.invokeGuardedCallback(type, listener, event, domID);
}
event.currentTarget = null;
}
|
Dispatch the event to the listener.
@param {SyntheticEvent} event SyntheticEvent to handle
@param {boolean} simulated If the event is simulated (changes exn behavior)
@param {function} listener Application-level callback
@param {string} domID DOM id to pass to the callback.
|
executeDispatch
|
javascript
|
amol-/dukpy
|
dukpy/jsmodules/react/react.js
|
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/react/react.js
|
MIT
|
function executeDispatchesInOrder(event, simulated) {
var dispatchListeners = event._dispatchListeners;
var dispatchIDs = event._dispatchIDs;
if ("development" !== 'production') {
validateEventDispatches(event);
}
if (Array.isArray(dispatchListeners)) {
for (var i = 0; i < dispatchListeners.length; i++) {
if (event.isPropagationStopped()) {
break;
}
// Listeners and IDs are two parallel arrays that are always in sync.
executeDispatch(event, simulated, dispatchListeners[i], dispatchIDs[i]);
}
} else if (dispatchListeners) {
executeDispatch(event, simulated, dispatchListeners, dispatchIDs);
}
event._dispatchListeners = null;
event._dispatchIDs = null;
}
|
Standard/simple iteration through an event's collected dispatches.
|
executeDispatchesInOrder
|
javascript
|
amol-/dukpy
|
dukpy/jsmodules/react/react.js
|
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/react/react.js
|
MIT
|
function executeDispatchesInOrderStopAtTrueImpl(event) {
var dispatchListeners = event._dispatchListeners;
var dispatchIDs = event._dispatchIDs;
if ("development" !== 'production') {
validateEventDispatches(event);
}
if (Array.isArray(dispatchListeners)) {
for (var i = 0; i < dispatchListeners.length; i++) {
if (event.isPropagationStopped()) {
break;
}
// Listeners and IDs are two parallel arrays that are always in sync.
if (dispatchListeners[i](event, dispatchIDs[i])) {
return dispatchIDs[i];
}
}
} else if (dispatchListeners) {
if (dispatchListeners(event, dispatchIDs)) {
return dispatchIDs;
}
}
return null;
}
|
Standard/simple iteration through an event's collected dispatches, but stops
at the first dispatch execution returning true, and returns that id.
@return {?string} id of the first dispatch execution who's listener returns
true, or null if no listener returned true.
|
executeDispatchesInOrderStopAtTrueImpl
|
javascript
|
amol-/dukpy
|
dukpy/jsmodules/react/react.js
|
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/react/react.js
|
MIT
|
function executeDirectDispatch(event) {
if ("development" !== 'production') {
validateEventDispatches(event);
}
var dispatchListener = event._dispatchListeners;
var dispatchID = event._dispatchIDs;
!!Array.isArray(dispatchListener) ? "development" !== 'production' ? invariant(false, 'executeDirectDispatch(...): Invalid `event`.') : invariant(false) : undefined;
var res = dispatchListener ? dispatchListener(event, dispatchID) : null;
event._dispatchListeners = null;
event._dispatchIDs = null;
return res;
}
|
Execution of a "direct" dispatch - there must be at most one dispatch
accumulated on the event or it is considered an error. It doesn't really make
sense for an event with multiple dispatches (bubbled) to keep track of the
return values at each dispatch execution, but it does tend to make sense when
dealing with "direct" dispatches.
@return {*} The return value of executing the single dispatch.
|
executeDirectDispatch
|
javascript
|
amol-/dukpy
|
dukpy/jsmodules/react/react.js
|
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/react/react.js
|
MIT
|
function hasDispatches(event) {
return !!event._dispatchListeners;
}
|
@param {SyntheticEvent} event
@return {boolean} True iff number of dispatches accumulated is greater than 0.
|
hasDispatches
|
javascript
|
amol-/dukpy
|
dukpy/jsmodules/react/react.js
|
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/react/react.js
|
MIT
|
function listenerAtPhase(id, event, propagationPhase) {
var registrationName = event.dispatchConfig.phasedRegistrationNames[propagationPhase];
return getListener(id, registrationName);
}
|
Some event types have a notion of different registration names for different
"phases" of propagation. This finds listeners by a given phase.
|
listenerAtPhase
|
javascript
|
amol-/dukpy
|
dukpy/jsmodules/react/react.js
|
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/react/react.js
|
MIT
|
function accumulateDirectionalDispatches(domID, upwards, event) {
if ("development" !== 'production') {
"development" !== 'production' ? warning(domID, 'Dispatching id must not be null') : undefined;
}
var phase = upwards ? PropagationPhases.bubbled : PropagationPhases.captured;
var listener = listenerAtPhase(domID, event, phase);
if (listener) {
event._dispatchListeners = accumulateInto(event._dispatchListeners, listener);
event._dispatchIDs = accumulateInto(event._dispatchIDs, domID);
}
}
|
Tags a `SyntheticEvent` with dispatched listeners. Creating this function
here, allows us to not have to bind or create functions for each event.
Mutating the event's members allows us to not have to create a wrapping
"dispatch" object that pairs the event with the listener.
|
accumulateDirectionalDispatches
|
javascript
|
amol-/dukpy
|
dukpy/jsmodules/react/react.js
|
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/react/react.js
|
MIT
|
function accumulateTwoPhaseDispatchesSingle(event) {
if (event && event.dispatchConfig.phasedRegistrationNames) {
EventPluginHub.injection.getInstanceHandle().traverseTwoPhase(event.dispatchMarker, accumulateDirectionalDispatches, event);
}
}
|
Collect dispatches (must be entirely collected before dispatching - see unit
tests). Lazily allocate the array to conserve memory. We must loop through
each event and perform the traversal for each one. We cannot perform a
single traversal for the entire collection of events because each event may
have a different target.
|
accumulateTwoPhaseDispatchesSingle
|
javascript
|
amol-/dukpy
|
dukpy/jsmodules/react/react.js
|
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/react/react.js
|
MIT
|
function accumulateTwoPhaseDispatchesSingleSkipTarget(event) {
if (event && event.dispatchConfig.phasedRegistrationNames) {
EventPluginHub.injection.getInstanceHandle().traverseTwoPhaseSkipTarget(event.dispatchMarker, accumulateDirectionalDispatches, event);
}
}
|
Same as `accumulateTwoPhaseDispatchesSingle`, but skips over the targetID.
|
accumulateTwoPhaseDispatchesSingleSkipTarget
|
javascript
|
amol-/dukpy
|
dukpy/jsmodules/react/react.js
|
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/react/react.js
|
MIT
|
function accumulateDispatches(id, ignoredDirection, event) {
if (event && event.dispatchConfig.registrationName) {
var registrationName = event.dispatchConfig.registrationName;
var listener = getListener(id, registrationName);
if (listener) {
event._dispatchListeners = accumulateInto(event._dispatchListeners, listener);
event._dispatchIDs = accumulateInto(event._dispatchIDs, id);
}
}
}
|
Accumulates without regard to direction, does not look for phased
registration names. Same as `accumulateDirectDispatchesSingle` but without
requiring that the `dispatchMarker` be the same as the dispatched ID.
|
accumulateDispatches
|
javascript
|
amol-/dukpy
|
dukpy/jsmodules/react/react.js
|
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/react/react.js
|
MIT
|
function accumulateDirectDispatchesSingle(event) {
if (event && event.dispatchConfig.registrationName) {
accumulateDispatches(event.dispatchMarker, null, event);
}
}
|
Accumulates dispatches on an `SyntheticEvent`, but only for the
`dispatchMarker`.
@param {SyntheticEvent} event
|
accumulateDirectDispatchesSingle
|
javascript
|
amol-/dukpy
|
dukpy/jsmodules/react/react.js
|
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/react/react.js
|
MIT
|
function accumulateTwoPhaseDispatches(events) {
forEachAccumulated(events, accumulateTwoPhaseDispatchesSingle);
}
|
Accumulates dispatches on an `SyntheticEvent`, but only for the
`dispatchMarker`.
@param {SyntheticEvent} event
|
accumulateTwoPhaseDispatches
|
javascript
|
amol-/dukpy
|
dukpy/jsmodules/react/react.js
|
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/react/react.js
|
MIT
|
function accumulateTwoPhaseDispatchesSkipTarget(events) {
forEachAccumulated(events, accumulateTwoPhaseDispatchesSingleSkipTarget);
}
|
Accumulates dispatches on an `SyntheticEvent`, but only for the
`dispatchMarker`.
@param {SyntheticEvent} event
|
accumulateTwoPhaseDispatchesSkipTarget
|
javascript
|
amol-/dukpy
|
dukpy/jsmodules/react/react.js
|
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/react/react.js
|
MIT
|
function accumulateEnterLeaveDispatches(leave, enter, fromID, toID) {
EventPluginHub.injection.getInstanceHandle().traverseEnterLeave(fromID, toID, accumulateDispatches, leave, enter);
}
|
Accumulates dispatches on an `SyntheticEvent`, but only for the
`dispatchMarker`.
@param {SyntheticEvent} event
|
accumulateEnterLeaveDispatches
|
javascript
|
amol-/dukpy
|
dukpy/jsmodules/react/react.js
|
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/react/react.js
|
MIT
|
function accumulateDirectDispatches(events) {
forEachAccumulated(events, accumulateDirectDispatchesSingle);
}
|
Accumulates dispatches on an `SyntheticEvent`, but only for the
`dispatchMarker`.
@param {SyntheticEvent} event
|
accumulateDirectDispatches
|
javascript
|
amol-/dukpy
|
dukpy/jsmodules/react/react.js
|
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/react/react.js
|
MIT
|
function FallbackCompositionState(root) {
this._root = root;
this._startText = this.getText();
this._fallbackText = null;
}
|
This helper class stores information about text content of a target node,
allowing comparison of content before and after a given event.
Identify the node where selection currently begins, then observe
both its text content and its current position in the DOM. Since the
browser may natively replace the target node during composition, we can
use its position to find its replacement.
@param {DOMEventTarget} root
|
FallbackCompositionState
|
javascript
|
amol-/dukpy
|
dukpy/jsmodules/react/react.js
|
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/react/react.js
|
MIT
|
oneArgumentPooler = function (copyFieldsFrom) {
var Klass = this;
if (Klass.instancePool.length) {
var instance = Klass.instancePool.pop();
Klass.call(instance, copyFieldsFrom);
return instance;
} else {
return new Klass(copyFieldsFrom);
}
}
|
Static poolers. Several custom versions for each potential number of
arguments. A completely generic pooler is easy to implement, but would
require accessing the `arguments` object. In each of these, `this` refers to
the Class itself, not an instance. If any others are needed, simply add them
here, or in their own files.
|
oneArgumentPooler
|
javascript
|
amol-/dukpy
|
dukpy/jsmodules/react/react.js
|
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/react/react.js
|
MIT
|
twoArgumentPooler = function (a1, a2) {
var Klass = this;
if (Klass.instancePool.length) {
var instance = Klass.instancePool.pop();
Klass.call(instance, a1, a2);
return instance;
} else {
return new Klass(a1, a2);
}
}
|
Static poolers. Several custom versions for each potential number of
arguments. A completely generic pooler is easy to implement, but would
require accessing the `arguments` object. In each of these, `this` refers to
the Class itself, not an instance. If any others are needed, simply add them
here, or in their own files.
|
twoArgumentPooler
|
javascript
|
amol-/dukpy
|
dukpy/jsmodules/react/react.js
|
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/react/react.js
|
MIT
|
threeArgumentPooler = function (a1, a2, a3) {
var Klass = this;
if (Klass.instancePool.length) {
var instance = Klass.instancePool.pop();
Klass.call(instance, a1, a2, a3);
return instance;
} else {
return new Klass(a1, a2, a3);
}
}
|
Static poolers. Several custom versions for each potential number of
arguments. A completely generic pooler is easy to implement, but would
require accessing the `arguments` object. In each of these, `this` refers to
the Class itself, not an instance. If any others are needed, simply add them
here, or in their own files.
|
threeArgumentPooler
|
javascript
|
amol-/dukpy
|
dukpy/jsmodules/react/react.js
|
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/react/react.js
|
MIT
|
fourArgumentPooler = function (a1, a2, a3, a4) {
var Klass = this;
if (Klass.instancePool.length) {
var instance = Klass.instancePool.pop();
Klass.call(instance, a1, a2, a3, a4);
return instance;
} else {
return new Klass(a1, a2, a3, a4);
}
}
|
Static poolers. Several custom versions for each potential number of
arguments. A completely generic pooler is easy to implement, but would
require accessing the `arguments` object. In each of these, `this` refers to
the Class itself, not an instance. If any others are needed, simply add them
here, or in their own files.
|
fourArgumentPooler
|
javascript
|
amol-/dukpy
|
dukpy/jsmodules/react/react.js
|
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/react/react.js
|
MIT
|
fiveArgumentPooler = function (a1, a2, a3, a4, a5) {
var Klass = this;
if (Klass.instancePool.length) {
var instance = Klass.instancePool.pop();
Klass.call(instance, a1, a2, a3, a4, a5);
return instance;
} else {
return new Klass(a1, a2, a3, a4, a5);
}
}
|
Static poolers. Several custom versions for each potential number of
arguments. A completely generic pooler is easy to implement, but would
require accessing the `arguments` object. In each of these, `this` refers to
the Class itself, not an instance. If any others are needed, simply add them
here, or in their own files.
|
fiveArgumentPooler
|
javascript
|
amol-/dukpy
|
dukpy/jsmodules/react/react.js
|
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/react/react.js
|
MIT
|
standardReleaser = function (instance) {
var Klass = this;
!(instance instanceof Klass) ? "development" !== 'production' ? invariant(false, 'Trying to release an instance into a pool of a different type.') : invariant(false) : undefined;
instance.destructor();
if (Klass.instancePool.length < Klass.poolSize) {
Klass.instancePool.push(instance);
}
}
|
Static poolers. Several custom versions for each potential number of
arguments. A completely generic pooler is easy to implement, but would
require accessing the `arguments` object. In each of these, `this` refers to
the Class itself, not an instance. If any others are needed, simply add them
here, or in their own files.
|
standardReleaser
|
javascript
|
amol-/dukpy
|
dukpy/jsmodules/react/react.js
|
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/react/react.js
|
MIT
|
addPoolingTo = function (CopyConstructor, pooler) {
var NewKlass = CopyConstructor;
NewKlass.instancePool = [];
NewKlass.getPooled = pooler || DEFAULT_POOLER;
if (!NewKlass.poolSize) {
NewKlass.poolSize = DEFAULT_POOL_SIZE;
}
NewKlass.release = standardReleaser;
return NewKlass;
}
|
Augments `CopyConstructor` to be a poolable class, augmenting only the class
itself (statically) not adding any prototypical fields. Any CopyConstructor
you give this may have a `poolSize` property, and will look for a
prototypical `destructor` on instances (optional).
@param {Function} CopyConstructor Constructor that can be used to reset.
@param {Function} pooler Customizable pooler.
|
addPoolingTo
|
javascript
|
amol-/dukpy
|
dukpy/jsmodules/react/react.js
|
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/react/react.js
|
MIT
|
function getListeningForDocument(mountAt) {
// In IE8, `mountAt` is a host object and doesn't have `hasOwnProperty`
// directly.
if (!Object.prototype.hasOwnProperty.call(mountAt, topListenersIDKey)) {
mountAt[topListenersIDKey] = reactTopListenersCounter++;
alreadyListeningTo[mountAt[topListenersIDKey]] = {};
}
return alreadyListeningTo[mountAt[topListenersIDKey]];
}
|
To ensure no conflicts with other potential React instances on the page
|
getListeningForDocument
|
javascript
|
amol-/dukpy
|
dukpy/jsmodules/react/react.js
|
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/react/react.js
|
MIT
|
function ForEachBookKeeping(forEachFunction, forEachContext) {
this.func = forEachFunction;
this.context = forEachContext;
this.count = 0;
}
|
PooledClass representing the bookkeeping associated with performing a child
traversal. Allows avoiding binding callbacks.
@constructor ForEachBookKeeping
@param {!function} forEachFunction Function to perform traversal with.
@param {?*} forEachContext Context to perform context with.
|
ForEachBookKeeping
|
javascript
|
amol-/dukpy
|
dukpy/jsmodules/react/react.js
|
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/react/react.js
|
MIT
|
function forEachSingleChild(bookKeeping, child, name) {
var func = bookKeeping.func;
var context = bookKeeping.context;
func.call(context, child, bookKeeping.count++);
}
|
PooledClass representing the bookkeeping associated with performing a child
traversal. Allows avoiding binding callbacks.
@constructor ForEachBookKeeping
@param {!function} forEachFunction Function to perform traversal with.
@param {?*} forEachContext Context to perform context with.
|
forEachSingleChild
|
javascript
|
amol-/dukpy
|
dukpy/jsmodules/react/react.js
|
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/react/react.js
|
MIT
|
function forEachChildren(children, forEachFunc, forEachContext) {
if (children == null) {
return children;
}
var traverseContext = ForEachBookKeeping.getPooled(forEachFunc, forEachContext);
traverseAllChildren(children, forEachSingleChild, traverseContext);
ForEachBookKeeping.release(traverseContext);
}
|
Iterates through children that are typically specified as `props.children`.
The provided forEachFunc(child, index) will be called for each
leaf child.
@param {?*} children Children tree container.
@param {function(*, int)} forEachFunc
@param {*} forEachContext Context for forEachContext.
|
forEachChildren
|
javascript
|
amol-/dukpy
|
dukpy/jsmodules/react/react.js
|
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/react/react.js
|
MIT
|
function MapBookKeeping(mapResult, keyPrefix, mapFunction, mapContext) {
this.result = mapResult;
this.keyPrefix = keyPrefix;
this.func = mapFunction;
this.context = mapContext;
this.count = 0;
}
|
PooledClass representing the bookkeeping associated with performing a child
mapping. Allows avoiding binding callbacks.
@constructor MapBookKeeping
@param {!*} mapResult Object containing the ordered map of results.
@param {!function} mapFunction Function to perform mapping with.
@param {?*} mapContext Context to perform mapping with.
|
MapBookKeeping
|
javascript
|
amol-/dukpy
|
dukpy/jsmodules/react/react.js
|
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/react/react.js
|
MIT
|
function mapSingleChildIntoContext(bookKeeping, child, childKey) {
var result = bookKeeping.result;
var keyPrefix = bookKeeping.keyPrefix;
var func = bookKeeping.func;
var context = bookKeeping.context;
var mappedChild = func.call(context, child, bookKeeping.count++);
if (Array.isArray(mappedChild)) {
mapIntoWithKeyPrefixInternal(mappedChild, result, childKey, emptyFunction.thatReturnsArgument);
} else if (mappedChild != null) {
if (ReactElement.isValidElement(mappedChild)) {
mappedChild = ReactElement.cloneAndReplaceKey(mappedChild,
// Keep both the (mapped) and old keys if they differ, just as
// traverseAllChildren used to do for objects as children
keyPrefix + (mappedChild !== child ? escapeUserProvidedKey(mappedChild.key || '') + '/' : '') + childKey);
}
result.push(mappedChild);
}
}
|
PooledClass representing the bookkeeping associated with performing a child
mapping. Allows avoiding binding callbacks.
@constructor MapBookKeeping
@param {!*} mapResult Object containing the ordered map of results.
@param {!function} mapFunction Function to perform mapping with.
@param {?*} mapContext Context to perform mapping with.
|
mapSingleChildIntoContext
|
javascript
|
amol-/dukpy
|
dukpy/jsmodules/react/react.js
|
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/react/react.js
|
MIT
|
function mapIntoWithKeyPrefixInternal(children, array, prefix, func, context) {
var escapedPrefix = '';
if (prefix != null) {
escapedPrefix = escapeUserProvidedKey(prefix) + '/';
}
var traverseContext = MapBookKeeping.getPooled(array, escapedPrefix, func, context);
traverseAllChildren(children, mapSingleChildIntoContext, traverseContext);
MapBookKeeping.release(traverseContext);
}
|
PooledClass representing the bookkeeping associated with performing a child
mapping. Allows avoiding binding callbacks.
@constructor MapBookKeeping
@param {!*} mapResult Object containing the ordered map of results.
@param {!function} mapFunction Function to perform mapping with.
@param {?*} mapContext Context to perform mapping with.
|
mapIntoWithKeyPrefixInternal
|
javascript
|
amol-/dukpy
|
dukpy/jsmodules/react/react.js
|
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/react/react.js
|
MIT
|
function mapChildren(children, func, context) {
if (children == null) {
return children;
}
var result = [];
mapIntoWithKeyPrefixInternal(children, result, null, func, context);
return result;
}
|
Maps children that are typically specified as `props.children`.
The provided mapFunction(child, key, index) will be called for each
leaf child.
@param {?*} children Children tree container.
@param {function(*, int)} func The map function.
@param {*} context Context for mapFunction.
@return {object} Object containing the ordered map of results.
|
mapChildren
|
javascript
|
amol-/dukpy
|
dukpy/jsmodules/react/react.js
|
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/react/react.js
|
MIT
|
function forEachSingleChildDummy(traverseContext, child, name) {
return null;
}
|
Maps children that are typically specified as `props.children`.
The provided mapFunction(child, key, index) will be called for each
leaf child.
@param {?*} children Children tree container.
@param {function(*, int)} func The map function.
@param {*} context Context for mapFunction.
@return {object} Object containing the ordered map of results.
|
forEachSingleChildDummy
|
javascript
|
amol-/dukpy
|
dukpy/jsmodules/react/react.js
|
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/react/react.js
|
MIT
|
function countChildren(children, context) {
return traverseAllChildren(children, forEachSingleChildDummy, null);
}
|
Count the number of children that are typically specified as
`props.children`.
@param {?*} children Children tree container.
@return {number} The number of children.
|
countChildren
|
javascript
|
amol-/dukpy
|
dukpy/jsmodules/react/react.js
|
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/react/react.js
|
MIT
|
function toArray(children) {
var result = [];
mapIntoWithKeyPrefixInternal(children, result, null, emptyFunction.thatReturnsArgument);
return result;
}
|
Flatten a children object (typically specified as `props.children`) and
return an array with appropriately re-keyed children.
|
toArray
|
javascript
|
amol-/dukpy
|
dukpy/jsmodules/react/react.js
|
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/react/react.js
|
MIT
|
function warnSetProps() {
if (!warnedSetProps) {
warnedSetProps = true;
"development" !== 'production' ? warning(false, 'setProps(...) and replaceProps(...) are deprecated. ' + 'Instead, call render again at the top level.') : undefined;
}
}
|
These methods are similar to DEFINE_MANY, except we assume they return
objects. We try to merge the keys of the return values of all the mixed in
functions. If there is a key conflict we throw.
|
warnSetProps
|
javascript
|
amol-/dukpy
|
dukpy/jsmodules/react/react.js
|
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/react/react.js
|
MIT
|
function validateTypeDef(Constructor, typeDef, location) {
for (var propName in typeDef) {
if (typeDef.hasOwnProperty(propName)) {
// use a warning instead of an invariant so components
// don't show up in prod but not in __DEV__
"development" !== 'production' ? warning(typeof typeDef[propName] === 'function', '%s: %s type `%s` is invalid; it must be a function, usually from ' + 'React.PropTypes.', Constructor.displayName || 'ReactClass', ReactPropTypeLocationNames[location], propName) : undefined;
}
}
}
|
Special case getDefaultProps which should move into statics but requires
automatic merging.
|
validateTypeDef
|
javascript
|
amol-/dukpy
|
dukpy/jsmodules/react/react.js
|
https://github.com/amol-/dukpy/blob/master/dukpy/jsmodules/react/react.js
|
MIT
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.