# Source and Build Notes

This plugin includes readable source and local build tooling for generated admin assets so the WordPress.org package can be reviewed without access to a public source repository. The production plugin package includes `package.json`, `assets-src/`, and `tools/build-vendor.mjs`, so the generated admin vendor assets can be rebuilt from the submitted package itself.

## Generated Admin JavaScript

- `assets/vendor/js/app.js` is generated from `assets-src/js/vendor-core.js`.
- `assets-src/js/vendor-core.js` imports the Bootstrap JavaScript modules used by the admin UI: Collapse, Dropdown, Modal, and Tooltip.
- `assets/vendor/js/datatables.js` is generated from `assets-src/js/vendor-datatables.js`.
- DataTables imports a module named `jquery` during the build. `tools/build-vendor.mjs` resolves that import with a virtual esbuild module that returns the `window.jQuery` instance provided by WordPress. The plugin does not include a jQuery source file or bundle its own jQuery runtime.
- `assets/vendor/js/dashboard-charts.js` is generated from `assets-src/js/dashboard-charts.js`.
- `assets-src/js/dashboard-charts.js` imports only the Apache ECharts modules needed by the dashboard line charts and exposes them through the plugin-owned `window.autoDmStudioCharts` adapter. It does not expose or depend on `window.echarts`, so it can coexist with another ECharts copy loaded by WordPress or another plugin.
- These JavaScript files are built by `tools/build-vendor.mjs` with esbuild.

Build from this plugin directory:

```powershell
pnpm install
pnpm run build:vendor:prod
```

Build readable, non-minified JavaScript output. CSS output is always readable:

```powershell
pnpm run build:vendor
```

## Generated Admin Vendor CSS

- `assets/vendor/css/admin-vendor.css` is generated by `tools/build-vendor.mjs`.
- The generated CSS is built from the readable npm package stylesheets listed below:
  - `bootstrap/dist/css/bootstrap.css`
  - `datatables.net-bs5/css/dataTables.bootstrap5.css`
  - `flatpickr/dist/flatpickr.css`
- The build process scopes selectors under `.auto-dm-studio-admin` so vendor styles do not leak into the rest of WordPress admin. Bootstrap modal backdrop/open selectors remain global because Bootstrap inserts the backdrop on `body`.

Plugin-owned admin styling lives in `assets/css/admin.css`.
