This repository has been archived by the owner on Apr 20, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathrx.winjs.min.js
1 lines (1 loc) · 6.33 KB
/
rx.winjs.min.js
1
!function(a,b){var c="object"==typeof exports&&exports,d=("object"==typeof module&&module&&module.exports==c&&module,"object"==typeof global&&global);d.global===d&&(window=d),"function"==typeof define&&define.amd?define(["rx","winjs","exports"],function(c,d,e){return a.Rx=b(a,e,c,d),a.Rx}):"object"==typeof module&&module&&module.exports===c?module.exports=b(a,module.exports,require("rx"),require("winjs")):a.Rx=b(a,{},a.Rx,a.WinJS)}(this,function(a,b,c,d){function e(a,b,c){function d(a,b,c){return a.addEventListener(b,c,!1),r(function(){a.removeEventListener(b,c,!1)})}var f=new q;if(a&&a.length)for(var g=0,h=a.length;h>g;g++)f.add(e(a[g],b,c));else f.add(d(a,b,c));return f}function f(a,b){return o(function(c){var d=function(d,e){c.onNext({name:b,newValue:d,oldValue:e,dataObject:a})};return a.bind(b,d),function(){a.unbind(b,d)}})}var g="object"==typeof exports&&exports,h=("object"==typeof module&&module&&module.exports==g&&module,"object"==typeof a&&a);h.global===h&&(window=h);var c=window.Rx,i=c.Subject,j=c.AsyncSubject,k=c.Observer,l=k.create,m=c.Observable,n=m.prototype,o=m.create,p=m.createWithDisposable,q=c.CompositeDisposable,r=c.Disposable.create,s=c.Disposable.empty,t=d.Promise,u=d.Binding;c.WinJS={},c.WinJS.fromEvent=function(a,b){return p(function(c){return e(a,b,c.onNext.bind(c))}).publish().refCount()},t.prototype.toObservable=function(a){var b=new j;return this.done(function(a){b.onNext(a),b.onCompleted()},b.onError.bind(b),function(b){"function"==typeof a?a(b):a&&a.onNext(b)}),b.asObservable()},n.toPromise=function(){var a,b,c=this;return new t(function(d,e){a=c.subscribe(function(a){b=a},function(a){e(a)},function(){d(b)})},function(){a&&a.dispose()})},t.toObservable=function(a,b){return t.prototype.toObservable.call(a,b)};var v=u.as;u.as=function(a){var b=v(a);return b.toObservable=function(){if(0===arguments.length)throw new Error("Must have at least one binding");for(var a=[],c=0,d=arguments.length;d>c;c++)a.push(f(b,arguments[c]));return m.merge(a)},b},window.MutationObserver&&(c.WinJS.fromMutationObserver=function(a,b){return o(function(c){var d=new MutationObserver(function(a){c.onNext(a)});return d.observe(a,b),function(){d.disconnect()}})}),c.WinJS.fromWebSocket=function(a,b,c){var d=new window.WebSocket(a,b),e=o(function(a){return c&&(d.onopen=function(a){"function"==typeof c?c(a):c.onNext&&c.onNext(a)}),d.onmessage=function(b){a.onNext(b)},d.onerror=function(b){a.onError(b)},d.onclose=function(){a.onCompleted()},function(){d.close()}}),f=l(function(a){d.readyState===WebSocket.OPEN&&d.send(a)});return i.create(f,e)},window.Worker&&(c.WinJS.fromWebWorker=function(a){var b=new window.Worker(a),c=p(function(a){return b.onmessage=function(b){a.onNext(b)},b.onerror=function(b){a.onError(b)},r(function(){b.close()})}),d=l(function(a){b.postMessage(a)});return i.create(d,c)}),c.WinJS.Geolocation={getCurrentPosition:function(a){var b=new c.AsyncSubject;return window.navigator.geolocation.getCurrentPosition(function(a){b.onNext(a),b.onCompleted()},function(a){b.onError(a)},a),b.asObservable()},watchPosition:function(a){return o(function(b){var c=window.navigator.geolocation.watchPosition(function(a){b.onNext(a)},function(a){b.onError(a)},a);return function(){window.navigator.geolocation.clearWatch(c)}}).publish().refCount()}};var w=c.WinJS.fromSensorEvent=function(a,b){return p(function(c){return a?(a.addEventListener(a,b,!1),r(function(){a.removeEventListener(a,b,!1)})):(c.onError("Sensor not supported"),s)}).publish().refCount()},x=Windows.Devices.Sensors.Accelerometer.getDefault();c.WinJS.Accelerometer={readingChanged:function(){return w(x,"readingchanged")},shaken:function(){return w(x,"shaken")}};var y=Windows.Devices.Sensors.Compass.getDefault();c.WinJS.Compass={readingChanged:function(){return w(y,"readingchanged")}};var z=Windows.Devices.Sensors.LightSensor.getDefault();c.WinJS.LightSensor={readingChanged:function(){return w(z,"readingchanged")}};var A=Windows.Devices.Sensors.OrientationSensor.getDefault();c.WinJS.OrientationSensor={readingChanged:function(){return w(A,"readingchanged")}};var B=Windows.Devices.Sensors.SimpleOrientationSensor.getDefault();c.WinJS.SimpleOrientationSensor={orientationChanged:function(){return w(B,"orientationchanged")}};var C,D;window.requestAnimationFrame?(C=window.requestAnimationFrame,D=window.cancelAnimationFrame):window.mozRequestAnimationFrame?(C=window.mozRequestAnimationFrame,D=window.mozCancelAnimationFrame):window.webkitRequestAnimationFrame?(C=window.webkitRequestAnimationFrame,D=window.webkitCancelAnimationFrame):window.msRequestAnimationFrame?(C=window.msRequestAnimationFrame,D=window.msCancelAnimationFrame):window.oRequestAnimationFrame?(C=window.oRequestAnimationFrame,D=window.oCancelAnimationFrame):(C=function(a){window.setTimeout(a,1e3/60)},D=window.clearTimeout),Scheduler.requestAnimationFrame=function(){function a(a,b){var c=this,d=new SingleAssignmentDisposable,e=C(function(){d.isDisposed||d.setDisposable(b(c,a))});return new q(d,r(function(){D(e)}))}function b(a,b,c){var d=this,e=Scheduler.normalize(b);if(0===e)return d.scheduleWithState(a,c);var f,g=new SingleAssignmentDisposable,h=function(){f&&D(f),e-d.now()<=0?g.isDisposed||g.setDisposable(c(d,a)):f=C(h)};return f=C(h),new q(g,r(function(){D(f)}))}function c(a,b,c){return this.scheduleWithRelativeAndState(a,b-this.now(),c)}var d=function(){return Date.now?Date.now:function(){return+new Date}}();return new Scheduler(d,a,b,c)}();var E=window.MutationObserver;return E&&(Scheduler.mutationObserver=function(){function a(a){var b={};for(var c in a)a.hasOwnProperty(c)&&(b[c]=a[c]);return b}function b(a){var b=i++;return h[b]=a,k.setAttribute("drainQueue","drainQueue"),b}function c(a){delete h[a]}function d(){return(new Date).getTime()}function e(a,c){var d=this,e=new SingleAssignmentDisposable;return b(function(){e.isDisposed||e.setDisposable(c(d,a))}),e}function f(a,d,e){var f=this,g=Scheduler.normalize(d);if(0===g)return f.scheduleWithState(a,e);var h,i=new SingleAssignmentDisposable,j=function(){h&&c(h),g-f.now()<=0?i.isDisposed||i.setDisposable(e(f,a)):h=b(j)};return h=b(j),new q(i,r(function(){c(h)}))}function g(a,b,c){return this.scheduleWithRelativeAndState(a,b-this.now(),c)}var h={},i=0,j=new E(function(){var b=a(h);h={};for(var c in b)b.hasOwnProperty(c)&&b[c]()}),k=document.createElement("div");return j.observe(k,{attributes:!0}),window.addEventListener("unload",function(){j.disconnect(),j=null},!1),new Scheduler(d,e,f,g)}()),c});