Skip to content

refactor: move rust source files into web-mainthread-apis dir#1946

Merged
PupilTong merged 6 commits intolynx-family:mainfrom
PupilTong:p/hw/rust-refactor-1
Nov 21, 2025
Merged

refactor: move rust source files into web-mainthread-apis dir#1946
PupilTong merged 6 commits intolynx-family:mainfrom
PupilTong:p/hw/rust-refactor-1

Conversation

@PupilTong
Copy link
Copy Markdown
Collaborator

@PupilTong PupilTong commented Nov 20, 2025

refactor: move rust source files into web-mainthread-apis dir

This is a part of #1937

  • also updated the timing for loading the wasm chunk

Summary by CodeRabbit

  • Chores

    • Reorganized workspace packages and updated membership; removed an obsolete style-transformer package and related manifests.
    • Updated wasm-bindgen to 0.2.105 and added binary build outputs; removed a dependency entry from changeset config.
  • New Features

    • Added a dedicated WebAssembly build workflow and automatic WASM initialization for the new mainthread APIs package.
  • Documentation

    • Removed legacy package docs and changelog entries.

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

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Nov 20, 2025

🦋 Changeset detected

Latest commit: b83c8cd

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

This PR includes changesets to release 10 packages
Name Type
@lynx-js/web-core-server Patch
@lynx-js/web-core Patch
@lynx-js/web-constants Patch
@lynx-js/web-mainthread-apis Patch
@lynx-js/web-worker-rpc Patch
@lynx-js/web-worker-runtime Patch
@lynx-js/web-rsbuild-server-middleware Patch
upgrade-rspeedy Patch
@lynx-js/rspeedy Patch
create-rspeedy 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 Nov 20, 2025

📝 Walkthrough

Walkthrough

Consolidates and removes the standalone web-style-transformer package, migrates its inline-style parsing and wasm build into web-mainthread-apis, updates workspace/Cargo/package manifests, refactors Rust module paths/visibility, and changes WASM initialization/import timing (dynamic import and top-level await).

Changes

Cohort / File(s) Summary
Removed package: web-style-transformer
packages/web-platform/web-style-transformer/*
Deleted package metadata and docs (package.json, CHANGELOG.md, LICENSE.txt, Notice.txt, README.md, turbo.json) and removed build script and JS re-exports (scripts/build.js, legacy.js, standard.js).
Workspace & changeset
.changeset/config.json, .changeset/long-baths-prove.md, Cargo.toml
Removed @lynx-js/web-style-transformer from changeset; added a changeset for web-core-server; updated Cargo workspace members (removed inline-style-parser & web-style-transformer, added web-mainthread-apis).
New package: web-mainthread-apis (JS layer)
packages/web-platform/web-mainthread-apis/package.json, packages/.../turbo.json, packages/.../wasm/*
Added/updated package.json (files, scripts, deps/devDeps), added wasm/index.js (top-level await), wasm/standard.js, wasm/legacy.js re-exports, and added binary/** to turbo outputs.
WASM build tooling & manifests
packages/web-platform/web-mainthread-apis/scripts/build.js, packages/.../scripts/wasm-bindgen
Added build orchestration script producing release/legacy/debug wasm artifacts; bumped wasm-bindgen manifest entries to 0.2.105.
Rust crate / manifest changes
packages/web-platform/inline-style-parser/Cargo.toml, packages/web-platform/web-mainthread-apis/Cargo.toml, packages/web-platform/web-mainthread-apis/src/lib.rs
Removed package metadata from inline-style-parser crate, renamed/created web-mainthread-apis crate, removed inline-style-parser dependency, and registered new style module in lib.rs.
Rust module refactors
packages/.../web-mainthread-apis/src/style/*
Added mod inline_style_parser, changed many crate:: imports to super::, made transformer non-public (mod transformer), adjusted tests and derives, and changed transform.rs to always append trailing source.
TypeScript WASM/init/import changes
packages/web-platform/web-mainthread-apis/ts/prepareMainThreadAPIs.ts, packages/.../ts/utils/tokenizer.ts, packages/web-platform/web-core-server/src/createLynxView.ts, packages/web-platform/web-tests/shell-project/mainthread-test.ts
Removed initWasm import/await from prepareMainThreadAPIs and tests, switched tokenizer wasm import to local ../../wasm/index.js, and moved prepareMainThreadAPIs import to a dynamic awaited import in createLynxView.
Tests & dev deps updates
packages/web-platform/web-tests/package.json
Removed devDependency on @lynx-js/web-style-transformer.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

  • Pay special attention to WASM initialization timing (top-level await in wasm/index.js vs removed explicit init elsewhere).
  • Verify no residual references to the removed web-style-transformer package (workspace, imports, tests).
  • Review the new build.js for platform/env assumptions and reproducibility.
  • Check Rust module visibility changes (transformer made internal) for downstream API/test impacts.

Possibly related PRs

Suggested reviewers

  • Sherry-hue
  • colinaaa
  • deanjingshui

Poem

🐇 I nibbled through crates and hopped a new lane,
Moved parsers home and let the wasm wake again.
Builds hum in scripts, imports now await,
Crates renamed, tails appended—hop, compile, elate.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately describes the main refactoring work: moving Rust source files (inline-style-parser) into web-mainthread-apis, which is reflected across the changeset.
✨ 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)
.changeset/long-baths-prove.md (1)

1-7: Consider clarifying the changeset description.

While the changeset correctly documents this as a patch-level change, the description "minor bundle output change" is vague. Consider being more specific about the impact, such as:

  • "WASM initialization now happens automatically at module load time"
  • "Changed WASM chunk loading from manual to automatic initialization"

This helps users understand if the change might affect their bundle size, load performance, or initialization behavior.

packages/web-platform/web-mainthread-apis/src/style/transformer/transform.rs (1)

1-2: Consider using explicit imports for better clarity.

The wildcard imports (::*) make it less clear where imported items originate. While acceptable for internal reorganization, explicit imports improve code maintainability.

Example refactor for line 1:

-use super::super::inline_style_parser::{char_code_definitions::*, parse_inline_style::*};
+use super::super::inline_style_parser::char_code_definitions::{is_white_space};
+use super::super::inline_style_parser::parse_inline_style::{parse_inline_style, Transformer};

(Adjust the explicit imports based on actual usage in the file)

📜 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 12f6fb3 and 3cba385.

⛔ Files ignored due to path filters (2)
  • Cargo.lock is excluded by !**/*.lock
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (35)
  • .changeset/config.json (0 hunks)
  • .changeset/long-baths-prove.md (1 hunks)
  • Cargo.toml (2 hunks)
  • packages/web-platform/inline-style-parser/Cargo.toml (0 hunks)
  • packages/web-platform/web-core-server/rslib.config.ts (1 hunks)
  • packages/web-platform/web-core-server/src/createLynxView.ts (1 hunks)
  • packages/web-platform/web-mainthread-apis/Cargo.toml (1 hunks)
  • packages/web-platform/web-mainthread-apis/package.json (1 hunks)
  • packages/web-platform/web-mainthread-apis/scripts/build.js (1 hunks)
  • packages/web-platform/web-mainthread-apis/scripts/wasm-bindgen (1 hunks)
  • packages/web-platform/web-mainthread-apis/src/lib.rs (1 hunks)
  • packages/web-platform/web-mainthread-apis/src/style/inline_style_parser/mod.rs (11 hunks)
  • packages/web-platform/web-mainthread-apis/src/style/inline_style_parser/parse_inline_style.rs (1 hunks)
  • packages/web-platform/web-mainthread-apis/src/style/inline_style_parser/tokenize.rs (2 hunks)
  • packages/web-platform/web-mainthread-apis/src/style/inline_style_parser/utils.rs (1 hunks)
  • packages/web-platform/web-mainthread-apis/src/style/mod.rs (1 hunks)
  • packages/web-platform/web-mainthread-apis/src/style/transformer/rules.rs (1 hunks)
  • packages/web-platform/web-mainthread-apis/src/style/transformer/transform.rs (3 hunks)
  • packages/web-platform/web-mainthread-apis/ts/prepareMainThreadAPIs.ts (0 hunks)
  • packages/web-platform/web-mainthread-apis/ts/utils/tokenizer.ts (1 hunks)
  • packages/web-platform/web-mainthread-apis/turbo.json (1 hunks)
  • packages/web-platform/web-mainthread-apis/wasm/index.js (1 hunks)
  • packages/web-platform/web-mainthread-apis/wasm/legacy.js (1 hunks)
  • packages/web-platform/web-mainthread-apis/wasm/standard.js (1 hunks)
  • packages/web-platform/web-style-transformer/CHANGELOG.md (0 hunks)
  • packages/web-platform/web-style-transformer/LICENSE.txt (0 hunks)
  • packages/web-platform/web-style-transformer/Notice.txt (0 hunks)
  • packages/web-platform/web-style-transformer/README.md (0 hunks)
  • packages/web-platform/web-style-transformer/legacy.js (0 hunks)
  • packages/web-platform/web-style-transformer/package.json (0 hunks)
  • packages/web-platform/web-style-transformer/scripts/build.js (0 hunks)
  • packages/web-platform/web-style-transformer/standard.js (0 hunks)
  • packages/web-platform/web-style-transformer/turbo.json (0 hunks)
  • packages/web-platform/web-tests/package.json (0 hunks)
  • packages/web-platform/web-tests/shell-project/mainthread-test.ts (0 hunks)
💤 Files with no reviewable changes (14)
  • packages/web-platform/web-tests/shell-project/mainthread-test.ts
  • packages/web-platform/web-style-transformer/Notice.txt
  • packages/web-platform/web-tests/package.json
  • packages/web-platform/web-style-transformer/standard.js
  • .changeset/config.json
  • packages/web-platform/web-style-transformer/README.md
  • packages/web-platform/web-style-transformer/CHANGELOG.md
  • packages/web-platform/web-mainthread-apis/ts/prepareMainThreadAPIs.ts
  • packages/web-platform/web-style-transformer/legacy.js
  • packages/web-platform/web-style-transformer/scripts/build.js
  • packages/web-platform/web-style-transformer/LICENSE.txt
  • packages/web-platform/web-style-transformer/package.json
  • packages/web-platform/inline-style-parser/Cargo.toml
  • packages/web-platform/web-style-transformer/turbo.json
🧰 Additional context used
📓 Path-based instructions (1)
.changeset/*.md

📄 CodeRabbit inference engine (AGENTS.md)

For contributions, generate and commit a Changeset describing your changes

Files:

  • .changeset/long-baths-prove.md
🧠 Learnings (31)
📓 Common learnings
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.
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.
📚 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-mainthread-apis/src/style/mod.rs
  • packages/web-platform/web-mainthread-apis/ts/utils/tokenizer.ts
  • packages/web-platform/web-mainthread-apis/src/style/inline_style_parser/mod.rs
  • packages/web-platform/web-mainthread-apis/src/style/inline_style_parser/utils.rs
  • packages/web-platform/web-mainthread-apis/src/style/transformer/transform.rs
  • packages/web-platform/web-mainthread-apis/src/lib.rs
  • packages/web-platform/web-mainthread-apis/Cargo.toml
📚 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-mainthread-apis/scripts/build.js
  • packages/web-platform/web-mainthread-apis/wasm/legacy.js
  • packages/web-platform/web-mainthread-apis/wasm/index.js
  • packages/web-platform/web-mainthread-apis/package.json
  • packages/web-platform/web-mainthread-apis/wasm/standard.js
  • packages/web-platform/web-core-server/src/createLynxView.ts
  • packages/web-platform/web-mainthread-apis/Cargo.toml
📚 Learning: 2025-09-28T08:46:43.177Z
Learnt from: f0rdream
Repo: lynx-family/lynx-stack PR: 1835
File: packages/react/worklet-runtime/src/workletRuntime.ts:52-55
Timestamp: 2025-09-28T08:46:43.177Z
Learning: The legacy worklet path with `_lepusWorkletHash` in `packages/react/worklet-runtime/src/workletRuntime.ts` is preserved for compatibility with MTS (Mini-app Threading Service) that doesn't support Initial Frame Rendering. This path will not be touched in current implementations.

Applied to files:

  • packages/web-platform/web-mainthread-apis/wasm/legacy.js
📚 Learning: 2025-07-16T06:25:41.055Z
Learnt from: PupilTong
Repo: lynx-family/lynx-stack PR: 1029
File: packages/web-platform/web-mainthread-apis/src/createMainThreadGlobalThis.ts:214-217
Timestamp: 2025-07-16T06:25:41.055Z
Learning: In the lynx-stack codebase, CSS strings produced by `genCssContent` are considered trusted developer input, so additional sanitization/escaping is not required.

Applied to files:

  • packages/web-platform/web-mainthread-apis/ts/utils/tokenizer.ts
📚 Learning: 2025-09-29T06:43:40.182Z
Learnt from: CR
Repo: lynx-family/lynx-stack PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-09-29T06:43:40.182Z
Learning: Applies to packages/**/etc/*.api.md : Always commit API extractor output after running `pnpm turbo api-extractor -- --local` (commit updated API report files)

Applied to files:

  • packages/web-platform/web-mainthread-apis/turbo.json
📚 Learning: 2025-09-10T11:42:36.855Z
Learnt from: gaoachao
Repo: lynx-family/lynx-stack PR: 1714
File: packages/react/transform/Cargo.toml:19-19
Timestamp: 2025-09-10T11:42:36.855Z
Learning: In packages/react/transform/Cargo.toml, the crate uses serde derive macros (#[derive(Serialize, Deserialize)]) in multiple files including src/esbuild.rs and src/swc_plugin_extract_str/mod.rs, so the "derive" feature is required when migrating to workspace dependencies.

Applied to files:

  • Cargo.toml
  • packages/web-platform/web-mainthread-apis/src/style/inline_style_parser/tokenize.rs
  • packages/web-platform/web-mainthread-apis/Cargo.toml
📚 Learning: 2025-08-11T05:59:28.530Z
Learnt from: upupming
Repo: lynx-family/lynx-stack PR: 1305
File: packages/react/testing-library/src/plugins/vitest.ts:4-6
Timestamp: 2025-08-11T05:59:28.530Z
Learning: In the lynx-family/lynx-stack repository, the `packages/react/testing-library` package does not have `vite` as a direct dependency. It relies on `vitest` being available from the monorepo root and accesses Vite types through re-exports from `vitest/node`. Direct imports from `vite` should not be suggested for this package.

Applied to files:

  • Cargo.toml
  • packages/web-platform/web-mainthread-apis/package.json
📚 Learning: 2025-10-29T10:28:27.519Z
Learnt from: upupming
Repo: lynx-family/lynx-stack PR: 1899
File: packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_static_extract_dynamic_inline_style.js:20-24
Timestamp: 2025-10-29T10:28:27.519Z
Learning: Files inside packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/ are auto-generated test snapshot files and should not be manually updated. Any issues with the generated code should be addressed in the code generator/transform logic, not in the snapshots themselves.

Applied to files:

  • Cargo.toml
📚 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:

  • Cargo.toml
  • .changeset/long-baths-prove.md
  • packages/web-platform/web-mainthread-apis/package.json
  • packages/web-platform/web-core-server/src/createLynxView.ts
📚 Learning: 2025-08-06T08:25:15.392Z
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1447
File: pnpm-workspace.yaml:20-22
Timestamp: 2025-08-06T08:25:15.392Z
Learning: In pnpm, configDependencies in pnpm-workspace.yaml (used for plugins like pnpm/plugin-better-defaults and pnpm/plugin-trusted-deps) do not appear in or modify pnpm-lock.yaml. These plugins are managed separately by pnpm itself, not as part of the workspace's dependency tree. This is different from the internal configDependencies field that can appear within pnpm-lock.yaml for tracking configuration file dependencies.

Applied to files:

  • Cargo.toml
📚 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/long-baths-prove.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/long-baths-prove.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/long-baths-prove.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/long-baths-prove.md
📚 Learning: 2025-11-06T01:19:23.670Z
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1917
File: packages/mcp-servers/devtool-mcp-server/tsconfig.json:8-8
Timestamp: 2025-11-06T01:19:23.670Z
Learning: The lynx-js/devtool-mcp-server package in lynx-family/lynx-stack targets Node.js >=18.19 (specified in its package.json engines), which is different from the root project's requirement of Node.js ^22 || ^24. The package uses "lib": ["ES2024.Promise"] in its tsconfig.json because it manually includes polyfills for Promise.withResolvers while maintaining compatibility with Node.js v18.

Applied to files:

  • .changeset/long-baths-prove.md
  • packages/web-platform/web-mainthread-apis/package.json
📚 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:

  • .changeset/long-baths-prove.md
  • packages/web-platform/web-mainthread-apis/package.json
  • packages/web-platform/web-core-server/src/createLynxView.ts
📚 Learning: 2025-11-05T03:26:52.546Z
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1916
File: packages/react/transform/crates/swc_plugin_snapshot/lib.rs:9-9
Timestamp: 2025-11-05T03:26:52.546Z
Learning: In the lynx-stack repository's swc_core v47 upgrade (PR #1916), the import `use swc_core::atoms as swc_atoms;` is required in files that use the `quote!` macro (e.g., packages/react/transform/crates/swc_plugin_snapshot/lib.rs, swc_plugin_list/lib.rs, swc_plugin_worklet/gen_stmt.rs) even though swc_atoms may not appear explicitly in the source code. This is because the quote! macro generates code that internally references swc_atoms. Removing this import causes compiler error: "failed to resolve: use of unresolved module or unlinked crate `swc_atoms`".

Applied to files:

  • packages/web-platform/web-mainthread-apis/src/style/inline_style_parser/parse_inline_style.rs
  • packages/web-platform/web-mainthread-apis/src/style/inline_style_parser/tokenize.rs
📚 Learning: 2025-08-27T11:36:36.415Z
Learnt from: PupilTong
Repo: lynx-family/lynx-stack PR: 1589
File: packages/web-platform/web-tests/resources/web-core.main-thread.json:4-4
Timestamp: 2025-08-27T11:36:36.415Z
Learning: User PupilTong indicated that packages/web-platform/web-tests/resources/web-core.main-thread.json is considered a binary file, despite it appearing as a JSON text file with readable JavaScript code strings in the content.

Applied to files:

  • packages/web-platform/web-mainthread-apis/package.json
📚 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-mainthread-apis/package.json
📚 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/rspeedy/create-rspeedy/template-react-vitest-rltl-js/vitest.config.js` is a template file for scaffolding new Rspeedy projects, not a test configuration that should be included in the main vitest projects array.

Applied to files:

  • packages/web-platform/web-mainthread-apis/package.json
📚 Learning: 2025-08-27T08:10:09.932Z
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1612
File: packages/rspeedy/create-rspeedy/template-react-vitest-rltl-ts/src/tsconfig.json:3-13
Timestamp: 2025-08-27T08:10:09.932Z
Learning: In the lynx-family/lynx-stack repository, Rspeedy templates use `lynx-js/rspeedy/client` types via `rspeedy-env.d.ts` instead of `vite/client` types. Rspeedy provides its own client-side environment type definitions and doesn't require direct Vite type references.

Applied to files:

  • packages/web-platform/web-mainthread-apis/package.json
📚 Learning: 2025-08-13T11:36:12.075Z
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1523
File: vitest.config.ts:52-72
Timestamp: 2025-08-13T11:36:12.075Z
Learning: The lynx-stack project requires Node.js >=22 as specified in package.json engines, so Node.js compatibility fallbacks for features introduced before v22 are unnecessary.

Applied to files:

  • packages/web-platform/web-mainthread-apis/package.json
📚 Learning: 2025-08-20T04:56:36.011Z
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1566
File: package.json:53-53
Timestamp: 2025-08-20T04:56:36.011Z
Learning: In lynx-stack, Node.js v24 is the preferred/default version for development (established in PR #1557), but Node.js v22 compatibility is maintained specifically for external CI systems like rspack-ecosystem-ci. The engines.node specification uses "^22 || ^24" to support both versions while keeping v24 as the primary target.

Applied to files:

  • packages/web-platform/web-mainthread-apis/package.json
📚 Learning: 2025-08-19T11:25:36.127Z
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1558
File: .changeset/solid-squids-fall.md:2-2
Timestamp: 2025-08-19T11:25:36.127Z
Learning: In the lynx-family/lynx-stack repository, changesets should use the exact package name from package.json#name, not generic or unscoped names. Each package has its own specific scoped name (e.g., "lynx-js/react-transform" for packages/react/transform).

Applied to files:

  • packages/web-platform/web-mainthread-apis/package.json
📚 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-mainthread-apis/wasm/standard.js
  • packages/web-platform/web-core-server/src/createLynxView.ts
📚 Learning: 2025-08-12T16:09:32.413Z
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1497
File: packages/react/transform/tests/__swc_snapshots__/src/swc_plugin_snapshot/mod.rs/basic_full_static.js:9-10
Timestamp: 2025-08-12T16:09:32.413Z
Learning: In the Lynx stack, functions prefixed with `__` that are called in transformed code may be injected globally by the Lynx Engine at runtime rather than exported from the React runtime package. For example, `__CreateFrame` is injected globally by the Lynx Engine, not exported from lynx-js/react.

Applied to files:

  • packages/web-platform/web-core-server/src/createLynxView.ts
📚 Learning: 2025-08-21T08:46:54.494Z
Learnt from: upupming
Repo: lynx-family/lynx-stack PR: 1370
File: packages/webpack/cache-events-webpack-plugin/src/LynxCacheEventsRuntimeModule.ts:23-27
Timestamp: 2025-08-21T08:46:54.494Z
Learning: In Lynx webpack runtime modules, the team prioritizes performance and simplicity over defensive runtime error handling. They prefer relying on compile-time type safety (TypeScript) rather than adding runtime checks like try-catch blocks or type validation, especially for performance-critical code like cache event setup/cleanup functions.

Applied to files:

  • packages/web-platform/web-core-server/src/createLynxView.ts
📚 Learning: 2025-09-25T14:03:25.576Z
Learnt from: PupilTong
Repo: lynx-family/lynx-stack PR: 1834
File: packages/web-platform/web-worker-runtime/src/backgroundThread/background-apis/createChunkLoading.ts:162-171
Timestamp: 2025-09-25T14:03:25.576Z
Learning: In the lynx-stack codebase, for loadScriptAsync implementations in createChunkLoading.ts, unhandled promise rejections from readScriptAsync are intentionally not caught - the caller is expected to handle errors rather than the loadScriptAsync method itself invoking the callback with error messages.

Applied to files:

  • packages/web-platform/web-core-server/src/createLynxView.ts
📚 Learning: 2025-09-28T07:52:03.601Z
Learnt from: Sherry-hue
Repo: lynx-family/lynx-stack PR: 1837
File: packages/web-platform/web-worker-runtime/src/backgroundThread/background-apis/createNativeApp.ts:151-154
Timestamp: 2025-09-28T07:52:03.601Z
Learning: There are two different registerUpdateDataHandler functions in the lynx-stack codebase:
1. Main thread version in packages/web-platform/web-worker-runtime/src/mainThread/crossThreadHandlers/registerUpdateDataHandler.ts takes (mainThreadRpc: Rpc, backgroundThreadRpc: Rpc, runtime: MainThreadGlobalThis)
2. Background thread version in packages/web-platform/web-worker-runtime/src/backgroundThread/background-apis/crossThreadHandlers/registerUpdateDataHandler.ts takes only (rpc: Rpc, tt: NativeTTObject)

Applied to files:

  • packages/web-platform/web-core-server/src/createLynxView.ts
📚 Learning: 2025-09-28T07:52:03.601Z
Learnt from: Sherry-hue
Repo: lynx-family/lynx-stack PR: 1837
File: packages/web-platform/web-worker-runtime/src/backgroundThread/background-apis/createNativeApp.ts:151-154
Timestamp: 2025-09-28T07:52:03.601Z
Learning: There are two different registerUpdateDataHandler functions in the lynx-stack codebase:
1. Main thread version in packages/web-platform/web-worker-runtime/src/mainThread/crossThreadHandlers/registerUpdateDataHandler.ts takes (mainThreadRpc: Rpc, backgroundThreadRpc: Rpc, runtime: MainThreadGlobalThis)
2. Background thread version in packages/web-platform/web-worker-runtime/src/backgroundThread/background-apis/crossThreadHandlers/registerUpdateDataHandler.ts takes only (rpc: Rpc, tt: any)

Applied to files:

  • packages/web-platform/web-core-server/src/createLynxView.ts
🧬 Code graph analysis (2)
packages/web-platform/web-mainthread-apis/src/style/inline_style_parser/mod.rs (1)
packages/web-platform/web-mainthread-apis/src/style/inline_style_parser/tokenize.rs (1)
  • tokenize (253-538)
packages/web-platform/web-mainthread-apis/src/style/transformer/transform.rs (2)
packages/web-platform/web-mainthread-apis/src/style/inline_style_parser/parse_inline_style.rs (1)
  • parse_inline_style (140-156)
packages/web-platform/web-mainthread-apis/src/style/transformer/rules.rs (4)
  • get_rename_rule_value (221-223)
  • get_replace_rule_value (226-235)
  • get_replace_rule_value (261-265)
  • get_replace_rule_value (278-282)
🪛 GitHub Check: test-typos
packages/web-platform/web-mainthread-apis/scripts/build.js

[warning] 65-65:
"typs" should be "typos".

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: build / Build (Windows)
  • GitHub Check: build / Build (Ubuntu)
  • GitHub Check: test-rust / Test (Ubuntu)
🔇 Additional comments (25)
packages/web-platform/web-core-server/rslib.config.ts (1)

33-35: Confirm impact of enabling Rspack futureDefaults

Turning on experiments.futureDefaults can change a set of Rspack defaults at once (tree‑shaking, resolution, output semantics, etc.). For this shared server bundle config, please double‑check that:

  • the current @rslib/core / Rspack versions fully support this flag,
  • it doesn’t affect wasm/chunk loading in unintended ways when combined with output.wasmLoading = 'async-node', and
  • other packages don’t rely on the previous defaults (or that you’ve aligned configs where needed).

If you’ve already compared bundle output and run the relevant tests, just note that in the PR description for future readers.

packages/web-platform/web-core-server/src/createLynxView.ts (1)

166-168: Dynamic import correctly ensures WASM initialization before use.

The change is correct and properly handles WASM initialization timing. The module @lynx-js/web-mainthread-apis has a top-level await initWasm() (wasm/index.js line 23), which means the dynamic import will not resolve until WASM initialization completes. When prepareMainThreadAPIs becomes available on line 169, WASM is guaranteed to be initialized and ready for use by startMainThread and functions like appendStyleElement.

This aligns with the PR objective to update WASM loading timing. The trade-off is that the first SSR render incurs the cost of module loading + WASM initialization, but Node.js caches the imported module, so subsequent calls reuse the cached version.

packages/web-platform/web-mainthread-apis/src/style/inline_style_parser/utils.rs (1)

1-1: LGTM! Import path correctly updated for new module structure.

The change from crate:: to super:: aligns with the module restructuring where inline_style_parser is now nested under the style module.

packages/web-platform/web-mainthread-apis/turbo.json (1)

16-17: LGTM! Build output configuration updated for WASM binaries.

Adding binary/** to outputs correctly tracks the new WASM binary artifacts produced by the build workflow.

packages/web-platform/web-mainthread-apis/wasm/standard.js (1)

1-1: LGTM! Clean proxy pattern for WASM binary exports.

The re-export provides a stable public interface separated from the binary artifact location.

packages/web-platform/web-mainthread-apis/wasm/legacy.js (1)

1-1: LGTM! Consistent pattern for legacy WASM variant.

Mirrors the standard.js proxy pattern for browsers without reference types support.

packages/web-platform/web-mainthread-apis/ts/utils/tokenizer.ts (1)

1-1: Import consolidation aligns with package restructuring.

The change from @lynx-js/web-style-transformer to the local ../../wasm/index.js correctly reflects the consolidation of functionality into web-mainthread-apis. Note that this module now indirectly depends on the automatic WASM initialization from wasm/index.js (see review comment on that file regarding top-level await implications).

packages/web-platform/web-mainthread-apis/scripts/wasm-bindgen (1)

6-6: wasm-bindgen version bumped to 0.2.105—minimal patch release, safe to merge.

The 0.2.105 release (published 2025-10-27) contains a single noted change: "Fix release workflow dependents", which addresses release infrastructure rather than core functionality. This patch presents no compatibility risks with the existing Rust code.

packages/web-platform/web-mainthread-apis/wasm/index.js (1)

23-23: Add error handling around top-level WASM initialization and consider making it conditional for server environments.

The top-level await initWasm() at line 23 unconditionally initializes WASM for all consumers, which has several implications:

  1. Initialization failures are unrecoverable: If initWasm() throws, the entire module import fails with no fallback. While web-core-server wraps the import in try-catch, the source has no error handling.

  2. Unnecessary initialization in SSR: Server-side contexts like web-core-server/src/createLynxView.ts import this module but don't use WASM functionality (tokenizer/wasm utilities are client-only). The auto-initialization wastes resources on the server.

  3. Blocking import for all consumers: Every module that imports from wasm/index.js (e.g., tokenizer.ts) now blocks on async WASM initialization, changing the module loading strategy globally.

Recommendations:

  • Wrap the top-level await in try-catch to prevent silent failures.
  • Consider using dynamic lazy initialization or environment detection to skip WASM setup in SSR/Node.js contexts, or export a separate server-safe entry point.
⛔ Skipped due to learnings
Learnt from: upupming
Repo: lynx-family/lynx-stack PR: 1370
File: packages/webpack/cache-events-webpack-plugin/src/LynxCacheEventsRuntimeModule.ts:23-27
Timestamp: 2025-08-21T08:46:54.494Z
Learning: In Lynx webpack runtime modules, the team prioritizes performance and simplicity over defensive runtime error handling. They prefer relying on compile-time type safety (TypeScript) rather than adding runtime checks like try-catch blocks or type validation, especially for performance-critical code like cache event setup/cleanup functions.
Learnt from: PupilTong
Repo: lynx-family/lynx-stack PR: 1834
File: packages/web-platform/web-worker-runtime/src/backgroundThread/background-apis/createChunkLoading.ts:162-171
Timestamp: 2025-09-25T14:03:25.576Z
Learning: In the lynx-stack codebase, for loadScriptAsync implementations in createChunkLoading.ts, unhandled promise rejections from readScriptAsync are intentionally not caught - the caller is expected to handle errors rather than the loadScriptAsync method itself invoking the callback with error messages.
packages/web-platform/web-mainthread-apis/src/style/inline_style_parser/tokenize.rs (1)

1-5: LGTM! Import path adjustments are correct.

The changes from crate:: to super:: imports correctly reflect the new module hierarchy where inline_style_parser is now a submodule under style.

Also applies to: 542-542

Cargo.toml (2)

9-9: Workspace consolidation looks good.

The addition of web-mainthread-apis to workspace members aligns with the PR's objective of consolidating the Rust source files.


32-32: No compatibility concerns identified.

Wasm-bindgen 0.2.105 does not introduce any breaking changes, containing only a fix to the release workflow. The version bump from 0.2.104 to 0.2.105 is safe and compatible.

packages/web-platform/web-mainthread-apis/scripts/build.js (1)

28-56: Well-structured WASM build function.

The build configuration with conditional release/debug modes and feature flags is well-organized and maintainable.

packages/web-platform/web-mainthread-apis/package.json (3)

19-19: WASM artifact packaging is correctly configured.

Adding "wasm" to files and excluding source maps ensures the WASM bindings are distributed correctly.

Also applies to: 21-21


28-30: Build script integration looks good.

The build script reference aligns with the new build infrastructure added in scripts/build.js.


33-35: Dependency consolidation is consistent with PR objectives.

Removing the @lynx-js/web-style-transformer dependency and adding wasm-feature-detect aligns with the package consolidation and WASM functionality.

packages/web-platform/web-mainthread-apis/src/style/inline_style_parser/mod.rs (2)

13-13: Verify the removal of Debug trait is intentional.

The Debug derive was removed from the Declaration struct. This may impact debugging and logging. Confirm this change is intentional and that Declaration doesn't need to be printed for debugging purposes.


505-505: Import path updates are correct.

All test module imports have been consistently updated from crate:: to super:: paths, correctly reflecting the new module structure.

Also applies to: 588-588, 605-605, 710-710, 803-805, 859-860, 939-940, 1051-1052, 1100-1102, 1149-1151

packages/web-platform/web-mainthread-apis/src/style/transformer/rules.rs (1)

239-239: LGTM! Test import path correctly updated.

The change from crate::transformer::rules:: to super:: is consistent with the module reorganization.

packages/web-platform/web-mainthread-apis/src/style/inline_style_parser/parse_inline_style.rs (1)

1-6: Import path adjustments are correct.

The transition from crate:: to super:: imports properly reflects the new module hierarchy after moving files into the style/inline_style_parser submodule.

packages/web-platform/web-mainthread-apis/src/style/mod.rs (1)

2-3: No issues found. The transformer module is appropriately private and poses no external dependency risk.

The verification confirms that the transformer module is private and used only internally within style/mod.rs. The two public functions (transform_raw_u16_inline_style_ptr and transform_raw_u16_inline_style_ptr_parsed) remain accessible to external callers through their #[wasm_bindgen] exports, maintaining the public API while keeping internal implementation details encapsulated.

packages/web-platform/web-mainthread-apis/Cargo.toml (1)

2-2: LGTM! Package consolidation aligns with PR objectives.

The package rename from "web-style-transformer" to "web-mainthread-apis" correctly reflects the consolidation effort described in the PR.

packages/web-platform/web-mainthread-apis/src/lib.rs (1)

1-1: LGTM! Correct module inclusion.

The style module is properly included as part of the crate restructuring.

packages/web-platform/web-mainthread-apis/src/style/transformer/transform.rs (2)

253-256: LGTM! Unconditional append logic is correct.

The unconditional append of the remaining source (&source[transformer.offset..]) correctly handles all cases:

  • When offset == 0 (no transformations), the entire source is returned
  • When offset > 0, only the untransformed tail is appended
  • When offset == source.len(), an empty string is appended (no-op)

267-272: LGTM! Good test coverage for the no-transformation case.

The new test verifies that declarations without transformation rules are correctly preserved, complementing the existing transformation tests.

Comment thread packages/web-platform/web-mainthread-apis/scripts/build.js Outdated
@codecov
Copy link
Copy Markdown

codecov Bot commented Nov 20, 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 Nov 20, 2025

CodSpeed Performance Report

Merging #1946 will degrade performances by 7.78%

Comparing PupilTong:p/hw/rust-refactor-1 (b83c8cd) with main (6933c50)

Summary

❌ 4 regressions
✅ 59 untouched
⏩ 3 skipped1

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Benchmarks breakdown

Benchmark BASE HEAD Change
transform 1000 view elements 42.4 ms 46 ms -7.78%
basic-performance-div-100 6.1 ms 6.4 ms -5.54%
basic-performance-div-1000 37.1 ms 39.1 ms -5.09%
basic-performance-div-10000 401.4 ms 431.3 ms -6.95%

Footnotes

  1. 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 Nov 20, 2025

Web Explorer

#6267 Bundle Size — 377.49KiB (+2.87%).

b83c8cd(current) vs 6933c50 main#6264(baseline)

Bundle metrics  Change 4 changes Regression 1 regression
                 Current
#6267
     Baseline
#6264
Regression  Initial JS 146.32KiB(+0.03%) 146.27KiB
No change  Initial CSS 32.37KiB 32.37KiB
Change  Cache Invalidation 88.15% 10.42%
No change  Chunks 8 8
No change  Assets 8 8
Change  Modules 230(+5.02%) 219
No change  Duplicate Modules 16 16
Change  Duplicate Code 2.95%(-8.1%) 3.21%
No change  Packages 4 4
No change  Duplicate Packages 0 0
Bundle size by type  Change 2 changes Regression 2 regressions
                 Current
#6267
     Baseline
#6264
Regression  JS 243.17KiB (+0.99%) 240.79KiB
Regression  Other 101.94KiB (+8.67%) 93.81KiB
No change  CSS 32.37KiB 32.37KiB

Bundle analysis reportBranch PupilTong:p/hw/rust-refactor-1Project dashboard


Generated by RelativeCIDocumentationReport issue

@relativeci
Copy link
Copy Markdown

relativeci Bot commented Nov 20, 2025

React Example

#6185 Bundle Size — 234.35KiB (0%).

2a26a9e(current) vs 0f2da6b main#6177(baseline)

Bundle metrics  no changes
                 Current
#6185
     Baseline
#6177
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 164 164
No change  Duplicate Modules 66 66
No change  Duplicate Code 46.71% 46.71%
No change  Packages 2 2
No change  Duplicate Packages 0 0
Bundle size by type  no changes
                 Current
#6185
     Baseline
#6177
No change  IMG 145.76KiB 145.76KiB
No change  Other 88.59KiB 88.59KiB

Bundle analysis reportBranch PupilTong:p/hw/rust-refactor-1Project dashboard


Generated by RelativeCIDocumentationReport issue

@PupilTong PupilTong self-assigned this Nov 20, 2025
@PupilTong PupilTong force-pushed the p/hw/rust-refactor-1 branch from acede56 to b83c8cd Compare November 20, 2025 12:39
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 (1)
packages/web-platform/web-mainthread-apis/src/style/transformer/transform.rs (1)

1-1: Consider using explicit imports instead of wildcards.

While the wildcard imports work correctly, using explicit imports (e.g., use super::super::inline_style_parser::char_code_definitions::{is_white_space, ...}) can improve code clarity and make it easier to track symbol origins.

📜 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 acede56 and b83c8cd.

⛔ Files ignored due to path filters (2)
  • Cargo.lock is excluded by !**/*.lock
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (34)
  • .changeset/config.json (0 hunks)
  • .changeset/long-baths-prove.md (1 hunks)
  • Cargo.toml (1 hunks)
  • packages/web-platform/inline-style-parser/Cargo.toml (0 hunks)
  • packages/web-platform/web-core-server/rslib.config.ts (1 hunks)
  • packages/web-platform/web-core-server/src/createLynxView.ts (1 hunks)
  • packages/web-platform/web-mainthread-apis/Cargo.toml (1 hunks)
  • packages/web-platform/web-mainthread-apis/package.json (1 hunks)
  • packages/web-platform/web-mainthread-apis/scripts/build.js (1 hunks)
  • packages/web-platform/web-mainthread-apis/src/lib.rs (1 hunks)
  • packages/web-platform/web-mainthread-apis/src/style/inline_style_parser/mod.rs (11 hunks)
  • packages/web-platform/web-mainthread-apis/src/style/inline_style_parser/parse_inline_style.rs (1 hunks)
  • packages/web-platform/web-mainthread-apis/src/style/inline_style_parser/tokenize.rs (2 hunks)
  • packages/web-platform/web-mainthread-apis/src/style/inline_style_parser/utils.rs (1 hunks)
  • packages/web-platform/web-mainthread-apis/src/style/mod.rs (1 hunks)
  • packages/web-platform/web-mainthread-apis/src/style/transformer/rules.rs (1 hunks)
  • packages/web-platform/web-mainthread-apis/src/style/transformer/transform.rs (3 hunks)
  • packages/web-platform/web-mainthread-apis/ts/prepareMainThreadAPIs.ts (0 hunks)
  • packages/web-platform/web-mainthread-apis/ts/utils/tokenizer.ts (1 hunks)
  • packages/web-platform/web-mainthread-apis/turbo.json (1 hunks)
  • packages/web-platform/web-mainthread-apis/wasm/index.js (1 hunks)
  • packages/web-platform/web-mainthread-apis/wasm/legacy.js (1 hunks)
  • packages/web-platform/web-mainthread-apis/wasm/standard.js (1 hunks)
  • packages/web-platform/web-style-transformer/CHANGELOG.md (0 hunks)
  • packages/web-platform/web-style-transformer/LICENSE.txt (0 hunks)
  • packages/web-platform/web-style-transformer/Notice.txt (0 hunks)
  • packages/web-platform/web-style-transformer/README.md (0 hunks)
  • packages/web-platform/web-style-transformer/legacy.js (0 hunks)
  • packages/web-platform/web-style-transformer/package.json (0 hunks)
  • packages/web-platform/web-style-transformer/scripts/build.js (0 hunks)
  • packages/web-platform/web-style-transformer/standard.js (0 hunks)
  • packages/web-platform/web-style-transformer/turbo.json (0 hunks)
  • packages/web-platform/web-tests/package.json (0 hunks)
  • packages/web-platform/web-tests/shell-project/mainthread-test.ts (0 hunks)
💤 Files with no reviewable changes (14)
  • packages/web-platform/web-mainthread-apis/ts/prepareMainThreadAPIs.ts
  • packages/web-platform/web-style-transformer/LICENSE.txt
  • packages/web-platform/web-style-transformer/package.json
  • packages/web-platform/web-tests/package.json
  • packages/web-platform/web-style-transformer/README.md
  • packages/web-platform/web-tests/shell-project/mainthread-test.ts
  • packages/web-platform/inline-style-parser/Cargo.toml
  • packages/web-platform/web-style-transformer/Notice.txt
  • packages/web-platform/web-style-transformer/CHANGELOG.md
  • packages/web-platform/web-style-transformer/turbo.json
  • packages/web-platform/web-style-transformer/scripts/build.js
  • packages/web-platform/web-style-transformer/standard.js
  • packages/web-platform/web-style-transformer/legacy.js
  • .changeset/config.json
🚧 Files skipped from review as they are similar to previous changes (12)
  • packages/web-platform/web-mainthread-apis/src/style/inline_style_parser/utils.rs
  • packages/web-platform/web-mainthread-apis/src/style/inline_style_parser/parse_inline_style.rs
  • packages/web-platform/web-mainthread-apis/wasm/index.js
  • packages/web-platform/web-core-server/rslib.config.ts
  • packages/web-platform/web-mainthread-apis/scripts/build.js
  • packages/web-platform/web-mainthread-apis/src/style/mod.rs
  • packages/web-platform/web-mainthread-apis/wasm/standard.js
  • packages/web-platform/web-mainthread-apis/src/lib.rs
  • packages/web-platform/web-core-server/src/createLynxView.ts
  • Cargo.toml
  • packages/web-platform/web-mainthread-apis/src/style/inline_style_parser/mod.rs
  • packages/web-platform/web-mainthread-apis/src/style/transformer/rules.rs
🧰 Additional context used
📓 Path-based instructions (1)
.changeset/*.md

📄 CodeRabbit inference engine (AGENTS.md)

For contributions, generate and commit a Changeset describing your changes

Files:

  • .changeset/long-baths-prove.md
🧠 Learnings (22)
📓 Common learnings
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.
Learnt from: gaoachao
Repo: lynx-family/lynx-stack PR: 1714
File: packages/react/transform/Cargo.toml:19-19
Timestamp: 2025-09-10T11:42:36.855Z
Learning: In packages/react/transform/Cargo.toml, the crate uses serde derive macros (#[derive(Serialize, Deserialize)]) in multiple files including src/esbuild.rs and src/swc_plugin_extract_str/mod.rs, so the "derive" feature is required when migrating to workspace dependencies.
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.
📚 Learning: 2025-09-29T06:43:40.182Z
Learnt from: CR
Repo: lynx-family/lynx-stack PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-09-29T06:43:40.182Z
Learning: Applies to packages/**/etc/*.api.md : Always commit API extractor output after running `pnpm turbo api-extractor -- --local` (commit updated API report files)

Applied to files:

  • packages/web-platform/web-mainthread-apis/turbo.json
📚 Learning: 2025-08-27T11:36:36.415Z
Learnt from: PupilTong
Repo: lynx-family/lynx-stack PR: 1589
File: packages/web-platform/web-tests/resources/web-core.main-thread.json:4-4
Timestamp: 2025-08-27T11:36:36.415Z
Learning: User PupilTong indicated that packages/web-platform/web-tests/resources/web-core.main-thread.json is considered a binary file, despite it appearing as a JSON text file with readable JavaScript code strings in the content.

Applied to files:

  • packages/web-platform/web-mainthread-apis/turbo.json
  • packages/web-platform/web-mainthread-apis/package.json
📚 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-mainthread-apis/wasm/legacy.js
  • packages/web-platform/web-mainthread-apis/Cargo.toml
  • packages/web-platform/web-mainthread-apis/ts/utils/tokenizer.ts
  • packages/web-platform/web-mainthread-apis/package.json
📚 Learning: 2025-09-28T08:46:43.177Z
Learnt from: f0rdream
Repo: lynx-family/lynx-stack PR: 1835
File: packages/react/worklet-runtime/src/workletRuntime.ts:52-55
Timestamp: 2025-09-28T08:46:43.177Z
Learning: The legacy worklet path with `_lepusWorkletHash` in `packages/react/worklet-runtime/src/workletRuntime.ts` is preserved for compatibility with MTS (Mini-app Threading Service) that doesn't support Initial Frame Rendering. This path will not be touched in current implementations.

Applied to files:

  • packages/web-platform/web-mainthread-apis/wasm/legacy.js
📚 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-mainthread-apis/src/style/transformer/transform.rs
  • packages/web-platform/web-mainthread-apis/Cargo.toml
  • packages/web-platform/web-mainthread-apis/ts/utils/tokenizer.ts
📚 Learning: 2025-09-10T11:42:36.855Z
Learnt from: gaoachao
Repo: lynx-family/lynx-stack PR: 1714
File: packages/react/transform/Cargo.toml:19-19
Timestamp: 2025-09-10T11:42:36.855Z
Learning: In packages/react/transform/Cargo.toml, the crate uses serde derive macros (#[derive(Serialize, Deserialize)]) in multiple files including src/esbuild.rs and src/swc_plugin_extract_str/mod.rs, so the "derive" feature is required when migrating to workspace dependencies.

Applied to files:

  • packages/web-platform/web-mainthread-apis/Cargo.toml
  • packages/web-platform/web-mainthread-apis/src/style/inline_style_parser/tokenize.rs
📚 Learning: 2025-11-05T03:26:52.546Z
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1916
File: packages/react/transform/crates/swc_plugin_snapshot/lib.rs:9-9
Timestamp: 2025-11-05T03:26:52.546Z
Learning: In the lynx-stack repository's swc_core v47 upgrade (PR #1916), the import `use swc_core::atoms as swc_atoms;` is required in files that use the `quote!` macro (e.g., packages/react/transform/crates/swc_plugin_snapshot/lib.rs, swc_plugin_list/lib.rs, swc_plugin_worklet/gen_stmt.rs) even though swc_atoms may not appear explicitly in the source code. This is because the quote! macro generates code that internally references swc_atoms. Removing this import causes compiler error: "failed to resolve: use of unresolved module or unlinked crate `swc_atoms`".

Applied to files:

  • packages/web-platform/web-mainthread-apis/src/style/inline_style_parser/tokenize.rs
📚 Learning: 2025-07-16T06:25:41.055Z
Learnt from: PupilTong
Repo: lynx-family/lynx-stack PR: 1029
File: packages/web-platform/web-mainthread-apis/src/createMainThreadGlobalThis.ts:214-217
Timestamp: 2025-07-16T06:25:41.055Z
Learning: In the lynx-stack codebase, CSS strings produced by `genCssContent` are considered trusted developer input, so additional sanitization/escaping is not required.

Applied to files:

  • packages/web-platform/web-mainthread-apis/ts/utils/tokenizer.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, 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:

  • packages/web-platform/web-mainthread-apis/package.json
  • .changeset/long-baths-prove.md
📚 Learning: 2025-11-06T01:19:23.670Z
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1917
File: packages/mcp-servers/devtool-mcp-server/tsconfig.json:8-8
Timestamp: 2025-11-06T01:19:23.670Z
Learning: The lynx-js/devtool-mcp-server package in lynx-family/lynx-stack targets Node.js >=18.19 (specified in its package.json engines), which is different from the root project's requirement of Node.js ^22 || ^24. The package uses "lib": ["ES2024.Promise"] in its tsconfig.json because it manually includes polyfills for Promise.withResolvers while maintaining compatibility with Node.js v18.

Applied to files:

  • packages/web-platform/web-mainthread-apis/package.json
  • .changeset/long-baths-prove.md
📚 Learning: 2025-08-19T11:25:36.127Z
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1558
File: .changeset/solid-squids-fall.md:2-2
Timestamp: 2025-08-19T11:25:36.127Z
Learning: In the lynx-family/lynx-stack repository, changesets should use the exact package name from package.json#name, not generic or unscoped names. Each package has its own specific scoped name (e.g., "lynx-js/react-transform" for packages/react/transform).

Applied to files:

  • packages/web-platform/web-mainthread-apis/package.json
📚 Learning: 2025-08-13T11:36:12.075Z
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1523
File: vitest.config.ts:52-72
Timestamp: 2025-08-13T11:36:12.075Z
Learning: The lynx-stack project requires Node.js >=22 as specified in package.json engines, so Node.js compatibility fallbacks for features introduced before v22 are unnecessary.

Applied to files:

  • packages/web-platform/web-mainthread-apis/package.json
📚 Learning: 2025-08-20T04:56:36.011Z
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1566
File: package.json:53-53
Timestamp: 2025-08-20T04:56:36.011Z
Learning: In lynx-stack, Node.js v24 is the preferred/default version for development (established in PR #1557), but Node.js v22 compatibility is maintained specifically for external CI systems like rspack-ecosystem-ci. The engines.node specification uses "^22 || ^24" to support both versions while keeping v24 as the primary target.

Applied to files:

  • packages/web-platform/web-mainthread-apis/package.json
📚 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-mainthread-apis/package.json
📚 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-mainthread-apis/package.json
  • .changeset/long-baths-prove.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:

  • packages/web-platform/web-mainthread-apis/package.json
  • .changeset/long-baths-prove.md
📚 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-mainthread-apis/package.json
📚 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/long-baths-prove.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/long-baths-prove.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/long-baths-prove.md
📚 Learning: 2025-09-29T06:43:40.182Z
Learnt from: CR
Repo: lynx-family/lynx-stack PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-09-29T06:43:40.182Z
Learning: Applies to .changeset/*.md : For contributions, generate and commit a Changeset describing your changes

Applied to files:

  • .changeset/long-baths-prove.md
🧬 Code graph analysis (1)
packages/web-platform/web-mainthread-apis/src/style/transformer/transform.rs (2)
packages/web-platform/web-mainthread-apis/src/style/inline_style_parser/parse_inline_style.rs (1)
  • parse_inline_style (140-156)
packages/web-platform/web-mainthread-apis/src/style/transformer/rules.rs (4)
  • get_rename_rule_value (221-223)
  • get_replace_rule_value (226-235)
  • get_replace_rule_value (261-265)
  • get_replace_rule_value (278-282)
🔇 Additional comments (12)
packages/web-platform/web-mainthread-apis/wasm/legacy.js (1)

1-1: Proxy re-export is correct and consistent with wasm/binary layout

The relative path and export * proxy pattern look right and align with the described standard.js setup. This keeps the legacy wasm surface centralized without adding extra complexity.

.changeset/long-baths-prove.md (1)

1-7: Clarify whether this changeset should document a version bump or remain empty.

The changeset marks a patch version bump for @lynx-js/web-core-server, but the PR is described as a refactoring with an internal "chore" change. Per learnings from prior PRs (1736, 1330), internal refactoring changes typically use empty changesets to satisfy CI requirements without generating release notes, reserving non-empty changesets for user-facing changes (bugfixes, features).

The description "minor bundle output change" and "timing of loading wasm chunk" is vague and doesn't clearly signal user-facing impact.

If this is an internal-only change: Use an empty changeset (---\n\n---) to satisfy CI without publishing release notes.

If WASM timing changes are user-facing: Expand the description to clarify the user impact and justify the patch bump.

Please confirm whether the WASM loading timing change is user-facing (affecting @lynx-js/web-core-server's public API/behavior) or purely internal optimization.

packages/web-platform/web-mainthread-apis/Cargo.toml (1)

2-2: Dependency migration verified as complete.

All concerns have been addressed:

  • No serde derive macros are used in the source code, so the "derive" feature is not needed.
  • The inline-style-parser functionality has been properly inlined as a local module (packages/web-platform/web-mainthread-apis/src/style/inline_style_parser/), not removed.
  • All dependencies from the original web-style-transformer crate have been accounted for; no external references remain.
  • The consolidation is complete and correct.
packages/web-platform/web-mainthread-apis/turbo.json (1)

15-18: The binary/** output configuration is correct and well-founded.

Verification confirms that the build process explicitly outputs WASM artifacts to the binary/ directory via the wasm-bindgen --out-dir binary command in scripts/build.js. The package.json file intentionally includes binary in the files array for npm publishing, and the turbo.json change correctly tracks these outputs for caching. The configuration is complete and consistent with the actual build process.

packages/web-platform/web-mainthread-apis/src/style/inline_style_parser/tokenize.rs (2)

1-5: LGTM! Import refactoring is correct.

The module import changes correctly reflect the reorganization from crate-level to nested module structure. Using super:: to access parent module items is appropriate for this new hierarchy.


542-542: Test imports updated correctly.

The test module's import path has been properly updated to reflect the new module structure.

packages/web-platform/web-mainthread-apis/src/style/transformer/transform.rs (2)

253-256: Logic simplification looks good.

The unconditional append of the remaining source is safe and cleaner than a conditional check. When offset equals source.len(), an empty string is appended (harmless), and when offset is less, the remaining untransformed source is correctly preserved.


267-272: Good addition of basic test coverage.

This test validates that simple declarations without transformation rules pass through unchanged, providing a useful baseline check for the refactored code.

packages/web-platform/web-mainthread-apis/package.json (3)

31-35: Consolidation of web-style-transformer is complete.

The verification confirms:

  1. Dependency successfully removed: @lynx-js/web-style-transformer is no longer listed in web-mainthread-apis/package.json dependencies.

  2. No lingering references: Zero references to web-style-transformer exist across the entire codebase—no imports, no package directories, no configuration references.

  3. Functionality properly integrated: Style transformation logic is now embedded within web-mainthread-apis:

    • Rust implementation: src/style/inline_style_parser/ and src/style/transformer/ modules
    • TypeScript exports: ts/style/transformInlineStyle.ts and ts/style/cssPropertyMap.ts

The consolidation is complete and the changes are safe to merge.


34-34: I need to clarify the binaryen version discrepancy before finalizing the review.

The search confirms a critical issue. The latest version of binaryen is 124.0.0, but the package.json specifies binaryen@125.0.0, which does not exist on npm. Let me verify Node.js compatibility for these packages:

Fix version error: binaryen@125.0.0 does not exist on npm.

The latest version of binaryen available is 124.0.0, not 125.0.0 as specified in the package.json. This version mismatch will cause npm install to fail. Update the package.json to use "binaryen": "^124.0.0".

The other two packages—wasm-feature-detect@1.8.0 and fb-dotslash@0.5.8—are available and current. wasm-feature-detect runs in browsers, Node and Deno, and both packages are compatible with the project's Node.js ≥22 requirement.

⛔ Skipped due to learnings
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1917
File: packages/mcp-servers/devtool-mcp-server/tsconfig.json:8-8
Timestamp: 2025-11-06T01:19:23.670Z
Learning: The lynx-js/devtool-mcp-server package in lynx-family/lynx-stack targets Node.js >=18.19 (specified in its package.json engines), which is different from the root project's requirement of Node.js ^22 || ^24. The package uses "lib": ["ES2024.Promise"] in its tsconfig.json because it manually includes polyfills for Promise.withResolvers while maintaining compatibility with Node.js v18.
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1523
File: vitest.config.ts:52-72
Timestamp: 2025-08-13T11:36:12.075Z
Learning: The lynx-stack project requires Node.js >=22 as specified in package.json engines, so Node.js compatibility fallbacks for features introduced before v22 are unnecessary.
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1566
File: package.json:53-53
Timestamp: 2025-08-20T04:56:36.011Z
Learning: In lynx-stack, Node.js v24 is the preferred/default version for development (established in PR #1557), but Node.js v22 compatibility is maintained specifically for external CI systems like rspack-ecosystem-ci. The engines.node specification uses "^22 || ^24" to support both versions while keeping v24 as the primary target.
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.

16-27: No validation issues found—package.json configuration is correct.

The files array correctly specifies build artifacts (dist, binary, wasm) along with source files. These directories don't exist in the source tree because they're generated during the build process, which is the standard pattern for compiled packages. The CI workflow (deploy-main.yml) explicitly runs the build step before publishing via changesets, ensuring the directories exist in the npm tarball. The glob patterns for exclusions (!dist/**/*.js.map, !binary/**/*.js.map) and CSS inclusion (**/*.css) are properly specified.

packages/web-platform/web-mainthread-apis/ts/utils/tokenizer.ts (1)

1-1: Critical issue: Missing error handling in wasm module initialization causes runtime crashes.

The import path change in tokenizer.ts is correct, and the wasm module exports match expectations. However, the wasm module has a critical flaw:

  • wasm/index.js exports uninitialized let wasm; and calls await initWasm(); at module scope
  • initWasm() has no error handling — if either referenceTypes() or the dynamic import fails, wasm remains undefined
  • tokenizer.ts calls wasm.transform_raw_u16_inline_style_ptr() without null-checking the wasm object
  • This causes runtime crash: "Cannot read property of undefined"

Add try-catch error handling to packages/web-platform/web-mainthread-apis/wasm/index.js around the initWasm() call and provide a graceful fallback or throw with helpful error message.

⛔ Skipped due to learnings
Learnt from: upupming
Repo: lynx-family/lynx-stack PR: 1370
File: packages/webpack/cache-events-webpack-plugin/src/LynxCacheEventsRuntimeModule.ts:23-27
Timestamp: 2025-08-21T08:46:54.494Z
Learning: In Lynx webpack runtime modules, the team prioritizes performance and simplicity over defensive runtime error handling. They prefer relying on compile-time type safety (TypeScript) rather than adding runtime checks like try-catch blocks or type validation, especially for performance-critical code like cache event setup/cleanup functions.
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.

Comment thread packages/web-platform/web-mainthread-apis/package.json
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 consolidates the WebAssembly-based style transformation functionality by moving Rust source files from the standalone web-style-transformer package into the web-mainthread-apis package. This refactoring simplifies the package structure and improves WASM initialization timing.

Key Changes:

  • Removed the standalone @lynx-js/web-style-transformer package and moved its Rust source files into packages/web-platform/web-mainthread-apis/src/style/
  • Updated WASM initialization to use top-level await in the module, ensuring automatic initialization before use
  • Changed web-core-server to dynamically import prepareMainThreadAPIs to ensure WASM is initialized before execution

Reviewed Changes

Copilot reviewed 34 out of 44 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
pnpm-lock.yaml Updated dependencies: moved wasm-feature-detect to web-mainthread-apis, upgraded binaryen to 125.0.0, removed web-style-transformer references
packages/web-platform/web-tests/shell-project/mainthread-test.ts Removed manual WASM initialization as it now happens automatically via top-level await
packages/web-platform/web-tests/package.json Removed web-style-transformer dependency
packages/web-platform/web-style-transformer/* Deleted entire package directory including build scripts, package.json, and documentation
packages/web-platform/web-mainthread-apis/wasm/* Added WASM wrapper files with automatic initialization via top-level await
packages/web-platform/web-mainthread-apis/turbo.json Added binary/** to build outputs
packages/web-platform/web-mainthread-apis/ts/utils/tokenizer.ts Updated import path from @lynx-js/web-style-transformer to local wasm module
packages/web-platform/web-mainthread-apis/ts/prepareMainThreadAPIs.ts Removed manual WASM initialization logic as it now happens automatically
packages/web-platform/web-mainthread-apis/src/style/* Moved and refactored Rust source files with updated module paths
packages/web-platform/web-mainthread-apis/scripts/* Added build scripts and wasm-bindgen dotslash configuration
packages/web-platform/web-mainthread-apis/package.json Added build script, wasm-feature-detect dependency, and devDependencies for WASM tooling
packages/web-platform/web-mainthread-apis/Cargo.toml Renamed package from web-style-transformer to web-mainthread-apis, removed inline-style-parser dependency
packages/web-platform/web-core-server/src/createLynxView.ts Changed to dynamic import of prepareMainThreadAPIs to ensure WASM initialization completes first
packages/web-platform/web-core-server/rslib.config.ts Added futureDefaults experiment for improved module handling
packages/web-platform/inline-style-parser/Cargo.toml Deleted standalone inline-style-parser package
Cargo.toml Updated workspace members to reference web-mainthread-apis instead of separate packages
Cargo.lock Updated package references reflecting the consolidation
.changeset/long-baths-prove.md Documented the WASM loading timing change for web-core-server
.changeset/config.json Removed web-style-transformer from ignored packages list
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

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

Comment thread packages/web-platform/web-mainthread-apis/scripts/build.js
Comment thread packages/web-platform/web-mainthread-apis/src/lib.rs
@PupilTong PupilTong merged commit e1a9493 into lynx-family:main Nov 21, 2025
84 of 90 checks passed
colinaaa pushed a commit that referenced this pull request Nov 23, 2025
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/rspeedy@0.12.0

### Minor Changes

- Bump Rsbuild v1.6.7 with Rspack v1.6.4.
([#1905](#1905))

### Patch Changes

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

## @lynx-js/devtool-mcp-server@0.4.1

### Patch Changes

- Export `registerTool` and `defineTool`.
([#1931](#1931))

- Fix failed to connect to client.
([#1931](#1931))

## @lynx-js/react@0.114.5

### Patch Changes

- Reduce `__SetInlineStyles` element API call when attrs in spread not
changed ([#1919](#1919))

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

### Patch Changes

-   Updated dependencies \[]:
    -   @lynx-js/web-worker-rpc@0.18.4

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

### Patch Changes

- feat: builtinTagTransformMap add `'x-input-ng': 'x-input'`
([#1932](#1932))

-   Updated dependencies \[]:
    -   @lynx-js/web-constants@0.18.4
    -   @lynx-js/web-mainthread-apis@0.18.4
    -   @lynx-js/web-worker-rpc@0.18.4
    -   @lynx-js/web-worker-runtime@0.18.4

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

### Patch Changes

- feat: builtinTagTransformMap add `'x-input-ng': 'x-input'`
([#1932](#1932))

- chore: minor bundle output change
([#1946](#1946))

    the timing of loading wasm chunk has been changed

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

### Patch Changes

- fix: when estimated-main-axis-size-px is not set, should use the
height of list
([#1930](#1930))

-   Updated dependencies \[]:
    -   @lynx-js/web-elements-template@0.8.11

## @lynx-js/web-explorer@0.0.13

### Patch Changes

- feat: builtinTagTransformMap add `'x-input-ng': 'x-input'`
([#1932](#1932))

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

### Patch Changes

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

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

### Patch Changes

-   Updated dependencies \[]:
    -   @lynx-js/web-constants@0.18.4
    -   @lynx-js/web-mainthread-apis@0.18.4
    -   @lynx-js/web-worker-rpc@0.18.4

## create-rspeedy@0.12.0



## upgrade-rspeedy@0.12.0



## @lynx-js/web-elements-template@0.8.11



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



## @lynx-js/web-worker-rpc@0.18.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

None yet

Development

Successfully merging this pull request may close these issues.

3 participants