Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ Full-page screenshots live under [`tests/visual/`](tests/visual/) and use [`play

By default tests use **headless** Chromium. Use **`npm run test:visual:headed`** to watch the browser.

[`tests/visual/home-helpers.js`](tests/visual/home-helpers.js) waits for the preview canvas, for `.loading` to disappear on the preview panels, and for paint frames before Argos screenshots (with a best-effort **`networkidle`** wait). Without **`ARGOS_TOKEN`**, navigation and layout still run but Argos capture/upload is skipped. Override the origin with **`PLAYWRIGHT_TEST_BASE_URL`** (see [`tests/visual/home.spec.js`](tests/visual/home.spec.js)).
[`tests/visual/home-helpers.ts`](tests/visual/home-helpers.ts) waits for the preview canvas, for `.loading` to disappear on the preview panels, and for paint frames before Argos screenshots (with a best-effort **`networkidle`** wait). Without **`ARGOS_TOKEN`**, navigation and layout still run but Argos capture/upload is skipped. Override the origin with **`PLAYWRIGHT_TEST_BASE_URL`** (see [`tests/visual/home.spec.js`](tests/visual/home.spec.js)).

**Unit and component specs (Mocha + Chai)**

Expand Down
8 changes: 4 additions & 4 deletions PERFORMANCE_PROFILING.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,16 @@ ZIP generation uses **`createZipExportProfiler`** in `sources/performance-profil
- **Split-by-item sheets** does not add `metadata.json`; use the console table and Performance marks when DEBUG is on.

- **Automation / agents:** After each export, `zipGenerateBlobWithProfiler` stores the latest `toMetadata()` snapshot on **`window.__lastZipExportProfile`** and accumulates **`window.__zipExportProfiles`** keyed by `exportKind`.
- **Scripts:** **`npm run profile:zip`** or **`npm run profile:zip:quick`** — run headless Chromium with the default URL hash from **`scripts/zip/zip-profile-default-hash.js`** (full outfit + weapon so custom layers show up in profiles).
- **Scripts:** **`npm run profile:zip`** or **`npm run profile:zip:quick`** — run headless Chromium with the default URL hash from **`scripts/zip/zip-profile-default-hash.ts`** (full outfit + weapon so custom layers show up in profiles).
- **Output:** **`tmp/zip-export-profile.json`** or **`tmp/zip-export-profile-quick.json`** (gitignored), and the same JSON on stdout.
- **Flags:** **`--only <kind>`** (e.g. **`npm run profile:zip -- --only splitAnimations`**) with kinds `splitAnimations`, `splitItemSheets`, `splitItemAnimations`, `individualFrames`. **`--out <path>`** overrides the JSON path. **`--quick`** uses a fake JSZip (faster; small **`generateZip`** time); default mode uses real JSZip.
- **Setup:** Playwright browsers **`npx playwright install`**. Server port **`ZIP_PROFILE_PORT`** (default **`9877`**). Entry points: **`scripts/zip/zip-export-profile.js`**, **`scripts/zip/zip-export-profile-runner.html`**.
- **`serve` and query strings:** Redirects may drop **`?`** params on the runner URL, so **`--quick`**, **`--only`**, and the default hash are injected via **`window.__ZIP_PROFILE_OPTS__`** before load (Playwright `addInitScript`). Opening the runner manually: preserve the query when possible, or add **`#`** plus the same hash as in **`zip-profile-default-hash.js`** (or rely on that module’s default in the runner).
- **Setup:** Playwright browsers **`npx playwright install`**. Server port **`ZIP_PROFILE_PORT`** (default **`9877`**). Entry points: **`scripts/zip/zip-export-profile.ts`**, **`scripts/zip/zip-export-profile-runner.html`**.
- **`serve` and query strings:** Redirects may drop **`?`** params on the runner URL, so **`--quick`**, **`--only`**, and the default hash are injected via **`window.__ZIP_PROFILE_OPTS__`** before load (Playwright `addInitScript`). Opening the runner manually: preserve the query when possible, or add **`#`** plus the same hash as in **`zip-profile-default-hash.ts`** (or rely on that module’s default in the runner).

- **Baseline snapshots (local, gitignored):**
- **`npm run profile:zip:baseline`** → **`tmp/baseline-zip-export-profile.json`**
- **`npm run profile:zip:baseline:quick`** → **`tmp/baseline-zip-export-profile-quick.json`**
- Compare runs: **`npm run diff:zip-profile -- tmp/baseline-zip-export-profile.json tmp/zip-export-profile.json`**, or **`node scripts/zip/diff-zip-profile.js --before … --after …`**, for per-phase deltas on the same machine/fixture.
- Compare runs: **`npm run diff:zip-profile -- tmp/baseline-zip-export-profile.json tmp/zip-export-profile.json`**, or **`node scripts/zip/diff-zip-profile.ts --before … --after …`**, for per-phase deltas on the same machine/fixture.

Query param note: only **`?debug=true`** and **`?debug=false`** are recognized as overrides (`sources/utils/debug.ts`). Other values (e.g. `?debug=1`) fall through to localhost detection.

Expand Down
10 changes: 5 additions & 5 deletions codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ ignore:
- scripts/computed-style/**
- scripts/imageProcessing/**
- scripts/zip/**
- scripts/fixture-builder.js
- scripts/generate-purgecss-safelist-hints.js
- scripts/issue382-golden-playwright.js
- scripts/update_sheet_definitions.js
- scripts/generateSources/source_inputs_fingerprint.js
- scripts/fixture-builder.ts
- scripts/generate-purgecss-safelist-hints.ts
- scripts/issue382-golden-playwright.ts
- scripts/update_sheet_definitions.ts
- scripts/generateSources/source_inputs_fingerprint.ts
- vite/**
- vite.config.js
- testem.cjs
Expand Down
24 changes: 23 additions & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export default [
ignores: [
// Built by Vite to dist/item-metadata.js (gitignored)
"dist/**",
// Generated by scripts/fixture-builder.js (see script header).
// Generated by scripts/fixture-builder.ts (see script header).
"tests/fixtures/**",
"tmp/**",
"spritesheets/**",
Expand Down Expand Up @@ -112,6 +112,17 @@ export default [
},
rules: commonRulesTs,
},
{
files: ["scripts/zip/zip-export-profile-runner.ts"],
languageOptions: {
globals: {
...globals.browser,
...globals.es2021,
m: "readonly",
},
},
rules: commonRulesTs,
},
{
files: ["tests/**/*.js"],
ignores: ["tests/visual/**"],
Expand Down Expand Up @@ -165,6 +176,17 @@ export default [
},
},
},
{
files: ["tests/visual/**/*.ts"],
languageOptions: {
globals: {
...globals.node,
...globals.browser,
...globals.es2021,
},
},
rules: commonRulesTs,
},
{
files: ["**/*.cjs"],
languageOptions: {
Expand Down
20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,16 @@
"test:browser:coverage": "rimraf coverage/browser && VITE_COVERAGE=true node ./node_modules/testem/testem.js ci",
"test:visual": "playwright test",
"test:visual:headed": "playwright test --headed",
"fixture:issue382": "node scripts/fixture-builder.js tests/fixtures/issue-382/issue-382-selections.json",
"profile:zip": "node scripts/zip/zip-export-profile.js",
"profile:zip:quick": "node scripts/zip/zip-export-profile.js --quick",
"profile:zip:baseline": "node scripts/zip/zip-export-profile.js --out tmp/baseline-zip-export-profile.json",
"profile:zip:baseline:quick": "node scripts/zip/zip-export-profile.js --quick --out tmp/baseline-zip-export-profile-quick.json",
"diff:zip-profile": "node scripts/zip/diff-zip-profile.js",
"compute-style-dump": "node scripts/computed-style/dump-computed-styles.js",
"compute-style-dump:mobile": "node scripts/computed-style/dump-computed-styles.js --preset mobile",
"compute-style-diff-all": "node scripts/computed-style/computed-style-diff-all.js",
"compute-style-diff-all:preview-ports": "node scripts/computed-style/computed-style-diff-all.js --url-a http://localhost:4176 --url-b http://localhost:4177",
"fixture:issue382": "node scripts/fixture-builder.ts tests/fixtures/issue-382/issue-382-selections.json",
"profile:zip": "node scripts/zip/zip-export-profile.ts",
"profile:zip:quick": "node scripts/zip/zip-export-profile.ts --quick",
"profile:zip:baseline": "node scripts/zip/zip-export-profile.ts --out tmp/baseline-zip-export-profile.json",
"profile:zip:baseline:quick": "node scripts/zip/zip-export-profile.ts --quick --out tmp/baseline-zip-export-profile-quick.json",
"diff:zip-profile": "node scripts/zip/diff-zip-profile.ts",
"compute-style-dump": "node scripts/computed-style/dump-computed-styles.ts",
"compute-style-dump:mobile": "node scripts/computed-style/dump-computed-styles.ts --preset mobile",
"compute-style-diff-all": "node scripts/computed-style/computed-style-diff-all.ts",
"compute-style-diff-all:preview-ports": "node scripts/computed-style/computed-style-diff-all.ts --url-a http://localhost:4176 --url-b http://localhost:4177",
"lockfile:fix": "bash scripts/fix-lockfile-after-rebase.sh"
},
"dependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
* Verbose stderr: `LPC_DEBUG_COMPUTED_STYLE=1` (phase timings + browser console in dump shared).
*
* Usage:
* node scripts/computed-style-diff-all.js
* node scripts/computed-style-diff-all.js --out-dir /tmp/cmp --url-a http://127.0.0.1:4174 --url-b http://127.0.0.1:4175
* node scripts/computed-style-diff-all.js --no-fail-on-diff # exit 0 even when diffs exist
* node scripts/computed-style/computed-style-diff-all.ts
* node scripts/computed-style/computed-style-diff-all.ts --out-dir /tmp/cmp --url-a http://127.0.0.1:4174 --url-b http://127.0.0.1:4175
* node scripts/computed-style/computed-style-diff-all.ts --no-fail-on-diff # exit 0 even when diffs exist
*/

import fs from "node:fs";
Expand All @@ -30,7 +30,7 @@ import {
COMPUTED_STYLE_DUMP_PAGES,
dumpComputedStylesForUrl,
lpcComputedStyleLog,
} from "./computed-style-dump-shared.js";
} from "./computed-style-dump-shared.ts";

const PRESET_ORDER = [
"mobile",
Expand All @@ -41,10 +41,18 @@ const PRESET_ORDER = [
"tabletLong",
"mediumDesktopLong",
"hugeDesktopLong",
];

function parseArgs(argv) {
const out = {
] as const;

type DiffCliArgs = {
urlA: string;
urlB: string;
outDir: string;
failOnDiff: boolean;
help: boolean;
};

function parseArgs(argv: string[]): DiffCliArgs {
const out: DiffCliArgs = {
urlA: process.env.COMPUTED_STYLE_URL_A ?? "http://127.0.0.1:4174",
urlB: process.env.COMPUTED_STYLE_URL_B ?? "http://127.0.0.1:4175",
outDir: path.join(process.cwd(), "computed-style-diff-output"),
Expand All @@ -68,9 +76,9 @@ function parseArgs(argv) {
return out;
}

function printHelp() {
function printHelp(): void {
console.error(`Usage:
node scripts/computed-style-diff-all.js [options]
node scripts/computed-style/computed-style-diff-all.ts [options]

Options:
--url-a <url> First site (default: $COMPUTED_STYLE_URL_A or http://127.0.0.1:4174)
Expand All @@ -87,7 +95,7 @@ Writes per preset and page (${COMPUTED_STYLE_DUMP_PAGES.join(", ")}):
`);
}

function unifiedDiff(pathA, pathB) {
function unifiedDiff(pathA: string, pathB: string): string {
try {
return execFileSync("diff", ["-u", pathA, pathB], {
encoding: "utf8",
Expand All @@ -97,7 +105,9 @@ function unifiedDiff(pathA, pathB) {
if (
e &&
typeof e === "object" &&
"status" in e &&
e.status === 1 &&
"stdout" in e &&
typeof e.stdout === "string"
) {
return e.stdout;
Expand All @@ -106,7 +116,7 @@ function unifiedDiff(pathA, pathB) {
}
}

async function main() {
async function main(): Promise<void> {
const args = parseArgs(process.argv);
if (args.help) {
printHelp();
Expand All @@ -115,7 +125,7 @@ async function main() {

fs.mkdirSync(args.outDir, { recursive: true });

const combined = [];
const combined: string[] = [];
let anyDiff = false;

for (const preset of PRESET_ORDER) {
Expand Down Expand Up @@ -193,7 +203,7 @@ async function main() {
}
}

main().catch((err) => {
main().catch((err: unknown) => {
console.error(err);
process.exit(1);
});
Loading
Loading