Skip to content

Conversation

@upupming
Copy link
Collaborator

@upupming upupming commented Jul 8, 2025

Summary

In the real Lynx App, lynx.getCoreContext and lynx.getJSContext works in the following way:

if (__BACKGROUND__) {
  lynx.getCoreContext().addEventListener("message", (e: Event) => {
    console.log('message', e)
    // {
    //   "type": "message",
    //     "data": {
    //     "type": "message",
    //       "data": [
    //         4,
    //         5,
    //         6
    //       ]
    //   },
    //   "origin": "CoreContext"
    // }
  });
  lynx.getCoreContext().postMessage({
    type: 'message',
    data: [1, 2, 3]
  });
} else {
  lynx.getJSContext().addEventListener("message", (e: Event) => {
    console.log('message', e)
  });
  // {
  //   "type": "message",
  //     "data": {
  //     "type": "message",
  //       "data": [
  //         1,
  //         2,
  //         3
  //       ]
  //   },
  //   "origin": "JSContext"
  // }
  lynx.getJSContext().postMessage({
    type: 'message',
    data: [3, 4, 5]
  });
}

We should switch to another thread when postMessage/dispatchEvent is called, this will fix the bug of thread switching when using MTS nested runOnMainThread and runOnBackground.

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

@changeset-bot
Copy link

changeset-bot bot commented Jul 8, 2025

🦋 Changeset detected

Latest commit: b03f0c4

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

This PR includes changesets to release 1 package
Name Type
@lynx-js/testing-environment Patch

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

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

@codecov
Copy link

codecov bot commented Jul 8, 2025

Codecov Report

Attention: Patch coverage is 0% with 10 lines in your changes missing coverage. Please review.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...s/testing-library/testing-environment/src/index.ts 0.00% 10 Missing ⚠️

📢 Thoughts on this report? Let us know!

@codspeed-hq
Copy link

codspeed-hq bot commented Jul 8, 2025

CodSpeed Performance Report

Merging #1244 will not alter performance

Comparing upupming:fix/testing-library-switch (b03f0c4) with main (7408d3b)

Summary

✅ 10 untouched benchmarks

@relativeci
Copy link

relativeci bot commented Jul 8, 2025

Web Explorer

#2697 Bundle Size — 259.2KiB (0%).

b03f0c4(current) vs 7408d3b main#2688(baseline)

Bundle metrics  no changes
                 Current
#2697
     Baseline
#2688
No change  Initial JS 141.05KiB 141.05KiB
No change  Initial CSS 31.88KiB 31.88KiB
No change  Cache Invalidation 0% 0%
No change  Chunks 4 4
No change  Assets 4 4
No change  Modules 210 210
No change  Duplicate Modules 17 17
No change  Duplicate Code 4.15% 4.15%
No change  Packages 4 4
No change  Duplicate Packages 0 0
Bundle size by type  no changes
                 Current
#2697
     Baseline
#2688
No change  JS 227.32KiB 227.32KiB
No change  CSS 31.88KiB 31.88KiB

Bundle analysis reportBranch upupming:fix/testing-library-swi...Project dashboard


Generated by RelativeCIDocumentationReport issue

@relativeci
Copy link

relativeci bot commented Jul 8, 2025

React Example

#2706 Bundle Size — 234.12KiB (0%).

b03f0c4(current) vs 7408d3b main#2697(baseline)

Bundle metrics  no changes
                 Current
#2706
     Baseline
#2697
No change  Initial JS 0B 0B
No change  Initial CSS 0B 0B
No change  Cache Invalidation 0% 0%
No change  Chunks 0 0
No change  Assets 4 4
No change  Modules 153 153
No change  Duplicate Modules 61 61
No change  Duplicate Code 45.85% 45.85%
No change  Packages 2 2
No change  Duplicate Packages 0 0
Bundle size by type  no changes
                 Current
#2706
     Baseline
#2697
No change  IMG 145.76KiB 145.76KiB
No change  Other 88.37KiB 88.37KiB

Bundle analysis reportBranch upupming:fix/testing-library-swi...Project dashboard


Generated by RelativeCIDocumentationReport issue

@upupming upupming requested review from Yradex, colinaaa, gaoachao and hzy July 21, 2025 03:52
@colinaaa colinaaa added this pull request to the merge queue Jul 21, 2025
Merged via the queue into lynx-family:main with commit 1a2a57d Jul 21, 2025
42 of 44 checks passed
colinaaa pushed a commit that referenced this pull request Jul 28, 2025
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## @lynx-js/[email protected]

### Minor Changes

- feat: Force synchronous rendering for background initial renders to
support Suspense fallbacks
([#1323](#1323))

- Introduces `@lynx-js/react/compat` submodule exporting Preact
implementations of:
([#1316](#1316))

    -   `startTransition`
    -   `useTransition`

### Patch Changes

- fix: Ensure useEffect callbacks execute before event handlers from the
same render cycle
([#1348](#1348))

- Enable rendering of the `Suspense` fallback on initial render.
([#1285](#1285))

- fix: Prevent "cannot set property 'current' of undefined" error thrown
by MainThreadRef on engine data updates
([#1342](#1342))

## @lynx-js/[email protected]

### Patch Changes

- Should be able to override `performance.profile` when `DEBUG=rspeedy`.
([#1307](#1307))

## @lynx-js/[email protected]

### Patch Changes

- Be compat with `@lynx-js/react` v0.112.0
([#1323](#1323))

- Fix not having profile in development by default.
([#1306](#1306))

- Updated dependencies
\[[`fcafd54`](fcafd54),
[`fe38de5`](fe38de5),
[`7cd5ea2`](7cd5ea2)]:
    -   @lynx-js/[email protected]
    -   @lynx-js/[email protected]
    -   @lynx-js/[email protected]
    -   @lynx-js/[email protected]

## @lynx-js/[email protected]

### Patch Changes

- Add alias for `@lynx-js/react/compat`.
([#1316](#1316))

## @lynx-js/[email protected]

### Patch Changes

- Fix the thread switching bug in `lynx.getCoreContext` and
`lynx.getJSContext`.
([#1244](#1244))

## @lynx-js/[email protected]

### Patch Changes

- Improve transform transition compatibility with Lynx versions that do
not support animating CSS variables.
([#1320](#1320))

- Added Lynx specific solo transform utilities that avoid CSS variables:
`solo-translate-x-*`, `solo-scale-*`, `solo-rotate-*` etc. These
utilities are implemented without CSS variables using raw transform
functions such as `translateX()`, `scale()` and `rotate()`. They are
mutually exclusive and cannot be combined with normal transform
utilities.

- Enabled arbitrary values for `transform-[...]`: e.g.
`transform-[translateX(20px)_rotate(10deg)]`, following Tailwind v4
behavior.

- Fix `scale-*` utilities not supporting negative values. Now supports
`-scale-x-100`, `-scale-y-50` as expected.
([#1320](#1320))

- Add filter utilities: `blur-*`, `grayscale-*`.
([#1345](#1345))

- Note: On Lynx, filter functions are mutually exclusive, only one can
be active at a time.

- Introduce scoped timing utilities with auto-derived repeat count for
grouped transition properties, working around Lynx's lack of automatic
value expansion.
([#1324](#1324))

- Scoped utilities like `duration-colors-*`, `ease-colors-*`, and
`delay-colors-*` are generated when `transitionProperty.colors` contains
multiple properties.

- Scoped utilities like `duration-n-*`, `ease-n-*`,`delay-n-*` are
generated when the `transitionProperty.DEFAULT` group contains multiple
properties.

- For single-property transitions (e.g., `transition-opacity`,
`transition-transform`), you must use Tailwind's default `duration-*`,
`ease-*`, and `delay-*` utilities, no scoped timing utilities will be
generated in these cases.

## @lynx-js/[email protected]

### Patch Changes

- fix: improve compatibility with legacy template
([#1337](#1337))

    avoid "object Object" error for old version rspeedy outputs

-   Updated dependencies \[]:
    -   @lynx-js/[email protected]

## @lynx-js/[email protected]

### Patch Changes

- fix: improve compatibility with legacy template
([#1337](#1337))

    avoid "object Object" error for old version rspeedy outputs

- Updated dependencies
\[[`0da5ef0`](0da5ef0)]:
    -   @lynx-js/[email protected]
    -   @lynx-js/[email protected]
    -   @lynx-js/[email protected]
    -   @lynx-js/[email protected]

## @lynx-js/[email protected]

### Patch Changes

- Add crossorigin attribute support to x-image component
([#1340](#1340))

- Added `crossorigin` to the `observedAttributes` array in `ImageSrc.ts`
- Implemented `#handleCrossorigin` handler using the `bindToAttribute`
helper to forward the crossorigin attribute from the custom element to
the internal `<img>` element
- Added comprehensive test coverage to verify the attribute is properly
passed through to the shadow DOM

This enables CORS-enabled image loading when using `<x-image
crossorigin="anonymous">` or similar configurations.

-   Updated dependencies \[]:
    -   @lynx-js/[email protected]

## @lynx-js/[email protected]

### Patch Changes

- Updated dependencies
\[[`0da5ef0`](0da5ef0)]:
    -   @lynx-js/[email protected]

## @lynx-js/[email protected]

### Patch Changes

- Updated dependencies
\[[`0da5ef0`](0da5ef0)]:
    -   @lynx-js/[email protected]
    -   @lynx-js/[email protected]
    -   @lynx-js/[email protected]

## @lynx-js/[email protected]

### Patch Changes

- Be compat with `@lynx-js/react` v0.112.0
([#1323](#1323))

- Fix `REACT_PROFILE` not taking effect.
([#1306](#1306))

## [email protected]



## [email protected]



## @lynx-js/[email protected]



## @lynx-js/[email protected]



## @lynx-js/[email protected]

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants