Files
2026-10-06 09:57:33 +03:30

375 lines
23 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# DEPENDENCIES.md — Voice-to-Voice FAQ Web Application
> **Companion to:** `ARCHITECTURE.md` · **See also:** `SRC_STRUCTURE.md`
> **Versions verified against the npm registry on 2026-10-05.** The latest Angular line at that date is **22.2.x**. Everything below targets Angular 22; section 1 lists what changes if you must stay on 18/19.
---
## 0. Read this first: six findings that change the install
These came out of checking real peer-dependency ranges and package contents, not from memory. Each one would otherwise cost you an `ERESOLVE` error or a runtime failure.
| # | Finding | What to do |
|---|---|---|
| 1 | **`provideExperimentalZonelessChangeDetection` no longer exists in Angular 22** (it is absent from `@angular/core@22.2.1`). The stable name is `provideZonelessChangeDetection`. The experimental name is only correct for Angular 18/19. | Use `provideZonelessChangeDetection()` (see `SRC_STRUCTURE.md` → `app.config.ts`). |
| 2 | **TypeScript must be `>=6.0 <6.1`.** `@angular/compiler-cli@22.2.1` and `@angular/build@22.2.1` both declare that peer range, while `typescript@latest` is already 7.0.x. | Pin `"typescript": "~6.0.3"`. Do not run `npm i typescript@latest`. |
| 3 | **`lucide-angular` is deprecated** on npm ("Please use `@lucide/angular` instead"). Its peer range stops at Angular 21 (`13.x – 21.x`), so it will conflict with Angular 22. | Use **`@lucide/angular`** (peer `>=17`). Icons are isolated behind `shared/ui/icons`, so only that folder knows which package is in use. |
| 4 | **Tailwind CSS is v4** (`4.3.x`). It is configured in CSS (`@theme`, `@utility`), runs through `@tailwindcss/postcss`, and **does not need Autoprefixer**. | Install `tailwindcss`, `@tailwindcss/postcss`, `postcss`. Skip `autoprefixer` (explained in §3.3). |
| 5 | **Three.js is pre-1.0** (`0.186.x`), and minor versions can contain breaking changes. | Pin with a **tilde** (`~0.186.1`) and keep `@types/three` on the matching minor (`~0.186.0`). |
| 6 | **Node.js `^22.22.3 \|\| ^24.15.0 \|\| >=26`** is required by Angular 22. | Set `engines` and add an `.nvmrc` (`24`). |
---
## 1. If you must stay on Angular 18 or 19
| Topic | Angular 22 (this document) | Angular 18/19 |
|---|---|---|
| Zoneless provider | `provideZonelessChangeDetection()` | `provideExperimentalZonelessChangeDetection()` |
| TypeScript | `~6.0.3` | Use the range printed by `npm view @angular/compiler-cli@<your-version> peerDependencies` |
| Icons | `@lucide/angular` | `lucide-angular` also works (its peer range covers these versions) |
| Tailwind | v4 via `@tailwindcss/postcss` | Stay on Tailwind v3 (`tailwind.config.js`, `postcss`, `autoprefixer`) unless your CLI version documents v4 support |
| Unit tests | Vitest via `@angular/build:unit-test` | Karma + Jasmine (default for those versions) |
| Components | `OnPush` set explicitly (kept explicit for readability) | `OnPush` set explicitly (required) |
For every other package (Three.js, AG Grid, PapaParse, CDK) install the version whose `peerDependencies` match your Angular major.
---
## 2. Complete `package.json`
```json
{
"name": "voice-faq-app",
"version": "0.1.0",
"private": true,
"engines": {
"node": "^22.22.3 || ^24.15.0"
},
"scripts": {
"start": "ng serve",
"build": "ng build",
"build:prod": "ng build --configuration production",
"build:stats": "ng build --configuration production --stats-json",
"watch": "ng build --watch --configuration development",
"test": "ng test",
"test:ci": "ng test --no-watch",
"e2e": "playwright test",
"lint": "ng lint",
"format": "prettier --write \"src/**/*.{ts,html,css,json}\"",
"format:check": "prettier --check \"src/**/*.{ts,html,css,json}\""
},
"dependencies": {
"@angular/cdk": "^22.2.1",
"@angular/common": "^22.2.1",
"@angular/compiler": "^22.2.1",
"@angular/core": "^22.2.1",
"@angular/forms": "^22.2.1",
"@angular/platform-browser": "^22.2.1",
"@angular/router": "^22.2.1",
"@lucide/angular": "^1.52.0",
"ag-grid-angular": "^36.2.0",
"ag-grid-community": "^36.2.0",
"papaparse": "^5.7.0",
"rxjs": "~7.8.2",
"three": "~0.186.1",
"tslib": "^2.8.1",
"zone.js": "~0.16.3"
},
"devDependencies": {
"@angular/build": "^22.2.1",
"@angular/cli": "^22.2.1",
"@angular/compiler-cli": "^22.2.1",
"@playwright/test": "^1.63.0",
"@tailwindcss/postcss": "^4.3.3",
"@types/audioworklet": "^0.0.100",
"@types/node": "^24.0.0",
"@types/papaparse": "^5.5.2",
"@types/three": "~0.186.0",
"angular-eslint": "^22.5.0",
"eslint": "^10.12.0",
"jsdom": "^30.1.2",
"postcss": "^8.5.28",
"prettier": "^3.9.9",
"prettier-plugin-tailwindcss": "^0.8.1",
"tailwindcss": "^4.3.3",
"typescript": "~6.0.3",
"typescript-eslint": "^8.71.0",
"vitest": "^5.0.3"
}
}
```
**About `zone.js`:** it is listed because your plan keeps Zone.js enabled during development and removes it at the zoneless milestone (`ZONELESS_CONVENTION.md`). When that milestone passes, delete it from `dependencies` and from the `polyfills` array in `angular.json`, and switch `app.config.ts` from `provideZoneChangeDetection` to `provideZonelessChangeDetection`. A project that starts zoneless can omit it from day one.
**Optional packages** (PDF/DOCX client-side previews) are intentionally **not** in the block above. See §3.5.
---
## 3. `dependencies`, justified
### 3.1 Core & framework
| Package | Version | Why it is needed | Notes |
|---|---|---|---|
| `@angular/core` | `^22.2.1` | Signals (`signal`, `computed`, `effect`, `input()`, `output()`, `viewChild()`), `DestroyRef`, `NgZone`, zoneless scheduler, `provideZonelessChangeDetection`. | **Includes `@angular/core/rxjs-interop`** (`toSignal`, `toObservable`, `takeUntilDestroyed`) as a *secondary entry point*; there is nothing separate to install. |
| `@angular/common` | `^22.2.1` | `NgOptimizedImage`, pipes, and **`@angular/common/http`** (`HttpClient`, `withFetch`, `withInterceptors`) for the FAQ REST API and upload progress. | `common/http` is also a secondary entry point of this package. |
| `@angular/compiler` | `^22.2.1` | Required at runtime by the standard CLI scaffold and by JIT paths in tests. | Keep on the same version as `core`. |
| `@angular/platform-browser` | `^22.2.1` | `bootstrapApplication`, DOM renderer, `Meta`/`Title`. | |
| `@angular/router` | `^22.2.1` | Lazy-loaded feature routes (`voice`, `knowledge-base`), functional guards, `withComponentInputBinding()`. | |
| `@angular/forms` | `^22.2.1` | Reactive forms in the Q&A editor modal and drawer filters. | Also a **peer dependency of `@angular/cdk`**. |
| `@angular/cdk` | `^22.2.1` | **`@angular/cdk/overlay`** (slide-over drawer positioning, scroll strategies), **`@angular/cdk/dialog`** (Q&A editor modal, focus trap, `aria-modal`), **`@angular/cdk/a11y`** (`FocusTrap`, `LiveAnnouncer` for state changes), `@angular/cdk/portal`, `@angular/cdk/scrolling` (virtual scroll for the transcript). | Peer range is `^22 \|\| ^23`; versions of `cdk` and `core` must match the major. |
| `rxjs` | `~7.8.2` | WebSocket event streams (`audio$`, `control$`), ingestion status stream (SSE), debouncing filters. Signals hold state; RxJS carries **events over time**. | Angular peers `^6.5.3 \|\| ^7.4.0`. |
| `tslib` | `^2.8.1` | Helper functions for emitted code (no duplication per file). | Required by the Angular build. |
| `zone.js` | `~0.16.3` | Only while the app still runs in zone mode. | Remove at the zoneless milestone (see §2). |
### 3.2 Audio & graphics
| Package | Version | Why it is needed | Notes |
|---|---|---|---|
| `three` | `~0.186.1` | WebGL renderer, scene graph, `ShaderMaterial`, icosahedron geometry for the audio-reactive orb. | Use **named imports** (`import { WebGLRenderer, Scene } from 'three'`) so esbuild can tree-shake. Load it only in the visualizer chunk via `import('three')` (lazy). Post-processing (bloom) lives in `three/addons/...` and is **not** planned for v1: the glow is computed in the fragment shader plus a CSS `drop-shadow`, which is far cheaper. |
| `@types/three` *(dev)* | `~0.186.0` | Type definitions (Three.js ships no types). | Same minor as `three`. |
**Web Audio API utilities.** The Web Audio API, `AudioWorklet`, `AnalyserNode`, and `MediaDevices` are **browser built-ins**: no runtime package is required, and none is recommended. Libraries like Tone.js or Howler.js are excluded (§5). The only audio-related package is the type shim below.
| Package | Version | Why | Notes |
|---|---|---|---|
| `@types/audioworklet` *(dev)* | `^0.0.100` | Types for `AudioWorkletProcessor`, `registerProcessor`, and the worklet global scope, used by `// @ts-check` in the `.js` processors and by any future TypeScript worklet sources. | Add `"types": ["audioworklet"]` only in a dedicated `tsconfig.worklet.json`, **not** in the app tsconfig (it conflicts with DOM lib globals). |
### 3.3 UI, layout & icons
| Package | Version | Why it is needed | Notes |
|---|---|---|---|
| `tailwindcss` *(dev)* | `^4.3.3` | Utility CSS, design tokens via `@theme` (glow shadows, state colors, glass surfaces), custom `@utility` classes (`glass`, `glow-*`). | v4 reads tokens from CSS; there is **no `tailwind.config.js`** by default. |
| `@tailwindcss/postcss` *(dev)* | `^4.3.3` | The PostCSS plugin the Angular build calls via `.postcssrc.json`. It also handles vendor prefixing and `@import` inlining. | |
| `postcss` *(dev)* | `^8.5.28` | Required by `@tailwindcss/postcss` and by the Angular CSS pipeline. | |
| `autoprefixer` | **not installed** | You asked for it, and it is the right choice on Tailwind v3. On **Tailwind v4 it is redundant**: prefixing is built into `@tailwindcss/postcss`. Adding it only adds build time. | If you stay on Tailwind v3 (Angular 18), install `autoprefixer ^10.6.1` and use `tailwind.config.js`. |
| `@lucide/angular` | `^1.52.0` | Tree-shakeable Lucide icons as Angular components. Used for mic, stop, transcript, upload, trash, edit, status icons. | Replaces the deprecated `lucide-angular`. Register only the icons you use through the wrapper in `shared/ui/icons` so unused icons never reach the bundle. Follow the package README for its exact component/directive API. |
| `ag-grid-community` | `^36.2.0` | Grid engine for the Q&A pairs: virtualized rows, inline editing, quick filter, column filters, row selection. | Register modules once (see §6.3). Keep community and angular wrapper on the **same version**. |
| `ag-grid-angular` | `^36.2.0` | Angular wrapper (`<ag-grid-angular>`), signal-friendly inputs, cell renderer components. | Peer: `@angular/core >= 20`. |
| `prettier-plugin-tailwindcss` *(dev)* | `^0.8.1` | Deterministic class ordering in templates. | |
**AG Grid vs. a custom Tailwind table.** The default plan is AG Grid because the grid needs inline editing, filtering, selection, and virtualization over potentially tens of thousands of Q&A rows. A Tailwind table remains a valid fallback for under roughly 500 rows. Both live behind `QaGridComponent`'s inputs/outputs, so swapping is a one-component change. Choosing the Tailwind table lets you drop both `ag-grid-*` packages.
### 3.4 Parsing & transport
| Package | Version | Why it is needed | Notes |
|---|---|---|---|
| `papaparse` | `^5.7.0` | Client-side CSV preview (first N rows), delimiter and header detection, row validation (`MISSING_QUESTION`, `MISSING_ANSWER`) before upload. | Lazy-load with `import('papaparse')`. Use `preview: N` for the preview and `chunk`/`step` streaming for counting rows in large files. **Do not rely on `worker: true`** under bundlers: PapaParse builds its worker from its own script URL, which commonly breaks once bundled; test it before depending on it. |
| `@types/papaparse` *(dev)* | `^5.5.2` | Types for PapaParse. | |
| WebSocket client | **none (native `WebSocket`)** | The browser's `WebSocket` supports binary frames (`binaryType = 'arraybuffer'`), which is exactly what the PCM protocol needs. Reconnect, backoff, heartbeat, and framing are ~150 lines in `core/websocket`. | See the Socket.IO note below. |
**Why not Socket.IO.** `socket.io-client` (latest `4.8.4`) speaks the Socket.IO protocol, which only works against a Socket.IO server and adds its own packet framing, optional long-polling transport, and event envelope on top of WebSocket. For a latency-critical raw-PCM stream with a custom 16-byte binary header (`ARCHITECTURE.md` §5.2), that is overhead without benefit. **Use it only if your backend is already Socket.IO.** In that case, install `socket.io-client@^4.8.4` and write a `SocketIoTransport implements RealtimeTransport` adapter; nothing else in the app changes, because everything consumes the transport interface.
### 3.5 Optional packages (add only if you need them)
The default design uploads files and lets the server do real parsing. The browser only validates type, size, and **magic bytes** (no library needed) and previews CSV. Add these only if you want richer previews:
| Package | Version | Purpose | Cost / caveat |
|---|---|---|---|
| `pdfjs-dist` | `^6.4.299` | Page count and first-page text preview of a PDF before upload. | Large; needs its worker file served as a static asset. Lazy-load behind the preview panel only. |
| `mammoth` | `^1.13.0` | DOCX → plain text/HTML preview in the browser. | Sizeable; lazy-load. A server-side preview is often simpler. |
| `socket.io-client` | `^4.8.4` | Only if the backend is Socket.IO (see §3.4). | Adds protocol overhead. |
---
## 4. `devDependencies`, justified
| Package | Version | Why |
|---|---|---|
| `@angular/cli` | `^22.2.1` | `ng serve`, `ng build`, `ng test`, `ng generate`, `ng update`. |
| `@angular/build` | `^22.2.1` | The esbuild/Vite-based builders (`application`, `dev-server`, `unit-test`). Supports the `loader` option used to import `.glsl` shader files as strings. |
| `@angular/compiler-cli` | `^22.2.1` | AOT compiler and `ngc`. Pins the supported TypeScript range (`>=6.0 <6.1`). |
| `typescript` | `~6.0.3` | Language and type checker; **tilde-pinned to the supported minor** (see §0, finding 2). |
| `tailwindcss`, `@tailwindcss/postcss`, `postcss` | see §3.3 | Styling pipeline. |
| `prettier`, `prettier-plugin-tailwindcss` | `^3.9.9`, `^0.8.1` | Formatting and class sorting. |
| `eslint`, `angular-eslint`, `typescript-eslint` | `^10.12.0`, `^22.5.0`, `^8.71.0` | Linting, including Angular template rules (`prefer-on-push-component-change-detection`, `prefer-signals`-style rules, `no-restricted-imports` to enforce the `shared ← core ← features` dependency rule). `typescript-eslint` supports TypeScript `<6.1`. |
| `vitest`, `jsdom` | `^5.0.3`, `^30.1.2` | Unit/integration tests through `@angular/build:unit-test`. Used for the transition table, frame codec, PCM utilities, stores, and components. Worklet processors are tested by loading the class into a fake worklet scope. |
| `@playwright/test` | `^1.63.0` | E2E: fake-microphone flags (`--use-fake-device-for-media-stream`), mock WebSocket gateway, and the "zero change-detection ticks" performance assertion. |
| `@types/three`, `@types/papaparse`, `@types/audioworklet`, `@types/node` | see §2 | Type packages. `@types/node` is for config files and test tooling only. |
---
## 5. Deliberately excluded
| Package | Why it is not here |
|---|---|
| `autoprefixer` | Redundant with Tailwind v4 (§3.3). |
| `lucide-angular` | Deprecated; conflicts with Angular 22 peers. Use `@lucide/angular`. |
| `socket.io-client` | Needs a Socket.IO server; unnecessary overhead for raw PCM (§3.4). Optional only. |
| `@ngrx/*` (Store, SignalStore) | The app has three small stores (`VoiceStateStore`, `FaqStore`, `AppSettingsStore`) with one writer each. Plain signals are sufficient and keep the zoneless story simple. Revisit if a fourth cross-feature store appears. |
| `@angular/material` | Duplicates CDK + Tailwind and conflicts with the glassmorphic design language. |
| `tone`, `howler`, `wavesurfer.js` | The app needs low-level PCM control through `AudioWorklet`; these add abstraction and bundle weight without helping. |
| `@angular/animations` | Not used: state transitions are CSS (Tailwind) and shader uniforms. |
| `lodash`, `moment`, `uuid` | Native `structuredClone`, `Intl`, and `crypto.randomUUID()` cover the need. |
| `ngx-papaparse`, `ngx-socket-io` | Thin, often lagging wrappers. Our own services (`CsvParserService`, `WebSocketService`) are small and zoneless-safe. |
| `three-stdlib`, `postprocessing` | Not needed for v1 (§3.2). |
---
## 6. Configuration these packages require
### 6.1 Tailwind v4 with the Angular build
`/.postcssrc.json` (project root, **not** inside `src/`):
```json
{
"plugins": {
"@tailwindcss/postcss": {}
}
}
```
`src/styles.css` starts with `@import "tailwindcss";` (full file in `SRC_STRUCTURE.md`). There is no `tailwind.config.js` and no `content` array; Tailwind v4 detects sources automatically.
### 6.2 `angular.json` fragments
```jsonc
{
"projects": {
"voice-faq-app": {
"schematics": {
// Keep ".component.ts" / ".service.ts" suffixes (Angular 20+ CLI omits them by default)
"@schematics/angular:component": { "type": "component", "changeDetection": "OnPush", "style": "none", "skipTests": false },
"@schematics/angular:directive": { "type": "directive" },
"@schematics/angular:service": { "type": "service" }
},
"architect": {
"build": {
"builder": "@angular/build:application",
"options": {
"browser": "src/main.ts",
"tsConfig": "tsconfig.app.json",
"styles": ["src/styles.css"],
// Zone phase only. Delete this line at the zoneless milestone:
"polyfills": ["zone.js"],
"assets": [
{ "glob": "favicon.ico", "input": "src", "output": "/" },
{ "glob": "**/*", "input": "src/assets", "output": "assets" }
],
// Import shader sources as strings: import vert from './orb.vert.glsl'
"loader": { ".glsl": "text", ".vert": "text", ".frag": "text" }
},
"configurations": {
"production": {
"budgets": [
{ "type": "initial", "maximumWarning": "250kB", "maximumError": "400kB" },
{ "type": "anyComponentStyle", "maximumWarning": "4kB", "maximumError": "8kB" }
],
"outputHashing": "all",
"fileReplacements": [
{ "replace": "src/environments/environment.ts", "with": "src/environments/environment.production.ts" }
]
},
"development": { "optimization": false, "extractLicenses": false, "sourceMap": true }
}
},
"test": {
"builder": "@angular/build:unit-test",
"options": { "tsConfig": "tsconfig.spec.json", "runner": "vitest", "buildTarget": "::development" }
}
}
}
}
}
```
Notes:
- `src/assets` is copied verbatim and is **not hashed**. Worklet files are fetched by URL at runtime, so load them with a version query (`pcm-capture-processor.js?v=<buildId>`) or the browser may run a stale processor after a deploy.
- The initial budget (`250 kB` warning) is what enforces lazy-loading of Three.js, AG Grid, and PapaParse.
### 6.3 AG Grid module registration (once, in the lazy `qa-grid` entry)
```ts
// features/faq-manager/grid/register-grid-modules.ts
import { AllCommunityModule, ModuleRegistry } from 'ag-grid-community';
let registered = false;
export function registerGridModules(): void {
if (registered) return;
ModuleRegistry.registerModules([AllCommunityModule]);
registered = true;
}
```
`AllCommunityModule` is the simplest correct start. Before production, replace it with only the modules you use (client-side row model, text editors, filters, row selection) following AG Grid's module-selection guide, to shrink the grid chunk. Theming uses AG Grid's JavaScript theme API, so **no AG Grid CSS imports** are needed in `styles.css`.
### 6.4 `tsconfig` essentials
```jsonc
// tsconfig.json (excerpt)
{
"compilerOptions": {
"strict": true,
"noImplicitOverride": true,
"noPropertyAccessFromIndexSignature": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"isolatedModules": true,
"target": "ES2022",
"module": "preserve",
"moduleResolution": "bundler",
"lib": ["ES2022", "dom", "dom.iterable"],
"paths": {
"@core/*": ["src/app/core/*"],
"@features/*": ["src/app/features/*"],
"@shared/*": ["src/app/shared/*"],
"@env/*": ["src/environments/*"]
}
},
"angularCompilerOptions": {
"strictInjectionParameters": true,
"strictInputAccessModifiers": true,
"strictTemplates": true
}
}
```
Add a one-line ambient declaration so shader imports type-check (`declare module '*.glsl' { const source: string; export default source; }`), kept in `src/app/core/audio/visualizer/shader-source.d.ts`.
### 6.5 Lazy-loading map (what must stay out of the initial bundle)
| Package | Loaded when | How |
|---|---|---|
| `three` | The voice page's orb mounts | `await import('three')` inside `ThreeOrbVisualizer.create()` |
| `ag-grid-*` | The FAQ grid first renders | Route-level lazy feature + dynamic import in `QaGridComponent` |
| `papaparse` | A CSV is dropped | `await import('papaparse')` inside `CsvParserService` |
| `pdfjs-dist`, `mammoth` (if used) | The preview panel opens | Dynamic import in the preview component |
| `@angular/cdk/overlay`, `/dialog` | The drawer or modal opens | Tree-shaken per entry point; opened through a small service |
---
## 7. Install & maintenance
```bash
# 1. Runtime and tooling
nvm install 24 && nvm use 24
# 2. Create the project (Angular 22), zoneless, no routing scaffolding conflicts
npx @angular/cli@22 new voice-faq-app --style=css --routing --ssr=false
cd voice-faq-app
# 3. Runtime dependencies
npm i @angular/cdk@^22.2.1 @lucide/angular@^1.52.0 \
ag-grid-angular@^36.2.0 ag-grid-community@^36.2.0 \
papaparse@^5.7.0 three@~0.186.1
# 4. Dev dependencies
npm i -D tailwindcss@^4.3.3 @tailwindcss/postcss@^4.3.3 postcss@^8.5.28 \
@types/three@~0.186.0 @types/papaparse@^5.5.2 @types/audioworklet@^0.0.100 \
prettier prettier-plugin-tailwindcss @playwright/test
# 5. Make sure TypeScript stayed in the supported range
npm ls typescript # expect 6.0.x
```
**Version policy**
- **Angular packages:** move together using `ng update @angular/core @angular/cli @angular/cdk` (never bump one alone).
- **`three` and `@types/three`:** tilde-pinned; upgrade deliberately, one minor at a time, reading the migration notes and running the visual regression screenshot of each of the five orb states.
- **AG Grid:** `ag-grid-community` and `ag-grid-angular` always share an identical version.
- **Automation:** enable Renovate or Dependabot with groups (`angular`, `ag-grid`, `three`, `tailwind`, `tooling`) and require CI (lint, unit, E2E, bundle budgets) to pass.
- **Audit:** `npm audit --omit=dev` in CI; fail on high severity in runtime dependencies.
- **Lockfile:** commit `package-lock.json`; use `npm ci` in CI.