WIP - add extractor, generate snippet_data

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

20
node_modules/rollup/dist/typings/ast/CallOptions.d.ts generated vendored Normal file
View File

@ -0,0 +1,20 @@
import { ExpressionEntity } from './nodes/shared/Expression';
import SpreadElement from './nodes/SpreadElement';
import TaggedTemplateExpression from './nodes/TaggedTemplateExpression';
import NewExpression from './nodes/NewExpression';
import Property from './nodes/Property';
import CallExpression from './nodes/CallExpression';
export declare type CallExpressionType = TaggedTemplateExpression | CallExpression | NewExpression | Property;
export interface CallCreateOptions {
withNew: boolean;
args?: (ExpressionEntity | SpreadElement)[];
callIdentifier: Object;
}
export default class CallOptions implements CallCreateOptions {
withNew: boolean;
args: (ExpressionEntity | SpreadElement)[];
callIdentifier: Object;
static create(callOptions: CallCreateOptions): CallOptions;
constructor({withNew, args, callIdentifier}?: CallCreateOptions);
equals(callOptions: CallOptions): boolean;
}

16
node_modules/rollup/dist/typings/ast/Entity.d.ts generated vendored Normal file
View File

@ -0,0 +1,16 @@
import ExecutionPathOptions from './ExecutionPathOptions';
import { ObjectPath } from './values';
export interface Entity {
toString: () => string;
}
export interface WritableEntity extends Entity {
hasEffectsWhenAssignedAtPath(path: ObjectPath, options: ExecutionPathOptions): boolean;
/**
* Reassign a given path of an object.
* E.g., node.reassignPath(['x', 'y']) is called when something
* is assigned to node.x.y.
* The default noop implementation is ok as long as hasEffectsWhenAssignedAtPath
* always returns true for this node. Otherwise it should be overridden.
*/
reassignPath(path: ObjectPath, options: ExecutionPathOptions): void;
}

View File

@ -0,0 +1,57 @@
import CallExpression from './nodes/CallExpression';
import CallOptions from './CallOptions';
import ThisVariable from './variables/ThisVariable';
import ParameterVariable from './variables/ParameterVariable';
import { Entity, WritableEntity } from './Entity';
import Property from './nodes/Property';
import { ExpressionEntity } from './nodes/shared/Expression';
import { ObjectPath } from './values';
export declare enum OptionTypes {
IGNORED_LABELS = 0,
ACCESSED_NODES = 1,
ARGUMENTS_VARIABLES = 2,
ASSIGNED_NODES = 3,
IGNORE_BREAK_STATEMENTS = 4,
IGNORE_RETURN_AWAIT_YIELD = 5,
NODES_CALLED_AT_PATH_WITH_OPTIONS = 6,
REPLACED_VARIABLE_INITS = 7,
RETURN_EXPRESSIONS_ACCESSED_AT_PATH = 8,
RETURN_EXPRESSIONS_ASSIGNED_AT_PATH = 9,
RETURN_EXPRESSIONS_CALLED_AT_PATH = 10,
}
export declare type RESULT_KEY = {};
export declare const RESULT_KEY: RESULT_KEY;
export declare type KeyTypes = OptionTypes | Entity | RESULT_KEY;
export default class ExecutionPathOptions {
private optionValues;
static create(): ExecutionPathOptions;
private constructor();
private get(option);
private remove(option);
private set(option, value);
private setIn(optionPath, value);
addAccessedNodeAtPath(path: ObjectPath, node: ExpressionEntity): ExecutionPathOptions;
addAccessedReturnExpressionAtPath(path: ObjectPath, callExpression: CallExpression | Property): ExecutionPathOptions;
addAssignedNodeAtPath(path: ObjectPath, node: WritableEntity): ExecutionPathOptions;
addAssignedReturnExpressionAtPath(path: ObjectPath, callExpression: CallExpression | Property): ExecutionPathOptions;
addCalledNodeAtPathWithOptions(path: ObjectPath, node: ExpressionEntity, callOptions: CallOptions): ExecutionPathOptions;
addCalledReturnExpressionAtPath(path: ObjectPath, callExpression: CallExpression | Property): ExecutionPathOptions;
getArgumentsVariables(): ExpressionEntity[];
getHasEffectsWhenCalledOptions(): ExecutionPathOptions;
getReplacedVariableInit(variable: ThisVariable | ParameterVariable): ExpressionEntity;
hasNodeBeenAccessedAtPath(path: ObjectPath, node: ExpressionEntity): boolean;
hasNodeBeenAssignedAtPath(path: ObjectPath, node: WritableEntity): boolean;
hasNodeBeenCalledAtPathWithOptions(path: ObjectPath, node: ExpressionEntity, callOptions: CallOptions): boolean;
hasReturnExpressionBeenAccessedAtPath(path: ObjectPath, callExpression: CallExpression | Property): boolean;
hasReturnExpressionBeenAssignedAtPath(path: ObjectPath, callExpression: CallExpression | Property): boolean;
hasReturnExpressionBeenCalledAtPath(path: ObjectPath, callExpression: CallExpression | Property): boolean;
ignoreBreakStatements(): boolean | Entity | ExpressionEntity[];
ignoreLabel(labelName: string): any;
ignoreReturnAwaitYield(): boolean | Entity | ExpressionEntity[];
replaceVariableInit(variable: ThisVariable | ParameterVariable, init: ExpressionEntity): ExecutionPathOptions;
setArgumentsVariables(variables: ExpressionEntity[]): ExecutionPathOptions;
setIgnoreBreakStatements(value?: boolean): ExecutionPathOptions;
setIgnoreLabel(labelName: string): ExecutionPathOptions;
setIgnoreNoLabels(): ExecutionPathOptions;
setIgnoreReturnAwaitYield(value?: boolean): ExecutionPathOptions;
}

1
node_modules/rollup/dist/typings/ast/clone.d.ts generated vendored Normal file
View File

@ -0,0 +1 @@
export default function clone<T>(node: T): T;

3
node_modules/rollup/dist/typings/ast/enhance.d.ts generated vendored Normal file
View File

@ -0,0 +1,3 @@
import Module from '../Module';
import Import from './nodes/Import';
export default function enhance(ast: any, module: Module, dynamicImportReturnList: Import[]): void;

4
node_modules/rollup/dist/typings/ast/keys.d.ts generated vendored Normal file
View File

@ -0,0 +1,4 @@
declare const keys: {
[name: string]: string[];
};
export default keys;

View File

@ -0,0 +1,14 @@
import SpreadElement from './SpreadElement';
import { SomeReturnExpressionCallback } from './shared/Expression';
import { ExpressionNode, NodeBase } from './shared/Node';
import { NodeType } from './NodeType';
import CallOptions from '../CallOptions';
import ExecutionPathOptions from '../ExecutionPathOptions';
import { ObjectPath } from '../values';
export default class ArrayExpression extends NodeBase {
type: NodeType.ArrayExpression;
elements: (ExpressionNode | SpreadElement | null)[];
hasEffectsWhenAccessedAtPath(path: ObjectPath): boolean;
hasEffectsWhenCalledAtPath(path: ObjectPath, callOptions: CallOptions, options: ExecutionPathOptions): boolean;
someReturnExpressionWhenCalledAtPath(path: ObjectPath, callOptions: CallOptions, predicateFunction: SomeReturnExpressionCallback, options: ExecutionPathOptions): boolean;
}

View File

@ -0,0 +1,14 @@
import { ObjectPath } from '../values';
import Scope from '../scopes/Scope';
import ExecutionPathOptions from '../ExecutionPathOptions';
import { PatternNode } from './shared/Pattern';
import { ExpressionEntity } from './shared/Expression';
import { NodeBase } from './shared/Node';
import { NodeType } from './NodeType';
export default class ArrayPattern extends NodeBase implements PatternNode {
type: NodeType.ArrayPattern;
elements: (PatternNode | null)[];
reassignPath(path: ObjectPath, options: ExecutionPathOptions): void;
hasEffectsWhenAssignedAtPath(path: ObjectPath, options: ExecutionPathOptions): boolean;
initialiseAndDeclare(parentScope: Scope, kind: string, _init: ExpressionEntity | null): void;
}

View File

@ -0,0 +1,25 @@
import Scope from '../scopes/Scope';
import ReturnValueScope from '../scopes/ReturnValueScope';
import BlockStatement from './BlockStatement';
import CallOptions from '../CallOptions';
import ExecutionPathOptions from '../ExecutionPathOptions';
import { ForEachReturnExpressionCallback, SomeReturnExpressionCallback } from './shared/Expression';
import { PatternNode } from './shared/Pattern';
import { NodeType } from './NodeType';
import { ExpressionNode, NodeBase } from './shared/Node';
import { ObjectPath } from '../values';
export default class ArrowFunctionExpression extends NodeBase {
type: NodeType.ArrowFunctionExpression;
body: BlockStatement | ExpressionNode;
params: PatternNode[];
scope: ReturnValueScope;
bindNode(): void;
forEachReturnExpressionWhenCalledAtPath(path: ObjectPath, callOptions: CallOptions, callback: ForEachReturnExpressionCallback, options: ExecutionPathOptions): void;
hasEffects(_options: ExecutionPathOptions): boolean;
hasEffectsWhenAccessedAtPath(path: ObjectPath, _options: ExecutionPathOptions): boolean;
hasEffectsWhenAssignedAtPath(path: ObjectPath, _options: ExecutionPathOptions): boolean;
hasEffectsWhenCalledAtPath(path: ObjectPath, _callOptions: CallOptions, options: ExecutionPathOptions): boolean;
initialiseChildren(): void;
initialiseScope(parentScope: Scope): void;
someReturnExpressionWhenCalledAtPath(path: ObjectPath, callOptions: CallOptions, predicateFunction: SomeReturnExpressionCallback, options: ExecutionPathOptions): boolean;
}

View File

@ -0,0 +1,13 @@
import ExecutionPathOptions from '../ExecutionPathOptions';
import { PatternNode } from './shared/Pattern';
import { ExpressionNode, NodeBase } from './shared/Node';
import { NodeType } from './NodeType';
import { ObjectPath } from '../values';
export default class AssignmentExpression extends NodeBase {
type: NodeType.AssignmentExpression;
left: PatternNode | ExpressionNode;
right: ExpressionNode;
bindNode(): void;
hasEffects(options: ExecutionPathOptions): boolean;
hasEffectsWhenAccessedAtPath(path: ObjectPath, options: ExecutionPathOptions): boolean;
}

View File

@ -0,0 +1,16 @@
import ExecutionPathOptions from '../ExecutionPathOptions';
import Scope from '../scopes/Scope';
import { PatternNode } from './shared/Pattern';
import { ExpressionEntity } from './shared/Expression';
import { ExpressionNode, NodeBase } from './shared/Node';
import { NodeType } from './NodeType';
import { ObjectPath } from '../values';
export default class AssignmentPattern extends NodeBase implements PatternNode {
type: NodeType.AssignmentPattern;
left: PatternNode;
right: ExpressionNode;
bindNode(): void;
reassignPath(path: ObjectPath, options: ExecutionPathOptions): void;
hasEffectsWhenAssignedAtPath(path: ObjectPath, options: ExecutionPathOptions): boolean;
initialiseAndDeclare(parentScope: Scope, kind: string, init: ExpressionEntity | null): void;
}

View File

@ -0,0 +1,10 @@
import { PatternNode } from './shared/Pattern';
import { ExpressionNode } from './shared/Node';
import { NodeType } from './NodeType';
export default interface AssignmentProperty extends PatternNode {
type: NodeType.Property;
value: PatternNode;
key: ExpressionNode;
kind: 'init';
method: false;
}

View File

@ -0,0 +1,8 @@
import ExecutionPathOptions from '../ExecutionPathOptions';
import { NodeType } from './NodeType';
import { ExpressionNode, NodeBase } from './shared/Node';
export default class AwaitExpression extends NodeBase {
type: NodeType.AwaitExpression;
argument: ExpressionNode;
hasEffects(options: ExecutionPathOptions): boolean;
}

View File

@ -0,0 +1,13 @@
import { ObjectPath } from '../values';
import ExecutionPathOptions from '../ExecutionPathOptions';
import { NodeType } from './NodeType';
import { ExpressionNode, NodeBase } from './shared/Node';
export declare type BinaryOperator = '==' | '!=' | '===' | '!==' | '<' | '<=' | '>' | '>=' | '<<' | '>>' | '>>>' | '+' | '-' | '*' | '/' | '%' | ' |' | '^' | '&' | '**' | 'in' | 'instanceof';
export default class BinaryExpression extends NodeBase {
type: NodeType.BinaryExpression;
left: ExpressionNode;
right: ExpressionNode;
operator: BinaryOperator;
getValue(): any;
hasEffectsWhenAccessedAtPath(path: ObjectPath, _options: ExecutionPathOptions): boolean;
}

View File

@ -0,0 +1,19 @@
import ExecutionPathOptions from '../ExecutionPathOptions';
import Scope from '../scopes/Scope';
import MagicString from 'magic-string';
import { Node, StatementBase, StatementNode } from './shared/Node';
import { NodeType } from './NodeType';
import { RenderOptions } from '../../utils/renderHelpers';
export declare function isBlockStatement(node: Node): node is BlockStatement;
export default class BlockStatement extends StatementBase {
type: NodeType.BlockStatement;
scope: Scope;
body: StatementNode[];
bindImplicitReturnExpressionToScope(): void;
hasEffects(options: ExecutionPathOptions): boolean;
includeInBundle(): boolean;
initialiseAndReplaceScope(scope: Scope): void;
initialiseChildren(_parentScope: Scope): void;
initialiseScope(parentScope: Scope): void;
render(code: MagicString, options: RenderOptions): void;
}

View File

@ -0,0 +1,9 @@
import ExecutionPathOptions from '../ExecutionPathOptions';
import Identifier from './Identifier';
import { NodeType } from './NodeType';
import { StatementBase } from './shared/Node';
export default class BreakStatement extends StatementBase {
type: NodeType.BreakStatement;
label: Identifier | null;
hasEffects(options: ExecutionPathOptions): boolean;
}

View File

@ -0,0 +1,22 @@
import CallOptions from '../CallOptions';
import ExecutionPathOptions from '../ExecutionPathOptions';
import SpreadElement from './SpreadElement';
import { ForEachReturnExpressionCallback, SomeReturnExpressionCallback } from './shared/Expression';
import { NodeType } from './NodeType';
import { ExpressionNode, NodeBase } from './shared/Node';
import { ObjectPath } from '../values';
export default class CallExpression extends NodeBase {
type: NodeType.CallExpression;
callee: ExpressionNode;
arguments: (ExpressionNode | SpreadElement)[];
private _callOptions;
reassignPath(path: ObjectPath, options: ExecutionPathOptions): void;
bindNode(): void;
forEachReturnExpressionWhenCalledAtPath(path: ObjectPath, callOptions: CallOptions, callback: ForEachReturnExpressionCallback, options: ExecutionPathOptions): void;
hasEffects(options: ExecutionPathOptions): boolean;
hasEffectsWhenAccessedAtPath(path: ObjectPath, options: ExecutionPathOptions): boolean;
hasEffectsWhenAssignedAtPath(path: ObjectPath, options: ExecutionPathOptions): boolean;
hasEffectsWhenCalledAtPath(path: ObjectPath, callOptions: CallOptions, options: ExecutionPathOptions): boolean;
initialiseNode(): void;
someReturnExpressionWhenCalledAtPath(path: ObjectPath, callOptions: CallOptions, predicateFunction: SomeReturnExpressionCallback, options: ExecutionPathOptions): boolean;
}

View File

@ -0,0 +1,14 @@
import { NodeBase } from './shared/Node';
import CatchScope from '../scopes/CatchScope';
import BlockStatement from './BlockStatement';
import Scope from '../scopes/Scope';
import { PatternNode } from './shared/Pattern';
import { NodeType } from './NodeType';
export default class CatchClause extends NodeBase {
type: NodeType.CatchClause;
param: PatternNode;
body: BlockStatement;
scope: CatchScope;
initialiseChildren(): void;
initialiseScope(parentScope: Scope): void;
}

View File

@ -0,0 +1,13 @@
import { NodeBase } from './shared/Node';
import ExecutionPathOptions from '../ExecutionPathOptions';
import CallOptions from '../CallOptions';
import MethodDefinition from './MethodDefinition';
import { NodeType } from './NodeType';
import { ObjectPath } from '../values';
export default class ClassBody extends NodeBase {
type: NodeType.ClassBody;
body: MethodDefinition[];
classConstructor: MethodDefinition | null;
hasEffectsWhenCalledAtPath(path: ObjectPath, callOptions: CallOptions, options: ExecutionPathOptions): boolean;
initialiseNode(): void;
}

View File

@ -0,0 +1,14 @@
import ClassNode from './shared/ClassNode';
import Scope from '../scopes/Scope';
import Identifier from './Identifier';
import MagicString from 'magic-string';
import { NodeType } from './NodeType';
import { Node } from './shared/Node';
import { RenderOptions } from '../../utils/renderHelpers';
export declare function isClassDeclaration(node: Node): node is ClassDeclaration;
export default class ClassDeclaration extends ClassNode {
type: NodeType.ClassDeclaration;
id: Identifier;
initialiseChildren(parentScope: Scope): void;
render(code: MagicString, options: RenderOptions): void;
}

View File

@ -0,0 +1,10 @@
import ClassNode from './shared/ClassNode';
import Scope from '../scopes/Scope';
import ExecutionPathOptions from '../ExecutionPathOptions';
import { NodeType } from './NodeType';
import { ObjectPath } from '../values';
export default class ClassExpression extends ClassNode {
type: NodeType.ClassExpression;
initialiseChildren(parentScope: Scope): void;
reassignPath(_path: ObjectPath, _options: ExecutionPathOptions): void;
}

View File

@ -0,0 +1,26 @@
import { ObjectPath } from '../values';
import ExecutionPathOptions from '../ExecutionPathOptions';
import CallOptions from '../CallOptions';
import MagicString from 'magic-string';
import { ForEachReturnExpressionCallback, SomeReturnExpressionCallback } from './shared/Expression';
import { NodeType } from './NodeType';
import { ExpressionNode, NodeBase } from './shared/Node';
import { NodeRenderOptions, RenderOptions } from '../../utils/renderHelpers';
export default class ConditionalExpression extends NodeBase {
type: NodeType.ConditionalExpression;
test: ExpressionNode;
alternate: ExpressionNode;
consequent: ExpressionNode;
forEachReturnExpressionWhenCalledAtPath(path: ObjectPath, callOptions: CallOptions, callback: ForEachReturnExpressionCallback, options: ExecutionPathOptions): void;
getValue(): any;
hasEffects(options: ExecutionPathOptions): boolean;
hasEffectsWhenAccessedAtPath(path: ObjectPath, options: ExecutionPathOptions): boolean;
hasEffectsWhenAssignedAtPath(path: ObjectPath, options: ExecutionPathOptions): boolean;
hasEffectsWhenCalledAtPath(path: ObjectPath, callOptions: CallOptions, options: ExecutionPathOptions): boolean;
includeInBundle(): boolean;
reassignPath(path: ObjectPath, options: ExecutionPathOptions): void;
render(code: MagicString, options: RenderOptions, {renderedParentType, isCalleeOfRenderedParent}?: NodeRenderOptions): void;
someReturnExpressionWhenCalledAtPath(path: ObjectPath, callOptions: CallOptions, predicateFunction: SomeReturnExpressionCallback, options: ExecutionPathOptions): boolean;
private forEachRelevantBranch(callback);
private someRelevantBranch(predicateFunction);
}

View File

@ -0,0 +1,9 @@
import ExecutionPathOptions from '../ExecutionPathOptions';
import { ExpressionNode, StatementNode, StatementBase } from './shared/Node';
import { NodeType } from './NodeType';
export default class DoWhileStatement extends StatementBase {
type: NodeType.DoWhileStatement;
body: StatementNode;
test: ExpressionNode;
hasEffects(options: ExecutionPathOptions): boolean;
}

View File

@ -0,0 +1,8 @@
import MagicString from 'magic-string';
import { NodeType } from './NodeType';
import { StatementBase } from './shared/Node';
import { RenderOptions } from '../../utils/renderHelpers';
export default class EmptyStatement extends StatementBase {
type: NodeType.EmptyStatement;
render(code: MagicString, _options: RenderOptions): void;
}

View File

@ -0,0 +1,12 @@
import { NodeBase } from './shared/Node';
import Literal from './Literal';
import MagicString from 'magic-string';
import { NodeType } from './NodeType';
import { NodeRenderOptions, RenderOptions } from '../../utils/renderHelpers';
export default class ExportAllDeclaration extends NodeBase {
type: NodeType.ExportAllDeclaration;
source: Literal<string>;
isExportDeclaration: true;
needsBoundaries: true;
render(code: MagicString, _options: RenderOptions, {start, end}?: NodeRenderOptions): void;
}

View File

@ -0,0 +1,20 @@
import { ExpressionNode, NodeBase } from './shared/Node';
import ExportDefaultVariable from '../variables/ExportDefaultVariable';
import ClassDeclaration from './ClassDeclaration';
import FunctionDeclaration from './FunctionDeclaration';
import MagicString from 'magic-string';
import { NodeType } from './NodeType';
import { NodeRenderOptions, RenderOptions } from '../../utils/renderHelpers';
export default class ExportDefaultDeclaration extends NodeBase {
type: NodeType.ExportDefaultDeclaration;
declaration: FunctionDeclaration | ClassDeclaration | ExpressionNode;
needsBoundaries: true;
isExportDeclaration: true;
variable: ExportDefaultVariable;
private declarationName;
bindNode(): void;
initialiseNode(): void;
render(code: MagicString, options: RenderOptions, {start, end}?: NodeRenderOptions): void;
private renderNamedDeclaration(code, declarationStart, declarationKeyword, needsId, options);
private renderVariableDeclaration(code, declarationStart, options);
}

View File

@ -0,0 +1,21 @@
import { NodeBase } from './shared/Node';
import ExecutionPathOptions from '../ExecutionPathOptions';
import Literal from './Literal';
import MagicString from 'magic-string';
import ExportSpecifier from './ExportSpecifier';
import FunctionDeclaration from './FunctionDeclaration';
import ClassDeclaration from './ClassDeclaration';
import VariableDeclaration from './VariableDeclaration';
import { NodeType } from './NodeType';
import { NodeRenderOptions, RenderOptions } from '../../utils/renderHelpers';
export default class ExportNamedDeclaration extends NodeBase {
type: NodeType.ExportNamedDeclaration;
declaration: FunctionDeclaration | ClassDeclaration | VariableDeclaration | null;
specifiers: ExportSpecifier[];
source: Literal<string> | null;
needsBoundaries: true;
isExportDeclaration: true;
bindChildren(): void;
hasEffects(options: ExecutionPathOptions): boolean;
render(code: MagicString, options: RenderOptions, {start, end}?: NodeRenderOptions): void;
}

View File

@ -0,0 +1,8 @@
import { Node } from './shared/Node';
import Identifier from './Identifier';
import { NodeType } from './NodeType';
export default interface ExportSpecifier extends Node {
type: NodeType.ExportSpecifier;
local: Identifier;
exported: Identifier;
}

View File

@ -0,0 +1,10 @@
import MagicString from 'magic-string';
import Scope from '../scopes/Scope';
import { StatementBase } from './shared/Node';
import { RenderOptions } from '../../utils/renderHelpers';
export default class ExpressionStatement extends StatementBase {
directive?: string;
initialiseNode(_parentScope: Scope): void;
shouldBeIncluded(): boolean;
render(code: MagicString, options: RenderOptions): void;
}

View File

@ -0,0 +1,20 @@
import VariableDeclaration from './VariableDeclaration';
import Scope from '../scopes/Scope';
import ExecutionPathOptions from '../ExecutionPathOptions';
import { PatternNode } from './shared/Pattern';
import { NodeType } from './NodeType';
import { ExpressionNode, Node, StatementBase, StatementNode } from './shared/Node';
import MagicString from 'magic-string';
import { RenderOptions } from '../../utils/renderHelpers';
export declare function isForInStatement(node: Node): node is ForInStatement;
export default class ForInStatement extends StatementBase {
type: NodeType.ForInStatement;
left: VariableDeclaration | PatternNode;
right: ExpressionNode;
body: StatementNode;
hasEffects(options: ExecutionPathOptions): boolean;
initialiseChildren(): void;
includeInBundle(): boolean;
initialiseScope(parentScope: Scope): void;
render(code: MagicString, options: RenderOptions): void;
}

View File

@ -0,0 +1,21 @@
import ExecutionPathOptions from '../ExecutionPathOptions';
import VariableDeclaration from './VariableDeclaration';
import Scope from '../scopes/Scope';
import { PatternNode } from './shared/Pattern';
import { NodeType } from './NodeType';
import { ExpressionNode, Node, StatementBase, StatementNode } from './shared/Node';
import MagicString from 'magic-string';
import { RenderOptions } from '../../utils/renderHelpers';
export declare function isForOfStatement(node: Node): node is ForOfStatement;
export default class ForOfStatement extends StatementBase {
type: NodeType.ForOfStatement;
left: VariableDeclaration | PatternNode;
right: ExpressionNode;
body: StatementNode;
bindNode(): void;
hasEffects(options: ExecutionPathOptions): boolean;
includeInBundle(): boolean;
initialiseChildren(): void;
initialiseScope(parentScope: Scope): void;
render(code: MagicString, options: RenderOptions): void;
}

View File

@ -0,0 +1,19 @@
import VariableDeclaration from './VariableDeclaration';
import ExecutionPathOptions from '../ExecutionPathOptions';
import Scope from '../scopes/Scope';
import { NodeType } from './NodeType';
import { ExpressionNode, Node, StatementBase, StatementNode } from './shared/Node';
import MagicString from 'magic-string';
import { RenderOptions } from '../../utils/renderHelpers';
export declare function isForStatement(node: Node): node is ForStatement;
export default class ForStatement extends StatementBase {
type: NodeType.ForStatement;
init: VariableDeclaration | ExpressionNode | null;
test: ExpressionNode | null;
update: ExpressionNode | null;
body: StatementNode;
hasEffects(options: ExecutionPathOptions): boolean;
initialiseChildren(): void;
initialiseScope(parentScope: Scope): void;
render(code: MagicString, options: RenderOptions): void;
}

View File

@ -0,0 +1,9 @@
import FunctionNode from './shared/FunctionNode';
import Scope from '../scopes/Scope';
import { NodeType } from './NodeType';
import { Node } from './shared/Node';
export declare function isFunctionDeclaration(node: Node): node is FunctionDeclaration;
export default class FunctionDeclaration extends FunctionNode {
type: NodeType.FunctionDeclaration;
initialiseChildren(parentScope: Scope): void;
}

View File

@ -0,0 +1,6 @@
import FunctionNode from './shared/FunctionNode';
import { NodeType } from './NodeType';
export default class FunctionExpression extends FunctionNode {
type: NodeType.FunctionExpression;
initialiseChildren(): void;
}

View File

@ -0,0 +1,29 @@
import { Node, NodeBase } from './shared/Node';
import { ObjectPath } from '../values';
import Scope from '../scopes/Scope';
import ExecutionPathOptions from '../ExecutionPathOptions';
import Variable from '../variables/Variable';
import CallOptions from '../CallOptions';
import MagicString from 'magic-string';
import { ExpressionEntity, ForEachReturnExpressionCallback, SomeReturnExpressionCallback } from './shared/Expression';
import { NodeType } from './NodeType';
import { NodeRenderOptions, RenderOptions } from '../../utils/renderHelpers';
export declare function isIdentifier(node: Node): node is Identifier;
export default class Identifier extends NodeBase {
type: NodeType.Identifier;
name: string;
variable: Variable;
private isBound;
bindNode(): void;
forEachReturnExpressionWhenCalledAtPath(path: ObjectPath, callOptions: CallOptions, callback: ForEachReturnExpressionCallback, options: ExecutionPathOptions): void;
hasEffectsWhenAccessedAtPath(path: ObjectPath, options: ExecutionPathOptions): boolean;
hasEffectsWhenAssignedAtPath(path: ObjectPath, options: ExecutionPathOptions): boolean;
hasEffectsWhenCalledAtPath(path: ObjectPath, callOptions: CallOptions, options: ExecutionPathOptions): boolean;
includeInBundle(): boolean;
initialiseAndDeclare(parentScope: Scope, kind: string, init: ExpressionEntity | null): void;
reassignPath(path: ObjectPath, options: ExecutionPathOptions): void;
private disallowImportReassignment();
renderSystemBindingUpdate(code: MagicString, name: string): void;
render(code: MagicString, options: RenderOptions, {renderedParentType, isCalleeOfRenderedParent}?: NodeRenderOptions): void;
someReturnExpressionWhenCalledAtPath(path: ObjectPath, callOptions: CallOptions, predicateFunction: SomeReturnExpressionCallback, options: ExecutionPathOptions): boolean;
}

View File

@ -0,0 +1,17 @@
import Scope from '../scopes/Scope';
import { ExpressionNode, StatementBase, StatementNode } from './shared/Node';
import MagicString from 'magic-string';
import { NodeType } from './NodeType';
import { RenderOptions } from '../../utils/renderHelpers';
export default class IfStatement extends StatementBase {
type: NodeType.IfStatement;
test: ExpressionNode;
consequent: StatementNode;
alternate: StatementNode | null;
private testValue;
private hoistedVars?;
initialiseChildren(parentScope: Scope): void;
initialiseNode(): void;
render(code: MagicString, options: RenderOptions): void;
shouldBeIncluded(): boolean;
}

16
node_modules/rollup/dist/typings/ast/nodes/Import.d.ts generated vendored Normal file
View File

@ -0,0 +1,16 @@
import CallExpression from './CallExpression';
import { NodeType } from './NodeType';
import { NodeBase } from './shared/Node';
import MagicString from 'magic-string';
import { RenderOptions } from '../../utils/renderHelpers';
export default class Import extends NodeBase {
type: NodeType.Import;
parent: CallExpression;
constructor();
private resolutionNamespace;
private resolutionInterop;
private rendered;
setResolution(interop: boolean, namespace?: string): void;
renderFinalResolution(code: MagicString, resolution: string): void;
render(code: MagicString, options: RenderOptions): void;
}

View File

@ -0,0 +1,17 @@
import { NodeBase } from './shared/Node';
import Literal from './Literal';
import ImportSpecifier from './ImportSpecifier';
import ImportDefaultSpecifier from './ImportDefaultSpecifier';
import ImportNamespaceSpecifier from './ImportNamespaceSpecifier';
import MagicString from 'magic-string';
import { NodeType } from './NodeType';
import { NodeRenderOptions, RenderOptions } from '../../utils/renderHelpers';
export default class ImportDeclaration extends NodeBase {
type: NodeType.ImportDeclaration;
specifiers: (ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier)[];
source: Literal<string>;
isImportDeclaration: true;
needsBoundaries: true;
bindChildren(): void;
render(code: MagicString, _options: RenderOptions, {start, end}?: NodeRenderOptions): void;
}

View File

@ -0,0 +1,7 @@
import Identifier from './Identifier';
import { Node } from './shared/Node';
import { NodeType } from './NodeType';
export default interface ImportDefaultSpecifier extends Node {
type: NodeType.ImportDefaultSpecifier;
local: Identifier;
}

View File

@ -0,0 +1,7 @@
import Identifier from './Identifier';
import { Node } from './shared/Node';
import { NodeType } from './NodeType';
export default interface ImportNamespaceSpecifier extends Node {
type: NodeType.ImportNamespaceSpecifier;
local: Identifier;
}

View File

@ -0,0 +1,8 @@
import Identifier from './Identifier';
import { Node } from './shared/Node';
import { NodeType } from './NodeType';
export default interface ImportSpecifier extends Node {
type: NodeType.ImportSpecifier;
local: Identifier;
imported: Identifier;
}

View File

@ -0,0 +1,10 @@
import ExecutionPathOptions from '../ExecutionPathOptions';
import Identifier from './Identifier';
import { NodeType } from './NodeType';
import { StatementBase, StatementNode } from './shared/Node';
export default class LabeledStatement extends StatementBase {
type: NodeType.LabeledStatement;
label: Identifier;
body: StatementNode;
hasEffects(options: ExecutionPathOptions): boolean;
}

View File

@ -0,0 +1,22 @@
import ExecutionPathOptions from '../ExecutionPathOptions';
import MagicString from 'magic-string';
import { SomeReturnExpressionCallback } from './shared/Expression';
import { Node, NodeBase } from './shared/Node';
import { NodeType } from './NodeType';
import CallOptions from '../CallOptions';
import { ObjectPath } from '../values';
import { RenderOptions } from '../../utils/renderHelpers';
export declare type LiteralValueTypes = string | boolean | null | number | RegExp;
export declare function isLiteral(node: Node): node is Literal;
export default class Literal<T = LiteralValueTypes> extends NodeBase {
type: NodeType.Literal;
value: T;
private members;
getValue(): T;
hasEffectsWhenAccessedAtPath(path: ObjectPath, _options: ExecutionPathOptions): boolean;
hasEffectsWhenAssignedAtPath(path: ObjectPath, _options: ExecutionPathOptions): boolean;
hasEffectsWhenCalledAtPath(path: ObjectPath, callOptions: CallOptions, options: ExecutionPathOptions): boolean;
initialiseNode(): void;
render(code: MagicString, _options: RenderOptions): void;
someReturnExpressionWhenCalledAtPath(path: ObjectPath, callOptions: CallOptions, predicateFunction: SomeReturnExpressionCallback, options: ExecutionPathOptions): boolean;
}

View File

@ -0,0 +1,27 @@
import { ObjectPath } from '../values';
import CallOptions from '../CallOptions';
import ExecutionPathOptions from '../ExecutionPathOptions';
import { ForEachReturnExpressionCallback, SomeReturnExpressionCallback } from './shared/Expression';
import { NodeType } from './NodeType';
import { ExpressionNode, NodeBase } from './shared/Node';
import { NodeRenderOptions, RenderOptions } from '../../utils/renderHelpers';
import MagicString from 'magic-string';
export declare type LogicalOperator = '||' | '&&';
export default class LogicalExpression extends NodeBase {
type: NodeType.LogicalExpression;
operator: LogicalOperator;
left: ExpressionNode;
right: ExpressionNode;
forEachReturnExpressionWhenCalledAtPath(path: ObjectPath, callOptions: CallOptions, callback: ForEachReturnExpressionCallback, options: ExecutionPathOptions): void;
getValue(): any;
hasEffects(options: ExecutionPathOptions): boolean;
hasEffectsWhenAccessedAtPath(path: ObjectPath, options: ExecutionPathOptions): boolean;
hasEffectsWhenAssignedAtPath(path: ObjectPath, options: ExecutionPathOptions): boolean;
hasEffectsWhenCalledAtPath(path: ObjectPath, callOptions: CallOptions, options: ExecutionPathOptions): boolean;
includeInBundle(): boolean;
reassignPath(path: ObjectPath, options: ExecutionPathOptions): void;
render(code: MagicString, options: RenderOptions, {renderedParentType, isCalleeOfRenderedParent}?: NodeRenderOptions): void;
someReturnExpressionWhenCalledAtPath(path: ObjectPath, callOptions: CallOptions, predicateFunction: SomeReturnExpressionCallback, options: ExecutionPathOptions): boolean;
private forEachRelevantBranch(callback);
private someRelevantBranch(predicateFunction);
}

View File

@ -0,0 +1,34 @@
import { ExpressionNode, Node, NodeBase } from './shared/Node';
import Variable from '../variables/Variable';
import ExecutionPathOptions from '../ExecutionPathOptions';
import CallOptions from '../CallOptions';
import MagicString from 'magic-string';
import { ForEachReturnExpressionCallback, SomeReturnExpressionCallback } from './shared/Expression';
import { NodeType } from './NodeType';
import { NodeRenderOptions, RenderOptions } from '../../utils/renderHelpers';
import { ObjectPath, ObjectPathKey } from '../values';
export declare function isMemberExpression(node: Node): node is MemberExpression;
export default class MemberExpression extends NodeBase {
type: NodeType.MemberExpression;
object: ExpressionNode;
property: ExpressionNode;
computed: boolean;
propertyKey: ObjectPathKey;
variable: Variable;
private isBound;
private replacement;
private arePropertyReadSideEffectsChecked;
bind(): void;
private resolveNamespaceVariables(baseVariable, path);
forEachReturnExpressionWhenCalledAtPath(path: ObjectPath, callOptions: CallOptions, callback: ForEachReturnExpressionCallback, options: ExecutionPathOptions): void;
hasEffects(options: ExecutionPathOptions): boolean;
hasEffectsWhenAccessedAtPath(path: ObjectPath, options: ExecutionPathOptions): boolean;
hasEffectsWhenAssignedAtPath(path: ObjectPath, options: ExecutionPathOptions): boolean;
hasEffectsWhenCalledAtPath(path: ObjectPath, callOptions: CallOptions, options: ExecutionPathOptions): boolean;
includeInBundle(): boolean;
initialiseNode(): void;
reassignPath(path: ObjectPath, options: ExecutionPathOptions): void;
private disallowNamespaceReassignment();
render(code: MagicString, options: RenderOptions, {renderedParentType, isCalleeOfRenderedParent}?: NodeRenderOptions): void;
someReturnExpressionWhenCalledAtPath(path: ObjectPath, callOptions: CallOptions, predicateFunction: SomeReturnExpressionCallback, options: ExecutionPathOptions): boolean;
}

View File

@ -0,0 +1,16 @@
import { ExpressionNode, NodeBase } from './shared/Node';
import ExecutionPathOptions from '../ExecutionPathOptions';
import FunctionExpression from './FunctionExpression';
import CallOptions from '../CallOptions';
import { NodeType } from './NodeType';
import { ObjectPath } from '../values';
export default class MethodDefinition extends NodeBase {
type: NodeType.MethodDefinition;
key: ExpressionNode;
value: FunctionExpression;
kind: 'constructor' | 'method' | 'get' | 'set';
computed: boolean;
static: boolean;
hasEffects(options: ExecutionPathOptions): boolean;
hasEffectsWhenCalledAtPath(path: ObjectPath, callOptions: CallOptions, options: ExecutionPathOptions): boolean;
}

View File

@ -0,0 +1,14 @@
import CallOptions from '../CallOptions';
import ExecutionPathOptions from '../ExecutionPathOptions';
import { ExpressionNode, NodeBase } from './shared/Node';
import { NodeType } from './NodeType';
import { ObjectPath } from '../values';
export default class NewExpression extends NodeBase {
type: NodeType.NewExpression;
callee: ExpressionNode;
arguments: ExpressionNode[];
_callOptions: CallOptions;
hasEffects(options: ExecutionPathOptions): boolean;
hasEffectsWhenAccessedAtPath(path: ObjectPath, _options: ExecutionPathOptions): boolean;
initialiseNode(): void;
}

View File

@ -0,0 +1,64 @@
export declare const enum NodeType {
ArrayExpression = "ArrayExpression",
ArrayPattern = "ArrayPattern",
ArrowFunctionExpression = "ArrowFunctionExpression",
AssignmentExpression = "AssignmentExpression",
AssignmentPattern = "AssignmentPattern",
AwaitExpression = "AwaitExpression",
BinaryExpression = "BinaryExpression",
BlockStatement = "BlockStatement",
BreakStatement = "BreakStatement",
CallExpression = "CallExpression",
CatchClause = "CatchClause",
ClassBody = "ClassBody",
ClassDeclaration = "ClassDeclaration",
ClassExpression = "ClassExpression",
ConditionalExpression = "ConditionalExpression",
DoWhileStatement = "DoWhileStatement",
EmptyStatement = "EmptyStatement",
ExportAllDeclaration = "ExportAllDeclaration",
ExportDefaultDeclaration = "ExportDefaultDeclaration",
ExportNamedDeclaration = "ExportNamedDeclaration",
ExportSpecifier = "ExportSpecifier",
ExpressionStatement = "ExpressionStatement",
ForStatement = "ForStatement",
ForInStatement = "ForInStatement",
ForOfStatement = "ForOfStatement",
FunctionDeclaration = "FunctionDeclaration",
FunctionExpression = "FunctionExpression",
Identifier = "Identifier",
IfStatement = "IfStatement",
Import = "Import",
ImportDeclaration = "ImportDeclaration",
ImportDefaultSpecifier = "ImportDefaultSpecifier",
ImportNamespaceSpecifier = "ImportNamespaceSpecifier",
ImportSpecifier = "ImportSpecifier",
LabeledStatement = "LabeledStatement",
Literal = "Literal",
LogicalExpression = "LogicalExpression",
MemberExpression = "MemberExpression",
MethodDefinition = "MethodDefinition",
NewExpression = "NewExpression",
ObjectExpression = "ObjectExpression",
ObjectPattern = "ObjectPattern",
Program = "Program",
Property = "Property",
RestElement = "RestElement",
ReturnStatement = "ReturnStatement",
SequenceExpression = "SequenceExpression",
SpreadElement = "SpreadElement",
SwitchCase = "SwitchCase",
SwitchStatement = "SwitchStatement",
TaggedTemplateExpression = "TaggedTemplateExpression",
TemplateElement = "TemplateElement",
TemplateLiteral = "TemplateLiteral",
ThisExpression = "ThisExpression",
ThrowStatement = "ThrowStatement",
TryStatement = "TryStatement",
UnaryExpression = "UnaryExpression",
UpdateExpression = "UpdateExpression",
VariableDeclarator = "VariableDeclarator",
VariableDeclaration = "VariableDeclaration",
WhileStatement = "WhileStatement",
YieldExpression = "YieldExpression",
}

View File

@ -0,0 +1,25 @@
import Property from './Property';
import CallOptions from '../CallOptions';
import ExecutionPathOptions from '../ExecutionPathOptions';
import { ForEachReturnExpressionCallback, SomeReturnExpressionCallback } from './shared/Expression';
import { ObjectPath, ObjectPathKey } from '../values';
import { Node, NodeBase } from './shared/Node';
import { NodeType } from './NodeType';
import { NodeRenderOptions, RenderOptions } from '../../utils/renderHelpers';
import MagicString from 'magic-string';
export declare function isObjectExpression(node: Node): node is ObjectExpression;
export default class ObjectExpression extends NodeBase {
type: NodeType.ObjectExpression;
properties: Property[];
reassignPath(path: ObjectPath, options: ExecutionPathOptions): void;
forEachReturnExpressionWhenCalledAtPath(path: ObjectPath, callOptions: CallOptions, callback: ForEachReturnExpressionCallback, options: ExecutionPathOptions): void;
_getPossiblePropertiesWithName(name: ObjectPathKey, kinds: ObjectPath): {
properties: Property[];
hasCertainHit: boolean;
};
hasEffectsWhenAccessedAtPath(path: ObjectPath, options: ExecutionPathOptions): boolean;
hasEffectsWhenAssignedAtPath(path: ObjectPath, options: ExecutionPathOptions): boolean;
hasEffectsWhenCalledAtPath(path: ObjectPath, callOptions: CallOptions, options: ExecutionPathOptions): boolean;
render(code: MagicString, options: RenderOptions, {renderedParentType}?: NodeRenderOptions): void;
someReturnExpressionWhenCalledAtPath(path: ObjectPath, callOptions: CallOptions, predicateFunction: SomeReturnExpressionCallback, options: ExecutionPathOptions): boolean;
}

View File

@ -0,0 +1,15 @@
import AssignmentProperty from './AssignmentProperty';
import Scope from '../scopes/Scope';
import ExecutionPathOptions from '../ExecutionPathOptions';
import { ExpressionEntity } from './shared/Expression';
import { PatternNode } from './shared/Pattern';
import { NodeBase } from './shared/Node';
import { NodeType } from './NodeType';
import { ObjectPath } from '../values';
export default class ObjectPattern extends NodeBase implements PatternNode {
type: NodeType.ObjectPattern;
properties: AssignmentProperty[];
reassignPath(path: ObjectPath, options: ExecutionPathOptions): void;
hasEffectsWhenAssignedAtPath(path: ObjectPath, options: ExecutionPathOptions): boolean;
initialiseAndDeclare(parentScope: Scope, kind: string, init: ExpressionEntity | null): void;
}

View File

@ -0,0 +1,9 @@
import MagicString from 'magic-string';
import { NodeBase, StatementNode } from './shared/Node';
import { NodeType } from './NodeType';
import { RenderOptions } from '../../utils/renderHelpers';
export default class Program extends NodeBase {
type: NodeType.Program;
body: StatementNode[];
render(code: MagicString, options: RenderOptions): void;
}

View File

@ -0,0 +1,30 @@
import { ExpressionNode, Node, NodeBase } from './shared/Node';
import CallOptions from '../CallOptions';
import { ObjectPath } from '../values';
import ExecutionPathOptions from '../ExecutionPathOptions';
import Scope from '../scopes/Scope';
import MagicString from 'magic-string';
import { ExpressionEntity, ForEachReturnExpressionCallback, SomeReturnExpressionCallback } from './shared/Expression';
import { NodeType } from './NodeType';
import { RenderOptions } from '../../utils/renderHelpers';
export declare function isProperty(node: Node): node is Property;
export default class Property extends NodeBase {
type: NodeType.Property;
key: ExpressionNode;
value: ExpressionNode;
kind: 'init' | 'get' | 'set';
method: boolean;
shorthand: boolean;
computed: boolean;
private _accessorCallOptions;
reassignPath(path: ObjectPath, options: ExecutionPathOptions): void;
forEachReturnExpressionWhenCalledAtPath(path: ObjectPath, callOptions: CallOptions, callback: ForEachReturnExpressionCallback, options: ExecutionPathOptions): void;
hasEffects(options: ExecutionPathOptions): boolean;
hasEffectsWhenAccessedAtPath(path: ObjectPath, options: ExecutionPathOptions): boolean;
hasEffectsWhenAssignedAtPath(path: ObjectPath, options: ExecutionPathOptions): boolean;
hasEffectsWhenCalledAtPath(path: ObjectPath, callOptions: CallOptions, options: ExecutionPathOptions): boolean;
initialiseAndDeclare(parentScope: Scope, kind: string, _init: ExpressionEntity | null): void;
initialiseNode(_parentScope: Scope): void;
render(code: MagicString, options: RenderOptions): void;
someReturnExpressionWhenCalledAtPath(path: ObjectPath, callOptions: CallOptions, predicateFunction: SomeReturnExpressionCallback, options: ExecutionPathOptions): boolean;
}

View File

@ -0,0 +1,14 @@
import { ObjectPath } from '../values';
import ExecutionPathOptions from '../ExecutionPathOptions';
import Scope from '../scopes/Scope';
import { PatternNode } from './shared/Pattern';
import { ExpressionEntity } from './shared/Expression';
import { NodeBase } from './shared/Node';
import { NodeType } from './NodeType';
export default class RestElement extends NodeBase implements PatternNode {
type: NodeType.RestElement;
argument: PatternNode;
reassignPath(path: ObjectPath, options: ExecutionPathOptions): void;
hasEffectsWhenAssignedAtPath(path: ObjectPath, options: ExecutionPathOptions): boolean;
initialiseAndDeclare(parentScope: Scope, kind: string, _init: ExpressionEntity | null): void;
}

View File

@ -0,0 +1,9 @@
import ExecutionPathOptions from '../ExecutionPathOptions';
import { NodeType } from './NodeType';
import { ExpressionNode, StatementBase } from './shared/Node';
export default class ReturnStatement extends StatementBase {
type: NodeType.ReturnStatement;
argument: ExpressionNode | null;
hasEffects(options: ExecutionPathOptions): boolean;
initialiseNode(): void;
}

View File

@ -0,0 +1,21 @@
import ExecutionPathOptions from '../ExecutionPathOptions';
import MagicString from 'magic-string';
import { ExpressionNode, NodeBase } from './shared/Node';
import { NodeType } from './NodeType';
import { NodeRenderOptions, RenderOptions } from '../../utils/renderHelpers';
import { ObjectPath } from '../values';
import CallOptions from '../CallOptions';
import { ForEachReturnExpressionCallback } from './shared/Expression';
export default class SequenceExpression extends NodeBase {
type: NodeType.SequenceExpression;
expressions: ExpressionNode[];
forEachReturnExpressionWhenCalledAtPath(path: ObjectPath, callOptions: CallOptions, callback: ForEachReturnExpressionCallback, options: ExecutionPathOptions): void;
getValue(): any;
hasEffects(options: ExecutionPathOptions): boolean;
hasEffectsWhenAccessedAtPath(path: ObjectPath, options: ExecutionPathOptions): boolean;
hasEffectsWhenAssignedAtPath(path: ObjectPath, options: ExecutionPathOptions): boolean;
hasEffectsWhenCalledAtPath(path: ObjectPath, callOptions: CallOptions, options: ExecutionPathOptions): boolean;
includeInBundle(): boolean;
reassignPath(path: ObjectPath, options: ExecutionPathOptions): void;
render(code: MagicString, options: RenderOptions, {renderedParentType, isCalleeOfRenderedParent}?: NodeRenderOptions): void;
}

View File

@ -0,0 +1,6 @@
import { ExpressionNode } from './shared/Node';
import { NodeType } from './NodeType';
export default interface SpreadElement extends ExpressionNode {
type: NodeType.SpreadElement;
argument: ExpressionNode;
}

View File

@ -0,0 +1,11 @@
import { ExpressionNode, NodeBase, StatementNode } from './shared/Node';
import { NodeType } from './NodeType';
import { RenderOptions } from '../../utils/renderHelpers';
import MagicString from 'magic-string';
export default class SwitchCase extends NodeBase {
type: NodeType.SwitchCase;
test: ExpressionNode | null;
consequent: StatementNode[];
includeInBundle(): boolean;
render(code: MagicString, options: RenderOptions): void;
}

View File

@ -0,0 +1,12 @@
import SwitchCase from './SwitchCase';
import ExecutionPathOptions from '../ExecutionPathOptions';
import Scope from '../scopes/Scope';
import { NodeType } from './NodeType';
import { ExpressionNode, StatementBase } from './shared/Node';
export default class SwitchStatement extends StatementBase {
type: NodeType.SwitchStatement;
discriminant: ExpressionNode;
cases: SwitchCase[];
hasEffects(options: ExecutionPathOptions): boolean;
initialiseScope(parentScope: Scope): void;
}

View File

@ -0,0 +1,13 @@
import TemplateLiteral from './TemplateLiteral';
import ExecutionPathOptions from '../ExecutionPathOptions';
import { NodeType } from './NodeType';
import { ExpressionNode, NodeBase } from './shared/Node';
export default class TaggedTemplateExpression extends NodeBase {
type: NodeType.TaggedTemplateExpression;
tag: ExpressionNode;
quasi: TemplateLiteral;
private _callOptions;
bindNode(): void;
hasEffects(options: ExecutionPathOptions): boolean;
initialiseNode(): void;
}

View File

@ -0,0 +1,12 @@
import { NodeBase } from './shared/Node';
import ExecutionPathOptions from '../ExecutionPathOptions';
import { NodeType } from './NodeType';
export default class TemplateElement extends NodeBase {
type: NodeType.TemplateElement;
tail: boolean;
value: {
cooked: string;
raw: string;
};
hasEffects(_options: ExecutionPathOptions): boolean;
}

View File

@ -0,0 +1,12 @@
import TemplateElement from './TemplateElement';
import MagicString from 'magic-string';
import { ExpressionNode, Node, NodeBase } from './shared/Node';
import { NodeType } from './NodeType';
import { RenderOptions } from '../../utils/renderHelpers';
export declare function isTemplateLiteral(node: Node): node is TemplateLiteral;
export default class TemplateLiteral extends NodeBase {
type: NodeType.TemplateLiteral;
quasis: TemplateElement[];
expressions: ExpressionNode[];
render(code: MagicString, options: RenderOptions): void;
}

View File

@ -0,0 +1,17 @@
import ThisVariable from '../variables/ThisVariable';
import ExecutionPathOptions from '../ExecutionPathOptions';
import MagicString from 'magic-string';
import { NodeBase } from './shared/Node';
import { NodeType } from './NodeType';
import { RenderOptions } from '../../utils/renderHelpers';
import { ObjectPath } from '../values';
export default class ThisExpression extends NodeBase {
type: NodeType.ThisExpression;
variable: ThisVariable;
alias: string;
initialiseNode(): void;
bindNode(): void;
hasEffectsWhenAccessedAtPath(path: ObjectPath, options: ExecutionPathOptions): boolean;
hasEffectsWhenAssignedAtPath(path: ObjectPath, options: ExecutionPathOptions): boolean;
render(code: MagicString, _options: RenderOptions): void;
}

View File

@ -0,0 +1,8 @@
import ExecutionPathOptions from '../ExecutionPathOptions';
import { NodeType } from './NodeType';
import { ExpressionNode, StatementBase } from './shared/Node';
export default class ThrowStatement extends StatementBase {
type: NodeType.ThrowStatement;
argument: ExpressionNode;
hasEffects(_options: ExecutionPathOptions): boolean;
}

View File

@ -0,0 +1,16 @@
import { ObjectPath } from '../values';
import ExecutionPathOptions from '../ExecutionPathOptions';
import { NodeType } from './NodeType';
import { ExpressionNode, NodeBase } from './shared/Node';
export default class UnaryExpression extends NodeBase {
type: NodeType.UnaryExpression;
operator: '-' | '+' | '!' | '~' | 'typeof' | 'void' | 'delete';
prefix: boolean;
argument: ExpressionNode;
value: any;
bindNode(): void;
getValue(): any;
hasEffects(options: ExecutionPathOptions): boolean;
hasEffectsWhenAccessedAtPath(path: ObjectPath, _options: ExecutionPathOptions): boolean;
initialiseNode(): void;
}

View File

@ -0,0 +1,5 @@
import ExecutionPathOptions from '../ExecutionPathOptions';
import { NodeBase } from './shared/Node';
export default class UnknownNode extends NodeBase {
hasEffects(_options: ExecutionPathOptions): boolean;
}

View File

@ -0,0 +1,13 @@
import ExecutionPathOptions from '../ExecutionPathOptions';
import { NodeType } from './NodeType';
import { ExpressionNode, NodeBase } from './shared/Node';
import { ObjectPath } from '../values';
export default class UpdateExpression extends NodeBase {
type: NodeType.UpdateExpression;
operator: '++' | '--' | '**';
argument: ExpressionNode;
prefix: boolean;
bindNode(): void;
hasEffects(options: ExecutionPathOptions): boolean;
hasEffectsWhenAccessedAtPath(path: ObjectPath, _options: ExecutionPathOptions): boolean;
}

View File

@ -0,0 +1,21 @@
import { Node, NodeBase } from './shared/Node';
import ExecutionPathOptions from '../ExecutionPathOptions';
import VariableDeclarator from './VariableDeclarator';
import MagicString from 'magic-string';
import { NodeType } from './NodeType';
import { NodeRenderOptions, RenderOptions } from '../../utils/renderHelpers';
import { ObjectPath } from '../values';
export declare function isVariableDeclaration(node: Node): node is VariableDeclaration;
export default class VariableDeclaration extends NodeBase {
type: NodeType.VariableDeclaration;
declarations: VariableDeclarator[];
kind: 'var' | 'let' | 'const';
reassignPath(_path: ObjectPath, _options: ExecutionPathOptions): void;
hasEffectsWhenAssignedAtPath(_path: ObjectPath, _options: ExecutionPathOptions): boolean;
includeWithAllDeclaredVariables(): boolean;
includeInBundle(): boolean;
initialiseChildren(): void;
render(code: MagicString, options: RenderOptions, nodeRenderOptions?: NodeRenderOptions): void;
private renderReplacedDeclarations(code, options, {start, end, isNoStatement});
private renderDeclarationEnd(code, separatorString, lastSeparatorPos, actualContentEnd, renderedContentEnd, addSemicolon);
}

View File

@ -0,0 +1,13 @@
import { ExpressionNode, NodeBase } from './shared/Node';
import Scope from '../scopes/Scope';
import ExecutionPathOptions from '../ExecutionPathOptions';
import { PatternNode } from './shared/Pattern';
import { NodeType } from './NodeType';
import { ObjectPath } from '../values';
export default class VariableDeclarator extends NodeBase {
type: NodeType.VariableDeclarator;
id: PatternNode;
init: ExpressionNode | null;
reassignPath(path: ObjectPath, options: ExecutionPathOptions): void;
initialiseDeclarator(parentScope: Scope, kind: string): void;
}

View File

@ -0,0 +1,9 @@
import ExecutionPathOptions from '../ExecutionPathOptions';
import { NodeType } from './NodeType';
import { ExpressionNode, StatementBase, StatementNode } from './shared/Node';
export default class WhileStatement extends StatementBase {
type: NodeType.WhileStatement;
test: ExpressionNode;
body: StatementNode;
hasEffects(options: ExecutionPathOptions): boolean;
}

View File

@ -0,0 +1,9 @@
import ExecutionPathOptions from '../ExecutionPathOptions';
import { NodeType } from './NodeType';
import { ExpressionNode, NodeBase } from './shared/Node';
export default class YieldExpression extends NodeBase {
type: NodeType.YieldExpression;
argument: ExpressionNode | null;
delegate: boolean;
hasEffects(options: ExecutionPathOptions): boolean;
}

View File

@ -0,0 +1,6 @@
import { NodeBase } from './shared/Node';
declare const nodes: {
[name: string]: typeof NodeBase;
};
export { NodeType } from './NodeType';
export default nodes;

View File

@ -0,0 +1,17 @@
import Scope from '../../scopes/Scope';
import CallOptions from '../../CallOptions';
import ExecutionPathOptions from '../../ExecutionPathOptions';
import Identifier from '../Identifier';
import ClassBody from '../ClassBody';
import { ExpressionNode, NodeBase } from './Node';
import { ObjectPath } from '../../values';
export default class ClassNode extends NodeBase {
body: ClassBody;
superClass: ExpressionNode | null;
id: Identifier | null;
hasEffectsWhenAccessedAtPath(path: ObjectPath, _options: ExecutionPathOptions): boolean;
hasEffectsWhenAssignedAtPath(path: ObjectPath, _options: ExecutionPathOptions): boolean;
hasEffectsWhenCalledAtPath(path: ObjectPath, callOptions: CallOptions, options: ExecutionPathOptions): boolean;
initialiseChildren(_parentScope: Scope): void;
initialiseScope(parentScope: Scope): void;
}

View File

@ -0,0 +1,21 @@
import { WritableEntity } from '../../Entity';
import CallOptions from '../../CallOptions';
import ExecutionPathOptions from '../../ExecutionPathOptions';
import { ObjectPath } from '../../values';
export declare type PredicateFunction = (node: ExpressionEntity) => boolean;
export declare type SomeReturnExpressionCallback = (options: ExecutionPathOptions) => PredicateFunction;
export declare type ForEachReturnExpressionCallback = (options: ExecutionPathOptions) => (node: ExpressionEntity) => void;
export interface ExpressionEntity extends WritableEntity {
/**
* Executes the callback on each possible return expression when calling this node.
*/
forEachReturnExpressionWhenCalledAtPath(path: ObjectPath, callOptions: CallOptions, callback: ForEachReturnExpressionCallback, options: ExecutionPathOptions): void;
getValue(): any;
hasEffectsWhenAccessedAtPath(path: ObjectPath, options: ExecutionPathOptions): boolean;
hasEffectsWhenCalledAtPath(path: ObjectPath, callOptions: CallOptions, options: ExecutionPathOptions): boolean;
/**
* Should return true if some possible return expression when called at the given
* path returns true.
*/
someReturnExpressionWhenCalledAtPath(path: ObjectPath, callOptions: CallOptions, predicateFunction: SomeReturnExpressionCallback, options: ExecutionPathOptions): boolean;
}

View File

@ -0,0 +1,25 @@
import FunctionScope from '../../scopes/FunctionScope';
import BlockScope from '../../scopes/FunctionScope';
import BlockStatement from '../BlockStatement';
import Identifier from '../Identifier';
import CallOptions from '../../CallOptions';
import ExecutionPathOptions from '../../ExecutionPathOptions';
import { PatternNode } from './Pattern';
import { ForEachReturnExpressionCallback, SomeReturnExpressionCallback } from './Expression';
import { NodeBase } from './Node';
import { ObjectPath } from '../../values';
export default class FunctionNode extends NodeBase {
id: Identifier;
body: BlockStatement;
scope: BlockScope;
params: PatternNode[];
bindNode(): void;
forEachReturnExpressionWhenCalledAtPath(path: ObjectPath, callOptions: CallOptions, callback: ForEachReturnExpressionCallback, options: ExecutionPathOptions): void;
hasEffects(options: ExecutionPathOptions): boolean;
hasEffectsWhenAccessedAtPath(path: ObjectPath): boolean;
hasEffectsWhenAssignedAtPath(path: ObjectPath): boolean;
hasEffectsWhenCalledAtPath(path: ObjectPath, callOptions: CallOptions, options: ExecutionPathOptions): boolean;
includeInBundle(): boolean;
initialiseScope(parentScope: FunctionScope): void;
someReturnExpressionWhenCalledAtPath(path: ObjectPath, callOptions: CallOptions, predicateFunction: SomeReturnExpressionCallback, options: ExecutionPathOptions): boolean;
}

View File

@ -0,0 +1,133 @@
import ExecutionPathOptions from '../../ExecutionPathOptions';
import Scope from '../../scopes/Scope';
import Module from '../../../Module';
import MagicString from 'magic-string';
import Variable from '../../variables/Variable';
import { ExpressionEntity, ForEachReturnExpressionCallback, SomeReturnExpressionCallback } from './Expression';
import CallOptions from '../../CallOptions';
import { ObjectPath } from '../../values';
import { Entity } from '../../Entity';
import { NodeRenderOptions, RenderOptions } from '../../../utils/renderHelpers';
export interface Node extends Entity {
end: number;
included: boolean;
keys: string[];
module: Module;
needsBoundaries?: boolean;
parent: Node | {
type?: string;
};
start: number;
type: string;
variable?: Variable;
__enhanced: boolean;
/**
* Called once all nodes have been initialised and the scopes have been populated.
* Usually one should not override this function but override bindNode and/or
* bindChildren instead.
*/
bind(): void;
eachChild(callback: (node: Node) => void): void;
/**
* Determine if this Node would have an effect on the bundle.
* This is usually true for already included nodes. Exceptions are e.g. break statements
* which only have an effect if their surrounding loop or switch statement is included.
* The options pass on information like this about the current execution path.
*/
hasEffects(options: ExecutionPathOptions): boolean;
/**
* Includes the node in the bundle. Children are usually included if they are
* necessary for this node (e.g. a function body) or if they have effects.
* Necessary variables need to be included as well. Should return true if any
* nodes or variables have been added that were missing before.
*/
includeInBundle(): boolean;
/**
* Alternative version of includeInBundle to override the default behaviour of
* declarations to only include nodes for declarators that have an effect. Necessary
* for for-loops that do not use a declared loop variable.
*/
includeWithAllDeclaredVariables(): boolean;
/**
* Assign a scope to this node and make sure all children have the right scopes.
* Perform any additional initialisation that does not depend on the scope being
* populated with variables.
* Usually one should not override this function but override initialiseScope,
* initialiseNode and/or initialiseChildren instead. BlockScopes have a special
* alternative initialisation initialiseAndReplaceScope.
*/
initialise(parentScope: Scope): void;
initialiseAndDeclare(parentScope: Scope, kind: string, init: ExpressionEntity | null): void;
render(code: MagicString, options: RenderOptions, nodeRenderOptions?: NodeRenderOptions): void;
/**
* Start a new execution path to determine if this node has an effect on the bundle and
* should therefore be included. Included nodes should always be included again in subsequent
* visits as the inclusion of additional variables may require the inclusion of more child
* nodes in e.g. block statements.
*/
shouldBeIncluded(): boolean;
someChild(callback: (node: Node) => boolean): boolean;
}
export interface StatementNode extends Node {
}
export interface ExpressionNode extends ExpressionEntity, Node {
}
export declare class NodeBase implements ExpressionNode {
type: string;
keys: string[];
included: boolean;
scope: Scope;
start: number;
end: number;
module: Module;
parent: Node | {
type?: string;
};
__enhanced: boolean;
constructor();
bind(): void;
/**
* Override to control on which children "bind" is called.
*/
bindChildren(): void;
/**
* Override this to bind assignments to variables and do any initialisations that
* require the scopes to be populated with variables.
*/
bindNode(): void;
eachChild(callback: (node: Node) => void): void;
forEachReturnExpressionWhenCalledAtPath(_path: ObjectPath, _callOptions: CallOptions, _callback: ForEachReturnExpressionCallback, _options: ExecutionPathOptions): void;
getValue(): {
toString: () => string;
};
hasEffects(options: ExecutionPathOptions): boolean;
hasEffectsWhenAccessedAtPath(path: ObjectPath, _options: ExecutionPathOptions): boolean;
hasEffectsWhenAssignedAtPath(_path: ObjectPath, _options: ExecutionPathOptions): boolean;
hasEffectsWhenCalledAtPath(_path: ObjectPath, _callOptions: CallOptions, _options: ExecutionPathOptions): boolean;
private hasIncludedChild();
includeInBundle(): boolean;
includeWithAllDeclaredVariables(): boolean;
initialise(parentScope: Scope): void;
initialiseAndDeclare(_parentScope: Scope, _kind: string, _init: ExpressionEntity | null): void;
/**
* Override to change how and with what scopes children are initialised
*/
initialiseChildren(_parentScope: Scope): void;
/**
* Override to perform special initialisation steps after the scope is initialised
*/
initialiseNode(_parentScope: Scope): void;
/**
* Override if this scope should receive a different scope than the parent scope.
*/
initialiseScope(parentScope: Scope): void;
insertSemicolon(code: MagicString): void;
locate(): any;
reassignPath(_path: ObjectPath, _options: ExecutionPathOptions): void;
render(code: MagicString, options: RenderOptions): void;
shouldBeIncluded(): boolean;
someChild(callback: (node: NodeBase) => boolean): boolean;
someReturnExpressionWhenCalledAtPath(_path: ObjectPath, _callOptions: CallOptions, predicateFunction: SomeReturnExpressionCallback, options: ExecutionPathOptions): boolean;
toString(): string;
}
export { NodeBase as StatementBase };

View File

@ -0,0 +1,4 @@
import { WritableEntity } from '../../Entity';
import { Node } from './Node';
export interface PatternNode extends WritableEntity, Node {
}

View File

@ -0,0 +1,4 @@
declare const pureFunctions: {
[name: string]: boolean;
};
export default pureFunctions;

View File

@ -0,0 +1,9 @@
import Scope from './Scope';
import Identifier from '../nodes/Identifier';
import LocalVariable from '../variables/LocalVariable';
export default class BlockScope extends Scope {
parent: Scope;
addDeclaration(identifier: Identifier, options?: {
isHoisted: boolean;
}): LocalVariable;
}

View File

@ -0,0 +1,10 @@
import ParameterScope from './ParameterScope';
import Identifier from '../nodes/Identifier';
import Scope from './Scope';
import LocalVariable from '../variables/LocalVariable';
export default class CatchScope extends ParameterScope {
parent: Scope;
addDeclaration(identifier: Identifier, options?: {
isHoisted: boolean;
}): LocalVariable;
}

View File

@ -0,0 +1,20 @@
import ReturnValueScope from './ReturnValueScope';
import ArgumentsVariable from '../variables/ArgumentsVariable';
import ThisVariable from '../variables/ThisVariable';
import ExecutionPathOptions from '../ExecutionPathOptions';
import CallOptions from '../CallOptions';
import ExportDefaultVariable from '../variables/ExportDefaultVariable';
import LocalVariable from '../variables/LocalVariable';
import GlobalVariable from '../variables/GlobalVariable';
import ExternalVariable from '../variables/ExternalVariable';
export default class FunctionScope extends ReturnValueScope {
variables: {
this: ThisVariable;
default: ExportDefaultVariable;
arguments: ArgumentsVariable;
[name: string]: LocalVariable | GlobalVariable | ExternalVariable | ArgumentsVariable;
};
constructor(options?: {});
findLexicalBoundary(): this;
getOptionsWhenCalledWith({args, withNew}: CallOptions, options: ExecutionPathOptions): ExecutionPathOptions;
}

View File

@ -0,0 +1,7 @@
import GlobalVariable from '../variables/GlobalVariable';
import Scope from './Scope';
export default class GlobalScope extends Scope {
parent: void;
findVariable(name: string): GlobalVariable;
deshadow(names: Set<string>, children?: Scope[]): void;
}

View File

@ -0,0 +1,11 @@
import Scope from './Scope';
import Module from '../../Module';
import Variable from '../variables/Variable';
export default class ModuleScope extends Scope {
parent: Scope;
module: Module;
constructor(module: Module);
deshadow(names: Set<string>, children?: Scope[]): void;
findLexicalBoundary(): this;
findVariable(name: string): Variable;
}

View File

@ -0,0 +1,16 @@
import Scope from './Scope';
import ParameterVariable from '../variables/ParameterVariable';
import Identifier from '../nodes/Identifier';
export default class ParameterScope extends Scope {
parent: Scope;
_parameters: ParameterVariable[];
constructor(options?: {});
/**
* Adds a parameter to this scope. Parameters must be added in the correct
* order, e.g. from left to right.
* @param {Identifier} identifier
* @returns {Variable}
*/
addParameterDeclaration(identifier: Identifier): ParameterVariable;
getParameterVariables(): ParameterVariable[];
}

View File

@ -0,0 +1,11 @@
import ParameterScope from './ParameterScope';
import CallOptions from '../CallOptions';
import ExecutionPathOptions from '../ExecutionPathOptions';
import { ExpressionEntity, ForEachReturnExpressionCallback } from '../nodes/shared/Expression';
export default class ReturnValueScope extends ParameterScope {
_returnExpressions: Set<ExpressionEntity>;
constructor(options?: {});
addReturnExpression(expression: ExpressionEntity): void;
forEachReturnExpressionWhenCalled(_callOptions: CallOptions, callback: ForEachReturnExpressionCallback, options: ExecutionPathOptions): void;
someReturnExpressionWhenCalled(_callOptions: CallOptions, predicateFunction: (options: ExecutionPathOptions) => (node: ExpressionEntity) => boolean, options: ExecutionPathOptions): boolean;
}

42
node_modules/rollup/dist/typings/ast/scopes/Scope.d.ts generated vendored Normal file
View File

@ -0,0 +1,42 @@
import LocalVariable from '../variables/LocalVariable';
import ExportDefaultVariable from '../variables/ExportDefaultVariable';
import Identifier from '../nodes/Identifier';
import ExportDefaultDeclaration from '../nodes/ExportDefaultDeclaration';
import GlobalVariable from '../variables/GlobalVariable';
import ThisVariable from '../variables/ThisVariable';
import ArgumentsVariable from '../variables/ArgumentsVariable';
import Variable from '../variables/Variable';
import { ExpressionEntity } from '../nodes/shared/Expression';
import ExternalVariable from '../variables/ExternalVariable';
export default class Scope {
parent: Scope | void;
variables: {
this: ThisVariable | LocalVariable;
default: ExportDefaultVariable;
arguments: ArgumentsVariable;
[name: string]: LocalVariable | GlobalVariable | ExternalVariable | ArgumentsVariable;
};
isModuleScope: boolean;
children: Scope[];
constructor(options?: {
parent?: Scope;
isModuleScope?: boolean;
});
/**
* @param identifier
* @param {Object} [options] - valid options are
* {(Node|null)} init
* {boolean} isHoisted
* @return {Variable}
*/
addDeclaration(identifier: Identifier, options?: {
init?: ExpressionEntity | null;
isHoisted?: boolean;
}): LocalVariable | GlobalVariable | ExternalVariable | ArgumentsVariable;
addExportDefaultDeclaration(name: string, exportDefaultDeclaration: ExportDefaultDeclaration): ExportDefaultVariable;
addReturnExpression(expression: ExpressionEntity): void;
contains(name: string): boolean;
deshadow(names: Set<string>, children?: Scope[]): void;
findLexicalBoundary(): Scope;
findVariable(name: string): Variable;
}

View File

@ -0,0 +1,2 @@
import { Node } from '../nodes/shared/Node';
export default function extractNames(param: Node): string[];

31
node_modules/rollup/dist/typings/ast/values.d.ts generated vendored Normal file
View File

@ -0,0 +1,31 @@
import { ExpressionEntity, SomeReturnExpressionCallback } from './nodes/shared/Expression';
import CallOptions from './CallOptions';
import { LiteralValueTypes } from './nodes/Literal';
import ExecutionPathOptions from './ExecutionPathOptions';
export interface UnknownKey {
type: 'UNKNOWN_KEY';
}
export declare type ObjectPathKey = string | UnknownKey;
export declare type ObjectPath = ObjectPathKey[];
export declare function isUnknownKey(key: ObjectPathKey): key is UnknownKey;
export declare const UNKNOWN_KEY: UnknownKey;
export declare type PathCallback = (path: ObjectPath, expression: ExpressionEntity) => void;
export declare type PathPredicate = (path: ObjectPath, expression: ExpressionEntity) => boolean;
export interface MemberDescription {
returns: ExpressionEntity;
callsArgs: number[] | null;
}
export interface MemberDescriptions {
[key: string]: MemberDescription;
}
export declare const UNKNOWN_VALUE: {
toString: () => string;
};
export declare const UNKNOWN_EXPRESSION: ExpressionEntity;
export declare const UNKNOWN_ARRAY_EXPRESSION: ExpressionEntity;
export declare const UNKNOWN_OBJECT_EXPRESSION: ExpressionEntity;
export declare const objectMembers: MemberDescriptions;
export declare const arrayMembers: MemberDescriptions;
export declare function getLiteralMembersForValue<T = LiteralValueTypes>(value: T): any;
export declare function hasMemberEffectWhenCalled(members: MemberDescriptions, memberName: ObjectPathKey, callOptions: CallOptions, options: ExecutionPathOptions): boolean;
export declare function someMemberReturnExpressionWhenCalled(members: MemberDescriptions, memberName: ObjectPathKey, callOptions: CallOptions, predicateFunction: SomeReturnExpressionCallback, options: ExecutionPathOptions): boolean;

View File

@ -0,0 +1,15 @@
import LocalVariable from './LocalVariable';
import { ObjectPath } from '../values';
import ExecutionPathOptions from '../ExecutionPathOptions';
import CallOptions from '../CallOptions';
import ParameterVariable from './ParameterVariable';
import { SomeReturnExpressionCallback } from '../nodes/shared/Expression';
export default class ArgumentsVariable extends LocalVariable {
private _parameters;
constructor(parameters: ParameterVariable[]);
reassignPath(path: ObjectPath, options: ExecutionPathOptions): void;
hasEffectsWhenAccessedAtPath(path: ObjectPath, options: ExecutionPathOptions): boolean;
hasEffectsWhenAssignedAtPath(path: ObjectPath, options: ExecutionPathOptions): boolean;
hasEffectsWhenCalledAtPath(path: ObjectPath, callOptions: CallOptions, options: ExecutionPathOptions): boolean;
someReturnExpressionWhenCalledAtPath(path: ObjectPath, callOptions: CallOptions, predicateFunction: SomeReturnExpressionCallback, options: ExecutionPathOptions): boolean;
}

View File

@ -0,0 +1,16 @@
import LocalVariable from './LocalVariable';
import ExportDefaultDeclaration from '../nodes/ExportDefaultDeclaration';
import Identifier from '../nodes/Identifier';
import Variable from './Variable';
export declare function isExportDefaultVariable(variable: Variable): variable is ExportDefaultVariable;
export default class ExportDefaultVariable extends LocalVariable {
isDefault: true;
hasId: boolean;
private _original;
constructor(name: string, exportDefaultDeclaration: ExportDefaultDeclaration);
addReference(identifier: Identifier): void;
getName(reset?: boolean): string;
referencesOriginal(): boolean;
getOriginalVariableName(): string;
setOriginalVariable(original: Variable): void;
}

View File

@ -0,0 +1,12 @@
import Variable from './Variable';
import Identifier from '../nodes/Identifier';
import ExternalModule from '../../ExternalModule';
export declare function isExternalVariable(variable: Variable): variable is ExternalVariable;
export default class ExternalVariable extends Variable {
module: ExternalModule;
isExternal: true;
isNamespace: boolean;
constructor(module: ExternalModule, name: string);
addReference(identifier: Identifier): void;
includeVariable(): boolean;
}

View File

@ -0,0 +1,10 @@
import Variable from './Variable';
import { ObjectPath } from '../values';
export default class GlobalVariable extends Variable {
isExternal: true;
isGlobal: true;
constructor(name: string);
hasEffectsWhenAccessedAtPath(path: ObjectPath): boolean;
hasEffectsWhenCalledAtPath(path: ObjectPath): boolean;
private isPureFunctionMember(path);
}

View File

@ -0,0 +1,21 @@
import Variable from './Variable';
import VariableReassignmentTracker from './VariableReassignmentTracker';
import ExecutionPathOptions from '../ExecutionPathOptions';
import CallOptions from '../CallOptions';
import Identifier from '../nodes/Identifier';
import ExportDefaultDeclaration from '../nodes/ExportDefaultDeclaration';
import { ExpressionEntity, ForEachReturnExpressionCallback, SomeReturnExpressionCallback } from '../nodes/shared/Expression';
import { ObjectPath } from '../values';
export default class LocalVariable extends Variable {
declarations: Set<Identifier | ExportDefaultDeclaration>;
boundExpressions: VariableReassignmentTracker;
constructor(name: string, declarator: Identifier | ExportDefaultDeclaration | null, init: ExpressionEntity);
addDeclaration(identifier: Identifier): void;
forEachReturnExpressionWhenCalledAtPath(path: ObjectPath, callOptions: CallOptions, callback: ForEachReturnExpressionCallback, options: ExecutionPathOptions): void;
hasEffectsWhenAccessedAtPath(path: ObjectPath, options: ExecutionPathOptions): boolean;
hasEffectsWhenAssignedAtPath(path: ObjectPath, options: ExecutionPathOptions): boolean;
hasEffectsWhenCalledAtPath(path: ObjectPath, callOptions: CallOptions, options: ExecutionPathOptions): boolean;
includeVariable(): boolean;
reassignPath(path: ObjectPath, options: ExecutionPathOptions): void;
someReturnExpressionWhenCalledAtPath(path: ObjectPath, callOptions: CallOptions, predicateFunction: SomeReturnExpressionCallback, options: ExecutionPathOptions): boolean;
}

View File

@ -0,0 +1,20 @@
import Variable from './Variable';
import Identifier from '../nodes/Identifier';
import Module from '../../Module';
import { RenderOptions } from '../../utils/renderHelpers';
export declare function isNamespaceVariable(variable: Variable): variable is NamespaceVariable;
export default class NamespaceVariable extends Variable {
isNamespace: true;
module: Module;
needsNamespaceBlock: boolean;
referencedEarly: boolean;
originals: {
[name: string]: Variable;
};
references: Identifier[];
constructor(module: Module);
addReference(identifier: Identifier): void;
includeVariable(): boolean;
renderFirst(): boolean;
renderBlock(options: RenderOptions): string;
}

View File

@ -0,0 +1,5 @@
import ReplaceableInitializationVariable from './ReplaceableInitializationVariable';
import Identifier from '../nodes/Identifier';
export default class ParameterVariable extends ReplaceableInitializationVariable {
constructor(identifier: Identifier);
}

View File

@ -0,0 +1,14 @@
import LocalVariable from './LocalVariable';
import { ObjectPath } from '../values';
import ExecutionPathOptions from '../ExecutionPathOptions';
import CallOptions from '../CallOptions';
import Identifier from '../nodes/Identifier';
import { ExpressionEntity, SomeReturnExpressionCallback } from '../nodes/shared/Expression';
export default class ReplaceableInitializationVariable extends LocalVariable {
constructor(name: string, declarator: Identifier | null);
hasEffectsWhenAccessedAtPath(path: ObjectPath, options: ExecutionPathOptions): boolean;
hasEffectsWhenAssignedAtPath(path: ObjectPath, options: ExecutionPathOptions): boolean;
hasEffectsWhenCalledAtPath(path: ObjectPath, callOptions: CallOptions, options: ExecutionPathOptions): boolean;
someReturnExpressionWhenCalledAtPath(path: ObjectPath, callOptions: CallOptions, predicateFunction: SomeReturnExpressionCallback, options: ExecutionPathOptions): boolean;
_getInit(options: ExecutionPathOptions): ExpressionEntity;
}

View File

@ -0,0 +1,4 @@
import ReplaceableInitializationVariable from './ReplaceableInitializationVariable';
export default class ThisVariable extends ReplaceableInitializationVariable {
constructor();
}

View File

@ -0,0 +1,43 @@
import { ObjectPath } from '../values';
import CallOptions from '../CallOptions';
import ExecutionPathOptions from '../ExecutionPathOptions';
import Identifier from '../nodes/Identifier';
import { ExpressionEntity, ForEachReturnExpressionCallback, SomeReturnExpressionCallback } from '../nodes/shared/Expression';
export default class Variable implements ExpressionEntity {
exportName?: string;
included: boolean;
isExternal?: boolean;
isGlobal?: boolean;
isDefault?: boolean;
isNamespace?: boolean;
isReassigned: boolean;
isId: boolean;
name: string;
reexported?: boolean;
safeName: string;
constructor(name: string);
/**
* Binds identifiers that reference this variable to this variable.
* Necessary to be able to change variable names.
*/
addReference(_identifier: Identifier): void;
reassignPath(_path: ObjectPath, _options: ExecutionPathOptions): void;
forEachReturnExpressionWhenCalledAtPath(_path: ObjectPath, _callOptions: CallOptions, _callback: ForEachReturnExpressionCallback, _options: ExecutionPathOptions): void;
getName(reset?: boolean): string;
getValue(): {
toString: () => string;
};
hasEffectsWhenAccessedAtPath(path: ObjectPath, _options: ExecutionPathOptions): boolean;
hasEffectsWhenAssignedAtPath(_path: ObjectPath, _options: ExecutionPathOptions): boolean;
hasEffectsWhenCalledAtPath(_path: ObjectPath, _callOptions: CallOptions, _options: ExecutionPathOptions): boolean;
/**
* Marks this variable as being part of the bundle, which is usually the case when one of
* its identifiers becomes part of the bundle. Returns true if it has not been included
* previously.
* Once a variable is included, it should take care all its declarations are included.
*/
includeVariable(): boolean;
someReturnExpressionWhenCalledAtPath(_path: ObjectPath, _callOptions: CallOptions, predicateFunction: SomeReturnExpressionCallback, options: ExecutionPathOptions): boolean;
toString(): string;
setSafeName(name: string): void;
}

View File

@ -0,0 +1,11 @@
import { ObjectPath, PathCallback, PathPredicate } from '../values';
import ExecutionPathOptions from '../ExecutionPathOptions';
import { ExpressionEntity } from '../nodes/shared/Expression';
export default class VariableReassignmentTracker {
private _initialExpression;
private _reassignedPathTracker;
constructor(initialExpression: ExpressionEntity);
reassignPath(path: ObjectPath, options: ExecutionPathOptions): void;
forEachAtPath(path: ObjectPath, callback: PathCallback): void;
someAtPath(path: ObjectPath, predicateFunction: PathPredicate): boolean;
}