|
| 1 | +// src/constants.ts |
| 2 | +// Constants and preset configurations for vite-plugin-component-debugger |
| 3 | + |
| 4 | +import type { Preset, TagOptions } from './types'; |
| 5 | + |
| 6 | +/** |
| 7 | + * Default Three.js/React Three Fiber elements to exclude from tagging |
| 8 | + */ |
| 9 | +export const DEFAULT_THREE_FIBER_ELEMENTS = new Set([ |
| 10 | + // Core objects |
| 11 | + 'mesh', 'group', 'scene', 'primitive', 'object3D', |
| 12 | + 'batchedMesh', 'instancedMesh', 'sprite', 'points', 'lineSegments', |
| 13 | + 'lineLoop', 'lOD', 'skinnedMesh', 'skeleton', 'bone', |
| 14 | + |
| 15 | + // Cameras |
| 16 | + 'perspectiveCamera', 'orthographicCamera', 'camera', |
| 17 | + 'cubeCamera', 'arrayCamera', |
| 18 | + |
| 19 | + // Lights |
| 20 | + 'ambientLight', 'directionalLight', 'pointLight', 'spotLight', |
| 21 | + 'hemisphereLight', 'rectAreaLight', 'lightProbe', |
| 22 | + 'ambientLightProbe', 'hemisphereLightProbe', |
| 23 | + 'spotLightShadow', 'directionalLightShadow', 'lightShadow', |
| 24 | + |
| 25 | + // Geometries |
| 26 | + 'boxGeometry', 'sphereGeometry', 'planeGeometry', 'cylinderGeometry', |
| 27 | + 'coneGeometry', 'circleGeometry', 'ringGeometry', 'torusGeometry', |
| 28 | + 'torusKnotGeometry', 'dodecahedronGeometry', 'icosahedronGeometry', |
| 29 | + 'octahedronGeometry', 'tetrahedronGeometry', 'polyhedronGeometry', |
| 30 | + 'tubeGeometry', 'shapeGeometry', 'extrudeGeometry', 'latheGeometry', |
| 31 | + 'edgesGeometry', 'wireframeGeometry', 'capsuleGeometry', |
| 32 | + |
| 33 | + // Buffer geometries |
| 34 | + 'bufferGeometry', 'instancedBufferGeometry', |
| 35 | + 'boxBufferGeometry', 'circleBufferGeometry', 'coneBufferGeometry', |
| 36 | + 'cylinderBufferGeometry', 'dodecahedronBufferGeometry', |
| 37 | + 'extrudeBufferGeometry', 'icosahedronBufferGeometry', |
| 38 | + 'latheBufferGeometry', 'octahedronBufferGeometry', |
| 39 | + 'planeBufferGeometry', 'polyhedronBufferGeometry', |
| 40 | + 'ringBufferGeometry', 'shapeBufferGeometry', |
| 41 | + 'sphereBufferGeometry', 'tetrahedronBufferGeometry', |
| 42 | + 'torusBufferGeometry', 'torusKnotBufferGeometry', |
| 43 | + 'tubeBufferGeometry', |
| 44 | + |
| 45 | + // Materials |
| 46 | + 'meshBasicMaterial', 'meshStandardMaterial', 'meshPhysicalMaterial', |
| 47 | + 'meshPhongMaterial', 'meshToonMaterial', 'meshNormalMaterial', |
| 48 | + 'meshLambertMaterial', 'meshDepthMaterial', 'meshDistanceMaterial', |
| 49 | + 'meshMatcapMaterial', 'lineDashedMaterial', 'lineBasicMaterial', |
| 50 | + 'material', 'rawShaderMaterial', 'shaderMaterial', 'shadowMaterial', |
| 51 | + 'spriteMaterial', 'pointsMaterial', |
| 52 | + |
| 53 | + // Helpers |
| 54 | + 'spotLightHelper', 'skeletonHelper', 'pointLightHelper', |
| 55 | + 'hemisphereLightHelper', 'gridHelper', 'polarGridHelper', |
| 56 | + 'directionalLightHelper', 'cameraHelper', 'boxHelper', |
| 57 | + 'box3Helper', 'planeHelper', 'arrowHelper', 'axesHelper', |
| 58 | + |
| 59 | + // Textures |
| 60 | + 'texture', 'videoTexture', 'dataTexture', 'dataTexture3D', |
| 61 | + 'compressedTexture', 'cubeTexture', 'canvasTexture', 'depthTexture', |
| 62 | + |
| 63 | + // Math |
| 64 | + 'vector2', 'vector3', 'vector4', 'euler', 'matrix3', 'matrix4', |
| 65 | + 'quaternion', 'color', 'raycaster', |
| 66 | + |
| 67 | + // Attributes |
| 68 | + 'bufferAttribute', 'float16BufferAttribute', 'float32BufferAttribute', |
| 69 | + 'float64BufferAttribute', 'int8BufferAttribute', 'int16BufferAttribute', |
| 70 | + 'int32BufferAttribute', 'uint8BufferAttribute', 'uint16BufferAttribute', |
| 71 | + 'uint32BufferAttribute', 'instancedBufferAttribute', |
| 72 | + |
| 73 | + // Other |
| 74 | + 'fog', 'fogExp2', 'shape' |
| 75 | +]); |
| 76 | + |
| 77 | +/** |
| 78 | + * Preset configurations for common use cases |
| 79 | + */ |
| 80 | +export const PRESETS: Record<Preset, Partial<TagOptions>> = { |
| 81 | + minimal: { |
| 82 | + includeAttributes: ['id'], |
| 83 | + includeProps: false, |
| 84 | + includeContent: false |
| 85 | + }, |
| 86 | + testing: { |
| 87 | + includeAttributes: ['id', 'name', 'component'], |
| 88 | + includeProps: false, |
| 89 | + includeContent: false |
| 90 | + }, |
| 91 | + debugging: { |
| 92 | + includeProps: true, |
| 93 | + includeContent: true, |
| 94 | + debug: true |
| 95 | + }, |
| 96 | + production: { |
| 97 | + includeAttributes: ['id', 'line'], |
| 98 | + transformers: { |
| 99 | + path: (p) => p.split('/').slice(-2).join('/'), // Only last 2 segments |
| 100 | + id: (id) => { |
| 101 | + const parts = id.split(':'); |
| 102 | + return parts.length > 2 ? parts.slice(-2).join(':') : id; // Only line:col |
| 103 | + } |
| 104 | + } |
| 105 | + } |
| 106 | +}; |
0 commit comments