Skip to content

feat: Implement the x-webview component with its attributes, styles, …#2061

Merged
PupilTong merged 2 commits intolynx-family:mainfrom
PupilTong:p/hw/implement-x-webview
Dec 29, 2025
Merged

feat: Implement the x-webview component with its attributes, styles, …#2061
PupilTong merged 2 commits intolynx-family:mainfrom
PupilTong:p/hw/implement-x-webview

Conversation

@PupilTong
Copy link
Copy Markdown
Collaborator

@PupilTong PupilTong commented Dec 26, 2025

…and tests.

Summary by CodeRabbit

  • New Features

    • Added x-webview component for embedding dynamic content with configurable src/srcdoc and reload support; emits load/error/message events for integration.
  • Documentation

    • Updated developer guidance for attribute handling and testing patterns, including Shadow DOM and hermetic test recommendations.
  • Style

    • Added default styling for the x-webview element.
  • Tests

    • Added end-to-end tests and fixtures validating rendering, attribute updates, load and message events.
  • Chores

    • Added a release changeset.

✏️ Tip: You can customize this high-level summary in your review settings.

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).
  • Changeset added, and when a BREAKING CHANGE occurs, it needs to be clearly marked (or not required).

@PupilTong PupilTong self-assigned this Dec 26, 2025
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Dec 26, 2025

🦋 Changeset detected

Latest commit: 5201d87

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

This PR includes changesets to release 1 package
Name Type
@lynx-js/web-elements 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

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Dec 26, 2025

📝 Walkthrough

Walkthrough

Adds a new x-webview component (element + attribute class), templates, styles, package export, test fixtures, Playwright E2E tests, and updates developer guidance and a changeset documenting the release.

Changes

Cohort / File(s) Summary
Release Documentation
​.changeset/brave-cats-jump.md
New changeset documenting a patch release and introduction of x-webview.
Developer Guidance
packages/web-platform/web-elements/AGENTS.md
Replaces Testing guidance with Attribute Handling rules; mandates Attribute Classes for reactive attributes and updates Playwright test patterns and examples.
Styling
packages/web-platform/web-elements/elements.css, packages/web-platform/web-elements/src/elements/XWebView/x-webview.css
Adds import for x-webview CSS and defines layout/overflow styles for x-webview.
Package Export
packages/web-platform/web-elements/package.json
Adds public export entry ./XWebView pointing to source, types, and built module paths.
Component Implementation
packages/web-platform/web-elements/src/elements/XWebView/XWebView.ts, .../XWebViewAttribute.ts, .../index.ts
New XWebView HTMLElement class with shadow iframe, event forwarding (load, error, message), src/html props and reload(); new XWebViewAttribute reactive attribute class observing src and html; index re-exports component.
Templates & Registry
packages/web-platform/web-elements/src/elements/htmlTemplates.ts, packages/web-platform/web-elements/src/elements/all.ts
Adds templateXWebView (iframe template/style) and imports the XWebView module into the elements aggregator.
Test Fixtures
packages/web-platform/web-elements/tests/fixtures/shell-project.ts, .../tests/fixtures/x-webview/basics.html
Switches shell project imports to local paths; adds HTML fixture for x-webview with event listeners for bindload/bindmessage.
E2E Tests
packages/web-platform/web-elements/tests/x-webview.spec.ts
New Playwright tests: render, src/html attribute behavior, bindload and bindmessage event flows, and network mocking for example.com.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested reviewers

  • Sherry-hue
  • HuJean

Poem

🐰 I hopped a frame into a cozy nest,
A tiny webview stitched and dressed,
I forward loads and whisper msgs true,
Attributes bind, and tests say "woo!" ✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: implementing the x-webview component with its attributes and styles, which matches the changeset that adds the new XWebView web component, attributes, styling, templates, CSS, and comprehensive tests.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
packages/web-platform/web-elements/src/elements/XWebView/x-webview.css (1)

1-5: Consider removing flex-direction: column or making layout configurable.

The hardcoded flex-direction: column may be unnecessarily restrictive. Consider:

  • Removing it to allow natural iframe sizing
  • Or supporting CSS variables like --lynx-linear-orientation for consistency with other elements

Based on learnings, other elements in this package use CSS variables extensively (e.g., --lynx-display, --lynx-linear-orientation) to drive layout from the Lynx engine.

🔎 Optional refactor to remove flex-direction constraint
 x-webview {
   display: flex;
-  flex-direction: column;
   overflow: hidden;
 }
packages/web-platform/web-elements/tests/x-webview.spec.ts (1)

1-92: Test coverage looks good, but consider testing the reload() method.

The tests appropriately cover attribute changes (src, html), rendering, and event handling (bindload, bindmessage). The use of Playwright patterns and the goto helper function align with coding guidelines.

Consider adding test coverage for the reload() method to ensure comprehensive coverage of the public API:

💡 Suggested test for reload() method
test('should reload the iframe', async ({ page }) => {
  await goto(page, 'x-webview/basics');
  const webview = page.locator('x-webview');
  
  // Set initial src
  await webview.evaluate(el => el.setAttribute('src', 'about:blank'));
  
  // Call reload method
  await webview.evaluate(el => (el as any).reload());
  
  // Verify that load event fires again
  await page.waitForFunction(() => window._reload_count > 1);
});

As per coding guidelines: "Ensure test coverage includes attribute changes, style updates, and event handling."

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ccbf3de and cebc859.

📒 Files selected for processing (13)
  • .changeset/brave-cats-jump.md
  • packages/web-platform/web-elements/AGENTS.md
  • packages/web-platform/web-elements/elements.css
  • packages/web-platform/web-elements/package.json
  • packages/web-platform/web-elements/src/elements/XWebView/XWebView.ts
  • packages/web-platform/web-elements/src/elements/XWebView/XWebViewAttribute.ts
  • packages/web-platform/web-elements/src/elements/XWebView/index.ts
  • packages/web-platform/web-elements/src/elements/XWebView/x-webview.css
  • packages/web-platform/web-elements/src/elements/all.ts
  • packages/web-platform/web-elements/src/elements/htmlTemplates.ts
  • packages/web-platform/web-elements/tests/fixtures/shell-project.ts
  • packages/web-platform/web-elements/tests/fixtures/x-webview/basics.html
  • packages/web-platform/web-elements/tests/x-webview.spec.ts
🧰 Additional context used
📓 Path-based instructions (12)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Use TypeScript in strict mode with the configuration specified in tsconfig.json

Files:

  • packages/web-platform/web-elements/src/elements/htmlTemplates.ts
  • packages/web-platform/web-elements/src/elements/all.ts
  • packages/web-platform/web-elements/tests/x-webview.spec.ts
  • packages/web-platform/web-elements/src/elements/XWebView/XWebViewAttribute.ts
  • packages/web-platform/web-elements/src/elements/XWebView/index.ts
  • packages/web-platform/web-elements/src/elements/XWebView/XWebView.ts
  • packages/web-platform/web-elements/tests/fixtures/shell-project.ts
**/*.{js,ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{js,ts,tsx}: Follow eslint rules as configured in eslint.config.js including React and TypeScript specific rules
Follow code formatting rules specified in .dprint.jsonc and biome.jsonc

Files:

  • packages/web-platform/web-elements/src/elements/htmlTemplates.ts
  • packages/web-platform/web-elements/src/elements/all.ts
  • packages/web-platform/web-elements/tests/x-webview.spec.ts
  • packages/web-platform/web-elements/src/elements/XWebView/XWebViewAttribute.ts
  • packages/web-platform/web-elements/src/elements/XWebView/index.ts
  • packages/web-platform/web-elements/src/elements/XWebView/XWebView.ts
  • packages/web-platform/web-elements/tests/fixtures/shell-project.ts
packages/web-platform/web-elements/**/*.ts

📄 CodeRabbit inference engine (packages/web-platform/web-elements/AGENTS.md)

packages/web-platform/web-elements/**/*.ts: Use element-reactive patterns: inherit from Element (via Component decorator) and use reactive utilities when creating new elements
Avoid synchronous layout thrashing by using boostedQueueMicrotask for DOM reads/writes when accurate layout info isn't immediately needed
Use CSS variables extensively (e.g., --lynx-display, --lynx-linear-orientation) to drive layout and style from the Lynx engine

Files:

  • packages/web-platform/web-elements/src/elements/htmlTemplates.ts
  • packages/web-platform/web-elements/src/elements/all.ts
  • packages/web-platform/web-elements/tests/x-webview.spec.ts
  • packages/web-platform/web-elements/src/elements/XWebView/XWebViewAttribute.ts
  • packages/web-platform/web-elements/src/elements/XWebView/index.ts
  • packages/web-platform/web-elements/src/elements/XWebView/XWebView.ts
  • packages/web-platform/web-elements/tests/fixtures/shell-project.ts
packages/web-platform/web-elements/src/elements/**/*.ts

📄 CodeRabbit inference engine (packages/web-platform/web-elements/AGENTS.md)

packages/web-platform/web-elements/src/elements/**/*.ts: Define shadow DOM templates in src/elements/htmlTemplates.ts rather than inline within element files
Tag names must use kebab-case; single-word names should be prefixed with x- (e.g., x-view, scroll-view)
Minimize heavy computation in attributeChangedCallback to keep main thread responsive

Files:

  • packages/web-platform/web-elements/src/elements/htmlTemplates.ts
  • packages/web-platform/web-elements/src/elements/all.ts
  • packages/web-platform/web-elements/src/elements/XWebView/XWebViewAttribute.ts
  • packages/web-platform/web-elements/src/elements/XWebView/index.ts
  • packages/web-platform/web-elements/src/elements/XWebView/XWebView.ts
packages/web-platform/web-elements/src/elements/**/!(index).ts

📄 CodeRabbit inference engine (packages/web-platform/web-elements/AGENTS.md)

Use PascalCase for class names (e.g., MyElement)

Files:

  • packages/web-platform/web-elements/src/elements/htmlTemplates.ts
  • packages/web-platform/web-elements/src/elements/all.ts
  • packages/web-platform/web-elements/src/elements/XWebView/XWebViewAttribute.ts
  • packages/web-platform/web-elements/src/elements/XWebView/XWebView.ts
packages/web-platform/web-elements/src/elements/**/*.css

📄 CodeRabbit inference engine (packages/web-platform/web-elements/AGENTS.md)

Write CSS in <element-name>.css in the element's directory and ensure it's imported in elements.css

Files:

  • packages/web-platform/web-elements/src/elements/XWebView/x-webview.css
packages/web-platform/web-elements/**/*.css

📄 CodeRabbit inference engine (packages/web-platform/web-elements/AGENTS.md)

For x-input, x-textarea, and x-image elements, control styling properties like placeholder colors or blur radii via attributes (e.g., placeholder-color, blur-radius) that internally map to CSS variables

Files:

  • packages/web-platform/web-elements/src/elements/XWebView/x-webview.css
  • packages/web-platform/web-elements/elements.css
packages/web-platform/web-elements/src/elements/all.ts

📄 CodeRabbit inference engine (packages/web-platform/web-elements/AGENTS.md)

Export all new components in src/elements/all.ts to ensure they are registered

Files:

  • packages/web-platform/web-elements/src/elements/all.ts
packages/web-platform/web-elements/**/package.json

📄 CodeRabbit inference engine (packages/web-platform/web-elements/AGENTS.md)

Add export configuration under "exports" field for newly implemented components (types and default)

Files:

  • packages/web-platform/web-elements/package.json
packages/web-platform/web-elements/tests/**/*.spec.ts

📄 CodeRabbit inference engine (packages/web-platform/web-elements/AGENTS.md)

packages/web-platform/web-elements/tests/**/*.spec.ts: Use Playwright for all E2E and functional tests with standard assertions like expect(locator).toBeVisible() and expect(locator).toHaveCSS()
Create a helper function goto(page, fixtureName) to handle navigation and waiting for resources like document.fonts.ready in Playwright tests
Ensure test coverage includes attribute changes, style updates, and event handling

Files:

  • packages/web-platform/web-elements/tests/x-webview.spec.ts
packages/web-platform/web-elements/src/elements/**/index.ts

📄 CodeRabbit inference engine (packages/web-platform/web-elements/AGENTS.md)

Ensure index.ts files and complex logic have clear, descriptive comments matching the implementation

Files:

  • packages/web-platform/web-elements/src/elements/XWebView/index.ts
packages/web-platform/web-elements/tests/fixtures/**/*.html

📄 CodeRabbit inference engine (packages/web-platform/web-elements/AGENTS.md)

Use HTML files for test case fixtures with one HTML file per test case/feature (Atomic Testing approach)

Files:

  • packages/web-platform/web-elements/tests/fixtures/x-webview/basics.html
🧠 Learnings (42)
📓 Common learnings
Learnt from: CR
Repo: lynx-family/lynx-stack PR: 0
File: packages/web-platform/web-elements/AGENTS.md:0-0
Timestamp: 2025-12-26T07:42:21.745Z
Learning: The `web-elements` package provides Native UI implementation using Web Components built on the `element-reactive` lightweight reactive framework for performance
Learnt from: CR
Repo: lynx-family/lynx-stack PR: 0
File: packages/web-platform/web-elements/AGENTS.md:0-0
Timestamp: 2025-12-26T07:42:21.745Z
Learning: Applies to packages/web-platform/web-elements/**/*.ts : Use CSS variables extensively (e.g., `--lynx-display`, `--lynx-linear-orientation`) to drive layout and style from the Lynx engine
📚 Learning: 2025-12-26T07:42:21.745Z
Learnt from: CR
Repo: lynx-family/lynx-stack PR: 0
File: packages/web-platform/web-elements/AGENTS.md:0-0
Timestamp: 2025-12-26T07:42:21.745Z
Learning: Applies to packages/web-platform/web-elements/src/elements/**/*.ts : Define shadow DOM templates in `src/elements/htmlTemplates.ts` rather than inline within element files

Applied to files:

  • packages/web-platform/web-elements/src/elements/htmlTemplates.ts
  • packages/web-platform/web-elements/src/elements/XWebView/x-webview.css
  • packages/web-platform/web-elements/src/elements/all.ts
  • packages/web-platform/web-elements/package.json
  • packages/web-platform/web-elements/tests/x-webview.spec.ts
  • packages/web-platform/web-elements/elements.css
  • packages/web-platform/web-elements/src/elements/XWebView/XWebViewAttribute.ts
  • packages/web-platform/web-elements/src/elements/XWebView/index.ts
  • packages/web-platform/web-elements/src/elements/XWebView/XWebView.ts
  • packages/web-platform/web-elements/tests/fixtures/shell-project.ts
  • packages/web-platform/web-elements/AGENTS.md
📚 Learning: 2025-12-26T07:42:21.745Z
Learnt from: CR
Repo: lynx-family/lynx-stack PR: 0
File: packages/web-platform/web-elements/AGENTS.md:0-0
Timestamp: 2025-12-26T07:42:21.745Z
Learning: Applies to packages/web-platform/web-elements/**/*.ts : Use `element-reactive` patterns: inherit from `Element` (via `Component` decorator) and use reactive utilities when creating new elements

Applied to files:

  • packages/web-platform/web-elements/src/elements/htmlTemplates.ts
  • packages/web-platform/web-elements/src/elements/all.ts
  • packages/web-platform/web-elements/package.json
  • packages/web-platform/web-elements/elements.css
  • packages/web-platform/web-elements/src/elements/XWebView/XWebViewAttribute.ts
  • packages/web-platform/web-elements/src/elements/XWebView/index.ts
  • packages/web-platform/web-elements/src/elements/XWebView/XWebView.ts
  • packages/web-platform/web-elements/AGENTS.md
📚 Learning: 2025-12-26T07:42:21.745Z
Learnt from: CR
Repo: lynx-family/lynx-stack PR: 0
File: packages/web-platform/web-elements/AGENTS.md:0-0
Timestamp: 2025-12-26T07:42:21.745Z
Learning: Applies to packages/web-platform/web-elements/src/elements/**/index.ts : Ensure `index.ts` files and complex logic have clear, descriptive comments matching the implementation

Applied to files:

  • packages/web-platform/web-elements/src/elements/htmlTemplates.ts
  • packages/web-platform/web-elements/src/elements/all.ts
  • packages/web-platform/web-elements/package.json
  • packages/web-platform/web-elements/src/elements/XWebView/XWebViewAttribute.ts
  • packages/web-platform/web-elements/src/elements/XWebView/index.ts
  • packages/web-platform/web-elements/src/elements/XWebView/XWebView.ts
  • packages/web-platform/web-elements/tests/fixtures/shell-project.ts
  • packages/web-platform/web-elements/AGENTS.md
📚 Learning: 2025-12-26T07:42:21.745Z
Learnt from: CR
Repo: lynx-family/lynx-stack PR: 0
File: packages/web-platform/web-elements/AGENTS.md:0-0
Timestamp: 2025-12-26T07:42:21.745Z
Learning: Applies to packages/web-platform/web-elements/**/*.ts : Use CSS variables extensively (e.g., `--lynx-display`, `--lynx-linear-orientation`) to drive layout and style from the Lynx engine

Applied to files:

  • packages/web-platform/web-elements/src/elements/htmlTemplates.ts
  • packages/web-platform/web-elements/src/elements/XWebView/x-webview.css
  • packages/web-platform/web-elements/src/elements/all.ts
  • packages/web-platform/web-elements/package.json
  • .changeset/brave-cats-jump.md
  • packages/web-platform/web-elements/elements.css
  • packages/web-platform/web-elements/src/elements/XWebView/XWebViewAttribute.ts
  • packages/web-platform/web-elements/src/elements/XWebView/index.ts
  • packages/web-platform/web-elements/src/elements/XWebView/XWebView.ts
  • packages/web-platform/web-elements/tests/fixtures/shell-project.ts
📚 Learning: 2025-12-26T07:42:21.745Z
Learnt from: CR
Repo: lynx-family/lynx-stack PR: 0
File: packages/web-platform/web-elements/AGENTS.md:0-0
Timestamp: 2025-12-26T07:42:21.745Z
Learning: Applies to packages/web-platform/web-elements/src/elements/**/*.ts : Tag names must use kebab-case; single-word names should be prefixed with `x-` (e.g., `x-view`, `scroll-view`)

Applied to files:

  • packages/web-platform/web-elements/src/elements/htmlTemplates.ts
  • packages/web-platform/web-elements/src/elements/all.ts
  • packages/web-platform/web-elements/package.json
  • packages/web-platform/web-elements/src/elements/XWebView/XWebViewAttribute.ts
  • packages/web-platform/web-elements/src/elements/XWebView/index.ts
  • packages/web-platform/web-elements/src/elements/XWebView/XWebView.ts
  • packages/web-platform/web-elements/AGENTS.md
📚 Learning: 2025-12-26T07:42:21.745Z
Learnt from: CR
Repo: lynx-family/lynx-stack PR: 0
File: packages/web-platform/web-elements/AGENTS.md:0-0
Timestamp: 2025-12-26T07:42:21.745Z
Learning: Applies to packages/web-platform/web-elements/**/package.json : Add export configuration under `"exports"` field for newly implemented components (types and default)

Applied to files:

  • packages/web-platform/web-elements/src/elements/htmlTemplates.ts
  • packages/web-platform/web-elements/src/elements/all.ts
  • packages/web-platform/web-elements/package.json
  • .changeset/brave-cats-jump.md
  • packages/web-platform/web-elements/elements.css
  • packages/web-platform/web-elements/src/elements/XWebView/XWebViewAttribute.ts
  • packages/web-platform/web-elements/src/elements/XWebView/index.ts
  • packages/web-platform/web-elements/src/elements/XWebView/XWebView.ts
  • packages/web-platform/web-elements/tests/fixtures/shell-project.ts
  • packages/web-platform/web-elements/AGENTS.md
📚 Learning: 2025-12-26T07:42:21.745Z
Learnt from: CR
Repo: lynx-family/lynx-stack PR: 0
File: packages/web-platform/web-elements/AGENTS.md:0-0
Timestamp: 2025-12-26T07:42:21.745Z
Learning: Applies to packages/web-platform/web-elements/src/elements/all.ts : Export all new components in `src/elements/all.ts` to ensure they are registered

Applied to files:

  • packages/web-platform/web-elements/src/elements/htmlTemplates.ts
  • packages/web-platform/web-elements/src/elements/all.ts
  • packages/web-platform/web-elements/package.json
  • packages/web-platform/web-elements/elements.css
  • packages/web-platform/web-elements/src/elements/XWebView/index.ts
  • packages/web-platform/web-elements/src/elements/XWebView/XWebView.ts
  • packages/web-platform/web-elements/tests/fixtures/shell-project.ts
  • packages/web-platform/web-elements/AGENTS.md
📚 Learning: 2025-12-26T07:42:21.745Z
Learnt from: CR
Repo: lynx-family/lynx-stack PR: 0
File: packages/web-platform/web-elements/AGENTS.md:0-0
Timestamp: 2025-12-26T07:42:21.745Z
Learning: Applies to packages/web-platform/web-elements/src/elements/**/*.css : Write CSS in `<element-name>.css` in the element's directory and ensure it's imported in `elements.css`

Applied to files:

  • packages/web-platform/web-elements/src/elements/XWebView/x-webview.css
  • packages/web-platform/web-elements/src/elements/all.ts
  • packages/web-platform/web-elements/package.json
  • packages/web-platform/web-elements/elements.css
  • packages/web-platform/web-elements/tests/fixtures/shell-project.ts
📚 Learning: 2025-12-26T07:42:21.745Z
Learnt from: CR
Repo: lynx-family/lynx-stack PR: 0
File: packages/web-platform/web-elements/AGENTS.md:0-0
Timestamp: 2025-12-26T07:42:21.745Z
Learning: Applies to packages/web-platform/web-elements/**/*.css : For `x-input`, `x-textarea`, and `x-image` elements, control styling properties like placeholder colors or blur radii via attributes (e.g., `placeholder-color`, `blur-radius`) that internally map to CSS variables

Applied to files:

  • packages/web-platform/web-elements/src/elements/XWebView/x-webview.css
  • packages/web-platform/web-elements/elements.css
  • packages/web-platform/web-elements/src/elements/XWebView/XWebViewAttribute.ts
📚 Learning: 2025-09-18T08:12:56.802Z
Learnt from: Sherry-hue
Repo: lynx-family/lynx-stack PR: 1770
File: packages/web-platform/web-mainthread-apis/src/utils/processStyleInfo.ts:316-318
Timestamp: 2025-09-18T08:12:56.802Z
Learning: In packages/web-platform/web-mainthread-apis/src/utils/processStyleInfo.ts, the current implementation uses cardStyleElement.textContent += for lazy component styles. While this could theoretically invalidate rule indices by reparsing the stylesheet, Sherry-hue indicated that UIDs don't repeat for the same element, making this approach acceptable for now. A future optimization to use separate style elements per entry was discussed but deferred to a separate PR to keep the current lazy bundle PR focused.

Applied to files:

  • packages/web-platform/web-elements/src/elements/XWebView/x-webview.css
  • packages/web-platform/web-elements/elements.css
📚 Learning: 2025-12-26T07:42:21.745Z
Learnt from: CR
Repo: lynx-family/lynx-stack PR: 0
File: packages/web-platform/web-elements/AGENTS.md:0-0
Timestamp: 2025-12-26T07:42:21.745Z
Learning: Applies to packages/web-platform/web-elements/tests/**/*.spec.ts : Ensure test coverage includes attribute changes, style updates, and event handling

Applied to files:

  • packages/web-platform/web-elements/src/elements/all.ts
  • packages/web-platform/web-elements/tests/x-webview.spec.ts
  • packages/web-platform/web-elements/src/elements/XWebView/XWebViewAttribute.ts
  • packages/web-platform/web-elements/tests/fixtures/x-webview/basics.html
  • packages/web-platform/web-elements/tests/fixtures/shell-project.ts
  • packages/web-platform/web-elements/AGENTS.md
📚 Learning: 2025-12-26T07:42:21.745Z
Learnt from: CR
Repo: lynx-family/lynx-stack PR: 0
File: packages/web-platform/web-elements/AGENTS.md:0-0
Timestamp: 2025-12-26T07:42:21.745Z
Learning: Applies to packages/web-platform/web-elements/src/elements/**/*.ts : Minimize heavy computation in `attributeChangedCallback` to keep main thread responsive

Applied to files:

  • packages/web-platform/web-elements/src/elements/all.ts
  • packages/web-platform/web-elements/src/elements/XWebView/XWebViewAttribute.ts
  • packages/web-platform/web-elements/src/elements/XWebView/index.ts
  • packages/web-platform/web-elements/src/elements/XWebView/XWebView.ts
  • packages/web-platform/web-elements/AGENTS.md
📚 Learning: 2025-10-10T08:22:12.051Z
Learnt from: Sherry-hue
Repo: lynx-family/lynx-stack PR: 1837
File: packages/web-platform/web-mainthread-apis/src/prepareMainThreadAPIs.ts:266-266
Timestamp: 2025-10-10T08:22:12.051Z
Learning: In packages/web-platform/web-mainthread-apis, the handleUpdatedData function returned from prepareMainThreadAPIs is internal-only, used to serve web-core. It does not require public documentation, type exports, or SSR support.

Applied to files:

  • packages/web-platform/web-elements/package.json
  • packages/web-platform/web-elements/src/elements/XWebView/index.ts
📚 Learning: 2025-12-26T05:10:16.728Z
Learnt from: CR
Repo: lynx-family/lynx-stack PR: 0
File: packages/web-platform/web-core-wasm/AGENTS.md:0-0
Timestamp: 2025-12-26T05:10:16.728Z
Learning: Applies to packages/web-platform/web-core-wasm/**/AGENTS.md : Check if `AGENTS.md` needs to be updated to reflect your changes (e.g., new feature flags, structural changes, new dependencies).

Applied to files:

  • packages/web-platform/web-elements/package.json
  • packages/web-platform/web-elements/AGENTS.md
📚 Learning: 2025-12-26T07:42:21.745Z
Learnt from: CR
Repo: lynx-family/lynx-stack PR: 0
File: packages/web-platform/web-elements/AGENTS.md:0-0
Timestamp: 2025-12-26T07:42:21.745Z
Learning: The `web-elements` package provides Native UI implementation using Web Components built on the `element-reactive` lightweight reactive framework for performance

Applied to files:

  • packages/web-platform/web-elements/package.json
  • .changeset/brave-cats-jump.md
📚 Learning: 2025-12-26T07:42:21.745Z
Learnt from: CR
Repo: lynx-family/lynx-stack PR: 0
File: packages/web-platform/web-elements/AGENTS.md:0-0
Timestamp: 2025-12-26T07:42:21.745Z
Learning: Applies to packages/web-platform/web-elements/src/elements/**/!(index).ts : Use PascalCase for class names (e.g., `MyElement`)

Applied to files:

  • packages/web-platform/web-elements/package.json
  • packages/web-platform/web-elements/src/elements/XWebView/index.ts
📚 Learning: 2025-12-26T07:42:21.745Z
Learnt from: CR
Repo: lynx-family/lynx-stack PR: 0
File: packages/web-platform/web-elements/AGENTS.md:0-0
Timestamp: 2025-12-26T07:42:21.745Z
Learning: Applies to packages/web-platform/web-elements/tests/**/*.spec.ts : Use Playwright for all E2E and functional tests with standard assertions like `expect(locator).toBeVisible()` and `expect(locator).toHaveCSS()`

Applied to files:

  • packages/web-platform/web-elements/tests/x-webview.spec.ts
  • packages/web-platform/web-elements/tests/fixtures/x-webview/basics.html
  • packages/web-platform/web-elements/tests/fixtures/shell-project.ts
  • packages/web-platform/web-elements/AGENTS.md
📚 Learning: 2025-12-26T05:10:01.595Z
Learnt from: CR
Repo: lynx-family/lynx-stack PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-26T05:10:01.595Z
Learning: Applies to packages/web-platform/web-tests/**/*.{ts,tsx,js} : Use Playwright for E2E tests in packages/web-platform/web-tests/

Applied to files:

  • packages/web-platform/web-elements/tests/x-webview.spec.ts
  • packages/web-platform/web-elements/tests/fixtures/shell-project.ts
  • packages/web-platform/web-elements/AGENTS.md
📚 Learning: 2025-12-26T05:10:16.728Z
Learnt from: CR
Repo: lynx-family/lynx-stack PR: 0
File: packages/web-platform/web-core-wasm/AGENTS.md:0-0
Timestamp: 2025-12-26T05:10:16.728Z
Learning: Applies to packages/web-platform/web-core-wasm/**/*.rs : Ensure that tests cover edge cases and verify the correctness of the logic.

Applied to files:

  • packages/web-platform/web-elements/tests/x-webview.spec.ts
  • packages/web-platform/web-elements/tests/fixtures/x-webview/basics.html
  • packages/web-platform/web-elements/AGENTS.md
📚 Learning: 2025-12-26T07:42:21.745Z
Learnt from: CR
Repo: lynx-family/lynx-stack PR: 0
File: packages/web-platform/web-elements/AGENTS.md:0-0
Timestamp: 2025-12-26T07:42:21.745Z
Learning: Applies to packages/web-platform/web-elements/tests/fixtures/**/*.html : Use HTML files for test case fixtures with one HTML file per test case/feature (Atomic Testing approach)

Applied to files:

  • packages/web-platform/web-elements/tests/x-webview.spec.ts
  • packages/web-platform/web-elements/tests/fixtures/x-webview/basics.html
  • packages/web-platform/web-elements/tests/fixtures/shell-project.ts
  • packages/web-platform/web-elements/AGENTS.md
📚 Learning: 2025-12-26T05:10:16.728Z
Learnt from: CR
Repo: lynx-family/lynx-stack PR: 0
File: packages/web-platform/web-core-wasm/AGENTS.md:0-0
Timestamp: 2025-12-26T05:10:16.728Z
Learning: Applies to packages/web-platform/web-core-wasm/**/*.rs : Use descriptive test names that explain what is being tested (e.g., `test_transform_rpx_case_insensitive`).

Applied to files:

  • packages/web-platform/web-elements/tests/x-webview.spec.ts
  • packages/web-platform/web-elements/tests/fixtures/x-webview/basics.html
📚 Learning: 2025-12-26T05:10:16.728Z
Learnt from: CR
Repo: lynx-family/lynx-stack PR: 0
File: packages/web-platform/web-core-wasm/AGENTS.md:0-0
Timestamp: 2025-12-26T05:10:16.728Z
Learning: Applies to packages/web-platform/web-core-wasm/**/*.rs : All new features and bug fixes must be accompanied by unit tests.

Applied to files:

  • packages/web-platform/web-elements/tests/x-webview.spec.ts
  • packages/web-platform/web-elements/tests/fixtures/x-webview/basics.html
  • packages/web-platform/web-elements/AGENTS.md
📚 Learning: 2025-12-26T07:42:21.745Z
Learnt from: CR
Repo: lynx-family/lynx-stack PR: 0
File: packages/web-platform/web-elements/AGENTS.md:0-0
Timestamp: 2025-12-26T07:42:21.745Z
Learning: Applies to packages/web-platform/web-elements/tests/**/*.spec.ts : Create a helper function `goto(page, fixtureName)` to handle navigation and waiting for resources like `document.fonts.ready` in Playwright tests

Applied to files:

  • packages/web-platform/web-elements/tests/x-webview.spec.ts
  • packages/web-platform/web-elements/tests/fixtures/x-webview/basics.html
  • packages/web-platform/web-elements/AGENTS.md
📚 Learning: 2025-12-26T05:10:16.728Z
Learnt from: CR
Repo: lynx-family/lynx-stack PR: 0
File: packages/web-platform/web-core-wasm/AGENTS.md:0-0
Timestamp: 2025-12-26T05:10:16.728Z
Learning: Applies to packages/web-platform/web-core-wasm/**/*.rs : Check if the comments in the code need to be updated to reflect your changes.

Applied to files:

  • packages/web-platform/web-elements/tests/x-webview.spec.ts
  • packages/web-platform/web-elements/elements.css
  • packages/web-platform/web-elements/tests/fixtures/shell-project.ts
📚 Learning: 2025-12-26T05:10:16.728Z
Learnt from: CR
Repo: lynx-family/lynx-stack PR: 0
File: packages/web-platform/web-core-wasm/AGENTS.md:0-0
Timestamp: 2025-12-26T05:10:16.728Z
Learning: Applies to packages/web-platform/web-core-wasm/**/*.rs : Run `cargo test --all-features` to execute unit tests. Tests are co-located with the source code using `#[cfg(test)]`.

Applied to files:

  • packages/web-platform/web-elements/tests/x-webview.spec.ts
📚 Learning: 2025-12-26T05:10:16.728Z
Learnt from: CR
Repo: lynx-family/lynx-stack PR: 0
File: packages/web-platform/web-core-wasm/AGENTS.md:0-0
Timestamp: 2025-12-26T05:10:16.728Z
Learning: Applies to packages/web-platform/web-core-wasm/**/*.rs : Verify that the implementation matches the comments and the intended behavior.

Applied to files:

  • packages/web-platform/web-elements/tests/x-webview.spec.ts
📚 Learning: 2025-08-27T12:42:01.095Z
Learnt from: upupming
Repo: lynx-family/lynx-stack PR: 1616
File: packages/webpack/cache-events-webpack-plugin/test/cases/not-cache-events/lazy-bundle/index.js:3-3
Timestamp: 2025-08-27T12:42:01.095Z
Learning: In webpack, properties like __webpack_require__.lynx_ce are injected during compilation/build time when webpack processes modules and generates bundles, not at runtime when dynamic imports execute. Tests for such properties don't need to wait for dynamic imports to complete.

Applied to files:

  • packages/web-platform/web-elements/tests/x-webview.spec.ts
  • packages/web-platform/web-elements/tests/fixtures/shell-project.ts
📚 Learning: 2025-09-12T09:43:04.847Z
Learnt from: gaoachao
Repo: lynx-family/lynx-stack PR: 1736
File: .changeset/spotty-experts-smoke.md:1-3
Timestamp: 2025-09-12T09:43:04.847Z
Learning: In the lynx-family/lynx-stack repository, empty changeset files (containing only `---\n\n---`) are used for internal changes that modify src/** files but don't require meaningful release notes, such as private package changes or testing-only modifications. This satisfies CI requirements without generating user-facing release notes.

Applied to files:

  • .changeset/brave-cats-jump.md
📚 Learning: 2025-07-22T09:23:07.797Z
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1330
File: .changeset/olive-animals-attend.md:1-3
Timestamp: 2025-07-22T09:23:07.797Z
Learning: In the lynx-family/lynx-stack repository, changesets are only required for meaningful changes to end-users such as bugfixes and features. Internal/development changes like chores, refactoring, or removing debug info do not need changeset entries.

Applied to files:

  • .changeset/brave-cats-jump.md
📚 Learning: 2025-07-22T09:26:16.722Z
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1330
File: .changeset/olive-animals-attend.md:1-3
Timestamp: 2025-07-22T09:26:16.722Z
Learning: In the lynx-family/lynx-stack repository, CI checks require changesets when files matching the pattern "src/**" are modified (as configured in .changeset/config.json). For internal changes that don't need meaningful changesets, an empty changeset file is used to satisfy the CI requirement while not generating any release notes.

Applied to files:

  • .changeset/brave-cats-jump.md
📚 Learning: 2025-09-12T09:43:04.847Z
Learnt from: gaoachao
Repo: lynx-family/lynx-stack PR: 1736
File: .changeset/spotty-experts-smoke.md:1-3
Timestamp: 2025-09-12T09:43:04.847Z
Learning: In the lynx-family/lynx-stack repository, private packages (marked with "private": true in package.json) like lynx-js/react-transform don't require meaningful changeset entries even when their public APIs change, since they are not published externally and only affect internal development.

Applied to files:

  • .changeset/brave-cats-jump.md
📚 Learning: 2025-08-07T04:00:59.645Z
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1454
File: pnpm-workspace.yaml:46-46
Timestamp: 2025-08-07T04:00:59.645Z
Learning: In the lynx-family/lynx-stack repository, the webpack patch (patches/webpack5.101.0.patch) was created to fix issues with webpack5.99.9 but only takes effect on webpack5.100.0 and later versions. The patchedDependencies entry should use "webpack@^5.100.0" to ensure the patch applies to the correct version range.

Applied to files:

  • .changeset/brave-cats-jump.md
📚 Learning: 2025-11-03T08:44:10.706Z
Learnt from: Sherry-hue
Repo: lynx-family/lynx-stack PR: 1911
File: packages/web-platform/web-elements/src/XList/ListItemAttributes.ts:24-29
Timestamp: 2025-11-03T08:44:10.706Z
Learning: In packages/web-platform/web-elements/src/XList/ListItemAttributes.ts, the `estimated-main-axis-size-px` attribute handler does not need to validate or guard against invalid/NaN values when parsing - data correctness verification is not required for this attribute.

Applied to files:

  • packages/web-platform/web-elements/src/elements/XWebView/XWebViewAttribute.ts
  • packages/web-platform/web-elements/AGENTS.md
📚 Learning: 2025-12-26T07:42:21.745Z
Learnt from: CR
Repo: lynx-family/lynx-stack PR: 0
File: packages/web-platform/web-elements/AGENTS.md:0-0
Timestamp: 2025-12-26T07:42:21.745Z
Learning: Applies to packages/web-platform/web-elements/**/*.ts : Avoid synchronous layout thrashing by using `boostedQueueMicrotask` for DOM reads/writes when accurate layout info isn't immediately needed

Applied to files:

  • packages/web-platform/web-elements/src/elements/XWebView/XWebView.ts
📚 Learning: 2025-10-11T06:16:12.517Z
Learnt from: Sherry-hue
Repo: lynx-family/lynx-stack PR: 1820
File: packages/web-platform/web-tests/tests/react.spec.ts:834-856
Timestamp: 2025-10-11T06:16:12.517Z
Learning: In packages/web-platform/web-tests/tests/react.spec.ts, the tests `basic-bindmouse` and `basic-mts-bindtouchstart` are NOT duplicates despite having similar test structures. They test different event types: `basic-bindmouse` validates mouse events (mousedown, mouseup, mousemove) with mouse-specific properties (button, buttons, x, y, pageX, pageY, clientX, clientY), while `basic-mts-bindtouchstart` validates touch events (touchstart) with touch arrays (touches, targetTouches, changedTouches). The similar test structure is coincidental and follows testing conventions.

Applied to files:

  • packages/web-platform/web-elements/tests/fixtures/x-webview/basics.html
  • packages/web-platform/web-elements/AGENTS.md
📚 Learning: 2025-11-11T08:05:14.163Z
Learnt from: Sherry-hue
Repo: lynx-family/lynx-stack PR: 1932
File: packages/web-platform/web-tests/tests/react/basic-element-x-input-ng-bindinput/index.jsx:10-26
Timestamp: 2025-11-11T08:05:14.163Z
Learning: In packages/web-platform/web-tests/tests/react/basic-element-x-input-ng-bindinput/index.jsx, the test intentionally uses selectionStart twice in the result string (instead of selectionStart and selectionEnd) because it prioritizes testing whether x-input-ng works functionally, rather than validating the correctness of selection values.

Applied to files:

  • packages/web-platform/web-elements/tests/fixtures/x-webview/basics.html
📚 Learning: 2025-12-26T05:10:01.595Z
Learnt from: CR
Repo: lynx-family/lynx-stack PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-26T05:10:01.595Z
Learning: Applies to packages/react/components/**/*.{ts,tsx} : Optimize component library in packages/react/components/ using ReactLynx syntax

Applied to files:

  • packages/web-platform/web-elements/tests/fixtures/shell-project.ts
📚 Learning: 2025-07-16T06:28:26.463Z
Learnt from: PupilTong
Repo: lynx-family/lynx-stack PR: 1029
File: packages/web-platform/web-core/src/uiThread/createRenderAllOnUI.ts:95-99
Timestamp: 2025-07-16T06:28:26.463Z
Learning: In the lynx-stack codebase, CSS selectors in SSR hydration are generated by their own packages, ensuring a predictable format that makes simple string manipulation safe and preferable over regex for performance reasons.

Applied to files:

  • packages/web-platform/web-elements/tests/fixtures/shell-project.ts
📚 Learning: 2025-08-13T11:46:43.737Z
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1523
File: vitest.config.ts:5-6
Timestamp: 2025-08-13T11:46:43.737Z
Learning: In the lynx-stack codebase, default imports are consistently used for Node.js built-in modules (e.g., `import os from 'node:os'`, `import fs from 'node:fs'`). The TypeScript configuration supports esModuleInterop and allowSyntheticDefaultImports, making default imports the preferred pattern over namespace imports for Node.js built-ins.

Applied to files:

  • packages/web-platform/web-elements/tests/fixtures/shell-project.ts
📚 Learning: 2025-08-06T13:28:57.182Z
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1453
File: vitest.config.ts:49-61
Timestamp: 2025-08-06T13:28:57.182Z
Learning: In the lynx-family/lynx-stack repository, the file `packages/react/testing-library/src/vitest.config.js` is source code for the testing library that gets exported for users, not a test configuration that should be included in the main vitest projects array.

Applied to files:

  • packages/web-platform/web-elements/tests/fixtures/shell-project.ts
📚 Learning: 2025-12-26T05:10:01.595Z
Learnt from: CR
Repo: lynx-family/lynx-stack PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-26T05:10:01.595Z
Learning: Applies to **/__test__/**/*.{ts,tsx,js} : Use vitest-based unit tests as configured in vitest.config.ts

Applied to files:

  • packages/web-platform/web-elements/AGENTS.md
🧬 Code graph analysis (2)
packages/web-platform/web-elements/src/elements/XWebView/XWebViewAttribute.ts (1)
packages/web-platform/web-core-wasm/src/main_thread/element_apis/element_template_apis.rs (1)
  • dom (157-157)
packages/web-platform/web-elements/src/elements/XWebView/XWebView.ts (3)
packages/web-platform/web-elements/src/elements/XWebView/index.ts (1)
  • XWebView (22-22)
packages/web-platform/web-elements/src/elements/XWebView/XWebViewAttribute.ts (1)
  • XWebViewAttribute (13-33)
packages/web-platform/web-elements/src/elements/htmlTemplates.ts (1)
  • templateXWebView (345-352)
🔇 Additional comments (13)
packages/web-platform/web-elements/AGENTS.md (1)

111-166: Excellent documentation updates for the new component pattern.

The additions provide critical guidance on:

  • Attribute handling pattern (avoiding a common pitfall with @registerAttributeHandler)
  • Test structure best practices (separate spec files, network mocking)
  • Shadow DOM access strategies in Playwright

These documentation updates are comprehensive and will help prevent common mistakes.

.changeset/brave-cats-jump.md (1)

1-5: LGTM!

The changeset correctly documents this as a patch release for the new x-webview component feature.

packages/web-platform/web-elements/elements.css (1)

19-19: LGTM!

The CSS import follows the established pattern and correctly references the new x-webview.css file.

packages/web-platform/web-elements/src/elements/htmlTemplates.ts (1)

345-352: LGTM!

The template follows the established pattern with:

  • Proper iframe styling (fills container, no border)
  • id="webview" for internal access via genDomGetter
  • part="webview" for external styling via ::part()

The structure is consistent with other templates in this file.

packages/web-platform/web-elements/src/elements/all.ts (1)

18-18: LGTM!

The import correctly registers the XWebView component following the established pattern.

packages/web-platform/web-elements/tests/fixtures/shell-project.ts (1)

1-5: LGTM!

The change to local source imports ensures test fixtures use the current local build rather than the published package, which is appropriate for hermetic testing.

packages/web-platform/web-elements/tests/fixtures/x-webview/basics.html (1)

1-33: Fixture is correct and properly mocked in test spec.

The x-webview fixture correctly sets up the element with event listeners for bindload and bindmessage. The external URL https://example.com is properly mocked in x-webview.spec.ts with page.route('https://example.com', ...) returning a valid HTML response.

packages/web-platform/web-elements/src/elements/XWebView/index.ts (1)

1-22: LGTM! Well-documented public API.

The module documentation is clear and comprehensive, covering attributes, events, and methods. The re-export follows the established pattern for web-elements.

packages/web-platform/web-elements/package.json (1)

109-113: LGTM! Export configuration is correct.

The XWebView export entry follows the established pattern with proper source, types, and default fields.

packages/web-platform/web-elements/src/elements/XWebView/XWebViewAttribute.ts (1)

1-33: LGTM! Clean attribute handling implementation.

The implementation correctly follows element-reactive patterns with decorators and minimal computation in attribute handlers. The mapping of src to iframe's src and html to iframe's srcdoc is appropriate.

Based on coding guidelines: "Use element-reactive patterns: inherit from Element (via Component decorator) and use reactive utilities when creating new elements" and "Minimize heavy computation in attributeChangedCallback to keep main thread responsive."

packages/web-platform/web-elements/src/elements/XWebView/XWebView.ts (3)

100-110: LGTM! Proper lifecycle management with one minor observation.

The connectedCallback and disconnectedCallback properly register and clean up event listeners. The message listener on window is appropriate since iframe postMessage events bubble to the window, and the source check in #handleMessage (line 76) ensures only messages from the correct iframe are processed.

Note: Multiple x-webview instances will each process all postMessage events on the window, though the source check filters them correctly. This is the standard pattern for iframe communication.


27-46: LGTM! Comprehensive event handling implementation.

The event handlers correctly:

  • Emit both standard events ('load', 'error', 'message') and bind-prefixed events for compatibility
  • Include appropriate detail payloads
  • Set bubbles: true and composed: true for proper event propagation
  • Filter messages by source (line 76) to prevent cross-iframe message leakage

Also applies to: 51-70, 75-98


112-139: LGTM! Property accessors and reload method are correctly implemented.

The src and html getters/setters properly delegate to attributes, and the reload() method correctly triggers a reload by reassigning the iframe's src. The eslint-disable comment is appropriate since self-assignment is intentional here.

Comment thread packages/web-platform/web-elements/src/elements/XWebView/XWebView.ts Outdated
@codecov
Copy link
Copy Markdown

codecov Bot commented Dec 26, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Dec 26, 2025

CodSpeed Performance Report

Merging #2061 will not alter performance

Comparing PupilTong:p/hw/implement-x-webview (5201d87) with main (f0317a3)1

Summary

✅ 63 untouched
⏩ 3 skipped2

Footnotes

  1. No successful run was found on main (ccbf3de) during the generation of this report, so f0317a3 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

  2. 3 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@relativeci
Copy link
Copy Markdown

relativeci Bot commented Dec 26, 2025

Web Explorer

#6875 Bundle Size — 379.1KiB (+0.72%).

5201d87(current) vs f0317a3 main#6867(baseline)

Bundle metrics  Change 5 changes Regression 2 regressions
                 Current
#6875
     Baseline
#6867
Regression  Initial JS 152.52KiB(+1.76%) 149.87KiB
Regression  Initial CSS 32.46KiB(+0.18%) 32.4KiB
Change  Cache Invalidation 48.43% 0%
No change  Chunks 8 8
No change  Assets 8 8
Change  Modules 236(+2.16%) 231
No change  Duplicate Modules 16 16
Change  Duplicate Code 3.03%(-2.88%) 3.12%
No change  Packages 4 4
No change  Duplicate Packages 0 0
Bundle size by type  Change 2 changes Regression 2 regressions
                 Current
#6875
     Baseline
#6867
Regression  JS 249.66KiB (+1.07%) 247.01KiB
No change  Other 96.98KiB 96.98KiB
Regression  CSS 32.46KiB (+0.18%) 32.4KiB

Bundle analysis reportBranch PupilTong:p/hw/implement-x-webvi...Project dashboard


Generated by RelativeCIDocumentationReport issue

@relativeci
Copy link
Copy Markdown

relativeci Bot commented Dec 26, 2025

React Example

#6715 Bundle Size — 237.01KiB (0%).

5201d87(current) vs f0317a3 main#6707(baseline)

Bundle metrics  no changes
                 Current
#6715
     Baseline
#6707
No change  Initial JS 0B 0B
No change  Initial CSS 0B 0B
No change  Cache Invalidation 0% 0%
No change  Chunks 0 0
No change  Assets 4 4
No change  Modules 162 162
No change  Duplicate Modules 65 65
No change  Duplicate Code 46.75% 46.75%
No change  Packages 2 2
No change  Duplicate Packages 0 0
Bundle size by type  no changes
                 Current
#6715
     Baseline
#6707
No change  IMG 145.76KiB 145.76KiB
No change  Other 91.25KiB 91.25KiB

Bundle analysis reportBranch PupilTong:p/hw/implement-x-webvi...Project dashboard


Generated by RelativeCIDocumentationReport issue

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (3)
packages/web-platform/web-elements/src/elements/XWebView/XWebView.ts (3)

25-96: Consider documenting the dual event pattern.

Each handler dispatches two events (e.g., 'load'/'bindload', 'error'/'binderror'). While the inline comment on line 82 hints at compatibility concerns for the message event, documenting why both event types are dispatched would improve maintainability.

💡 Optional: Add JSDoc explaining the dual dispatch pattern
  /**
   * @internal
+  * Dispatches 'load' and 'bindload' events when the iframe loads.
+  * Both events are provided for API compatibility.
   */
  readonly #handleLoad = () => {

134-137: LGTM! Clean reload implementation.

The self-assignment technique is a standard approach to force iframe reload. The eslint-disable comment is appropriate.

💡 Optional: Add JSDoc for public API
+ /**
+  * Reloads the current content in the webview.
+  */
  reload() {
    // eslint-disable-next-line no-self-assign
    this.#getWebView().src = this.#getWebView().src;
  }

98-108: Window-level message listener creates multiple global listeners per instance—consider delegating to a single listener.

The window.addEventListener('message', ...) on line 101 means each x-webview instance registers its own global listener. While the #handleMessage filter (line 74) correctly prevents cross-instance interference by checking e.source !== this.#getWebView().contentWindow, this pattern causes every message event on the page to trigger all registered handlers unnecessarily. For pages with multiple x-webview instances, a single delegated listener with instance routing would be more performant.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cebc859 and 5201d87.

📒 Files selected for processing (1)
  • packages/web-platform/web-elements/src/elements/XWebView/XWebView.ts
🧰 Additional context used
📓 Path-based instructions (5)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Use TypeScript in strict mode with the configuration specified in tsconfig.json

Files:

  • packages/web-platform/web-elements/src/elements/XWebView/XWebView.ts
**/*.{js,ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{js,ts,tsx}: Follow eslint rules as configured in eslint.config.js including React and TypeScript specific rules
Follow code formatting rules specified in .dprint.jsonc and biome.jsonc

Files:

  • packages/web-platform/web-elements/src/elements/XWebView/XWebView.ts
packages/web-platform/web-elements/**/*.ts

📄 CodeRabbit inference engine (packages/web-platform/web-elements/AGENTS.md)

packages/web-platform/web-elements/**/*.ts: Use element-reactive patterns: inherit from Element (via Component decorator) and use reactive utilities when creating new elements
Avoid synchronous layout thrashing by using boostedQueueMicrotask for DOM reads/writes when accurate layout info isn't immediately needed
Use CSS variables extensively (e.g., --lynx-display, --lynx-linear-orientation) to drive layout and style from the Lynx engine

Files:

  • packages/web-platform/web-elements/src/elements/XWebView/XWebView.ts
packages/web-platform/web-elements/src/elements/**/*.ts

📄 CodeRabbit inference engine (packages/web-platform/web-elements/AGENTS.md)

packages/web-platform/web-elements/src/elements/**/*.ts: Define shadow DOM templates in src/elements/htmlTemplates.ts rather than inline within element files
Tag names must use kebab-case; single-word names should be prefixed with x- (e.g., x-view, scroll-view)
Minimize heavy computation in attributeChangedCallback to keep main thread responsive

Files:

  • packages/web-platform/web-elements/src/elements/XWebView/XWebView.ts
packages/web-platform/web-elements/src/elements/**/!(index).ts

📄 CodeRabbit inference engine (packages/web-platform/web-elements/AGENTS.md)

Use PascalCase for class names (e.g., MyElement)

Files:

  • packages/web-platform/web-elements/src/elements/XWebView/XWebView.ts
🧠 Learnings (15)
📓 Common learnings
Learnt from: CR
Repo: lynx-family/lynx-stack PR: 0
File: packages/web-platform/web-elements/AGENTS.md:0-0
Timestamp: 2025-12-26T07:42:21.745Z
Learning: Applies to packages/web-platform/web-elements/**/*.ts : Use CSS variables extensively (e.g., `--lynx-display`, `--lynx-linear-orientation`) to drive layout and style from the Lynx engine
Learnt from: CR
Repo: lynx-family/lynx-stack PR: 0
File: packages/web-platform/web-elements/AGENTS.md:0-0
Timestamp: 2025-12-26T07:42:21.745Z
Learning: Applies to packages/web-platform/web-elements/**/package.json : Add export configuration under `"exports"` field for newly implemented components (types and default)
Learnt from: CR
Repo: lynx-family/lynx-stack PR: 0
File: packages/web-platform/web-elements/AGENTS.md:0-0
Timestamp: 2025-12-26T07:42:21.745Z
Learning: The `web-elements` package provides Native UI implementation using Web Components built on the `element-reactive` lightweight reactive framework for performance
Learnt from: CR
Repo: lynx-family/lynx-stack PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-26T05:10:01.595Z
Learning: Applies to packages/web-platform/web-tests/**/*.{ts,tsx,js} : Use Playwright for E2E tests in packages/web-platform/web-tests/
Learnt from: CR
Repo: lynx-family/lynx-stack PR: 0
File: packages/web-platform/web-core-wasm/AGENTS.md:0-0
Timestamp: 2025-12-26T05:10:16.728Z
Learning: Applies to packages/web-platform/web-core-wasm/**/*.rs : All new features and bug fixes must be accompanied by unit tests.
Learnt from: CR
Repo: lynx-family/lynx-stack PR: 0
File: packages/web-platform/web-elements/AGENTS.md:0-0
Timestamp: 2025-12-26T07:42:21.745Z
Learning: Applies to packages/web-platform/web-elements/tests/**/*.spec.ts : Use Playwright for all E2E and functional tests with standard assertions like `expect(locator).toBeVisible()` and `expect(locator).toHaveCSS()`
Learnt from: CR
Repo: lynx-family/lynx-stack PR: 0
File: packages/web-platform/web-elements/AGENTS.md:0-0
Timestamp: 2025-12-26T07:42:21.745Z
Learning: Applies to packages/web-platform/web-elements/tests/**/*.spec.ts : Ensure test coverage includes attribute changes, style updates, and event handling
Learnt from: CR
Repo: lynx-family/lynx-stack PR: 0
File: packages/web-platform/web-elements/AGENTS.md:0-0
Timestamp: 2025-12-26T07:42:21.745Z
Learning: Applies to packages/web-platform/web-elements/src/elements/all.ts : Export all new components in `src/elements/all.ts` to ensure they are registered
📚 Learning: 2025-12-26T07:42:21.745Z
Learnt from: CR
Repo: lynx-family/lynx-stack PR: 0
File: packages/web-platform/web-elements/AGENTS.md:0-0
Timestamp: 2025-12-26T07:42:21.745Z
Learning: Applies to packages/web-platform/web-elements/**/*.ts : Use `element-reactive` patterns: inherit from `Element` (via `Component` decorator) and use reactive utilities when creating new elements

Applied to files:

  • packages/web-platform/web-elements/src/elements/XWebView/XWebView.ts
📚 Learning: 2025-12-26T07:42:21.745Z
Learnt from: CR
Repo: lynx-family/lynx-stack PR: 0
File: packages/web-platform/web-elements/AGENTS.md:0-0
Timestamp: 2025-12-26T07:42:21.745Z
Learning: Applies to packages/web-platform/web-elements/src/elements/**/*.ts : Define shadow DOM templates in `src/elements/htmlTemplates.ts` rather than inline within element files

Applied to files:

  • packages/web-platform/web-elements/src/elements/XWebView/XWebView.ts
📚 Learning: 2025-12-26T07:42:21.745Z
Learnt from: CR
Repo: lynx-family/lynx-stack PR: 0
File: packages/web-platform/web-elements/AGENTS.md:0-0
Timestamp: 2025-12-26T07:42:21.745Z
Learning: Applies to packages/web-platform/web-elements/src/elements/**/index.ts : Ensure `index.ts` files and complex logic have clear, descriptive comments matching the implementation

Applied to files:

  • packages/web-platform/web-elements/src/elements/XWebView/XWebView.ts
📚 Learning: 2025-12-26T07:42:21.745Z
Learnt from: CR
Repo: lynx-family/lynx-stack PR: 0
File: packages/web-platform/web-elements/AGENTS.md:0-0
Timestamp: 2025-12-26T07:42:21.745Z
Learning: Applies to packages/web-platform/web-elements/src/elements/**/*.ts : Minimize heavy computation in `attributeChangedCallback` to keep main thread responsive

Applied to files:

  • packages/web-platform/web-elements/src/elements/XWebView/XWebView.ts
📚 Learning: 2025-12-26T07:42:21.745Z
Learnt from: CR
Repo: lynx-family/lynx-stack PR: 0
File: packages/web-platform/web-elements/AGENTS.md:0-0
Timestamp: 2025-12-26T07:42:21.745Z
Learning: Applies to packages/web-platform/web-elements/src/elements/**/*.ts : Tag names must use kebab-case; single-word names should be prefixed with `x-` (e.g., `x-view`, `scroll-view`)

Applied to files:

  • packages/web-platform/web-elements/src/elements/XWebView/XWebView.ts
📚 Learning: 2025-12-26T07:42:21.745Z
Learnt from: CR
Repo: lynx-family/lynx-stack PR: 0
File: packages/web-platform/web-elements/AGENTS.md:0-0
Timestamp: 2025-12-26T07:42:21.745Z
Learning: Applies to packages/web-platform/web-elements/**/*.ts : Use CSS variables extensively (e.g., `--lynx-display`, `--lynx-linear-orientation`) to drive layout and style from the Lynx engine

Applied to files:

  • packages/web-platform/web-elements/src/elements/XWebView/XWebView.ts
📚 Learning: 2025-12-26T07:42:21.745Z
Learnt from: CR
Repo: lynx-family/lynx-stack PR: 0
File: packages/web-platform/web-elements/AGENTS.md:0-0
Timestamp: 2025-12-26T07:42:21.745Z
Learning: Applies to packages/web-platform/web-elements/**/*.ts : Avoid synchronous layout thrashing by using `boostedQueueMicrotask` for DOM reads/writes when accurate layout info isn't immediately needed

Applied to files:

  • packages/web-platform/web-elements/src/elements/XWebView/XWebView.ts
📚 Learning: 2025-12-26T07:42:21.745Z
Learnt from: CR
Repo: lynx-family/lynx-stack PR: 0
File: packages/web-platform/web-elements/AGENTS.md:0-0
Timestamp: 2025-12-26T07:42:21.745Z
Learning: Applies to packages/web-platform/web-elements/tests/**/*.spec.ts : Ensure test coverage includes attribute changes, style updates, and event handling

Applied to files:

  • packages/web-platform/web-elements/src/elements/XWebView/XWebView.ts
📚 Learning: 2025-12-26T07:42:21.745Z
Learnt from: CR
Repo: lynx-family/lynx-stack PR: 0
File: packages/web-platform/web-elements/AGENTS.md:0-0
Timestamp: 2025-12-26T07:42:21.745Z
Learning: Applies to packages/web-platform/web-elements/**/package.json : Add export configuration under `"exports"` field for newly implemented components (types and default)

Applied to files:

  • packages/web-platform/web-elements/src/elements/XWebView/XWebView.ts
📚 Learning: 2025-12-26T07:42:21.745Z
Learnt from: CR
Repo: lynx-family/lynx-stack PR: 0
File: packages/web-platform/web-elements/AGENTS.md:0-0
Timestamp: 2025-12-26T07:42:21.745Z
Learning: Applies to packages/web-platform/web-elements/src/elements/all.ts : Export all new components in `src/elements/all.ts` to ensure they are registered

Applied to files:

  • packages/web-platform/web-elements/src/elements/XWebView/XWebView.ts
📚 Learning: 2025-11-03T08:44:10.706Z
Learnt from: Sherry-hue
Repo: lynx-family/lynx-stack PR: 1911
File: packages/web-platform/web-elements/src/XList/ListItemAttributes.ts:24-29
Timestamp: 2025-11-03T08:44:10.706Z
Learning: In packages/web-platform/web-elements/src/XList/ListItemAttributes.ts, the `estimated-main-axis-size-px` attribute handler does not need to validate or guard against invalid/NaN values when parsing - data correctness verification is not required for this attribute.

Applied to files:

  • packages/web-platform/web-elements/src/elements/XWebView/XWebView.ts
📚 Learning: 2025-12-26T05:10:16.728Z
Learnt from: CR
Repo: lynx-family/lynx-stack PR: 0
File: packages/web-platform/web-core-wasm/AGENTS.md:0-0
Timestamp: 2025-12-26T05:10:16.728Z
Learning: Applies to packages/web-platform/web-core-wasm/**/*.rs : Check if the comments in the code need to be updated to reflect your changes.

Applied to files:

  • packages/web-platform/web-elements/src/elements/XWebView/XWebView.ts
📚 Learning: 2025-12-26T05:10:16.728Z
Learnt from: CR
Repo: lynx-family/lynx-stack PR: 0
File: packages/web-platform/web-core-wasm/AGENTS.md:0-0
Timestamp: 2025-12-26T05:10:16.728Z
Learning: Applies to packages/web-platform/web-core-wasm/**/AGENTS.md : Check if `AGENTS.md` needs to be updated to reflect your changes (e.g., new feature flags, structural changes, new dependencies).

Applied to files:

  • packages/web-platform/web-elements/src/elements/XWebView/XWebView.ts
📚 Learning: 2025-09-18T08:12:56.802Z
Learnt from: Sherry-hue
Repo: lynx-family/lynx-stack PR: 1770
File: packages/web-platform/web-mainthread-apis/src/utils/processStyleInfo.ts:316-318
Timestamp: 2025-09-18T08:12:56.802Z
Learning: In packages/web-platform/web-mainthread-apis/src/utils/processStyleInfo.ts, the current implementation uses cardStyleElement.textContent += for lazy component styles. While this could theoretically invalidate rule indices by reparsing the stylesheet, Sherry-hue indicated that UIDs don't repeat for the same element, making this approach acceptable for now. A future optimization to use separate style elements per entry was discussed but deferred to a separate PR to keep the current lazy bundle PR focused.

Applied to files:

  • packages/web-platform/web-elements/src/elements/XWebView/XWebView.ts
🔇 Additional comments (3)
packages/web-platform/web-elements/src/elements/XWebView/XWebView.ts (3)

1-15: LGTM! Clean component setup.

The component follows element-reactive patterns correctly, uses proper tag naming (x-webview), and composes the necessary mixins. Import paths and decorator usage are correct.


17-20: LGTM! Proper DOM getter pattern.

The use of genDomGetter with proper typing follows the element-reactive pattern for accessing shadow DOM elements.


110-132: LGTM! Standard attribute reflection pattern.

The src and html properties correctly reflect their attributes with proper null handling. Note that these properties accept arbitrary URLs and HTML without validation, which places security responsibility on the component user—this is typical for webview/iframe wrappers.

@PupilTong PupilTong requested a review from Sherry-hue December 26, 2025 10:03
@PupilTong PupilTong merged commit 1bb269b into lynx-family:main Dec 29, 2025
47 checks passed
colinaaa pushed a commit that referenced this pull request Jan 4, 2026
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## @lynx-js/gesture-runtime@2.1.1

### Patch Changes

- Add `NativeGesture`
([#2076](#2076))

## @lynx-js/react@0.115.3

### Patch Changes

- Add dual-thread commutation logs for troubleshooting when
`REACT_ALOG=true` or global define `__ALOG__` is set.
([#2081](#2081))

- Use error cause to simplify the error msg of lazy bundle loading. User
can catch the error cause to get the original result:
([#2056](#2056))

    ```ts
    const LazyComponent = lazy(async () => {
      try {
        const mod = await import("./lazy-bundle");
        return mod.default;
      } catch (error) {
console.error(`Lazy Bundle load failed message: ${error.message}`);
        // User can catch the error cause to get the original result
        console.error(`Lazy Bundle load failed result: ${error.cause}`);
        throw error;
      }
    });
    ```

## @lynx-js/rspeedy@0.12.5

### Patch Changes

-   Updated dependencies \[]:
    -   @lynx-js/web-rsbuild-server-middleware@0.19.4

## @lynx-js/react-rsbuild-plugin@0.12.4

### Patch Changes

-   ([#2051](#2051))

-   Updated dependencies \[]:
    -   @lynx-js/react-alias-rsbuild-plugin@0.12.4
    -   @lynx-js/use-sync-external-store@1.5.0
    -   @lynx-js/react-refresh-webpack-plugin@0.3.4
    -   @lynx-js/react-webpack-plugin@0.7.3

## @lynx-js/testing-environment@0.1.9

### Patch Changes

- Fix duplicated `<page />` elements on body when multiple
`__CreatePage` called.
([#2065](#2065))

## @lynx-js/web-constants@0.19.4

### Patch Changes

- Updated dependencies
\[[`bba05e2`](bba05e2)]:
    -   @lynx-js/web-worker-rpc@0.19.4

## @lynx-js/web-core@0.19.4

### Patch Changes

- Updated dependencies
\[[`bba05e2`](bba05e2)]:
    -   @lynx-js/web-worker-rpc@0.19.4
    -   @lynx-js/web-constants@0.19.4
    -   @lynx-js/web-worker-runtime@0.19.4
    -   @lynx-js/web-mainthread-apis@0.19.4

## @lynx-js/web-elements@0.10.1

### Patch Changes

- feat: implement x-webview component
([#2061](#2061))

- feat: support `recyclable="false"` on `list-item` and enable overflow
visibility
([#2069](#2069))

## @lynx-js/web-mainthread-apis@0.19.4

### Patch Changes

-   Updated dependencies \[]:
    -   @lynx-js/web-constants@0.19.4

## @lynx-js/web-worker-rpc@0.19.4

### Patch Changes

- Ensure the `default` export entry is last in the package exports map.
([#2075](#2075))

## @lynx-js/web-worker-runtime@0.19.4

### Patch Changes

- Updated dependencies
\[[`bba05e2`](bba05e2)]:
    -   @lynx-js/web-worker-rpc@0.19.4
    -   @lynx-js/web-constants@0.19.4
    -   @lynx-js/web-mainthread-apis@0.19.4

## create-rspeedy@0.12.5



## @lynx-js/react-alias-rsbuild-plugin@0.12.4



## upgrade-rspeedy@0.12.5



## @lynx-js/web-core-server@0.19.4



## @lynx-js/web-rsbuild-server-middleware@0.19.4

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants