node_modules updated, buefy add to lib folder
This commit is contained in:
+50
-46
@@ -1,6 +1,4 @@
|
||||
import { root } from '../../util/root';
|
||||
import { tryCatch } from '../../util/tryCatch';
|
||||
import { errorObject } from '../../util/errorObject';
|
||||
import { Observable } from '../../Observable';
|
||||
import { Subscriber } from '../../Subscriber';
|
||||
import { map } from '../../operators/map';
|
||||
@@ -113,46 +111,38 @@ export class AjaxSubscriber extends Subscriber {
|
||||
this.request = request;
|
||||
this.done = false;
|
||||
const headers = request.headers = request.headers || {};
|
||||
if (!request.crossDomain && !headers['X-Requested-With']) {
|
||||
if (!request.crossDomain && !this.getHeader(headers, 'X-Requested-With')) {
|
||||
headers['X-Requested-With'] = 'XMLHttpRequest';
|
||||
}
|
||||
if (!('Content-Type' in headers) && !(root.FormData && request.body instanceof root.FormData) && typeof request.body !== 'undefined') {
|
||||
let contentTypeHeader = this.getHeader(headers, 'Content-Type');
|
||||
if (!contentTypeHeader && !(root.FormData && request.body instanceof root.FormData) && typeof request.body !== 'undefined') {
|
||||
headers['Content-Type'] = 'application/x-www-form-urlencoded; charset=UTF-8';
|
||||
}
|
||||
request.body = this.serializeBody(request.body, request.headers['Content-Type']);
|
||||
request.body = this.serializeBody(request.body, this.getHeader(request.headers, 'Content-Type'));
|
||||
this.send();
|
||||
}
|
||||
next(e) {
|
||||
this.done = true;
|
||||
const { xhr, request, destination } = this;
|
||||
const response = new AjaxResponse(e, xhr, request);
|
||||
if (response.response === errorObject) {
|
||||
destination.error(errorObject.e);
|
||||
let result;
|
||||
try {
|
||||
result = new AjaxResponse(e, xhr, request);
|
||||
}
|
||||
else {
|
||||
destination.next(response);
|
||||
catch (err) {
|
||||
return destination.error(err);
|
||||
}
|
||||
destination.next(result);
|
||||
}
|
||||
send() {
|
||||
const { request, request: { user, method, url, async, password, headers, body } } = this;
|
||||
const createXHR = request.createXHR;
|
||||
const xhr = tryCatch(createXHR).call(request);
|
||||
if (xhr === errorObject) {
|
||||
this.error(errorObject.e);
|
||||
}
|
||||
else {
|
||||
this.xhr = xhr;
|
||||
try {
|
||||
const xhr = this.xhr = request.createXHR();
|
||||
this.setupEvents(xhr, request);
|
||||
let result;
|
||||
if (user) {
|
||||
result = tryCatch(xhr.open).call(xhr, method, url, async, user, password);
|
||||
xhr.open(method, url, async, user, password);
|
||||
}
|
||||
else {
|
||||
result = tryCatch(xhr.open).call(xhr, method, url, async);
|
||||
}
|
||||
if (result === errorObject) {
|
||||
this.error(errorObject.e);
|
||||
return null;
|
||||
xhr.open(method, url, async);
|
||||
}
|
||||
if (async) {
|
||||
xhr.timeout = request.timeout;
|
||||
@@ -162,13 +152,16 @@ export class AjaxSubscriber extends Subscriber {
|
||||
xhr.withCredentials = !!request.withCredentials;
|
||||
}
|
||||
this.setHeaders(xhr, headers);
|
||||
result = body ? tryCatch(xhr.send).call(xhr, body) : tryCatch(xhr.send).call(xhr);
|
||||
if (result === errorObject) {
|
||||
this.error(errorObject.e);
|
||||
return null;
|
||||
if (body) {
|
||||
xhr.send(body);
|
||||
}
|
||||
else {
|
||||
xhr.send();
|
||||
}
|
||||
}
|
||||
return xhr;
|
||||
catch (err) {
|
||||
this.error(err);
|
||||
}
|
||||
}
|
||||
serializeBody(body, contentType) {
|
||||
if (!body || typeof body === 'string') {
|
||||
@@ -199,6 +192,14 @@ export class AjaxSubscriber extends Subscriber {
|
||||
}
|
||||
}
|
||||
}
|
||||
getHeader(headers, headerName) {
|
||||
for (let key in headers) {
|
||||
if (key.toLowerCase() === headerName.toLowerCase()) {
|
||||
return headers[key];
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
setupEvents(xhr, request) {
|
||||
const progressSubscriber = request.progressSubscriber;
|
||||
function xhrTimeout(e) {
|
||||
@@ -206,13 +207,14 @@ export class AjaxSubscriber extends Subscriber {
|
||||
if (progressSubscriber) {
|
||||
progressSubscriber.error(e);
|
||||
}
|
||||
const ajaxTimeoutError = new AjaxTimeoutError(this, request);
|
||||
if (ajaxTimeoutError.response === errorObject) {
|
||||
subscriber.error(errorObject.e);
|
||||
let error;
|
||||
try {
|
||||
error = new AjaxTimeoutError(this, request);
|
||||
}
|
||||
else {
|
||||
subscriber.error(ajaxTimeoutError);
|
||||
catch (err) {
|
||||
error = err;
|
||||
}
|
||||
subscriber.error(error);
|
||||
}
|
||||
xhr.ontimeout = xhrTimeout;
|
||||
xhrTimeout.request = request;
|
||||
@@ -239,13 +241,14 @@ export class AjaxSubscriber extends Subscriber {
|
||||
if (progressSubscriber) {
|
||||
progressSubscriber.error(e);
|
||||
}
|
||||
const ajaxError = new AjaxError('ajax error', this, request);
|
||||
if (ajaxError.response === errorObject) {
|
||||
subscriber.error(errorObject.e);
|
||||
let error;
|
||||
try {
|
||||
error = new AjaxError('ajax error', this, request);
|
||||
}
|
||||
else {
|
||||
subscriber.error(ajaxError);
|
||||
catch (err) {
|
||||
error = err;
|
||||
}
|
||||
subscriber.error(error);
|
||||
};
|
||||
xhr.onerror = xhrError;
|
||||
xhrError.request = request;
|
||||
@@ -278,13 +281,14 @@ export class AjaxSubscriber extends Subscriber {
|
||||
if (progressSubscriber) {
|
||||
progressSubscriber.error(e);
|
||||
}
|
||||
const ajaxError = new AjaxError('ajax error ' + status, this, request);
|
||||
if (ajaxError.response === errorObject) {
|
||||
subscriber.error(errorObject.e);
|
||||
let error;
|
||||
try {
|
||||
error = new AjaxError('ajax error ' + status, this, request);
|
||||
}
|
||||
else {
|
||||
subscriber.error(ajaxError);
|
||||
catch (err) {
|
||||
error = err;
|
||||
}
|
||||
subscriber.error(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -335,7 +339,7 @@ function parseJson(xhr) {
|
||||
function parseXhrResponse(responseType, xhr) {
|
||||
switch (responseType) {
|
||||
case 'json':
|
||||
return tryCatch(parseJson)(xhr);
|
||||
return parseJson(xhr);
|
||||
case 'xml':
|
||||
return xhr.responseXML;
|
||||
case 'text':
|
||||
@@ -349,4 +353,4 @@ function AjaxTimeoutErrorImpl(xhr, request) {
|
||||
return this;
|
||||
}
|
||||
export const AjaxTimeoutError = AjaxTimeoutErrorImpl;
|
||||
//# sourceMappingURL=AjaxObservable.js.map
|
||||
//# sourceMappingURL=AjaxObservable.js.map
|
||||
+1
-1
File diff suppressed because one or more lines are too long
+35
-36
@@ -3,8 +3,6 @@ import { Subscriber } from '../../Subscriber';
|
||||
import { Observable } from '../../Observable';
|
||||
import { Subscription } from '../../Subscription';
|
||||
import { ReplaySubject } from '../../ReplaySubject';
|
||||
import { tryCatch } from '../../util/tryCatch';
|
||||
import { errorObject } from '../../util/errorObject';
|
||||
const DEFAULT_WEBSOCKET_CONFIG = {
|
||||
url: '',
|
||||
deserializer: (e) => JSON.parse(e.data),
|
||||
@@ -56,29 +54,28 @@ export class WebSocketSubject extends AnonymousSubject {
|
||||
multiplex(subMsg, unsubMsg, messageFilter) {
|
||||
const self = this;
|
||||
return new Observable((observer) => {
|
||||
const result = tryCatch(subMsg)();
|
||||
if (result === errorObject) {
|
||||
observer.error(errorObject.e);
|
||||
try {
|
||||
self.next(subMsg());
|
||||
}
|
||||
else {
|
||||
self.next(result);
|
||||
catch (err) {
|
||||
observer.error(err);
|
||||
}
|
||||
let subscription = self.subscribe(x => {
|
||||
const result = tryCatch(messageFilter)(x);
|
||||
if (result === errorObject) {
|
||||
observer.error(errorObject.e);
|
||||
const subscription = self.subscribe(x => {
|
||||
try {
|
||||
if (messageFilter(x)) {
|
||||
observer.next(x);
|
||||
}
|
||||
}
|
||||
else if (result) {
|
||||
observer.next(x);
|
||||
catch (err) {
|
||||
observer.error(err);
|
||||
}
|
||||
}, err => observer.error(err), () => observer.complete());
|
||||
return () => {
|
||||
const result = tryCatch(unsubMsg)();
|
||||
if (result === errorObject) {
|
||||
observer.error(errorObject.e);
|
||||
try {
|
||||
self.next(unsubMsg());
|
||||
}
|
||||
else {
|
||||
self.next(result);
|
||||
catch (err) {
|
||||
observer.error(err);
|
||||
}
|
||||
subscription.unsubscribe();
|
||||
};
|
||||
@@ -108,6 +105,12 @@ export class WebSocketSubject extends AnonymousSubject {
|
||||
}
|
||||
});
|
||||
socket.onopen = (e) => {
|
||||
const { _socket } = this;
|
||||
if (!_socket) {
|
||||
socket.close();
|
||||
this._resetState();
|
||||
return;
|
||||
}
|
||||
const { openObserver } = this._config;
|
||||
if (openObserver) {
|
||||
openObserver.next(e);
|
||||
@@ -115,13 +118,13 @@ export class WebSocketSubject extends AnonymousSubject {
|
||||
const queue = this.destination;
|
||||
this.destination = Subscriber.create((x) => {
|
||||
if (socket.readyState === 1) {
|
||||
const { serializer } = this._config;
|
||||
const msg = tryCatch(serializer)(x);
|
||||
if (msg === errorObject) {
|
||||
this.destination.error(errorObject.e);
|
||||
return;
|
||||
try {
|
||||
const { serializer } = this._config;
|
||||
socket.send(serializer(x));
|
||||
}
|
||||
catch (e) {
|
||||
this.destination.error(e);
|
||||
}
|
||||
socket.send(msg);
|
||||
}
|
||||
}, (e) => {
|
||||
const { closingObserver } = this._config;
|
||||
@@ -165,13 +168,12 @@ export class WebSocketSubject extends AnonymousSubject {
|
||||
}
|
||||
};
|
||||
socket.onmessage = (e) => {
|
||||
const { deserializer } = this._config;
|
||||
const result = tryCatch(deserializer)(e);
|
||||
if (result === errorObject) {
|
||||
observer.error(errorObject.e);
|
||||
try {
|
||||
const { deserializer } = this._config;
|
||||
observer.next(deserializer(e));
|
||||
}
|
||||
else {
|
||||
observer.next(result);
|
||||
catch (err) {
|
||||
observer.error(err);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -196,15 +198,12 @@ export class WebSocketSubject extends AnonymousSubject {
|
||||
return subscriber;
|
||||
}
|
||||
unsubscribe() {
|
||||
const { source, _socket } = this;
|
||||
const { _socket } = this;
|
||||
if (_socket && _socket.readyState === 1) {
|
||||
_socket.close();
|
||||
this._resetState();
|
||||
}
|
||||
this._resetState();
|
||||
super.unsubscribe();
|
||||
if (!source) {
|
||||
this.destination = new ReplaySubject();
|
||||
}
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=WebSocketSubject.js.map
|
||||
//# sourceMappingURL=WebSocketSubject.js.map
|
||||
+1
-1
File diff suppressed because one or more lines are too long
+1
-1
@@ -1,3 +1,3 @@
|
||||
import { AjaxObservable } from './AjaxObservable';
|
||||
export const ajax = AjaxObservable.create;
|
||||
//# sourceMappingURL=ajax.js.map
|
||||
//# sourceMappingURL=ajax.js.map
|
||||
+1
-1
@@ -1 +1 @@
|
||||
{"version":3,"file":"ajax.js","sources":["../../../../src/internal/observable/dom/ajax.ts"],"names":[],"mappings":"AAAA,OAAO,EAAG,cAAc,EAAuB,MAAM,kBAAkB,CAAC;AAkBxE,MAAM,CAAC,MAAM,IAAI,GAAuB,cAAc,CAAC,MAAM,CAAC"}
|
||||
{"version":3,"file":"ajax.js","sources":["../../../../src/internal/observable/dom/ajax.ts"],"names":[],"mappings":"AAAA,OAAO,EAAG,cAAc,EAAuB,MAAM,kBAAkB,CAAC;AAiFxE,MAAM,CAAC,MAAM,IAAI,GAAuB,cAAc,CAAC,MAAM,CAAC"}
|
||||
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
import { Observable } from '../../Observable';
|
||||
export function fromFetch(input, init) {
|
||||
return new Observable(subscriber => {
|
||||
const controller = new AbortController();
|
||||
const signal = controller.signal;
|
||||
let outerSignalHandler;
|
||||
let abortable = true;
|
||||
let unsubscribed = false;
|
||||
if (init) {
|
||||
if (init.signal) {
|
||||
outerSignalHandler = () => {
|
||||
if (!signal.aborted) {
|
||||
controller.abort();
|
||||
}
|
||||
};
|
||||
init.signal.addEventListener('abort', outerSignalHandler);
|
||||
}
|
||||
init.signal = signal;
|
||||
}
|
||||
else {
|
||||
init = { signal };
|
||||
}
|
||||
fetch(input, init).then(response => {
|
||||
abortable = false;
|
||||
subscriber.next(response);
|
||||
subscriber.complete();
|
||||
}).catch(err => {
|
||||
abortable = false;
|
||||
if (!unsubscribed) {
|
||||
subscriber.error(err);
|
||||
}
|
||||
});
|
||||
return () => {
|
||||
unsubscribed = true;
|
||||
if (abortable) {
|
||||
controller.abort();
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
//# sourceMappingURL=fetch.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"fetch.js","sources":["../../../../src/internal/observable/dom/fetch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAoD9C,MAAM,UAAU,SAAS,CAAC,KAAuB,EAAE,IAAkB;IACnE,OAAO,IAAI,UAAU,CAAW,UAAU,CAAC,EAAE;QAC3C,MAAM,UAAU,GAAG,IAAI,eAAe,EAAE,CAAC;QACzC,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;QACjC,IAAI,kBAA8B,CAAC;QACnC,IAAI,SAAS,GAAG,IAAI,CAAC;QACrB,IAAI,YAAY,GAAG,KAAK,CAAC;QAEzB,IAAI,IAAI,EAAE;YAER,IAAI,IAAI,CAAC,MAAM,EAAE;gBACf,kBAAkB,GAAG,GAAG,EAAE;oBACxB,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE;wBACnB,UAAU,CAAC,KAAK,EAAE,CAAC;qBACpB;gBACH,CAAC,CAAC;gBACF,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,kBAAkB,CAAC,CAAC;aAC3D;YACD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;SACtB;aAAM;YACL,IAAI,GAAG,EAAE,MAAM,EAAE,CAAC;SACnB;QAED,KAAK,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE;YACjC,SAAS,GAAG,KAAK,CAAC;YAClB,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YAC1B,UAAU,CAAC,QAAQ,EAAE,CAAC;QACxB,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE;YACb,SAAS,GAAG,KAAK,CAAC;YAClB,IAAI,CAAC,YAAY,EAAE;gBAEjB,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;aACvB;QACH,CAAC,CAAC,CAAC;QAEH,OAAO,GAAG,EAAE;YACV,YAAY,GAAG,IAAI,CAAC;YACpB,IAAI,SAAS,EAAE;gBACb,UAAU,CAAC,KAAK,EAAE,CAAC;aACpB;QACH,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC"}
|
||||
+1
-1
@@ -2,4 +2,4 @@ import { WebSocketSubject } from './WebSocketSubject';
|
||||
export function webSocket(urlConfigOrSource) {
|
||||
return new WebSocketSubject(urlConfigOrSource);
|
||||
}
|
||||
//# sourceMappingURL=webSocket.js.map
|
||||
//# sourceMappingURL=webSocket.js.map
|
||||
+1
-1
@@ -1 +1 @@
|
||||
{"version":3,"file":"webSocket.js","sources":["../../../../src/internal/observable/dom/webSocket.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAA0B,MAAM,oBAAoB,CAAC;AA4J9E,MAAM,UAAU,SAAS,CAAI,iBAAqD;IAChF,OAAO,IAAI,gBAAgB,CAAI,iBAAiB,CAAC,CAAC;AACpD,CAAC"}
|
||||
{"version":3,"file":"webSocket.js","sources":["../../../../src/internal/observable/dom/webSocket.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAA0B,MAAM,oBAAoB,CAAC;AAyJ9E,MAAM,UAAU,SAAS,CAAI,iBAAqD;IAChF,OAAO,IAAI,gBAAgB,CAAI,iBAAiB,CAAC,CAAC;AACpD,CAAC"}
|
||||
|
||||
Reference in New Issue
Block a user