mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-18 19:21:34 +08:00
get in the zone
This commit is contained in:
@ -22,12 +22,7 @@
|
|||||||
|
|
||||||
<!-- web animations polyfill for non-chrome browsers -->
|
<!-- web animations polyfill for non-chrome browsers -->
|
||||||
<script src="/../../../../dist/vendor/web-animations-js/web-animations.min.js"></script>
|
<script src="/../../../../dist/vendor/web-animations-js/web-animations.min.js"></script>
|
||||||
|
<!--<script src="extension-register.js" type="text/javascript"></script>
|
||||||
<script src="/../../../../scripts/resources/zone-microtask.js" type="text/javascript"></script>
|
|
||||||
<!-- <script src="long-stack-trace-zone.js" type="text/javascript"></script> -->
|
|
||||||
<!-- <script src="traceur-runtime.js" type="text/javascript"></script>
|
|
||||||
<script src="system.src.js" type="text/javascript"></script>
|
|
||||||
<script src="extension-register.js" type="text/javascript"></script>
|
|
||||||
<script src="extension-cjs.js" type="text/javascript"></script>
|
<script src="extension-cjs.js" type="text/javascript"></script>
|
||||||
<script src="runtime_paths.js" type="text/javascript"></script> -->
|
<script src="runtime_paths.js" type="text/javascript"></script> -->
|
||||||
<script src="/../../../../scripts/resources/traceur-runtime.js" type="text/javascript"></script>
|
<script src="/../../../../scripts/resources/traceur-runtime.js" type="text/javascript"></script>
|
||||||
@ -36,6 +31,8 @@
|
|||||||
<script src="/../../../../config.js"></script>
|
<script src="/../../../../config.js"></script>
|
||||||
<script src="/../../../../dist/js/dependencies.js"></script>
|
<script src="/../../../../dist/js/dependencies.js"></script>
|
||||||
<script src="/../../../../dist/js/ionic.bundle.js"></script>
|
<script src="/../../../../dist/js/ionic.bundle.js"></script>
|
||||||
|
<script src="/../../../../scripts/resources/zone-microtask.js" type="text/javascript"></script>
|
||||||
|
<script src="/../../../../scripts/resources/long-stack-trace-zone.js" type="text/javascript"></script>
|
||||||
<!-- <script src="../../../../bundle.js"></script> -->
|
<!-- <script src="../../../../bundle.js"></script> -->
|
||||||
<script type="text/javascript">System.import(window.location.pathname.substring(1) + 'index').then(function(m) { m.main(); }, console.error.bind(console))</script>
|
<script type="text/javascript">System.import(window.location.pathname.substring(1) + 'index').then(function(m) { m.main(); }, console.error.bind(console))</script>
|
||||||
</body>
|
</body>
|
||||||
|
88
scripts/resources/long-stack-trace-zone.js
Normal file
88
scripts/resources/long-stack-trace-zone.js
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
/*
|
||||||
|
* Wrapped stacktrace
|
||||||
|
*
|
||||||
|
* We need this because in some implementations, constructing a trace is slow
|
||||||
|
* and so we want to defer accessing the trace for as long as possible
|
||||||
|
*/
|
||||||
|
Zone.Stacktrace = function (e) {
|
||||||
|
this._e = e;
|
||||||
|
};
|
||||||
|
Zone.Stacktrace.prototype.get = function () {
|
||||||
|
if (zone.stackFramesFilter) {
|
||||||
|
return this._e.stack.
|
||||||
|
split('\n').
|
||||||
|
filter(zone.stackFramesFilter).
|
||||||
|
join('\n');
|
||||||
|
}
|
||||||
|
return this._e.stack;
|
||||||
|
}
|
||||||
|
|
||||||
|
Zone.getStacktrace = function () {
|
||||||
|
function getStacktraceWithUncaughtError () {
|
||||||
|
return new Zone.Stacktrace(new Error());
|
||||||
|
}
|
||||||
|
|
||||||
|
function getStacktraceWithCaughtError () {
|
||||||
|
try {
|
||||||
|
throw new Error();
|
||||||
|
} catch (e) {
|
||||||
|
return new Zone.Stacktrace(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Some implementations of exception handling don't create a stack trace if the exception
|
||||||
|
// isn't thrown, however it's faster not to actually throw the exception.
|
||||||
|
var stack = getStacktraceWithUncaughtError();
|
||||||
|
if (stack && stack._e.stack) {
|
||||||
|
Zone.getStacktrace = getStacktraceWithUncaughtError;
|
||||||
|
return stack;
|
||||||
|
} else {
|
||||||
|
Zone.getStacktrace = getStacktraceWithCaughtError;
|
||||||
|
return Zone.getStacktrace();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Zone.longStackTraceZone = {
|
||||||
|
getLongStacktrace: function (exception) {
|
||||||
|
var trace = [];
|
||||||
|
var zone = this;
|
||||||
|
if (exception) {
|
||||||
|
if (zone.stackFramesFilter) {
|
||||||
|
trace.push(exception.stack.split('\n').
|
||||||
|
filter(zone.stackFramesFilter).
|
||||||
|
join('\n'));
|
||||||
|
} else {
|
||||||
|
trace.push(exception.stack);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var now = Date.now();
|
||||||
|
while (zone && zone.constructedAtException) {
|
||||||
|
trace.push(
|
||||||
|
'--- ' + (Date(zone.constructedAtTime)).toString() +
|
||||||
|
' - ' + (now - zone.constructedAtTime) + 'ms ago',
|
||||||
|
zone.constructedAtException.get());
|
||||||
|
zone = zone.parent;
|
||||||
|
}
|
||||||
|
return trace.join('\n');
|
||||||
|
},
|
||||||
|
|
||||||
|
stackFramesFilter: function (line) {
|
||||||
|
return line.indexOf('zone.js') === -1;
|
||||||
|
},
|
||||||
|
|
||||||
|
onError: function (exception) {
|
||||||
|
var reporter = this.reporter || console.log.bind(console);
|
||||||
|
reporter(exception.toString());
|
||||||
|
reporter(this.getLongStacktrace(exception));
|
||||||
|
},
|
||||||
|
|
||||||
|
'$fork': function (parentFork) {
|
||||||
|
return function() {
|
||||||
|
var newZone = parentFork.apply(this, arguments);
|
||||||
|
newZone.constructedAtException = Zone.getStacktrace();
|
||||||
|
newZone.constructedAtTime = Date.now();
|
||||||
|
return newZone;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
Reference in New Issue
Block a user