Extract the monolithic SDK context provider into seven focused modules: - context-types.ts (203 LOC): SDKContextValue interface, initialState, ExtendedSDKAction - context-reducer.ts (353 LOC): sdkReducer with all action handlers - context-provider.tsx (495 LOC): SDKProvider component + SDKContext - context-hooks.ts (17 LOC): useSDK hook - context-validators.ts (94 LOC): local checkpoint validation logic - context-projects.ts (67 LOC): project management API helpers - context-sync-helpers.ts (145 LOC): sync infrastructure init/cleanup/callbacks - context.tsx (23 LOC): barrel re-export preserving existing import paths All files under the 500-line hard cap. Build verified with `npx next build`. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
18 lines
507 B
TypeScript
18 lines
507 B
TypeScript
'use client'
|
|
|
|
import { useContext } from 'react'
|
|
import { SDKContextValue } from './context-types'
|
|
import { SDKContext } from './context-provider'
|
|
|
|
// =============================================================================
|
|
// HOOK
|
|
// =============================================================================
|
|
|
|
export function useSDK(): SDKContextValue {
|
|
const context = useContext(SDKContext)
|
|
if (!context) {
|
|
throw new Error('useSDK must be used within SDKProvider')
|
|
}
|
|
return context
|
|
}
|