@fluid-topics/ft-app-context 1.1.82 → 1.1.83

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,6 @@
1
1
  import { FtReduxStore, Optional } from "@fluid-topics/ft-wc-utils";
2
2
  import { FtMetadataConfiguration, FtSession, FtUiLocale } from "@fluid-topics/public-api";
3
+ import { PayloadAction } from "@reduxjs/toolkit";
3
4
  export declare const FtAppInfoStoreName = "ft-app-info";
4
5
  export interface FtAppInfoState {
5
6
  baseUrl: Optional<string>;
@@ -15,7 +16,12 @@ export interface FtAppInfoState {
15
16
  navigatorOnline: boolean;
16
17
  forcedOffline: boolean;
17
18
  }
18
- declare const reducers: {};
19
+ export declare class AuthenticationChangeEvent extends CustomEvent<Optional<FtSession>> {
20
+ constructor(session: Optional<FtSession>);
21
+ }
22
+ declare const reducers: {
23
+ session: (state: FtAppInfoState, action: PayloadAction<Optional<FtSession>>) => void;
24
+ };
19
25
  export type FtAppInfoStateReducers = typeof reducers;
20
26
  export type FtAppInfoStore = FtReduxStore<FtAppInfoState, FtAppInfoStateReducers>;
21
27
  export declare const ftAppInfoStore: FtAppInfoStore;
@@ -1,6 +1,18 @@
1
- import { FtReduxStore } from "@fluid-topics/ft-wc-utils";
1
+ import { deepEqual, FtReduxStore } from "@fluid-topics/ft-wc-utils";
2
2
  export const FtAppInfoStoreName = "ft-app-info";
3
- const reducers = {};
3
+ export class AuthenticationChangeEvent extends CustomEvent {
4
+ constructor(session) {
5
+ super("authentication-change", { detail: session });
6
+ }
7
+ }
8
+ const reducers = {
9
+ session: (state, action) => {
10
+ if (!deepEqual(state.session, action.payload)) {
11
+ state.session = action.payload;
12
+ setTimeout(() => ftAppInfoStore.eventBus.dispatchEvent(new AuthenticationChangeEvent(action.payload)), 0);
13
+ }
14
+ }
15
+ };
4
16
  export const ftAppInfoStore = FtReduxStore.get({
5
17
  name: FtAppInfoStoreName,
6
18
  reducers: reducers,
@@ -16,6 +16,10 @@ export declare class FtI18nServiceInternalClass extends FtServiceWithCache {
16
16
  constructor(messageContextProvider: (locale: string, name: string) => Promise<FtMessageContext>);
17
17
  [clearAfterUnitTest]: () => void;
18
18
  private clearWhenUiLocaleChanges;
19
+ /**
20
+ * ⚠️ Only use in GWT or unit test contexts
21
+ * @param context
22
+ */
19
23
  addContext(context: FtMessageContext): void;
20
24
  getAllContexts(): Array<FtMessageContext>;
21
25
  prepareContext(name: string, defaultMessages: Record<string, string>): Promise<void>;
@@ -26,6 +26,10 @@ export class FtI18nServiceInternalClass extends FtServiceWithCache {
26
26
  this.notifyAll();
27
27
  }
28
28
  }
29
+ /**
30
+ * ⚠️ Only use in GWT or unit test contexts
31
+ * @param context
32
+ */
29
33
  addContext(context) {
30
34
  const name = context.name.toLowerCase();
31
35
  this.cache.setFinal(name, context);
@@ -1,11 +1,11 @@
1
1
  import { CacheRegistry } from "@fluid-topics/ft-wc-utils";
2
- import { FluidTopicsApi } from "@fluid-topics/public-api";
2
+ import type { FluidTopicsApi } from "@fluid-topics/public-api";
3
3
  export declare class FtServiceWithCache {
4
4
  private overrideApi?;
5
5
  static commonCache: CacheRegistry;
6
6
  cache: CacheRegistry;
7
7
  constructor(withCommonCache?: boolean, overrideApi?: FluidTopicsApi | undefined);
8
8
  protected get api(): FluidTopicsApi;
9
- protected get awaitApi(): FluidTopicsApi | Promise<FluidTopicsApi>;
9
+ protected get awaitApi(): Promise<FluidTopicsApi>;
10
10
  clearCache(): void;
11
11
  }
@@ -14,8 +14,7 @@ export class FtServiceWithCache {
14
14
  return (_a = this.overrideApi) !== null && _a !== void 0 ? _a : FluidTopicsApiProvider.get();
15
15
  }
16
16
  get awaitApi() {
17
- var _a;
18
- return (_a = this.overrideApi) !== null && _a !== void 0 ? _a : FluidTopicsApiProvider.await();
17
+ return this.overrideApi ? Promise.resolve(this.overrideApi) : FluidTopicsApiProvider.await();
19
18
  }
20
19
  clearCache() {
21
20
  this.cache.clearAll();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluid-topics/ft-app-context",
3
- "version": "1.1.82",
3
+ "version": "1.1.83",
4
4
  "description": "Global application context for Fluid Topics integrations",
5
5
  "keywords": [
6
6
  "Lit"
@@ -19,11 +19,11 @@
19
19
  "url": "ssh://git@scm.mrs.antidot.net:2222/fluidtopics/ft-web-components.git"
20
20
  },
21
21
  "dependencies": {
22
- "@fluid-topics/ft-wc-utils": "1.1.82",
22
+ "@fluid-topics/ft-wc-utils": "1.1.83",
23
23
  "lit": "3.1.0"
24
24
  },
25
25
  "devDependencies": {
26
26
  "@fluid-topics/public-api": "1.0.71"
27
27
  },
28
- "gitHead": "2fd30a90406265aa7cc0714cafe53090343c0086"
28
+ "gitHead": "2ca7449aa6df93b0b6ba0794e695aa3f605f38bf"
29
29
  }