import { DEFAULT_FRAG_CHUNK , DEFAULT_VERT_CHUNK , FRAG , VERT } from './constants' ; import { ProxyProps , ProxyComponent } from './types/internal' ; import { fragmentChunks , vertexChunks , commonChunks } from './generated' ; function NullFunction ( ) { return null ; } type ShaderProxyHelper < T extends string > = { [ key in T ] : any ; } & { Body : ProxyComponent ; Head : ProxyComponent ; } ; const vertHandler = { get : function ( _ , name ) { const Component = function < Child extends string [ ] | string > ( { children } ) { return children ; } ; Object . defineProperty ( Component , 'chunkName' , { writable : true } ) ; Object . defineProperty ( Component , 'shaderType' , { writable : true } ) ; Component . chunkName = name === 'Body' ? DEFAULT_VERT_CHUNK : name ; Component . shaderType = VERT ; return Component ; } } ; export const vert = new Proxy ( NullFunction , vertHandler ) ; const fragHandler = { get : function ( _ , name ) { const Component = function < Child extends string [ ] | string > ( { children } ) { return children ; } ; Object . defineProperty ( Component , 'chunkName' , { writable : true } ) ; Object . defineProperty ( Component , 'shaderType' , { writable : true } ) ; Component . chunkName = name === 'Body' ? DEFAULT_FRAG_CHUNK : name ; Component . shaderType = FRAG ; return Component ; } } ; export const frag = new Proxy ( NullFunction , fragHandler ) ; export function common < Child extends string [ ] | string > ( { children } ) { return ( children as unknown ) as JSX . Element ; }