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

@equinor/fusion-framework-module-app

Package Overview
Dependencies
Maintainers
3
Versions
186
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

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

Comparing version 1.2.0 to 1.3.0

6

CHANGELOG.md

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

## 1.3.0 (2022-11-14)
### Features
- **module-app:** add app loader ([0ef0b71](https://github.com/equinor/fusion-framework/commit/0ef0b71de27f1dccc757aa7eceea558072a1db60))
## [1.2.0](https://github.com/equinor/fusion-framework/compare/@equinor/fusion-framework-module-app@1.1.6...@equinor/fusion-framework-module-app@1.2.0) (2022-11-14)

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

7

dist/esm/configurator.js

@@ -23,3 +23,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

const serviceDiscovery = yield init.requireInstance('serviceDiscovery');
return yield serviceDiscovery.createClient('portal');
try {
return yield serviceDiscovery.createClient('app');
}
catch (err) {
return yield serviceDiscovery.createClient('portal');
}
}

@@ -26,0 +31,0 @@ });

@@ -13,3 +13,3 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {

var _AppProvider_appClient, _AppProvider_appsClient, _AppProvider_configClient, _AppProvider_current$, _AppProvider_subscription;
import { BehaviorSubject, distinctUntilChanged, Observable, pairwise, Subscription, takeWhile, } from 'rxjs';
import { BehaviorSubject, distinctUntilChanged, filter, firstValueFrom, from, map, merge, Observable, pairwise, scan, Subscription, switchMap, takeWhile, } from 'rxjs';
import { Query } from '@equinor/fusion-observable/query';

@@ -67,2 +67,9 @@ import { compareAppManifest } from './helpers';

}
loadApp(appKey) {
const loadApp$ = this.getApp(appKey).pipe(switchMap((manifest) => {
return firstValueFrom(from(import(manifest.entry)).pipe(map((module) => ({ manifest, module }))));
}));
const loadConfig$ = this.getAppConfig(appKey).pipe(map((config) => ({ config })));
return merge(loadApp$, loadConfig$).pipe(scan((acc, next) => Object.assign({}, acc, next), {}), filter((x) => ['manifest', 'module', 'config'].every((key) => !!x[key])));
}
dispose() {

@@ -69,0 +76,0 @@ __classPrivateFieldGet(this, _AppProvider_subscription, "f").unsubscribe();

@@ -12,3 +12,9 @@ import { Observable } from 'rxjs';

readonly current$: Observable<AppManifest | undefined>;
loadApp<TEnvironment = unknown, TModule = any>(appKey: string): Observable<AppBundle<TEnvironment, TModule>>;
}
export declare type AppBundle<TEnvironment = unknown, TModule = unknown> = {
manifest: AppManifest;
config: AppConfig<TEnvironment>;
module: TModule;
};
export declare class AppProvider extends Observable<AppManifest | undefined> implements IAppProvider {

@@ -26,2 +32,3 @@ #private;

setCurrentApp(appKey: string): Promise<void>;
loadApp<TEnvironment = unknown, TModule = unknown>(appKey: string): Observable<AppBundle<TEnvironment, TModule>>;
dispose(): void;

@@ -28,0 +35,0 @@ }

@@ -32,2 +32,3 @@ import type { EventModule } from '@equinor/fusion-framework-module-event';

hide?: boolean;
entry: string;
};

@@ -34,0 +35,0 @@ export declare type Endpoint = {

4

package.json
{
"name": "@equinor/fusion-framework-module-app",
"version": "1.2.0",
"version": "1.3.0",
"description": "",

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

},
"gitHead": "8d6faac0a36f2e1792e4112e362c6ce3cf98371e"
"gitHead": "8034da7d4ca056c44b253c91285e86f7011639ba"
}

@@ -39,4 +39,9 @@ import { AnyModule, ModuleInitializerArgs } from '@equinor/fusion-framework-module';

const serviceDiscovery = await init.requireInstance('serviceDiscovery');
/** resolve and create a client from discovery */
return await serviceDiscovery.createClient('portal');
try {
return await serviceDiscovery.createClient('app');
} catch (err) {
return await serviceDiscovery.createClient('portal');
}
}

@@ -43,0 +48,0 @@ }

import {
BehaviorSubject,
distinctUntilChanged,
filter,
firstValueFrom,
from,
map,
merge,
Observable,
pairwise,
scan,
Subscription,
switchMap,
takeWhile,

@@ -31,4 +38,18 @@ } from 'rxjs';

readonly current$: Observable<AppManifest | undefined>;
loadApp<TEnvironment = unknown, TModule = any>(
appKey: string
): Observable<AppBundle<TEnvironment, TModule>>;
}
/**
* @template TModule - ES module type
*/
export type AppBundle<TEnvironment = unknown, TModule = unknown> = {
manifest: AppManifest;
config: AppConfig<TEnvironment>;
/** ES module instance */
module: TModule;
};
export class AppProvider extends Observable<AppManifest | undefined> implements IAppProvider {

@@ -109,2 +130,26 @@ #appClient: Query<AppManifest, { appKey: string }>;

public loadApp<TEnvironment = unknown, TModule = unknown>(
appKey: string
): Observable<AppBundle<TEnvironment, TModule>> {
const loadApp$ = this.getApp(appKey).pipe(
switchMap((manifest) => {
return firstValueFrom(
// TODO: use source from manifest when service is ready!
/* @vite-ignore */
from(import(manifest.entry)).pipe(map((module) => ({ manifest, module })))
);
})
);
const loadConfig$ = this.getAppConfig(appKey).pipe(map((config) => ({ config })));
return merge(loadApp$, loadConfig$).pipe(
scan((acc: Partial<AppBundle>, next) => Object.assign({}, acc, next), {}),
/** only output when all attributes are filled */
filter((x): x is AppBundle<TEnvironment, TModule> =>
['manifest', 'module', 'config'].every((key) => !!x[key as keyof AppBundle])
)
);
}
public dispose() {

@@ -111,0 +156,0 @@ this.#subscription.unsubscribe();

@@ -39,2 +39,3 @@ import type { EventModule } from '@equinor/fusion-framework-module-event';

hide?: boolean;
entry: string;
};

@@ -41,0 +42,0 @@

Sorry, the diff of this file is not supported yet

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