UNPKG

2.73 kBTypeScriptView Raw
1/**
2 * @license
3 * Copyright Google LLC All Rights Reserved.
4 *
5 * Use of this source code is governed by an MIT-style license that can be
6 * found in the LICENSE file at https://angular.io/license
7 */
8import { NodeContext, PrebootAppData, PrebootData, PrebootEvent, PrebootWindow } from '../common/preboot.interfaces';
9export declare function _window(): PrebootWindow;
10export declare class EventReplayer {
11 clientNodeCache: {
12 [key: string]: Element;
13 };
14 replayStarted: boolean;
15 win: PrebootWindow;
16 /**
17 * Window setting and getter to facilitate testing of window
18 * in non-browser environments
19 */
20 setWindow(win: PrebootWindow): void;
21 /**
22 * Window setting and getter to facilitate testing of window
23 * in non-browser environments
24 */
25 getWindow(): PrebootWindow;
26 /**
27 * Replay all events for all apps. this can only be run once.
28 * if called multiple times, will only do something once
29 */
30 replayAll(): void;
31 /**
32 * Replay all events for one app (most of the time there is just one app)
33 * @param appData
34 */
35 replayForApp(appData: PrebootAppData): void;
36 /**
37 * Replay one particular event
38 * @param appData
39 * @param prebootEvent
40 */
41 replayEvent(appData: PrebootAppData, prebootEvent: PrebootEvent): void;
42 /**
43 * Switch the buffer for one particular app (i.e. display the client
44 * view and destroy the server view)
45 * @param appData
46 */
47 switchBuffer(appData: PrebootAppData): void;
48 /**
49 * Finally, set focus, remove all the event listeners and remove
50 * any freeze screen that may be there
51 * @param prebootData
52 */
53 cleanup(prebootData: PrebootData): void;
54 setFocus(activeNode: NodeContext): void;
55 /**
56 * Given a node from the server rendered view, find the equivalent
57 * node in the client rendered view. We do this by the following approach:
58 * 1. take the name of the server node tag (ex. div or h1 or input)
59 * 2. add either id (ex. div#myid) or class names (ex. div.class1.class2)
60 * 3. use that value as a selector to get all the matching client nodes
61 * 4. loop through all client nodes found and for each generate a key value
62 * 5. compare the client key to the server key; once there is a match,
63 * we have our client node
64 *
65 * NOTE: this only works when the client view is almost exactly the same as
66 * the server view. we will need an improvement here in the future to account
67 * for situations where the client view is different in structure from the
68 * server view
69 */
70 findClientNode(serverNodeContext: NodeContext): HTMLElement | null;
71}