loader-status.ts 1.4 KB

1234567891011121314151617181920212223242526272829303132333435
  1. /**
  2. * Fiber-state projection vocabulary for the framework-free boot page. The
  3. * boot chain subscribes to `internal/status` and projects the owning loader
  4. * entry's current state.
  5. * @module @deepseek-ai/dsh-client-web/src/loader-status
  6. */
  7. import type { FiberState } from '@deepseek-ai/cordis'
  8. /**
  9. * Value mirror of cordis's `FiberState` const enum: a const enum has no
  10. * runtime object to import (and esbuild-based pipelines cannot inline it
  11. * across modules), so these values mirror the pinned vendored definition
  12. * while retaining its type (same rationale as dsh-tool-cordis's mirror).
  13. */
  14. export const FIBER_STATE = {
  15. PENDING: 0 as FiberState.PENDING,
  16. LOADING: 1 as FiberState.LOADING,
  17. ACTIVE: 2 as FiberState.ACTIVE,
  18. FAILED: 3 as FiberState.FAILED,
  19. DISPOSED: 4 as FiberState.DISPOSED,
  20. UNLOADING: 5 as FiberState.UNLOADING,
  21. } as const
  22. /** One entry's projected state label (lower-case face of {@link FiberState}). */
  23. export type LoaderEntryState = 'pending' | 'loading' | 'active' | 'failed' | 'disposed' | 'unloading'
  24. /** Label for each fiber state, keyed by member (inlining-safe — no reverse mapping). */
  25. export const STATE_LABELS: Record<FiberState, LoaderEntryState> = {
  26. [FIBER_STATE.PENDING]: 'pending',
  27. [FIBER_STATE.LOADING]: 'loading',
  28. [FIBER_STATE.ACTIVE]: 'active',
  29. [FIBER_STATE.FAILED]: 'failed',
  30. [FIBER_STATE.DISPOSED]: 'disposed',
  31. [FIBER_STATE.UNLOADING]: 'unloading',
  32. }