Skip to content

Commit a80e662

Browse files
Merge branch 'main' into fix/4223-bidi-logical-props
2 parents 8a12b5b + 2aac986 commit a80e662

143 files changed

Lines changed: 7589 additions & 5023 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/copilot-instructions.md‎

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# Copilot instructions for ReSpec
2+
3+
ReSpec is a browser-based tool that generates W3C specifications. Authors write HTML plus a `<script>` tag, and ReSpec fills in boilerplate, cross-references, bibliography, and validation. Roughly half of W3C standards are produced with it, so a regression here reaches a lot of documents.
4+
5+
Contributions written with AI are welcome and have a policy: see [AI_POLICY.md](../AI_POLICY.md). Read it before opening a pull request.
6+
7+
## Build and test
8+
9+
This is the whole sequence. The build is part of it, and so are `BROWSERS` and `PUPPETEER_CACHE_DIR`:
10+
11+
```bash
12+
export PUPPETEER_CACHE_DIR="$PWD/.cache/puppeteer"
13+
pnpm i --frozen-lockfile
14+
pnpm lint # tsc -p src/jsconfig.json && eslint .
15+
pnpm build:w3c && pnpm build:aom && pnpm build:dini
16+
BROWSERS=ChromeHeadless pnpm test # unit then integration, via karma
17+
pnpm test:build # the builder tool
18+
pnpm test:headless # renders examples through puppeteer
19+
```
20+
21+
**Always set `BROWSERS`, or pass `--browsers`.** No karma config sets a default, so `pnpm test` on its own launches nothing, waits for a browser to connect by hand, and hangs until something kills it. Nothing in the output says so; it simply stops after printing `START:`.
22+
23+
**Set `PUPPETEER_CACHE_DIR` to `$PWD/.cache/puppeteer` for anything that launches a browser**, which includes `pnpm test:headless` via `tools/respecDocWriter.js`. The agent environment provisions the browser there rather than in the default home cache, so puppeteer will not find it unless pointed at the same place.
24+
25+
If you are a human with a browser already in puppeteer's default cache, you do not need that line, and you should skip it: the workspace copy is around 340 MB and does not get shared between checkouts.
26+
27+
The integration suite (`tests/spec/`) reads the bundles in `builds/`, not `src/`, so a source change has no effect on it until the bundle is rebuilt. That is why the build sits above the test line rather than being mentioned afterwards. The unit suite (`tests/unit/`) loads `src/` directly, so it needs no rebuild and is the faster loop while iterating.
28+
29+
There is one bundle per profile. Building only `w3c` leaves the DiNI and AOM suites testing the previous code, which looks like a passing or failing test that has nothing to do with the change. If a change that provably does nothing alters a test result, suspect a stale bundle before suspecting the test.
30+
31+
Never commit anything under `builds/`. CI rebuilds it, and a PR touching it fails a dedicated check.
32+
33+
To run a single integration suite, rebuild first, then pass the describe block. The unit config needs no rebuild:
34+
35+
```bash
36+
pnpm build:w3c
37+
npx karma start tests/spec/karma.conf.cjs --single-run --browsers ChromeHeadless --grep="Core - Inlines"
38+
npx karma start tests/unit/karma.conf.cjs --single-run --browsers ChromeHeadless
39+
```
40+
41+
`--grep` is a literal string match. Alternation does not work, and only the last `--grep` counts, so run separate invocations instead.
42+
43+
### Testing against a local respec-web-services or specref
44+
45+
The suite resolves cross-references, W3C group data, caniuse, baseline and bibliography against `respec.org` and `api.specref.org`. Two environment variables send those requests somewhere else instead, so you can check a service change against this suite before it deploys:
46+
47+
```bash
48+
RESPEC_SERVICES_BASE=http://localhost:8000 \
49+
SPECREF_BASE=http://localhost:8001 \
50+
BROWSERS=ChromeHeadless npx karma start tests/spec/karma.conf.cjs --single-run
51+
```
52+
53+
Set neither and everything goes to production exactly as before. A service worker (`tests/spec/respec-test-sw.js`) does the redirecting, so it also covers requests no per-document `fetch` wrapper reaches, such as the highlighter's `importScripts`.
54+
55+
**Set both, or bibliography can still reach production.** `core/biblio.js` asks `api.specref.org` first and can fall back to `respec.org/bibrefs`, and these variables replace whole origins, so either one on its own leaves one of those two on the network: with only `SPECREF_BASE`, the fallback goes to production, and with only `RESPEC_SERVICES_BASE`, the first attempt does. Either way a local Specref that is stopped or broken can still pass the bibliography specs, quietly answered by production. Karma warns when only one is set.
56+
57+
Two consequences to expect. While either variable is set the suite stops seeding the Cache API and gives each spec document a cache that misses every lookup, so every request really reaches your service rather than being answered from a fixture. And a service that is not running answers 502 through the worker, which surfaces as ReSpec's ordinary "response was not ok" handling rather than as an unhandled rejection.
58+
59+
## Code style
60+
61+
Prefer functional style over imperative loops: `forEach`, `map`, `filter`, `find`, `reduce`, `some`, `every`. Use an early `return` inside `forEach` rather than `continue`. `NodeList`, `Map` and `Set` have `forEach` natively, so prefer `nodeList.forEach()` over `[...nodeList].forEach()` and avoid the extra array.
62+
63+
Every `querySelector`, `closest`, `getElementById` and `getAttribute` result is possibly null; check before use. Do not paper over it with `?? ""`, because the empty string then flows on into an `html` template and renders as an empty text node, so the bug shows up later as missing output rather than as a null failing where it happened.
64+
65+
Write en-US English everywhere, including comments and identifiers: behavior, color, license, center, analyze, initialize, serialize. Leave existing en-GB spelling alone when it is load-bearing, such as an established identifier or a verbatim quotation.
66+
67+
Run `pnpm format --write` on changed files. CI fails on unformatted code.
68+
69+
## Pull requests, commits, and comments
70+
71+
The house style is in [AI_POLICY.md](../AI_POLICY.md) under "Write it the way the project writes it". In short:
72+
73+
- Pull request titles follow conventional commits, `type(scope): summary`, enforced by the Check PR Title workflow.
74+
- Pull request descriptions are plain prose. No `## Summary`, no `## Changes`, no `## Test plan`, no emoji, no bold section labels. A closing reference goes on the first line.
75+
- `Closes #N` only when every ask in the issue is delivered, otherwise `Refs #N`. Confirm the number is an issue and not a pull request before citing it.
76+
- Commit messages are one imperative subject line, lowercase after any prefix, no trailing period, and no body unless the diff cannot be understood without one. A `Co-Authored-By` trailer naming the model that wrote it is welcome.
77+
- Comments say why, not what. Delete a comment that restates the line below it. No bare `fixes #1234` in source.
78+
79+
## Tests
80+
81+
A test that cannot fail is worse than no test, because it costs review time and implies coverage that does not exist. A regression test must fail on `main` for the reason the issue describes, and pass with the fix. Do not assert a literal the implementation just set, and do not exercise a path the issue never mentioned while the reported path stays uncovered.
82+
83+
Do not claim a bug is fixed without showing it broken first. Run the same repro against the pre-fix state and against your fix, and put that in the PR description. Prefer running it on the base commit; when the base will not build with your new test, revert only the fix and say so. The exact format the check validates is in [ai-pr-proof-requirement.md](../ai-pr-proof-requirement.md).
84+
85+
One concern per pull request. A locale addition or a drive-by refactor belongs in its own PR even when it is one line and obviously correct.
86+
87+
## Adding a module
88+
89+
A module goes in `src/core/` only if every profile wants it. If it is specific to one, put it in that profile's folder instead, as `src/w3c/` already does for eight modules. Either way it exports `name` and a `run(conf)`. `run` may be synchronous or async, whichever the work needs: most core modules are synchronous, and only the ones that fetch or await something are not. The module must be registered in every profile that needs it: `profiles/w3c.js`, `profiles/aom.js`, `profiles/dini.js`. Tests go in `tests/spec/core/`. If the module uses `getIntlData`, add a Czech (`cs`) entry.

‎.github/workflows/codeql-analysis.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838

3939
steps:
4040
- name: Checkout repository
41-
uses: actions/checkout@v6
41+
uses: actions/checkout@v7
4242

4343
# Initializes the CodeQL tools for scanning.
4444
- name: Initialize CodeQL
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: "Copilot Setup Steps"
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
paths:
7+
- .github/workflows/copilot-setup-steps.yml
8+
pull_request:
9+
paths:
10+
- .github/workflows/copilot-setup-steps.yml
11+
12+
jobs:
13+
copilot-setup-steps:
14+
runs-on: ubuntu-latest
15+
permissions:
16+
contents: read
17+
steps:
18+
- uses: actions/checkout@v7
19+
- uses: pnpm/action-setup@v6
20+
- uses: actions/setup-node@v6
21+
with: { node-version-file: ".nvmrc", cache: pnpm }
22+
23+
# Deliberately NOT setting PUPPETEER_SKIP_DOWNLOAD, though the CI workflows
24+
# do. CI can skip the download because it points PUPPETEER_EXECUTABLE_PATH at
25+
# the runner's Chrome for the same job. Variables set here do not reach the
26+
# agent's later commands, so skipping would leave it with neither a bundled
27+
# browser nor a path to one.
28+
#
29+
# PUPPETEER_CACHE_DIR is set per step, not on the job. Copilot honors only
30+
# steps, permissions, runs-on, services, snapshot and timeout-minutes, so a
31+
# job-level env block is dropped when it runs these as setup steps, even
32+
# though a normal Actions run would apply it. The workspace location is
33+
# deliberate: puppeteer defaults to ~/.cache/puppeteer, and the home
34+
# directory is not guaranteed to survive into the agent's own session.
35+
- run: pnpm i --frozen-lockfile
36+
env:
37+
PUPPETEER_CACHE_DIR: ${{ github.workspace }}/.cache/puppeteer
38+
39+
# Explicitly, rather than relying on puppeteer's postinstall. pnpm caches the
40+
# fact that a build script ran, but the browser that script downloads lands
41+
# outside node_modules, so on a warm store the install completes in seconds
42+
# and no browser appears. This command is idempotent.
43+
- run: npx puppeteer browsers install chrome
44+
env:
45+
PUPPETEER_CACHE_DIR: ${{ github.workspace }}/.cache/puppeteer
46+
47+
# karma loads the bundles from builds/, not src/, and there is one per
48+
# profile. Building all three means the agent can run any suite without first
49+
# working out why a src/ change had no effect on the tests.
50+
- run: pnpm build:w3c
51+
- run: pnpm build:aom
52+
- run: pnpm build:dini
53+
54+
# Fails the setup loudly if puppeteer has no usable browser, rather than
55+
# leaving the agent to discover it mid-task. Same cache dir as the install,
56+
# or this would check a location nothing populated. Dynamic import rather
57+
# than require, so it does not depend on require(esm) support if the pinned
58+
# Node version ever moves.
59+
- name: Check puppeteer has a browser
60+
env:
61+
PUPPETEER_CACHE_DIR: ${{ github.workspace }}/.cache/puppeteer
62+
run: |
63+
node -e "
64+
const fs = require('fs');
65+
import('puppeteer')
66+
.then(p => p.default.executablePath())
67+
.then(p => { fs.accessSync(p); console.log('browser ok:', p); })
68+
.catch(e => { console.error('no usable browser:', e.message); process.exit(1); })
69+
"

‎.github/workflows/pr.yml‎

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ jobs:
2525
name: Check linting issues
2626
runs-on: ubuntu-latest
2727
steps:
28-
- uses: actions/checkout@v6
28+
- uses: actions/checkout@v7
2929
- name: Ensure builds/ has not changed
3030
run: |
3131
curl -sL https://api.github.com/repos/speced/respec/pulls/${{ github.event.pull_request.number }}/files -o /tmp/pr_files.json
3232
cat /tmp/pr_files.json | jq -r '.[].filename' | grep -qE "^builds/" || exit 0
3333
echo "::error::Uh oh! builds/ was changed."; exit 1
34-
- uses: pnpm/action-setup@v5
35-
- uses: actions/setup-node@v6
34+
- uses: pnpm/action-setup@v6
35+
- uses: actions/setup-node@v7
3636
with: { node-version-file: '.nvmrc', cache: pnpm }
3737
- run: pnpm i --frozen-lockfile
3838
- run: pnpm lint
@@ -42,9 +42,9 @@ jobs:
4242
runs-on: ubuntu-latest
4343
needs: lint
4444
steps:
45-
- uses: actions/checkout@v6
46-
- uses: pnpm/action-setup@v5
47-
- uses: actions/setup-node@v6
45+
- uses: actions/checkout@v7
46+
- uses: pnpm/action-setup@v6
47+
- uses: actions/setup-node@v7
4848
with: { node-version-file: '.nvmrc', cache: pnpm }
4949
- run: pnpm i --frozen-lockfile
5050
- run: pnpm test:build
@@ -59,12 +59,12 @@ jobs:
5959
runs-on: ubuntu-latest
6060
needs: lint
6161
steps:
62-
- uses: actions/checkout@v6
63-
- uses: pnpm/action-setup@v5
64-
- uses: actions/setup-node@v6
62+
- uses: actions/checkout@v7
63+
- uses: pnpm/action-setup@v6
64+
- uses: actions/setup-node@v7
6565
with: { node-version-file: '.nvmrc', cache: pnpm }
6666
- run: pnpm i --frozen-lockfile
67-
- run: pnpm build:w3c & pnpm build:geonovum
67+
- run: pnpm build:w3c && pnpm build:aom && pnpm build:dini
6868
- run: pnpm test:unit
6969
env:
7070
BROWSERS: ${{ matrix.browser }}
@@ -77,9 +77,9 @@ jobs:
7777
runs-on: ubuntu-latest
7878
needs: lint
7979
steps:
80-
- uses: actions/checkout@v6
81-
- uses: pnpm/action-setup@v5
82-
- uses: actions/setup-node@v6
80+
- uses: actions/checkout@v7
81+
- uses: pnpm/action-setup@v6
82+
- uses: actions/setup-node@v7
8383
with: { node-version-file: '.nvmrc', cache: pnpm }
8484
- run: pnpm i --frozen-lockfile
8585
- run: pnpm build:w3c

‎.github/workflows/push.yml‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ jobs:
2727
name: Headless Tests
2828
runs-on: ubuntu-latest
2929
steps:
30-
- uses: actions/checkout@v6
31-
- uses: pnpm/action-setup@v5
32-
- uses: actions/setup-node@v6
30+
- uses: actions/checkout@v7
31+
- uses: pnpm/action-setup@v6
32+
- uses: actions/setup-node@v7
3333
with: { node-version-file: '.nvmrc', cache: pnpm }
3434
- run: pnpm i --frozen-lockfile
3535
- run: pnpm build:w3c
@@ -52,12 +52,12 @@ jobs:
5252
name: Karma Unit Tests (Chrome)
5353
runs-on: ubuntu-latest
5454
steps:
55-
- uses: actions/checkout@v6
56-
- uses: pnpm/action-setup@v5
57-
- uses: actions/setup-node@v6
55+
- uses: actions/checkout@v7
56+
- uses: pnpm/action-setup@v6
57+
- uses: actions/setup-node@v7
5858
with: { node-version-file: '.nvmrc', cache: pnpm }
5959
- run: pnpm i --frozen-lockfile
60-
- run: pnpm build:w3c & pnpm build:geonovum
60+
- run: pnpm build:w3c && pnpm build:aom && pnpm build:dini
6161
- run: pnpm test
6262
env:
6363
BROWSERS: ChromeHeadless

‎.github/workflows/regressions.yml‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ jobs:
1111
name: Build W3C profile
1212
runs-on: ubuntu-latest
1313
steps:
14-
- uses: actions/checkout@v6
15-
- uses: pnpm/action-setup@v5
16-
- uses: actions/setup-node@v6
14+
- uses: actions/checkout@v7
15+
- uses: pnpm/action-setup@v6
16+
- uses: actions/setup-node@v7
1717
with: { node-version-file: '.nvmrc', cache: pnpm }
1818
- run: pnpm i --frozen-lockfile
1919
- run: pnpm build:w3c
@@ -41,9 +41,9 @@ jobs:
4141
- https://w3c.github.io/geolocation-api/
4242
fail-fast: false
4343
steps:
44-
- uses: actions/checkout@v6
45-
- uses: pnpm/action-setup@v5
46-
- uses: actions/setup-node@v6
44+
- uses: actions/checkout@v7
45+
- uses: pnpm/action-setup@v6
46+
- uses: actions/setup-node@v7
4747
with: { node-version-file: '.nvmrc', cache: pnpm }
4848
- run: pnpm i --frozen-lockfile
4949
- uses: actions/download-artifact@v8

‎.gitignore‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,15 @@ bevy.json
88
.idea
99
js/deps/builds
1010
!js/profile-w3c-common.js
11-
!js/profile-geonovum.js
1211
!js/profile-w3c.js
1312
.vscode/*
1413
!.vscode/tasks.json
1514
package-lock.json
1615
yarn.lock
1716
*.log
1817
.worktrees/
19-
CLAUDE.md
18+
CLAUDE.local.md
19+
20+
# Browser downloaded by puppeteer when PUPPETEER_CACHE_DIR points into the repo
21+
# (see .github/workflows/copilot-setup-steps.yml)
22+
.cache/

‎.npmrc‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
11
engine-strict=true
2-
strict-peer-dependencies=false
3-
auto-install-peers=false

0 commit comments

Comments
 (0)