# Pristy Libvue

Shared Vue 3 component library for the [Pristy](https://pristy.fr/) ECM suite. Provides reusable components, services, stores, composables, and plugins used across all Pristy frontend applications.

## Installation

```bash
npm install @pristy/pristy-libvue
```

## Usage

All exports use named imports:

```js
import { alfrescoFileService, useUserStore, TreeExplorer } from "@pristy/pristy-libvue"
```

### What's included

| Category | Examples | Count |
|---|---|---|
| **Components** | `TreeExplorer`, `PDFComponent`, `DynamicContentView`, `CopyOrMovePopup`, `AdvancedSearchPanel`, `ChatPanel` | ~45 |
| **Services** | `alfrescoFileService`, `alfrescoNodeService`, `configService`, `workspaceService`, `errorService` | ~20 |
| **Stores** (Pinia) | `useUserStore`, `useConfigStore`, `useNavigationStore`, `useFavoritesStore`, `useSearchStore` | ~15 |
| **Composables** | `useCodeMirror`, `useMarkdownPreview`, `useCollabEditor`, `useCollabWebSocket` | 5 |
| **Pages** | `LoginPage`, `NotFoundPages`, `ErrorPage` | 3 |
| **Plugins** | `vueKeyCloak` | 1 |

See [`src/index.js`](src/index.js) for the full list of exports.

## Peer Dependencies

These must be installed by the consuming application:

| Package | Version |
|---|---|
| `vue` | ^3.5 |
| `vue-i18n` | ^11.3 |
| `vue-router` | ^4.6 |
| `@codemirror/*` | ^6.x (14 packages) |
| `codemirror` | 6.0.2 |

## Local Development

### Build the library

```bash
npm install
npm run build:library
```

### Link locally to another Pristy app

```bash
# In pristy-libvue
npm link

# In the consuming app (e.g. pristy-espaces)
npm link ../pristy-libvue
npm run dev.link      # Uses vite.config.link.js
```

After any change to pristy-libvue, rebuild with `npm run build:library` (or use `npm run build:dev` for watch mode with source maps).

### Available scripts

| Script | Description |
|---|---|
| `npm run build:library` | Production build (ESM + UMD + CSS + .d.ts) |
| `npm run build:dev` | Watch mode build with source maps |
| `npm run analyze` | Bundle size analysis (opens stats.html) |
| `npm run lint` | Lint and auto-fix with ESLint |
| `npm run check` | Lint without fixing (CI mode) |
| `npm run format` | Format with Prettier |
| `npm run test` | Run tests with Vitest |
| `npm run coverage` | Generate test coverage report |

## Architecture

The library follows a **Services -> Stores -> Components** pattern:

- **Services** (`src/services/`): Stateless modules handling API calls and business logic
- **Stores** (`src/stores/`): Pinia stores managing session state
- **Components** (`src/components/`): UI presentation consuming stores
- **Composables** (`src/composables/`): Reusable composition functions (CodeMirror, Markdown, WebSocket)

## Conventions

- **Icons**: Remixicon only (`ri-*` classes). No PrimeIcons.
- **i18n**: All user-facing strings must use `$t('key')`. No hardcoded text.
- **Imports**: Use `@/` alias for all internal imports. Never import from `@/index.js` internally.
- **License**: Every `.vue` and `.js` file must include the AGPL-3.0 header.
- **Comments**: English only.

## License

[AGPL-3.0](https://www.gnu.org/licenses/agpl-3.0.html) - Copyright (C) 2022 [Jeci SARL](https://jeci.fr)
