@equinor/fusion-framework-module-app
Advanced tools
Comparing version 2.3.0 to 2.4.0
@@ -6,2 +6,8 @@ # Change Log | ||
## [2.4.0](https://github.com/equinor/fusion-framework/compare/@equinor/fusion-framework-module-app@2.3.0...@equinor/fusion-framework-module-app@2.4.0) (2022-12-12) | ||
### Features | ||
- **module-app:** allow creating app instance ([d2d3080](https://github.com/equinor/fusion-framework/commit/d2d3080f4822fefca5df5a4a1ce46f138095d567)) | ||
## 2.3.0 (2022-12-12) | ||
@@ -8,0 +14,0 @@ |
@@ -55,5 +55,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
} | ||
constructor(appKey, args) { | ||
constructor(value, args) { | ||
_App_state.set(this, void 0); | ||
__classPrivateFieldSet(this, _App_state, createState(appKey, args.provider), "f"); | ||
__classPrivateFieldSet(this, _App_state, createState(value, args.provider), "f"); | ||
const { appKey } = value; | ||
const subscriptions = new Subscription(); | ||
@@ -60,0 +61,0 @@ if (args.event) { |
@@ -5,3 +5,3 @@ import { actionBaseType, createReducer as makeReducer, isCompleteAction, isRequestAction, } from '@equinor/fusion-observable'; | ||
import { actions } from './actions'; | ||
export const createReducer = (appKey) => makeReducer({ appKey, status: new Set() }, (builder) => builder | ||
export const createReducer = (value) => makeReducer(Object.assign(Object.assign({}, value), { status: new Set() }), (builder) => builder | ||
.addCase(actions.setManifest, (state, action) => { | ||
@@ -8,0 +8,0 @@ state.manifest = action.payload; |
import { FlowSubject } from '@equinor/fusion-observable'; | ||
import { createReducer } from './create-reducer'; | ||
import { handleFetchManifest, handleFetchConfig, handleImportApplication } from './flows'; | ||
export const createState = (appKey, provider) => { | ||
const reducer = createReducer(appKey); | ||
export const createState = (value, provider) => { | ||
const reducer = createReducer(value); | ||
const state = new FlowSubject(reducer); | ||
@@ -7,0 +7,0 @@ state.addFlow(handleFetchManifest(provider)); |
@@ -82,5 +82,9 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) { | ||
} | ||
setCurrentApp(appKey) { | ||
__classPrivateFieldGet(this, _AppModuleProvider_current$, "f").next(new App(appKey, { provider: this, event: __classPrivateFieldGet(this, _AppModuleProvider_event, "f") })); | ||
setCurrentApp(appKeyOrApp) { | ||
const app = typeof appKeyOrApp === 'string' ? this.createApp({ appKey: appKeyOrApp }) : App; | ||
__classPrivateFieldGet(this, _AppModuleProvider_current$, "f").next(app); | ||
} | ||
createApp(value) { | ||
return new App(value, { provider: this, event: __classPrivateFieldGet(this, _AppModuleProvider_event, "f") }); | ||
} | ||
dispose() { | ||
@@ -87,0 +91,0 @@ __classPrivateFieldGet(this, _AppModuleProvider_subscription, "f").unsubscribe(); |
@@ -7,2 +7,3 @@ import { AppConfig, AppManifest, AppModulesInstance, AppScriptModule } from '../types'; | ||
import { AnyModule, ModuleType } from '@equinor/fusion-framework-module'; | ||
import { AppBundleStateInitial } from './types'; | ||
import '../events'; | ||
@@ -20,3 +21,3 @@ export declare function filterEmpty<T>(): OperatorFunction<T | null | undefined, T>; | ||
get instance(): AppModulesInstance<TModules> | undefined; | ||
constructor(appKey: string, args: { | ||
constructor(value: AppBundleStateInitial, args: { | ||
provider: AppModuleProvider; | ||
@@ -23,0 +24,0 @@ event?: ModuleType<EventModule>; |
@@ -1,3 +0,3 @@ | ||
import { AppBundleState } from './types'; | ||
export declare const createReducer: (appKey: string) => import("@equinor/fusion-observable").ReducerWithInitialState<AppBundleState<any, any>, import("@equinor/fusion-observable").AnyAction>; | ||
import { AppBundleState, AppBundleStateInitial } from './types'; | ||
export declare const createReducer: (value: AppBundleStateInitial) => import("@equinor/fusion-observable").ReducerWithInitialState<AppBundleState<any, any>, import("@equinor/fusion-observable").AnyAction>; | ||
export default createReducer; |
import { FlowSubject } from '@equinor/fusion-observable'; | ||
import type { Actions } from './actions'; | ||
import type { AppBundleState } from './types'; | ||
import type { AppBundleState, AppBundleStateInitial } from './types'; | ||
import type { AppModuleProvider } from '../AppModuleProvider'; | ||
export declare const createState: (appKey: string, provider: AppModuleProvider) => FlowSubject<AppBundleState, Actions>; | ||
export declare const createState: (value: AppBundleStateInitial, provider: AppModuleProvider) => FlowSubject<AppBundleState, Actions>; |
@@ -10,1 +10,2 @@ import type { AppConfig, AppManifest, AppModulesInstance, AppScriptModule } from '../types'; | ||
}; | ||
export type AppBundleStateInitial<TConfig = any, TModules = any> = Omit<AppBundleState<TConfig, TModules>, 'status'>; |
@@ -8,2 +8,3 @@ import { Observable } from 'rxjs'; | ||
import { AppModuleConfig } from './AppConfigurator'; | ||
import { AppBundleStateInitial } from 'app/types'; | ||
export declare class AppModuleProvider { | ||
@@ -24,5 +25,6 @@ #private; | ||
getAppConfig<TType = unknown>(appKey: string, tag?: string): Observable<AppConfig<TType>>; | ||
setCurrentApp(appKey: string): void; | ||
setCurrentApp(appKeyOrApp: string | App): void; | ||
createApp(value: AppBundleStateInitial): App; | ||
dispose(): void; | ||
} | ||
export default AppModuleProvider; |
{ | ||
"name": "@equinor/fusion-framework-module-app", | ||
"version": "2.3.0", | ||
"version": "2.4.0", | ||
"description": "", | ||
@@ -44,3 +44,3 @@ "main": "dist/esm/index.js", | ||
}, | ||
"gitHead": "4bc7a862d19921fc8801e5238d7013b8ece12917" | ||
"gitHead": "a37a5380c885ba37e6462429f4ebc501aee64bb9" | ||
} |
@@ -19,3 +19,3 @@ import { AppConfig, AppManifest, AppModulesInstance, AppScriptModule } from '../types'; | ||
import { actions, Actions } from './actions'; | ||
import { AppBundleState } from './types'; | ||
import { AppBundleState, AppBundleStateInitial } from './types'; | ||
@@ -82,7 +82,12 @@ import '../events'; | ||
constructor( | ||
appKey: string, | ||
args: { provider: AppModuleProvider; event?: ModuleType<EventModule> } | ||
value: AppBundleStateInitial, | ||
args: { | ||
provider: AppModuleProvider; | ||
event?: ModuleType<EventModule>; | ||
} | ||
) { | ||
this.#state = createState(appKey, args.provider); | ||
this.#state = createState(value, args.provider); | ||
const { appKey } = value; | ||
const subscriptions = new Subscription(); | ||
@@ -89,0 +94,0 @@ |
@@ -14,6 +14,6 @@ import { | ||
import { AppBundleState } from './types'; | ||
import { AppBundleState, AppBundleStateInitial } from './types'; | ||
export const createReducer = (appKey: string) => | ||
makeReducer({ appKey, status: new Set() } as AppBundleState, (builder) => | ||
export const createReducer = (value: AppBundleStateInitial) => | ||
makeReducer({ ...value, status: new Set() } as AppBundleState, (builder) => | ||
builder | ||
@@ -20,0 +20,0 @@ .addCase(actions.setManifest, (state, action) => { |
@@ -8,10 +8,10 @@ import { FlowSubject } from '@equinor/fusion-observable'; | ||
import type { Actions } from './actions'; | ||
import type { AppBundleState } from './types'; | ||
import type { AppBundleState, AppBundleStateInitial } from './types'; | ||
import type { AppModuleProvider } from '../AppModuleProvider'; | ||
export const createState = ( | ||
appKey: string, | ||
provider: AppModuleProvider | ||
value: AppBundleStateInitial, | ||
provider: AppModuleProvider, | ||
): FlowSubject<AppBundleState, Actions> => { | ||
const reducer = createReducer(appKey); | ||
const reducer = createReducer(value); | ||
const state = new FlowSubject<AppBundleState, Actions>(reducer); | ||
@@ -18,0 +18,0 @@ state.addFlow(handleFetchManifest(provider)); |
@@ -12,1 +12,6 @@ import type { AppConfig, AppManifest, AppModulesInstance, AppScriptModule } from '../types'; | ||
}; | ||
export type AppBundleStateInitial<TConfig = any, TModules = any> = Omit< | ||
AppBundleState<TConfig, TModules>, | ||
'status' | ||
>; |
@@ -24,2 +24,3 @@ import { | ||
import { AppConfigError, AppManifestError } from './errors'; | ||
import { AppBundleStateInitial } from 'app/types'; | ||
@@ -151,6 +152,14 @@ export class AppModuleProvider { | ||
*/ | ||
public setCurrentApp(appKey: string): void { | ||
this.#current$.next(new App(appKey, { provider: this, event: this.#event })); | ||
public setCurrentApp(appKeyOrApp: string | App): void { | ||
const app = typeof appKeyOrApp === 'string' ? this.createApp({ appKey: appKeyOrApp }) : App; | ||
this.#current$.next(app as App); | ||
} | ||
/** | ||
* This should not be used, only for legacy creation backdoor | ||
*/ | ||
public createApp(value: AppBundleStateInitial): App { | ||
return new App(value, { provider: this, event: this.#event }); | ||
} | ||
public dispose() { | ||
@@ -157,0 +166,0 @@ this.#subscription.unsubscribe(); |
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
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
231821
1784