This repository has been archived by the owner on Feb 17, 2024. It is now read-only.
forked from pxwise/universal-passthrough
-
Notifications
You must be signed in to change notification settings - Fork 1
/
passthrough-registry.server.ts
53 lines (47 loc) · 1.75 KB
/
passthrough-registry.server.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/**
* UniversalPassthrough
*/
/**
* PassthroughRegistry class definition.
*/
export class PassthroughRegistry {
private browserElements: any = {};
private serverElements: any = {};
public isRegistered(id: string): boolean { return true; }
public registerElement(id: string, el: HTMLElement): HTMLElement|any { }
public complete(): void { }
public detach(id: string, el: HTMLElement): void { }
public reattach(id: string, el: HTMLElement): void { }
private replaceBrowserElements(): void { }
}
/**
* PassthroughRegistryFactory function.
*/
export function PassthroughRegistryFactory() {
// @todo dyamically assemble passthrough element ids
let browserElements = {};
let serverElements = {};
let replaceBrowserElements = (): void => {};
return {
// isRegistered(id: string): boolean => { return true; },
// registerElement(id: string, el: HTMLElement): HTMLElement|any => { },
// complete(): void => { },
// detach(id: string, el: HTMLElement): void => { },
// reattach(id: string, el: HTMLElement): void => { }
// replaceBrowserElements(): void { }
isRegistered: (id: string): boolean => true,
// original does not grab correct el
// registerElement: (id: any, el: any): any => { console.log('registerElements'); return serverElements[id] = el},
registerElement: (id: string, el: HTMLElement): HTMLElement|any => serverElements[id] = '',
complete(): void { },
detach: (id: string, el: HTMLElement): void => { },
reattach: (id: string, el: HTMLElement): void => { }
};
}
/**
* passthrough facade function to execute in client.ts.
*/
export function passthrough(moduleRef: any): void {
const passthroughRegistry = moduleRef.injector.get(PassthroughRegistry)
passthroughRegistry.complete();
}