feat: add encode module for web-core-wasm#2060
Conversation
|
📝 WalkthroughWalkthroughAdds a new package packages/web-platform/web-core-wasm: Rust→WASM build tooling and manifests, generated WASM TypeScript declaration files, TypeScript runtime/encoder modules and many new type declarations, test harness and tests, package metadata, plus a small Rust error-type signature update. Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ 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). (4)
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. Comment |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Actionable comments posted: 6
🧹 Nitpick comments (25)
packages/web-platform/web-core-wasm/src/template/template_sections/style_info/decoded_style_info.rs (1)
36-59: Consistent error type usage improves clarity.The change to use fully qualified
wasm_bindgen::JsErroraligns with other parts of the codebase (as seen in themod.rsfile) and makes the error boundary more explicit. The implementation correctly uses pre-allocated buffers and the?operator for error propagation.Optional: Add documentation for crate-visible function
While the function is
pub(crate), adding a doc comment would improve maintainability:+ /// Creates a new `StyleInfoDecoder` by decoding the provided raw style information. + /// + /// # Arguments + /// * `raw_style_info` - The raw style information to decode + /// * `entry_name` - Optional entry name for scoping + /// * `config_enable_css_selector` - Whether CSS selector mode is enabled + /// + /// # Errors + /// Returns an error if decoding fails or if keyframes rules are malformed. pub(crate) fn new( raw_style_info: RawStyleInfo, entry_name: Option<String>, config_enable_css_selector: bool, ) -> Result<Self, wasm_bindgen::JsError> {Based on coding guidelines, documentation helps ensure comments accurately reflect logic.
packages/web-platform/web-core-wasm/ts/types/ProcessDataCallback.ts (1)
4-4: Consider usingunknowninstead ofanyfor stricter type safety.The use of
anybypasses TypeScript's type checking. Consider usingunknownor a generic type parameter to maintain type safety while preserving flexibility:export type ProcessDataCallback<T = unknown, R = unknown> = ( data: T, processorName?: string, ) => R;This provides better type safety without losing flexibility for consumers who can specify concrete types when needed.
packages/web-platform/web-core-wasm/ts/types/NativeModules.ts (1)
7-11: Consider usingunknowninstead ofanyfor type-safe module calls.The
anytype fordataparameter and return type bypasses TypeScript's type system. Usingunknownwould provide better type safety:export type NativeModulesCall = ( name: string, - data: any, + data: unknown, moduleName: string, -) => Promise<any> | any; +) => Promise<unknown> | unknown;This forces callers to perform type assertions or guards, reducing the risk of runtime type errors.
packages/web-platform/web-core-wasm/ts/types/NapiModules.ts (1)
9-21: Consider consistent type safety for thedataparameter.While the
dispatchNapiModulesparameter correctly uses the typedCloneable, thedataparameter usesany. For consistency and better type safety, consider usingunknown:export type NapiModulesCall = ( name: string, - data: any, + data: unknown, moduleName: string, dispatchNapiModules: (data: Cloneable) => void, ) =>This maintains type safety throughout the signature and forces proper type handling at call sites.
packages/web-platform/web-core-wasm/tests/jsdom.ts (1)
55-59: Replace @ts-ignore with proper type assertion.Using
@ts-ignoresuppresses all type checking. Use a type assertion instead for better type safety:if (!globalThis.self) { - // @ts-ignore - globalThis.self = globalThis; + (globalThis as any).self = globalThis; }Alternatively, extend the global namespace properly:
declare global { var self: typeof globalThis; }packages/web-platform/web-core-wasm/ts/types/TimingAPIs.ts (1)
15-16: Consider documenting the intent of empty MetricsTimingInfo.The empty interface may be a placeholder for future metrics. Consider adding a JSDoc comment to clarify whether this is intentional or awaiting implementation:
/** * Metrics timing information. * Currently empty - reserved for future metric collection. */ export interface MetricsTimingInfo { }packages/web-platform/web-core-wasm/ts/types/IElementPAPI.ts (1)
1-425: Consider modularizing this large type definition file.At 425 lines, this file defines a comprehensive API surface. For improved maintainability, consider splitting into focused modules:
- Event-related types (AddEventPAPI, GetEventPAPI, etc.)
- Element manipulation types (AppendElementPAPI, RemoveElementPAPI, etc.)
- Configuration/dataset types (SetConfigPAPI, GetDatasetPAPI, etc.)
- Style-related types (AddInlineStylePAPI, SetCSSIdPAPI, etc.)
- Core interfaces (ElementPAPIs, MainThreadGlobalAPIs, etc.)
This would maintain the same public API through a barrel export while improving navigability.
packages/web-platform/web-core-wasm/ts/types/Cloneable.ts (1)
4-8: Consider generic parameter consistency in recursive case.Line 8 references
Cloneablewithout passing the generic parameterT, which means nested structures always use the default primitive types. This may be intentional, but it's inconsistent with the parameterized design.If deeply nested structures should respect the same type constraint, consider:
🔎 Alternative with consistent generics
export type Cloneable<T = string | number | null | boolean | undefined> = | T | Record<string, T> | T[] - | Array<Record<string, Cloneable>>; + | Array<Record<string, Cloneable<T>>>;However, if the current behavior (primitives-only in nested structures) is intended, the implementation is correct as-is.
packages/web-platform/web-core-wasm/ts/encode/encodeCSS.ts (3)
7-10: Address @ts-ignore suppressions.Lines 7-8 use
@ts-ignoreto suppress type errors when importing from the WASM-generated bindings. While this may be necessary during development, consider:
- Whether the generated type definitions can be improved to eliminate the need for suppressions
- Adding comments explaining why the suppressions are necessary
- Using
@ts-expect-errorinstead of@ts-ignore(which will error if the suppression becomes unnecessary)🔎 Recommended improvement
+// Generated WASM bindings may not have complete type definitions +// TODO: Improve type generation or add manual type definitions -// @ts-ignore +// @ts-expect-error - Generated types incomplete } from '../../binary/encode/encode.js'; -// @ts-ignore +// @ts-expect-error - Generated types incomplete export * from '../../binary/encode/encode.js';
80-82: Document the selector parsing workaround.The code adds a mocked declaration to parse selectors, which is a workaround for CSS parsing requirements. This approach is functional but deserves a comment explaining why it's necessary.
🔎 Suggested comment addition
// Parse selectors +// Note: css-tree's parse() requires a complete rule with at least one declaration +// We add a mocked declaration to satisfy the parser, then extract just the selector const ast = CSS.csstree.parse( `${node.selectorText.value}{ --mocked-declaration:1;}`, ) as CSS.csstree.StyleSheet;
107-117: Improve type safety for selector processing.Lines 107-116 use
@ts-expect-errorto accesschild.name, assuming it exists based on runtime checks. However, the error thrown on line 109-111 may not catch all cases wherenameis missing.Consider a more defensive approach:
🔎 Type-safe alternative
-// @ts-expect-error -if (!child.name) { +if (!('name' in child) || !child.name) { throw new Error( `Selector section of type ${child.type} is missing a name/value.`, ); } selector.push_one_selector_section( child.type, - // @ts-expect-error - child.name as string, + ('name' in child ? child.name : '') as string, );This approach uses proper type guards and avoids @ts-expect-error directives.
packages/web-platform/web-core-wasm/ts/types/LynxContextEventTarget.ts (1)
11-23: Clarify event type inconsistency between addEventListener and dispatchEvent.The interface has a type inconsistency:
addEventListeneraccepts listeners of type(event: Event) => void(generic DOM Event)dispatchEventacceptsContextCrossThreadEventThis mismatch could be confusing. Consider:
- If both should use
ContextCrossThreadEventfor consistency- If this is intentional (addEventListener for DOM events, dispatchEvent for cross-thread), add documentation clarifying the distinction
🔎 Option 1: Use consistent types
export interface LynxContextEventTarget { onTriggerEvent?: (event: ContextCrossThreadEvent) => void; postMessage(message: any): void; dispatchEvent( event: ContextCrossThreadEvent, ): number; - addEventListener(type: string, listener: (event: Event) => void): void; + addEventListener(type: string, listener: (event: ContextCrossThreadEvent) => void): void; removeEventListener( type: string, - listener: (event: Event) => void, + listener: (event: ContextCrossThreadEvent) => void, ): void; }Option 2: Add clarifying documentation
export interface LynxContextEventTarget { onTriggerEvent?: (event: ContextCrossThreadEvent) => void; postMessage(message: any): void; + /** Dispatches a cross-thread event */ dispatchEvent( event: ContextCrossThreadEvent, ): number; + /** Registers a listener for DOM-compatible events */ addEventListener(type: string, listener: (event: Event) => void): void; + /** Removes a listener for DOM-compatible events */ removeEventListener( type: string, listener: (event: Event) => void, ): void; }packages/web-platform/web-core-wasm/ts/encode/encodeElementTemplate.ts (2)
10-11: Consider addressing the@ts-ignoredirective.The
@ts-ignoresuppresses type checking for the WASM bindings import. If the type definitions are expected to exist in../../binary/encode/encode.js, ensure they are properly generated and exported. Otherwise, consider adding a proper type declaration file or documenting why this is necessary.
21-76: Nested function is recreated on each template iteration.The
createEncodeOneElementTemplateDatafunction is defined inside theforloop, causing it to be recreated for every template entry. While functionally correct, this can be slightly inefficient for large template sets.Consider hoisting the function or using a closure factory pattern if performance becomes a concern.
🔎 Alternative approach to avoid function recreation
export function encodeElementTemplates( elementTemplates: Record<string, ElementTemplateData>, ): Uint8Array { const elementTemplateSection = new ElementTemplateSection(); + + function createEncodeOneElementTemplateData( + data: ElementTemplateData, + elementTemplate: RawElementTemplate, + getNextId: () => number, + ): number { + const currentId = getNextId(); + elementTemplate.create_element(data.type, currentId); + // ... rest of encoding logic, using getNextId() instead of uniqueId + return currentId; + } + for (const [key, templateData] of Object.entries(elementTemplates)) { let uniqueId = 1; const elementTemplate = new RawElementTemplate(); - - function createEncodeOneElementTemplateData(data: ElementTemplateData) { - // ... function body - } + const getNextId = () => uniqueId++; elementTemplate.append_to_root( - createEncodeOneElementTemplateData(templateData), + createEncodeOneElementTemplateData(templateData, elementTemplate, getNextId), );packages/web-platform/web-core-wasm/tests/encode.spec.ts (1)
351-361: Commented-out test should be addressed.There's a commented-out test for
cssog basic. Either remove it if it's no longer needed, or add a TODO comment explaining why it's disabled and when it should be re-enabled.packages/web-platform/web-core-wasm/ts/types/Element.ts (1)
43-48: Consider using stricter types for animation options.The
keyframesandtimingOptionsfields useanyandRecord<string, any>, which bypasses TypeScript's type safety benefits. If possible, consider using Web Animations API types for better type checking.🔎 Suggested stricter typing
export interface ElementAnimationOptions { operation: AnimationOperation; id: string; - keyframes?: any; - timingOptions?: Record<string, any>; + keyframes?: Keyframe[] | PropertyIndexedKeyframes; + timingOptions?: KeyframeAnimationOptions; }Note:
Keyframe,PropertyIndexedKeyframes, andKeyframeAnimationOptionsare built-in DOM types from the Web Animations API.packages/web-platform/web-core-wasm/ts/types/BTSChunk.ts (1)
5-44: Consider grouping parameters into a typed object for maintainability.The 33+ positional parameters make this signature difficult to maintain and error-prone when adding/removing dependencies. A grouped object pattern would improve clarity and make future changes safer.
🔎 Alternative grouped parameter approach
export interface BTSChunkDependencies { // Module system postMessage: undefined; module: { exports: unknown }; exports: unknown; // Lynx Core lynxCoreInject: unknown; Card: unknown; NativeModules: unknown; Component: unknown; ReactLynx: unknown; nativeAppId: unknown; Behavior: unknown; LynxJSBI: unknown; lynx: unknown; Reporter: unknown; // Timing APIs setTimeout: unknown; setInterval: unknown; clearInterval: unknown; clearTimeout: unknown; requestAnimationFrame: unknown; cancelAnimationFrame: unknown; // BOM APIs window: unknown; document: unknown; // ... etc } export type BTSChunkEntry = (deps: BTSChunkDependencies) => unknown;Note: This would be a breaking change if the current signature is already in use.
packages/web-platform/web-core-wasm/ts/types/I18nTypes.ts (1)
8-13: Naming inconsistency:fallback_urluses snake_case while other fields use camelCase.The
fallback_urlfield uses snake_case whilelocaleandchanneluse camelCase. Consider aligning to a consistent naming convention.export interface I18nResourceTranslationOptions { locale: string; channel: string; - fallback_url?: string; + fallbackUrl?: string; [key: string]: Cloneable; }If
fallback_urlis required for compatibility with an external API, consider documenting this.packages/web-platform/web-core-wasm/ts/types/IMtsBinding.ts (1)
33-33: Consider using camelCase for parameter naming consistency.The parameter
event_nameuses snake_case, while other parameters in this interface use camelCase (e.g.,handlerName,eventObject). For consistency with TypeScript conventions and the rest of this interface, consider renaming toeventName.Suggested fix
- addEventListener(event_name: string): void; + addEventListener(eventName: string): void;packages/web-platform/web-core-wasm/ts/types/MainThreadLynx.ts (1)
2-2: Copyright year may need update.The copyright year is 2023, but this appears to be a new file created in 2025 based on the PR context. Consider updating to 2025 for consistency with other new files in this PR.
packages/web-platform/web-core-wasm/ts/types/EventType.ts (2)
21-32: Index signature may be overly permissive.The index signature on line 31 allows
{}as a value type, which could permit unintended object shapes. If the intent is to allow object values, consider using a more specific type orRecord<string, unknown>pattern for better type safety.
45-54: Dual-casing pattern for backward compatibility.The
ExposureEventDetailtype provides both kebab-case (exposure-id) and camelCase (exposureID) properties. This appears intentional for compatibility with different consumers. Consider adding a brief doc comment to clarify this design decision for future maintainers.packages/web-platform/web-core-wasm/ts/constants.ts (1)
55-55: Document magic number meaning.The magic header
0x464F525741524453decodes to ASCII "FORWARDS". Consider adding this to the comment for clarity.Suggested enhancement
-export const MagicHeader = /*#__PURE__*/ 0x464F525741524453; // random magic number for verififying the stream is a Lynx encoded template +export const MagicHeader = /*#__PURE__*/ 0x464F525741524453; // "FORWARDS" in ASCII - magic number for verifying the stream is a Lynx encoded templatepackages/web-platform/web-core-wasm/ts/types/NativeApp.ts (2)
11-14: Circular type reference in LynxKernelInject.The
initmethod takes{ tt: LynxKernelInject }, creating a self-referential type. If this is intentional for a bootstrap pattern, consider adding a doc comment to clarify the design intent.
203-203: Unused parameter in reportException signature.The second parameter
_: unknownappears to be unused. If this is for API compatibility, consider documenting it. Otherwise, it could be removed.If parameter is for compatibility
- reportException: (error: Error, _: unknown) => void; + /** @param _legacyParam - Preserved for API compatibility, unused */ + reportException: (error: Error, _legacyParam: unknown) => void;
f94b074 to
1927129
Compare
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (4)
packages/web-platform/web-core-wasm/ts/constants.ts (3)
16-16: Verify naming consistency.
lynxPartIdAttributeis set to'dirtyID', which seems inconsistent. The constant name suggests "part ID" while the value suggests "dirty ID". Please verify this is intentional or if one should be renamed for clarity.
30-33: Consider more specific typing.The type
Record<string, string | number>permits numbers, but the object only contains strings. Consider usingRecord<string, string>or a more specific interface for better type safety.
50-52: Verify self-mapping is intentional.
'lynxblur','lynxfocus', and'lynxinput'map to themselves inLynxEventNameToW3cCommon. This differs from other entries that perform actual transformations. Please confirm this is intentional and not a placeholder.packages/web-platform/web-core-wasm/scripts/build.js (1)
8-25: Consider using absolute paths from packageRoot.The relative paths with multiple
..separators are fragile. If the directory structure changes, these paths may break.🔎 Proposed refactor using packageRoot
-const cargoOutput = path.join( - '..', - '..', - '..', - 'target', - 'wasm32-unknown-unknown', - 'release', - 'web_core_wasm.wasm', -); -const cargoOutputDebug = path.join( - '..', - '..', - '..', - 'target', - 'wasm32-unknown-unknown', - 'debug', - 'web_core_wasm.wasm', -); +const cargoOutput = path.join( + packageRoot, + '..', + '..', + 'target', + 'wasm32-unknown-unknown', + 'release', + 'web_core_wasm.wasm', +); +const cargoOutputDebug = path.join( + packageRoot, + '..', + '..', + 'target', + 'wasm32-unknown-unknown', + 'debug', + 'web_core_wasm.wasm', +);
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
packages/web-platform/web-core-wasm/scripts/build.jspackages/web-platform/web-core-wasm/ts/constants.tspackages/web-platform/web-core-wasm/ts/types/index.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- packages/web-platform/web-core-wasm/ts/types/index.ts
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{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-core-wasm/scripts/build.jspackages/web-platform/web-core-wasm/ts/constants.ts
**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
Use TypeScript in strict mode with the configuration specified in tsconfig.json
Files:
packages/web-platform/web-core-wasm/ts/constants.ts
🧠 Learnings (27)
📓 Common learnings
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 : When adding new functionality, carefully consider which feature flag it belongs to (`client`, `encode`, or `server`).
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.
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.
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 all public structs, enums, and functions have clear documentation comments (`///`). Comments must accurately reflect the logic.
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 `#[cfg(feature = "...")]` to conditionally compile code based on features (`client`, `encode`, `server`).
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.
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-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)]`.
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 : Minimize crossing the WASM/JS boundary. Batch operations where possible.
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: AGENTS.md:0-0
Timestamp: 2025-12-26T05:10:01.595Z
Learning: Applies to packages/**/*.rs : Include Rust compilation targets (wasm32-unknown-unknown) for packages requiring native bindings
📚 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 : Minimize crossing the WASM/JS boundary. Batch operations where possible.
Applied to files:
packages/web-platform/web-core-wasm/scripts/build.jspackages/web-platform/web-core-wasm/ts/constants.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 : When adding new functionality, carefully consider which feature flag it belongs to (`client`, `encode`, or `server`).
Applied to files:
packages/web-platform/web-core-wasm/scripts/build.jspackages/web-platform/web-core-wasm/ts/constants.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-core-wasm/scripts/build.jspackages/web-platform/web-core-wasm/ts/constants.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-core-wasm/scripts/build.js
📚 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-core-wasm/scripts/build.js
📚 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 `#[cfg(feature = "...")]` to conditionally compile code based on features (`client`, `encode`, `server`).
Applied to files:
packages/web-platform/web-core-wasm/scripts/build.js
📚 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-core-wasm/scripts/build.js
📚 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-core-wasm/scripts/build.jspackages/web-platform/web-core-wasm/ts/constants.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 packages/**/*.rs : Include Rust compilation targets (wasm32-unknown-unknown) for packages requiring native bindings
Applied to files:
packages/web-platform/web-core-wasm/scripts/build.js
📚 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-core-wasm/scripts/build.jspackages/web-platform/web-core-wasm/ts/constants.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 : Minimize allocations in hot paths. Use `String::with_capacity()` when the size is known, reuse buffers where possible.
Applied to files:
packages/web-platform/web-core-wasm/scripts/build.js
📚 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-core-wasm/scripts/build.js
📚 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 idiomatic Rust patterns. Prefer `Option::map`, `Result::and_then`, iterators, and pattern matching over imperative code where appropriate.
Applied to files:
packages/web-platform/web-core-wasm/scripts/build.js
📚 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 `Result` types for fallible operations. Avoid `unwrap()` in production code paths; prefer `?` operator or explicit error handling.
Applied to files:
packages/web-platform/web-core-wasm/scripts/build.js
📚 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/**/*.rs : Implement native bindings tests using cargo test in Rust packages
Applied to files:
packages/web-platform/web-core-wasm/scripts/build.js
📚 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-core-wasm/ts/constants.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-core-wasm/ts/constants.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-core-wasm/ts/constants.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 : Ensure that all public structs, enums, and functions have clear documentation comments (`///`). Comments must accurately reflect the logic.
Applied to files:
packages/web-platform/web-core-wasm/ts/constants.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-core-wasm/ts/constants.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-core-wasm/ts/constants.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-wasm/ts/constants.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-core-wasm/ts/constants.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-wasm/ts/constants.ts
📚 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-core-wasm/ts/constants.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-core-wasm/ts/constants.ts
⏰ 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). (2)
- GitHub Check: build / Build (Ubuntu)
- GitHub Check: test-rust / Test (Ubuntu)
🔇 Additional comments (4)
packages/web-platform/web-core-wasm/ts/constants.ts (1)
95-121: No changes required. The TypeScript and Rust constants are properly synchronized—all tag mappings and their corresponding IDs match exactly across both files.packages/web-platform/web-core-wasm/scripts/build.js (3)
77-89: Excellent documentation of WebAssembly feature support.The feature support matrix with browser versions and reference links is very helpful for understanding the build configuration choices.
97-97: No action needed. The--all-featuresflag is a valid wasm-opt option that enables all WebAssembly features during optimization. Using it for theencodebuild is intentional—the encode feature is a build-time tool for template serialization, not runtime code, so enabling all WASM features during optimization is appropriate.Likely an incorrect or invalid review comment.
56-59: The hardcoded--enable-bulk-memoryflag usage appears intentional and defensive.The flag is hardcoded for both client and encode builds. For the client build, it explicitly enables the bulk-memory feature separately from the optimization flag (
--enable-bulk-memory-opt). For the encode build, it's combined with--all-features, which may or may not already include bulk-memory depending on wasm-opt's behavior. AGENTS.md emphasizes bulk-memory as a critical feature with broad browser support (Chrome 75+, Firefox 79+, Safari 15+), suggesting the defensive approach is intentional. If the goal is to ensure bulk-memory is always available, the current implementation is correct. If the intent is to optimize the flags, verify whether--all-featuresalready enables bulk-memory in the version of wasm-opt being used (binaryen 124.0.0), and remove the redundancy if confirmed.
0dc8f55 to
5894777
Compare
CodSpeed Performance ReportMerging #2060 will degrade performance by 7.22%Comparing Summary
Benchmarks breakdown
Footnotes
|
Web Explorer#6925 Bundle Size — 379.05KiB (-0.04%).3eeeef1(current) vs 34065b5 main#6922(baseline) Bundle metrics
Bundle size by type
Bundle analysis report Branch PupilTong:p/hw/rust-pick-encode Project dashboard Generated by RelativeCI Documentation Report issue |
React Example#6765 Bundle Size — 237KiB (0%).3eeeef1(current) vs 34065b5 main#6762(baseline) Bundle metrics
|
| Current #6765 |
Baseline #6762 |
|
|---|---|---|
0B |
0B |
|
0B |
0B |
|
0% |
0% |
|
0 |
0 |
|
4 |
4 |
|
162 |
162 |
|
65 |
65 |
|
46.74% |
46.74% |
|
2 |
2 |
|
0 |
0 |
Bundle size by type no changes
| Current #6765 |
Baseline #6762 |
|
|---|---|---|
145.76KiB |
145.76KiB |
|
91.24KiB |
91.24KiB |
Bundle analysis report Branch PupilTong:p/hw/rust-pick-encode Project dashboard
Generated by RelativeCI Documentation Report issue
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (10)
packages/web-platform/web-core-wasm/src/template/template_sections/style_info/decoded_style_info.rs (1)
40-40: Standardize error type naming across the style_info module.The module currently uses inconsistent patterns for error types.
decoded_style_info.rsandmod.rsuse fully qualifiedwasm_bindgen::JsError, whileraw_style_info.rsuses bareJsError(relying onuse wasm_bindgen::prelude::*;). For consistency across the module, consider standardizing on the fully qualified form used in the public API functions inmod.rs.Lines 40, 61–64, 246
packages/web-platform/web-core-wasm/vitest.config.ts (1)
9-17: Consider aligning test name with package name.The test suite is named
'web-platform/web-core-tests'but the package isweb-core-wasm. For consistency and easier identification in test reports, consider renaming to'web-platform/web-core-wasm'.🔎 Proposed fix
export default defineConfig({ test: { - name: 'web-platform/web-core-tests', + name: 'web-platform/web-core-wasm', include: ['**/tests/*.spec.ts'], exclude: ['**/tests/*.bench.spec.ts'],packages/web-platform/web-core-wasm/ts/types/NapiModules.ts (1)
9-21: Consider using a more specific type for thedataparameter.The
dataparameter is typed asany, which bypasses TypeScript's type checking. If possible, consider usingunknownorCloneablefor better type safety, consistent with howdispatchNapiModulesis typed.🔎 Proposed fix
export type NapiModulesCall = ( name: string, - data: any, + data: unknown, moduleName: string, dispatchNapiModules: (data: Cloneable) => void, ) =>packages/web-platform/web-core-wasm/ts/types/NativeModules.ts (1)
7-11: Consider using more specific types for better type safety.Both the
dataparameter and return type useany. For consistency withNapiModulesCall(which usesunknownin return types) and better type safety, consider usingunknown:🔎 Proposed fix
export type NativeModulesCall = ( name: string, - data: any, + data: unknown, moduleName: string, -) => Promise<any> | any; +) => Promise<unknown> | unknown;packages/web-platform/web-core-wasm/ts/types/UpdateDataOptions.ts (1)
1-9: Add license header for consistency.This file is missing the Apache License header that other files in the same directory include (e.g.,
NapiModules.ts,NativeModules.ts,JSRealm.ts).🔎 Proposed fix
+// Copyright 2023 The Lynx Authors. All rights reserved. +// Licensed under the Apache License Version 2.0 that can be found in the +// LICENSE file in the root directory of this source tree. + export const enum NativeUpdateDataType { UPDATE = 0, RESET = 1,packages/web-platform/web-core-wasm/ts/types/ProcessDataCallback.ts (1)
4-4: Consider improving type safety and adding documentation.The
anytypes for bothdataand the return value reduce type safety. Since this is a new public type export, consider using generics orunknownfor better type safety, and add JSDoc documentation to clarify the intended usage.🔎 Suggested improvement
+/** + * Callback for processing data from a worker thread. + * @param data - The data to process + * @param processorName - Optional name of the processor + * @returns Processed data result + */ -export type ProcessDataCallback = (data: any, processorName?: string) => any; +export type ProcessDataCallback<T = unknown, R = unknown> = (data: T, processorName?: string) => R;packages/web-platform/web-core-wasm/tests/encode.spec.ts (1)
351-361: Remove or enable the commented-out test.The commented-out test at lines 351-361 should either be removed if it's obsolete or uncommented and fixed if it's still needed. Leaving commented-out tests in the codebase can cause confusion.
packages/web-platform/web-core-wasm/ts/client/wasm.ts (2)
42-74: Consider exposing resource cleanup for the wrapped WASM object.
DecodedStyleDatafrom the WASM bindings providesfree()and[Symbol.dispose]()methods for releasing memory. TheDecodedStylewrapper class doesn't expose these, which could lead to memory leaks if instances aren't garbage collected promptly.🔎 Suggested addition for resource cleanup
export class DecodedStyle { // ... existing code ... + + free(): void { + this.#styleData.free(); + } + + [Symbol.dispose](): void { + this.#styleData[Symbol.dispose](); + } }
37-40: The code pattern is correct and intentional. Top-levelawaitis supported by the build configuration (ESNext target with webpack), and the worker initialization approach is deliberately different: workers useDecodedStyle.webWorkerDecode()for style decoding rather than callinginitSync(). This pattern is tested and working.However, update
AGENTS.mdto explicitly document that thewasm.tsmodule exportswasmInstanceprimarily for main-thread use, and that workers should use the staticwebWorkerDecode()method onDecodedStylefor decoding style data instead of relying on module-level initialization.packages/web-platform/web-core-wasm/ts/types/NativeApp.ts (1)
1-3: Copyright year appears outdated.The copyright header shows 2023, but this is new code being added in 2025. Consider updating to the current year for consistency with other new files in this PR.
3ba406c to
e7e3df0
Compare
There was a problem hiding this comment.
Actionable comments posted: 4
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
packages/web-platform/web-core-wasm/src/template/template_sections/style_info/decoded_style_info.rs (2)
19-33: Add documentation comments for the public struct.The
StyleInfoDecoderstruct is conditionally exposed viawasm_bindgenwhen theencodefeature is enabled, making it part of the public API surface. It lacks documentation comments explaining its purpose, fields, and usage.As per coding guidelines, all public structs, enums, and functions must have clear documentation comments (
///).📝 Suggested documentation structure
+/// Decoder for style information that transforms raw CSS rules into a flat string representation. +/// +/// This decoder handles CSS transformations including: +/// - Converting selectors (e.g., `:root` to `[part="page"]`) +/// - Processing @font-face and @keyframes rules +/// - Handling CSS scope and entry names +/// - Transforming custom units (e.g., `rpx`) #[cfg_attr(feature = "encode", wasm_bindgen)] // for testing purpose pub(crate) struct StyleInfoDecoder { + /// Generated CSS content (excluding font-face rules) pub(super) style_content: String, + /// Separate buffer for @font-face rules (placed at the head) pub(super) font_face_content: String, // ... rest of fields with their doc comments
36-59: Add documentation for the constructor method.The
newmethod lacks documentation explaining its parameters, return value, and potential errors. This is essential for a public API exposed via wasm_bindgen.As per coding guidelines, all public functions must have clear documentation comments.
📝 Suggested documentation
+ /// Creates a new `StyleInfoDecoder` and decodes the provided raw style information. + /// + /// # Arguments + /// + /// * `raw_style_info` - The raw style information to decode + /// * `entry_name` - Optional entry name for CSS scoping + /// * `config_enable_css_selector` - Whether to enable full CSS selector processing + /// + /// # Errors + /// + /// Returns an error if decoding fails (e.g., invalid keyframes structure) pub(crate) fn new( raw_style_info: RawStyleInfo, entry_name: Option<String>, config_enable_css_selector: bool, ) -> Result<Self, wasm_bindgen::JsError> {
♻️ Duplicate comments (1)
packages/web-platform/web-core-wasm/ts/encode/webEncoder.ts (1)
95-97:String(value)may produce unexpected results for nested objects.This concern was previously raised. When
pageConfigcontains nested objects,String(value)will produce"[object Object]"instead of meaningful serialization.
🧹 Nitpick comments (13)
packages/web-platform/web-core-wasm/ts/types/ProcessDataCallback.ts (2)
4-4: Consider replacinganywithunknownfor better type safety.The use of
anyfor both thedataparameter and return type bypasses TypeScript's type checking. In strict mode, preferunknown(which requires type narrowing) or define specific types if the shape is known.🔎 Suggested refactor using `unknown`
-export type ProcessDataCallback = (data: any, processorName?: string) => any; +export type ProcessDataCallback = (data: unknown, processorName?: string) => unknown;
4-4: Add JSDoc documentation for the public type.Since this type is part of the public API surface, consider adding JSDoc comments to explain its purpose, parameter meanings, and expected return value.
🔎 Example JSDoc documentation
+/** + * Callback function for processing data with an optional processor name. + * @param data - The data to be processed + * @param processorName - Optional name of the processor handling the data + * @returns The processed data + */ export type ProcessDataCallback = (data: any, processorName?: string) => any;packages/web-platform/web-core-wasm/ts/types/NativeApp.ts (2)
32-32: UseRecord<string, any>for better type safety.Object keys in JavaScript are always strings (or symbols). Using
anyas the key type provides no additional flexibility but loses type safety.Suggested fix
- trigger(eventName: string, params: string | Record<any, any>): void; + trigger(eventName: string, params: string | Record<string, any>): void;
194-196: Consider a more descriptive return type.The return type
{}(empty object type) provides minimal type information. If the observer object has any known properties or methods, consider defining them. Otherwise,objector a branded type may be more appropriate to indicate it's an opaque handle.Suggested improvement
createJSObjectDestructionObserver( callback: (...args: unknown[]) => unknown, - ): {}; + ): object;Or define a specific type if the observer has known methods:
type DestructionObserver = { // Add known properties/methods if any };packages/web-platform/web-core-wasm/ts/types/IMtsBinding.ts (1)
10-39: Add JSDoc documentation for each method.The interface-level comment is present, but individual methods lack documentation explaining their purpose, parameters, and expected behavior. This is especially important for public WASM bindings that will be consumed by other modules.
📝 Suggested JSDoc additions
/** * The JS binding for the WASM main thread context instance. */ export interface RustMainthreadContextBinding { + /** + * Executes a worklet handler with the provided event context. + * @param handler - The worklet handler function to execute + * @param eventObject - The cross-thread event object + * @param targetUniqueId - Unique identifier for the event target + * @param targetDataset - Dataset associated with the target element + * @param currentTargetUniqueId - Unique identifier for the current target + * @param currentTargetDataset - Dataset associated with the current target element + */ runWorklet( handler: unknown, eventObject: LynxCrossThreadEvent, targetUniqueId: number, targetDataset: CloneableObject, currentTargetUniqueId: number, currentTargetDataset: CloneableObject, ): void; + /** + * Publishes an event to registered handlers. + * @param handlerName - Name of the event handler + * @param parentComponentId - Optional parent component identifier + * @param eventObject - The cross-thread event object + * @param targetUniqueId - Unique identifier for the event target + * @param targetDataset - Dataset associated with the target element + * @param currentTargetUniqueId - Unique identifier for the current target + * @param currentTargetDataset - Dataset associated with the current target element + */ publishEvent( handlerName: string, parentComponentId: string | undefined, eventObject: LynxCrossThreadEvent, targetUniqueId: number, targetDataset: CloneableObject, currentTargetUniqueId: number, currentTargetDataset: CloneableObject, ): void; + /** + * Registers an event listener for the specified event name. + * @param event_name - The name of the event to listen for + */ addEventListener(event_name: string): void; + /** + * Marks an element for exposure tracking based on its unique ID. + * @param uniqueId - The unique identifier of the element + * @param toEnable - Whether to enable or disable exposure tracking + */ markExposureRelatedElementByUniqueId( uniqueId: number, toEnable: boolean, ): void; }packages/web-platform/web-core-wasm/ts/types/BTSChunk.ts (1)
5-44: Add documentation for this complex public type.The
BTSChunkEntrytype has 36+ parameters representing a complete execution environment but lacks JSDoc comments explaining:
- What BTSChunkEntry represents (appears to be a chunk entry point function signature)
- When/how it should be used
- Why certain parameters (e.g.,
postMessage) have specific types- The semantic meaning of the environment parameters
Consider adding comprehensive JSDoc comments to improve maintainability.
Additionally, while
unknownis type-safe for WASM interop boundaries, verify whether more specific types could be used for commonly-typed parameters likesetTimeout,setInterval,fetch,XMLHttpRequest, or BOM APIs where standard TypeScript lib types exist.Based on learnings: The team values compile-time type safety. Consider whether stricter typing for at least some parameters would benefit consumers without compromising WASM interop flexibility.
packages/web-platform/web-core-wasm/ts/types/IElementPAPI.ts (3)
402-403: Clarify the comment for type-only declaration.The comment mentions "empty implementation," but this is a type declaration file. Consider revising to something like:
// Type placeholder for _AddEventListener to avoid business call errors at runtimeto clarify this is describing the runtime behavior, not the type definition.🔎 Suggested comment update
- // This is an empty implementation, just to avoid business call errors + // Runtime provides a placeholder implementation to avoid business call errors _AddEventListener: (...args: unknown[]) => void;
408-408: Fix grammar in comment.The comment has a subject-verb agreement error. Change "is assigned" to "are assigned" for the plural subject "methods."
🔎 Grammar fix
- // the following methods is assigned by the main thread user code + // the following methods are assigned by the main thread user code renderPage: ((data: unknown) => void) | undefined;
15-425: Add JSDoc documentation for public API surface.This file defines the public Element PAPI interface with extensive type declarations (~40 type aliases and 3 major interfaces), but lacks JSDoc comments. Adding documentation would significantly improve developer experience and API discoverability, especially for complex methods like
CreateComponentPAPI,UpdateListCallbacksPAPI, and the various element manipulation APIs.Based on learnings, all public types should have clear documentation comments.
Example documentation structure:
/** * Options for flushing the element tree to the native layer. */ export interface FlushElementTreeOptions { /** Optional pipeline performance tracking options. */ pipelineOptions?: PerformancePipelineOptions; } /** * Event handler for Element PAPI events. * Can be a string identifier, a worklet descriptor, or undefined. */ type ElementPAPIEventHandler = | string | { type: 'worklet'; value: unknown } | undefined; /** * Adds an event listener to an element. * @param element - The target HTML element * @param eventType - Lynx event type (bindEvent, catchEvent, etc.) * @param eventName - Name of the event to listen for * @param newEventHandler - Event handler function or worklet */ export type AddEventPAPI = ( element: HTMLElement, eventType: LynxEventType, eventName: string, newEventHandler: ElementPAPIEventHandler, ) => void;packages/web-platform/web-core-wasm/ts/encode/encodeCSS.ts (2)
7-10: Consider adding type declarations for the encode.js module.The
@ts-ignorecomments suppress type errors for the encode.js import. While this works, adding proper type declarations would improve type safety and IDE support. This could be addressed when the encode.d.ts file is stabilized.
100-106: Consider adding PseudoElementSelector handling.The code handles
PseudoClassSelectorby slicing off the leading colon (:hover→hover), but there's no explicit handling forPseudoElementSelector(e.g.,::before,::after). These would fall through to the generic handler which may not handle the double-colon correctly.🔎 Proposed fix
if (child.type === 'PseudoClassSelector') { selector.push_one_selector_section( child.type, CSS.csstree.generate(child).slice(1), ); continue; } + if (child.type === 'PseudoElementSelector') { + selector.push_one_selector_section( + child.type, + CSS.csstree.generate(child).slice(2), + ); + continue; + }packages/web-platform/web-core-wasm/binary/client/client.d.ts (2)
29-29: Consider more specific typing for the function field.The
functionfield is typed asany, which reduces type safety. If the function signature is known, consider using a more specific type such asFunctionor an appropriate callback signature.💡 Potential type improvement
- function: any; + function: Function;Or if the signature is known:
function: (event: Event) => void;
49-55: Consider stricter typing for event-related parameters.Multiple methods use
anyfor event-related parameters (lines 51, 52, 54, 55). While this may be necessary for WASM bindings, consider usingunknowninstead ofanyto enforce type checking at usage sites, or define specific event types if the structure is known.
There was a problem hiding this comment.
Actionable comments posted: 1
♻️ Duplicate comments (1)
packages/web-platform/web-core-wasm/package.json (1)
13-20: Exports and main field mismatch still present.The
exportsfield only declares"./encode"whilemainpoints to"./dist/client/index.js", creating a resolution inconsistency. Modern Node.js and bundlers prioritizeexportsovermain, making the client entry point unreachable via standard imports. Either add a"./client"export entry or updatemainto align with the declared exports.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (1)
packages/web-platform/web-core-wasm/package.json
🧰 Additional context used
🧠 Learnings (19)
📓 Common learnings
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 : When adding new functionality, carefully consider which feature flag it belongs to (`client`, `encode`, or `server`).
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.
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.
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 `#[cfg(feature = "...")]` to conditionally compile code based on features (`client`, `encode`, `server`).
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.
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 : Minimize crossing the WASM/JS boundary. Batch operations where possible.
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-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)]`.
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 idiomatic Rust patterns. Prefer `Option::map`, `Result::and_then`, iterators, and pattern matching over imperative code where appropriate.
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/**/*.rs : Include Rust compilation targets (wasm32-unknown-unknown) for packages requiring native bindings
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 `Result` types for fallible operations. Avoid `unwrap()` in production code paths; prefer `?` operator or explicit error handling.
📚 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-core-wasm/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, 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-core-wasm/package.json
📚 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 : When adding new functionality, carefully consider which feature flag it belongs to (`client`, `encode`, or `server`).
Applied to files:
packages/web-platform/web-core-wasm/package.json
📚 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-core-wasm/package.json
📚 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-core-wasm/package.json
📚 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-core-wasm/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-core-wasm/package.json
📚 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-core-wasm/package.json
📚 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 all public structs, enums, and functions have clear documentation comments (`///`). Comments must accurately reflect the logic.
Applied to files:
packages/web-platform/web-core-wasm/package.json
📚 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-core-wasm/package.json
📚 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-core-wasm/package.json
📚 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-core-wasm/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-core-wasm/package.json
📚 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-wasm/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-core-wasm/package.json
📚 Learning: 2025-08-14T12:54:51.143Z
Learnt from: upupming
Repo: lynx-family/lynx-stack PR: 1370
File: .changeset/brave-melons-add.md:1-7
Timestamp: 2025-08-14T12:54:51.143Z
Learning: In the lynx-family/lynx-stack repository, packages use 0.x.x versioning where minor version bumps indicate breaking changes (not major bumps), following pre-1.0 semantic versioning conventions.
Applied to files:
packages/web-platform/web-core-wasm/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-core-wasm/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-core-wasm/package.json
⏰ 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 (Ubuntu)
- GitHub Check: test-rust / Test (Ubuntu)
- GitHub Check: test-rust / clippy
🔇 Additional comments (3)
packages/web-platform/web-core-wasm/package.json (3)
11-11: VerifysideEffects: trueis intentional.Setting
sideEffects: truedisables tree-shaking for this package. For WASM modules that require initialization or memory setup, this is typically correct. Confirm this is the intended behavior, as it affects bundle optimization in consuming applications.Based on learnings, WASM packages often need side effects for initialization.
21-32: Files configuration looks good.The publishable files list appropriately includes distribution artifacts (
dist,binary,css), excludes source maps for production, and includes standard metadata files.
33-45: Scripts and browser targets are appropriate.The build script correctly delegates to a custom Node.js script for WASM tooling, and the browserslist targets (Chrome >= 92, Safari >= 16.4) provide good WebAssembly support coverage.
389c63a to
22cb19b
Compare
There was a problem hiding this comment.
Actionable comments posted: 4
♻️ Duplicate comments (4)
packages/web-platform/web-core-wasm/scripts/wasm-bindgen (1)
8-102: Update to wasm-bindgen 0.2.106 by regenerating this manifest.This manifest pins wasm-bindgen to version 0.2.105, which is outdated. To update to 0.2.106, re-run the generation command from line 6 with
--tag 0.2.106:uv run https://gist.githubusercontent.com/colinaaa/090b404e09f6628be90076765b4d455d/raw/dotslash-publish-release.py --config ./scripts/dotslash-config.json --local-config --repo wasm-bindgen/wasm-bindgen --output ./scripts --tag 0.2.106This was previously flagged in past review comments.
packages/web-platform/web-core-wasm/ts/types/IMtsBinding.ts (2)
14-21: Strengthen handler type for better type safety.The
handlerparameter is typed asunknown, which requires type guards before use and weakens type safety across the WASM/JS boundary.This was flagged in a previous review. Consider defining a specific type for the handler (e.g., a function signature or branded type).
33-33: Fix parameter naming inconsistency.The parameter
event_nameuses snake_case, which is inconsistent with TypeScript conventions and the rest of the interface (e.g.,handlerName,parentComponentId).This was flagged in a previous review. Rename to
eventNamefor consistency.packages/web-platform/web-core-wasm/ts/encode/webEncoder.ts (1)
95-97:String(value)may produce unexpected results for nested objects.This issue was flagged in a previous review. When
pageConfigcontains nested objects,String(value)will produce"[object Object]"instead of a meaningful serialization.
🧹 Nitpick comments (11)
packages/web-platform/web-core-wasm/src/template/template_sections/style_info/decoded_style_info.rs (1)
61-273: LGTM! Decode method error handling updated consistently.The
decodemethod signature and error construction have been updated to usewasm_bindgen::JsError, maintaining consistency with the constructor and the broader encode module. The error handling is idiomatic and follows Rust best practices.💡 Optional: Enhance error message with actual selector count
For better debugging, consider including the actual number of selectors found in the error message:
if style_rule.prelude.selector_list.len() != 1 { - return Err(wasm_bindgen::JsError::new( - "KeyFrames rule must have exactly one selector", - )); + return Err(wasm_bindgen::JsError::new(&format!( + "KeyFrames rule must have exactly one selector, found {}", + style_rule.prelude.selector_list.len() + ))); }As per coding guidelines, this change follows the guideline to use
Resulttypes for fallible operations and avoidunwrap()in production code paths.packages/web-platform/web-core-wasm/ts/types/NativeModules.ts (1)
7-11: Consider usingunknowninstead ofanyfor better type safety.The
dataparameter and return type useany, which bypasses TypeScript's type checking. For a public API surface,unknownwould be safer as it forces callers to perform type narrowing before use.🔎 Suggested improvement
export type NativeModulesCall = ( name: string, - data: any, + data: unknown, moduleName: string, -) => Promise<any> | any; +) => Promise<unknown> | unknown;packages/web-platform/web-core-wasm/ts/types/LynxContextEventTarget.ts (2)
14-22: Event type inconsistency betweendispatchEventand listener callbacks.
dispatchEventacceptsContextCrossThreadEvent, butaddEventListener/removeEventListenercallbacks receive the standard DOMEventtype. This creates a type mismatch where the listener won't see thedatafield fromContextCrossThreadEvent.Consider aligning the listener type with the event type being dispatched, or document that listeners receive a wrapped DOM Event.
🔎 Suggested alignment
- addEventListener(type: string, listener: (event: Event) => void): void; - removeEventListener( - type: string, - listener: (event: Event) => void, - ): void; + addEventListener(type: string, listener: (event: ContextCrossThreadEvent | Event) => void): void; + removeEventListener( + type: string, + listener: (event: ContextCrossThreadEvent | Event) => void, + ): void;Alternatively, if this is intentional for DOM compatibility, add a JSDoc comment explaining the design.
15-17: Document thedispatchEventreturn type.The return type
numberdiffers from the standard DOMdispatchEventwhich returnsboolean. Consider adding a JSDoc comment explaining what the number represents (e.g., listener count, status code).packages/web-platform/web-core-wasm/ts/types/EventType.ts (1)
45-51: Dual property naming pattern for backward compatibility.The
ExposureEventDetailtype includes both kebab-case (exposure-id,exposure-scene) and camelCase (exposureID,exposureScene) properties. This appears intentional for compatibility, but consider adding a comment to clarify this design choice for future maintainers.packages/web-platform/web-core-wasm/ts/types/NativeApp.ts (2)
117-143: Inconsistent parameter naming conventions.Several methods use snake_case parameter names (
component_id,first_only,native_props,root_unique_id) which is inconsistent with TypeScript/JavaScript conventions. While this might reflect the underlying native API, consider using camelCase for the TypeScript interface.Example for
setNativeProps:setNativeProps: ( type: IdentifierType, identifier: string, - component_id: string, - first_only: boolean, - native_props: Record<string, unknown>, - root_unique_id: number | undefined, + componentId: string, + firstOnly: boolean, + nativeProps: Record<string, unknown>, + rootUniqueId: number | undefined, ) => void;
56-56: Consider using a more specific type forlynxCoreInject.The
lynxCoreInject: anyproperty bypasses type checking. If the structure is known, define an interface; otherwise, useunknownto require type narrowing before use.packages/web-platform/web-core-wasm/vitest.config.ts (2)
18-21: Consider filtering undefined from plugins array.The conditional
process.env['CI'] ? codspeed() : undefinedleavesundefinedin the plugins array when not in CI. While Vite handles this gracefully, filtering is cleaner.🔎 Suggested improvement
plugins: [ - process.env['CI'] ? codspeed() : undefined, wasm(), - ], + ...(process.env['CI'] ? [codspeed()] : []), + ],Or alternatively:
plugins: [ wasm(), process.env['CI'] && codspeed(), ].filter(Boolean),
10-12: Minor: Test name inconsistency with package name.The test name
'web-platform/web-core-tests'differs from the package directoryweb-core-wasm. Consider using'web-platform/web-core-wasm'for consistency.packages/web-platform/web-core-wasm/ts/types/WorkerStartMessage.ts (1)
11-11: Consider stricter typing forsystemInfo.Using
Record<string, any>bypasses type safety. If the structure is truly unknown at compile time, considerRecord<string, unknown>which requires explicit type narrowing before use, or define a more specificSystemInfotype if the structure is known.🔎 Suggested improvement
- systemInfo?: Record<string, any>; + systemInfo?: Record<string, unknown>;packages/web-platform/web-core-wasm/ts/encode/webEncoder.ts (1)
164-166: Consider adding a debug assertion for buffer bounds.Adding a sanity check that
offset === bufferLengthafter writing all sections would catch any calculation mismatches during development.🔎 Proposed addition
buffer.set(encodedManifest, offset); offset += encodedManifest.length; + if (offset !== bufferLength) { + throw new Error(`Buffer size mismatch: expected ${bufferLength}, got ${offset}`); + } + return buffer; }
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (2)
packages/web-platform/web-core-wasm/tests/__snapshots__/encode.spec.ts.snapis excluded by!**/*.snappnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (49)
.dprint.jsoncpackages/web-platform/tsconfig.jsonpackages/web-platform/web-core-wasm/.gitignorepackages/web-platform/web-core-wasm/AGENTS.mdpackages/web-platform/web-core-wasm/binary/client/client.d.tspackages/web-platform/web-core-wasm/binary/client/client_bg.wasm.d.tspackages/web-platform/web-core-wasm/binary/client/client_debug.d.tspackages/web-platform/web-core-wasm/binary/client/client_debug_bg.wasm.d.tspackages/web-platform/web-core-wasm/binary/encode/encode.d.tspackages/web-platform/web-core-wasm/binary/encode/encode_bg.wasm.d.tspackages/web-platform/web-core-wasm/binary/encode/encode_debug.d.tspackages/web-platform/web-core-wasm/binary/encode/encode_debug_bg.wasm.d.tspackages/web-platform/web-core-wasm/package.jsonpackages/web-platform/web-core-wasm/scripts/build.jspackages/web-platform/web-core-wasm/scripts/dotslash-config.jsonpackages/web-platform/web-core-wasm/scripts/wasm-bindgenpackages/web-platform/web-core-wasm/src/template/template_sections/style_info/decoded_style_info.rspackages/web-platform/web-core-wasm/tests/encode.spec.tspackages/web-platform/web-core-wasm/tests/jsdom.tspackages/web-platform/web-core-wasm/ts/client/wasm.tspackages/web-platform/web-core-wasm/ts/constants.tspackages/web-platform/web-core-wasm/ts/encode/encodeCSS.tspackages/web-platform/web-core-wasm/ts/encode/encodeElementTemplate.tspackages/web-platform/web-core-wasm/ts/encode/index.tspackages/web-platform/web-core-wasm/ts/encode/webEncoder.tspackages/web-platform/web-core-wasm/ts/types/BTSChunk.tspackages/web-platform/web-core-wasm/ts/types/Cloneable.tspackages/web-platform/web-core-wasm/ts/types/Element.tspackages/web-platform/web-core-wasm/ts/types/ElementTemplateData.tspackages/web-platform/web-core-wasm/ts/types/EventType.tspackages/web-platform/web-core-wasm/ts/types/I18nTypes.tspackages/web-platform/web-core-wasm/ts/types/IElementPAPI.tspackages/web-platform/web-core-wasm/ts/types/IMtsBinding.tspackages/web-platform/web-core-wasm/ts/types/JSRealm.tspackages/web-platform/web-core-wasm/ts/types/LynxContextEventTarget.tspackages/web-platform/web-core-wasm/ts/types/MainThreadLynx.tspackages/web-platform/web-core-wasm/ts/types/NapiModules.tspackages/web-platform/web-core-wasm/ts/types/NativeApp.tspackages/web-platform/web-core-wasm/ts/types/NativeModules.tspackages/web-platform/web-core-wasm/ts/types/PageConfig.tspackages/web-platform/web-core-wasm/ts/types/ProcessDataCallback.tspackages/web-platform/web-core-wasm/ts/types/TimingAPIs.tspackages/web-platform/web-core-wasm/ts/types/UpdateDataOptions.tspackages/web-platform/web-core-wasm/ts/types/WorkerStartMessage.tspackages/web-platform/web-core-wasm/ts/types/index.tspackages/web-platform/web-core-wasm/tsconfig.jsonpackages/web-platform/web-core-wasm/turbo.jsonpackages/web-platform/web-core-wasm/vitest.config.tspackages/web-platform/web-mainthread-apis/.gitignore
🚧 Files skipped from review as they are similar to previous changes (25)
- packages/web-platform/web-core-wasm/tsconfig.json
- packages/web-platform/web-core-wasm/ts/encode/encodeElementTemplate.ts
- packages/web-platform/web-core-wasm/ts/types/NapiModules.ts
- packages/web-platform/web-core-wasm/ts/encode/index.ts
- packages/web-platform/web-core-wasm/ts/types/ElementTemplateData.ts
- packages/web-platform/web-core-wasm/package.json
- packages/web-platform/web-core-wasm/ts/types/ProcessDataCallback.ts
- packages/web-platform/web-core-wasm/ts/types/PageConfig.ts
- packages/web-platform/web-core-wasm/ts/types/I18nTypes.ts
- packages/web-platform/web-core-wasm/ts/types/Element.ts
- packages/web-platform/web-core-wasm/ts/client/wasm.ts
- packages/web-platform/web-core-wasm/ts/types/JSRealm.ts
- packages/web-platform/web-core-wasm/tests/encode.spec.ts
- packages/web-platform/web-core-wasm/scripts/build.js
- .dprint.jsonc
- packages/web-platform/web-core-wasm/ts/types/TimingAPIs.ts
- packages/web-platform/web-core-wasm/ts/constants.ts
- packages/web-platform/web-core-wasm/ts/types/index.ts
- packages/web-platform/web-core-wasm/ts/types/BTSChunk.ts
- packages/web-platform/web-core-wasm/binary/client/client.d.ts
- packages/web-platform/web-core-wasm/binary/encode/encode_debug.d.ts
- packages/web-platform/web-core-wasm/ts/types/IElementPAPI.ts
- packages/web-platform/web-core-wasm/binary/encode/encode.d.ts
- packages/web-platform/web-core-wasm/binary/encode/encode_debug_bg.wasm.d.ts
- packages/web-platform/web-core-wasm/turbo.json
🧰 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-core-wasm/ts/types/UpdateDataOptions.tspackages/web-platform/web-core-wasm/ts/types/NativeModules.tspackages/web-platform/web-core-wasm/tests/jsdom.tspackages/web-platform/web-core-wasm/ts/encode/encodeCSS.tspackages/web-platform/web-core-wasm/vitest.config.tspackages/web-platform/web-core-wasm/ts/types/LynxContextEventTarget.tspackages/web-platform/web-core-wasm/ts/types/Cloneable.tspackages/web-platform/web-core-wasm/ts/types/EventType.tspackages/web-platform/web-core-wasm/ts/types/WorkerStartMessage.tspackages/web-platform/web-core-wasm/ts/types/NativeApp.tspackages/web-platform/web-core-wasm/binary/client/client_debug.d.tspackages/web-platform/web-core-wasm/ts/encode/webEncoder.tspackages/web-platform/web-core-wasm/ts/types/MainThreadLynx.tspackages/web-platform/web-core-wasm/ts/types/IMtsBinding.tspackages/web-platform/web-core-wasm/binary/client/client_bg.wasm.d.tspackages/web-platform/web-core-wasm/binary/encode/encode_bg.wasm.d.tspackages/web-platform/web-core-wasm/binary/client/client_debug_bg.wasm.d.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-core-wasm/ts/types/UpdateDataOptions.tspackages/web-platform/web-core-wasm/ts/types/NativeModules.tspackages/web-platform/web-core-wasm/tests/jsdom.tspackages/web-platform/web-core-wasm/ts/encode/encodeCSS.tspackages/web-platform/web-core-wasm/vitest.config.tspackages/web-platform/web-core-wasm/ts/types/LynxContextEventTarget.tspackages/web-platform/web-core-wasm/ts/types/Cloneable.tspackages/web-platform/web-core-wasm/ts/types/EventType.tspackages/web-platform/web-core-wasm/ts/types/WorkerStartMessage.tspackages/web-platform/web-core-wasm/ts/types/NativeApp.tspackages/web-platform/web-core-wasm/binary/client/client_debug.d.tspackages/web-platform/web-core-wasm/ts/encode/webEncoder.tspackages/web-platform/web-core-wasm/ts/types/MainThreadLynx.tspackages/web-platform/web-core-wasm/ts/types/IMtsBinding.tspackages/web-platform/web-core-wasm/binary/client/client_bg.wasm.d.tspackages/web-platform/web-core-wasm/binary/encode/encode_bg.wasm.d.tspackages/web-platform/web-core-wasm/binary/client/client_debug_bg.wasm.d.ts
packages/**/*.rs
📄 CodeRabbit inference engine (AGENTS.md)
packages/**/*.rs: Implement native bindings tests using cargo test in Rust packages
Include Rust compilation targets (wasm32-unknown-unknown) for packages requiring native bindings
Files:
packages/web-platform/web-core-wasm/src/template/template_sections/style_info/decoded_style_info.rs
packages/web-platform/web-core-wasm/**/*.rs
📄 CodeRabbit inference engine (packages/web-platform/web-core-wasm/AGENTS.md)
packages/web-platform/web-core-wasm/**/*.rs: Ensure that all public structs, enums, and functions have clear documentation comments (///). Comments must accurately reflect the logic.
Verify that the implementation matches the comments and the intended behavior.
Use idiomatic Rust patterns. PreferOption::map,Result::and_then, iterators, and pattern matching over imperative code where appropriate.
UseResulttypes for fallible operations. Avoidunwrap()in production code paths; prefer?operator or explicit error handling.
Runcargo test --all-featuresto execute unit tests. Tests are co-located with the source code using#[cfg(test)].
All new features and bug fixes must be accompanied by unit tests.
Use descriptive test names that explain what is being tested (e.g.,test_transform_rpx_case_insensitive).
Ensure that tests cover edge cases and verify the correctness of the logic.
Use#[cfg(feature = "...")]to conditionally compile code based on features (client,encode,server).
When adding new functionality, carefully consider which feature flag it belongs to (client,encode, orserver).
Minimize allocations in hot paths. UseString::with_capacity()when the size is known, reuse buffers where possible.
Minimize crossing the WASM/JS boundary. Batch operations where possible.
Check if the comments in the code need to be updated to reflect your changes.
Files:
packages/web-platform/web-core-wasm/src/template/template_sections/style_info/decoded_style_info.rs
packages/web-platform/web-core-wasm/**/AGENTS.md
📄 CodeRabbit inference engine (packages/web-platform/web-core-wasm/AGENTS.md)
Check if
AGENTS.mdneeds to be updated to reflect your changes (e.g., new feature flags, structural changes, new dependencies).
Files:
packages/web-platform/web-core-wasm/AGENTS.md
🧠 Learnings (51)
📓 Common learnings
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 : When adding new functionality, carefully consider which feature flag it belongs to (`client`, `encode`, or `server`).
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.
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.
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.
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 : Minimize crossing the WASM/JS boundary. Batch operations where possible.
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 `#[cfg(feature = "...")]` to conditionally compile code based on features (`client`, `encode`, `server`).
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)]`.
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: AGENTS.md:0-0
Timestamp: 2025-12-26T05:10:01.595Z
Learning: Applies to packages/**/*.rs : Include Rust compilation targets (wasm32-unknown-unknown) for packages requiring native bindings
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 idiomatic Rust patterns. Prefer `Option::map`, `Result::and_then`, iterators, and pattern matching over imperative code where appropriate.
📚 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-core-wasm/ts/types/UpdateDataOptions.tspackages/web-platform/web-core-wasm/binary/client/client_debug.d.tspackages/web-platform/web-core-wasm/ts/types/MainThreadLynx.tspackages/web-platform/web-core-wasm/ts/types/IMtsBinding.tspackages/web-platform/web-core-wasm/binary/client/client_bg.wasm.d.tspackages/web-platform/web-core-wasm/binary/client/client_debug_bg.wasm.d.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-wasm/ts/types/UpdateDataOptions.tspackages/web-platform/web-core-wasm/ts/types/LynxContextEventTarget.tspackages/web-platform/web-core-wasm/ts/types/MainThreadLynx.tspackages/web-platform/web-core-wasm/ts/types/IMtsBinding.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-core-wasm/scripts/dotslash-config.jsonpackages/web-platform/web-core-wasm/ts/types/NativeModules.tspackages/web-platform/web-core-wasm/src/template/template_sections/style_info/decoded_style_info.rspackages/web-platform/web-core-wasm/.gitignorepackages/web-platform/web-core-wasm/AGENTS.mdpackages/web-platform/tsconfig.jsonpackages/web-platform/web-core-wasm/tests/jsdom.tspackages/web-platform/web-core-wasm/ts/encode/encodeCSS.tspackages/web-platform/web-core-wasm/vitest.config.tspackages/web-platform/web-core-wasm/scripts/wasm-bindgenpackages/web-platform/web-core-wasm/binary/client/client_debug.d.tspackages/web-platform/web-core-wasm/ts/encode/webEncoder.tspackages/web-platform/web-core-wasm/ts/types/MainThreadLynx.tspackages/web-platform/web-core-wasm/ts/types/IMtsBinding.tspackages/web-platform/web-core-wasm/binary/client/client_bg.wasm.d.tspackages/web-platform/web-core-wasm/binary/encode/encode_bg.wasm.d.tspackages/web-platform/web-core-wasm/binary/client/client_debug_bg.wasm.d.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-core-wasm/scripts/dotslash-config.jsonpackages/web-platform/web-core-wasm/.gitignorepackages/web-platform/web-core-wasm/AGENTS.mdpackages/web-platform/tsconfig.jsonpackages/web-platform/web-core-wasm/tests/jsdom.tspackages/web-platform/web-core-wasm/vitest.config.tspackages/web-platform/web-core-wasm/ts/types/LynxContextEventTarget.tspackages/web-platform/web-core-wasm/scripts/wasm-bindgenpackages/web-platform/web-core-wasm/ts/types/EventType.tspackages/web-platform/web-core-wasm/binary/client/client_debug.d.tspackages/web-platform/web-core-wasm/ts/types/MainThreadLynx.tspackages/web-platform/web-core-wasm/binary/client/client_bg.wasm.d.tspackages/web-platform/web-core-wasm/binary/encode/encode_bg.wasm.d.tspackages/web-platform/web-core-wasm/binary/client/client_debug_bg.wasm.d.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 : When adding new functionality, carefully consider which feature flag it belongs to (`client`, `encode`, or `server`).
Applied to files:
packages/web-platform/web-core-wasm/scripts/dotslash-config.jsonpackages/web-platform/web-core-wasm/src/template/template_sections/style_info/decoded_style_info.rspackages/web-platform/web-core-wasm/.gitignorepackages/web-platform/web-core-wasm/AGENTS.mdpackages/web-platform/tsconfig.jsonpackages/web-platform/web-core-wasm/ts/encode/encodeCSS.tspackages/web-platform/web-core-wasm/scripts/wasm-bindgenpackages/web-platform/web-core-wasm/binary/client/client_debug.d.tspackages/web-platform/web-core-wasm/ts/encode/webEncoder.tspackages/web-platform/web-core-wasm/ts/types/IMtsBinding.tspackages/web-platform/web-core-wasm/binary/client/client_bg.wasm.d.tspackages/web-platform/web-core-wasm/binary/encode/encode_bg.wasm.d.tspackages/web-platform/web-core-wasm/binary/client/client_debug_bg.wasm.d.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 : Minimize crossing the WASM/JS boundary. Batch operations where possible.
Applied to files:
packages/web-platform/web-core-wasm/scripts/dotslash-config.jsonpackages/web-platform/web-core-wasm/src/template/template_sections/style_info/decoded_style_info.rspackages/web-platform/web-core-wasm/.gitignorepackages/web-platform/web-core-wasm/AGENTS.mdpackages/web-platform/web-core-wasm/tests/jsdom.tspackages/web-platform/web-core-wasm/ts/encode/encodeCSS.tspackages/web-platform/web-core-wasm/scripts/wasm-bindgenpackages/web-platform/web-core-wasm/binary/client/client_debug.d.tspackages/web-platform/web-core-wasm/ts/encode/webEncoder.tspackages/web-platform/web-core-wasm/ts/types/IMtsBinding.tspackages/web-platform/web-core-wasm/binary/client/client_bg.wasm.d.tspackages/web-platform/web-core-wasm/binary/encode/encode_bg.wasm.d.tspackages/web-platform/web-core-wasm/binary/client/client_debug_bg.wasm.d.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 : Ensure that tests cover edge cases and verify the correctness of the logic.
Applied to files:
packages/web-platform/web-core-wasm/scripts/dotslash-config.jsonpackages/web-platform/web-core-wasm/src/template/template_sections/style_info/decoded_style_info.rspackages/web-platform/web-core-wasm/.gitignorepackages/web-platform/web-core-wasm/AGENTS.mdpackages/web-platform/tsconfig.jsonpackages/web-platform/web-core-wasm/tests/jsdom.tspackages/web-platform/web-core-wasm/ts/encode/encodeCSS.tspackages/web-platform/web-core-wasm/scripts/wasm-bindgenpackages/web-platform/web-core-wasm/ts/encode/webEncoder.tspackages/web-platform/web-core-wasm/ts/types/IMtsBinding.tspackages/web-platform/web-core-wasm/binary/client/client_bg.wasm.d.tspackages/web-platform/web-core-wasm/binary/encode/encode_bg.wasm.d.tspackages/web-platform/web-core-wasm/binary/client/client_debug_bg.wasm.d.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-core-wasm/scripts/dotslash-config.jsonpackages/web-platform/web-core-wasm/src/template/template_sections/style_info/decoded_style_info.rspackages/web-platform/web-core-wasm/.gitignorepackages/web-platform/web-core-wasm/AGENTS.mdpackages/web-platform/tsconfig.jsonpackages/web-platform/web-core-wasm/tests/jsdom.tspackages/web-platform/web-core-wasm/ts/encode/encodeCSS.tspackages/web-platform/web-core-wasm/scripts/wasm-bindgenpackages/web-platform/web-core-wasm/binary/client/client_debug.d.tspackages/web-platform/web-core-wasm/ts/encode/webEncoder.tspackages/web-platform/web-core-wasm/ts/types/IMtsBinding.tspackages/web-platform/web-core-wasm/binary/client/client_bg.wasm.d.tspackages/web-platform/web-core-wasm/binary/encode/encode_bg.wasm.d.tspackages/web-platform/web-core-wasm/binary/client/client_debug_bg.wasm.d.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 : All new features and bug fixes must be accompanied by unit tests.
Applied to files:
packages/web-platform/web-core-wasm/scripts/dotslash-config.jsonpackages/web-platform/web-core-wasm/.gitignorepackages/web-platform/web-core-wasm/AGENTS.mdpackages/web-platform/tsconfig.jsonpackages/web-platform/web-core-wasm/tests/jsdom.tspackages/web-platform/web-core-wasm/vitest.config.tspackages/web-platform/web-core-wasm/scripts/wasm-bindgenpackages/web-platform/web-core-wasm/binary/client/client_debug.d.tspackages/web-platform/web-core-wasm/ts/encode/webEncoder.tspackages/web-platform/web-core-wasm/binary/client/client_bg.wasm.d.tspackages/web-platform/web-core-wasm/binary/encode/encode_bg.wasm.d.tspackages/web-platform/web-core-wasm/binary/client/client_debug_bg.wasm.d.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-core-wasm/scripts/dotslash-config.jsonpackages/web-platform/web-core-wasm/ts/types/NativeModules.tspackages/web-platform/tsconfig.jsonpackages/web-platform/web-core-wasm/vitest.config.tspackages/web-platform/web-core-wasm/ts/types/EventType.tspackages/web-platform/web-core-wasm/ts/types/NativeApp.tspackages/web-platform/web-core-wasm/ts/encode/webEncoder.tspackages/web-platform/web-core-wasm/binary/encode/encode_bg.wasm.d.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 : Ensure that all public structs, enums, and functions have clear documentation comments (`///`). Comments must accurately reflect the logic.
Applied to files:
packages/web-platform/web-core-wasm/scripts/dotslash-config.jsonpackages/web-platform/web-core-wasm/src/template/template_sections/style_info/decoded_style_info.rspackages/web-platform/web-core-wasm/.gitignorepackages/web-platform/web-core-wasm/AGENTS.mdpackages/web-platform/web-core-wasm/scripts/wasm-bindgenpackages/web-platform/web-core-wasm/binary/client/client_debug.d.tspackages/web-platform/web-core-wasm/ts/encode/webEncoder.tspackages/web-platform/web-core-wasm/binary/client/client_bg.wasm.d.tspackages/web-platform/web-core-wasm/binary/encode/encode_bg.wasm.d.tspackages/web-platform/web-core-wasm/binary/client/client_debug_bg.wasm.d.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 : Use descriptive test names that explain what is being tested (e.g., `test_transform_rpx_case_insensitive`).
Applied to files:
packages/web-platform/web-core-wasm/scripts/dotslash-config.jsonpackages/web-platform/web-core-wasm/.gitignorepackages/web-platform/web-core-wasm/AGENTS.mdpackages/web-platform/web-core-wasm/tests/jsdom.tspackages/web-platform/web-core-wasm/vitest.config.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 packages/**/*.rs : Include Rust compilation targets (wasm32-unknown-unknown) for packages requiring native bindings
Applied to files:
packages/web-platform/web-core-wasm/scripts/dotslash-config.jsonpackages/web-platform/web-core-wasm/AGENTS.mdpackages/web-platform/tsconfig.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-core-wasm/ts/types/NativeModules.tspackages/web-platform/web-core-wasm/ts/types/NativeApp.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 : Use `Result` types for fallible operations. Avoid `unwrap()` in production code paths; prefer `?` operator or explicit error handling.
Applied to files:
packages/web-platform/web-core-wasm/src/template/template_sections/style_info/decoded_style_info.rspackages/web-platform/web-core-wasm/scripts/wasm-bindgenpackages/web-platform/web-core-wasm/ts/types/IMtsBinding.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 : Use idiomatic Rust patterns. Prefer `Option::map`, `Result::and_then`, iterators, and pattern matching over imperative code where appropriate.
Applied to files:
packages/web-platform/web-core-wasm/src/template/template_sections/style_info/decoded_style_info.rspackages/web-platform/web-core-wasm/AGENTS.mdpackages/web-platform/web-core-wasm/scripts/wasm-bindgen
📚 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 `#[cfg(feature = "...")]` to conditionally compile code based on features (`client`, `encode`, `server`).
Applied to files:
packages/web-platform/web-core-wasm/src/template/template_sections/style_info/decoded_style_info.rspackages/web-platform/web-core-wasm/AGENTS.mdpackages/web-platform/tsconfig.json
📚 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 : Minimize allocations in hot paths. Use `String::with_capacity()` when the size is known, reuse buffers where possible.
Applied to files:
packages/web-platform/web-core-wasm/src/template/template_sections/style_info/decoded_style_info.rspackages/web-platform/web-core-wasm/scripts/wasm-bindgen
📚 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-core-wasm/.gitignorepackages/web-platform/tsconfig.json
📚 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} : Place test files in __test__/ directories adjacent to source files
Applied to files:
packages/web-platform/web-core-wasm/.gitignore
📚 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 **/*.{ts,tsx} : Use TypeScript in strict mode with the configuration specified in tsconfig.json
Applied to files:
packages/web-platform/web-core-wasm/.gitignorepackages/web-platform/tsconfig.json
📚 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-core-wasm/.gitignorepackages/web-platform/tsconfig.jsonpackages/web-platform/web-core-wasm/vitest.config.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 **/*.{js,ts,tsx} : Follow code formatting rules specified in .dprint.jsonc and biome.jsonc
Applied to files:
packages/web-platform/web-core-wasm/.gitignorepackages/web-platform/tsconfig.json
📚 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/rspeedy/plugin-*/**/*.{ts,tsx,js} : Configure build plugins using the plugin architecture in packages/rspeedy/plugin-*/
Applied to files:
packages/web-platform/web-core-wasm/.gitignorepackages/web-platform/tsconfig.jsonpackages/web-platform/web-core-wasm/vitest.config.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 **/*.{js,ts,tsx} : Follow eslint rules as configured in eslint.config.js including React and TypeScript specific rules
Applied to files:
packages/web-platform/web-core-wasm/.gitignore
📚 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-core-wasm/AGENTS.mdpackages/web-platform/tsconfig.jsonpackages/web-platform/web-core-wasm/tests/jsdom.tspackages/web-platform/web-core-wasm/vitest.config.tspackages/web-platform/web-core-wasm/scripts/wasm-bindgen
📚 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-core-wasm/AGENTS.mdpackages/web-platform/web-core-wasm/ts/encode/encodeCSS.tspackages/web-platform/web-core-wasm/ts/types/LynxContextEventTarget.tspackages/web-platform/web-core-wasm/ts/types/MainThreadLynx.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 packages/react/transform/**/*.rs : Implement custom Rust-based JSX transforms in packages/react/transform/
Applied to files:
packages/web-platform/web-core-wasm/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/tsconfig.jsonpackages/web-platform/web-core-wasm/binary/client/client_bg.wasm.d.tspackages/web-platform/web-core-wasm/binary/client/client_debug_bg.wasm.d.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/tsconfig.jsonpackages/web-platform/web-core-wasm/binary/client/client_debug.d.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 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/tsconfig.jsonpackages/web-platform/web-core-wasm/tests/jsdom.tspackages/web-platform/web-core-wasm/vitest.config.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-core-wasm/tests/jsdom.tspackages/web-platform/web-core-wasm/vitest.config.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-core-wasm/tests/jsdom.tspackages/web-platform/web-core-wasm/vitest.config.ts
📚 Learning: 2025-08-27T11:37:38.587Z
Learnt from: PupilTong
Repo: lynx-family/lynx-stack PR: 1589
File: packages/web-platform/web-worker-runtime/src/mainThread/startMainThread.ts:36-49
Timestamp: 2025-08-27T11:37:38.587Z
Learning: In web worker script loading (loadScript function), the pattern of calling fetch() before importScripts() is intentional for caching benefits, not redundant networking. The fetch() ensures HTTP caching is utilized before the synchronous importScripts() call.
Applied to files:
packages/web-platform/web-core-wasm/tests/jsdom.ts
📚 Learning: 2025-08-11T05:57:18.212Z
Learnt from: upupming
Repo: lynx-family/lynx-stack PR: 1305
File: packages/testing-library/testing-environment/src/index.ts:255-258
Timestamp: 2025-08-11T05:57:18.212Z
Learning: In the ReactLynx testing environment (`packages/testing-library/testing-environment/src/index.ts`), the dual assignment pattern `target.console.method = console.method = () => {}` is required for rstest compatibility. This is because rstest provides `console` in an IIFE (Immediately Invoked Function Expression), and both the target and global console need to have these methods defined for proper test execution.
Applied to files:
packages/web-platform/web-core-wasm/tests/jsdom.tspackages/web-platform/web-core-wasm/ts/types/LynxContextEventTarget.tspackages/web-platform/web-core-wasm/ts/types/MainThreadLynx.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-core-wasm/ts/encode/encodeCSS.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/**/*.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-core-wasm/ts/encode/encodeCSS.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/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-core-wasm/vitest.config.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-core-wasm/vitest.config.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-core-wasm/ts/types/LynxContextEventTarget.tspackages/web-platform/web-core-wasm/ts/types/EventType.tspackages/web-platform/web-core-wasm/binary/client/client_debug.d.tspackages/web-platform/web-core-wasm/ts/encode/webEncoder.tspackages/web-platform/web-core-wasm/binary/encode/encode_bg.wasm.d.tspackages/web-platform/web-core-wasm/binary/client/client_debug_bg.wasm.d.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-wasm/ts/types/LynxContextEventTarget.tspackages/web-platform/web-core-wasm/ts/types/EventType.tspackages/web-platform/web-core-wasm/ts/types/NativeApp.tspackages/web-platform/web-core-wasm/ts/types/MainThreadLynx.ts
📚 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-core-wasm/scripts/wasm-bindgen
📚 Learning: 2025-08-19T12:49:38.940Z
Learnt from: upupming
Repo: lynx-family/lynx-stack PR: 1370
File: packages/webpack/template-webpack-plugin/src/LynxCacheEventsSetupListRuntimeModule.ts:110-112
Timestamp: 2025-08-19T12:49:38.940Z
Learning: The GlobalEventEmitter API in the Lynx framework is designed to pass arguments as an array (single parameter) rather than spreading individual arguments. When replaying cached events with emitter.emit(listenerKey, action.data.args), the args array should be passed as-is, not spread with the spread operator.
Applied to files:
packages/web-platform/web-core-wasm/ts/types/EventType.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-wasm/ts/types/EventType.tspackages/web-platform/web-core-wasm/ts/types/NativeApp.tspackages/web-platform/web-core-wasm/ts/types/MainThreadLynx.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-core-wasm/ts/types/NativeApp.tspackages/web-platform/web-core-wasm/ts/types/MainThreadLynx.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-wasm/ts/types/MainThreadLynx.tspackages/web-platform/web-core-wasm/ts/types/IMtsBinding.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-core-wasm/ts/types/MainThreadLynx.ts
📚 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-core-wasm/ts/types/IMtsBinding.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 : Use PascalCase for class names (e.g., `MyElement`)
Applied to files:
packages/web-platform/web-core-wasm/ts/types/IMtsBinding.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-core-wasm/ts/types/IMtsBinding.ts
🧬 Code graph analysis (10)
packages/web-platform/web-core-wasm/src/template/template_sections/style_info/decoded_style_info.rs (1)
packages/web-platform/web-core-wasm/src/template/template_sections/style_info/mod.rs (1)
new(48-55)
packages/web-platform/web-core-wasm/tests/jsdom.ts (1)
packages/rspeedy/core/register/index.js (1)
MessageChannel(27-27)
packages/web-platform/web-core-wasm/ts/encode/encodeCSS.ts (2)
packages/web-platform/web-core-wasm/binary/encode/encode.d.ts (4)
RawStyleInfo(55-84)Rule(85-117)RulePrelude(127-138)Selector(139-151)packages/web-platform/web-core-wasm/binary/encode/encode_debug.d.ts (4)
RawStyleInfo(55-84)Rule(85-117)RulePrelude(127-138)Selector(139-151)
packages/web-platform/web-core-wasm/vitest.config.ts (1)
packages/web-platform/web-core-wasm/scripts/build.js (1)
__dirname(6-6)
packages/web-platform/web-core-wasm/ts/types/LynxContextEventTarget.ts (2)
packages/web-platform/web-core-wasm/ts/types/Cloneable.ts (1)
Cloneable(4-8)packages/react/worklet-runtime/src/types/runtimeProxy.d.ts (1)
Event(7-11)
packages/web-platform/web-core-wasm/ts/types/EventType.ts (1)
packages/web-platform/web-core-wasm/ts/types/Cloneable.ts (1)
Cloneable(4-8)
packages/web-platform/web-core-wasm/ts/types/WorkerStartMessage.ts (3)
packages/web-platform/web-core-wasm/ts/types/Cloneable.ts (1)
Cloneable(4-8)packages/web-platform/web-core-wasm/ts/types/NativeModules.ts (1)
NativeModulesMap(5-5)packages/web-platform/web-core-wasm/ts/types/NapiModules.ts (1)
NapiModulesMap(7-7)
packages/web-platform/web-core-wasm/binary/client/client_debug.d.ts (1)
packages/web-platform/web-core-wasm/binary/client/client.d.ts (4)
DecodedStyleData(3-11)ElementTemplateSection(12-17)EventInfo(23-30)MainThreadWasmContext(31-72)
packages/web-platform/web-core-wasm/ts/encode/webEncoder.ts (4)
packages/web-platform/web-core-wasm/ts/types/ElementTemplateData.ts (1)
ElementTemplateData(9-18)packages/web-platform/web-core-wasm/ts/encode/encodeCSS.ts (1)
encodeCSS(12-144)packages/web-platform/web-core-wasm/ts/encode/encodeElementTemplate.ts (1)
encodeElementTemplates(13-84)packages/web-platform/web-core-wasm/ts/constants.ts (2)
MagicHeader(55-55)TemplateSectionLabel(57-64)
packages/web-platform/web-core-wasm/ts/types/IMtsBinding.ts (2)
packages/web-platform/web-core-wasm/ts/types/EventType.ts (1)
LynxCrossThreadEvent(21-32)packages/web-platform/web-core-wasm/ts/types/Cloneable.ts (1)
CloneableObject(10-14)
22cb19b to
ef40bd4
Compare
There was a problem hiding this comment.
Actionable comments posted: 4
♻️ Duplicate comments (6)
packages/web-platform/web-core-wasm/ts/encode/webEncoder.ts (2)
12-19: UTF-16 encoding with host-dependent byte order.This
encodeAsJSONhelper usescharCodeAt()which produces host-endian UTF-16 bytes. This will cause cross-platform decode failures between little-endian and big-endian systems.🔎 Proposed fix using TextEncoder for consistent UTF-8
function encodeAsJSON(map: Record<string, unknown>): Uint8Array { const jsonString = JSON.stringify(map); - const utf16Array = new Uint16Array(jsonString.length); - for (let i = 0; i < jsonString.length; i++) { - utf16Array[i] = jsonString.charCodeAt(i); - } - return new Uint8Array(utf16Array.buffer); + return new TextEncoder().encode(jsonString); }If UTF-16LE is required by the decoder, use explicit little-endian writes:
function encodeAsJSON(map: Record<string, unknown>): Uint8Array { const jsonString = JSON.stringify(map); + const buffer = new Uint8Array(jsonString.length * 2); + const view = new DataView(buffer.buffer); + for (let i = 0; i < jsonString.length; i++) { + view.setUint16(i * 2, jsonString.charCodeAt(i), true); // true = little-endian + } + return buffer; - const utf16Array = new Uint16Array(jsonString.length); - for (let i = 0; i < jsonString.length; i++) { - utf16Array[i] = jsonString.charCodeAt(i); - } - return new Uint8Array(utf16Array.buffer); }
95-97:String(value)produces"[object Object]"for nested objects.When
pageConfigcontains nested objects or arrays,String(value)will not serialize them meaningfully.🔎 Proposed fix
for (const [key, value] of Object.entries(pageConfig)) { - configMap[key] = String(value); + configMap[key] = typeof value === 'object' && value !== null + ? JSON.stringify(value) + : String(value); }packages/web-platform/web-core-wasm/ts/types/IMtsBinding.ts (2)
14-21: Handler type remainsunknown.The
handlerparameter is typed asunknown, which weakens type safety for worklet invocations. This was previously flagged - consider defining a more specific type (e.g.,(...args: unknown[]) => void | Promise<void>) to improve compile-time safety at the WASM/JS boundary.
33-33: Parameter uses snake_case instead of camelCase.The parameter
event_nameshould follow TypeScript/JavaScript camelCase conventions (eventName) to be consistent with other parameters in this interface likehandlerName,parentComponentId, etc.packages/web-platform/web-core-wasm/ts/types/IElementPAPI.ts (2)
203-212:Exclude<string, 'update-list-info'>doesn't provide intended type narrowing.
Excludeoperates on union types, not string literals within the basestringtype. This still resolves tostringand won't prevent'update-list-info'from being passed. The intersection on line 376 may not provide the expected overload behavior.
354-359: Duplicate config getters without documentation.Both
__GetElementConfig(line 354) and__GetConfig(line 359) have the same type. If this is for backward compatibility or aliasing, a comment explaining the rationale would help maintainability.
🧹 Nitpick comments (10)
packages/web-platform/web-core-wasm/vitest.config.ts (3)
10-17: Consider aligning the test name with the package name.The test name is set to
'web-platform/web-core-tests', but the package isweb-core-wasm. This inconsistency could cause confusion when viewing test results or logs.🔎 Suggested fix for naming consistency
test: { - name: 'web-platform/web-core-tests', + name: 'web-platform/web-core-wasm', include: ['**/tests/*.spec.ts'], exclude: ['**/tests/*.bench.spec.ts'], benchmark: { include: ['**/tests/*.bench.spec.ts'], }, },
18-21: Consider filtering the plugins array for better clarity.While Vitest automatically filters out falsy values from the plugins array, explicitly filtering would make the intent clearer.
🔎 Suggested refactor for clarity
- plugins: [ - process.env['CI'] ? codspeed() : undefined, - wasm(), - ], + plugins: [ + ...(process.env['CI'] ? [codspeed()] : []), + wasm(), + ],Or alternatively:
- plugins: [ - process.env['CI'] ? codspeed() : undefined, - wasm(), - ], + plugins: [ + process.env['CI'] && codspeed(), + wasm(), + ].filter(Boolean),
22-31: Add documentation explaining the debug build alias.The alias redirecting
client.jstoclient_debug.jsduring testing lacks explanation. Add a comment tovitest.config.tsclarifying why the debug build is used for tests (e.g., for better error messages, stack traces, or specific testing scenarios). If this pattern is intentional and important to the testing strategy, consider documenting it inAGENTS.mdunder a testing section.packages/web-platform/web-core-wasm/src/template/template_sections/style_info/decoded_style_info.rs (1)
36-59: Error type change improves explicitness.The updated return type using
wasm_bindgen::JsErroraligns with the pattern used in other parts of the module and improves clarity about the error type's origin.However, consider adding documentation comments to explain this
pub(crate)method's purpose, parameters, and error conditions:📝 Suggested documentation
+ /// Creates a new StyleInfoDecoder from raw style information. + /// + /// # Arguments + /// * `raw_style_info` - The raw style information to decode + /// * `entry_name` - Optional entry name for CSS scoping + /// * `config_enable_css_selector` - Whether to enable CSS selector processing + /// + /// # Errors + /// Returns `wasm_bindgen::JsError` if decoding fails pub(crate) fn new( raw_style_info: RawStyleInfo, entry_name: Option<String>, config_enable_css_selector: bool, ) -> Result<Self, wasm_bindgen::JsError> {As per coding guidelines, clear documentation improves maintainability.
packages/web-platform/web-core-wasm/ts/client/wasm.ts (1)
33-35: No graceful degradation when WASM reference-types are unsupported.When
referenceTypes()returnsfalse, an error is thrown with no fallback. Consider whether a polyfill or alternative code path should be provided for older browsers, or document the browser support requirements.packages/web-platform/web-core-wasm/ts/types/EventType.ts (1)
1-3: Copyright year inconsistency.The copyright header shows 2023, while other new files in this PR use 2025. Consider updating for consistency.
packages/web-platform/web-core-wasm/ts/types/NativeApp.ts (3)
32-32: UseRecord<string, unknown>instead ofRecord<any, any>.
Record<any, any>effectively types the record asany, losing type safety. UsingRecord<string, unknown>maintains the record structure while requiring explicit type handling for values.🔎 Proposed fix
- trigger(eventName: string, params: string | Record<any, any>): void; + trigger(eventName: string, params: string | Record<string, unknown>): void;
56-60: Multiple uses ofanyreduce type safety.
lynxCoreInject: anyandRecord<string, any>forupdateCardDataparameters weaken type checking. Consider defining more specific types or usingunknownwhere the exact shape is not known but type guards will be used.
1-3: Copyright year inconsistency.This file uses 2023 while other new files in the PR use 2025. Consider updating for consistency.
packages/web-platform/web-core-wasm/binary/client/client.d.ts (1)
29-29: Consider strengthening type safety by replacinganytypes.Multiple methods use
anyfor parameters and return types (e.g.,function: any,config: object,event: any,mts_binding: any). While this may be necessary for FFI boundaries, consider using more specific types or type parameters where possible to improve type safety and developer experience.For example:
- Line 29:
function: anycould potentially be typed asFunctionor a more specific callback signature- Line 42:
config: objectcould use a specific config interface- Line 54:
serialized_event: anycould use a more specific event type- Line 66:
mts_binding: anyandunique_id_symbol: anycould have more specific typesNote: If these types are constrained by wasm-bindgen's code generation, document this limitation and consider filing an issue upstream to improve type generation.
Also applies to: 42-42, 46-46, 48-48, 51-52, 54-54, 66-66
This is a part of #1937
Summary by CodeRabbit
New Features
Documentation
Tests
Chores
Bug Fixes
✏️ Tip: You can customize this high-level summary in your review settings.
Checklist