Skip to content

Prepare browser client for next release#1848

Draft
Juice10 wants to merge 9 commits into
nextfrom
codex/browser-client-next-readiness
Draft

Prepare browser client for next release#1848
Juice10 wants to merge 9 commits into
nextfrom
codex/browser-client-next-readiness

Conversation

@Juice10

@Juice10 Juice10 commented Jun 1, 2026

Copy link
Copy Markdown
Member

Summary

  • Builds on the new next prerelease branch and the refreshed assets work.
  • Adds captureAssets support across rrweb recording, snapshotting, replay, and shared types.
  • Adds packages/browser-client to release plumbing and Turbo build metadata env hashing so browser-client builds include fresh commit metadata.
  • Switches @rrweb/browser-client from the temporary inlineStylesheet shim to captureAssets.stylesheets: 'without-fetch' by default while preserving caller-provided captureAssets and legacy inlineStylesheet compatibility.
  • Updates browser-client README, examples, and test env docs for ESM/npm usage, strict JSON script configs, and split public/read API key variables.
  • Adds browser-client coverage for asset events over both WebSocket and HTTP fallback transport paths when Cloud test credentials are available.

Branch setup

  • Base branch is now next, not master.
  • next carries .changeset/pre.json with tag: "next" so this payload can release on the prerelease channel.
  • Release-channel setup lives in Set up next prerelease channel #1851 for the workflow/docs that should also land on master.

Verification

Previously run before retargeting:

  • yarn workspace @rrweb/types check-types
  • yarn workspace rrweb-snapshot check-types
  • yarn workspace rrweb check-types
  • yarn workspace @rrweb/browser-client check-types
  • yarn workspace @rrweb/browser-client lint
  • yarn workspace @rrweb/browser-client test (integration tests skipped locally because API keys were not set)
  • yarn workspace rrweb vitest run test/record/asset.test.ts test/replay/asset-unit.test.ts test/replay/asset-integration.test.ts
  • git diff --check

Re-run after rebasing onto next:

  • yarn workspace @rrweb/browser-client check-types
  • yarn workspace @rrweb/browser-client lint
  • yarn workspace @rrweb/browser-client vitest run test/load-diagnostics.test.ts
  • git diff --check

@changeset-bot

changeset-bot Bot commented Jun 1, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: a13c470

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 20 packages
Name Type
@rrweb/browser-client Patch
rrweb Patch
rrweb-snapshot Patch
@rrweb/types Patch
@rrweb/all Patch
@rrweb/record Patch
@rrweb/replay Patch
@rrweb/web-extension Patch
@rrweb/rrweb-plugin-canvas-webrtc-record Patch
@rrweb/rrweb-plugin-canvas-webrtc-replay Patch
@rrweb/rrweb-plugin-console-record Patch
@rrweb/rrweb-plugin-console-replay Patch
@rrweb/rrweb-plugin-sequential-id-record Patch
@rrweb/rrweb-plugin-sequential-id-replay Patch
rrdom Patch
@rrweb/packer Patch
rrdom-nodejs Patch
rrvideo Patch
rrweb-player Patch
@rrweb/utils Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@Juice10 Juice10 force-pushed the codex/browser-client-next-readiness branch from 865f7af to 252e13c Compare June 1, 2026 15:31
@Juice10 Juice10 changed the base branch from master to next June 1, 2026 15:31
@Juice10 Juice10 marked this pull request as ready for review June 1, 2026 15:53
@Juice10 Juice10 marked this pull request as draft June 1, 2026 15:57
@Juice10 Juice10 force-pushed the codex/browser-client-next-readiness branch from fb91407 to a13c470 Compare June 1, 2026 16:01
@Juice10 Juice10 requested a review from Copilot June 1, 2026 18:05

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR prepares the repo (on the next prerelease branch) for the upcoming release by introducing end-to-end “asset capture” support across recording, snapshotting, replay, shared types, and the @rrweb/browser-client defaults/docs/tests.

Changes:

  • Add captureAssets plumbing + types, emit Asset events, and track capturedAssetStatuses on FullSnapshot for stylesheet/asset-aware replay.
  • Implement replay-side asset rebuilding (including stylesheet rebuilding and captured-attribute handling) plus new rrweb/rrweb-snapshot test coverage and fixtures.
  • Update @rrweb/browser-client defaults, docs, and integration tests; plus build/release plumbing updates (Turbo env hashing, workspace refs, changeset).

Reviewed changes

Copilot reviewed 38 out of 52 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
turbo.json Include commit hash env vars in Turbo global/task env hashing for reproducible metadata.
tsconfig.json Add packages/browser-client as a TS project reference.
packages/types/src/index.ts Introduce shared asset-capture types (captureAssetsParam, assetStatus, asset, replay asset manager interfaces).
packages/rrweb/src/types.ts Wire captureAssets + legacy compatibility types into recorder/replayer internal params.
packages/rrweb/src/record/index.ts Implement captureAssets defaults/mapping from legacy options; emit Asset events + capturedAssetStatuses on full snapshots.
packages/rrweb/src/record/mutation.ts Capture assets during mutations; propagate captured stylesheet attrs; adjust style text handling during async processing.
packages/rrweb/src/record/observers/asset-manager.ts New recorder-side AssetManager for capturing blobs/CSS and emitting asset events/statuses.
packages/rrweb/src/replay/machine.ts Add live-mode buffering to delay full snapshot rendering until awaited stylesheet assets arrive (to avoid FOUC).
packages/rrweb/src/replay/index.ts Integrate replay AssetManager: preload assets, rewrite captured attributes, and handle EventType.Asset.
packages/rrweb/src/replay/asset-manager/index.ts New replay-side AssetManager to rebuild assets (object URLs + CSS text) and manage captured attributes.
packages/rrweb/src/replay/asset-manager/update-srcset.ts Helper to update srcset entries as assets load.
packages/rrweb/test/replay/asset-unit.test.ts New unit tests for replay AssetManager behavior (loading/failed/srcset/stylesheets/live mode).
packages/rrweb/test/replay/asset-integration.test.ts New puppeteer-based integration tests validating asset application + stylesheet waiting behavior.
packages/rrweb/test/replay/fixtures/assets.ts New replay fixture including captured assets/statuses + asset events.
packages/rrweb/test/replay/fixtures/assets-mutation.ts New replay fixture for mutation-driven captured asset updates.
packages/rrweb/test/replay/fixtures/assets-src-changed-before-asset-loaded.ts New replay fixture covering live-mode src changes while assets are loading.
packages/rrweb/test/replay/fixtures/assets-body-inline-style.ts New replay fixture for inline <style> assets inside body.
packages/rrweb/test/record/asset.test.ts Large new recorder integration suite for object URLs, origins, stylesheets, timestamps, failures, etc.
packages/rrweb/test/html/assets/subtitles.vtt Add a VTT fixture for track/subtitle asset capture tests.
packages/rrweb/README.md Link to the new asset capture recipe docs and clarify legacy compatibility.
packages/rrweb-snapshot/src/utils.ts Add asset-capture utilities (shouldCaptureAsset, capturable attr map, stringifyCssRules, helpers).
packages/rrweb-snapshot/src/snapshot.ts Detect capturable attributes, emit onAssetDetected, add stylesheet style-id tracking + iframe recursion adjustments.
packages/rrweb-snapshot/src/index.ts Export new snapshot utilities (getHref, getSourcesFromSrcset).
packages/rrweb-snapshot/test/utils.test.ts Add unit tests for shouldCaptureAsset.
packages/rrweb-snapshot/test/snapshot.test.ts Add tests asserting correct onAssetDetected behavior + captured attribute serialization.
packages/browser-client/src/index.ts Default to captureAssets.stylesheets: 'without-fetch' (unless caller overrides / legacy inlineStylesheet provided).
packages/browser-client/test/load-diagnostics.test.ts Add coverage for browser-client asset-capture defaults and legacy mapping behavior.
packages/browser-client/test/integration.test.ts Extend integration tests to verify asset events over WS + HTTP fallback and split public/read keys.
packages/browser-client/test/record.html Update example script-tag config to strict JSON and safe placeholder keys.
packages/browser-client/test/autostart.html Update autostart example to strict JSON format.
packages/browser-client/README.md Document asset-capture defaults and test env key split.
packages/browser-client/.env.example Add VITE_TEST_PUBLIC_API_KEY / VITE_TEST_READ_API_KEY examples + compatibility fallback.
guide.md Document new captureAssets option and legacy mapping in the main guide.
guide.zh_CN.md Document new captureAssets option and legacy mapping in the CN guide.
docs/recipes/index.md Add an “Asset Capture” recipe entry.
docs/recipes/index.zh_CN.md Add a CN “Asset Capture” recipe entry.
docs/recipes/assets.md New asset capture recipe documentation (EN).
docs/recipes/assets.zh_CN.md New asset capture recipe documentation (CN).
.changeset/brave-browsers-remember.md Changeset for patch releases across affected packages.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +15 to +21
// from https://stackoverflow.com/a/6969486/543604
const escapedUrlToReplace = urlToReplace.replace(
/[.*+?^${}()|[\]\\]/g,
'\\$&',
);
const matcher = new RegExp(`(?<=^|[\\s,])${escapedUrlToReplace}(?=[\\s,]|$)`);
const newSrcset = expectedValue.replace(matcher, newURL);
Comment on lines +1100 to +1106
if (captureAssets.stylesheets === undefined) {
if (inlineStylesheet) {
captureAssets.stylesheets = 'without-fetch';
} else {
captureAssets.stylesheets = false;
}
}
Comment on lines +296 to +316
const flushAddEventQueue = () => {
addEventQueueTimeout = -1;
while (addEventQueue.length) {
castOrScheduleEvent(addEventQueue.shift()!);
}
};

if (event.type === EventType.Asset && addEventQueueTimeout) {
let matchUrl = event.data.url;
if (matchUrl.startsWith('rr_css_text')) {
matchUrl = `${awaitAssetsHref}#${matchUrl}`;
}
awaitAssets.delete(matchUrl);
}
if (addEventQueue.length) {
addEventQueue.push(event);
if (awaitAssets.size === 0) {
clearTimeout(addEventQueueTimeout);
flushAddEventQueue();
}
} else {
Comment on lines +141 to +143
} else if (el.getAttribute('media') !== null) {
const linkAppliedQuery = matchMedia(el.getAttribute('media') as string);
if (!linkAppliedQuery.matches) {
Comment on lines +267 to +269
requestIdleCallback(processStylesheet, {
timeout,
});
Comment on lines +981 to +983
// to fix: assets can be emitted in either order
expect(assetEvents).toMatchObject(expected);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants