import { last } from "lodash" ; import * as dom from "../dom" ; import { AdaptMountedElement , BuildHelpers } from "../jsx" ; export interface BuildContext { element : AdaptMountedElement ; options : dom . BuildOptionsInternal ; helpers : BuildHelpers ; } export type StateInfo = Map < AdaptMountedElement , number > ; export interface HookInfo { stateInfo : StateInfo ; } export function createHookInfo ( ) { return { stateInfo : new Map < AdaptMountedElement , number > ( ) , } ; } const buildContext = [ ] ; export function startHooks ( context ) { buildContext . push ( context ) ; } export function finishHooks ( ) { buildContext . pop ( ) ; } export function currentContext ( ) { const ctx = last ( buildContext ) ; if ( ctx == null ) throw new Error ( `Hook functions can only be called from an SFC` ) ; return ctx ; }