diff --git a/.github/workflows/bench.yml b/.github/workflows/bench.yml new file mode 100644 index 00000000..3eab1b3b --- /dev/null +++ b/.github/workflows/bench.yml @@ -0,0 +1,42 @@ +# The representative-task benchmark (bench/README.md): each task is a job a Solid user does with a library of the +# ecosystem — its good program accepted by both checkers, typed by the library's own types and run in Chromium, its +# one-line mistakes refused. The run is compared with bench/scorecard.json: a check that is green there may not turn +# red, and a check that is red is one its task's `known` gives the reason for. +name: bench + +on: + push: + branches: [main] + paths: ["compiler/**", "ref/**", "runtime/**", "tooling/rx-language-server/**", "bench/**", ".github/workflows/bench.yml"] + pull_request: + paths: ["compiler/**", "ref/**", "runtime/**", "tooling/rx-language-server/**", "bench/**", ".github/workflows/bench.yml"] + workflow_dispatch: + +jobs: + bench: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v5 + - uses: dtolnay/rust-toolchain@stable + - uses: Swatinem/rust-cache@v2 + with: + workspaces: compiler + - uses: actions/setup-node@v5 + with: + node-version: 24 + - name: The crate (rxc, and the Node-API build Solid's Vite plugin loads) + working-directory: compiler + run: | + npm ci + cargo build --release + npx napi build --platform --release --features node --manifest-path ./Cargo.toml -- --lib + - name: The runtime + run: npm --prefix runtime ci && npm --prefix runtime run build + - name: The language server's packages (rx-tsc) + run: npm --prefix tooling/rx-language-server ci + - name: The libraries, and Chromium + run: | + mkdir -p bench/.out/ws && cp bench/package.json bench/.out/ws/package.json + (cd bench/.out/ws && npm install --no-audit --no-fund --legacy-peer-deps && npx playwright install --with-deps chromium) + - name: The benchmark, against bench/scorecard.json + run: node bench/run.mjs --check --strict diff --git a/.github/workflows/editor.yml b/.github/workflows/editor.yml index 10042da9..2caa5db2 100644 --- a/.github/workflows/editor.yml +++ b/.github/workflows/editor.yml @@ -13,9 +13,9 @@ name: editor on: push: branches: [main] - paths: ["compiler/**", "tooling/**", ".github/workflows/editor.yml"] + paths: ["compiler/**", "tooling/**", "runtime/**", "ref/compile/rt-*.ts", ".github/workflows/editor.yml"] pull_request: - paths: ["compiler/**", "tooling/**", ".github/workflows/editor.yml"] + paths: ["compiler/**", "tooling/**", "runtime/**", "ref/compile/rt-*.ts", ".github/workflows/editor.yml"] workflow_dispatch: jobs: @@ -41,6 +41,8 @@ jobs: cargo build --lib --release --target wasm32-unknown-unknown --manifest-path compiler/Cargo.toml - name: Solid next (the types the tests check against) run: sh ref/scripts/solid-next.sh && npm --prefix ref install + - name: The runtime (test/tsc.js checks an entry against its types) + run: npm --prefix runtime ci && npm --prefix runtime run build - name: Language server tests working-directory: tooling/rx-language-server run: | diff --git a/.github/workflows/suites.yml b/.github/workflows/suites.yml new file mode 100644 index 00000000..c2ef445e --- /dev/null +++ b/.github/workflows/suites.yml @@ -0,0 +1,114 @@ +# The suites CONTRIBUTING.md lists ("Running the suite"), on every change to what they read: the crate's own tests, the +# reference implementation's (ref/: the interpreter over every scenario, the same scenarios lowered onto Solid, the +# compiled modules, streamed SSR and hydration in Chromium, the TSX projection), the crate against ref/ in each of its +# modes (CP-5: checked, client-only, whole-program, lowered, projected), and the three suites that run a guarantee +# rather than a list of cases (compiler/test/confined.mjs, drafts.mjs, ssr-held.mjs). +# +# ref/ runs on Solid built from source at ref/SOLID_NEXT (ref/scripts/solid-next.sh: pnpm, and a Rust build of Solid's +# native compiler). That build is kept in a cache keyed by the pin, so it is made once per pin and restored after. +name: suites + +on: + push: + branches: [main] + paths: ["compiler/**", "ref/**", "runtime/**", "scenarios/**", "examples/**", "bench/**", ".github/workflows/suites.yml"] + pull_request: + paths: ["compiler/**", "ref/**", "runtime/**", "scenarios/**", "examples/**", "bench/**", ".github/workflows/suites.yml"] + workflow_dispatch: + +jobs: + # the crate's own tests (compiler/src's units, compiler/tests/) + cargo: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v5 + - uses: dtolnay/rust-toolchain@stable + - uses: Swatinem/rust-cache@v2 + with: + workspaces: compiler + key: test + - name: cargo test + working-directory: compiler + run: cargo test --release + + # ref/'s runners, and the crate against ref/ + ref: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v5 + - uses: dtolnay/rust-toolchain@stable + - uses: Swatinem/rust-cache@v2 + with: + workspaces: compiler + - uses: pnpm/action-setup@v4 + with: + version: 11.1.1 # solid-next's packageManager + - uses: actions/setup-node@v5 + with: + node-version: 24 + - name: Solid next, from the cache + id: solid + uses: actions/cache@v4 + with: + path: ${{ github.workspace }}/../solid-next + key: solid-next-${{ runner.os }}-${{ hashFiles('ref/SOLID_NEXT', 'ref/scripts/solid-next.sh') }} + - name: Solid next, built at the pin + if: steps.solid.outputs.cache-hit != 'true' + run: sh ref/scripts/solid-next.sh + - name: ref/ (links ../solid-next), and Chromium + run: | + npm --prefix ref install + (cd ref && npx playwright install --with-deps chromium) + - name: The crate (rxc, and the Node-API build) + working-directory: compiler + run: | + npm ci + cargo build --release + npx napi build --platform --release --features node --manifest-path ./Cargo.toml -- --lib + - name: The runtime + run: npm --prefix runtime ci && npm --prefix runtime run build + - name: "the runtime as built: both builds, the request's and the render's state, and Solid's contract (the installed release and the pin)" + working-directory: runtime + run: SOLID_NEXT="${{ github.workspace }}/../solid-next" node test.mjs + - name: "ref: the interpreter over every scenario" + working-directory: ref + run: npm test + - name: "ref: the scenarios lowered onto Solid (the oracle)" + working-directory: ref + run: npm run oracle + - name: "ref: compiled modules" + working-directory: ref + run: npm run compiled + - name: "ref: streamed SSR and hydration in Chromium" + working-directory: ref + run: npm run ssr + - name: "ref: the TSX projection, checked by TypeScript" + working-directory: ref + run: npm run types + - name: "crate against ref/: checked" + working-directory: ref + run: npm run crate + - name: "crate against ref/: client-only (--spa)" + working-directory: ref + run: npm run crate -- --spa + - name: "crate against ref/: the whole program (--whole-program)" + working-directory: ref + run: npm run crate -- --whole-program + - name: "crate against ref/: lowered (--lower)" + working-directory: ref + run: npm run crate -- --lower + - name: "crate against ref/: projected (--project)" + working-directory: ref + run: npm run crate -- --project + - name: "the guarantees, run: drafts (MO-10i) and held results (MO-10f) on the server" + run: | + node compiler/test/drafts.mjs + node compiler/test/ssr-held.mjs + - name: "the library build: a package written in .rx (MO-13e)" + run: node compiler/test/lib.mjs + - name: The libraries confined.mjs runs against (bench/package.json) + run: | + mkdir -p bench/.out/ws && cp bench/package.json bench/.out/ws/package.json + (cd bench/.out/ws && npm install --no-audit --no-fund --legacy-peer-deps) + - name: "the guarantees, run: the counterexamples and their controls, in Chromium (CN-7)" + run: node compiler/test/confined.mjs diff --git a/.github/workflows/tree-sitter.yml b/.github/workflows/tree-sitter.yml new file mode 100644 index 00000000..373fc5a2 --- /dev/null +++ b/.github/workflows/tree-sitter.yml @@ -0,0 +1,38 @@ +# The tree-sitter grammar (tooling/tree-sitter-rx): src/ is generated but committed, since Zed compiles src/parser.c +# as it is, so check it is what grammar.js generates; then the corpus, and every tracked .rx file with no ERROR or +# MISSING node. +name: tree-sitter + +on: + push: + branches: [main] + paths: ["tooling/tree-sitter-rx/**", "**/*.rx", ".github/workflows/tree-sitter.yml"] + pull_request: + paths: ["tooling/tree-sitter-rx/**", "**/*.rx", ".github/workflows/tree-sitter.yml"] + workflow_dispatch: + +jobs: + grammar: + runs-on: ubuntu-latest + defaults: + run: + working-directory: tooling/tree-sitter-rx + steps: + - uses: actions/checkout@v5 + - uses: pnpm/action-setup@v4 + with: + version: 11.1.1 # as editor.yml + - uses: actions/setup-node@v5 + with: + node-version: 22 + - run: pnpm install --frozen-lockfile + - name: src/ is what grammar.js generates + run: | + pnpm run generate + git diff --exit-code -- src/ + - name: Corpus + run: pnpm test + - name: Every tracked .rx file + run: pnpm run parse:repo + - name: Queries + run: pnpm run query -- ../../examples/*.rx > /dev/null diff --git a/CHANGELOG.md b/CHANGELOG.md index 72ea93c6..a3cad1b1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,144 @@ ## Unreleased +**New** + +- A library written in `.rx` can be published and used from `.rx` apps and from `.tsx` Solid 2 apps (spec/09 MO-13). + `rx-lib` (`@reactivescript/compiler`) builds a package: each module compiled for the browser and the server, the + module an import resolves to on each side, the printed signature as its `.d.rx`, the projection's types + (`x.rx.d.ts`) and the types of the JavaScript (`x.d.ts`), and it holds the package.json's `exports` to that layout + (`--write` writes them). An `.rx` app is checked against the shipped `.d.rx` as against the package's source; a + `.tsx` app gets TypeScript's checks only. The runtime has `library(factory, name)` for the JavaScript side. +- A package's module has one instance in a page, whoever imports it (spec/09 MO-13g): an `.rx` program and a `.tsx` + host that both import it share its state (they had an instance each). `library` and `components` bind to the page's + app — the first app made in the page; the app the runtime makes for JavaScript is the one a program's `createApp` + then returns. A second `createApp` in a page is still a second app. +- On the server, a `.tsx` app that uses an `.rx` package (or `?rx-lib` components) renders with a plain + `renderToString` or `renderToStream`: outside Solid's request event the state is the render's, found through the + owner, never shared by two renders. It threw before. Used where nothing renders and no request is answered, it still + throws, and the message says what to do. +- In a request event, a package's state lives as the request does (spec/09 MO-13g). It was under the first render's + root: a second render of the same request (a head rendered apart, a `renderToString` inside a stream) read nodes + the first had disposed. Now each render of the request holds the state, it is disposed when a turn of the event + loop passes with none open, and a render that begins after that throws, saying why. `holdRequest()` (new, server) + holds it across an `await` between two renders. +- What the server runtime reads of Solid's internals to find a render's root owner is in one file + (`ref/compile/solid-internals.ts`), checked against Solid's public `getHydrationWriter()`: a Solid shaped otherwise + is refused with an error naming its version, where it would have been one app for whatever owner was topmost. + `runtime/test.mjs` asserts those internals (CI runs it). A package export used under a root made outside any render + and any request now throws as any use outside a render does (it took the topmost owner for a render). + +- A package's module that JavaScript uses first is instantiated in a root no owner holds, whose id is the module's + name (spec/09 MO-13h): it is not disposed with the component that first read it, and its nodes have the server's + ids wherever the first use is. +- A `.d.rx` that begins `//@ signature .rx` is the printed signature of a compiled `.rx` module, and is read + as one wherever a JS import finds it (beside a relative module, or a package's): absent `rejects(…)` is nothing, + sources, equations, actions, contexts with relative keys, `catches`, `shape(…)` are the signature's. The compiler + writes the line on every signature it prints (the header comment it wrote before is gone). A `.d.rx` without it is + a JS module's declaration, as before. The tree-sitter grammar reads such a file. + +**Changed** + +- The record after a component's props' type is held to that type (spec/13 TY-6f, 09 MO-8o). `props: P & { onChange?: + handler (v: Option) => void }` was checked as `P & NoInfer<{ … }>`, which an intersection satisfies whatever the record + says. `rx-tsc` now checks each field of the record on its own: it names a prop the type has, and the type it is written + with is one the library's type for that prop takes (the same, or narrower). Otherwise `DECLARATION_MISMATCH` on the + row, naming the prop and both types. A declaration with a retyped or misspelt field in such a record, accepted before, + is refused. +- `rx-declare` writes no `any` of its own for a module with types, for any export (spec/09 MO-8q, extended): a type + parameter's bound is written out however long, a part with no name is its place at the row's type parameters + (`Parameters>[1]`), a predicate is written as the library writes it, options a row cannot + write field by field are the type the library declares, a result the library calls `JSX.Element` is a component's + though the app's project cannot resolve it, a function of nothing that gives an element is `() => View`, and a row + with a bound that has no name is its last signature with each such part by its place. `--readings ` prints + each reading of a row and TypeScript's answer. The library's own `any`s inside a type it names are reproduced (they + were counted against the row, which then dropped the type). `bench --check` drafts every export of each module its + tasks declare and fails on an `any` of the draft's, or on more parts said by place than the scorecard records. + Generated declarations are redrafted (draft 6). +- The tree-sitter grammar reads a member of an import type, `import("pkg").Types["error"]`. +- A declared component's props may be a type, with the fields that carry words in a record after it (spec/09 MO-8o): + `export component Select