@metricinsights/pp-dev 0.19.0 → 1.0.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/CHANGELOG.md +198 -0
  2. package/README.md +298 -266
  3. package/dist/CHANGELOG.md +198 -0
  4. package/dist/README.md +298 -266
  5. package/dist/cjs/cli.js +1 -1
  6. package/dist/cjs/cli.js.map +1 -1
  7. package/dist/cjs/helpers.js +1 -1
  8. package/dist/cjs/helpers.js.map +1 -1
  9. package/dist/cjs/index-DeUfAH6g.js +2 -0
  10. package/dist/cjs/index-DeUfAH6g.js.map +1 -0
  11. package/dist/cjs/index.js +1 -1
  12. package/dist/cjs/migrate-r2mXdGLZ.js +2 -0
  13. package/dist/cjs/migrate-r2mXdGLZ.js.map +1 -0
  14. package/dist/cjs/package.json +16 -16
  15. package/dist/cjs/plugin-Cm9vRLCu.js +2 -0
  16. package/dist/cjs/plugin-Cm9vRLCu.js.map +1 -0
  17. package/dist/cjs/plugin.js +1 -1
  18. package/dist/cjs/version-plugin-DsC5NLoX.js +2 -0
  19. package/dist/cjs/{version-plugin-DUKsGBsW.js.map → version-plugin-DsC5NLoX.js.map} +1 -1
  20. package/dist/client/client.css +1 -1
  21. package/dist/client/client.css.map +1 -1
  22. package/dist/client/client.js +509 -47
  23. package/dist/client/client.js.map +1 -1
  24. package/dist/client/index.html +71 -18
  25. package/dist/esm/cli.js +1 -1
  26. package/dist/esm/cli.js.map +1 -1
  27. package/dist/esm/helpers.js +1 -1
  28. package/dist/esm/helpers.js.map +1 -1
  29. package/dist/esm/index-DOjGFYJ7.js +2 -0
  30. package/dist/esm/index-DOjGFYJ7.js.map +1 -0
  31. package/dist/esm/index.js +1 -1
  32. package/dist/esm/migrate-BYuCtRbI.js +2 -0
  33. package/dist/esm/migrate-BYuCtRbI.js.map +1 -0
  34. package/dist/esm/package.json +16 -16
  35. package/dist/esm/plugin-B2ocw-wb.js +2 -0
  36. package/dist/esm/plugin-B2ocw-wb.js.map +1 -0
  37. package/dist/esm/plugin.js +1 -1
  38. package/dist/esm/version-plugin-BGWVTSsN.js +2 -0
  39. package/dist/esm/{version-plugin-C7j2jDQX.js.map → version-plugin-BGWVTSsN.js.map} +1 -1
  40. package/dist/types/index.d.ts +116 -139
  41. package/package.json +34 -28
  42. package/dist/cjs/index-Bb3yIW5d.js +0 -2
  43. package/dist/cjs/index-Bb3yIW5d.js.map +0 -1
  44. package/dist/cjs/plugin-CqahMAGe.js +0 -2
  45. package/dist/cjs/plugin-CqahMAGe.js.map +0 -1
  46. package/dist/cjs/version-plugin-DUKsGBsW.js +0 -2
  47. package/dist/esm/index-Cd-DmbPQ.js +0 -2
  48. package/dist/esm/index-Cd-DmbPQ.js.map +0 -1
  49. package/dist/esm/plugin-BeehFkJq.js +0 -2
  50. package/dist/esm/plugin-BeehFkJq.js.map +0 -1
  51. package/dist/esm/version-plugin-C7j2jDQX.js +0 -2
package/README.md CHANGED
@@ -45,142 +45,79 @@ import ppDev from '@metricinsights/pp-dev';
45
45
  // Plugin only (for Vite integration)
46
46
  import { vitePPDev } from '@metricinsights/pp-dev/plugin';
47
47
 
48
- // Helpers only (for utility functions)
49
- import { helpers } from '@metricinsights/pp-dev/helpers';
48
+ // Helpers only (defineConfig and utility functions)
49
+ import { defineConfig } from '@metricinsights/pp-dev/helpers';
50
50
 
51
51
  // Client assets (for development UI)
52
52
  import '@metricinsights/pp-dev/client/css/client.css';
53
53
  ```
54
54
 
55
- **Available Exports**:
56
-
57
- - **Main**: Complete pp-dev functionality with CLI and plugins
58
- - **Plugin**: Vite plugin for integration with build tools
59
- - **Helpers**: Utility functions for authentication and configuration
60
- - **Client**: Development UI assets and styles
61
-
62
- ## 🚀 Performance & Build System
63
-
64
- The pp-dev package includes optimized startup performance and build system with multiple strategies:
65
-
66
- ### Quick Start
67
-
68
- ```bash
69
- # Standard build (parallel)
70
- npm run build
71
-
72
- # Fast development build
73
- npm run build:fast
74
-
75
- # Watch mode for development
76
- npm run build:watch
77
-
78
- # Bundle analysis
79
- npm run build:analyze
80
-
81
- # Performance profiling
82
- npm run startup:profile
83
-
84
- # Startup optimization
85
- npm run startup:optimize
86
- ```
87
-
88
- ### Performance Features
89
-
90
- - **40-50% faster startup** with intelligent caching
91
- - **60-70% faster subsequent starts** with connection pooling
92
- - **Lazy loading** of heavy modules (jsdom, esbuild)
93
- - **API response caching** with configurable TTL
94
- - **HTTP connection pooling** for reduced overhead
95
- - **Startup profiling** with detailed performance analysis
96
- - **Intelligent dependency optimization** based on profiling data
97
-
98
- ### Build Features
99
-
100
- - **Parallel builds** for 40-60% faster build times
101
- - **Enhanced tree-shaking** for smaller bundles
102
- - **Multiple output formats** (ESM, CJS, Types)
103
- - **Bundle analysis** with visualizer support
104
- - **ESBuild integration** for faster TypeScript compilation
105
- - **Build optimization scripts** for performance tuning
106
-
107
- ### Startup Optimization
108
-
109
- The new startup optimization system in v0.11.0 provides:
110
-
111
- - **Performance Monitoring**: Real-time startup time tracking and analysis
112
- - **Cache Optimization**: Intelligent cache management for config and API responses
113
- - **Dependency Analysis**: Identification of performance bottlenecks
114
- - **Optimization Suggestions**: Automated recommendations for performance improvements
115
-
116
- Run the startup optimizer to analyze and improve your development environment:
117
-
118
- ```bash
119
- npm run startup:optimize
120
- ```
121
-
122
- 📖 See [BUILD_IMPROVEMENTS.md](./BUILD_IMPROVEMENTS.md) for build details.
123
- 📖 See [STARTUP_PERFORMANCE.md](./STARTUP_PERFORMANCE.md) for performance details.
124
-
125
55
  ## Configuration
126
56
 
127
57
  ### Configuration File
128
58
 
129
59
  Create a configuration file named `pp-dev.config` with one of these extensions:
130
60
 
61
+ - `.ts` (recommended)
131
62
  - `.js` or `.cjs` (for CommonJS)
132
- - `.ts` (for TypeScript)
133
63
  - `.json`
134
64
 
135
65
  Alternatively, you can define configuration in your `package.json` using the `pp-dev` key.
136
66
 
137
67
  ### Configuration Examples
138
68
 
139
- #### JavaScript (CommonJS)
140
-
141
- ```javascript
142
- // pp-dev.config.js
143
-
144
- /**
145
- * @type {import('@metricinsights/pp-dev').PPDevConfig}
146
- */
147
- module.exports = {
148
- backendBaseURL: 'https://mi.company.com',
149
- appId: 1,
150
- v7Features: true,
151
- miHudLess: true,
152
- integrateMiTopBar: true,
153
- };
154
- ```
155
-
156
- #### TypeScript
69
+ #### TypeScript (recommended)
157
70
 
158
71
  ```typescript
159
72
  // pp-dev.config.ts
73
+ import { defineConfig } from '@metricinsights/pp-dev';
74
+
75
+ export default defineConfig({
76
+ mi: {
77
+ url: 'https://mi.company.com',
78
+ token: process.env.MI_ACCESS_TOKEN,
79
+ mode: 'standalone',
80
+ apiVersion: 7,
81
+ },
82
+ app: {
83
+ id: 123,
84
+ type: 'template',
85
+ },
86
+ });
87
+ ```
160
88
 
161
- import { PPDevConfig } from '@metricinsights/pp-dev';
89
+ #### JavaScript (CommonJS)
162
90
 
163
- const config: PPDevConfig = {
164
- backendBaseURL: 'https://mi.company.com',
165
- appId: 1,
166
- v7Features: true,
167
- miHudLess: true,
168
- integrateMiTopBar: true,
169
- };
91
+ ```javascript
92
+ // pp-dev.config.js
93
+ const { defineConfig } = require('@metricinsights/pp-dev');
170
94
 
171
- export default config;
95
+ module.exports = defineConfig({
96
+ mi: {
97
+ url: 'https://mi.company.com',
98
+ mode: 'standalone',
99
+ apiVersion: 7,
100
+ },
101
+ app: {
102
+ id: 123,
103
+ type: 'template',
104
+ },
105
+ });
172
106
  ```
173
107
 
174
108
  #### JSON
175
109
 
176
110
  ```json
177
- // pp-dev.config.json
178
111
  {
179
- "backendBaseURL": "https://mi.company.com",
180
- "appId": 1,
181
- "v7Features": true,
182
- "miHudLess": true,
183
- "integrateMiTopBar": true
112
+ "mi": {
113
+ "url": "https://mi.company.com",
114
+ "mode": "standalone",
115
+ "apiVersion": 7
116
+ },
117
+ "app": {
118
+ "id": 123,
119
+ "type": "template"
120
+ }
184
121
  }
185
122
  ```
186
123
 
@@ -189,176 +126,157 @@ export default config;
189
126
  ```json
190
127
  {
191
128
  "name": "my-portal-page",
192
- "version": "1.0.0",
193
129
  "pp-dev": {
194
- "backendBaseURL": "https://mi.company.com",
195
- "appId": 1,
196
- "v7Features": true,
197
- "miHudLess": true,
198
- "integrateMiTopBar": true
130
+ "mi": {
131
+ "url": "https://mi.company.com",
132
+ "mode": "standalone"
133
+ },
134
+ "app": {
135
+ "id": 123
136
+ }
199
137
  }
200
138
  }
201
139
  ```
202
140
 
203
141
  ## Configuration Options
204
142
 
205
- > **Version Compatibility**: This documentation covers pp-dev v0.11.0+. Some options may not be available in older versions. Check the [CHANGELOG](./CHANGELOG.md) for version-specific information.
206
-
207
- ### Required Options
208
-
209
- | Option | Type | Description |
210
- | ---------------- | ------ | --------------------------------------------------------------------------- |
211
- | `backendBaseURL` | string | URL of the Metric Insights instance for API proxying |
212
- | `portalPageId` | number | ID of the Portal Page for variable values (deprecated, use `appId` instead) |
213
- | `appId` | number | ID of the Portal Page for variable values (synonym for `portalPageId`) |
214
-
215
- ### Optional Options
216
-
217
- | Option | Type | Default | Description |
218
- | ---------------------- | ----------------- | ----------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
219
- | `miHudLess` | boolean | `false` | Disables Metric Insights navigation bar in development |
220
- | `integrateMiTopBar` | boolean \| object | `false` | Integrates MI Top Bar and scripts into the App build (requires `miHudLess: true`). When `true`, enables both `addRootElement` and `addSharedComponentsScripts`. When an object, allows selective enabling: `{ addRootElement?: boolean, addSharedComponentsScripts?: boolean }` |
221
- | `templateLess` | boolean | `false` | Disables template variable transformation |
222
- | `enableProxyCache` | boolean | `true` | Enables caching of proxied requests |
223
- | `proxyCacheTTL` | number | `600000` | Cache TTL in milliseconds (10 minutes) |
224
- | `disableSSLValidation` | boolean | `false` | Disables SSL certificate validation for proxy requests |
225
- | `imageOptimizer` | boolean \| object | `true` | Controls image optimization. See [vite-plugin-image-optimizer](https://www.npmjs.com/package/vite-plugin-image-optimizer#plugin-options) for object options |
226
- | `outDir` | string | `dist` | Output directory for builds |
227
- | `distZip` | boolean \| object | `true` | Controls build output zipping. Object options: `{ outDir?: string, outFileName?: string }` |
228
- | `syncBackupsDir` | string | `backups` | Directory for asset backups from MI server |
229
- | `v7Features` | boolean | `false` | Enables Metric Insights v7 features |
230
- | `personalAccessToken` | string | `process.env.MI_ACCESS_TOKEN` | Personal Access Token for the MI instance |
231
-
232
- ### integrateMiTopBar Details
233
-
234
- The `integrateMiTopBar` option allows you to integrate the Metric Insights Top Bar and scripts directly into your application build. This is useful when you want to:
235
-
236
- 1. **Customize the Top Bar**: Modify the appearance and behavior of the MI navigation
237
- 2. **Bundle Integration**: Include MI scripts in your build instead of loading them dynamically
238
- 3. **Offline Development**: Work with MI features even when disconnected from the server
239
-
240
- **Important**: This option can only be enabled when `miHudLess` is set to `true`.
241
-
242
- #### Configuration Options
243
-
244
- `integrateMiTopBar` can be configured in two ways:
245
-
246
- **1. Boolean (Simple)**
247
-
248
- - `true`: Enables both `addRootElement` and `addSharedComponentsScripts`
249
- - `false`: Disables integration (default)
250
-
251
- **2. Object (Advanced)**
252
-
253
- - `addRootElement`: Adds `<div id="mi-react-root">` element to the body for React mounting
254
- - `addSharedComponentsScripts`: Adds MI shared component scripts and styles:
255
- - `/auth/info.js` - Authentication info script
256
- - `/js/main.js` - Main MI JavaScript bundle
257
- - `/css/main.css` - MI stylesheet
258
-
259
- #### Examples
260
-
261
- **Simple boolean configuration:**
262
-
263
- ```javascript
264
- // pp-dev.config.js
265
- module.exports = {
266
- backendBaseURL: 'https://mi.company.com',
267
- appId: 1,
268
- miHudLess: true, // Required: Disable dynamic MI scripts
269
- integrateMiTopBar: true, // Enable: Integrate Top Bar into build
270
- };
271
- ```
272
-
273
- **Advanced object configuration (selective features):**
274
-
275
- ```javascript
276
- // pp-dev.config.js
277
- module.exports = {
278
- backendBaseURL: 'https://mi.company.com',
279
- appId: 1,
280
- miHudLess: true,
281
- integrateMiTopBar: {
282
- addRootElement: true, // Add root element for React
283
- addSharedComponentsScripts: true, // Add MI scripts and styles
284
- },
285
- };
286
- ```
287
-
288
- **Partial integration (scripts only, manual root element):**
289
-
290
- ```javascript
291
- // pp-dev.config.js
292
- module.exports = {
293
- backendBaseURL: 'https://mi.company.com',
294
- appId: 1,
295
- miHudLess: true,
296
- integrateMiTopBar: {
297
- addRootElement: false, // Don't add root element
298
- addSharedComponentsScripts: true, // Add MI scripts and styles
299
- },
300
- };
301
- ```
302
-
303
- ### v7Features Details
304
-
305
- When enabled (`true`), this option:
306
-
307
- 1. Changes development path from `/pt/<portal-page-name>` to `/pl/<portal-page-name>`
308
- 2. Updates Code Sync feature to use v7.1.0+ URLs
309
-
310
- ### Personal Access Token
311
-
312
- The `personalAccessToken` option allows you to authenticate with the Metric Insights instance. You can set it in your configuration or use the `MI_ACCESS_TOKEN` environment variable.
313
-
314
- Example with authentication and Top Bar integration:
315
-
316
- ```javascript
317
- // pp-dev.config.js
318
- module.exports = {
319
- backendBaseURL: 'https://mi.company.com',
320
- appId: 1,
321
- personalAccessToken: process.env.MI_ACCESS_TOKEN,
322
- miHudLess: true,
323
- integrateMiTopBar: true,
324
- };
325
- ```
326
-
327
- **Environment Variable**: Set `MI_ACCESS_TOKEN` in your `.env` file:
328
-
329
- ```bash
330
- MI_ACCESS_TOKEN=your_token_here
331
- ```
143
+ ### `mi` Metric Insights connection
144
+
145
+ | Field | Type | Default | Description |
146
+ |--------------|-----------------------------------|----------------|-----------------------------------------------------------|
147
+ | `url` | `string` | | URL of the Metric Insights instance |
148
+ | `token` | `string` | `MI_ACCESS_TOKEN` env | Personal access token for authentication |
149
+ | `mode` | `'standalone' \| 'embedding'` | `'standalone'` | Standalone hides the MI navigation; embedding keeps it |
150
+ | `include` | `'top-bar' \| 'shared-components'`| — | Bundle MI top-bar assets into the build (requires `standalone`) |
151
+ | `apiVersion` | `6 \| 7` | `7` | MI API version to target |
152
+
153
+ ### `app` — Portal Page identity
154
+
155
+ | Field | Type | Default | Description |
156
+ |--------|----------------------------|--------------------------|-------------------------------------------------------------|
157
+ | `id` | `number` | — | Portal Page ID used to fetch template variables |
158
+ | `type` | `'template' \| 'page'` | `'template'` | `template` syncs back to MI; `page` is standalone-only |
159
+ | `name` | `string` | `package.json#name` | Template name on the MI instance (usually auto-resolved) |
160
+
161
+ ### `proxy` Request proxying
162
+
163
+ | Field | Type | Default | Description |
164
+ |---------------------|-----------|----------|------------------------------------------------------|
165
+ | `cache` | `boolean` | `true` | Enable caching of proxied requests |
166
+ | `cacheTtl` | `number` | `600000` | Cache TTL in milliseconds (10 minutes) |
167
+ | `tls.allowSelfSigned` | `boolean` | `false` | Allow self-signed SSL certificates on the MI server |
168
+
169
+ ### `build` — Build output
170
+
171
+ | Field | Type | Default | Description |
172
+ |---------------------|-------------------------------------------------------------|----------|--------------------------------------------------------------------------------------|
173
+ | `outDir` | `string` | `'dist'` | Output directory |
174
+ | `zip` | `boolean \| { fileName?: string; outDir?: string; inDir?: string }` | `true` | Zip build output. Object form customizes filename and directories. |
175
+ | `versionFile` | `boolean \| { enabled?: boolean; fileNameTemplate?: string }` | `true` | Write a VERSION file into the build |
176
+ | `imageOptimisations`| `boolean \| Record<string, unknown>` | `true` | Image optimization. See [vite-plugin-image-optimizer](https://www.npmjs.com/package/vite-plugin-image-optimizer#plugin-options) for object options |
177
+
178
+ ### `inspector` Request Inspector
179
+
180
+ | Field | Type | Default | Description |
181
+ |----------------|-----------|-------------|----------------------------------------------------------------|
182
+ | `enabled` | `boolean` | `true` | Enable the request inspector |
183
+ | `maxMemory` | `number` | `104857600` | Max total body memory (bytes) before oldest entries are evicted (default 100 MB) |
184
+ | `captureLimit` | `number` | `10485760` | Max body size captured per request/response (bytes, default 10 MB). Larger bodies are stored truncated. |
185
+
186
+ ### `sync` Template sync
187
+
188
+ | Field | Type | Default | Description |
189
+ |--------------|----------|-------------|-----------------------------------------|
190
+ | `backupsDir` | `string` | `'backups'` | Directory for backups from the MI server |
191
+
192
+ ### `devPanel` Dev panel appearance
193
+
194
+ | Field | Type | Default | Description |
195
+ |------------|-----------------------------------------------------------------|------------------|-----------------------------------------------------------------------------|
196
+ | `position` | `'top-left' \| 'top-right' \| 'bottom-left' \| 'bottom-right'` | `'bottom-right'` | Screen corner the dev panel is anchored to |
197
+ | `hidden` | `boolean` | `false` | Fully hide the panel. Restore in the browser with `?pp-dev-panel=show` |
198
+ | `autoHide` | `boolean` | `false` | Panel slides behind the screen edge leaving a thin strip; hover reveals it |
199
+
200
+ These values are **defaults**: the panel itself has a settings popover (gear icon) with a corner
201
+ picker, an auto-hide toggle and a hide button, and the panel can be dragged by its grip handle and
202
+ snapped to any corner. Runtime choices are persisted in the browser's `localStorage`
203
+ (`pp-dev-info-position`, `pp-dev-info-auto-hide`, `pp-dev-info-hidden`) and take precedence over
204
+ the config until "Reset to config defaults" is clicked in the popover. The URL params
205
+ `?pp-dev-panel=show` / `?pp-dev-panel=hide` set a persistent override too — handy for restoring a
206
+ hidden panel or taking clean screenshots. Note that `localStorage` is origin-scoped, so overrides
207
+ apply to every pp-dev app served on the same host and port. See the [Dev Panel](#dev-panel)
208
+ section for the full feature description.
209
+
210
+ ### Validation
211
+
212
+ pp-dev validates your config at startup and reports problems clearly:
213
+
214
+ | Condition | Behaviour |
215
+ |---|---|
216
+ | `mi.include` set + `mi.mode !== 'standalone'` | error |
217
+ | `mi.url` missing + `mi.mode === 'embedding'` or `app.type === 'template'` | error |
218
+ | `mi.url` missing + `mi.mode === 'standalone'` + `app.type === 'page'` | warning |
219
+ | `app.type === 'template'` without `app.id` | error |
220
+ | `app.type === 'page'` + `mi.mode === 'standalone'` without `app.id` | error |
221
+ | `app.name` missing and no `package.json#name` | error |
222
+ | `devPanel.position` not one of the four corners | error |
223
+
224
+ ### Environment Variables
225
+
226
+ | Variable | Description |
227
+ |-------------------|-------------------------------------------------|
228
+ | `MI_ACCESS_TOKEN` | Default value for `mi.token` when not set in config |
332
229
 
333
230
  **Local development and network exposure**: pp-dev is a **development** tool. It assumes a trusted machine. Personal access tokens and session helpers are still sensitive: they can authenticate to your Metric Insights backend as you.
334
231
 
335
- - Prefer binding the dev server to **`localhost`** when you do not need access from other devices. If you use **`--host`** (or equivalent) so the app listens on **all interfaces** or your LAN, other machines on the same network can reach the dev server and its dev-only routes (for example the in-browser token login flow). Treat that like exposing credentials: use only on networks you trust, or restrict access with your OS firewall.
336
- - Do not commit real tokens; keep them in `.env` (gitignored) or your secret store. Avoid sharing screen recordings or logs that contain `MI_ACCESS_TOKEN` or bearer tokens.
337
-
338
- ### Enhanced Authentication (v0.11.0+)
339
-
340
- The new authentication system in v0.11.0 provides:
341
-
342
- - **Automatic Environment Loading**: Automatically loads `MI_*` environment variables from `.env` files
343
- - **Token Validation**: Enhanced token validation and error handling
344
- - **Secure Headers**: Automatic header management for authenticated requests
345
- - **Connection Pooling**: Optimized HTTP connections for better performance
232
+ - Prefer binding the dev server to **`localhost`** when you do not need access from other devices. If you use **`--host`** (or equivalent) so the app listens on **all interfaces** or your LAN, other machines on the same network can reach the dev server and its dev-only routes. Treat that like exposing credentials: use only on networks you trust, or restrict access with your OS firewall.
233
+ - Do not commit real tokens; keep them in `.env` (gitignored) or your secret store.
346
234
 
347
- **Supported Environment Variables**:
235
+ ## Migrating from 0.x
348
236
 
349
- - `MI_ACCESS_TOKEN`: Personal access token for authentication
350
- - `MI_BACKEND_URL`: Alternative to `backendBaseURL` in config
351
- - `MI_APP_ID`: Alternative to `appId` in config
352
-
353
- **Automatic Loading**: pp-dev automatically detects and loads these variables from your project's `.env` file:
237
+ Run the built-in codemod to upgrade your config automatically:
354
238
 
355
239
  ```bash
356
- # .env
357
- MI_ACCESS_TOKEN=your_personal_access_token
358
- MI_BACKEND_URL=https://mi.company.com
359
- MI_APP_ID=123
240
+ npx @metricinsights/pp-dev migrate
360
241
  ```
361
242
 
243
+ Options:
244
+
245
+ | Option | Description |
246
+ |---|---|
247
+ | `[config]` | Path to config file (auto-detected if omitted) |
248
+ | `--dry-run` | Preview the migrated output without writing |
249
+ | `--format ts\|js\|json` | Override output format |
250
+ | `--output <file>` | Write to a specific file instead of overwriting |
251
+ | `--no-backup` | Skip creating a `.bak` backup of the original |
252
+
253
+ The command detects flat 0.x configs and legacy `pp-watch.config.*` files, converts them to the new grouped format, and writes a `.bak` backup before overwriting.
254
+
255
+ **Field mapping** (0.x → 1.0):
256
+
257
+ | 0.x | 1.0 |
258
+ |---|---|
259
+ | `backendBaseURL` | `mi.url` |
260
+ | `personalAccessToken` | `mi.token` |
261
+ | `miHudLess: true` | `mi.mode: 'standalone'` |
262
+ | `miHudLess: false` | `mi.mode: 'embedding'` |
263
+ | `integrateMiTopBar: true` | `mi.mode: 'standalone'`, `mi.include: 'top-bar'` |
264
+ | `integrateMiTopBar: { addSharedComponentsScripts: true }` | `mi.include: 'shared-components'` |
265
+ | `v7Features: true` | `mi.apiVersion: 7` |
266
+ | `v7Features: false` | `mi.apiVersion: 6` |
267
+ | `appId` / `portalPageId` | `app.id` |
268
+ | `templateName` | `app.name` (usually omit — auto-resolved from `package.json#name`) |
269
+ | `templateLess: true` | `app.type: 'page'` |
270
+ | `templateLess: false` | `app.type: 'template'` |
271
+ | `enableProxyCache` | `proxy.cache` |
272
+ | `proxyCacheTTL` | `proxy.cacheTtl` |
273
+ | `disableSSLValidation: true` | `proxy.tls.allowSelfSigned: true` |
274
+ | `distZip` | `build.zip` |
275
+ | `versionPlugin` | `build.versionFile` |
276
+ | `imageOptimizer` | `build.imageOptimisations` |
277
+ | `outDir` | `build.outDir` |
278
+ | `syncBackupsDir` | `sync.backupsDir` |
279
+
362
280
  ## CLI Commands
363
281
 
364
282
  ### Global Options
@@ -388,14 +306,11 @@ pp-dev [root] [options]
388
306
 
389
307
  **Development Shortcuts**:
390
308
 
391
- - `p` - Start/stop performance profiler (v0.11.0+)
392
309
  - `l` - Proxy re-login (refresh authentication)
393
310
  - `r` - Restart dev server
394
311
  - `u` - Show server URLs
395
312
  - `q` - Quit dev server
396
313
 
397
- **Performance Profiling**: Use the `p` shortcut to start/stop the Node.js profiler for detailed performance analysis during development.
398
-
399
314
  ### Next.js Development
400
315
 
401
316
  ```bash
@@ -423,6 +338,20 @@ pp-dev build [options]
423
338
  | `--assetsDir <dir>` | `assets` | Assets directory under outDir |
424
339
  | `--changelog [file]` | `true` | Create changelog file |
425
340
 
341
+ ### Migration
342
+
343
+ ```bash
344
+ pp-dev migrate [config] [options]
345
+ ```
346
+
347
+ | Option | Description |
348
+ |---|---|
349
+ | `[config]` | Config file to migrate (auto-detected if omitted) |
350
+ | `--dry-run` | Preview output without writing |
351
+ | `--format ts\|js\|json` | Output format |
352
+ | `--output <file>` | Write to a specific path |
353
+ | `--no-backup` | Skip `.bak` backup |
354
+
426
355
  ### Changelog Generation
427
356
 
428
357
  ```bash
@@ -454,7 +383,7 @@ pp-dev generate-icon-font [source] [destination] [options]
454
383
 
455
384
  ## Next.js Integration
456
385
 
457
- 1. Add pp-dev configuration to your project root
386
+ 1. Add a `pp-dev.config.ts` to your project root
458
387
  2. Update `package.json` scripts:
459
388
  ```json
460
389
  {
@@ -478,6 +407,109 @@ module.exports = withPPDev({
478
407
 
479
408
  For custom build configuration, create a `vite.config` file. See [Vite Configuration](https://vitejs.dev/config/) for details.
480
409
 
410
+ ## Dev Panel
411
+
412
+ pp-dev injects a floating dev panel into every served page. It shows the package name and version, the backend URL, the template mode and the App ID, and hosts the template **Sync** button. Since 1.0 the panel is fully repositionable and can be hidden.
413
+
414
+ ### Position
415
+
416
+ The panel can be anchored to any of the four screen corners (default: bottom-right). Three ways to move it:
417
+
418
+ - **Drag & snap** — grab the grip handle (six dots on the panel's left side) and drag; on release the panel snaps to the nearest corner. Dragging works across iframes and is cancelled with <kbd>Escape</kbd>.
419
+ - **Settings popover** — click the gear icon and pick a corner in the 2×2 grid.
420
+ - **Config default** — set `devPanel.position` in `pp-dev.config` (see below).
421
+
422
+ The minimize arrow, the panel's shadow, rounded corner and slide direction all mirror automatically for left/top placements. Sync notification popups stack from the screen edge opposite the panel so they never cover it.
423
+
424
+ ### Auto-hide
425
+
426
+ Toggle **Auto-hide** in the settings popover (or set `devPanel.autoHide: true`). The panel slides behind the nearest screen edge leaving a 4px accent strip; hovering the strip for ~300 ms slides it out, and it hides again ~500 ms after the pointer leaves. Keyboard focus inside the panel keeps it revealed. While auto-hide is active the minimize arrow acts as a **pin** button that returns the panel to normal mode.
427
+
428
+ ### Hiding and restoring
429
+
430
+ **Hide panel** in the settings popover (or `devPanel.hidden: true`) removes the panel from view entirely. To bring it back, open any page with `?pp-dev-panel=show` in the URL — the override persists across reloads. The symmetric `?pp-dev-panel=hide` hides it, which is handy for demos and clean screenshots.
431
+
432
+ ### State persistence
433
+
434
+ Runtime choices are saved in the browser's `localStorage` (`pp-dev-info-position`, `pp-dev-info-auto-hide`, `pp-dev-info-hidden`) and take precedence over config values. **Reset to config defaults** in the settings popover clears all overrides. Storage is origin-scoped: overrides apply to every pp-dev app served on the same host and port, and a Metric Insights page that clears origin storage will reset them to config defaults.
435
+
436
+ ### Configuration
437
+
438
+ ```typescript
439
+ // pp-dev.config.ts
440
+ export default defineConfig({
441
+ devPanel: {
442
+ position: 'bottom-right', // 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right'
443
+ hidden: false, // hide the panel entirely (restore with ?pp-dev-panel=show)
444
+ autoHide: false, // slide behind the screen edge, reveal on hover
445
+ },
446
+ });
447
+ ```
448
+
449
+ See the [`devPanel` option reference](#devpanel--dev-panel-appearance) for details.
450
+
451
+ ## Request Inspector
452
+
453
+ pp-dev includes a built-in request inspector that captures every proxied and locally-served HTTP request made during development. It is enabled by default.
454
+
455
+ ### Web UI
456
+
457
+ Open `http://localhost:3000/@pp-dev/inspector` (replace port as needed) in any browser tab while the dev server is running. The UI shows:
458
+
459
+ - A scrollable list of captured requests with method, status, source badge, and timing
460
+ - Full request and response headers, with a **Copy** button per section
461
+ - Request and response bodies rendered as text for JSON/HTML/CSS/plain-text content types, with **Copy** and **Save** buttons
462
+ - Binary bodies (images, fonts, archives) show metadata only and offer a **Save** button
463
+ - A **Clear** button in the top-right removes all stored entries
464
+
465
+ ### Source badges
466
+
467
+ Each request in the list displays a colored letter badge to the left of the HTTP status:
468
+
469
+ | Badge | Color | Meaning |
470
+ |-------|--------|----------------------------------------------|
471
+ | `P` | Purple | Forwarded to the upstream Metric Insights server (proxy) |
472
+ | `C` | Amber | Served from the local proxy cache |
473
+ | `L` | Grey | Served locally (static file, dev route, etc.) |
474
+
475
+ ### Console banner
476
+
477
+ The dev panel script prints a one-line banner to the browser DevTools console when the page loads:
478
+
479
+ ```
480
+ pp-dev 🔍 Request Inspector → http://localhost:3000/@pp-dev/inspector
481
+ ```
482
+
483
+ The message persists in DevTools history so it is visible even when you open the console after the page has loaded.
484
+
485
+ ### REST API
486
+
487
+ The inspector also exposes a lightweight JSON API, useful for tooling and AI agents:
488
+
489
+ | Method | Path | Description |
490
+ |----------|-------------------------|---------------------------------------------|
491
+ | `GET` | `/@api/requests` | Paginated list of captured requests (metadata only, no bodies) |
492
+ | `GET` | `/@api/requests/:id` | Full entry including captured request/response bodies (base64-encoded) |
493
+ | `GET` | `/@api/requests/stats` | Store stats: entry count, memory usage, limits |
494
+ | `DELETE` | `/@api/requests` | Clear all stored entries |
495
+
496
+ `GET /@api/requests` accepts `?limit=` (default 50) and `?offset=` query parameters for pagination.
497
+
498
+ Bodies in `GET /@api/requests/:id` are returned as base64 strings in `requestBody` / `responseBody` fields alongside `requestContentType` / `responseContentType`. A `*Truncated: true` flag indicates the body exceeded `captureLimit` and was cut off.
499
+
500
+ ### Configuration
501
+
502
+ ```typescript
503
+ // pp-dev.config.ts
504
+ export default defineConfig({
505
+ inspector: {
506
+ enabled: true, // set to false to disable entirely
507
+ maxMemory: 100 * 1024 * 1024, // evict oldest entries above 100 MB
508
+ captureLimit: 10 * 1024 * 1024, // capture at most 10 MB per body
509
+ },
510
+ });
511
+ ```
512
+
481
513
  ## Troubleshooting
482
514
 
483
515
  ### Common Issues
@@ -510,8 +542,8 @@ If you encounter an error like "Next.js is required but not available":
510
542
  #### Version Compatibility
511
543
 
512
544
  - **pp-dev** requires Next.js version 15 or higher (but less than 17)
513
- - **Node.js** version 20 or higher is required
514
- - **TypeScript** version 4.2 or higher is supported
545
+ - **Node.js** version 24 or higher is required
546
+ - **TypeScript** version 5 or higher is recommended
515
547
 
516
548
  ### Getting Help
517
549