@jtl-software/cloud-apps-core 0.0.0-dev.fd3fa36 → 0.0.0-dev.fdea84c

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,7 +1,17 @@
1
1
  import { AppBridgeEventCapability, AppBridgeMethodCapability } from './capabilities';
2
2
  import { AppBridgeInfrastructure, AppBridgeMessagePort } from './core';
3
+ /** The app-scoped panel token the host mints and pushes; the payload of `getAppToken`/`appTokenChanged`. */
4
+ export type AppToken = {
5
+ accessToken: string;
6
+ refreshToken?: string;
7
+ expiresIn: number;
8
+ };
3
9
  export default class AppBridge extends AppBridgeInfrastructure {
4
10
  readonly method: AppBridgeMethodCapability;
5
11
  readonly event: AppBridgeEventCapability;
12
+ private cachedAppToken;
13
+ private readonly disposers;
6
14
  constructor(appBridgeMessagePort: AppBridgeMessagePort);
15
+ /** Removes the panel-token cache subscription and wake listeners. Call when tearing the bridge down. */
16
+ dispose(): void;
7
17
  }
@@ -0,0 +1 @@
1
+ export {};
@@ -1,7 +1,15 @@
1
1
  import { Disposer, AppBridgeCapability, AppBridgeMessagePort } from '../../core';
2
2
  export default class AppBridgeMethodCapability extends AppBridgeCapability<'method'> {
3
3
  private readonly _exposedMethods;
4
+ private readonly _localResponders;
4
5
  constructor(appBridgeMessagePort: AppBridgeMessagePort);
6
+ /**
7
+ * Answer a `call(methodName, ...)` locally instead of sending it to the other side, when the
8
+ * handler returns a defined value; a returned `undefined` falls through to the remote method.
9
+ * Lets the bridge serve a locally cached result (e.g. a pushed panel token) without a round-trip,
10
+ * transparently to the caller. Returns a disposer that removes the responder.
11
+ */
12
+ respondLocally<TMethod>(methodName: string, handler: TMethod): Disposer;
5
13
  expose<TMethod>(methodName: string, method: TMethod): Disposer;
6
14
  removeExposedMethod(methodName: string): void;
7
15
  isExposed(methodName: string): boolean;