/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.dev/license */ /** * A type-safe key to use with `TransferState`. * * Example: * * ```ts * const COUNTER_KEY = makeStateKey('counter'); * let value = 10; * * transferState.set(COUNTER_KEY, value); * ``` * * @publicApi */ export type StateKey = string & { __not_a_string: never; __value_type?: T; }; /** * Create a `StateKey` that can be used to store value of type T with `TransferState`. * * Example: * * ```ts * const COUNTER_KEY = makeStateKey('counter'); * let value = 10; * * transferState.set(COUNTER_KEY, value); * ``` * * @publicApi */ export declare function makeStateKey(key: string): StateKey; /** * A key value store that is transferred from the application on the server side to the application * on the client side. * * The `TransferState` is available as an injectable token. * On the client, just inject this token using DI and use it, it will be lazily initialized. * On the server it's already included if `renderApplication` function is used. Otherwise, import * the `ServerTransferStateModule` module to make the `TransferState` available. * * The values in the store are serialized/deserialized using JSON.stringify/JSON.parse. So only * boolean, number, string, null and non-class objects will be serialized and deserialized in a * non-lossy manner. * * @publicApi */ export declare class TransferState { /** @nocollapse */ static ɵprov: import("./di/interface/defs").ɵɵInjectableDeclaration; private onSerializeCallbacks; /** * Get the value corresponding to a key. Return `defaultValue` if key is not found. */ get(key: StateKey, defaultValue: T): T; /** * Set the value corresponding to a key. */ set(key: StateKey, value: T): void; /** * Remove a key from the store. */ remove(key: StateKey): void; /** * Test whether a key exists in the store. */ hasKey(key: StateKey): boolean; /** * Indicates whether the state is empty. */ get isEmpty(): boolean; /** * Register a callback to provide the value for a key when `toJson` is called. */ onSerialize(key: StateKey, callback: () => T): void; /** * Serialize the current state of the store to JSON. */ toJson(): string; } export declare function retrieveTransferredState(doc: Document, appId: string): Record;