@progen-labs/spectra 0.4.1 → 0.5.0
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.
- package/README.md +56 -8
- package/bin/spectra.js +8 -4
- package/dist/assets/index-mtYxDBW7.js +11 -0
- package/dist/assets/index-z14kjW8r.css +1 -0
- package/dist/index.html +2 -2
- package/package.json +2 -2
- package/schema/config.schema.json +50 -0
- package/server/analysis/findings.js +18 -9
- package/server/cli.js +10 -4
- package/server/explore/evaluate-cli.js +14 -4
- package/server/explore/evaluate.js +3 -1
- package/server/pdf/template.js +2 -2
- package/server/probe.browser.js +85 -14
- package/server/project-config.js +17 -5
- package/server/recorder.js +154 -15
- package/server/signin.js +524 -2
- package/server/test-signin.js +179 -0
- package/shared/compare.js +9 -9
- package/shared/snapshot.js +1 -1
- package/src/App.jsx +1 -1
- package/src/components/CompareResults.jsx +1 -1
- package/src/components/ControlBar.jsx +83 -60
- package/src/components/EvaluationPanel.jsx +1 -1
- package/src/components/FilePanel.jsx +2 -2
- package/src/components/PageMap.jsx +26 -22
- package/src/components/ReactPanel.jsx +2 -4
- package/src/components/SignIn.jsx +291 -0
- package/src/components/Vitals.jsx +1 -1
- package/src/framework.js +12 -0
- package/src/heat.js +3 -3
- package/src/styles.css +91 -0
- package/dist/assets/index-DY8VmG9y.js +0 -11
- package/dist/assets/index-Dx1YSFIx.css +0 -1
package/README.md
CHANGED
|
@@ -11,10 +11,12 @@ exact function, file and line, the evidence, and a suggested fix.
|
|
|
11
11
|
Deep component-level attribution for **React, Next.js, Vue and Angular** (component names, render counts
|
|
12
12
|
and per-component render/change-detection time; source files too, where the framework exposes them). For
|
|
13
13
|
**Svelte and any other build**, a source-mapped generic profile still pinpoints the slow files and
|
|
14
|
-
functions.
|
|
15
|
-
|
|
14
|
+
functions. The framework is detected in the page itself, so it is right wherever you start Spectra from.
|
|
15
|
+
Apps behind a login work too: Spectra [signs in first](#behind-a-login), with every kind of login. A
|
|
16
|
+
[Progen Labs](https://github.com/progen-labs) project — independent, open source, no telemetry, no account
|
|
17
|
+
required.
|
|
16
18
|
|
|
17
|
-
**Watch the
|
|
19
|
+
**Watch the demo (2½ minutes):** [progen-labs.github.io/website/#spectra/demo](https://progen-labs.github.io/website/#spectra/demo).
|
|
18
20
|
|
|
19
21
|
**Documentation:** the full guide, with annotated screenshots of every screen, is at
|
|
20
22
|
[progen-labs.github.io/website](https://progen-labs.github.io/website/#spectra/docs/introduction).
|
|
@@ -53,7 +55,7 @@ With no `--url`, Spectra:
|
|
|
53
55
|
Automation: 8/8 golden paths passed.
|
|
54
56
|
```
|
|
55
57
|
|
|
56
|
-
Then open the visual dashboard — ranked culprits,
|
|
58
|
+
Then open the visual dashboard — ranked culprits, component re-renders, long tasks, the golden-path matrix,
|
|
57
59
|
**PDF export** and **commit-to-commit compare**:
|
|
58
60
|
|
|
59
61
|
```bash
|
|
@@ -87,13 +89,47 @@ spectra --version
|
|
|
87
89
|
| `--command "<cmd>"` | Override the dev-server command |
|
|
88
90
|
| `--boot-timeout <s>` | How long to wait for the dev server (default 60) |
|
|
89
91
|
| `--headed` | Show the browser window |
|
|
90
|
-
| `--
|
|
92
|
+
| `--login-url <url>`, `--login-user <name>` | Sign in first: the login page and the username; the password comes from `SPECTRA_LOGIN_PASSWORD` (see [Behind a login](#behind-a-login)) |
|
|
93
|
+
| `--login <method>` | `form`, `link`, `http`, `token` or `manual` (you sign in in the Chrome window); guessed when left out |
|
|
91
94
|
| `--quick` | One page-load profile instead of the golden-path suite: the fast loop |
|
|
92
95
|
| `--runs <n>` | Record n times and report the median (with `--quick` or `--mode`) |
|
|
93
96
|
| `--mode live\|load` | Classic single-page profile instead of the golden-path suite |
|
|
94
97
|
| `--json` | Print a machine-readable result on stdout (tables go to stderr) |
|
|
95
98
|
| `--out <file>` | Also write that result to a file (an input for `compare`) |
|
|
96
|
-
| `--config <file>` | Budgets file (default: `spectra.config.json` in your project) |
|
|
99
|
+
| `--config <file>` | Budgets and sign-in file (default: `spectra.config.json` in your project) |
|
|
100
|
+
|
|
101
|
+
## Behind a login
|
|
102
|
+
|
|
103
|
+
Most production frontends sit behind a login, and the Chrome Spectra launches starts signed out. Tell
|
|
104
|
+
Spectra how your app signs in and it signs in before it records, so the login never shows up in a
|
|
105
|
+
measurement:
|
|
106
|
+
|
|
107
|
+
| Method | For |
|
|
108
|
+
| --- | --- |
|
|
109
|
+
| **Login form** (`form`) | A username and password on your app's login page or its identity provider (OAuth, OpenID Connect, SAML): one or two steps, forms that render late, in iframes or web components, behind a "Sign in" button, with **authenticator codes** from a TOTP secret |
|
|
110
|
+
| **I'll sign in myself** (`manual`) | SMS or email codes, push approvals, passkeys, CAPTCHAs: Chrome opens on the login page and Spectra waits for you |
|
|
111
|
+
| **Browser prompt** (`http`) | HTTP Basic or Digest, common on staging servers |
|
|
112
|
+
| **Token or cookie** (`token`) | A header (sent only to your app's origin), cookies or localStorage entries |
|
|
113
|
+
| **Sign-in link** (`link`) | A URL that signs in by itself, such as a dev-only auto-login |
|
|
114
|
+
|
|
115
|
+
In the dashboard, turn on **My app needs a sign-in** under **Page to profile**. On the command line:
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
SPECTRA_LOGIN_PASSWORD="$TEST_PASSWORD" npx spectra performance --login-url http://localhost:3000/login --login-user demo@example.com
|
|
119
|
+
npx spectra performance --login manual --login-url https://staging.example.com/login
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
Or once, for every command, the VS Code extension, the MCP server and `spectra fix`, in `spectra.config.json`:
|
|
123
|
+
|
|
124
|
+
```json
|
|
125
|
+
{ "signIn": { "method": "form", "url": "http://localhost:3000/login", "username": "demo@example.com" } }
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
Secrets come only from the dashboard or the environment (`SPECTRA_LOGIN_PASSWORD`, `SPECTRA_LOGIN_TOTP_SECRET`,
|
|
129
|
+
`SPECTRA_LOGIN_HEADER`, `SPECTRA_LOGIN_COOKIES`, `SPECTRA_LOGIN_STORAGE`). They stay in memory: never written
|
|
130
|
+
to disk, a report, a log or an error message, and `spectra.config.json` refuses them. Spectra never solves
|
|
131
|
+
CAPTCHAs. Use a test account where you can. See
|
|
132
|
+
[Signing in](https://progen-labs.github.io/website/#spectra/docs/signing-in), with a short video.
|
|
97
133
|
|
|
98
134
|
## Measure, change, verify
|
|
99
135
|
|
|
@@ -268,7 +304,8 @@ See the [VS Code guide](https://progen-labs.github.io/website/#spectra/docs/vsco
|
|
|
268
304
|
Auto-exploration never triggers destructive actions. Spectra detects controls that would mutate state —
|
|
269
305
|
anything labelled delete / pay / checkout / log out, logout links, and `POST`/`PUT`/`DELETE` form submits —
|
|
270
306
|
and **skips** them unless you explicitly allow them. Form fields are filled with synthetic values; GET
|
|
271
|
-
searches and navigations are fair game.
|
|
307
|
+
searches and navigations are fair game. If a session expires and the app sends Spectra back to its login page,
|
|
308
|
+
Spectra signs in again.
|
|
272
309
|
|
|
273
310
|
## Where results go
|
|
274
311
|
|
|
@@ -299,4 +336,15 @@ and report generation work.
|
|
|
299
336
|
|
|
300
337
|
## License
|
|
301
338
|
|
|
302
|
-
MIT © Progen Labs
|
|
339
|
+
MIT © 2026 Sourav Debnath (Progen Labs)
|
|
340
|
+
|
|
341
|
+
<p align="center">
|
|
342
|
+
<a href="https://progen-labs.github.io/website/">
|
|
343
|
+
<picture>
|
|
344
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://progen-labs.github.io/website/brand/progen-seed-mark.svg">
|
|
345
|
+
<img alt="Progen Labs" src="https://progen-labs.github.io/website/brand/progen-seed-mark-light.svg" height="72">
|
|
346
|
+
</picture>
|
|
347
|
+
</a>
|
|
348
|
+
<br>
|
|
349
|
+
<sub>Spectra is a <a href="https://progen-labs.github.io/website/">Progen Labs</a> project: independent, open source, always free.</sub>
|
|
350
|
+
</p>
|
package/bin/spectra.js
CHANGED
|
@@ -21,6 +21,7 @@ import path from 'node:path';
|
|
|
21
21
|
import { fileURLToPath } from 'node:url';
|
|
22
22
|
import { bootDevServer } from '../server/explore/boot.js';
|
|
23
23
|
import { detectFramework } from '../server/framework.js';
|
|
24
|
+
import { SIGN_IN_HELP } from '../server/signin.js';
|
|
24
25
|
|
|
25
26
|
const here = path.dirname(fileURLToPath(import.meta.url));
|
|
26
27
|
const PKG_ROOT = path.resolve(here, '..');
|
|
@@ -65,7 +66,8 @@ performance options:
|
|
|
65
66
|
--command "<cmd>" Override the dev-server command (default: your npm dev script)
|
|
66
67
|
--boot-timeout <s> How long to wait for the dev server (default 60)
|
|
67
68
|
--headed Show the browser window
|
|
68
|
-
|
|
69
|
+
|
|
70
|
+
${SIGN_IN_HELP}
|
|
69
71
|
|
|
70
72
|
quick single-page profile (opt in with --quick, --mode or --scenario):
|
|
71
73
|
--quick One page-load profile (about 15 s): the fast loop
|
|
@@ -80,7 +82,7 @@ output and checks (any performance run):
|
|
|
80
82
|
--json Print a machine-readable result on stdout (progress and
|
|
81
83
|
tables go to stderr)
|
|
82
84
|
--out <file> Also write that result to a file (input for compare)
|
|
83
|
-
--config <file> Budgets file (default: spectra.config.json
|
|
85
|
+
--config <file> Budgets and sign-in file (default: spectra.config.json)
|
|
84
86
|
|
|
85
87
|
compare options:
|
|
86
88
|
<before> <after> Each: a report id, a report file, a --out result file,
|
|
@@ -88,8 +90,9 @@ compare options:
|
|
|
88
90
|
--json, --out <file> As above
|
|
89
91
|
--fail-on-regression Exit with code 2 when a key metric got worse
|
|
90
92
|
|
|
91
|
-
Budgets (spectra.config.json in your project root):
|
|
92
|
-
{ "budgets": { "tbtMs": 200, "lcpMs": 2500, "cls": 0.1, "criticalFindings": 0 }
|
|
93
|
+
Budgets and sign-in (spectra.config.json in your project root):
|
|
94
|
+
{ "budgets": { "tbtMs": 200, "lcpMs": 2500, "cls": 0.1, "criticalFindings": 0 },
|
|
95
|
+
"signIn": { "method": "form", "url": "http://localhost:3000/login", "username": "me@example.com" } }
|
|
93
96
|
|
|
94
97
|
Exit codes: 0 done · 1 could not run · 2 over budget / regression
|
|
95
98
|
|
|
@@ -102,6 +105,7 @@ Examples:
|
|
|
102
105
|
spectra compare before.json after.json # did the change help?
|
|
103
106
|
spectra fix --max-fixes 3 # let an agent fix them, verified
|
|
104
107
|
spectra performance --json | jq .summary # pipe it anywhere
|
|
108
|
+
SPECTRA_LOGIN_PASSWORD=… spectra performance --login-url http://localhost:3000/login --login-user me@example.com
|
|
105
109
|
`;
|
|
106
110
|
|
|
107
111
|
// What a terminate signal must clean up: the running script and a dev server
|