# Architecture

## Goal

`@ccpc/cad-viewer` is a small adapter package for host Vue applications. It hides the direct setup required by `@mlightcad/cad-viewer` and exposes one component:

```ts
import { CcpcCadViewer } from '@ccpc/cad-viewer'
```

The package is intentionally independent from the local upstream source checkout at `D:\new_work\cad-viewer`. That checkout is only used as a reference when reading upstream implementation details.

## Dependency Strategy

The host app should only provide Vue:

```json
{
  "peerDependencies": {
    "vue": "^3.4.21"
  }
}
```

The mlightcad runtime stack is kept in this package's `devDependencies` and bundled into the library output during build. This is deliberate because existing host apps can already depend on a different `three` version.

Do not move `@mlightcad/*`, `three`, `vue-i18n`, or `element-plus` into runtime `dependencies` unless the consuming apps are ready to resolve their peer versions directly.

## Runtime Assets

CAD parsing and text rendering need worker files under the host app's public assets path:

```text
public/assets/dxf-parser-worker.js
public/assets/libredwg-parser-worker.js
public/assets/mtext-renderer-worker.js
```

The worker files are generated from installed mlightcad packages by:

```powershell
npm run prepare-assets
```

They are copied into a consuming app by:

```powershell
npm run copy-assets -- D:\work\modelcollab\public\assets
```

The published tarball includes the generated `assets/*.js` files, but Git does not track them.
