import { getNextElement , insert , spread , SVGElements , hydrate as hydrateCore } from "./client" ; import { createSignal , createMemo , onCleanup , untrack , splitProps , Component , JSX , createRoot , sharedConfig , Accessor , enableHydration , $DEVCOMP } from "solid-js" ; export * from "./client" ; export { For , Show , Suspense , SuspenseList , Switch , Match , Index , ErrorBoundary , mergeProps } from "solid-js" ; export * from "./server-mock" ; export const isServer = false ; const SVG_NAMESPACE = "http://www.w3.org/2000/svg" ; function createElement ( tagName , isSVG = false ) { return isSVG ? document . createElementNS ( SVG_NAMESPACE , tagName ) : document . createElement ( tagName ) ; } export const hydrate = ( ... args ) => { enableHydration ( ) ; return hydrateCore ( ... args ) ; } ; description export function Portal ( props ) { const { useShadow } = props , marker = document . createTextNode ( "" ) , mount = props . mount || document . body ; function renderPortal ( ) { if ( sharedConfig . context ) { const [ s , set ] = createSignal ( false ) ; queueMicrotask ( ( ) => set ( true ) ) ; return ( ) => s ( ) && props . children ; } else return ( ) => props . children ; } if ( mount instanceof HTMLHeadElement ) { const [ clean , setClean ] = createSignal ( false ) ; const cleanup = ( ) => setClean ( true ) ; createRoot ( dispose => insert ( mount , ( ) => ( ! clean ( ) ? renderPortal ( ) ( ) : dispose ( ) ) , null ) ) ; onCleanup ( ( ) => { if ( sharedConfig . context ) queueMicrotask ( cleanup ) ; else cleanup ( ) ; } ) ; } else { const container = createElement ( props . isSVG ? "g" : "div" , props . isSVG ) , renderRoot = useShadow && container . attachShadow ? container . attachShadow ( { mode : "open" } ) : container ; Object . defineProperty ( container , "host" , { get ( ) { return marker . parentNode ; } } ) ; insert ( renderRoot , renderPortal ( ) ) ; mount . appendChild ( container ) ; ( props as any ) . ref && ( props as any ) . ref ( container ) ; onCleanup ( ( ) => mount . removeChild ( container ) ) ; } return marker ; } type DynamicProps < T > = T & { children ? : any ; component ? : Component < T > | string | keyof JSX . IntrinsicElements ; } ; description export function Dynamic < T > ( props ) { const [ p , others ] = splitProps ( props , [ "component" ] ) ; return createMemo ( ( ) => { const component = p . component as Function | string ; switch ( typeof component ) { case "function" : if ( "_DX_DEV_" ) Object . assign ( component , { [ $DEVCOMP ] : true } ) ; return untrack ( ( ) => component ( others ) ) ; case "string" : const isSvg = SVGElements . has ( component ) ; const el = sharedConfig . context ? getNextElement ( ) : createElement ( component , isSvg ) ; spread ( el , others , isSvg ) ; return el ; default : break ; } } ) ; }