diff --git a/gulpfile.js b/gulpfile.js index bd7e01e158..20be46d8a8 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -752,19 +752,23 @@ gulp.task('bundle.js.sfx.dev', ['build.js.dev'], function() { gulp.task('bundle.js.prod.deps', ['bundle.js.prod'], function() { return bundler.modify( - ['node_modules/zone.js/zone.js', 'dist/build/angular2.js'], 'angular2.js') - .pipe(gulp.dest('dist/bundle')); + ['node_modules/zone.js/dist/zone-microtask.js', 'dist/build/angular2.js'], + 'angular2.js' + ).pipe(gulp.dest('dist/bundle')); }); gulp.task('bundle.js.min.deps', ['bundle.js.min'], function() { return bundler.modify( - ['node_modules/zone.js/zone.js', 'dist/build/angular2.min.js'], 'angular2.min.js') - .pipe(gulp.dest('dist/bundle')); + ['node_modules/zone.js/dist/zone-microtask.js', 'dist/build/angular2.min.js'], + 'angular2.min.js' + ).pipe(gulp.dest('dist/bundle')); }); -var JS_DEV_DEPS = ['node_modules/zone.js/zone.js', - 'node_modules/zone.js/long-stack-trace-zone.js', - 'node_modules/reflect-metadata/Reflect.js']; +var JS_DEV_DEPS = [ + 'node_modules/zone.js/dist/zone-microtask.js', + 'node_modules/zone.js/dist/long-stack-trace-zone.js', + 'node_modules/reflect-metadata/Reflect.js' +]; gulp.task('bundle.js.dev.deps', ['bundle.js.dev'], function() { return bundler.modify(JS_DEV_DEPS.concat(['dist/build/angular2.dev.js']), 'angular2.dev.js') diff --git a/karma-js.conf.js b/karma-js.conf.js index 91a7250300..2dea094ef2 100644 --- a/karma-js.conf.js +++ b/karma-js.conf.js @@ -12,8 +12,9 @@ module.exports = function(config) { // Loaded through the es6-module-loader, in `test-main.js`. {pattern: 'dist/js/dev/es5/**', included: false, watched: false}, - 'zone/zone-microtask.js', - 'zone/long-stack-trace-zone.js', + // zone-microtask must be included first as it contains a Promise monkey patch + 'node_modules/zone.js/dist/zone-microtask.js', + 'node_modules/zone.js/dist/long-stack-trace-zone.js', 'node_modules/traceur/bin/traceur-runtime.js', 'node_modules/es6-module-loader/dist/es6-module-loader-sans-promises.src.js', diff --git a/npm-shrinkwrap.clean.json b/npm-shrinkwrap.clean.json index bf7a6cc142..a2358e941f 100644 --- a/npm-shrinkwrap.clean.json +++ b/npm-shrinkwrap.clean.json @@ -9483,7 +9483,7 @@ } }, "zone.js": { - "version": "0.4.4" + "version": "0.5.0" } }, "name": "angular", diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index 2780900f12..c9d73b7285 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -5793,108 +5793,108 @@ }, "gulp-clang-format": { "version": "1.0.12", - "from": "gulp-clang-format@1.0.12", + "from": "https://registry.npmjs.org/gulp-clang-format/-/gulp-clang-format-1.0.12.tgz", "resolved": "https://registry.npmjs.org/gulp-clang-format/-/gulp-clang-format-1.0.12.tgz", "dependencies": { "gulp-util": { "version": "3.0.4", - "from": "gulp-util@>=3.0.4 <4.0.0", + "from": "https://registry.npmjs.org/gulp-util/-/gulp-util-3.0.4.tgz", "resolved": "https://registry.npmjs.org/gulp-util/-/gulp-util-3.0.4.tgz", "dependencies": { "array-differ": { "version": "1.0.0", - "from": "array-differ@>=1.0.0 <2.0.0", + "from": "https://registry.npmjs.org/array-differ/-/array-differ-1.0.0.tgz", "resolved": "https://registry.npmjs.org/array-differ/-/array-differ-1.0.0.tgz" }, "array-uniq": { "version": "1.0.2", - "from": "array-uniq@>=1.0.2 <2.0.0", + "from": "https://registry.npmjs.org/array-uniq/-/array-uniq-1.0.2.tgz", "resolved": "https://registry.npmjs.org/array-uniq/-/array-uniq-1.0.2.tgz" }, "beeper": { "version": "1.0.0", - "from": "beeper@>=1.0.0 <2.0.0", + "from": "https://registry.npmjs.org/beeper/-/beeper-1.0.0.tgz", "resolved": "https://registry.npmjs.org/beeper/-/beeper-1.0.0.tgz" }, "chalk": { "version": "1.0.0", - "from": "chalk@>=1.0.0 <2.0.0", + "from": "https://registry.npmjs.org/chalk/-/chalk-1.0.0.tgz", "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.0.0.tgz", "dependencies": { "ansi-styles": { "version": "2.0.1", - "from": "ansi-styles@>=2.0.1 <3.0.0", + "from": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.0.1.tgz", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.0.1.tgz" }, "escape-string-regexp": { "version": "1.0.3", - "from": "escape-string-regexp@>=1.0.2 <2.0.0", + "from": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.3.tgz", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.3.tgz" }, "has-ansi": { "version": "1.0.3", - "from": "has-ansi@>=1.0.3 <2.0.0", + "from": "https://registry.npmjs.org/has-ansi/-/has-ansi-1.0.3.tgz", "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-1.0.3.tgz", "dependencies": { "ansi-regex": { "version": "1.1.1", - "from": "ansi-regex@>=1.1.0 <2.0.0", + "from": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-1.1.1.tgz", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-1.1.1.tgz" }, "get-stdin": { "version": "4.0.1", - "from": "get-stdin@>=4.0.1 <5.0.0", + "from": "https://registry.npmjs.org/get-stdin/-/get-stdin-4.0.1.tgz", "resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-4.0.1.tgz" } } }, "strip-ansi": { "version": "2.0.1", - "from": "strip-ansi@>=2.0.1 <3.0.0", + "from": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-2.0.1.tgz", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-2.0.1.tgz", "dependencies": { "ansi-regex": { "version": "1.1.1", - "from": "ansi-regex@>=1.1.0 <2.0.0", + "from": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-1.1.1.tgz", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-1.1.1.tgz" } } }, "supports-color": { "version": "1.3.1", - "from": "supports-color@>=1.3.0 <2.0.0", + "from": "https://registry.npmjs.org/supports-color/-/supports-color-1.3.1.tgz", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-1.3.1.tgz" } } }, "dateformat": { "version": "1.0.11", - "from": "dateformat@>=1.0.11 <2.0.0", + "from": "https://registry.npmjs.org/dateformat/-/dateformat-1.0.11.tgz", "resolved": "https://registry.npmjs.org/dateformat/-/dateformat-1.0.11.tgz", "dependencies": { "get-stdin": { "version": "4.0.1", - "from": "get-stdin@*", + "from": "https://registry.npmjs.org/get-stdin/-/get-stdin-4.0.1.tgz", "resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-4.0.1.tgz" }, "meow": { "version": "3.1.0", - "from": "meow@*", + "from": "https://registry.npmjs.org/meow/-/meow-3.1.0.tgz", "resolved": "https://registry.npmjs.org/meow/-/meow-3.1.0.tgz", "dependencies": { "camelcase-keys": { "version": "1.0.0", - "from": "camelcase-keys@>=1.0.0 <2.0.0", + "from": "https://registry.npmjs.org/camelcase-keys/-/camelcase-keys-1.0.0.tgz", "resolved": "https://registry.npmjs.org/camelcase-keys/-/camelcase-keys-1.0.0.tgz", "dependencies": { "camelcase": { "version": "1.0.2", - "from": "camelcase@>=1.0.1 <2.0.0", + "from": "https://registry.npmjs.org/camelcase/-/camelcase-1.0.2.tgz", "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-1.0.2.tgz" }, "map-obj": { "version": "1.0.1", - "from": "map-obj@>=1.0.0 <2.0.0", + "from": "https://registry.npmjs.org/map-obj/-/map-obj-1.0.1.tgz", "resolved": "https://registry.npmjs.org/map-obj/-/map-obj-1.0.1.tgz" } } @@ -5905,116 +5905,116 @@ }, "lodash._reescape": { "version": "3.0.0", - "from": "lodash._reescape@>=3.0.0 <4.0.0", + "from": "https://registry.npmjs.org/lodash._reescape/-/lodash._reescape-3.0.0.tgz", "resolved": "https://registry.npmjs.org/lodash._reescape/-/lodash._reescape-3.0.0.tgz" }, "lodash._reevaluate": { "version": "3.0.0", - "from": "lodash._reevaluate@>=3.0.0 <4.0.0", + "from": "https://registry.npmjs.org/lodash._reevaluate/-/lodash._reevaluate-3.0.0.tgz", "resolved": "https://registry.npmjs.org/lodash._reevaluate/-/lodash._reevaluate-3.0.0.tgz" }, "lodash._reinterpolate": { "version": "3.0.0", - "from": "lodash._reinterpolate@>=3.0.0 <4.0.0", + "from": "https://registry.npmjs.org/lodash._reinterpolate/-/lodash._reinterpolate-3.0.0.tgz", "resolved": "https://registry.npmjs.org/lodash._reinterpolate/-/lodash._reinterpolate-3.0.0.tgz" }, "lodash.template": { "version": "3.5.1", - "from": "lodash.template@>=3.0.0 <4.0.0", + "from": "https://registry.npmjs.org/lodash.template/-/lodash.template-3.5.1.tgz", "resolved": "https://registry.npmjs.org/lodash.template/-/lodash.template-3.5.1.tgz", "dependencies": { "lodash._basecopy": { "version": "3.0.1", - "from": "lodash._basecopy@>=3.0.0 <4.0.0", + "from": "https://registry.npmjs.org/lodash._basecopy/-/lodash._basecopy-3.0.1.tgz", "resolved": "https://registry.npmjs.org/lodash._basecopy/-/lodash._basecopy-3.0.1.tgz" }, "lodash._basetostring": { "version": "3.0.0", - "from": "lodash._basetostring@>=3.0.0 <4.0.0", + "from": "https://registry.npmjs.org/lodash._basetostring/-/lodash._basetostring-3.0.0.tgz", "resolved": "https://registry.npmjs.org/lodash._basetostring/-/lodash._basetostring-3.0.0.tgz" }, "lodash._basevalues": { "version": "3.0.0", - "from": "lodash._basevalues@>=3.0.0 <4.0.0", + "from": "https://registry.npmjs.org/lodash._basevalues/-/lodash._basevalues-3.0.0.tgz", "resolved": "https://registry.npmjs.org/lodash._basevalues/-/lodash._basevalues-3.0.0.tgz" }, "lodash._isiterateecall": { "version": "3.0.7", - "from": "lodash._isiterateecall@>=3.0.0 <4.0.0", + "from": "https://registry.npmjs.org/lodash._isiterateecall/-/lodash._isiterateecall-3.0.7.tgz", "resolved": "https://registry.npmjs.org/lodash._isiterateecall/-/lodash._isiterateecall-3.0.7.tgz" }, "lodash.escape": { "version": "3.0.0", - "from": "lodash.escape@>=3.0.0 <4.0.0", + "from": "https://registry.npmjs.org/lodash.escape/-/lodash.escape-3.0.0.tgz", "resolved": "https://registry.npmjs.org/lodash.escape/-/lodash.escape-3.0.0.tgz" }, "lodash.isnative": { "version": "3.0.2", - "from": "lodash.isnative@>=3.0.0 <4.0.0", + "from": "https://registry.npmjs.org/lodash.isnative/-/lodash.isnative-3.0.2.tgz", "resolved": "https://registry.npmjs.org/lodash.isnative/-/lodash.isnative-3.0.2.tgz" }, "lodash.keys": { "version": "3.0.7", - "from": "lodash.keys@>=3.0.0 <4.0.0", + "from": "https://registry.npmjs.org/lodash.keys/-/lodash.keys-3.0.7.tgz", "resolved": "https://registry.npmjs.org/lodash.keys/-/lodash.keys-3.0.7.tgz", "dependencies": { "lodash.isarguments": { "version": "3.0.2", - "from": "lodash.isarguments@>=3.0.0 <4.0.0", + "from": "https://registry.npmjs.org/lodash.isarguments/-/lodash.isarguments-3.0.2.tgz", "resolved": "https://registry.npmjs.org/lodash.isarguments/-/lodash.isarguments-3.0.2.tgz" }, "lodash.isarray": { "version": "3.0.2", - "from": "lodash.isarray@>=3.0.0 <4.0.0", + "from": "https://registry.npmjs.org/lodash.isarray/-/lodash.isarray-3.0.2.tgz", "resolved": "https://registry.npmjs.org/lodash.isarray/-/lodash.isarray-3.0.2.tgz" } } }, "lodash.restparam": { "version": "3.6.1", - "from": "lodash.restparam@>=3.0.0 <4.0.0", + "from": "https://registry.npmjs.org/lodash.restparam/-/lodash.restparam-3.6.1.tgz", "resolved": "https://registry.npmjs.org/lodash.restparam/-/lodash.restparam-3.6.1.tgz" }, "lodash.templatesettings": { "version": "3.1.0", - "from": "lodash.templatesettings@>=3.0.0 <4.0.0", + "from": "https://registry.npmjs.org/lodash.templatesettings/-/lodash.templatesettings-3.1.0.tgz", "resolved": "https://registry.npmjs.org/lodash.templatesettings/-/lodash.templatesettings-3.1.0.tgz" } } }, "multipipe": { "version": "0.1.2", - "from": "multipipe@>=0.1.2 <0.2.0", + "from": "https://registry.npmjs.org/multipipe/-/multipipe-0.1.2.tgz", "resolved": "https://registry.npmjs.org/multipipe/-/multipipe-0.1.2.tgz", "dependencies": { "duplexer2": { "version": "0.0.2", - "from": "duplexer2@0.0.2", + "from": "https://registry.npmjs.org/duplexer2/-/duplexer2-0.0.2.tgz", "resolved": "https://registry.npmjs.org/duplexer2/-/duplexer2-0.0.2.tgz", "dependencies": { "readable-stream": { "version": "1.1.13", - "from": "readable-stream@>=1.1.9 <1.2.0", + "from": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.13.tgz", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.13.tgz", "dependencies": { "core-util-is": { "version": "1.0.1", - "from": "core-util-is@>=1.0.0 <1.1.0", + "from": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.1.tgz", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.1.tgz" }, "isarray": { "version": "0.0.1", - "from": "isarray@0.0.1", + "from": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz" }, "string_decoder": { "version": "0.10.31", - "from": "string_decoder@>=0.10.0 <0.11.0", + "from": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz" }, "inherits": { "version": "2.0.1", - "from": "inherits@>=2.0.1 <2.1.0", + "from": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz" } } @@ -6025,44 +6025,44 @@ }, "object-assign": { "version": "2.0.0", - "from": "object-assign@>=2.0.0 <3.0.0", + "from": "https://registry.npmjs.org/object-assign/-/object-assign-2.0.0.tgz", "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-2.0.0.tgz" }, "replace-ext": { "version": "0.0.1", - "from": "replace-ext@0.0.1", + "from": "https://registry.npmjs.org/replace-ext/-/replace-ext-0.0.1.tgz", "resolved": "https://registry.npmjs.org/replace-ext/-/replace-ext-0.0.1.tgz" } } }, "stream-equal": { "version": "0.1.5", - "from": "stream-equal@>=0.1.5 <0.2.0", + "from": "https://registry.npmjs.org/stream-equal/-/stream-equal-0.1.5.tgz", "resolved": "https://registry.npmjs.org/stream-equal/-/stream-equal-0.1.5.tgz", "dependencies": { "readable-stream": { "version": "1.0.33", - "from": "readable-stream@>=1.0.2 <1.1.0", + "from": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.33.tgz", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.33.tgz", "dependencies": { "core-util-is": { "version": "1.0.1", - "from": "core-util-is@>=1.0.0 <1.1.0", + "from": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.1.tgz", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.1.tgz" }, "isarray": { "version": "0.0.1", - "from": "isarray@0.0.1", + "from": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz" }, "string_decoder": { "version": "0.10.31", - "from": "string_decoder@>=0.10.0 <0.11.0", + "from": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz" }, "inherits": { "version": "2.0.1", - "from": "inherits@>=2.0.1 <2.1.0", + "from": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz" } } @@ -6071,7 +6071,7 @@ }, "clang-format": { "version": "1.0.12", - "from": "clang-format@>=1.0.12 <2.0.0", + "from": "https://registry.npmjs.org/clang-format/-/clang-format-1.0.12.tgz", "resolved": "https://registry.npmjs.org/clang-format/-/clang-format-1.0.12.tgz" } } @@ -13436,7 +13436,7 @@ }, "mime": { "version": "1.2.11", - "from": "mime@>=1.2.9 <1.3.0", + "from": "mime@>=1.2.11 <1.3.0", "resolved": "https://registry.npmjs.org/mime/-/mime-1.2.11.tgz" }, "mimeparse": { @@ -13989,7 +13989,7 @@ }, "node-uuid": { "version": "1.4.3", - "from": "node-uuid@>=1.4.0 <1.5.0", + "from": "node-uuid@>=1.0.0 <2.0.0", "resolved": "https://registry.npmjs.org/node-uuid/-/node-uuid-1.4.3.tgz" }, "async": { @@ -14660,9 +14660,9 @@ } }, "zone.js": { - "version": "0.4.4", - "from": "https://registry.npmjs.org/zone.js/-/zone.js-0.4.4.tgz", - "resolved": "https://registry.npmjs.org/zone.js/-/zone.js-0.4.4.tgz" + "version": "0.5.0", + "from": "zone.js@0.5.0", + "resolved": "https://registry.npmjs.org/zone.js/-/zone.js-0.5.0.tgz" } } } diff --git a/package.json b/package.json index a24a26ee43..807cae9275 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "systemjs": "^0.9.1", "traceur": "0.0.87", "which": "~1", - "zone.js": "0.4.4" + "zone.js": "0.5.0" }, "devDependencies": { "angular": "1.3.5", diff --git a/tools/broccoli/trees/browser_tree.ts b/tools/broccoli/trees/browser_tree.ts index 3078715c96..3c9d0ab6d7 100644 --- a/tools/broccoli/trees/browser_tree.ts +++ b/tools/broccoli/trees/browser_tree.ts @@ -78,8 +78,8 @@ module.exports = function makeBrowserTree(options, destinationPath) { var vendorScriptsTree = flatten(new Funnel('.', { files: [ - 'zone/zone-microtask.js', - 'zone/long-stack-trace-zone.js', + 'node_modules/zone.js/dist/zone-microtask.js', + 'node_modules/zone.js/dist/long-stack-trace-zone.js', 'node_modules/es6-module-loader/dist/es6-module-loader-sans-promises.src.js', 'node_modules/systemjs/dist/system.src.js', 'node_modules/systemjs/lib/extension-register.js', diff --git a/zone/long-stack-trace-zone.js b/zone/long-stack-trace-zone.js deleted file mode 100644 index 2199b2a538..0000000000 --- a/zone/long-stack-trace-zone.js +++ /dev/null @@ -1,88 +0,0 @@ -/* - * 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 (locals) { - var newZone = this._fork(locals); - newZone.constructedAtException = Zone.getStacktrace(); - newZone.constructedAtTime = Date.now(); - return newZone; - }, - - _fork: zone.fork -}; - diff --git a/zone/zone-microtask.js b/zone/zone-microtask.js deleted file mode 100644 index 09d03d2713..0000000000 --- a/zone/zone-microtask.js +++ /dev/null @@ -1,1924 +0,0 @@ -(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o postsJSON - values[1] // => commentsJSON - - return values; - }); - ``` - - @class Promise - @param {function} resolver - Useful for tooling. - @constructor - */ - function lib$es6$promise$promise$$Promise(resolver) { - this._id = lib$es6$promise$promise$$counter++; - this._state = undefined; - this._result = undefined; - this._subscribers = []; - - if (lib$es6$promise$$internal$$noop !== resolver) { - if (!lib$es6$promise$utils$$isFunction(resolver)) { - lib$es6$promise$promise$$needsResolver(); - } - - if (!(this instanceof lib$es6$promise$promise$$Promise)) { - lib$es6$promise$promise$$needsNew(); - } - - lib$es6$promise$$internal$$initializePromise(this, resolver); - } - } - - lib$es6$promise$promise$$Promise.all = lib$es6$promise$promise$all$$default; - lib$es6$promise$promise$$Promise.race = lib$es6$promise$promise$race$$default; - lib$es6$promise$promise$$Promise.resolve = lib$es6$promise$promise$resolve$$default; - lib$es6$promise$promise$$Promise.reject = lib$es6$promise$promise$reject$$default; - - lib$es6$promise$promise$$Promise.prototype = { - constructor: lib$es6$promise$promise$$Promise, - - /** - The primary way of interacting with a promise is through its `then` method, - which registers callbacks to receive either a promise's eventual value or the - reason why the promise cannot be fulfilled. - - ```js - findUser().then(function(user){ - // user is available - }, function(reason){ - // user is unavailable, and you are given the reason why - }); - ``` - - Chaining - -------- - - The return value of `then` is itself a promise. This second, 'downstream' - promise is resolved with the return value of the first promise's fulfillment - or rejection handler, or rejected if the handler throws an exception. - - ```js - findUser().then(function (user) { - return user.name; - }, function (reason) { - return 'default name'; - }).then(function (userName) { - // If `findUser` fulfilled, `userName` will be the user's name, otherwise it - // will be `'default name'` - }); - - findUser().then(function (user) { - throw new Error('Found user, but still unhappy'); - }, function (reason) { - throw new Error('`findUser` rejected and we're unhappy'); - }).then(function (value) { - // never reached - }, function (reason) { - // if `findUser` fulfilled, `reason` will be 'Found user, but still unhappy'. - // If `findUser` rejected, `reason` will be '`findUser` rejected and we're unhappy'. - }); - ``` - If the downstream promise does not specify a rejection handler, rejection reasons will be propagated further downstream. - - ```js - findUser().then(function (user) { - throw new PedagogicalException('Upstream error'); - }).then(function (value) { - // never reached - }).then(function (value) { - // never reached - }, function (reason) { - // The `PedgagocialException` is propagated all the way down to here - }); - ``` - - Assimilation - ------------ - - Sometimes the value you want to propagate to a downstream promise can only be - retrieved asynchronously. This can be achieved by returning a promise in the - fulfillment or rejection handler. The downstream promise will then be pending - until the returned promise is settled. This is called *assimilation*. - - ```js - findUser().then(function (user) { - return findCommentsByAuthor(user); - }).then(function (comments) { - // The user's comments are now available - }); - ``` - - If the assimliated promise rejects, then the downstream promise will also reject. - - ```js - findUser().then(function (user) { - return findCommentsByAuthor(user); - }).then(function (comments) { - // If `findCommentsByAuthor` fulfills, we'll have the value here - }, function (reason) { - // If `findCommentsByAuthor` rejects, we'll have the reason here - }); - ``` - - Simple Example - -------------- - - Synchronous Example - - ```javascript - var result; - - try { - result = findResult(); - // success - } catch(reason) { - // failure - } - ``` - - Errback Example - - ```js - findResult(function(result, err){ - if (err) { - // failure - } else { - // success - } - }); - ``` - - Promise Example; - - ```javascript - findResult().then(function(result){ - // success - }, function(reason){ - // failure - }); - ``` - - Advanced Example - -------------- - - Synchronous Example - - ```javascript - var author, books; - - try { - author = findAuthor(); - books = findBooksByAuthor(author); - // success - } catch(reason) { - // failure - } - ``` - - Errback Example - - ```js - - function foundBooks(books) { - - } - - function failure(reason) { - - } - - findAuthor(function(author, err){ - if (err) { - failure(err); - // failure - } else { - try { - findBoooksByAuthor(author, function(books, err) { - if (err) { - failure(err); - } else { - try { - foundBooks(books); - } catch(reason) { - failure(reason); - } - } - }); - } catch(error) { - failure(err); - } - // success - } - }); - ``` - - Promise Example; - - ```javascript - findAuthor(). - then(findBooksByAuthor). - then(function(books){ - // found books - }).catch(function(reason){ - // something went wrong - }); - ``` - - @method then - @param {Function} onFulfilled - @param {Function} onRejected - Useful for tooling. - @return {Promise} - */ - then: function(onFulfillment, onRejection) { - var parent = this; - var state = parent._state; - - if (state === lib$es6$promise$$internal$$FULFILLED && !onFulfillment || state === lib$es6$promise$$internal$$REJECTED && !onRejection) { - return this; - } - - var child = new this.constructor(lib$es6$promise$$internal$$noop); - var result = parent._result; - - if (state) { - var callback = arguments[state - 1]; - lib$es6$promise$asap$$default(function(){ - lib$es6$promise$$internal$$invokeCallback(state, child, callback, result); - }); - } else { - lib$es6$promise$$internal$$subscribe(parent, child, onFulfillment, onRejection); - } - - return child; - }, - - /** - `catch` is simply sugar for `then(undefined, onRejection)` which makes it the same - as the catch block of a try/catch statement. - - ```js - function findAuthor(){ - throw new Error('couldn't find that author'); - } - - // synchronous - try { - findAuthor(); - } catch(reason) { - // something went wrong - } - - // async with promises - findAuthor().catch(function(reason){ - // something went wrong - }); - ``` - - @method catch - @param {Function} onRejection - Useful for tooling. - @return {Promise} - */ - 'catch': function(onRejection) { - return this.then(null, onRejection); - } - }; - function lib$es6$promise$polyfill$$polyfill() { - var local; - - if (typeof global !== 'undefined') { - local = global; - } else if (typeof self !== 'undefined') { - local = self; - } else { - try { - local = Function('return this')(); - } catch (e) { - throw new Error('polyfill failed because global object is unavailable in this environment'); - } - } - - var P = local.Promise; - - if (P && Object.prototype.toString.call(P.resolve()) === '[object Promise]' && !P.cast) { - return; - } - - local.Promise = lib$es6$promise$promise$$default; - } - var lib$es6$promise$polyfill$$default = lib$es6$promise$polyfill$$polyfill; - - var lib$es6$promise$umd$$ES6Promise = { - 'Promise': lib$es6$promise$promise$$default, - 'polyfill': lib$es6$promise$polyfill$$default - }; - - /* global define:true module:true window: true */ - if (typeof define === 'function' && define['amd']) { - define(function() { return lib$es6$promise$umd$$ES6Promise; }); - } else if (typeof module !== 'undefined' && module['exports']) { - module['exports'] = lib$es6$promise$umd$$ES6Promise; - } else if (typeof this !== 'undefined') { - this['ES6Promise'] = lib$es6$promise$umd$$ES6Promise; - } - - lib$es6$promise$polyfill$$default(); -}).call(this); - - -}).call(this,{},typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{}],4:[function(require,module,exports){ -(function (global){ -'use strict'; - -function scheduleMicrotask(fn) { - asap(this.bind(fn)); -} - -function addMicrotaskSupport(zoneClass) { - zoneClass.prototype.scheduleMicrotask = scheduleMicrotask; - return zoneClass; -} - -module.exports = { - addMicrotaskSupport: addMicrotaskSupport -}; - -// TODO(vicb): There are plan to be able to use asap() from es6-promise -// see https://github.com/jakearchibald/es6-promise/pull/113 -// for now adapt code from asap.js in es6-promise -// Note: the node support has been dropped here - -// TODO(vicb): Create a benchmark for the different methods & the usage of the queue -// see https://github.com/angular/zone.js/issues/97 - -var len = 0; - -var hasNativePromise = typeof Promise ==! "undefined" && - Promise.toString().indexOf("[native code]") !== -1; - -var isFirefox = global.navigator && - global.navigator.userAgent.toLowerCase().indexOf('firefox') > -1; - -function asap(callback) { - queue[len] = callback; - len += 1; - if (len === 1) { - scheduleFlush(); - } -} - -var browserWindow = (typeof global.window !== 'undefined') ? global.window : undefined; -var browserGlobal = browserWindow || {}; -var BrowserMutationObserver = browserGlobal.MutationObserver || browserGlobal.WebKitMutationObserver; - -// test for web worker but not in IE10 -var isWorker = typeof Uint8ClampedArray !== 'undefined' && - typeof importScripts !== 'undefined' && - typeof MessageChannel !== 'undefined'; - -function useMutationObserver() { - var iterations = 0; - var observer = new BrowserMutationObserver(flush); - var node = document.createTextNode(''); - observer.observe(node, { characterData: true }); - - return function() { - node.data = (iterations = ++iterations % 2); - }; -} - -// web worker -function useMessageChannel() { - var channel = new MessageChannel(); - channel.port1.onmessage = flush; - return function () { - channel.port2.postMessage(0); - }; -} - -function useSetTimeout() { - return function() { - setTimeout(flush, 1); - }; -} - -function usePromise() { - var resolvedPromise = Promise.resolve(void 0); - return function() { - resolvedPromise.then(flush); - } -} - -var queue = new Array(1000); - -function flush() { - for (var i = 0; i < len; i++) { - var callback = queue[i]; - callback(); - queue[i] = undefined; - } - - len = 0; -} - -var scheduleFlush; -// Decide what async method to use to triggering processing of queued callbacks: -if (hasNativePromise && !isFirefox) { - // TODO(vicb): remove '!isFirefox' when the bug is fixed: - // https://bugzilla.mozilla.org/show_bug.cgi?id=1162013 - scheduleFlush = usePromise(); -} else if (BrowserMutationObserver) { - scheduleFlush = useMutationObserver(); -} else if (isWorker) { - scheduleFlush = useMessageChannel(); -} else { - scheduleFlush = useSetTimeout(); -} - -}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{}],5:[function(require,module,exports){ -(function (global){ -'use strict'; - -var fnPatch = require('./functions'); -var promisePatch = require('./promise'); -var mutationObserverPatch = require('./mutation-observer'); -var definePropertyPatch = require('./define-property'); -var registerElementPatch = require('./register-element'); -var webSocketPatch = require('./websocket'); -var eventTargetPatch = require('./event-target'); -var propertyDescriptorPatch = require('./property-descriptor'); - -function apply() { - fnPatch.patchSetClearFunction(global, [ - 'timeout', - 'interval', - 'immediate' - ]); - - fnPatch.patchSetFunction(global, [ - 'requestAnimationFrame', - 'mozRequestAnimationFrame', - 'webkitRequestAnimationFrame' - ]); - - fnPatch.patchFunction(global, [ - 'alert', - 'prompt' - ]); - - eventTargetPatch.apply(); - - propertyDescriptorPatch.apply(); - - promisePatch.apply(); - - mutationObserverPatch.patchClass('MutationObserver'); - mutationObserverPatch.patchClass('WebKitMutationObserver'); - - definePropertyPatch.apply(); - - registerElementPatch.apply(); -} - -module.exports = { - apply: apply -}; - -}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"./define-property":6,"./event-target":7,"./functions":8,"./mutation-observer":9,"./promise":10,"./property-descriptor":11,"./register-element":12,"./websocket":13}],6:[function(require,module,exports){ -'use strict'; - -// might need similar for object.freeze -// i regret nothing - -var _defineProperty = Object.defineProperty; -var _getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; -var _create = Object.create; - -function apply() { - Object.defineProperty = function (obj, prop, desc) { - if (isUnconfigurable(obj, prop)) { - throw new TypeError('Cannot assign to read only property \'' + prop + '\' of ' + obj); - } - if (prop !== 'prototype') { - desc = rewriteDescriptor(obj, prop, desc); - } - return _defineProperty(obj, prop, desc); - }; - - Object.defineProperties = function (obj, props) { - Object.keys(props).forEach(function (prop) { - Object.defineProperty(obj, prop, props[prop]); - }); - return obj; - }; - - Object.create = function (obj, proto) { - if (typeof proto === 'object') { - Object.keys(proto).forEach(function (prop) { - proto[prop] = rewriteDescriptor(obj, prop, proto[prop]); - }); - } - return _create(obj, proto); - }; - - Object.getOwnPropertyDescriptor = function (obj, prop) { - var desc = _getOwnPropertyDescriptor(obj, prop); - if (isUnconfigurable(obj, prop)) { - desc.configurable = false; - } - return desc; - }; -}; - -function _redefineProperty(obj, prop, desc) { - desc = rewriteDescriptor(obj, prop, desc); - return _defineProperty(obj, prop, desc); -}; - -function isUnconfigurable (obj, prop) { - return obj && obj.__unconfigurables && obj.__unconfigurables[prop]; -} - -function rewriteDescriptor (obj, prop, desc) { - desc.configurable = true; - if (!desc.configurable) { - if (!obj.__unconfigurables) { - _defineProperty(obj, '__unconfigurables', { writable: true, value: {} }); - } - obj.__unconfigurables[prop] = true; - } - return desc; -} - -module.exports = { - apply: apply, - _redefineProperty: _redefineProperty -}; - - - -},{}],7:[function(require,module,exports){ -(function (global){ -'use strict'; - -var utils = require('../utils'); - -function apply() { - // patched properties depend on addEventListener, so this needs to come first - if (global.EventTarget) { - utils.patchEventTargetMethods(global.EventTarget.prototype); - - // Note: EventTarget is not available in all browsers, - // if it's not available, we instead patch the APIs in the IDL that inherit from EventTarget - } else { - var apis = [ 'ApplicationCache', - 'EventSource', - 'FileReader', - 'InputMethodContext', - 'MediaController', - 'MessagePort', - 'Node', - 'Performance', - 'SVGElementInstance', - 'SharedWorker', - 'TextTrack', - 'TextTrackCue', - 'TextTrackList', - 'WebKitNamedFlow', - 'Window', - 'Worker', - 'WorkerGlobalScope', - 'XMLHttpRequestEventTarget', - 'XMLHttpRequestUpload' - ]; - - apis.forEach(function(thing) { - global[thing] && utils.patchEventTargetMethods(global[thing].prototype); - }); - } -} - -module.exports = { - apply: apply -}; - -}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"../utils":14}],8:[function(require,module,exports){ -(function (global){ -'use strict'; - -var utils = require('../utils'); - -function patchSetClearFunction(obj, fnNames) { - fnNames.map(function (name) { - return name[0].toUpperCase() + name.substr(1); - }).forEach(function (name) { - var setName = 'set' + name; - var delegate = obj[setName]; - - if (delegate) { - var clearName = 'clear' + name; - var ids = {}; - - var bindArgs = setName === 'setInterval' ? utils.bindArguments : utils.bindArgumentsOnce; - - global.zone[setName] = function (fn) { - var id, fnRef = fn; - arguments[0] = function () { - delete ids[id]; - return fnRef.apply(this, arguments); - }; - var args = bindArgs(arguments); - id = delegate.apply(obj, args); - ids[id] = true; - return id; - }; - - obj[setName] = function () { - return global.zone[setName].apply(this, arguments); - }; - - var clearDelegate = obj[clearName]; - - global.zone[clearName] = function (id) { - if (ids[id]) { - delete ids[id]; - global.zone.dequeueTask(); - } - return clearDelegate.apply(this, arguments); - }; - - obj[clearName] = function () { - return global.zone[clearName].apply(this, arguments); - }; - } - }); -}; - -function patchSetFunction(obj, fnNames) { - fnNames.forEach(function (name) { - var delegate = obj[name]; - - if (delegate) { - global.zone[name] = function (fn) { - var fnRef = fn; - arguments[0] = function () { - return fnRef.apply(this, arguments); - }; - var args = utils.bindArgumentsOnce(arguments); - return delegate.apply(obj, args); - }; - - obj[name] = function () { - return zone[name].apply(this, arguments); - }; - } - }); -}; - -function patchFunction(obj, fnNames) { - fnNames.forEach(function (name) { - var delegate = obj[name]; - global.zone[name] = function () { - return delegate.apply(obj, arguments); - }; - - obj[name] = function () { - return global.zone[name].apply(this, arguments); - }; - }); -}; - - -module.exports = { - patchSetClearFunction: patchSetClearFunction, - patchSetFunction: patchSetFunction, - patchFunction: patchFunction -}; - -}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"../utils":14}],9:[function(require,module,exports){ -(function (global){ -'use strict'; - -// wrap some native API on `window` -function patchClass(className) { - var OriginalClass = global[className]; - if (!OriginalClass) return; - - global[className] = function (fn) { - this._o = new OriginalClass(zone.bind(fn, true)); - }; - - var instance = new OriginalClass(function () {}); - - global[className].prototype.disconnect = function () { - var result = this._o.disconnect.apply(this._o, arguments); - this._active && global.zone.dequeueTask(); - this._active = false; - return result; - }; - - global[className].prototype.observe = function () { - if (!this._active) { - global.zone.enqueueTask(); - } - this._active = true; - return this._o.observe.apply(this._o, arguments); - }; - - var prop; - for (prop in instance) { - (function (prop) { - if (typeof global[className].prototype !== undefined) { - return; - } - if (typeof instance[prop] === 'function') { - global[className].prototype[prop] = function () { - return this._o[prop].apply(this._o, arguments); - }; - } else { - Object.defineProperty(global[className].prototype, prop, { - set: function (fn) { - if (typeof fn === 'function') { - this._o[prop] = zone.bind(fn); - } else { - this._o[prop] = fn; - } - }, - get: function () { - return this._o[prop]; - } - }); - } - }(prop)); - } -}; - -module.exports = { - patchClass: patchClass -}; - -}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{}],10:[function(require,module,exports){ -(function (global){ -'use strict'; - -var utils = require('../utils'); - -/* - * patch a fn that returns a promise - */ -var bindPromiseFn = (function() { - // if the browser natively supports Promises, we can just return a native promise - if (global.Promise) { - return function (delegate) { - return function() { - var delegatePromise = delegate.apply(this, arguments); - if (delegatePromise instanceof Promise) { - return delegatePromise; - } else { - return new Promise(function(resolve, reject) { - delegatePromise.then(resolve, reject); - }); - } - }; - }; - } else { - // if the browser does not have native promises, we have to patch each promise instance - return function (delegate) { - return function () { - return patchThenable(delegate.apply(this, arguments)); - }; - }; - } - - function patchThenable(thenable) { - var then = thenable.then; - thenable.then = function () { - var args = utils.bindArguments(arguments); - var nextThenable = then.apply(thenable, args); - return patchThenable(nextThenable); - }; - - var ocatch = thenable.catch; - thenable.catch = function () { - var args = utils.bindArguments(arguments); - var nextThenable = ocatch.apply(thenable, args); - return patchThenable(nextThenable); - }; - return thenable; - } -}()); - -function apply() { - if (global.Promise) { - utils.patchPrototype(Promise.prototype, [ - 'then', - 'catch' - ]); - } -} - -module.exports = { - apply: apply, - bindPromiseFn: bindPromiseFn -}; - -}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"../utils":14}],11:[function(require,module,exports){ -(function (global){ -'use strict'; - -var webSocketPatch = require('./websocket'); -var utils = require('../utils'); - -var eventNames = 'copy cut paste abort blur focus canplay canplaythrough change click contextmenu dblclick drag dragend dragenter dragleave dragover dragstart drop durationchange emptied ended input invalid keydown keypress keyup load loadeddata loadedmetadata loadstart message mousedown mouseenter mouseleave mousemove mouseout mouseover mouseup pause play playing progress ratechange reset scroll seeked seeking select show stalled submit suspend timeupdate volumechange waiting mozfullscreenchange mozfullscreenerror mozpointerlockchange mozpointerlockerror error webglcontextrestored webglcontextlost webglcontextcreationerror'.split(' '); - -function apply() { - if (canPatchViaPropertyDescriptor()) { - // for browsers that we can patch the descriptor: Chrome & Firefox - var onEventNames = eventNames.map(function (property) { - return 'on' + property; - }); - utils.patchProperties(HTMLElement.prototype, onEventNames); - utils.patchProperties(XMLHttpRequest.prototype); - utils.patchProperties(WebSocket.prototype); - } else { - // Safari - patchViaCapturingAllTheEvents(); - utils.patchClass('XMLHttpRequest'); - webSocketPatch.apply(); - } -} - -function canPatchViaPropertyDescriptor() { - if (!Object.getOwnPropertyDescriptor(HTMLElement.prototype, 'onclick') && typeof Element !== 'undefined') { - // WebKit https://bugs.webkit.org/show_bug.cgi?id=134364 - // IDL interface attributes are not configurable - var desc = Object.getOwnPropertyDescriptor(Element.prototype, 'onclick'); - if (desc && !desc.configurable) return false; - } - - Object.defineProperty(HTMLElement.prototype, 'onclick', { - get: function () { - return true; - } - }); - var elt = document.createElement('div'); - var result = !!elt.onclick; - Object.defineProperty(HTMLElement.prototype, 'onclick', {}); - return result; -}; - -// Whenever any event fires, we check the event target and all parents -// for `onwhatever` properties and replace them with zone-bound functions -// - Chrome (for now) -function patchViaCapturingAllTheEvents() { - eventNames.forEach(function (property) { - var onproperty = 'on' + property; - document.addEventListener(property, function (event) { - var elt = event.target, bound; - while (elt) { - if (elt[onproperty] && !elt[onproperty]._unbound) { - bound = global.zone.bind(elt[onproperty]); - bound._unbound = elt[onproperty]; - elt[onproperty] = bound; - } - elt = elt.parentElement; - } - }, true); - }); -}; - -module.exports = { - apply: apply -}; - -}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"../utils":14,"./websocket":13}],12:[function(require,module,exports){ -(function (global){ -'use strict'; - -var _redefineProperty = require('./define-property')._redefineProperty; - -function apply() { - if (!('registerElement' in global.document)) { - return; - } - var _registerElement = document.registerElement; - var callbacks = [ - 'createdCallback', - 'attachedCallback', - 'detachedCallback', - 'attributeChangedCallback' - ]; - document.registerElement = function (name, opts) { - callbacks.forEach(function (callback) { - if (opts.prototype[callback]) { - var descriptor = Object.getOwnPropertyDescriptor(opts.prototype, callback); - if (descriptor.value) { - descriptor.value = zone.bind(descriptor.value || opts.prototype[callback]); - _redefineProperty(opts.prototype, callback, descriptor); - } - } - }); - return _registerElement.apply(document, [name, opts]); - }; -} - -module.exports = { - apply: apply -}; - -}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"./define-property":6}],13:[function(require,module,exports){ -(function (global){ -'use strict'; - -var utils = require('../utils.js'); - -// we have to patch the instance since the proto is non-configurable -function apply() { - var WS = global.WebSocket; - utils.patchEventTargetMethods(WS.prototype); - global.WebSocket = function(a, b) { - var socket = arguments.length > 1 ? new WS(a, b) : new WS(a); - var proxySocket; - - // Safari 7.0 has non-configurable own 'onmessage' and friends properties on the socket instance - var onmessageDesc = Object.getOwnPropertyDescriptor(socket, 'onmessage'); - if (onmessageDesc && onmessageDesc.configurable === false) { - proxySocket = Object.create(socket); - ['addEventListener', 'removeEventListener', 'send', 'close'].forEach(function(propName) { - proxySocket[propName] = function() { - return socket[propName].apply(socket, arguments); - }; - }); - } else { - // we can patch the real socket - proxySocket = socket; - } - - utils.patchProperties(proxySocket, ['onclose', 'onerror', 'onmessage', 'onopen']); - - return proxySocket; - }; -} - -module.exports = { - apply: apply -}; - -}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"../utils.js":14}],14:[function(require,module,exports){ -(function (global){ -'use strict'; - -function bindArguments(args) { - for (var i = args.length - 1; i >= 0; i--) { - if (typeof args[i] === 'function') { - args[i] = global.zone.bind(args[i]); - } - } - return args; -}; - -function bindArgumentsOnce(args) { - for (var i = args.length - 1; i >= 0; i--) { - if (typeof args[i] === 'function') { - args[i] = global.zone.bindOnce(args[i]); - } - } - return args; -}; - -function patchPrototype(obj, fnNames) { - fnNames.forEach(function (name) { - var delegate = obj[name]; - if (delegate) { - obj[name] = function () { - return delegate.apply(this, bindArguments(arguments)); - }; - } - }); -}; - -function patchProperty(obj, prop) { - var desc = Object.getOwnPropertyDescriptor(obj, prop) || { - enumerable: true, - configurable: true - }; - - // A property descriptor cannot have getter/setter and be writable - // deleting the writable and value properties avoids this error: - // - // TypeError: property descriptors must not specify a value or be writable when a - // getter or setter has been specified - delete desc.writable; - delete desc.value; - - // substr(2) cuz 'onclick' -> 'click', etc - var eventName = prop.substr(2); - var _prop = '_' + prop; - - desc.set = function (fn) { - if (this[_prop]) { - this.removeEventListener(eventName, this[_prop]); - } - - if (typeof fn === 'function') { - this[_prop] = fn; - this.addEventListener(eventName, fn, false); - } else { - this[_prop] = null; - } - }; - - desc.get = function () { - return this[_prop]; - }; - - Object.defineProperty(obj, prop, desc); -}; - -function patchProperties(obj, properties) { - - (properties || (function () { - var props = []; - for (var prop in obj) { - props.push(prop); - } - return props; - }()). - filter(function (propertyName) { - return propertyName.substr(0,2) === 'on'; - })). - forEach(function (eventName) { - patchProperty(obj, eventName); - }); -}; - -function patchEventTargetMethods(obj) { - var addDelegate = obj.addEventListener; - obj.addEventListener = function (eventName, fn) { - fn._bound = fn._bound || {}; - arguments[1] = fn._bound[eventName] = zone.bind(fn); - return addDelegate.apply(this, arguments); - }; - - var removeDelegate = obj.removeEventListener; - obj.removeEventListener = function (eventName, fn) { - if(arguments[1]._bound && arguments[1]._bound[eventName]) { - var _bound = arguments[1]._bound; - arguments[1] = _bound[eventName]; - delete _bound[eventName]; - } - var result = removeDelegate.apply(this, arguments); - global.zone.dequeueTask(fn); - return result; - }; -}; - -// wrap some native API on `window` -function patchClass(className) { - var OriginalClass = global[className]; - if (!OriginalClass) return; - - global[className] = function () { - var a = bindArguments(arguments); - switch (a.length) { - case 0: this._o = new OriginalClass(); break; - case 1: this._o = new OriginalClass(a[0]); break; - case 2: this._o = new OriginalClass(a[0], a[1]); break; - case 3: this._o = new OriginalClass(a[0], a[1], a[2]); break; - case 4: this._o = new OriginalClass(a[0], a[1], a[2], a[3]); break; - default: throw new Error('what are you even doing?'); - } - }; - - var instance = new OriginalClass(className.substr(-16) === 'MutationObserver' ? function () {} : undefined); - - var prop; - for (prop in instance) { - (function (prop) { - if (typeof instance[prop] === 'function') { - global[className].prototype[prop] = function () { - return this._o[prop].apply(this._o, arguments); - }; - } else { - Object.defineProperty(global[className].prototype, prop, { - set: function (fn) { - if (typeof fn === 'function') { - this._o[prop] = global.zone.bind(fn); - } else { - this._o[prop] = fn; - } - }, - get: function () { - return this._o[prop]; - } - }); - } - }(prop)); - }; -}; - -module.exports = { - bindArguments: bindArguments, - bindArgumentsOnce: bindArgumentsOnce, - patchPrototype: patchPrototype, - patchProperty: patchProperty, - patchProperties: patchProperties, - patchEventTargetMethods: patchEventTargetMethods, - patchClass: patchClass -}; - -}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{}]},{},[1]);