Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@equinor/fusion-framework-module-context

Package Overview
Dependencies
Maintainers
4
Versions
145
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@equinor/fusion-framework-module-context - npm Package Compare versions

Comparing version 4.0.2 to 4.0.3

6

CHANGELOG.md

@@ -6,2 +6,8 @@ # Change Log

## [4.0.3](https://github.com/equinor/fusion-framework/compare/@equinor/fusion-framework-module-context@4.0.2...@equinor/fusion-framework-module-context@4.0.3) (2023-05-11)
### Bug Fixes
- **module-context:** execute all setting of context ([eb85c0c](https://github.com/equinor/fusion-framework/commit/eb85c0c239ec70edeb796b2f03b6ecd4c2fb9fb5)), closes [/github.com/equinor/fusion-framework/blob/3cd1a9e01c56fc9afb72f2df474a7b066b4215c4/packages/modules/context/src/ContextProvider.ts#L181](https://github.com/equinor//github.com/equinor/fusion-framework/blob/3cd1a9e01c56fc9afb72f2df474a7b066b4215c4/packages/modules/context/src/ContextProvider.ts/issues/L181)
## 4.0.2 (2023-05-10)

@@ -8,0 +14,0 @@

23

dist/esm/ContextProvider.js

@@ -21,5 +21,5 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

};
var _ContextProvider_contextClient, _ContextProvider_contextQuery, _ContextProvider_contextRelated, _ContextProvider_event, _ContextProvider_subscriptions, _ContextProvider_contextType, _ContextProvider_contextFilter, _ContextProvider_contextParameterFn;
import { EMPTY, firstValueFrom, lastValueFrom, Observable, of, Subscription, throwError, } from 'rxjs';
import { catchError, filter, map, pairwise, switchMap } from 'rxjs/operators';
var _ContextProvider_contextClient, _ContextProvider_contextQuery, _ContextProvider_contextRelated, _ContextProvider_event, _ContextProvider_subscriptions, _ContextProvider_contextType, _ContextProvider_contextFilter, _ContextProvider_contextParameterFn, _ContextProvider_contextQueue;
import { EMPTY, firstValueFrom, lastValueFrom, Observable, of, Subject, Subscription, throwError, } from 'rxjs';
import { catchError, filter, finalize, map, pairwise, switchMap, takeUntil, tap, } from 'rxjs/operators';
import { ContextClient } from './client/ContextClient';

@@ -57,2 +57,3 @@ import Query from '@equinor/fusion-query';

_ContextProvider_contextParameterFn.set(this, void 0);
_ContextProvider_contextQueue.set(this, new Subject());
const { config, event } = args;

@@ -91,2 +92,5 @@ if (args.parentContext) {

}
__classPrivateFieldGet(this, _ContextProvider_subscriptions, "f").add(__classPrivateFieldGet(this, _ContextProvider_contextQueue, "f")
.pipe(switchMap((next) => next), tap((x) => console.debug('ContextProvider::#contextQueue', x)))
.subscribe((context) => __classPrivateFieldGet(this, _ContextProvider_contextClient, "f").setCurrentContext(context !== null && context !== void 0 ? context : null)));
}

@@ -148,2 +152,12 @@ connectParentContext(provider, opt) {

setCurrentContext(context, opt) {
const abort$ = new Subject();
const subject$ = new Subject();
const task$ = this._setCurrentContext(context, opt).pipe(tap((x) => subject$.next(x)), takeUntil(abort$), finalize(() => subject$.complete()), catchError((err) => {
subject$.error(err);
return EMPTY;
}));
__classPrivateFieldGet(this, _ContextProvider_contextQueue, "f").next(task$);
return subject$.pipe(finalize(() => abort$.next(true)));
}
_setCurrentContext(context, opt) {
return new Observable((subscriber) => {

@@ -209,3 +223,2 @@ var _a;

.subscribe((context) => {
__classPrivateFieldGet(this, _ContextProvider_contextClient, "f").setCurrentContext(context !== null && context !== void 0 ? context : null);
subscriber.next(context);

@@ -272,4 +285,4 @@ subscriber.complete();

}
_ContextProvider_contextClient = new WeakMap(), _ContextProvider_contextQuery = new WeakMap(), _ContextProvider_contextRelated = new WeakMap(), _ContextProvider_event = new WeakMap(), _ContextProvider_subscriptions = new WeakMap(), _ContextProvider_contextType = new WeakMap(), _ContextProvider_contextFilter = new WeakMap(), _ContextProvider_contextParameterFn = new WeakMap();
_ContextProvider_contextClient = new WeakMap(), _ContextProvider_contextQuery = new WeakMap(), _ContextProvider_contextRelated = new WeakMap(), _ContextProvider_event = new WeakMap(), _ContextProvider_subscriptions = new WeakMap(), _ContextProvider_contextType = new WeakMap(), _ContextProvider_contextFilter = new WeakMap(), _ContextProvider_contextParameterFn = new WeakMap(), _ContextProvider_contextQueue = new WeakMap();
export default ContextProvider;
//# sourceMappingURL=ContextProvider.js.map

@@ -53,2 +53,6 @@ import { Observable, Subscription } from 'rxjs';

}): Observable<T>;
protected _setCurrentContext<T extends ContextItem<Record<string, unknown>> | null>(context: T, opt?: {
validate?: boolean;
resolve?: boolean;
}): Observable<T>;
setCurrentContextAsync<T extends ContextItem<Record<string, unknown>> | null>(context: T, opt?: {

@@ -55,0 +59,0 @@ validate?: boolean;

{
"name": "@equinor/fusion-framework-module-context",
"version": "4.0.2",
"version": "4.0.3",
"description": "",

@@ -52,3 +52,3 @@ "main": "./dist/esm/index.js",

},
"gitHead": "3cd1a9e01c56fc9afb72f2df474a7b066b4215c4"
"gitHead": "70d3c82b6b68ba276e97c6de56c646f2b71d3fbd"
}

@@ -7,6 +7,16 @@ import {

of,
Subject,
Subscription,
throwError,
} from 'rxjs';
import { catchError, filter, map, pairwise, switchMap } from 'rxjs/operators';
import {
catchError,
filter,
finalize,
map,
pairwise,
switchMap,
takeUntil,
tap,
} from 'rxjs/operators';

@@ -77,2 +87,4 @@ import { ContextModuleConfig } from './configurator';

#contextQueue = new Subject<Observable<ContextItem<Record<string, unknown>>>>();
public get contextClient() {

@@ -164,2 +176,11 @@ return this.#contextClient;

}
this.#subscriptions.add(
this.#contextQueue
.pipe(
switchMap((next) => next),
tap((x) => console.debug('ContextProvider::#contextQueue', x))
)
.subscribe((context) => this.#contextClient.setCurrentContext(context ?? null))
);
}

@@ -250,2 +271,13 @@

/**
* Setting context is a complex operation, and might not happen immediately.
* When setting the context, a task is created and added to the queue.
* Once the task is completed, the returned observable will emit the value which will be the next state.
*
* Even tho this function returns a `Observable`, the task will be queued even tho nobody subscribes.
*
* If the observable is subscribe, unsubscribing __WILL__ abort the task and remove it from queue
*
* @param context context item which would be queue to set as current
*/
public setCurrentContext<T extends ContextItem<Record<string, unknown>> | null>(

@@ -255,2 +287,37 @@ context: T,

): Observable<T> {
/** signal for aborting the queue entry */
const abort$ = new Subject();
/** wrapper for returning an observable to the caller */
const subject$ = new Subject<T>();
const task$ = this._setCurrentContext(context, opt).pipe(
/** send context item which was set to the caller */
tap((x) => subject$.next(x)),
/** abort task on signal */
takeUntil(abort$),
/** close observable sent to caller */
finalize(() => subject$.complete()),
/** catch errors to not stall queue */
catchError((err) => {
/** send the error to the caller */
subject$.error(err);
/** skip setting any context */
return EMPTY;
})
);
/** add task to internal queue */
this.#contextQueue.next(task$ as Observable<ContextItem<Record<string, unknown>>>);
return subject$.pipe(
/** if caller subscribes, unsubscribe should abort queue entry */
finalize(() => abort$.next(true))
);
}
protected _setCurrentContext<T extends ContextItem<Record<string, unknown>> | null>(
context: T,
opt?: { validate?: boolean; resolve?: boolean }
): Observable<T> {
return new Observable((subscriber) => {

@@ -339,3 +406,2 @@ if (context === this.currentContext) {

.subscribe((context) => {
this.#contextClient.setCurrentContext(context ?? null);
subscriber.next(context);

@@ -342,0 +408,0 @@ subscriber.complete();

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc