diff options
author | Nevena Bojovic <nenabojov@gmail.com> | 2022-03-01 20:05:50 +0100 |
---|---|---|
committer | Nevena Bojovic <nenabojov@gmail.com> | 2022-03-01 20:05:50 +0100 |
commit | 291803c31f829fe0d32bb3207bc11def95a7408c (patch) | |
tree | c7d43107d79291b19d8c9eceefbe91c9f9a52acf /sandbox/testAppNevena/Front/node_modules/rxjs/src/internal | |
parent | 1fa69862057db4db53cfda5be9c24b4228ef63f7 (diff) |
Urađena test aplikacija. Povezan front i back.
Diffstat (limited to 'sandbox/testAppNevena/Front/node_modules/rxjs/src/internal')
10 files changed, 918 insertions, 0 deletions
diff --git a/sandbox/testAppNevena/Front/node_modules/rxjs/src/internal/observable/dom/AjaxObservable.ts b/sandbox/testAppNevena/Front/node_modules/rxjs/src/internal/observable/dom/AjaxObservable.ts new file mode 100644 index 00000000..d1f3f918 --- /dev/null +++ b/sandbox/testAppNevena/Front/node_modules/rxjs/src/internal/observable/dom/AjaxObservable.ts @@ -0,0 +1,550 @@ +import { root } from '../../util/root'; +import { Observable } from '../../Observable'; +import { Subscriber } from '../../Subscriber'; +import { TeardownLogic } from '../../types'; +import { map } from '../../operators/map'; + +export interface AjaxRequest { + url?: string; + body?: any; + user?: string; + async?: boolean; + method?: string; + headers?: Object; + timeout?: number; + password?: string; + hasContent?: boolean; + crossDomain?: boolean; + withCredentials?: boolean; + createXHR?: () => XMLHttpRequest; + progressSubscriber?: Subscriber<any>; + responseType?: string; +} + +function getCORSRequest(): XMLHttpRequest { + if (root.XMLHttpRequest) { + return new root.XMLHttpRequest(); + } else if (!!root.XDomainRequest) { + return new root.XDomainRequest(); + } else { + throw new Error('CORS is not supported by your browser'); + } +} + +function getXMLHttpRequest(): XMLHttpRequest { + if (root.XMLHttpRequest) { + return new root.XMLHttpRequest(); + } else { + let progId: string; + try { + const progIds = ['Msxml2.XMLHTTP', 'Microsoft.XMLHTTP', 'Msxml2.XMLHTTP.4.0']; + for (let i = 0; i < 3; i++) { + try { + progId = progIds[i]; + if (new root.ActiveXObject(progId)) { + break; + } + } catch (e) { + //suppress exceptions + } + } + return new root.ActiveXObject(progId); + } catch (e) { + throw new Error('XMLHttpRequest is not supported by your browser'); + } + } +} + +export interface AjaxCreationMethod { + (urlOrRequest: string | AjaxRequest): Observable<AjaxResponse>; + get(url: string, headers?: Object): Observable<AjaxResponse>; + post(url: string, body?: any, headers?: Object): Observable<AjaxResponse>; + put(url: string, body?: any, headers?: Object): Observable<AjaxResponse>; + patch(url: string, body?: any, headers?: Object): Observable<AjaxResponse>; + delete(url: string, headers?: Object): Observable<AjaxResponse>; + getJSON<T>(url: string, headers?: Object): Observable<T>; +} + +export function ajaxGet(url: string, headers: Object = null) { + return new AjaxObservable<AjaxResponse>({ method: 'GET', url, headers }); +} + +export function ajaxPost(url: string, body?: any, headers?: Object): Observable<AjaxResponse> { + return new AjaxObservable<AjaxResponse>({ method: 'POST', url, body, headers }); +} + +export function ajaxDelete(url: string, headers?: Object): Observable<AjaxResponse> { + return new AjaxObservable<AjaxResponse>({ method: 'DELETE', url, headers }); +} + +export function ajaxPut(url: string, body?: any, headers?: Object): Observable<AjaxResponse> { + return new AjaxObservable<AjaxResponse>({ method: 'PUT', url, body, headers }); +} + +export function ajaxPatch(url: string, body?: any, headers?: Object): Observable<AjaxResponse> { + return new AjaxObservable<AjaxResponse>({ method: 'PATCH', url, body, headers }); +} + +const mapResponse = map((x: AjaxResponse, index: number) => x.response); + +export function ajaxGetJSON<T>(url: string, headers?: Object): Observable<T> { + return mapResponse( + new AjaxObservable<AjaxResponse>({ + method: 'GET', + url, + responseType: 'json', + headers + }) + ); +} + +/** + * We need this JSDoc comment for affecting ESDoc. + * @extends {Ignored} + * @hide true + */ +export class AjaxObservable<T> extends Observable<T> { + /** + * Creates an observable for an Ajax request with either a request object with + * url, headers, etc or a string for a URL. + * + * ## Example + * ```ts + * import { ajax } from 'rxjs/ajax'; + * + * const source1 = ajax('/products'); + * const source2 = ajax({ url: 'products', method: 'GET' }); + * ``` + * + * @param {string|Object} request Can be one of the following: + * A string of the URL to make the Ajax call. + * An object with the following properties + * - url: URL of the request + * - body: The body of the request + * - method: Method of the request, such as GET, POST, PUT, PATCH, DELETE + * - async: Whether the request is async + * - headers: Optional headers + * - crossDomain: true if a cross domain request, else false + * - createXHR: a function to override if you need to use an alternate + * XMLHttpRequest implementation. + * - resultSelector: a function to use to alter the output value type of + * the Observable. Gets {@link AjaxResponse} as an argument. + * @return {Observable} An observable sequence containing the XMLHttpRequest. + * @static true + * @name ajax + * @owner Observable + * @nocollapse + */ + static create: AjaxCreationMethod = (() => { + const create: any = (urlOrRequest: string | AjaxRequest) => { + return new AjaxObservable(urlOrRequest); + }; + + create.get = ajaxGet; + create.post = ajaxPost; + create.delete = ajaxDelete; + create.put = ajaxPut; + create.patch = ajaxPatch; + create.getJSON = ajaxGetJSON; + + return <AjaxCreationMethod>create; + })(); + + private request: AjaxRequest; + + constructor(urlOrRequest: string | AjaxRequest) { + super(); + + const request: AjaxRequest = { + async: true, + createXHR: function(this: AjaxRequest) { + return this.crossDomain ? getCORSRequest() : getXMLHttpRequest(); + }, + crossDomain: true, + withCredentials: false, + headers: {}, + method: 'GET', + responseType: 'json', + timeout: 0 + }; + + if (typeof urlOrRequest === 'string') { + request.url = urlOrRequest; + } else { + for (const prop in urlOrRequest) { + if (urlOrRequest.hasOwnProperty(prop)) { + request[prop] = urlOrRequest[prop]; + } + } + } + + this.request = request; + } + + /** @deprecated This is an internal implementation detail, do not use. */ + _subscribe(subscriber: Subscriber<T>): TeardownLogic { + return new AjaxSubscriber(subscriber, this.request); + } +} + +/** + * We need this JSDoc comment for affecting ESDoc. + * @ignore + * @extends {Ignored} + */ +export class AjaxSubscriber<T> extends Subscriber<Event> { + private xhr: XMLHttpRequest; + private done: boolean = false; + + constructor(destination: Subscriber<T>, public request: AjaxRequest) { + super(destination); + + const headers = request.headers = request.headers || {}; + + // force CORS if requested + if (!request.crossDomain && !this.getHeader(headers, 'X-Requested-With')) { + headers['X-Requested-With'] = 'XMLHttpRequest'; + } + + // ensure content type is set + 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'; + } + + // properly serialize body + request.body = this.serializeBody(request.body, this.getHeader(request.headers, 'Content-Type')); + + this.send(); + } + + next(e: Event): void { + this.done = true; + const { xhr, request, destination } = this; + let result; + try { + result = new AjaxResponse(e, xhr, request); + } catch (err) { + return destination.error(err); + } + destination.next(result); + } + + private send(): void { + const { + request, + request: { user, method, url, async, password, headers, body } + } = this; + try { + const xhr = this.xhr = request.createXHR(); + + // set up the events before open XHR + // https://developer.mozilla.org/en/docs/Web/API/XMLHttpRequest/Using_XMLHttpRequest + // You need to add the event listeners before calling open() on the request. + // Otherwise the progress events will not fire. + this.setupEvents(xhr, request); + // open XHR + if (user) { + xhr.open(method, url, async, user, password); + } else { + xhr.open(method, url, async); + } + + // timeout, responseType and withCredentials can be set once the XHR is open + if (async) { + xhr.timeout = request.timeout; + xhr.responseType = request.responseType as any; + } + + if ('withCredentials' in xhr) { + xhr.withCredentials = !!request.withCredentials; + } + + // set headers + this.setHeaders(xhr, headers); + + // finally send the request + if (body) { + xhr.send(body); + } else { + xhr.send(); + } + } catch (err) { + this.error(err); + } + } + + private serializeBody(body: any, contentType?: string) { + if (!body || typeof body === 'string') { + return body; + } else if (root.FormData && body instanceof root.FormData) { + return body; + } + + if (contentType) { + const splitIndex = contentType.indexOf(';'); + if (splitIndex !== -1) { + contentType = contentType.substring(0, splitIndex); + } + } + + switch (contentType) { + case 'application/x-www-form-urlencoded': + return Object.keys(body).map(key => `${encodeURIComponent(key)}=${encodeURIComponent(body[key])}`).join('&'); + case 'application/json': + return JSON.stringify(body); + default: + return body; + } + } + + private setHeaders(xhr: XMLHttpRequest, headers: Object) { + for (let key in headers) { + if (headers.hasOwnProperty(key)) { + xhr.setRequestHeader(key, headers[key]); + } + } + } + + private getHeader(headers: {}, headerName: string): any { + for (let key in headers) { + if (key.toLowerCase() === headerName.toLowerCase()) { + return headers[key]; + } + } + + return undefined; + } + + private setupEvents(xhr: XMLHttpRequest, request: AjaxRequest) { + const progressSubscriber = request.progressSubscriber; + + function xhrTimeout(this: XMLHttpRequest, e: ProgressEvent): void { + const {subscriber, progressSubscriber, request } = (<any>xhrTimeout); + if (progressSubscriber) { + progressSubscriber.error(e); + } + let error; + try { + error = new AjaxTimeoutError(this, request); // TODO: Make betterer. + } catch (err) { + error = err; + } + subscriber.error(error); + } + xhr.ontimeout = xhrTimeout; + (<any>xhrTimeout).request = request; + (<any>xhrTimeout).subscriber = this; + (<any>xhrTimeout).progressSubscriber = progressSubscriber; + if (xhr.upload && 'withCredentials' in xhr) { + if (progressSubscriber) { + let xhrProgress: (e: ProgressEvent) => void; + xhrProgress = function(e: ProgressEvent) { + const { progressSubscriber } = (<any>xhrProgress); + progressSubscriber.next(e); + }; + if (root.XDomainRequest) { + xhr.onprogress = xhrProgress; + } else { + xhr.upload.onprogress = xhrProgress; + } + (<any>xhrProgress).progressSubscriber = progressSubscriber; + } + let xhrError: (e: any) => void; + xhrError = function(this: XMLHttpRequest, e: ErrorEvent) { + const { progressSubscriber, subscriber, request } = (<any>xhrError); + if (progressSubscriber) { + progressSubscriber.error(e); + } + let error; + try { + error = new AjaxError('ajax error', this, request); + } catch (err) { + error = err; + } + subscriber.error(error); + }; + xhr.onerror = xhrError; + (<any>xhrError).request = request; + (<any>xhrError).subscriber = this; + (<any>xhrError).progressSubscriber = progressSubscriber; + } + + function xhrReadyStateChange(this: XMLHttpRequest, e: Event) { + return; + } + xhr.onreadystatechange = xhrReadyStateChange; + (<any>xhrReadyStateChange).subscriber = this; + (<any>xhrReadyStateChange).progressSubscriber = progressSubscriber; + (<any>xhrReadyStateChange).request = request; + + function xhrLoad(this: XMLHttpRequest, e: Event) { + const { subscriber, progressSubscriber, request } = (<any>xhrLoad); + if (this.readyState === 4) { + // normalize IE9 bug (http://bugs.jquery.com/ticket/1450) + let status: number = this.status === 1223 ? 204 : this.status; + let response: any = (this.responseType === 'text' ? ( + this.response || this.responseText) : this.response); + + // fix status code when it is 0 (0 status is undocumented). + // Occurs when accessing file resources or on Android 4.1 stock browser + // while retrieving files from application cache. + if (status === 0) { + status = response ? 200 : 0; + } + + // 4xx and 5xx should error (https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html) + if (status < 400) { + if (progressSubscriber) { + progressSubscriber.complete(); + } + subscriber.next(e); + subscriber.complete(); + } else { + if (progressSubscriber) { + progressSubscriber.error(e); + } + let error; + try { + error = new AjaxError('ajax error ' + status, this, request); + } catch (err) { + error = err; + } + subscriber.error(error); + } + } + } + xhr.onload = xhrLoad; + (<any>xhrLoad).subscriber = this; + (<any>xhrLoad).progressSubscriber = progressSubscriber; + (<any>xhrLoad).request = request; + } + + unsubscribe() { + const { done, xhr } = this; + if (!done && xhr && xhr.readyState !== 4 && typeof xhr.abort === 'function') { + xhr.abort(); + } + super.unsubscribe(); + } +} + +/** + * A normalized AJAX response. + * + * @see {@link ajax} + * + * @class AjaxResponse + */ +export class AjaxResponse { + /** @type {number} The HTTP status code */ + status: number; + + /** @type {string|ArrayBuffer|Document|object|any} The response data */ + response: any; + + /** @type {string} The raw responseText */ + responseText: string; + + /** @type {string} The responseType (e.g. 'json', 'arraybuffer', or 'xml') */ + responseType: string; + + constructor(public originalEvent: Event, public xhr: XMLHttpRequest, public request: AjaxRequest) { + this.status = xhr.status; + this.responseType = xhr.responseType || request.responseType; + this.response = parseXhrResponse(this.responseType, xhr); + } +} + +export type AjaxErrorNames = 'AjaxError' | 'AjaxTimeoutError'; + +/** + * A normalized AJAX error. + * + * @see {@link ajax} + * + * @class AjaxError + */ +export interface AjaxError extends Error { + /** @type {XMLHttpRequest} The XHR instance associated with the error */ + xhr: XMLHttpRequest; + + /** @type {AjaxRequest} The AjaxRequest associated with the error */ + request: AjaxRequest; + + /** @type {number} The HTTP status code */ + status: number; + + /** @type {string} The responseType (e.g. 'json', 'arraybuffer', or 'xml') */ + responseType: string; + + /** @type {string|ArrayBuffer|Document|object|any} The response data */ + response: any; +} + +export interface AjaxErrorCtor { + new(message: string, xhr: XMLHttpRequest, request: AjaxRequest): AjaxError; +} + +const AjaxErrorImpl = (() => { + function AjaxErrorImpl(this: any, message: string, xhr: XMLHttpRequest, request: AjaxRequest): AjaxError { + Error.call(this); + this.message = message; + this.name = 'AjaxError'; + this.xhr = xhr; + this.request = request; + this.status = xhr.status; + this.responseType = xhr.responseType || request.responseType; + this.response = parseXhrResponse(this.responseType, xhr); + return this; + } + AjaxErrorImpl.prototype = Object.create(Error.prototype); + return AjaxErrorImpl; +})(); + +export const AjaxError: AjaxErrorCtor = AjaxErrorImpl as any; + +function parseJson(xhr: XMLHttpRequest) { + // HACK(benlesh): TypeScript shennanigans + // tslint:disable-next-line:no-any XMLHttpRequest is defined to always have 'response' inferring xhr as never for the else clause. + if ('response' in (xhr as any)) { + //IE does not support json as responseType, parse it internally + return xhr.responseType ? xhr.response : JSON.parse(xhr.response || xhr.responseText || 'null'); + } else { + return JSON.parse((xhr as any).responseText || 'null'); + } +} + +function parseXhrResponse(responseType: string, xhr: XMLHttpRequest) { + switch (responseType) { + case 'json': + return parseJson(xhr); + case 'xml': + return xhr.responseXML; + case 'text': + default: + // HACK(benlesh): TypeScript shennanigans + // tslint:disable-next-line:no-any XMLHttpRequest is defined to always have 'response' inferring xhr as never for the else sub-expression. + return ('response' in (xhr as any)) ? xhr.response : xhr.responseText; + } +} + +export interface AjaxTimeoutError extends AjaxError { +} + +export interface AjaxTimeoutErrorCtor { + new(xhr: XMLHttpRequest, request: AjaxRequest): AjaxTimeoutError; +} + +function AjaxTimeoutErrorImpl(this: any, xhr: XMLHttpRequest, request: AjaxRequest) { + AjaxError.call(this, 'ajax timeout', xhr, request); + this.name = 'AjaxTimeoutError'; + return this; +} + +/** + * @see {@link ajax} + * + * @class AjaxTimeoutError + */ +export const AjaxTimeoutError: AjaxTimeoutErrorCtor = AjaxTimeoutErrorImpl as any; diff --git a/sandbox/testAppNevena/Front/node_modules/rxjs/src/internal/observable/dom/ajax.ts b/sandbox/testAppNevena/Front/node_modules/rxjs/src/internal/observable/dom/ajax.ts new file mode 100644 index 00000000..d0885c1d --- /dev/null +++ b/sandbox/testAppNevena/Front/node_modules/rxjs/src/internal/observable/dom/ajax.ts @@ -0,0 +1,82 @@ +import { AjaxObservable, AjaxCreationMethod } from './AjaxObservable'; +/** + * There is an ajax operator on the Rx object. + * + * It creates an observable for an Ajax request with either a request object with + * url, headers, etc or a string for a URL. + * + * + * ## Using ajax() to fetch the response object that is being returned from API. + * ```ts + * import { ajax } from 'rxjs/ajax'; + * import { map, catchError } from 'rxjs/operators'; + * import { of } from 'rxjs'; + * + * const obs$ = ajax(`https://api.github.com/users?per_page=5`).pipe( + * map(userResponse => console.log('users: ', userResponse)), + * catchError(error => { + * console.log('error: ', error); + * return of(error); + * }) + * ); + * + * ``` + * + * ## Using ajax.getJSON() to fetch data from API. + * ```ts + * import { ajax } from 'rxjs/ajax'; + * import { map, catchError } from 'rxjs/operators'; + * import { of } from 'rxjs'; + * + * const obs$ = ajax.getJSON(`https://api.github.com/users?per_page=5`).pipe( + * map(userResponse => console.log('users: ', userResponse)), + * catchError(error => { + * console.log('error: ', error); + * return of(error); + * }) + * ); + * + * ``` + * + * ## Using ajax() with object as argument and method POST with a two seconds delay. + * ```ts + * import { ajax } from 'rxjs/ajax'; + * import { of } from 'rxjs'; + * + * const users = ajax({ + * url: 'https://httpbin.org/delay/2', + * method: 'POST', + * headers: { + * 'Content-Type': 'application/json', + * 'rxjs-custom-header': 'Rxjs' + * }, + * body: { + * rxjs: 'Hello World!' + * } + * }).pipe( + * map(response => console.log('response: ', response)), + * catchError(error => { + * console.log('error: ', error); + * return of(error); + * }) + * ); + * + * ``` + * + * ## Using ajax() to fetch. An error object that is being returned from the request. + * ```ts + * import { ajax } from 'rxjs/ajax'; + * import { map, catchError } from 'rxjs/operators'; + * import { of } from 'rxjs'; + * + * const obs$ = ajax(`https://api.github.com/404`).pipe( + * map(userResponse => console.log('users: ', userResponse)), + * catchError(error => { + * console.log('error: ', error); + * return of(error); + * }) + * ); + * + * ``` + */ +export const ajax: AjaxCreationMethod = (() => AjaxObservable.create)(); diff --git a/sandbox/testAppNevena/Front/node_modules/rxjs/src/internal/scheduler/Action.ts b/sandbox/testAppNevena/Front/node_modules/rxjs/src/internal/scheduler/Action.ts new file mode 100644 index 00000000..6cf91bcb --- /dev/null +++ b/sandbox/testAppNevena/Front/node_modules/rxjs/src/internal/scheduler/Action.ts @@ -0,0 +1,36 @@ +import { Scheduler } from '../Scheduler'; +import { Subscription } from '../Subscription'; +import { SchedulerAction } from '../types'; + +/** + * A unit of work to be executed in a `scheduler`. An action is typically + * created from within a {@link SchedulerLike} and an RxJS user does not need to concern + * themselves about creating and manipulating an Action. + * + * ```ts + * class Action<T> extends Subscription { + * new (scheduler: Scheduler, work: (state?: T) => void); + * schedule(state?: T, delay: number = 0): Subscription; + * } + * ``` + * + * @class Action<T> + */ +export class Action<T> extends Subscription { + constructor(scheduler: Scheduler, work: (this: SchedulerAction<T>, state?: T) => void) { + super(); + } + /** + * Schedules this action on its parent {@link SchedulerLike} for execution. May be passed + * some context object, `state`. May happen at some point in the future, + * according to the `delay` parameter, if specified. + * @param {T} [state] Some contextual data that the `work` function uses when + * called by the Scheduler. + * @param {number} [delay] Time to wait before executing the work, where the + * time unit is implicit and defined by the Scheduler. + * @return {void} + */ + public schedule(state?: T, delay: number = 0): Subscription { + return this; + } +} diff --git a/sandbox/testAppNevena/Front/node_modules/rxjs/src/internal/scheduler/AnimationFrameAction.ts b/sandbox/testAppNevena/Front/node_modules/rxjs/src/internal/scheduler/AnimationFrameAction.ts new file mode 100644 index 00000000..e9ea64fa --- /dev/null +++ b/sandbox/testAppNevena/Front/node_modules/rxjs/src/internal/scheduler/AnimationFrameAction.ts @@ -0,0 +1,47 @@ +import { AsyncAction } from './AsyncAction'; +import { AnimationFrameScheduler } from './AnimationFrameScheduler'; +import { SchedulerAction } from '../types'; + +/** + * We need this JSDoc comment for affecting ESDoc. + * @ignore + * @extends {Ignored} + */ +export class AnimationFrameAction<T> extends AsyncAction<T> { + + constructor(protected scheduler: AnimationFrameScheduler, + protected work: (this: SchedulerAction<T>, state?: T) => void) { + super(scheduler, work); + } + + protected requestAsyncId(scheduler: AnimationFrameScheduler, id?: any, delay: number = 0): any { + // If delay is greater than 0, request as an async action. + if (delay !== null && delay > 0) { + return super.requestAsyncId(scheduler, id, delay); + } + // Push the action to the end of the scheduler queue. + scheduler.actions.push(this); + // If an animation frame has already been requested, don't request another + // one. If an animation frame hasn't been requested yet, request one. Return + // the current animation frame request id. + return scheduler.scheduled || (scheduler.scheduled = requestAnimationFrame( + () => scheduler.flush(null))); + } + protected recycleAsyncId(scheduler: AnimationFrameScheduler, id?: any, delay: number = 0): any { + // If delay exists and is greater than 0, or if the delay is null (the + // action wasn't rescheduled) but was originally scheduled as an async + // action, then recycle as an async action. + if ((delay !== null && delay > 0) || (delay === null && this.delay > 0)) { + return super.recycleAsyncId(scheduler, id, delay); + } + // If the scheduler queue is empty, cancel the requested animation frame and + // set the scheduled flag to undefined so the next AnimationFrameAction will + // request its own. + if (scheduler.actions.length === 0) { + cancelAnimationFrame(id); + scheduler.scheduled = undefined; + } + // Return undefined so the action knows to request a new async id if it's rescheduled. + return undefined; + } +} diff --git a/sandbox/testAppNevena/Front/node_modules/rxjs/src/internal/scheduler/AnimationFrameScheduler.ts b/sandbox/testAppNevena/Front/node_modules/rxjs/src/internal/scheduler/AnimationFrameScheduler.ts new file mode 100644 index 00000000..c550429f --- /dev/null +++ b/sandbox/testAppNevena/Front/node_modules/rxjs/src/internal/scheduler/AnimationFrameScheduler.ts @@ -0,0 +1,31 @@ +import { AsyncAction } from './AsyncAction'; +import { AsyncScheduler } from './AsyncScheduler'; + +export class AnimationFrameScheduler extends AsyncScheduler { + public flush(action?: AsyncAction<any>): void { + + this.active = true; + this.scheduled = undefined; + + const {actions} = this; + let error: any; + let index: number = -1; + let count: number = actions.length; + action = action || actions.shift(); + + do { + if (error = action.execute(action.state, action.delay)) { + break; + } + } while (++index < count && (action = actions.shift())); + + this.active = false; + + if (error) { + while (++index < count && (action = actions.shift())) { + action.unsubscribe(); + } + throw error; + } + } +} diff --git a/sandbox/testAppNevena/Front/node_modules/rxjs/src/internal/scheduler/AsapAction.ts b/sandbox/testAppNevena/Front/node_modules/rxjs/src/internal/scheduler/AsapAction.ts new file mode 100644 index 00000000..1fe1622d --- /dev/null +++ b/sandbox/testAppNevena/Front/node_modules/rxjs/src/internal/scheduler/AsapAction.ts @@ -0,0 +1,48 @@ +import { Immediate } from '../util/Immediate'; +import { AsyncAction } from './AsyncAction'; +import { AsapScheduler } from './AsapScheduler'; +import { SchedulerAction } from '../types'; +/** + * We need this JSDoc comment for affecting ESDoc. + * @ignore + * @extends {Ignored} + */ +export class AsapAction<T> extends AsyncAction<T> { + + constructor(protected scheduler: AsapScheduler, + protected work: (this: SchedulerAction<T>, state?: T) => void) { + super(scheduler, work); + } + + protected requestAsyncId(scheduler: AsapScheduler, id?: any, delay: number = 0): any { + // If delay is greater than 0, request as an async action. + if (delay !== null && delay > 0) { + return super.requestAsyncId(scheduler, id, delay); + } + // Push the action to the end of the scheduler queue. + scheduler.actions.push(this); + // If a microtask has already been scheduled, don't schedule another + // one. If a microtask hasn't been scheduled yet, schedule one now. Return + // the current scheduled microtask id. + return scheduler.scheduled || (scheduler.scheduled = Immediate.setImmediate( + scheduler.flush.bind(scheduler, null) + )); + } + protected recycleAsyncId(scheduler: AsapScheduler, id?: any, delay: number = 0): any { + // If delay exists and is greater than 0, or if the delay is null (the + // action wasn't rescheduled) but was originally scheduled as an async + // action, then recycle as an async action. + if ((delay !== null && delay > 0) || (delay === null && this.delay > 0)) { + return super.recycleAsyncId(scheduler, id, delay); + } + // If the scheduler queue is empty, cancel the requested microtask and + // set the scheduled flag to undefined so the next AsapAction will schedule + // its own. + if (scheduler.actions.length === 0) { + Immediate.clearImmediate(id); + scheduler.scheduled = undefined; + } + // Return undefined so the action knows to request a new async id if it's rescheduled. + return undefined; + } +} diff --git a/sandbox/testAppNevena/Front/node_modules/rxjs/src/internal/scheduler/animationFrame.ts b/sandbox/testAppNevena/Front/node_modules/rxjs/src/internal/scheduler/animationFrame.ts new file mode 100644 index 00000000..a3f62050 --- /dev/null +++ b/sandbox/testAppNevena/Front/node_modules/rxjs/src/internal/scheduler/animationFrame.ts @@ -0,0 +1,40 @@ +import { AnimationFrameAction } from './AnimationFrameAction'; +import { AnimationFrameScheduler } from './AnimationFrameScheduler'; + +/** + * + * Animation Frame Scheduler + * + * <span class="informal">Perform task when `window.requestAnimationFrame` would fire</span> + * + * When `animationFrame` scheduler is used with delay, it will fall back to {@link asyncScheduler} scheduler + * behaviour. + * + * Without delay, `animationFrame` scheduler can be used to create smooth browser animations. + * It makes sure scheduled task will happen just before next browser content repaint, + * thus performing animations as efficiently as possible. + * + * ## Example + * Schedule div height animation + * ```ts + * // html: <div style="background: #0ff;"></div> + * import { animationFrameScheduler } from 'rxjs'; + * + * const div = document.querySelector('div'); + * + * animationFrameScheduler.schedule(function(height) { + * div.style.height = height + "px"; + * + * this.schedule(height + 1); // `this` references currently executing Action, + * // which we reschedule with new state + * }, 0, 0); + * + * // You will see a div element growing in height + * ``` + */ +export const animationFrameScheduler = new AnimationFrameScheduler(AnimationFrameAction); + +/** + * @deprecated renamed. Use {@link animationFrameScheduler} + */ +export const animationFrame = animationFrameScheduler; diff --git a/sandbox/testAppNevena/Front/node_modules/rxjs/src/internal/scheduler/asap.ts b/sandbox/testAppNevena/Front/node_modules/rxjs/src/internal/scheduler/asap.ts new file mode 100644 index 00000000..bbd721d2 --- /dev/null +++ b/sandbox/testAppNevena/Front/node_modules/rxjs/src/internal/scheduler/asap.ts @@ -0,0 +1,43 @@ +import { AsapAction } from './AsapAction'; +import { AsapScheduler } from './AsapScheduler'; + +/** + * + * Asap Scheduler + * + * <span class="informal">Perform task as fast as it can be performed asynchronously</span> + * + * `asap` scheduler behaves the same as {@link asyncScheduler} scheduler when you use it to delay task + * in time. If however you set delay to `0`, `asap` will wait for current synchronously executing + * code to end and then it will try to execute given task as fast as possible. + * + * `asap` scheduler will do its best to minimize time between end of currently executing code + * and start of scheduled task. This makes it best candidate for performing so called "deferring". + * Traditionally this was achieved by calling `setTimeout(deferredTask, 0)`, but that technique involves + * some (although minimal) unwanted delay. + * + * Note that using `asap` scheduler does not necessarily mean that your task will be first to process + * after currently executing code. In particular, if some task was also scheduled with `asap` before, + * that task will execute first. That being said, if you need to schedule task asynchronously, but + * as soon as possible, `asap` scheduler is your best bet. + * + * ## Example + * Compare async and asap scheduler< + * ```ts + * import { asapScheduler, asyncScheduler } from 'rxjs'; + * + * asyncScheduler.schedule(() => console.log('async')); // scheduling 'async' first... + * asapScheduler.schedule(() => console.log('asap')); + * + * // Logs: + * // "asap" + * // "async" + * // ... but 'asap' goes first! + * ``` + */ +export const asapScheduler = new AsapScheduler(AsapAction); + +/** + * @deprecated renamed. Use {@link asapScheduler} + */ +export const asap = asapScheduler; diff --git a/sandbox/testAppNevena/Front/node_modules/rxjs/src/internal/util/ArgumentOutOfRangeError.ts b/sandbox/testAppNevena/Front/node_modules/rxjs/src/internal/util/ArgumentOutOfRangeError.ts new file mode 100644 index 00000000..b9bd72d1 --- /dev/null +++ b/sandbox/testAppNevena/Front/node_modules/rxjs/src/internal/util/ArgumentOutOfRangeError.ts @@ -0,0 +1,31 @@ +export interface ArgumentOutOfRangeError extends Error { +} + +export interface ArgumentOutOfRangeErrorCtor { + new(): ArgumentOutOfRangeError; +} + +const ArgumentOutOfRangeErrorImpl = (() => { + function ArgumentOutOfRangeErrorImpl(this: any) { + Error.call(this); + this.message = 'argument out of range'; + this.name = 'ArgumentOutOfRangeError'; + return this; + } + + ArgumentOutOfRangeErrorImpl.prototype = Object.create(Error.prototype); + + return ArgumentOutOfRangeErrorImpl; +})(); + +/** + * An error thrown when an element was queried at a certain index of an + * Observable, but no such index or position exists in that sequence. + * + * @see {@link elementAt} + * @see {@link take} + * @see {@link takeLast} + * + * @class ArgumentOutOfRangeError + */ +export const ArgumentOutOfRangeError: ArgumentOutOfRangeErrorCtor = ArgumentOutOfRangeErrorImpl as any;
\ No newline at end of file diff --git a/sandbox/testAppNevena/Front/node_modules/rxjs/src/internal/util/applyMixins.ts b/sandbox/testAppNevena/Front/node_modules/rxjs/src/internal/util/applyMixins.ts new file mode 100644 index 00000000..7c1ed242 --- /dev/null +++ b/sandbox/testAppNevena/Front/node_modules/rxjs/src/internal/util/applyMixins.ts @@ -0,0 +1,10 @@ +export function applyMixins(derivedCtor: any, baseCtors: any[]) { + for (let i = 0, len = baseCtors.length; i < len; i++) { + const baseCtor = baseCtors[i]; + const propertyKeys = Object.getOwnPropertyNames(baseCtor.prototype); + for (let j = 0, len2 = propertyKeys.length; j < len2; j++) { + const name = propertyKeys[j]; + derivedCtor.prototype[name] = baseCtor.prototype[name]; + } + } +}
\ No newline at end of file |