Skip to content

Latest commit

 

History

History
 
 

docsearch-react

README.md

Phoenix Code DocSearch source dependency

This is a narrowly maintained source fork of @docsearch/react 5.2.0, released locally as 5.2.0-phcode.2. The application consumes the package in releases/; it does not rewrite installed dependencies or modify DocSearch's DOM at runtime.

Upstream provenance

src/ and style/ contain the package's production source. Unrelated upstream tests, screenshots, examples, and monorepo packages are omitted. The original SHA-256 for each imported file is recorded in upstream-files.json.

Changes

The reviewed source differences are recorded in upstream.patch:

  1. Preserve encoded URLs. src/utils/sanitize.ts retains upstream's scheme validation, including decoding used to detect unsafe schemes, but returns the original validated URL. Previously, an absolute URL containing Pro%20Features became ProFeatures; encoded query values and fragments could also change. The existing HTML escaping and unsafe-scheme rejection remain in place.
  2. Name the Sidepanel dialog. src/Sidepanel/Sidepanel.tsx creates a unique heading ID with React.useId(), connects it with aria-labelledby, and passes the already supported header translations through to SidepanelHeader.tsx. The heading stays visible and gives the dialog its accessible name.
  3. Render linked screenshots. src/utils/markdown.ts renders a link's child tokens through the existing safe Markdown renderers. Previously, a screenshot wrapped in a link appeared as literal Markdown. Image and link URLs still pass through the sanitizer; embedded HTML and attribute values remain escaped.
  4. Identify the maintained build. src/version.ts reports 5.2.0-phcode.2.

The build configuration only relocates upstream's shared configuration into this directory. It preserves the public exports, ESM and UMD outputs, CSS entry points, and ES2017 browser target. Development dependencies are locked locally; no new build tool is required by the application's normal installation.

Rebuild and verify

Use Node.js 24 and npm 11, matching the tested build environment. Run from this directory:

npm ci --ignore-scripts
npm run build
npm test
npm pack --pack-destination releases --ignore-scripts

The JavaScript tests execute the sanitizer source through the TypeScript compiler, retain upstream's unsafe-scheme fixtures, test URL preservation, render the built Sidepanel to verify its accessible name, and check that every other production source file still matches its upstream hash. Shared JavaScript cases cover linked and standalone images, formatted labels, encoded URLs, unsafe nested URLs, HTML and attribute injection, and partially streamed Markdown against both source and the installed compiled package. No test sends an AI request.

Commit source changes and the rebuilt tarball together. Update the application lockfile so its integrity covers the new package. Do not run npm publish for this private package. Do not edit dist/, the tarball, or installed node_modules.

The application's root dependency and npm override must both resolve to this same artifact; check npm ls @docsearch/react to ensure that the Docusaurus adapter, modal, and sidepanel integrations share the corrected package.

Retiring this fork

Before upgrading, check upstream for fixes to the URL sanitizer, the Sidepanel accessible name, and linked-image rendering. Run the same regression cases against the candidate release and verify full-page Ask AI submission, encoded citation/source links, mobile layout, and keyboard close/focus behavior. Once an official release passes, replace the file dependency with that release, remove the override, and remove this directory.

Checked on 18 November 2026: the live npm registry and official release notes still list DocSearch 5.2.0 and Docusaurus 3.10.2 as latest stable. The upstream Markdown renderer still escapes the raw link label instead of rendering its child tokens. Keep the three fixes until upstream passes all regression cases.

Relevant upstream implementation and documentation: