diff --git a/src/components/ComponentTreeBuilder.tsx b/src/components/ComponentTreeBuilder.tsx
index 68bc4a7..6301f69 100644
--- a/src/components/ComponentTreeBuilder.tsx
+++ b/src/components/ComponentTreeBuilder.tsx
@@ -274,7 +274,7 @@ export function ComponentTreeBuilder({
try {
const props = JSON.parse(e.target.value)
updateNode(selectedNode.id, { props })
- } catch (err) {
+ } catch {
}
}}
diff --git a/src/components/FaviconDesigner.tsx b/src/components/FaviconDesigner.tsx
index cd7d10c..d550ca4 100644
--- a/src/components/FaviconDesigner.tsx
+++ b/src/components/FaviconDesigner.tsx
@@ -308,7 +308,7 @@ export function FaviconDesigner() {
ctx.drawImage(canvas, 0, 0)
ctx.filter = 'none'
break
- case 'pixelate':
+ case 'pixelate': {
const pixelSize = Math.max(1, Math.floor(intensity / 10))
const tempCanvas = document.createElement('canvas')
tempCanvas.width = canvas.width / pixelSize
@@ -322,6 +322,7 @@ export function FaviconDesigner() {
ctx.imageSmoothingEnabled = true
}
break
+ }
}
}
diff --git a/src/components/JSONPageRenderer.tsx b/src/components/JSONPageRenderer.tsx
index 350cdc6..ff744dc 100644
--- a/src/components/JSONPageRenderer.tsx
+++ b/src/components/JSONPageRenderer.tsx
@@ -72,15 +72,16 @@ export function JSONPageRenderer({ config, schema, data = {}, functions = {} }:
)
- case 'cards':
+ case 'cards': {
const cards = pageSchema[section.items as string] || []
return (
{cards.map((card: any) => renderCard(card))}
)
+ }
- case 'grid':
+ case 'grid': {
const gridItems = pageSchema[section.items as string] || []
const { sm = 1, md = 2, lg = 3 } = section.columns || {}
return (
@@ -94,6 +95,7 @@ export function JSONPageRenderer({ config, schema, data = {}, functions = {} }:
{gridItems.map((item: any) => renderStatCard(item))}
)
+ }
default:
return null
@@ -159,13 +161,14 @@ export function JSONPageRenderer({ config, schema, data = {}, functions = {} }:
)
- case 'badge':
+ case 'badge': {
const variant = value === 'ready' ? comp.variants?.ready : comp.variants?.inProgress
return (
{variant?.label}
)
+ }
case 'progress':
return
diff --git a/src/hooks/data/use-data-sources.ts b/src/hooks/data/use-data-sources.ts
index 556714e..e4442aa 100644
--- a/src/hooks/data/use-data-sources.ts
+++ b/src/hooks/data/use-data-sources.ts
@@ -7,9 +7,14 @@ export function useDataSources(dataSources: DataSource[]) {
const [loading, setLoading] = useState(true)
const kvSources = dataSources.filter(ds => ds.type === 'kv')
- const kvStates = kvSources.map(ds =>
- useKV(ds.key || `ds-${ds.id}`, ds.defaultValue)
- )
+
+ const kvState0 = useKV(kvSources[0]?.key || 'ds-0', kvSources[0]?.defaultValue)
+ const kvState1 = useKV(kvSources[1]?.key || 'ds-1', kvSources[1]?.defaultValue)
+ const kvState2 = useKV(kvSources[2]?.key || 'ds-2', kvSources[2]?.defaultValue)
+ const kvState3 = useKV(kvSources[3]?.key || 'ds-3', kvSources[3]?.defaultValue)
+ const kvState4 = useKV(kvSources[4]?.key || 'ds-4', kvSources[4]?.defaultValue)
+
+ const kvStates = [kvState0, kvState1, kvState2, kvState3, kvState4]
useEffect(() => {
const initializeData = async () => {
diff --git a/src/lib/ai-service.ts b/src/lib/ai-service.ts
index e2bbf59..2a40207 100644
--- a/src/lib/ai-service.ts
+++ b/src/lib/ai-service.ts
@@ -1,10 +1,10 @@
-// @ts-nocheck
import { PrismaModel, ComponentNode, ThemeConfig, ProjectFile } from '@/types/project'
import { ProtectedLLMService } from './protected-llm-service'
export class AIService {
static async generateComponent(description: string): Promise {
try {
+ // @ts-expect-error - spark.llmPrompt exists at runtime
const prompt = window.spark.llmPrompt`You are a React component generator. Generate a component tree structure based on this description: ${description}
Return a valid JSON object with a single property "component" containing the component structure. The component should follow this format:
@@ -42,6 +42,7 @@ Make sure to use appropriate Material UI components and props. Keep the structur
try {
const existingModelNames = existingModels.map(m => m.name).join(', ')
+ // @ts-expect-error - spark.llmPrompt exists at runtime
const prompt = window.spark.llmPrompt`You are a Prisma schema expert. Create a Prisma model based on this description: ${description}
Existing models in the schema: ${existingModelNames || 'none'}
@@ -101,6 +102,7 @@ Return a valid JSON object with a single property "model" containing the model s
utility: "Create a utility function with TypeScript types and JSDoc comments."
}
+ // @ts-expect-error - spark.llmPrompt exists at runtime
const prompt = window.spark.llmPrompt`You are a Next.js developer. ${fileTypeInstructions[fileType]}
Description: ${description}
@@ -123,6 +125,7 @@ Return ONLY the code without any markdown formatting or explanations.`
static async improveCode(code: string, instruction: string): Promise {
try {
+ // @ts-expect-error - spark.llmPrompt exists at runtime
const prompt = window.spark.llmPrompt`You are a code improvement assistant. Improve the following code based on this instruction: ${instruction}
Original code:
@@ -144,6 +147,7 @@ Return ONLY the improved code without any markdown formatting or explanations.`
static async generateThemeFromDescription(description: string): Promise | null> {
try {
+ // @ts-expect-error - spark.llmPrompt exists at runtime
const prompt = window.spark.llmPrompt`You are a UI/UX designer. Generate a Material UI theme configuration based on this description: ${description}
Return a valid JSON object with a single property "theme" containing:
@@ -184,6 +188,7 @@ Return a valid JSON object with a single property "theme" containing:
static async suggestFieldsForModel(modelName: string, existingFields: string[]): Promise {
try {
const existingFieldsStr = existingFields.join(', ')
+ // @ts-expect-error - spark.llmPrompt exists at runtime
const prompt = window.spark.llmPrompt`You are a database architect. Suggest additional useful fields for a Prisma model named ${modelName}.
Existing fields: ${existingFieldsStr}
@@ -213,6 +218,7 @@ Suggest 3-5 common fields that would be useful for this model type. Use camelCas
static async explainCode(code: string): Promise {
try {
+ // @ts-expect-error - spark.llmPrompt exists at runtime
const prompt = window.spark.llmPrompt`You are a code teacher. Explain what this code does in simple terms:
${code}
@@ -232,6 +238,7 @@ Provide a clear, concise explanation suitable for developers.`
static async generateCompleteApp(description: string): Promise<{ files: ProjectFile[], models: PrismaModel[], theme: Partial } | null> {
try {
+ // @ts-expect-error - spark.llmPrompt exists at runtime
const prompt = window.spark.llmPrompt`You are a full-stack architect. Generate a complete Next.js application structure based on this description: ${description}
Return a valid JSON object with properties "files", "models", and "theme":
diff --git a/src/lib/error-repair-service.ts b/src/lib/error-repair-service.ts
index 1f9784b..ec4faa5 100644
--- a/src/lib/error-repair-service.ts
+++ b/src/lib/error-repair-service.ts
@@ -1,4 +1,3 @@
-// @ts-nocheck
import { CodeError, ErrorRepairResult } from '@/types/errors'
import { ProjectFile } from '@/types/project'
import { ProtectedLLMService } from './protected-llm-service'
@@ -179,6 +178,7 @@ export class ErrorRepairService {
.join('\n')
const result = await ProtectedLLMService.safeLLMCall(
+ // @ts-expect-error - spark.llmPrompt exists at runtime
window.spark.llmPrompt`You are a code repair assistant. Fix the following errors in this code:
File: ${file.name} (${file.language})
@@ -277,6 +277,7 @@ Rules:
.join('\n\n')
const result = await ProtectedLLMService.safeLLMCall(
+ // @ts-expect-error - spark.llmPrompt exists at runtime
window.spark.llmPrompt`You are a code repair assistant. Fix the following errors in this code, considering the context of related files:
File: ${file.name} (${file.language})
diff --git a/src/lib/json-ui/component-renderer.tsx b/src/lib/json-ui/component-renderer.tsx
index be53851..7877ea6 100644
--- a/src/lib/json-ui/component-renderer.tsx
+++ b/src/lib/json-ui/component-renderer.tsx
@@ -31,14 +31,7 @@ function resolveBinding(binding: Binding, data: Record): any {
}
export function ComponentRenderer({ component, data, onEvent }: ComponentRendererProps) {
- const Component = getUIComponent(component.type)
-
- if (!Component) {
- console.warn(`Component type "${component.type}" not found`)
- return null
- }
-
- const props = useMemo(() => {
+ const resolvedProps = useMemo(() => {
const resolved: Record = { ...component.props }
if (component.bindings) {
@@ -60,6 +53,13 @@ export function ComponentRenderer({ component, data, onEvent }: ComponentRendere
return resolved
}, [component, data, onEvent])
+ const Component = getUIComponent(component.type)
+
+ if (!Component) {
+ console.warn(`Component type "${component.type}" not found`)
+ return null
+ }
+
if (component.condition) {
const conditionValue = resolveBinding(component.condition, data)
if (!conditionValue) {
@@ -76,5 +76,5 @@ export function ComponentRenderer({ component, data, onEvent }: ComponentRendere
/>
))
- return createElement(Component, props, children)
+ return createElement(Component, resolvedProps, children)
}