-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfix-app.cjs
More file actions
67 lines (58 loc) · 3.89 KB
/
Copy pathfix-app.cjs
File metadata and controls
67 lines (58 loc) · 3.89 KB
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
const fs = require('fs')
let code = fs.readFileSync('src/App.tsx', 'utf-8')
// Fix 1: Remove the StatusMatrix import that was missed
code = code.replace(`import { StatusMatrix } from '@/components/StatusMatrix'\n`, '')
// Fix 2: Remove dead RuntimeKind type (was removed from types)
code = code.replace(
`const resolveRuntime = (path: string, engine: DbEngine): RuntimeKind | null => {`,
`const resolveRuntime = (path: string, engine: DbEngine): string | null => {`
)
// Fix 3: Remove dead busy state
code = code.replace(` const [busy, setBusy] = useState(false)\n`, '')
code = code.replace(` const [busy, setBusy] = useState(false)\r\n`, '')
// Fix 4: Remove the dangling setRuntimeStatus call in the init useEffect
code = code.replace(
` setRuntimeStatus(\n 'desktop',\n adapter.kind === 'electron' ? 'ready' : 'partial',\n adapter.kind === 'electron'\n ? 'Electron filesystem bridge detected and active.'\n : 'Browser build active. Electron main/preload are scaffolded for packaging.',\n )`,
` // runtime status: desktop adapter detected`
)
code = code.replace(
` setRuntimeStatus(\r\n 'desktop',\r\n adapter.kind === 'electron' ? 'ready' : 'partial',\r\n adapter.kind === 'electron'\r\n ? 'Electron filesystem bridge detected and active.'\r\n : 'Browser build active. Electron main/preload are scaffolded for packaging.',\r\n )`,
` // runtime status: desktop adapter detected`
)
// Fix 5: Remove offline/service worker setRuntimeStatus calls
code = code.replace(
` setRuntimeStatus('offline', 'loading', 'Registering service worker and runtime caches.')\n void navigator.serviceWorker.register('/sw.js').then(\n () => {\n setRuntimeStatus('offline', 'ready', 'App shell caching is active for offline-after-load demos.')\n },\n () => {\n setRuntimeStatus('offline', 'partial', 'Service worker registration failed; network caching is best-effort.')\n },\n )`,
` // Service worker registration (no status tracking needed)`
)
code = code.replace(
` setRuntimeStatus('offline', 'loading', 'Registering service worker and runtime caches.')\r\n void navigator.serviceWorker.register('/sw.js').then(\r\n () => {\r\n setRuntimeStatus('offline', 'ready', 'App shell caching is active for offline-after-load demos.')\r\n },\r\n () => {\r\n setRuntimeStatus('offline', 'partial', 'Service worker registration failed; network caching is best-effort.')\r\n },\r\n )`,
` // Service worker registration (no status tracking needed)`
)
// Fix 6: Remove dead worker terminate refs
const deadRefs = [
` jsWorkerRef.current?.terminate()\r\n`,
` pythonWorkerRef.current?.terminate()\r\n`,
` sqliteWorkerRef.current?.terminate()\r\n`,
` postgresWorkerRef.current?.terminate()\r\n`,
` emceptionRef.current?.terminate()\r\n`,
` jsWorkerRef.current?.terminate()\n`,
` pythonWorkerRef.current?.terminate()\n`,
` sqliteWorkerRef.current?.terminate()\n`,
` postgresWorkerRef.current?.terminate()\n`,
` emceptionRef.current?.terminate()\n`,
]
for (const ref of deadRefs) {
code = code.split(ref).join('')
}
// Fix 7: Fix LinuxPanel onStatus prop — replace setRuntimeStatus with no-op
code = code.replace(
`onStatus={(status, detail) => setRuntimeStatus('linux', status, detail)}`,
`onStatus={() => {}}`
)
// Fix 8: Make sure 'import { executionRouter, type RuntimeState }' line has correct type import
code = code.replace(
`import { executionRouter, type RuntimeState } from '@/core/executionRouter'`,
`import { executionRouter } from '@/core/executionRouter'\nimport type { RuntimeState } from '@/core/executionRouter'`
)
fs.writeFileSync('src/App.tsx', code)
console.log('App.tsx cleanup complete! Length:', code.length)