@aurelia/debug
Advanced tools
Comparing version 0.2.0-dev.20180925 to 0.2.0-dev.20180926
@@ -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, Assign, Binary, BindingBehavior, CallFunction, CallMember, CallScope, Conditional, ArrayLiteral, ObjectLiteral, PrimitiveLiteral, Unary, HtmlLiteral, ValueConverter } from '@aurelia/runtime'; | ||
import { Reporter } from '@aurelia/kernel'; | ||
@@ -279,6 +279,2 @@ | ||
}, | ||
13: { | ||
type: 0 /* error */, | ||
message: 'TaskQueue long stack traces are only available in debug mode.' | ||
}, | ||
14: { | ||
@@ -319,72 +315,16 @@ 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.' | ||
} | ||
}; | ||
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); | ||
enableImprovedExpressionDebugging(); | ||
@@ -394,3 +334,3 @@ } | ||
export { BindingContext$1 as BindingContext, enableImprovedExpressionDebugging, adoptDebugMethods, Unparser, DebugConfiguration, Reporter$1 as Reporter, enableImprovedTaskQueueDebugging }; | ||
export { BindingContext$1 as BindingContext, enableImprovedExpressionDebugging, adoptDebugMethods, Unparser, DebugConfiguration, Reporter$1 as Reporter }; | ||
//# sourceMappingURL=index.es6.js.map |
@@ -282,6 +282,2 @@ (function (global, factory) { | ||
}, | ||
13: { | ||
type: 0 /* error */, | ||
message: 'TaskQueue long stack traces are only available in debug mode.' | ||
}, | ||
14: { | ||
@@ -322,72 +318,16 @@ 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.' | ||
} | ||
}; | ||
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); | ||
enableImprovedExpressionDebugging(); | ||
@@ -403,3 +343,2 @@ } | ||
exports.Reporter = Reporter; | ||
exports.enableImprovedTaskQueueDebugging = enableImprovedTaskQueueDebugging; | ||
@@ -406,0 +345,0 @@ Object.defineProperty(exports, '__esModule', { value: true }); |
{ | ||
"name": "@aurelia/debug", | ||
"version": "0.2.0-dev.20180925", | ||
"version": "0.2.0-dev.20180926", | ||
"main": "dist/index.umd.js", | ||
@@ -46,4 +46,4 @@ "module": "dist/index.es6.js", | ||
"dependencies": { | ||
"@aurelia/kernel": "0.2.0-dev.20180925", | ||
"@aurelia/runtime": "^0.2.0-dev.20180925" | ||
"@aurelia/kernel": "0.2.0-dev.20180926", | ||
"@aurelia/runtime": "^0.2.0-dev.20180926" | ||
}, | ||
@@ -89,3 +89,3 @@ "devDependencies": { | ||
}, | ||
"gitHead": "57c07e8ffac77dfd6cc55529d972c55016f316e8" | ||
"gitHead": "ad6eeb42a81e32b0c67cb4ebb65a46b608bc7397" | ||
} |
import { IContainer } from '@aurelia/kernel'; | ||
import { enableImprovedExpressionDebugging } from './binding/unparser'; | ||
import { Reporter } from './reporter'; | ||
import { enableImprovedTaskQueueDebugging} from './task-queue'; | ||
export const DebugConfiguration = { | ||
register(container: IContainer) { | ||
register(container: IContainer): void { | ||
Reporter.write(2); | ||
enableImprovedTaskQueueDebugging(container); | ||
enableImprovedExpressionDebugging(); | ||
enableImprovedExpressionDebugging(); | ||
} | ||
}; |
@@ -5,2 +5,1 @@ export * from './binding/binding-context'; | ||
export * from './reporter'; | ||
export * from './task-queue'; |
@@ -105,6 +105,2 @@ import { Reporter as RuntimeReporter } from '@aurelia/kernel'; | ||
}, | ||
13: { | ||
type: MessageType.error, | ||
message: 'TaskQueue long stack traces are only available in debug mode.' | ||
}, | ||
14: { | ||
@@ -145,3 +141,11 @@ type: MessageType.error, | ||
message: 'A containerless custom element cannot be the root component of an application.' | ||
}, | ||
30: { | ||
type: MessageType.error, | ||
message: 'There are more targets than there are target instructions.' | ||
}, | ||
31: { | ||
type: MessageType.error, | ||
message: 'There are more target instructions than there are targets.' | ||
} | ||
}; |
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
81474
23
1032
+ Added@aurelia/kernel@0.2.0-dev.20180926(transitive)
- Removed@aurelia/kernel@0.2.0-dev.20180925(transitive)