@prmichaelsen/acp-visualizer 0.1.5 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prmichaelsen/acp-visualizer",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "type": "module",
5
5
  "description": "Browser-based dashboard for visualizing ACP progress.yaml data",
6
6
  "bin": {
@@ -1,6 +1,3 @@
1
- import { watch } from 'fs'
2
- import { getProgressYamlPath } from './config'
3
-
4
1
  type Controller = ReadableStreamDefaultController
5
2
 
6
3
  let watcher: {
@@ -8,9 +5,12 @@ let watcher: {
8
5
  removeClient: (controller: Controller) => void
9
6
  } | null = null
10
7
 
11
- export function getFileWatcher() {
8
+ export async function getFileWatcher() {
12
9
  if (watcher) return watcher
13
10
 
11
+ const { watch } = await import('fs')
12
+ const { getProgressYamlPath } = await import('./config')
13
+
14
14
  const filePath = getProgressYamlPath()
15
15
  const clients = new Set<Controller>()
16
16
 
@@ -2,7 +2,7 @@ import { HeadContent, Scripts, createRootRoute, Outlet } from '@tanstack/react-r
2
2
  import { useAutoRefresh } from '../lib/useAutoRefresh'
3
3
  import { Sidebar } from '../components/Sidebar'
4
4
  import { Header } from '../components/Header'
5
- import { ProgressDatabaseService } from '../services/progress-database.service'
5
+ import { getProgressData } from '../services/progress-database.service'
6
6
  import type { ProgressData } from '../lib/types'
7
7
 
8
8
  import appCss from '../styles.css?url'
@@ -12,7 +12,7 @@ export const Route = createRootRoute({
12
12
  let progressData: ProgressData | null = null
13
13
 
14
14
  try {
15
- const result = ProgressDatabaseService.getProgressData()
15
+ const result = await getProgressData()
16
16
  if (result.ok) {
17
17
  progressData = result.data
18
18
  }
@@ -5,7 +5,7 @@ export const Route = createFileRoute('/api/watch')({
5
5
  server: {
6
6
  handlers: {
7
7
  GET: async () => {
8
- const watcher = getFileWatcher()
8
+ const watcher = await getFileWatcher()
9
9
 
10
10
  const stream = new ReadableStream({
11
11
  start(controller) {
@@ -1,14 +1,17 @@
1
- import { readFileSync } from 'fs'
2
- import { parseProgressYaml } from '../lib/yaml-loader'
3
- import { getProgressYamlPath } from '../lib/config'
1
+ import { createServerFn } from '@tanstack/react-start'
4
2
  import type { ProgressData } from '../lib/types'
5
3
 
6
4
  export type ProgressResult =
7
5
  | { ok: true; data: ProgressData }
8
6
  | { ok: false; error: 'FILE_NOT_FOUND' | 'PARSE_ERROR'; message: string; path: string }
9
7
 
10
- export class ProgressDatabaseService {
11
- static getProgressData(): ProgressResult {
8
+ export const getProgressData = createServerFn({ method: 'GET' }).handler(
9
+ async (): Promise<ProgressResult> => {
10
+ // Dynamic imports keep fs and yaml-loader out of the client bundle
11
+ const { readFileSync } = await import('fs')
12
+ const { parseProgressYaml } = await import('../lib/yaml-loader')
13
+ const { getProgressYamlPath } = await import('../lib/config')
14
+
12
15
  const filePath = getProgressYamlPath()
13
16
 
14
17
  try {
@@ -42,5 +45,5 @@ export class ProgressDatabaseService {
42
45
  path: filePath,
43
46
  }
44
47
  }
45
- }
46
- }
48
+ },
49
+ )