Skip to content

feat(react): support lynx ssr#60

Merged
hzy merged 2 commits intolynx-family:mainfrom
hzy:p/hzy/support-lynx-ssr
Mar 21, 2025
Merged

feat(react): support lynx ssr#60
hzy merged 2 commits intolynx-family:mainfrom
hzy:p/hzy/support-lynx-ssr

Conversation

@hzy
Copy link
Copy Markdown
Collaborator

@hzy hzy commented Mar 5, 2025

In this PR, we add support for Lynx SSR by adding two call-by-native api ssrEncode and ssrHydrate.

Summary

Checklist

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

@hzy hzy requested a review from colinaaa as a code owner March 5, 2025 06:00
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 5, 2025

🦋 Changeset detected

Latest commit: 19761f9

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/react 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

@hzy hzy force-pushed the p/hzy/support-lynx-ssr branch 2 times, most recently from f412fa1 to 6d3f33a Compare March 11, 2025 09:22
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 11, 2025

@hzy hzy force-pushed the p/hzy/support-lynx-ssr branch 7 times, most recently from 52eefdb to 440f2f1 Compare March 19, 2025 00:32
@hzy hzy requested review from Huxpro and Yradex and removed request for Huxpro March 19, 2025 00:32
@hzy hzy force-pushed the p/hzy/support-lynx-ssr branch 3 times, most recently from ee76e2c to f4b2fdd Compare March 20, 2025 09:28
colinaaa
colinaaa previously approved these changes Mar 20, 2025
@hzy hzy force-pushed the p/hzy/support-lynx-ssr branch from ee8f57d to 24f656d Compare March 21, 2025 07:19
hzy and others added 2 commits March 21, 2025 15:39
In this PR, we add support for Lynx SSR by adding two call-by-native api `ssrEncode` and `ssrHydrate`.
Co-authored-by: Qingyu Wang <40660121+colinaaa@users.noreply.github.com>
Signed-off-by: Zhiyuan Hong <28915578+hzy@users.noreply.github.com>
@hzy hzy force-pushed the p/hzy/support-lynx-ssr branch from 24f656d to 19761f9 Compare March 21, 2025 07:45
@hzy hzy enabled auto-merge March 21, 2025 07:54
@hzy hzy added this pull request to the merge queue Mar 21, 2025
Merged via the queue into lynx-family:main with commit b18cbce Mar 21, 2025
13 of 15 checks passed
@hzy hzy deleted the p/hzy/support-lynx-ssr branch March 21, 2025 08:13
colinaaa pushed a commit that referenced this pull request Mar 22, 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/react@0.106.0

### Minor Changes

- Improved rendering performance by batching updates sent to the main
thread in a single render pass. This optimization reduces redundant
layout operations on the main thread, accelerates rendering, and
prevents screen flickering.
([#239](#239))

**BREAKING CHANGE**: This commit changes the behavior of Timing API.
Previously, timing events were fired for each update individually. With
the new batching mechanism, timing events related to the rendering
pipeline will now be triggered once per render cycle rather than for
each individual update, affecting applications that rely on the previous
timing behavior.

### Patch Changes

- Add missing typing for `useErrorBoundary`.
([#263](#263))

    You can now use `useErrorBoundary` it in TypeScript like this:

    ```tsx
    import { useErrorBoundary } from "@lynx-js/react";
    ```

- Modified the format of data sent from background threads to the main
thread. ([#207](#207))

- Support Lynx SSR.
([#60](#60))

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

### Minor Changes

- refractor: remove entryId concept
([#217](#217))

    After the PR #198
    All contents are isolated by a shadowroot.
Therefore we don't need to add the entryId selector to avoid the
lynx-view's style taking effect on the whole page.

### Patch Changes

- feat: `nativeModulesUrl` of lynx-view is changed to
`nativeModulesMap`, and the usage is completely aligned with
`napiModulesMap`.
([#220](#220))

    "warning: This is a breaking change."

`nativeModulesMap` will be a map: key is module-name, value should be a
esm url which export default a
    function with two parameters(you never need to use `this`):

- `NativeModules`: oriented `NativeModules`, which you can use to call
        other Native-Modules.

- `NativeModulesCall`: trigger `onNativeModulesCall`, same as the
deprecated `this.nativeModulesCall`.

    example:

    ```js
    const nativeModulesMap = {
      CustomModule: URL.createObjectURL(
        new Blob(
          [
            `export default function(NativeModules, NativeModulesCall) {
        return {
          async getColor(data, callback) {
            const color = await NativeModulesCall('getColor', data);
            callback(color);
          },
        }
      };`,
          ],
          { type: "text/javascript" }
        )
      ),
    };
    lynxView.nativeModulesMap = nativeModulesMap;
    ```

In addition, we will use Promise.all to load `nativeModules`, which will
optimize performance in the case of multiple modules.

- refactor: clean the decodeOperations implementation
([#261](#261))

- refactor: remove customelement defined detecting logic
([#247](#247))

Before this commit, for those element with tag without `-`, we always
try to detect if the `x-${tagName}` is defined.

After this commit, we pre-define a map(could be override by the
`overrideLynxTagToHTMLTagMap`) to make that transformation for tag name.

    This change is a path to SSR and the MTS support.

- Updated dependencies
\[[`53230f0`](53230f0)]:
    -   @lynx-js/web-worker-rpc@0.9.0

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

### Minor Changes

- feat: `nativeModulesUrl` of lynx-view is changed to
`nativeModulesMap`, and the usage is completely aligned with
`napiModulesMap`.
([#220](#220))

    "warning: This is a breaking change."

`nativeModulesMap` will be a map: key is module-name, value should be a
esm url which export default a
    function with two parameters(you never need to use `this`):

- `NativeModules`: oriented `NativeModules`, which you can use to call
        other Native-Modules.

- `NativeModulesCall`: trigger `onNativeModulesCall`, same as the
deprecated `this.nativeModulesCall`.

    example:

    ```js
    const nativeModulesMap = {
      CustomModule: URL.createObjectURL(
        new Blob(
          [
            `export default function(NativeModules, NativeModulesCall) {
        return {
          async getColor(data, callback) {
            const color = await NativeModulesCall('getColor', data);
            callback(color);
          },
        }
      };`,
          ],
          { type: "text/javascript" }
        )
      ),
    };
    lynxView.nativeModulesMap = nativeModulesMap;
    ```

In addition, we will use Promise.all to load `nativeModules`, which will
optimize performance in the case of multiple modules.

- refractor: remove entryId concept
([#217](#217))

    After the PR #198
    All contents are isolated by a shadowroot.
Therefore we don't need to add the entryId selector to avoid the
lynx-view's style taking effect on the whole page.

### Patch Changes

- refactor: code clean
([#266](#266))

- refactor: clean the decodeOperations implementation
([#261](#261))

- fix: When the width and height of lynx-view are not auto, the width
and height of the `lynx-tag="page"` need to be correctly set to 100%.
([#228](#228))

- refactor: remove customelement defined detecting logic
([#247](#247))

Before this commit, for those element with tag without `-`, we always
try to detect if the `x-${tagName}` is defined.

After this commit, we pre-define a map(could be override by the
`overrideLynxTagToHTMLTagMap`) to make that transformation for tag name.

    This change is a path to SSR and the MTS support.

- fix: 'error' event for main-thread \_reportError
([#283](#283))

- Updated dependencies
\[[`5b5e090`](5b5e090),
[`b844e75`](b844e75),
[`53230f0`](53230f0),
[`6f16827`](6f16827),
[`d2d55ef`](d2d55ef)]:
    -   @lynx-js/web-worker-runtime@0.9.0
    -   @lynx-js/web-constants@0.9.0
    -   @lynx-js/web-worker-rpc@0.9.0

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

### Minor Changes

- feat: 1. list adds support for the `sticky` attribute. Now
sticky-offset, sticky-top, and sticky-bottom will only take effect when
`sticky` is `true`.
([#257](#257))

    2.  Added support for `list-main-axis-gap`, `list-cross-axis-gap`.

- feat(web): The list element supports list-type with **flow**.
([#240](#240))

It supports all attributes and events under single, and also provides
`full-span`.

    For detailed usage, please refer to the official website.

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

### Minor Changes

- refractor: remove entryId concept
([#217](#217))

    After the PR #198
    All contents are isolated by a shadowroot.
Therefore we don't need to add the entryId selector to avoid the
lynx-view's style taking effect on the whole page.

### Patch Changes

- refactor: clean the decodeOperations implementation
([#261](#261))

- refactor: remove customelement defined detecting logic
([#247](#247))

Before this commit, for those element with tag without `-`, we always
try to detect if the `x-${tagName}` is defined.

After this commit, we pre-define a map(could be override by the
`overrideLynxTagToHTMLTagMap`) to make that transformation for tag name.

    This change is a path to SSR and the MTS support.

- Updated dependencies
\[[`5b5e090`](5b5e090),
[`f447811`](f447811),
[`b844e75`](b844e75),
[`6f16827`](6f16827),
[`d2d55ef`](d2d55ef)]:
    -   @lynx-js/web-constants@0.9.0
    -   @lynx-js/web-style-transformer@0.2.3

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

### Minor Changes

- feat: `nativeModulesUrl` of lynx-view is changed to
`nativeModulesMap`, and the usage is completely aligned with
`napiModulesMap`.
([#220](#220))

    "warning: This is a breaking change."

`nativeModulesMap` will be a map: key is module-name, value should be a
esm url which export default a
    function with two parameters(you never need to use `this`):

- `NativeModules`: oriented `NativeModules`, which you can use to call
        other Native-Modules.

- `NativeModulesCall`: trigger `onNativeModulesCall`, same as the
deprecated `this.nativeModulesCall`.

    example:

    ```js
    const nativeModulesMap = {
      CustomModule: URL.createObjectURL(
        new Blob(
          [
            `export default function(NativeModules, NativeModulesCall) {
        return {
          async getColor(data, callback) {
            const color = await NativeModulesCall('getColor', data);
            callback(color);
          },
        }
      };`,
          ],
          { type: "text/javascript" }
        )
      ),
    };
    lynxView.nativeModulesMap = nativeModulesMap;
    ```

In addition, we will use Promise.all to load `nativeModules`, which will
optimize performance in the case of multiple modules.

- refractor: remove entryId concept
([#217](#217))

    After the PR #198
    All contents are isolated by a shadowroot.
Therefore we don't need to add the entryId selector to avoid the
lynx-view's style taking effect on the whole page.

### Patch Changes

- refactor: remove customelement defined detecting logic
([#247](#247))

Before this commit, for those element with tag without `-`, we always
try to detect if the `x-${tagName}` is defined.

After this commit, we pre-define a map(could be override by the
`overrideLynxTagToHTMLTagMap`) to make that transformation for tag name.

    This change is a path to SSR and the MTS support.

- Updated dependencies
\[[`5b5e090`](5b5e090),
[`b844e75`](b844e75),
[`53230f0`](53230f0),
[`6f16827`](6f16827),
[`d2d55ef`](d2d55ef)]:
    -   @lynx-js/web-constants@0.9.0
    -   @lynx-js/web-mainthread-apis@0.9.0
    -   @lynx-js/web-worker-rpc@0.9.0

## @lynx-js/rspeedy@0.8.5

### Patch Changes

- Bump Rsdoctor v1.0.0.
([#250](#250))

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

### Patch Changes

- Support `@lynx-js/react` v0.106.0.
([#239](#239))

- Fix the issue where the canary version of React was not included in
the `rule.include` configuration.
([#275](#275))

- Updated dependencies
\[[`ba26a4d`](ba26a4d),
[`462e97b`](462e97b),
[`aa1fbed`](aa1fbed),
[`d2d55ef`](d2d55ef),
[`6af0396`](6af0396)]:
    -   @lynx-js/template-webpack-plugin@0.6.6
    -   @lynx-js/react-webpack-plugin@0.6.9
    -   @lynx-js/runtime-wrapper-webpack-plugin@0.0.9
    -   @lynx-js/web-webpack-plugin@0.6.3
    -   @lynx-js/react-alias-rsbuild-plugin@0.9.3
    -   @lynx-js/css-extract-webpack-plugin@0.5.2
    -   @lynx-js/react-refresh-webpack-plugin@0.3.2

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

### Patch Changes

- Fix the issue where the canary version of React was not included in
the `rule.include` configuration.
([#275](#275))

## @lynx-js/web-style-transformer@0.2.3

### Patch Changes

- feat: 1. list adds support for the `sticky` attribute. Now
sticky-offset, sticky-top, and sticky-bottom will only take effect when
`sticky` is `true`.
([#257](#257))

    2.  Added support for `list-main-axis-gap`, `list-cross-axis-gap`.

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

### Patch Changes

- feat: add a new type function RpcCallType
([#283](#283))

## @lynx-js/react-webpack-plugin@0.6.9

### Patch Changes

- Support `@lynx-js/react` v0.106.0.
([#239](#239))

## @lynx-js/runtime-wrapper-webpack-plugin@0.0.9

### Patch Changes

- Add `window` variable to callback argument in `background.js` and the
`window` is `undefined` in Lynx. Sometimes it's useful to distinguish
between Lynx and the Web.
([#248](#248))

    ```js
    define('background.js', (..., window) => {
      console.log(window); // `undefined` in Lynx
    })
    ```

## @lynx-js/template-webpack-plugin@0.6.6

### Patch Changes

- expose main.lynx.bundle to compiler
([#231](#231))

## @lynx-js/web-webpack-plugin@0.6.3

### Patch Changes

- chore: remove unused file
([#217](#217))

- Updated dependencies
\[[`f447811`](f447811)]:
    -   @lynx-js/web-style-transformer@0.2.3

## create-rspeedy@0.8.5



## upgrade-rspeedy@0.8.5

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
upupming added a commit that referenced this pull request Jan 4, 2026
<!--
  Thank you for submitting a pull request!

We appreciate the time and effort you have invested in making these
changes. Please ensure that you provide enough information to allow
others to review your pull request.

Upon submission, your pull request will be automatically assigned with
reviewers.

If you want to learn more about contributing to this project, please
visit:
https://github.com/lynx-family/lynx-stack/blob/main/CONTRIBUTING.md.
-->

<!-- The AI summary below will be auto-generated - feel free to replace
it with your own. -->

Solves #2045

An example log from our examples/react package is as below.

First screen:

<details>

```log
[BackgroundThread Component Render] name: Fragment, uniqID: undefined, __id: undefined
main-thread.js:3421 [ReactLynxDebug] FiberElement API call #1: __CreatePage("0", 0) => page#10
main-thread.js:3421 [ReactLynxDebug] FiberElement API call #2: __GetElementUniqueID(page#10) => 10
main-thread.js:3421 [ReactLynxDebug] FiberElement API call #3: __SetCSSId([page#10], 0)
main-thread.js:3460 [MainThread Component Render] name: App
main-thread.js:3421 [ReactLynxDebug] FiberElement API call #4: __CreateView(10) => view#11
main-thread.js:3421 [ReactLynxDebug] FiberElement API call #5: __CreateView(10) => view#12
main-thread.js:3421 [ReactLynxDebug] FiberElement API call #6: __SetClasses(view#12, "Background")
main-thread.js:3421 [ReactLynxDebug] FiberElement API call #7: __AppendElement(view#11, view#12) => view#12
main-thread.js:3421 [ReactLynxDebug] FiberElement API call #8: __CreateView(10) => view#13
main-thread.js:3421 [ReactLynxDebug] FiberElement API call #9: __SetClasses(view#13, "App")
main-thread.js:3421 [ReactLynxDebug] FiberElement API call #10: __AppendElement(view#11, view#13) => view#13
main-thread.js:3421 [ReactLynxDebug] FiberElement API call #11: __CreateView(10) => view#14
main-thread.js:3421 [ReactLynxDebug] FiberElement API call #12: __SetClasses(view#14, "Banner")
main-thread.js:3421 [ReactLynxDebug] FiberElement API call #13: __AppendElement(view#13, view#14) => view#14
main-thread.js:3421 [ReactLynxDebug] FiberElement API call #14: __CreateWrapperElement(10) => wrapper#15
main-thread.js:3421 [ReactLynxDebug] FiberElement API call #15: __AppendElement(view#14, wrapper#15) => wrapper#15
main-thread.js:3421 [ReactLynxDebug] FiberElement API call #16: __CreateText(10) => text#16
main-thread.js:3421 [ReactLynxDebug] FiberElement API call #17: __SetClasses(text#16, "Title")
main-thread.js:3421 [ReactLynxDebug] FiberElement API call #18: __SetAttribute(text#16, "text", "React")
main-thread.js:3421 [ReactLynxDebug] FiberElement API call #19: __AppendElement(view#14, text#16) => text#16
main-thread.js:3421 [ReactLynxDebug] FiberElement API call #20: __CreateText(10) => text#17
main-thread.js:3421 [ReactLynxDebug] FiberElement API call #21: __SetClasses(text#17, "Subtitle")
main-thread.js:3421 [ReactLynxDebug] FiberElement API call #22: __SetAttribute(text#17, "text", "on Lynx")
main-thread.js:3421 [ReactLynxDebug] FiberElement API call #23: __AppendElement(view#14, text#17) => text#17
main-thread.js:3421 [ReactLynxDebug] FiberElement API call #24: __CreateView(10) => view#18
main-thread.js:3421 [ReactLynxDebug] FiberElement API call #25: __SetClasses(view#18, "Content")
main-thread.js:3421 [ReactLynxDebug] FiberElement API call #26: __AppendElement(view#13, view#18) => view#18
main-thread.js:3421 [ReactLynxDebug] FiberElement API call #27: __CreateImage(10) => image#19
main-thread.js:3421 [ReactLynxDebug] FiberElement API call #28: __SetClasses(image#19, "Arrow")
main-thread.js:3421 [ReactLynxDebug] FiberElement API call #29: __AppendElement(view#18, image#19) => image#19
main-thread.js:3421 [ReactLynxDebug] FiberElement API call #30: __CreateText(10) => text#20
main-thread.js:3421 [ReactLynxDebug] FiberElement API call #31: __SetClasses(text#20, "Description")
main-thread.js:3421 [ReactLynxDebug] FiberElement API call #32: __SetAttribute(text#20, "text", "Tap the logo and have fun!")
main-thread.js:3421 [ReactLynxDebug] FiberElement API call #33: __AppendElement(view#18, text#20) => text#20
main-thread.js:3421 [ReactLynxDebug] FiberElement API call #34: __CreateText(10) => text#21
main-thread.js:3421 [ReactLynxDebug] FiberElement API call #35: __SetClasses(text#21, "Hint")
main-thread.js:3421 [ReactLynxDebug] FiberElement API call #36: __AppendElement(view#18, text#21) => text#21
main-thread.js:3421 [ReactLynxDebug] FiberElement API call #37: __CreateRawText("Edit") => raw-text#22
main-thread.js:3421 [ReactLynxDebug] FiberElement API call #38: __AppendElement(text#21, raw-text#22) => raw-text#22
main-thread.js:3421 [ReactLynxDebug] FiberElement API call #39: __CreateWrapperElement(10) => wrapper#23
main-thread.js:3421 [ReactLynxDebug] FiberElement API call #40: __AppendElement(text#21, wrapper#23) => wrapper#23
main-thread.js:3421 [ReactLynxDebug] FiberElement API call #41: __CreateRawText("to see updates!") => raw-text#24
main-thread.js:3421 [ReactLynxDebug] FiberElement API call #42: __AppendElement(text#21, raw-text#24) => raw-text#24
main-thread.js:3421 [ReactLynxDebug] FiberElement API call #43: __CreateView(10) => view#25
main-thread.js:3421 [ReactLynxDebug] FiberElement API call #44: __SetInlineStyles(view#25, "flex:1")
main-thread.js:3421 [ReactLynxDebug] FiberElement API call #45: __AppendElement(view#13, view#25) => view#25
main-thread.js:3421 [ReactLynxDebug] FiberElement API call #46: __AppendElement(page#10, view#11) => view#11
main-thread.js:3421 [ReactLynxDebug] FiberElement API call #47: __SetAttribute(image#19, "src", "http://1.1.1.1:3000/static/image/arrow.aee54ba7.png")
main-thread.js:3421 [ReactLynxDebug] FiberElement API call #48: __CreateView(10) => view#26
main-thread.js:3421 [ReactLynxDebug] FiberElement API call #49: __SetClasses(view#26, "Logo")
main-thread.js:3421 [ReactLynxDebug] FiberElement API call #50: __ReplaceElement(view#26, wrapper#15)
main-thread.js:3421 [ReactLynxDebug] FiberElement API call #51: __AddEvent(view#26, "bindEvent", "tap", "-3:0:")
main-thread.js:3421 [ReactLynxDebug] FiberElement API call #52: __CreateImage(10) => image#27
main-thread.js:3421 [ReactLynxDebug] FiberElement API call #53: __SetClasses(image#27, "Logo--lynx")
main-thread.js:3421 [ReactLynxDebug] FiberElement API call #54: __AppendElement(view#26, image#27) => image#27
main-thread.js:3421 [ReactLynxDebug] FiberElement API call #55: __SetAttribute(image#27, "src", "http://1.1.1.1:3000/static/image/lynx-logo.620eb8d1.png")
main-thread.js:3421 [ReactLynxDebug] FiberElement API call #56: __CreateText(10) => text#28
main-thread.js:3421 [ReactLynxDebug] FiberElement API call #57: __SetInlineStyles(text#28, "font-style:italic;color:rgba(255, 255, 255, 0.85)")
main-thread.js:3421 [ReactLynxDebug] FiberElement API call #58: __ReplaceElement(text#28, wrapper#23)
main-thread.js:3421 [ReactLynxDebug] FiberElement API call #59: __CreateRawText("") => raw-text#29
main-thread.js:3421 [ReactLynxDebug] FiberElement API call #60: __SetAttribute(raw-text#29, "text", " src/App.tsx ")
main-thread.js:3421 [ReactLynxDebug] FiberElement API call #61: __AppendElement(text#28, raw-text#29) => raw-text#29
main-thread.js:3421 [ReactLynxDebug] FiberElement API call #62: __OnLifecycleEvent(["rLynxFirstScreen", {"root":"{\"id\":-1,\"type\":\"root\",\"children\":[{\"id\":-5,\"type\":\"__snapshot_835da_b8ae7_1\",\"values\":[\"http://1.1.1.1:3000/static/image/arrow.aee54ba7.png\"],\"children\":[{\"id\":-3,\"type\":\"__snapshot_835da_b8ae7_2\",\"values\":[\"-3:0:\"],\"children\":[{\"id\":-2,\"type\":\"__snapshot_835da_b8ae7_4\",\"values\":[\"http://1.1.1.1:3000/static/image/lynx-logo.620eb8d1.png\"]}]},{\"id\":-4,\"type\":\"__snapshot_835da_b8ae7_5\",\"children\":[{\"id\":-6,\"type\":null,\"values\":[\" src/App.tsx \"]}]}]}]}","jsReadyEventIdSwap":{}}])
background.js:11351 [rspeedy-dev-server] Server started: Hot Module Replacement enabled, Live Reloading enabled, Progress disabled, Overlay disabled.
background.js:3564 [HMR] Waiting for update signal from WDS...
background.js:4476 [BackgroundThread Component Render] name: App, uniqID: __snapshot_835da_b8ae7_1, __id: 2
background.js:4476 [BackgroundThread Component Render] name: Fragment, uniqID: __snapshot_835da_b8ae7_1, __id: 2
background.js:214 Hello, ReactLynx
background.js:8011 [ReactLynxDebug] MTS -> BTS OnLifecycleEvent:
{
  "root": {
    "id": -1,
    "type": "root",
    "children": [
      {
        "id": -5,
        "type": "__snapshot_835da_b8ae7_1",
        "values": [
          "http://1.1.1.1:3000/static/image/arrow.aee54ba7.png"
        ],
        "children": [
          {
            "id": -3,
            "type": "__snapshot_835da_b8ae7_2",
            "values": [
              "-3:0:"
            ],
            "children": [
              {
                "id": -2,
                "type": "__snapshot_835da_b8ae7_4",
                "values": [
                  "http://1.1.1.1:3000/static/image/lynx-logo.620eb8d1.png"
                ]
              }
            ]
          },
          {
            "id": -4,
            "type": "__snapshot_835da_b8ae7_5",
            "children": [
              {
                "id": -6,
                "type": null,
                "values": [
                  " src/App.tsx "
                ]
              }
            ]
          }
        ]
      }
    ]
  },
  "jsReadyEventIdSwap": {}
}
main-thread.js:5801 [ReactLynxDebug] BTS -> MTS updateMainThread:
{
  "data": {
    "patchList": [
      {
        "snapshotPatch": [],
        "id": 2
      }
    ]
  },
  "patchOptions": {
    "isHydration": true,
    "reloadVersion": 0,
    "pipelineOptions": {
      "pipelineID": "0x16c567000_29",
      "needTimestamps": true,
      "pipelineOrigin": "reactLynxHydrate",
      "dsl": "reactLynx",
      "stage": "hydrate"
    }
  }
}
main-thread.js:3421 [ReactLynxDebug] FiberElement API call #63: __FlushElementTree(page#10, {"pipelineOptions":{"pipelineID":"0x16c567000_29","needTimestamps":true,"pipelineOrigin":"reactLynxHydrate","dsl":"reactLynx","stage":"hydrate"}})

```

</details>

Next update:

<details>

```log
[BackgroundThread Component Render] name: App, uniqID: __snapshot_835da_b8ae7_1, __id: -5
main-thread.js:5801 [ReactLynxDebug] BTS -> MTS updateMainThread:
{
  "data": {
    "patchList": [
      {
        "id": 3,
        "snapshotPatch": [
          {
            "op": "RemoveChild",
            "parentId": -3,
            "childId": -2
          },
          {
            "op": "CreateElement",
            "type": "__snapshot_835da_b8ae7_3",
            "id": 7
          },
          {
            "op": "SetAttributes",
            "id": 7,
            "values": [
              "http://1.1.1.1:3000/static/image/react-logo.75eb3837.png"
            ]
          },
          {
            "op": "InsertBefore",
            "parentId": -3,
            "childId": 7,
            "beforeId": null
          }
        ]
      }
    ]
  },
  "patchOptions": {
    "reloadVersion": 0,
    "pipelineOptions": {
      "pipelineID": "0x16c567000_30",
      "needTimestamps": false,
      "pipelineOrigin": "updateTriggeredByBts",
      "dsl": "reactLynx",
      "stage": "update"
    }
  }
}
main-thread.js:3421 [ReactLynxDebug] FiberElement API call #64: __RemoveElement(view#26, image#27) => image#27
main-thread.js:3421 [ReactLynxDebug] FiberElement API call #65: __CreateImage(10) => image#30
main-thread.js:3421 [ReactLynxDebug] FiberElement API call #66: __SetClasses(image#30, "Logo--react")
main-thread.js:3421 [ReactLynxDebug] FiberElement API call #67: __SetAttribute(image#30, "src", "http://1.1.1.1:3000/static/image/react-logo.75eb3837.png")
main-thread.js:3421 [ReactLynxDebug] FiberElement API call #68: __AppendElement(view#26, image#30) => image#30
main-thread.js:3421 [ReactLynxDebug] FiberElement API call #69: __FlushElementTree(page#10, {"pipelineOptions":{"pipelineID":"0x16c567000_30","needTimestamps":false,"pipelineOrigin":"updateTriggeredByBts","dsl":"reactLynx","stage":"update"}})
```

</details>

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* Enhanced debug logging: structured, dual-thread API-call, lifecycle
and hydration traces when debug mode is enabled.
* **Tests**
* Added and expanded tests and snapshots to validate richer logging,
API-call sequences, and hydration traces.
* **Chores**
* Development-only error messages now include a troubleshooting hint
recommending the debug-mode option for easier diagnosis.

<sub>✏️ Tip: You can customize this high-level summary in your review
settings.</sub>
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

## Checklist

<!--- Check and mark with an "x" -->

- [x] Tests updated (or not required).
- [ ] Documentation updated (or not required).
- [x] Changeset added, and when a BREAKING CHANGE occurs, it needs to be
clearly marked (or not required).
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.

3 participants