Files
soroban-abacus-flashcards/apps/web/next.config.js
Thomas Hallock 5f4f1fde33 feat(practice): add document scanning with multi-quad tracking
Adds real-time document detection to the camera capture on session
summary pages. Uses OpenCV.js for edge detection and perspective
correction.

Key features:
- Multi-quad tracking: detects ALL quadrilaterals, not just largest
- Scores quads by stability over time (filters transient detections)
- Visual feedback: yellow (detecting) → green (stable) → bright green (locked)
- Auto-crops and deskews captured documents
- Falls back to raw photo if no document detected

Technical details:
- OpenCV.js (~8MB) lazy-loaded only when camera opens
- Tracks quads across frames by matching corner positions
- Filters by area (15-95% of frame) and document aspect ratios
- Locks on after 5 frames with 50%+ stability

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-31 11:57:50 -06:00

80 lines
2.1 KiB
JavaScript

const createNextIntlPlugin = require('next-intl/plugin')
const withNextIntl = createNextIntlPlugin('./src/i18n/request.ts')
/** @type {import('next').NextConfig} */
const nextConfig = {
// Enable source maps in production for easier debugging
productionBrowserSourceMaps: true,
eslint: {
ignoreDuringBuilds: true,
},
typescript: {
ignoreBuildErrors: true,
},
experimental: {
optimizePackageImports: ['@soroban/core', '@soroban/client'],
serverComponentsExternalPackages: ['@myriaddreamin/typst.ts'],
},
transpilePackages: ['@soroban/core', '@soroban/client', '@svg-maps/world', '@svg-maps/usa'],
webpack: (config, { isServer }) => {
config.experiments = {
...config.experiments,
asyncWebAssembly: true,
layers: true,
}
// Exclude native Node.js modules from client bundle
// canvas is a jscanify dependency only needed for Node.js, not browser
if (!isServer) {
config.externals = [...(config.externals || []), 'canvas']
}
// Optimize WASM loading
if (!isServer) {
// Enable dynamic imports for better code splitting
config.optimization = {
...config.optimization,
splitChunks: {
...config.optimization.splitChunks,
cacheGroups: {
...config.optimization.splitChunks?.cacheGroups,
// Create separate chunk for WASM modules
wasm: {
test: /\.wasm$/,
name: 'wasm',
chunks: 'async',
enforce: true,
},
// Separate typst.ts into its own chunk
typst: {
test: /[\\/]node_modules[\\/]@myriaddreamin[\\/]typst.*[\\/]/,
name: 'typst',
chunks: 'async',
enforce: true,
},
},
},
}
// Add preload hints for critical WASM files
config.resolve.fallback = {
...config.resolve.fallback,
fs: false,
path: false,
}
}
// Fix for WASM modules
config.module.rules.push({
test: /\.wasm$/,
type: 'asset/resource',
})
return config
},
}
module.exports = withNextIntl(nextConfig)