New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@aurelia/debug

Package Overview
Dependencies
Maintainers
1
Versions
571
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aurelia/debug - npm Package Compare versions

Comparing version 0.2.0 to 0.3.0-dev.20181013

src/binding/binding-context.ts

117

CHANGELOG.md

@@ -6,5 +6,120 @@ # Change Log

<a name="0.3.0"></a>
# 0.3.0 (2018-10-12)
### Features:
* **kernel:** add decoratable interface to support strongly typed decorators ([f67a414](https://github.com/aurelia/aurelia/commit/f67a414))
* **binding:** add @connectable decorator back in (strongly typed) ([f67a414](https://github.com/aurelia/aurelia/commit/f67a414))
* **all:** implement InterpolationBinding ([f67a414](https://github.com/aurelia/aurelia/commit/f67a414))
* **unparser:** implement interpolation unparsing ([f67a414](https://github.com/aurelia/aurelia/commit/f67a414))
* **expression-parser:** delegate errors to Reporter for more descriptive errors ([a0c9b0e](https://github.com/aurelia/aurelia/commit/a0c9b0e))
* **debug:** create AST expression serializer ([a0c9b0e](https://github.com/aurelia/aurelia/commit/a0c9b0e))
* **expression-parser:** improve error reporting ([a0c9b0e](https://github.com/aurelia/aurelia/commit/a0c9b0e))
* **kernel:** add unwrap interface ([197235c](https://github.com/aurelia/aurelia/commit/197235c))
* **ast:** add visitor interface and implement accept methods on AST ([197235c](https://github.com/aurelia/aurelia/commit/197235c))
* **expression-parser:** allow member expressions on numeric literals ([197235c](https://github.com/aurelia/aurelia/commit/197235c))
* **template-compiler:** handle semicolon-separated bindings in attributes ([ad6eeb4](https://github.com/aurelia/aurelia/commit/ad6eeb4))
* **jit:** decouple attribute/element parsing from template compiler ([ad6eeb4](https://github.com/aurelia/aurelia/commit/ad6eeb4))
* **template-compiler:** add initial implementation of semantic model ([ad6eeb4](https://github.com/aurelia/aurelia/commit/ad6eeb4))
* **renderer:** throw specific error codes on target/instruction count mismatch ([ad6eeb4](https://github.com/aurelia/aurelia/commit/ad6eeb4))
### Bug Fixes:
* **kernel:** fix decorated interface ([f67a414](https://github.com/aurelia/aurelia/commit/f67a414))
* **binding:** wrap updatetarget/updatesource so vCurrent BBs work again ([f67a414](https://github.com/aurelia/aurelia/commit/f67a414))
* **expression-parser:** fix differentation for caching of expressions/interpolations ([f67a414](https://github.com/aurelia/aurelia/commit/f67a414))
* **iterator-binding:** correctly compile and render ForOfStatement ([f67a414](https://github.com/aurelia/aurelia/commit/f67a414))
* **expression-parser:** correctly parse "unsafe" integers ([a0c9b0e](https://github.com/aurelia/aurelia/commit/a0c9b0e))
* **expression-parser:** disable broken "raw" values on template for now ([a0c9b0e](https://github.com/aurelia/aurelia/commit/a0c9b0e))
* **expression-parser:** correctly parse member expressions when preceded by a unary operator ([a0c9b0e](https://github.com/aurelia/aurelia/commit/a0c9b0e))
* **expression-parser:** allow template strings to have member expressions ([a0c9b0e](https://github.com/aurelia/aurelia/commit/a0c9b0e))
* **expression-parser:** allow AccessThis to be the tag for a template ([a0c9b0e](https://github.com/aurelia/aurelia/commit/a0c9b0e))
* **expression-parser:** use IsAssign instead of Conditional precedence for nested expressions ([a0c9b0e](https://github.com/aurelia/aurelia/commit/a0c9b0e))
* **expression-parser:** fix binary sibling operator precedence ([a0c9b0e](https://github.com/aurelia/aurelia/commit/a0c9b0e))
* **expression-parser:** ensure AccessScope is assignable ([a0c9b0e](https://github.com/aurelia/aurelia/commit/a0c9b0e))
* **expression-parser:** properly detect EOF for unterminated quote instead of hanging ([a0c9b0e](https://github.com/aurelia/aurelia/commit/a0c9b0e))
* **expression-parser:** throw on invalid dot terminal in AccessThis ([a0c9b0e](https://github.com/aurelia/aurelia/commit/a0c9b0e))
* **expression-parser:** throw on unterminated template instead of hanging ([a0c9b0e](https://github.com/aurelia/aurelia/commit/a0c9b0e))
* **expression-parser:** correctly parse number with trailing dot ([a0c9b0e](https://github.com/aurelia/aurelia/commit/a0c9b0e))
* **debug:** correct / update unparser and debug mode ([197235c](https://github.com/aurelia/aurelia/commit/197235c))
* **expression-parser:** fix parsing error with trailing elision ([197235c](https://github.com/aurelia/aurelia/commit/197235c))
* **expression-parser:** allow AccessThis as the last element of an array ([197235c](https://github.com/aurelia/aurelia/commit/197235c))
* **expression-parser:** allow AccessThis as the condition in a conditional ([197235c](https://github.com/aurelia/aurelia/commit/197235c))
* **expression-parser:** allow AccessThis as left-hand side of binary expressions ([197235c](https://github.com/aurelia/aurelia/commit/197235c))
* **expression-parser:** reset access after parsing non-identifiers ([197235c](https://github.com/aurelia/aurelia/commit/197235c))
* **unparser:** explicitly reconstruct precedence ([197235c](https://github.com/aurelia/aurelia/commit/197235c))
* **template-compiler:** make non-bindable customElement instructions siblings of the element instruction ([ad6eeb4](https://github.com/aurelia/aurelia/commit/ad6eeb4))
* **template-compiler:** properly resolve bindable customElement instructions by the registered attribute name ([ad6eeb4](https://github.com/aurelia/aurelia/commit/ad6eeb4))
* **scope:** add bindingContext to overrideContext ([ad6eeb4](https://github.com/aurelia/aurelia/commit/ad6eeb4))
### Performance Improvements:
* **expression-parser:** remove unreachable branch ([f67a414](https://github.com/aurelia/aurelia/commit/f67a414))
* **expression-parser:** reuse one ParserState object ([a0c9b0e](https://github.com/aurelia/aurelia/commit/a0c9b0e))
* **expression-parser:** use explicit numeric comparisons for bitwise operators ([197235c](https://github.com/aurelia/aurelia/commit/197235c))
* **element-parser:** use PLATFORM.emptyArray where possible and remove redundant property ([ad6eeb4](https://github.com/aurelia/aurelia/commit/ad6eeb4))
* **template-compiler:** convert parseAttribute to class instance with cache ([ad6eeb4](https://github.com/aurelia/aurelia/commit/ad6eeb4))
* **semantic-model:** use PLATFORM.emptyArray when possible ([ad6eeb4](https://github.com/aurelia/aurelia/commit/ad6eeb4))
* **element-parser:** use PLATFORM.emptyArray when possible ([ad6eeb4](https://github.com/aurelia/aurelia/commit/ad6eeb4))
### Refactorings:
* **binding:** cleanup/shuffle some interfaces accordingly ([f67a414](https://github.com/aurelia/aurelia/commit/f67a414))
* **template-compiler:** cleanup/inline instruction classes ([f67a414](https://github.com/aurelia/aurelia/commit/f67a414))
* **expression-parser:** extract enums and util function out into common.ts ([a0c9b0e](https://github.com/aurelia/aurelia/commit/a0c9b0e))
* **jit:** improve parser registration and attribute testing ([ad6eeb4](https://github.com/aurelia/aurelia/commit/ad6eeb4))
* **attribute-parser:** store raw attribute values in syntax ([ad6eeb4](https://github.com/aurelia/aurelia/commit/ad6eeb4))
* **template-compiler:** decouple entrypoint from internal recursion point ([ad6eeb4](https://github.com/aurelia/aurelia/commit/ad6eeb4))
* **template-compiler:** first step to integrate the semantic model ([ad6eeb4](https://github.com/aurelia/aurelia/commit/ad6eeb4))
* **template-compiler:** initial migration steps to semantic model ([ad6eeb4](https://github.com/aurelia/aurelia/commit/ad6eeb4))
* **template-compiler:** more small tweaks, enable a few more tests ([ad6eeb4](https://github.com/aurelia/aurelia/commit/ad6eeb4))
* **template-compiler:** recognize single value attribute as bindable ([ad6eeb4](https://github.com/aurelia/aurelia/commit/ad6eeb4))
* **template-compiler:** fix plain attribute compilation ([ad6eeb4](https://github.com/aurelia/aurelia/commit/ad6eeb4))
* **template-compiler:** fix template controller / repeater compilation ([ad6eeb4](https://github.com/aurelia/aurelia/commit/ad6eeb4))
* **template-compiler:** fix semicolon-separated attribute bindings ([ad6eeb4](https://github.com/aurelia/aurelia/commit/ad6eeb4))
* **template-compiler:** fix let and textNodes ([ad6eeb4](https://github.com/aurelia/aurelia/commit/ad6eeb4))
* **template-compiler:** fix as-element ([ad6eeb4](https://github.com/aurelia/aurelia/commit/ad6eeb4))
* **template-compiler:** fix surrogates ([ad6eeb4](https://github.com/aurelia/aurelia/commit/ad6eeb4))
* **template-compiler:** fix let.dest ([ad6eeb4](https://github.com/aurelia/aurelia/commit/ad6eeb4))
* **template-compiler:** fix as-element / resourceKey ([ad6eeb4](https://github.com/aurelia/aurelia/commit/ad6eeb4))
* **template-compiler:** fix bindable precedence ([ad6eeb4](https://github.com/aurelia/aurelia/commit/ad6eeb4))
* **template-compiler:** fix slots ([ad6eeb4](https://github.com/aurelia/aurelia/commit/ad6eeb4))
* **template-compiler:** fix nested+sibling template controllers and cleanup the api a bit ([ad6eeb4](https://github.com/aurelia/aurelia/commit/ad6eeb4))
* **template-compiler:** fix let ([ad6eeb4](https://github.com/aurelia/aurelia/commit/ad6eeb4))
<a name="0.2.0"></a>
# 0.2.0 (2018-09-18)
**Note:** Version bump only for package @aurelia/debug
### Features:
* **observers:** auto-enable collection observers and make the toggles idempotent ([d6a10b5](https://github.com/aurelia/aurelia/commit/d6a10b5))
* **custom-elements:** define basic abstraction for element projection ([0a17b16](https://github.com/aurelia/aurelia/commit/0a17b16))
* **runtime:** enable getting the custom element behavior... ([0a17b16](https://github.com/aurelia/aurelia/commit/0a17b16))
### Bug Fixes:
* **examples:** correct versions ([1b7c764](https://github.com/aurelia/aurelia/commit/1b7c764))
* **tsconfig:** correct extends path ([797674f](https://github.com/aurelia/aurelia/commit/797674f))
* **jit-parcel:** remove else for now, fix instructions ([d6a10b5](https://github.com/aurelia/aurelia/commit/d6a10b5))
* **template-compiler:** wrap the nodes in a fragment ([d6a10b5](https://github.com/aurelia/aurelia/commit/d6a10b5))
* **jit-parcel:** remove path mappings from tsconfig ([d6a10b5](https://github.com/aurelia/aurelia/commit/d6a10b5))
* **template-compiler:** use firstElementChild instead of wrapper ([d6a10b5](https://github.com/aurelia/aurelia/commit/d6a10b5))
* **template-compiler:** various small tweaks and fixes, make example work ([d6a10b5](https://github.com/aurelia/aurelia/commit/d6a10b5))
* **jit-parcel:** make the example work with something simple ([d6a10b5](https://github.com/aurelia/aurelia/commit/d6a10b5))
* **aurelia:** set isStarted=true after tasks have finished ([d6a10b5](https://github.com/aurelia/aurelia/commit/d6a10b5))
* **e2e:** move publish into e2e job ([d6a10b5](https://github.com/aurelia/aurelia/commit/d6a10b5))
* **ci:** fix typo ([d6a10b5](https://github.com/aurelia/aurelia/commit/d6a10b5))
* **ci:** set the correct path before each cmd ([d6a10b5](https://github.com/aurelia/aurelia/commit/d6a10b5))
* **ci:** try a different approach for the workspaces ([d6a10b5](https://github.com/aurelia/aurelia/commit/d6a10b5))
* **templating:** address trivial errors when removing emulation ([0a17b16](https://github.com/aurelia/aurelia/commit/0a17b16))
* **templating:** remove shadow dom from compose element ([0a17b16](https://github.com/aurelia/aurelia/commit/0a17b16))
* **all:** last few corrections from the merge ([0a17b16](https://github.com/aurelia/aurelia/commit/0a17b16))
* **runtime:** various fixes related to compose ([0a17b16](https://github.com/aurelia/aurelia/commit/0a17b16))
* **kernel:** scripts working ([9302580](https://github.com/aurelia/aurelia/commit/9302580))
* **all:** lots of path fixes and a few typing fixes, make sure everything builds correctly ([9302580](https://github.com/aurelia/aurelia/commit/9302580))
* **test:** make all the tests run via lerna ([9302580](https://github.com/aurelia/aurelia/commit/9302580))

5

dist/binding/binding-context.d.ts
import { IScope } from '@aurelia/runtime';
export declare const BindingContext: {
createScopeForTest(bindingContext: any, parentBindingContext?: any): IScope;
createScope(bindingContext: any, overrideContext?: import("@aurelia/runtime/dist/binding/binding-context").IOverrideContext): IScope;
createScopeFromOverride(overrideContext: import("@aurelia/runtime/dist/binding/binding-context").IOverrideContext): IScope;
createScopeFromParent(parentScope: IScope, bindingContext: any): IScope;
createOverride(bindingContext?: any, parentOverrideContext?: import("@aurelia/runtime/dist/binding/binding-context").IOverrideContext): import("@aurelia/runtime/dist/binding/binding-context").IOverrideContext;
get(scope: IScope, name: string, ancestor: number): any;
};
//# sourceMappingURL=binding-context.d.ts.map

@@ -5,3 +5,2 @@ export * from './binding/binding-context';

export * from './reporter';
export * from './task-queue';
//# sourceMappingURL=index.d.ts.map

@@ -1,2 +0,2 @@

import { BindingContext, ITaskQueue, AccessKeyed, AccessMember, AccessScope, AccessThis, Assign, Binary, BindingBehavior, CallFunction, CallMember, CallScope, Conditional, ArrayLiteral, ObjectLiteral, PrimitiveLiteral, Unary, HtmlLiteral, ValueConverter } from '@aurelia/runtime';
import { BindingContext, AccessKeyed, AccessMember, AccessScope, AccessThis, ArrayBindingPattern, ArrayLiteral, Assign, Binary, BindingBehavior, BindingIdentifier, CallFunction, CallMember, CallScope, Conditional, ForOfStatement, HtmlLiteral, Interpolation, ObjectBindingPattern, ObjectLiteral, PrimitiveLiteral, TaggedTemplate, Template, Unary, ValueConverter } from '@aurelia/runtime';
import { Reporter } from '@aurelia/kernel';

@@ -17,181 +17,403 @@

const astTypeMap = [
{ type: AccessKeyed, name: 'AccessKeyed' },
{ type: AccessMember, name: 'AccessMember' },
{ type: AccessScope, name: 'AccessScope' },
{ type: AccessThis, name: 'AccessThis' },
{ type: ArrayBindingPattern, name: 'ArrayBindingPattern' },
{ type: ArrayLiteral, name: 'ArrayLiteral' },
{ type: Assign, name: 'Assign' },
{ type: Binary, name: 'Binary' },
{ type: BindingBehavior, name: 'BindingBehavior' },
{ type: BindingIdentifier, name: 'BindingIdentifier' },
{ type: CallFunction, name: 'CallFunction' },
{ type: CallMember, name: 'CallMember' },
{ type: CallScope, name: 'CallScope' },
{ type: Conditional, name: 'Conditional' },
{ type: ForOfStatement, name: 'ForOfStatement' },
{ type: HtmlLiteral, name: 'HtmlLiteral' },
{ type: Interpolation, name: 'Interpolation' },
{ type: ObjectBindingPattern, name: 'ObjectBindingPattern' },
{ type: ObjectLiteral, name: 'ObjectLiteral' },
{ type: PrimitiveLiteral, name: 'PrimitiveLiteral' },
{ type: TaggedTemplate, name: 'TaggedTemplate' },
{ type: Template, name: 'Template' },
{ type: Unary, name: 'Unary' },
{ type: ValueConverter, name: 'ValueConverter' }
];
function enableImprovedExpressionDebugging() {
[
{ type: AccessKeyed, name: 'AccessKeyed' },
{ type: AccessMember, name: 'AccessMember' },
{ type: AccessScope, name: 'AccessScope' },
{ type: AccessThis, name: 'AccessThis' },
{ type: Assign, name: 'Assign' },
{ type: Binary, name: 'Binary' },
{ type: BindingBehavior, name: 'BindingBehavior' },
{ type: CallFunction, name: 'CallFunction' },
{ type: CallMember, name: 'CallMember' },
{ type: CallScope, name: 'CallScope' },
{ type: Conditional, name: 'Conditional' },
{ type: ArrayLiteral, name: 'LiteralArray' },
{ type: ObjectLiteral, name: 'LiteralObject' },
{ type: PrimitiveLiteral, name: 'LiteralPrimitive' },
{ type: PrimitiveLiteral, name: 'LiteralString' },
{ type: Unary, name: 'Unary' },
{ type: HtmlLiteral, name: 'TemplateLiteral' },
{ type: ValueConverter, name: 'ValueConverter' }
].forEach(x => adoptDebugMethods(x.type, x.name));
astTypeMap.forEach(x => adoptDebugMethods(x.type, x.name));
}
/*@internal*/
function adoptDebugMethods(type, name) {
type.prototype.toString = function () { return Unparser.unparse(this); };
type.prototype.accept = function (visitor) { return visitor['visit' + name](this); };
function adoptDebugMethods($type, name) {
$type.prototype.toString = function () { return Unparser.unparse(this); };
}
/*@internal*/
class Unparser {
constructor(buffer) {
this.buffer = buffer;
this.buffer = buffer;
constructor() {
this.text = '';
}
static unparse(expression) {
let buffer = [];
let visitor = new Unparser(buffer);
expression.accept(visitor);
return buffer.join('');
static unparse(expr) {
const visitor = new Unparser();
expr.accept(visitor);
return visitor.text;
}
write(text) {
this.buffer.push(text);
visitAccessMember(expr) {
expr.object.accept(this);
this.text += `.${expr.name}`;
}
writeArgs(args) {
this.write('(');
for (let i = 0, length = args.length; i < length; ++i) {
visitAccessKeyed(expr) {
expr.object.accept(this);
this.text += '[';
expr.key.accept(this);
this.text += ']';
}
visitAccessThis(expr) {
if (expr.ancestor === 0) {
this.text += '$this';
return;
}
this.text += '$parent';
let i = expr.ancestor - 1;
while (i--) {
this.text += '.$parent';
}
}
visitAccessScope(expr) {
let i = expr.ancestor;
while (i--) {
this.text += '$parent.';
}
this.text += expr.name;
}
visitArrayLiteral(expr) {
const elements = expr.elements;
this.text += '[';
for (let i = 0, length = elements.length; i < length; ++i) {
if (i !== 0) {
this.write(',');
this.text += ',';
}
args[i].accept(this);
elements[i].accept(this);
}
this.write(')');
this.text += ']';
}
visitBindingBehavior(behavior) {
let args = behavior.args;
behavior.expression.accept(this);
this.write(`&${behavior.name}`);
for (let i = 0, length = args.length; i < length; ++i) {
this.write(':');
args[i].accept(this);
visitObjectLiteral(expr) {
const keys = expr.keys;
const values = expr.values;
this.text += '{';
for (let i = 0, length = keys.length; i < length; ++i) {
if (i !== 0) {
this.text += ',';
}
this.text += `'${keys[i]}':`;
values[i].accept(this);
}
this.text += '}';
}
visitValueConverter(converter) {
let args = converter.args;
converter.expression.accept(this);
this.write(`|${converter.name}`);
for (let i = 0, length = args.length; i < length; ++i) {
this.write(':');
args[i].accept(this);
visitPrimitiveLiteral(expr) {
this.text += '(';
if (typeof expr.value === 'string') {
const escaped = expr.value.replace(/'/g, '\'');
this.text += `'${escaped}'`;
}
else {
this.text += `${expr.value}`;
}
this.text += ')';
}
visitAssign(assign) {
assign.target.accept(this);
this.write('=');
assign.value.accept(this);
visitCallFunction(expr) {
this.text += '(';
expr.func.accept(this);
this.writeArgs(expr.args);
this.text += ')';
}
visitConditional(conditional) {
conditional.condition.accept(this);
this.write('?');
conditional.yes.accept(this);
this.write(':');
conditional.no.accept(this);
visitCallMember(expr) {
this.text += '(';
expr.object.accept(this);
this.text += `.${expr.name}`;
this.writeArgs(expr.args);
this.text += ')';
}
visitAccessThis(access) {
if (access.ancestor === 0) {
this.write('$this');
return;
}
this.write('$parent');
let i = access.ancestor - 1;
visitCallScope(expr) {
this.text += '(';
let i = expr.ancestor;
while (i--) {
this.write('.$parent');
this.text += '$parent.';
}
this.text += expr.name;
this.writeArgs(expr.args);
this.text += ')';
}
visitAccessScope(access) {
let i = access.ancestor;
while (i--) {
this.write('$parent.');
visitTemplate(expr) {
const { cooked, expressions } = expr;
const length = expressions.length;
this.text += '`';
this.text += cooked[0];
for (let i = 0; i < length; i++) {
expressions[i].accept(this);
this.text += cooked[i + 1];
}
this.write(access.name);
this.text += '`';
}
visitAccessMember(access) {
access.object.accept(this);
this.write(`.${access.name}`);
visitTaggedTemplate(expr) {
const { cooked, expressions } = expr;
const length = expressions.length;
expr.func.accept(this);
this.text += '`';
this.text += cooked[0];
for (let i = 0; i < length; i++) {
expressions[i].accept(this);
this.text += cooked[i + 1];
}
this.text += '`';
}
visitAccessKeyed(access) {
access.object.accept(this);
this.write('[');
access.key.accept(this);
this.write(']');
visitUnary(expr) {
this.text += `(${expr.operation}`;
if (expr.operation.charCodeAt(0) >= /*a*/ 97) {
this.text += ' ';
}
expr.expression.accept(this);
this.text += ')';
}
visitCallScope(call) {
let i = call.ancestor;
while (i--) {
this.write('$parent.');
visitBinary(expr) {
this.text += '(';
expr.left.accept(this);
if (expr.operation.charCodeAt(0) === /*i*/ 105) {
this.text += ` ${expr.operation} `;
}
this.write(call.name);
this.writeArgs(call.args);
else {
this.text += expr.operation;
}
expr.right.accept(this);
this.text += ')';
}
visitCallFunction(call) {
call.func.accept(this);
this.writeArgs(call.args);
visitConditional(expr) {
this.text += '(';
expr.condition.accept(this);
this.text += '?';
expr.yes.accept(this);
this.text += ':';
expr.no.accept(this);
this.text += ')';
}
visitCallMember(call) {
call.object.accept(this);
this.write(`.${call.name}`);
this.writeArgs(call.args);
visitAssign(expr) {
this.text += '(';
expr.target.accept(this);
this.text += '=';
expr.value.accept(this);
this.text += ')';
}
visitUnary(unary) {
this.write(`(${unary.operation}`);
unary.expression.accept(this);
this.write(')');
visitValueConverter(expr) {
const args = expr.args;
expr.expression.accept(this);
this.text += `|${expr.name}`;
for (let i = 0, length = args.length; i < length; ++i) {
this.text += ':';
args[i].accept(this);
}
}
visitBinary(binary) {
binary.left.accept(this);
this.write(binary.operation);
binary.right.accept(this);
visitBindingBehavior(expr) {
const args = expr.args;
expr.expression.accept(this);
this.text += `&${expr.name}`;
for (let i = 0, length = args.length; i < length; ++i) {
this.text += ':';
args[i].accept(this);
}
}
visitLiteralPrimitive(literal) {
this.write(`${literal.value}`);
}
visitLiteralArray(literal) {
let elements = literal.elements;
this.write('[');
visitArrayBindingPattern(expr) {
const elements = expr.elements;
this.text += '[';
for (let i = 0, length = elements.length; i < length; ++i) {
if (i !== 0) {
this.write(',');
this.text += ',';
}
elements[i].accept(this);
}
this.write(']');
this.text += ']';
}
visitLiteralObject(literal) {
let keys = literal.keys;
let values = literal.values;
this.write('{');
visitObjectBindingPattern(expr) {
const keys = expr.keys;
const values = expr.values;
this.text += '{';
for (let i = 0, length = keys.length; i < length; ++i) {
if (i !== 0) {
this.write(',');
this.text += ',';
}
this.write(`'${keys[i]}':`);
this.text += `'${keys[i]}':`;
values[i].accept(this);
}
this.write('}');
this.text += '}';
}
visitLiteralString(literal) {
let escaped = literal.value.replace(/'/g, "\'");
this.write(`'${escaped}'`);
visitBindingIdentifier(expr) {
this.text += expr.name;
}
visitTemplateLiteral(node) {
let parts = node.parts;
for (let i = 0, length = parts.length; i < length; ++i) {
parts[i].accept(this);
visitHtmlLiteral(expr) { throw new Error('visitHtmlLiteral'); }
visitForOfStatement(expr) {
expr.declaration.accept(this);
this.text += ' of ';
expr.iterable.accept(this);
}
visitInterpolation(expr) {
const { parts, expressions } = expr;
const length = expressions.length;
this.text += '${';
this.text += parts[0];
for (let i = 0; i < length; i++) {
expressions[i].accept(this);
this.text += parts[i + 1];
}
this.text += '}';
}
writeArgs(args) {
this.text += '(';
for (let i = 0, length = args.length; i < length; ++i) {
if (i !== 0) {
this.text += ',';
}
args[i].accept(this);
}
this.text += ')';
}
}
/*@internal*/
class Serializer {
static serialize(expr) {
const visitor = new Serializer();
if (expr === null || expr === undefined || typeof expr.accept !== 'function') {
return `${expr}`;
}
return expr.accept(visitor);
}
visitAccessMember(expr) {
return `{"type":"AccessMember","name":${expr.name},"object":${expr.object.accept(this)}}`;
}
visitAccessKeyed(expr) {
return `{"type":"AccessKeyed","object":${expr.object.accept(this)},"key":${expr.key.accept(this)}}`;
}
visitAccessThis(expr) {
return `{"type":"AccessThis","ancestor":${expr.ancestor}}`;
}
visitAccessScope(expr) {
return `{"type":"AccessScope","name":"${expr.name}","ancestor":${expr.ancestor}}`;
}
visitArrayLiteral(expr) {
return `{"type":"ArrayLiteral","elements":${this.serializeExpressions(expr.elements)}}`;
}
visitObjectLiteral(expr) {
return `{"type":"ObjectLiteral","keys":${serializePrimitives(expr.keys)},"values":${this.serializeExpressions(expr.values)}}`;
}
visitPrimitiveLiteral(expr) {
return `{"type":"PrimitiveLiteral","value":${serializePrimitive(expr.value)}}`;
}
visitCallFunction(expr) {
return `{"type":"CallFunction","func":${expr.func.accept(this)},"args":${this.serializeExpressions(expr.args)}}`;
}
visitCallMember(expr) {
return `{"type":"CallMember","name":"${expr.name}","object":${expr.object.accept(this)},"args":${this.serializeExpressions(expr.args)}}`;
}
visitCallScope(expr) {
return `{"type":"CallScope","name":"${expr.name}","ancestor":${expr.ancestor},"args":${this.serializeExpressions(expr.args)}}`;
}
visitTemplate(expr) {
return `{"type":"Template","cooked":${serializePrimitives(expr.cooked)},"expressions":${this.serializeExpressions(expr.expressions)}}`;
}
visitTaggedTemplate(expr) {
return `{"type":"TaggedTemplate","cooked":${serializePrimitives(expr.cooked)},"raw":${serializePrimitives(expr.cooked.raw)},"expressions":${this.serializeExpressions(expr.expressions)}}`;
}
visitUnary(expr) {
return `{"type":"Unary","operation":"${expr.operation}","expression":${expr.expression.accept(this)}}`;
}
visitBinary(expr) {
return `{"type":"Binary","operation":"${expr.operation}","left":${expr.left.accept(this)},"right":${expr.right.accept(this)}}`;
}
visitConditional(expr) {
return `{"type":"Conditional","condition":${expr.condition.accept(this)},"yes":${expr.yes.accept(this)},"no":${expr.no.accept(this)}}`;
}
visitAssign(expr) {
return `{"type":"Assign","target":${expr.target.accept(this)},"value":${expr.value.accept(this)}}`;
}
visitValueConverter(expr) {
return `{"type":"ValueConverter","name":"${expr.name}","expression":${expr.expression.accept(this)},"args":${this.serializeExpressions(expr.args)}}`;
}
visitBindingBehavior(expr) {
return `{"type":"BindingBehavior","name":"${expr.name}","expression":${expr.expression.accept(this)},"args":${this.serializeExpressions(expr.args)}}`;
}
visitArrayBindingPattern(expr) {
return `{"type":"ArrayBindingPattern","elements":${this.serializeExpressions(expr.elements)}}`;
}
visitObjectBindingPattern(expr) {
return `{"type":"ObjectBindingPattern","keys":${serializePrimitives(expr.keys)},"values":${this.serializeExpressions(expr.values)}}`;
}
visitBindingIdentifier(expr) {
return `{"type":"BindingIdentifier","name":"${expr.name}"}`;
}
visitHtmlLiteral(expr) { throw new Error('visitHtmlLiteral'); }
visitForOfStatement(expr) {
return `{"type":"ForOfStatement","declaration":${expr.declaration.accept(this)},"iterable":${expr.iterable.accept(this)}}`;
}
visitInterpolation(expr) {
return `{"type":"Interpolation","cooked":${serializePrimitives(expr.parts)},"expressions":${this.serializeExpressions(expr.expressions)}}`;
}
// tslint:disable-next-line:no-any
serializeExpressions(args) {
let text = '[';
for (let i = 0, ii = args.length; i < ii; ++i) {
if (i !== 0) {
text += ',';
}
text += args[i].accept(this);
}
text += ']';
return text;
}
}
// tslint:disable-next-line:no-any
function serializePrimitives(values) {
let text = '[';
for (let i = 0, ii = values.length; i < ii; ++i) {
if (i !== 0) {
text += ',';
}
text += serializePrimitive(values[i]);
}
text += ']';
return text;
}
// tslint:disable-next-line:no-any
function serializePrimitive(value) {
if (typeof value === 'string') {
return `"\\"${escapeString(value)}\\""`;
}
else if (value === null || value === undefined) {
return `"${value}"`;
}
else {
return `${value}`;
}
}
function escapeString(str) {
let ret = '';
for (let i = 0, ii = str.length; i < ii; ++i) {
ret += escape(str.charAt(i));
}
return ret;
}
function escape(ch) {
switch (ch) {
case '\b': return '\\b';
case '\t': return '\\t';
case '\n': return '\\n';
case '\v': return '\\v';
case '\f': return '\\f';
case '\r': return '\\r';
case '\"': return '\\"';
case '\'': return '\\\'';
case '\\': return '\\\\';
default: return ch;
}
}
const Reporter$1 = Object.assign(Reporter, {
write(code, ...params) {
let info = getMessageInfoForCode(code);
const Reporter$1 = Object.assign({}, Reporter, { write(code, ...params) {
const info = getMessageInfoForCode(code);
switch (info.type) {

@@ -212,8 +434,7 @@ case 3 /* debug */:

error(code, ...params) {
let info = getMessageInfoForCode(code);
let error = new Error(info.message);
const info = getMessageInfoForCode(code);
const error = new Error(info.message);
error.data = params;
return error;
}
});
} });
function getMessageInfoForCode(code) {

@@ -281,6 +502,2 @@ return codeLookup[code] || createInvalidCodeMessageInfo(code);

},
13: {
type: 0 /* error */,
message: 'TaskQueue long stack traces are only available in debug mode.'
},
14: {

@@ -321,72 +538,73 @@ type: 0 /* error */,

message: 'A containerless custom element cannot be the root component of an application.'
},
30: {
type: 0 /* error */,
message: 'There are more targets than there are target instructions.'
},
31: {
type: 0 /* error */,
message: 'There are more target instructions than there are targets.'
},
100: {
type: 0 /* error */,
message: 'Invalid start of expression.'
},
101: {
type: 0 /* error */,
message: 'Unconsumed token.'
},
102: {
type: 0 /* error */,
message: 'Double dot and spread operators are not supported.'
},
103: {
type: 0 /* error */,
message: 'Invalid member expression.'
},
104: {
type: 0 /* error */,
message: 'Unexpected end of expression.'
},
105: {
type: 0 /* error */,
message: 'Expected identifier.'
},
106: {
type: 0 /* error */,
message: 'Invalid BindingIdentifier at left hand side of "of".'
},
107: {
type: 0 /* error */,
message: 'Invalid or unsupported property definition in object literal.'
},
108: {
type: 0 /* error */,
message: 'Unterminated quote in string literal.'
},
109: {
type: 0 /* error */,
message: 'Unterminated template string.'
},
110: {
type: 0 /* error */,
message: 'Missing expected token.'
},
111: {
type: 0 /* error */,
message: 'Unexpected character.'
},
150: {
type: 0 /* error */,
message: 'Left hand side of expression is not assignable.'
},
151: {
type: 0 /* error */,
message: 'Unexpected keyword "of"'
}
};
function enableImprovedTaskQueueDebugging(container) {
container.registerTransformer(ITaskQueue, taskQueue => {
const stackSeparator = '\nEnqueued in TaskQueue by:\n';
const microStackSeparator = '\nEnqueued in MicroTaskQueue by:\n';
const originalOnError = taskQueue.onError.bind(taskQueue);
return Object.assign(taskQueue, {
longStacks: true,
prepareTaskStack() {
return this.prepareStack(stackSeparator);
},
prepareMicroTaskStack() {
return this.prepareStack(microStackSeparator);
},
prepareStack(separator) {
let stack = separator + filterQueueStack(captureStack());
if (typeof this.stack === 'string') {
stack = filterFlushStack(stack) + this.stack;
}
return stack;
},
onError(error, task) {
if (this.longStacks && task.stack && typeof error === 'object' && error !== null) {
// Note: IE sets error.stack when throwing but does not override a defined .stack.
error.stack = filterFlushStack(error.stack) + task.stack;
}
originalOnError(error, task);
}
});
});
}
function captureStack() {
let error = new Error();
// Firefox, Chrome, Edge all have .stack defined by now, IE has not.
if (error.stack) {
return error.stack;
}
try {
throw error;
}
catch (e) {
return e.stack;
}
}
function filterQueueStack(stack) {
// Remove everything (error message + top stack frames) up to the topmost queueTask or queueMicroTask call
return stack.replace(/^[\s\S]*?\bqueue(Micro)?Task\b[^\n]*\n/, '');
}
function filterFlushStack(stack) {
// Remove bottom frames starting with the last flushTaskQueue or flushMicroTaskQueue
let index = stack.lastIndexOf('flushMicroTaskQueue');
if (index < 0) {
index = stack.lastIndexOf('flushTaskQueue');
if (index < 0) {
return stack;
}
}
index = stack.lastIndexOf('\n', index);
return index < 0 ? stack : stack.substr(0, index);
// The following would work but without regex support to match from end of string,
// it's hard to ensure we have the last occurrence of "flushTaskQueue".
// return stack.replace(/\n[^\n]*?\bflush(Micro)?TaskQueue\b[\s\S]*$/, "");
}
const DebugConfiguration = {
register(container) {
Reporter$1.write(2);
enableImprovedTaskQueueDebugging(container);
Object.assign(Reporter, Reporter$1);
enableImprovedExpressionDebugging();

@@ -396,3 +614,3 @@ }

export { BindingContext$1 as BindingContext, enableImprovedExpressionDebugging, adoptDebugMethods, Unparser, DebugConfiguration, Reporter$1 as Reporter, enableImprovedTaskQueueDebugging };
export { BindingContext$1 as BindingContext, enableImprovedExpressionDebugging, adoptDebugMethods, Unparser, Serializer, DebugConfiguration, Reporter$1 as Reporter };
//# sourceMappingURL=index.es6.js.map

@@ -20,181 +20,403 @@ (function (global, factory) {

const astTypeMap = [
{ type: AST.AccessKeyed, name: 'AccessKeyed' },
{ type: AST.AccessMember, name: 'AccessMember' },
{ type: AST.AccessScope, name: 'AccessScope' },
{ type: AST.AccessThis, name: 'AccessThis' },
{ type: AST.ArrayBindingPattern, name: 'ArrayBindingPattern' },
{ type: AST.ArrayLiteral, name: 'ArrayLiteral' },
{ type: AST.Assign, name: 'Assign' },
{ type: AST.Binary, name: 'Binary' },
{ type: AST.BindingBehavior, name: 'BindingBehavior' },
{ type: AST.BindingIdentifier, name: 'BindingIdentifier' },
{ type: AST.CallFunction, name: 'CallFunction' },
{ type: AST.CallMember, name: 'CallMember' },
{ type: AST.CallScope, name: 'CallScope' },
{ type: AST.Conditional, name: 'Conditional' },
{ type: AST.ForOfStatement, name: 'ForOfStatement' },
{ type: AST.HtmlLiteral, name: 'HtmlLiteral' },
{ type: AST.Interpolation, name: 'Interpolation' },
{ type: AST.ObjectBindingPattern, name: 'ObjectBindingPattern' },
{ type: AST.ObjectLiteral, name: 'ObjectLiteral' },
{ type: AST.PrimitiveLiteral, name: 'PrimitiveLiteral' },
{ type: AST.TaggedTemplate, name: 'TaggedTemplate' },
{ type: AST.Template, name: 'Template' },
{ type: AST.Unary, name: 'Unary' },
{ type: AST.ValueConverter, name: 'ValueConverter' }
];
function enableImprovedExpressionDebugging() {
[
{ type: AST.AccessKeyed, name: 'AccessKeyed' },
{ type: AST.AccessMember, name: 'AccessMember' },
{ type: AST.AccessScope, name: 'AccessScope' },
{ type: AST.AccessThis, name: 'AccessThis' },
{ type: AST.Assign, name: 'Assign' },
{ type: AST.Binary, name: 'Binary' },
{ type: AST.BindingBehavior, name: 'BindingBehavior' },
{ type: AST.CallFunction, name: 'CallFunction' },
{ type: AST.CallMember, name: 'CallMember' },
{ type: AST.CallScope, name: 'CallScope' },
{ type: AST.Conditional, name: 'Conditional' },
{ type: AST.ArrayLiteral, name: 'LiteralArray' },
{ type: AST.ObjectLiteral, name: 'LiteralObject' },
{ type: AST.PrimitiveLiteral, name: 'LiteralPrimitive' },
{ type: AST.PrimitiveLiteral, name: 'LiteralString' },
{ type: AST.Unary, name: 'Unary' },
{ type: AST.HtmlLiteral, name: 'TemplateLiteral' },
{ type: AST.ValueConverter, name: 'ValueConverter' }
].forEach(x => adoptDebugMethods(x.type, x.name));
astTypeMap.forEach(x => adoptDebugMethods(x.type, x.name));
}
/*@internal*/
function adoptDebugMethods(type, name) {
type.prototype.toString = function () { return Unparser.unparse(this); };
type.prototype.accept = function (visitor) { return visitor['visit' + name](this); };
function adoptDebugMethods($type, name) {
$type.prototype.toString = function () { return Unparser.unparse(this); };
}
/*@internal*/
class Unparser {
constructor(buffer) {
this.buffer = buffer;
this.buffer = buffer;
constructor() {
this.text = '';
}
static unparse(expression) {
let buffer = [];
let visitor = new Unparser(buffer);
expression.accept(visitor);
return buffer.join('');
static unparse(expr) {
const visitor = new Unparser();
expr.accept(visitor);
return visitor.text;
}
write(text) {
this.buffer.push(text);
visitAccessMember(expr) {
expr.object.accept(this);
this.text += `.${expr.name}`;
}
writeArgs(args) {
this.write('(');
for (let i = 0, length = args.length; i < length; ++i) {
visitAccessKeyed(expr) {
expr.object.accept(this);
this.text += '[';
expr.key.accept(this);
this.text += ']';
}
visitAccessThis(expr) {
if (expr.ancestor === 0) {
this.text += '$this';
return;
}
this.text += '$parent';
let i = expr.ancestor - 1;
while (i--) {
this.text += '.$parent';
}
}
visitAccessScope(expr) {
let i = expr.ancestor;
while (i--) {
this.text += '$parent.';
}
this.text += expr.name;
}
visitArrayLiteral(expr) {
const elements = expr.elements;
this.text += '[';
for (let i = 0, length = elements.length; i < length; ++i) {
if (i !== 0) {
this.write(',');
this.text += ',';
}
args[i].accept(this);
elements[i].accept(this);
}
this.write(')');
this.text += ']';
}
visitBindingBehavior(behavior) {
let args = behavior.args;
behavior.expression.accept(this);
this.write(`&${behavior.name}`);
for (let i = 0, length = args.length; i < length; ++i) {
this.write(':');
args[i].accept(this);
visitObjectLiteral(expr) {
const keys = expr.keys;
const values = expr.values;
this.text += '{';
for (let i = 0, length = keys.length; i < length; ++i) {
if (i !== 0) {
this.text += ',';
}
this.text += `'${keys[i]}':`;
values[i].accept(this);
}
this.text += '}';
}
visitValueConverter(converter) {
let args = converter.args;
converter.expression.accept(this);
this.write(`|${converter.name}`);
for (let i = 0, length = args.length; i < length; ++i) {
this.write(':');
args[i].accept(this);
visitPrimitiveLiteral(expr) {
this.text += '(';
if (typeof expr.value === 'string') {
const escaped = expr.value.replace(/'/g, '\'');
this.text += `'${escaped}'`;
}
else {
this.text += `${expr.value}`;
}
this.text += ')';
}
visitAssign(assign) {
assign.target.accept(this);
this.write('=');
assign.value.accept(this);
visitCallFunction(expr) {
this.text += '(';
expr.func.accept(this);
this.writeArgs(expr.args);
this.text += ')';
}
visitConditional(conditional) {
conditional.condition.accept(this);
this.write('?');
conditional.yes.accept(this);
this.write(':');
conditional.no.accept(this);
visitCallMember(expr) {
this.text += '(';
expr.object.accept(this);
this.text += `.${expr.name}`;
this.writeArgs(expr.args);
this.text += ')';
}
visitAccessThis(access) {
if (access.ancestor === 0) {
this.write('$this');
return;
}
this.write('$parent');
let i = access.ancestor - 1;
visitCallScope(expr) {
this.text += '(';
let i = expr.ancestor;
while (i--) {
this.write('.$parent');
this.text += '$parent.';
}
this.text += expr.name;
this.writeArgs(expr.args);
this.text += ')';
}
visitAccessScope(access) {
let i = access.ancestor;
while (i--) {
this.write('$parent.');
visitTemplate(expr) {
const { cooked, expressions } = expr;
const length = expressions.length;
this.text += '`';
this.text += cooked[0];
for (let i = 0; i < length; i++) {
expressions[i].accept(this);
this.text += cooked[i + 1];
}
this.write(access.name);
this.text += '`';
}
visitAccessMember(access) {
access.object.accept(this);
this.write(`.${access.name}`);
visitTaggedTemplate(expr) {
const { cooked, expressions } = expr;
const length = expressions.length;
expr.func.accept(this);
this.text += '`';
this.text += cooked[0];
for (let i = 0; i < length; i++) {
expressions[i].accept(this);
this.text += cooked[i + 1];
}
this.text += '`';
}
visitAccessKeyed(access) {
access.object.accept(this);
this.write('[');
access.key.accept(this);
this.write(']');
visitUnary(expr) {
this.text += `(${expr.operation}`;
if (expr.operation.charCodeAt(0) >= /*a*/ 97) {
this.text += ' ';
}
expr.expression.accept(this);
this.text += ')';
}
visitCallScope(call) {
let i = call.ancestor;
while (i--) {
this.write('$parent.');
visitBinary(expr) {
this.text += '(';
expr.left.accept(this);
if (expr.operation.charCodeAt(0) === /*i*/ 105) {
this.text += ` ${expr.operation} `;
}
this.write(call.name);
this.writeArgs(call.args);
else {
this.text += expr.operation;
}
expr.right.accept(this);
this.text += ')';
}
visitCallFunction(call) {
call.func.accept(this);
this.writeArgs(call.args);
visitConditional(expr) {
this.text += '(';
expr.condition.accept(this);
this.text += '?';
expr.yes.accept(this);
this.text += ':';
expr.no.accept(this);
this.text += ')';
}
visitCallMember(call) {
call.object.accept(this);
this.write(`.${call.name}`);
this.writeArgs(call.args);
visitAssign(expr) {
this.text += '(';
expr.target.accept(this);
this.text += '=';
expr.value.accept(this);
this.text += ')';
}
visitUnary(unary) {
this.write(`(${unary.operation}`);
unary.expression.accept(this);
this.write(')');
visitValueConverter(expr) {
const args = expr.args;
expr.expression.accept(this);
this.text += `|${expr.name}`;
for (let i = 0, length = args.length; i < length; ++i) {
this.text += ':';
args[i].accept(this);
}
}
visitBinary(binary) {
binary.left.accept(this);
this.write(binary.operation);
binary.right.accept(this);
visitBindingBehavior(expr) {
const args = expr.args;
expr.expression.accept(this);
this.text += `&${expr.name}`;
for (let i = 0, length = args.length; i < length; ++i) {
this.text += ':';
args[i].accept(this);
}
}
visitLiteralPrimitive(literal) {
this.write(`${literal.value}`);
}
visitLiteralArray(literal) {
let elements = literal.elements;
this.write('[');
visitArrayBindingPattern(expr) {
const elements = expr.elements;
this.text += '[';
for (let i = 0, length = elements.length; i < length; ++i) {
if (i !== 0) {
this.write(',');
this.text += ',';
}
elements[i].accept(this);
}
this.write(']');
this.text += ']';
}
visitLiteralObject(literal) {
let keys = literal.keys;
let values = literal.values;
this.write('{');
visitObjectBindingPattern(expr) {
const keys = expr.keys;
const values = expr.values;
this.text += '{';
for (let i = 0, length = keys.length; i < length; ++i) {
if (i !== 0) {
this.write(',');
this.text += ',';
}
this.write(`'${keys[i]}':`);
this.text += `'${keys[i]}':`;
values[i].accept(this);
}
this.write('}');
this.text += '}';
}
visitLiteralString(literal) {
let escaped = literal.value.replace(/'/g, "\'");
this.write(`'${escaped}'`);
visitBindingIdentifier(expr) {
this.text += expr.name;
}
visitTemplateLiteral(node) {
let parts = node.parts;
for (let i = 0, length = parts.length; i < length; ++i) {
parts[i].accept(this);
visitHtmlLiteral(expr) { throw new Error('visitHtmlLiteral'); }
visitForOfStatement(expr) {
expr.declaration.accept(this);
this.text += ' of ';
expr.iterable.accept(this);
}
visitInterpolation(expr) {
const { parts, expressions } = expr;
const length = expressions.length;
this.text += '${';
this.text += parts[0];
for (let i = 0; i < length; i++) {
expressions[i].accept(this);
this.text += parts[i + 1];
}
this.text += '}';
}
writeArgs(args) {
this.text += '(';
for (let i = 0, length = args.length; i < length; ++i) {
if (i !== 0) {
this.text += ',';
}
args[i].accept(this);
}
this.text += ')';
}
}
/*@internal*/
class Serializer {
static serialize(expr) {
const visitor = new Serializer();
if (expr === null || expr === undefined || typeof expr.accept !== 'function') {
return `${expr}`;
}
return expr.accept(visitor);
}
visitAccessMember(expr) {
return `{"type":"AccessMember","name":${expr.name},"object":${expr.object.accept(this)}}`;
}
visitAccessKeyed(expr) {
return `{"type":"AccessKeyed","object":${expr.object.accept(this)},"key":${expr.key.accept(this)}}`;
}
visitAccessThis(expr) {
return `{"type":"AccessThis","ancestor":${expr.ancestor}}`;
}
visitAccessScope(expr) {
return `{"type":"AccessScope","name":"${expr.name}","ancestor":${expr.ancestor}}`;
}
visitArrayLiteral(expr) {
return `{"type":"ArrayLiteral","elements":${this.serializeExpressions(expr.elements)}}`;
}
visitObjectLiteral(expr) {
return `{"type":"ObjectLiteral","keys":${serializePrimitives(expr.keys)},"values":${this.serializeExpressions(expr.values)}}`;
}
visitPrimitiveLiteral(expr) {
return `{"type":"PrimitiveLiteral","value":${serializePrimitive(expr.value)}}`;
}
visitCallFunction(expr) {
return `{"type":"CallFunction","func":${expr.func.accept(this)},"args":${this.serializeExpressions(expr.args)}}`;
}
visitCallMember(expr) {
return `{"type":"CallMember","name":"${expr.name}","object":${expr.object.accept(this)},"args":${this.serializeExpressions(expr.args)}}`;
}
visitCallScope(expr) {
return `{"type":"CallScope","name":"${expr.name}","ancestor":${expr.ancestor},"args":${this.serializeExpressions(expr.args)}}`;
}
visitTemplate(expr) {
return `{"type":"Template","cooked":${serializePrimitives(expr.cooked)},"expressions":${this.serializeExpressions(expr.expressions)}}`;
}
visitTaggedTemplate(expr) {
return `{"type":"TaggedTemplate","cooked":${serializePrimitives(expr.cooked)},"raw":${serializePrimitives(expr.cooked.raw)},"expressions":${this.serializeExpressions(expr.expressions)}}`;
}
visitUnary(expr) {
return `{"type":"Unary","operation":"${expr.operation}","expression":${expr.expression.accept(this)}}`;
}
visitBinary(expr) {
return `{"type":"Binary","operation":"${expr.operation}","left":${expr.left.accept(this)},"right":${expr.right.accept(this)}}`;
}
visitConditional(expr) {
return `{"type":"Conditional","condition":${expr.condition.accept(this)},"yes":${expr.yes.accept(this)},"no":${expr.no.accept(this)}}`;
}
visitAssign(expr) {
return `{"type":"Assign","target":${expr.target.accept(this)},"value":${expr.value.accept(this)}}`;
}
visitValueConverter(expr) {
return `{"type":"ValueConverter","name":"${expr.name}","expression":${expr.expression.accept(this)},"args":${this.serializeExpressions(expr.args)}}`;
}
visitBindingBehavior(expr) {
return `{"type":"BindingBehavior","name":"${expr.name}","expression":${expr.expression.accept(this)},"args":${this.serializeExpressions(expr.args)}}`;
}
visitArrayBindingPattern(expr) {
return `{"type":"ArrayBindingPattern","elements":${this.serializeExpressions(expr.elements)}}`;
}
visitObjectBindingPattern(expr) {
return `{"type":"ObjectBindingPattern","keys":${serializePrimitives(expr.keys)},"values":${this.serializeExpressions(expr.values)}}`;
}
visitBindingIdentifier(expr) {
return `{"type":"BindingIdentifier","name":"${expr.name}"}`;
}
visitHtmlLiteral(expr) { throw new Error('visitHtmlLiteral'); }
visitForOfStatement(expr) {
return `{"type":"ForOfStatement","declaration":${expr.declaration.accept(this)},"iterable":${expr.iterable.accept(this)}}`;
}
visitInterpolation(expr) {
return `{"type":"Interpolation","cooked":${serializePrimitives(expr.parts)},"expressions":${this.serializeExpressions(expr.expressions)}}`;
}
// tslint:disable-next-line:no-any
serializeExpressions(args) {
let text = '[';
for (let i = 0, ii = args.length; i < ii; ++i) {
if (i !== 0) {
text += ',';
}
text += args[i].accept(this);
}
text += ']';
return text;
}
}
// tslint:disable-next-line:no-any
function serializePrimitives(values) {
let text = '[';
for (let i = 0, ii = values.length; i < ii; ++i) {
if (i !== 0) {
text += ',';
}
text += serializePrimitive(values[i]);
}
text += ']';
return text;
}
// tslint:disable-next-line:no-any
function serializePrimitive(value) {
if (typeof value === 'string') {
return `"\\"${escapeString(value)}\\""`;
}
else if (value === null || value === undefined) {
return `"${value}"`;
}
else {
return `${value}`;
}
}
function escapeString(str) {
let ret = '';
for (let i = 0, ii = str.length; i < ii; ++i) {
ret += escape(str.charAt(i));
}
return ret;
}
function escape(ch) {
switch (ch) {
case '\b': return '\\b';
case '\t': return '\\t';
case '\n': return '\\n';
case '\v': return '\\v';
case '\f': return '\\f';
case '\r': return '\\r';
case '\"': return '\\"';
case '\'': return '\\\'';
case '\\': return '\\\\';
default: return ch;
}
}
const Reporter = Object.assign(kernel.Reporter, {
write(code, ...params) {
let info = getMessageInfoForCode(code);
const Reporter = Object.assign({}, kernel.Reporter, { write(code, ...params) {
const info = getMessageInfoForCode(code);
switch (info.type) {

@@ -215,8 +437,7 @@ case 3 /* debug */:

error(code, ...params) {
let info = getMessageInfoForCode(code);
let error = new Error(info.message);
const info = getMessageInfoForCode(code);
const error = new Error(info.message);
error.data = params;
return error;
}
});
} });
function getMessageInfoForCode(code) {

@@ -284,6 +505,2 @@ return codeLookup[code] || createInvalidCodeMessageInfo(code);

},
13: {
type: 0 /* error */,
message: 'TaskQueue long stack traces are only available in debug mode.'
},
14: {

@@ -324,72 +541,73 @@ type: 0 /* error */,

message: 'A containerless custom element cannot be the root component of an application.'
},
30: {
type: 0 /* error */,
message: 'There are more targets than there are target instructions.'
},
31: {
type: 0 /* error */,
message: 'There are more target instructions than there are targets.'
},
100: {
type: 0 /* error */,
message: 'Invalid start of expression.'
},
101: {
type: 0 /* error */,
message: 'Unconsumed token.'
},
102: {
type: 0 /* error */,
message: 'Double dot and spread operators are not supported.'
},
103: {
type: 0 /* error */,
message: 'Invalid member expression.'
},
104: {
type: 0 /* error */,
message: 'Unexpected end of expression.'
},
105: {
type: 0 /* error */,
message: 'Expected identifier.'
},
106: {
type: 0 /* error */,
message: 'Invalid BindingIdentifier at left hand side of "of".'
},
107: {
type: 0 /* error */,
message: 'Invalid or unsupported property definition in object literal.'
},
108: {
type: 0 /* error */,
message: 'Unterminated quote in string literal.'
},
109: {
type: 0 /* error */,
message: 'Unterminated template string.'
},
110: {
type: 0 /* error */,
message: 'Missing expected token.'
},
111: {
type: 0 /* error */,
message: 'Unexpected character.'
},
150: {
type: 0 /* error */,
message: 'Left hand side of expression is not assignable.'
},
151: {
type: 0 /* error */,
message: 'Unexpected keyword "of"'
}
};
function enableImprovedTaskQueueDebugging(container) {
container.registerTransformer(AST.ITaskQueue, taskQueue => {
const stackSeparator = '\nEnqueued in TaskQueue by:\n';
const microStackSeparator = '\nEnqueued in MicroTaskQueue by:\n';
const originalOnError = taskQueue.onError.bind(taskQueue);
return Object.assign(taskQueue, {
longStacks: true,
prepareTaskStack() {
return this.prepareStack(stackSeparator);
},
prepareMicroTaskStack() {
return this.prepareStack(microStackSeparator);
},
prepareStack(separator) {
let stack = separator + filterQueueStack(captureStack());
if (typeof this.stack === 'string') {
stack = filterFlushStack(stack) + this.stack;
}
return stack;
},
onError(error, task) {
if (this.longStacks && task.stack && typeof error === 'object' && error !== null) {
// Note: IE sets error.stack when throwing but does not override a defined .stack.
error.stack = filterFlushStack(error.stack) + task.stack;
}
originalOnError(error, task);
}
});
});
}
function captureStack() {
let error = new Error();
// Firefox, Chrome, Edge all have .stack defined by now, IE has not.
if (error.stack) {
return error.stack;
}
try {
throw error;
}
catch (e) {
return e.stack;
}
}
function filterQueueStack(stack) {
// Remove everything (error message + top stack frames) up to the topmost queueTask or queueMicroTask call
return stack.replace(/^[\s\S]*?\bqueue(Micro)?Task\b[^\n]*\n/, '');
}
function filterFlushStack(stack) {
// Remove bottom frames starting with the last flushTaskQueue or flushMicroTaskQueue
let index = stack.lastIndexOf('flushMicroTaskQueue');
if (index < 0) {
index = stack.lastIndexOf('flushTaskQueue');
if (index < 0) {
return stack;
}
}
index = stack.lastIndexOf('\n', index);
return index < 0 ? stack : stack.substr(0, index);
// The following would work but without regex support to match from end of string,
// it's hard to ensure we have the last occurrence of "flushTaskQueue".
// return stack.replace(/\n[^\n]*?\bflush(Micro)?TaskQueue\b[\s\S]*$/, "");
}
const DebugConfiguration = {
register(container) {
Reporter.write(2);
enableImprovedTaskQueueDebugging(container);
Object.assign(kernel.Reporter, Reporter);
enableImprovedExpressionDebugging();

@@ -403,5 +621,5 @@ }

exports.Unparser = Unparser;
exports.Serializer = Serializer;
exports.DebugConfiguration = DebugConfiguration;
exports.Reporter = Reporter;
exports.enableImprovedTaskQueueDebugging = enableImprovedTaskQueueDebugging;

@@ -408,0 +626,0 @@ Object.defineProperty(exports, '__esModule', { value: true });

{
"name": "@aurelia/debug",
"version": "0.2.0",
"version": "0.3.0-dev.20181013",
"main": "dist/index.umd.js",

@@ -25,2 +25,3 @@ "module": "dist/index.es6.js",

"dist",
"src",
"README.md",

@@ -46,4 +47,4 @@ "CHANGELOG.md",

"dependencies": {
"@aurelia/kernel": "^0.2.0",
"@aurelia/runtime": "^0.2.0"
"@aurelia/kernel": "^0.3.0-dev.20181013",
"@aurelia/runtime": "^0.3.0-dev.20181013"
},

@@ -89,3 +90,3 @@ "devDependencies": {

},
"gitHead": "712101a020943279230b68b075305246f84d1037"
"gitHead": "6ba681c5c0255796f55855f2e64b3adcc4c494c3"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc