MCPcopy
hub / github.com/tensorflow/tfjs / visor

Function visor

tfjs-vis/src/visor.ts:40–82  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

38 * @doc {heading: 'Visor & Surfaces'}
39 */
40export function visor(): Visor {
41 if (typeof document === 'undefined') {
42 throw new Error(
43 'No document defined. This library needs a browser/dom to work');
44 }
45
46 if (document.getElementById(VISOR_CONTAINER_ID) && visorSingleton != null) {
47 return visorSingleton;
48 }
49
50 // Create the container
51 let visorEl = document.getElementById(VISOR_CONTAINER_ID);
52
53 if (visorEl == null) {
54 visorEl = document.createElement('div');
55 visorEl.id = VISOR_CONTAINER_ID;
56 document.body.appendChild(visorEl);
57 }
58
59 let renderRoot: Element;
60 function renderVisor(
61 domNode: HTMLElement,
62 surfaceList: Map<string, SurfaceInfoStrict>): VisorComponent {
63 let visorInstance: VisorComponent = null;
64 renderRoot = VisorComponent.render(domNode, renderRoot, {
65 ref: (r: VisorComponent) => visorInstance = r,
66 surfaceList: Array.from(surfaceList.values()),
67 });
68 // Side effect of VisorComponent.render() is to assign visorInstance
69 return visorInstance;
70 }
71
72 // TODO: consider changing this type. Possibly lift into top level state
73 // object
74 const surfaceList: Map<string, SurfaceInfoStrict> = new Map();
75 const visorComponentInstance: VisorComponent =
76 renderVisor(visorEl, surfaceList);
77
78 visorSingleton =
79 new Visor(visorComponentInstance, visorEl, surfaceList, renderVisor);
80
81 return visorSingleton;
82}
83
84/**
85 * An instance of the visor. An instance of this class is created using the

Callers 3

getDrawAreaFunction · 0.90
visor_test.tsFile · 0.85

Calls 1

renderVisorFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…