/************************************************************************* * Copyright 2020 Adobe * All Rights Reserved. * * NOTICE: Adobe permits you to use, modify, and distribute this file in * accordance with the terms of the Adobe license agreement accompanying * it. If you have received this file from a source other than Adobe, * then your use, modification, or distribution of it requires the prior * written permission of Adobe. **************************************************************************/ /** * API used to integrate as solution web application with the unified shell of the Adobe Experience * Cloud. * @packageDocumentation * @preferred */ import { getEMR } from './src/Global'; import Runtime from './src/Runtime'; export type { RuntimeConfiguration } from './RuntimeConfiguration'; /** * Get the runtime object which contains all unified-shell APIs. * * ***Example:*** * * ```typescript * import React from 'react'; * import ReactDOM from 'react-dom'; * import excApp from '@adobe/exc-app'; * * export class MyComponent extends React.Component { * constructor(props) { * this.runtime = excApp(); * } * } * ``` * @returns The runtime object. */ export default function runtime(): Runtime; /** * Initializes a solution web application by invoking the bootstrap callback * once the runtime is ready. * 1. if the module is already defined, start to bootstrap * 2. otherwise define the global callback that will be called when runtime is ready. * * ***Example:*** * * ```typescript * import React from 'react'; * import {createRoot} from 'react-dom/client'; * import runtime, {init} from '@adobe/exc-app'; * * init(() => { * createRoot(document.querySelector('#main')).render(); * }); * ``` * @param bootstrap Callback used to bootstrap a solution. The runtime object is passed in as a * parameter to this callback. */ export declare function init(bootstrap: (runtime: Runtime) => void): void; export { getEMR }; export declare function isNested(): boolean; /** * Registers a callback to run when this application's window is torn down. This is the * only reliable signal available for releasing subscriptions made on shared, page-level * API modules (e.g. `user.on(...)`) - unlike relying on the browser's own `unload`/ * `pagehide` events, which aren't guaranteed to fire for an iframe that's simply removed. * * **Reliability note:** only supported for top-level applications in this release - `cb` * is guaranteed to run once this application's own window is torn down. It is NOT yet * supported for applications embedded via `nest()`: calling this from a nested application * currently always returns the no-op fallback below, the same as if the runtime weren't * available at all. Cross-origin applications are also not supported - a cross-origin * window can only ever load its own, separate module-runtime bundle (a browser security * constraint, not an implementation choice), and `cb` would be registered into that * bundle's own instance, which nothing outside it can ever reach to tear down. * * ***Example:*** * * ```typescript * useEffect(() => { * const onImsOrgChanged = (): void => { ... }; * user.on('change:imsOrg', onImsOrgChanged); * // onUnmount's own return value only unregisters the hook - it does NOT itself call the * // callback - so it must not be returned directly as this effect's cleanup, or a normal * // unmount would unregister the hook without ever calling user.off(...), leaking the * // subscription forever (the hook would no longer be there to release it later, when the * // window itself is actually torn down). * const unregisterOnUnmount = onUnmount(() => user.off('change:imsOrg', onImsOrgChanged)); * return () => { * user.off('change:imsOrg', onImsOrgChanged); * unregisterOnUnmount(); * }; * }, []); * ``` * @param cb Callback to run once, when this application's window is torn down. * @returns Unregisters cb; a no-op if it already ran or the runtime isn't available. */ export declare function onUnmount(cb: () => void): () => void; export type { Runtime };