Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | 'use client' import { useState } from 'react' import { css } from '../../../../styled-system/css' import { addOpenCVScript } from '@/lib/vision/opencv/addScript' import { checkWindowCv } from '@/lib/vision/opencv/checkCv' /** * Test just adding script tag - no waiting. */ export default function LoaderTestScriptPage() { const [added, setAdded] = useState(false) const [cvStatus, setCvStatus] = useState<{ exists: boolean hasImread: boolean } | null>(null) const handleAddScript = () => { console.log('[LoaderTestScript] Add Script clicked') const result = addOpenCVScript() console.log('[LoaderTestScript] addOpenCVScript returned:', result) setAdded(result) } const handleCheckCv = () => { console.log('[LoaderTestScript] Check CV clicked') const result = checkWindowCv() console.log('[LoaderTestScript] checkWindowCv returned:', result) setCvStatus(result) } return ( <div data-component="loader-test-script-page" className={css({ minHeight: '100vh', bg: 'gray.900', color: 'gray.100', p: 8, display: 'flex', flexDirection: 'column', alignItems: 'center', justifyContent: 'center', gap: 4, })} > <h1 className={css({ fontSize: '2xl', fontWeight: 'bold' })}>Script Tag Test (No Waiting)</h1> <p className={css({ color: 'gray.400', mb: 4 })}> Step 1: Add script tag. Step 2: Check if cv loaded. </p> <div className={css({ display: 'flex', gap: 4 })}> <button type="button" onClick={handleAddScript} className={css({ px: 6, py: 3, bg: 'emerald.600', color: 'white', borderRadius: 'lg', fontSize: 'lg', fontWeight: 'bold', border: 'none', cursor: 'pointer', _hover: { bg: 'emerald.500' }, })} > 1. Add Script Tag </button> <button type="button" onClick={handleCheckCv} className={css({ px: 6, py: 3, bg: 'sky.600', color: 'white', borderRadius: 'lg', fontSize: 'lg', fontWeight: 'bold', border: 'none', cursor: 'pointer', _hover: { bg: 'sky.500' }, })} > 2. Check window.cv </button> </div> <div className={css({ mt: 4, textAlign: 'center' })}> <div>Script added: {added ? 'yes' : 'no'}</div> {cvStatus && ( <> <div>cv exists: {cvStatus.exists ? 'yes' : 'no'}</div> <div>cv.imread exists: {cvStatus.hasImread ? 'yes' : 'no'}</div> </> )} </div> </div> ) } |