Add a framework adapter
Use packages/react and packages/vue as models. Both pass the contract suite and have a hydration test. Core does all the work, and an adapter only binds it to the framework, so that every framework behaves the same.
Copy the steps into your task list, and mark each step when it is done.
Keep the item of the adapter on the plan board, https://github.com/orgs/awesome-reveal/projects/1, in sync with the work. Set its Status to "In Progress" before step 1. Add the PR number to each checklist item that a PR covers, tick the item when the PR merges, and set "Done" when all items are ticked.
- Create
packages/<framework>withpackage.json,tsconfig.json,vite.config.ts,test/tsconfig.jsonand thetest/setupfiles. Copy them frompackages/react, and change these items:
name,description,keywordsandrepository.directory.- The framework peer dependency and its dev dependencies.
- The JSX options in
tsconfig.json, such asjsxImportSource. Remove them if the framework has no JSX.
Keep "@awesome-reveal/core": "workspace:*", and keep "version" equal to the other packages. Add the package to the paths in tsconfig.base.json, so that the example type-checks against the sources.
- Prefer plain TypeScript sources, such as render functions, when the framework allows it. Then the build needs no compiler plugin, and
vite-plugin-dtsemits the declarations. If the framework needs a compiler plugin, pass it todefineLibConfiginvite.config.tsas the second argument. Check the declarations and the output format:
vite-plugin-dtsemits declarations for.vuefiles only when@vue/language-coreis installed.vite-plugin-dtscannot emit declarations for.sveltefiles. Svelte libraries use@sveltejs/package.- Solid libraries also publish uncompiled JSX under a
"solid"export condition, so that the consumer compiles it for the DOM or the server.
- Ship the SSR stylesheet in the package, so that in most setups the user imports no CSS. Copy
src/reveal.cssfrompackages/react, passrevealCssandnoStyletodefineLibConfig, and set"sideEffects": ["*.css"]. Add the./reveal.cssexport, aspackages/react/package.jsondoes, for the setups that need an explicit import, such as an Astro island. Import the CSS from each module that renders hidden markup, through the#reveal-style.csssubpath import ofpackages/react/package.json. Itsnodecondition resolves to an empty module, so that Node and the server builds of bundlers load no CSS. A component file that the framework compiles, asHost.astrois, can import the CSS directly. Copysrc/reveal-style.d.tstoo, because the build type-checks beforedisthas the CSS declarations. Add atest/browser/stylesheet.test.ts. It checks that yourreveal.cssequals the React copy. It also checks that the page has astyleelement with thedata-vite-dev-idof your own copy. Re-export theSideandStartStatetypes of core fromsrc/index.ts. - Write the API as a binding on core. Choose the layer for each API, not for the whole adapter, because one adapter can have both kinds:
- Use
createRevealfrom@awesome-reveal/core/adapterfor each reveal API, andcreateCascadefor each cascade API. Give the adapter a reveal API and a cascade API, as the other adapters do. When the framework renders the element, as React and the Vue<Reveal>do, renderdata-awesome-revealfromrevealed. Sometimes the adapter owns the element, and the framework does not render its attributes: directives, actions, attachments and custom elements. Then setdata-awesome-revealin thesubscribelistener whenrevealedbecomesfalse, asv-revealand the Astro custom element do. Core removes the attribute at the reveal, beforeonReveal. - Do not call
reveal()orcascade()of the root entry. They animate with no SSR state and nowhen, so the server markup and the client state differ. - Obey the adapter contract:
- Take exactly the adapter
RevealOptionsof core, orCascadeOptionsfor a cascade API, with the same names, defaults andnullmeaning. Do not add an option or a default. - Let one core object own the observer, the animation and
when. Do not rebuild that state machine in the adapter. - Render
hiddenAttributesof core on the revealed element whilerevealedis false. A cascade renderscascadeHiddenAttributes, andreveal.csshides its direct children. Do not write a style: the packagereveal.csshides the element. The client render must equal the server markup. - Do not replay the animation on a new element, such as a changed
astag.attachkeeps the state. A directive that is bound to its element is the only exception. - Treat
data-awesome-revealanddata-awesome-reveal-attachedas reserved. Do not let the framework render removedata-awesome-reveal-attached, which core sets at the attach. Leave thestyleof the user as it is. - Pass
onRevealto core. If the framework has events, emit an event from it, as the Vue<Reveal>and the Astro custom element do. - Do not defer the entrance, for example with a timer or a frame callback: core starts it in the task of the report, before the next paint.
- Do not catch the errors of core. It reports the errors of
onReveal.
- Render the hidden state in the server markup, so that the element does not show before hydration. Add a hydration test that renders on the server, hydrates in a browser, and fails on a mismatch warning, as
packages/react/test/browser/hydration.test.tsxandpackages/vue/test/browser/hydration.test.tsdo. An attribute that only the server renders can cause a mismatch. - Add the Vitest projects to
vitest.config.ts:<framework>:unit,<framework>:browser,<framework>:package, and<framework>:ssrwhen the framework renders on a server.
- Give the
sourcesalias to:unitand:ssr, and only thetestUtilsalias to:package, because:packagetestsdist. - Give
:browserthe options...browserTest()and the aliases ofsourcesFor(). ExtendsourcesFor()for thereveal.cssof the new package. Write the parentheses ofbrowserTest(): each project needs its own browser instances, because Vitest writes a name into each instance. The function also setsunstubGlobals: true. - Put the bare imports of the framework and of its
vitest-browser-*package inoptimizeDeps.includeof:browser. Without the list, a run with a warm cache can optimize the dependencies again in the middle of the run. Vite then reloads the page, and the page loads two copies of the framework. - Exclude
test/browser/**from:unit. Run the:unit,:ssrand:browserprojects in theframeworkjob ofci.yml, as step 12 describes. - Add the package to the coverage thresholds.
- Add a
typecheckblock to:unit, asreact:unithas, so thatpnpm testruns the type tests. Iftsccannot read the component files, set thecheckerthat can, such asvue-tscfor Vue. - If the tests compile component files, add the compiler plugin to the project
plugins, and to the rootdevDependencies, because the rootvitest.config.tsimports it.
- Write the tests in
test/browser/with the helpers of@awesome-reveal/test-utils, and addtest/browser/contract.test.tswith a harness fordescribeContractof each reveal API and fordescribeCascadeContractof each cascade API. RundescribeSSRContractfrom the SSR test, with"cascade"as the hidden value for a cascade API, as the React and Vue packages do. A scenario that fails is a bug of the adapter. Do not skip it. - Port the tests of
packages/react/test/package: the dist files and exports, the server markup,describeDocs, and the tree-shaking fixtures with size limits, throughbundleFixture()of@awesome-reveal/test-utils/bundle. Drop the"use client"test if the framework has no Server Components.describeDocstype-checks only thetsandtsxfences of the consumer skills and of the README. Put the setup and native keyframes examples in these fences, as whole modules with their imports. - Add the consumer skills in
packages/<framework>/skills/<name>/SKILL.md, and addskillstofiles. Portadding-reveal-animationsfrom the React package. - Add
examples/<framework>, with the sections ofexamples/react. - Add the package to
release-please-config.json, with"component"set to the package name, and tolinked-versions. Without"component", release-please drops the npm scope from the tags. Add its path to.release-please-manifest.json, with the current version of core. Before the release PR merges, do "Publish a new package" in thereleasing-packagesskill. Its steps need the npm one-time codes of the user, so list them in your final report. - Update the repo config for the framework:
- If the peer range covers an older major version of the framework, add it to the
frameworkmatrix in.github/workflows/ci.yml, with the:unit,:ssrand:browserprojects of the package. The "Require CI" ruleset lists the name of eachframeworkmatrix entry, such asTest (Vue 3.5.0). Only an admin can change it, so list the new name in your final report. - Add a
<framework>case tocasesinscripts/smoke.mjs, as thevuecase does: it installs the tarballs, builds a page, checks the server markup, and checks the reveal in Chromium. Add entries withbrowser: trueto thesmokematrix inci.ymlfor the lowest and the highest version of the peer range. Add the case to the usage comment ofsmoke.mjsand to thesmoke.mjscommand inAGENTS.md. The "Require CI" ruleset lists eachsmokematrix name, and only an admin can change it, so list the new names in your final report. - Add a group with the framework packages to the
npmentry of.github/dependabot.yml. - If oxlint has a plugin for the framework, such as
vue, enable it in anoverridesentry of.oxlintrc.json. Limit the entry to the package and its example, as the Vue entry does.
- Add the package to the package table in the root
README.md. In.github/ISSUE_TEMPLATE/bug_report.yml, add it to thepackagedropdown, and add a StackBlitz template of the framework, such asvite.new/vue-tsorastro.new/minimal, to the reproduction field. - Add
.claude/rules/<framework>/adapter.mdfor the gotchas of the framework, withpaths: ["packages/<framework>/**", "examples/<framework>/**"]. - The docs site is the separate repo
awesome-reveal/website. List the adapter page in your final report as work for that repo. - Run the checks:
pnpm test --coveragepnpm exec tsc -p packages/<framework>/test, or the checker of step 6, such aspnpm --filter @awesome-reveal/vue exec vue-tsc -p testpnpm test:packagenode scripts/smoke.mjs <framework>, afterpnpm test:packagebuilt the packagespnpm lintandpnpm format:check- A manual check of the example in a browser
Fix each failure, then run all the checks again. Open the PR only when all of them pass.