@lynx-js/react-canary 0.116.5 → 0.116.6-canary-20260310-d034dae1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
# @lynx-js/react
|
|
2
2
|
|
|
3
|
+
## 0.116.6-canary-20260310040608-d034dae124f8a96faa11028b131173703e49b23f
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Avoid registering lifecycle refs for main-thread functions (MTF) that have not received an `execId` during `renderPage()` first-screen binding. ([#2320](https://github.com/lynx-family/lynx-stack/pull/2320))
|
|
8
|
+
|
|
3
9
|
## 0.116.5
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
|
6
12
|
|
|
7
13
|
- Improve React runtime hook profiling. ([#2235](https://github.com/lynx-family/lynx-stack/pull/2235))
|
|
8
14
|
Enable Profiling recording first, then enter the target page so the trace includes full render/hydrate phases.
|
|
9
|
-
|
|
10
15
|
- Record trace events for `useEffect` / `useLayoutEffect` hook entry, callback, and cleanup phases.
|
|
11
16
|
- Log trace events for `useState` setter calls.
|
|
12
17
|
- Wire `profileFlowId` support in debug profile utilities and attach flow IDs to related hook traces.
|
|
@@ -55,7 +60,6 @@
|
|
|
55
60
|
- Bump `swc_core` v56. ([#2154](https://github.com/lynx-family/lynx-stack/pull/2154))
|
|
56
61
|
|
|
57
62
|
- Use `disableDeprecatedWarning` option to suppress BROKEN warnings during compilation. ([#2157](https://github.com/lynx-family/lynx-stack/pull/2157))
|
|
58
|
-
|
|
59
63
|
1. BROKEN: `getNodeRef`/`getNodeRefFromRoot`/`createSelectorQuery` on component instance is broken and MUST be migrated in ReactLynx 3.0, please use ref or lynx.createSelectorQuery instead.
|
|
60
64
|
2. BROKEN: `getElementById` on component instance is broken and MUST be migrated in ReactLynx 3.0, please use ref or lynx.getElementById instead.
|
|
61
65
|
|
|
@@ -93,9 +97,9 @@
|
|
|
93
97
|
|
|
94
98
|
```typescript
|
|
95
99
|
function getStyle(ele: MainThread.Element) {
|
|
96
|
-
|
|
97
|
-
const width = ele.getComputedStyleProperty(
|
|
98
|
-
const transformMatrix = ele.getComputedStyleProperty(
|
|
100
|
+
"main thread";
|
|
101
|
+
const width = ele.getComputedStyleProperty("width"); // Returns 300px
|
|
102
|
+
const transformMatrix = ele.getComputedStyleProperty("transform"); // Returns matrix(2, 0, 0, 2, 200, 400)
|
|
99
103
|
}
|
|
100
104
|
```
|
|
101
105
|
|
|
@@ -110,7 +114,7 @@
|
|
|
110
114
|
```ts
|
|
111
115
|
const LazyComponent = lazy(async () => {
|
|
112
116
|
try {
|
|
113
|
-
const mod = await import(
|
|
117
|
+
const mod = await import("./lazy-bundle");
|
|
114
118
|
return mod.default;
|
|
115
119
|
} catch (error) {
|
|
116
120
|
console.error(`Lazy Bundle load failed message: ${error.message}`);
|
|
@@ -138,14 +142,13 @@
|
|
|
138
142
|
- Auto define lynx.loadLazyBundle when using `import(/* relative path */)`. ([#1956](https://github.com/lynx-family/lynx-stack/pull/1956))
|
|
139
143
|
|
|
140
144
|
- feat: support declaring cross-thread shared modules via Import Attributes, enabling Main Thread Functions to call standard JS functions directly. ([#1968](https://github.com/lynx-family/lynx-stack/pull/1968))
|
|
141
|
-
|
|
142
145
|
- Usage: Add `with { runtime: "shared" }` to the `import` statement. For example:
|
|
143
146
|
|
|
144
147
|
```ts
|
|
145
|
-
import { func } from
|
|
148
|
+
import { func } from "./utils.js" with { runtime: "shared" };
|
|
146
149
|
|
|
147
150
|
function worklet() {
|
|
148
|
-
|
|
151
|
+
"main thread";
|
|
149
152
|
func(); // callable inside a main thread function
|
|
150
153
|
}
|
|
151
154
|
```
|
|
@@ -161,13 +164,11 @@
|
|
|
161
164
|
- **BREAKING CHANGE**: Delay the `createSnapshot` operation to `Snapshot` constructor to speed up IFR. ([#1899](https://github.com/lynx-family/lynx-stack/pull/1899))
|
|
162
165
|
|
|
163
166
|
This change refactors how snapshots are created and registered:
|
|
164
|
-
|
|
165
167
|
- Removed the `entryUniqID` function
|
|
166
168
|
- Snapshots are now lazily created via `snapshotCreatorMap` instead of eagerly at bundle load time
|
|
167
169
|
- Snapshot IDs are generated at compile time and only prefixed with `${globDynamicComponentEntry}:` for standalone lazy bundles
|
|
168
170
|
|
|
169
171
|
**⚠️ Lazy Bundle Compatibility:**
|
|
170
|
-
|
|
171
172
|
- **Backward compatibility (new runtime → old lazy bundles)**: ✅ **Supported**. Old lazy bundles will work with the new runtime.
|
|
172
173
|
|
|
173
174
|
- **Forward compatibility (old runtime → new lazy bundles)**: ❌ **NOT Supported**. Lower version consumers **will not be able to load lazy bundles produced by this version** due to the changed snapshot creation mechanism.
|
|
@@ -222,11 +223,11 @@
|
|
|
222
223
|
- Support testing React Compiler in testing library. Enable React Compiler by setting the `experimental_enableReactCompiler` option of `createVitestConfig` to `true`. ([#1269](https://github.com/lynx-family/lynx-stack/pull/1269))
|
|
223
224
|
|
|
224
225
|
```js
|
|
225
|
-
import { defineConfig, mergeConfig } from
|
|
226
|
-
import { createVitestConfig } from
|
|
226
|
+
import { defineConfig, mergeConfig } from "vitest/config";
|
|
227
|
+
import { createVitestConfig } from "@lynx-js/react/testing-library/vitest-config";
|
|
227
228
|
|
|
228
229
|
const defaultConfig = await createVitestConfig({
|
|
229
|
-
runtimePkgName:
|
|
230
|
+
runtimePkgName: "@lynx-js/react",
|
|
230
231
|
experimental_enableReactCompiler: true,
|
|
231
232
|
});
|
|
232
233
|
|
|
@@ -256,7 +257,7 @@
|
|
|
256
257
|
```tsx
|
|
257
258
|
function App() {
|
|
258
259
|
function handleInnerTap(event: MainThread.TouchEvent) {
|
|
259
|
-
|
|
260
|
+
"main thread";
|
|
260
261
|
event.stopPropagation();
|
|
261
262
|
// Or stop immediate propagation with
|
|
262
263
|
// event.stopImmediatePropagation();
|
|
@@ -354,10 +355,10 @@
|
|
|
354
355
|
- Add `animate` API in Main Thread Script(MTS), so you can now control a CSS animation imperatively ([#1534](https://github.com/lynx-family/lynx-stack/pull/1534))
|
|
355
356
|
|
|
356
357
|
```ts
|
|
357
|
-
import type { MainThread } from
|
|
358
|
+
import type { MainThread } from "@lynx-js/types";
|
|
358
359
|
|
|
359
360
|
function startAnimation(ele: MainThread.Element) {
|
|
360
|
-
|
|
361
|
+
"main thread";
|
|
361
362
|
const animation = ele.animate([{ opacity: 0 }, { opacity: 1 }], {
|
|
362
363
|
duration: 3000,
|
|
363
364
|
});
|
|
@@ -386,13 +387,12 @@
|
|
|
386
387
|
- Supports `recyclable` attribute in `<list-item>` to control whether the list item is recyclable. The `recyclable` attribute depends on Lynx Engine 3.4 or later. ([#1388](https://github.com/lynx-family/lynx-stack/pull/1388))
|
|
387
388
|
|
|
388
389
|
```jsx
|
|
389
|
-
<list-item recyclable={false}
|
|
390
|
+
<list-item recyclable={false} />
|
|
390
391
|
```
|
|
391
392
|
|
|
392
393
|
- feat: Support using a host element as direct child of Suspense ([#1455](https://github.com/lynx-family/lynx-stack/pull/1455))
|
|
393
394
|
|
|
394
395
|
- Add profile in production build: ([#1336](https://github.com/lynx-family/lynx-stack/pull/1336))
|
|
395
|
-
|
|
396
396
|
1. `diff:__COMPONENT_NAME__`: how long ReactLynx diff took.
|
|
397
397
|
2. `render:__COMPONENT_NAME__`: how long your render function took.
|
|
398
398
|
3. `setState`: an instant trace event, indicate when your setState was called.
|
|
@@ -407,7 +407,7 @@
|
|
|
407
407
|
|
|
408
408
|
```ts
|
|
409
409
|
function handleTap() {
|
|
410
|
-
|
|
410
|
+
"main thread";
|
|
411
411
|
// The following check always returned false before this fix
|
|
412
412
|
if (myHandleTap) {
|
|
413
413
|
runOnBackground(myHandleTap)();
|
|
@@ -430,7 +430,6 @@
|
|
|
430
430
|
- feat: Force synchronous rendering for background initial renders to support Suspense fallbacks ([#1323](https://github.com/lynx-family/lynx-stack/pull/1323))
|
|
431
431
|
|
|
432
432
|
- Introduces `@lynx-js/react/compat` submodule exporting Preact implementations of: ([#1316](https://github.com/lynx-family/lynx-stack/pull/1316))
|
|
433
|
-
|
|
434
433
|
- `startTransition`
|
|
435
434
|
- `useTransition`
|
|
436
435
|
|
|
@@ -468,10 +467,10 @@
|
|
|
468
467
|
Add the import to `@lynx-js/react/debug` at the first line of the entry:
|
|
469
468
|
|
|
470
469
|
```js
|
|
471
|
-
import
|
|
472
|
-
import { root } from
|
|
470
|
+
import "@lynx-js/react/debug";
|
|
471
|
+
import { root } from "@lynx-js/react";
|
|
473
472
|
|
|
474
|
-
import { App } from
|
|
473
|
+
import { App } from "./App.jsx";
|
|
475
474
|
|
|
476
475
|
root.render(<App />);
|
|
477
476
|
```
|
|
@@ -481,9 +480,9 @@
|
|
|
481
480
|
For example, you can use it like this:
|
|
482
481
|
|
|
483
482
|
```jsx
|
|
484
|
-
<list-item defer={{ unmountRecycled: true }} item-key=
|
|
483
|
+
<list-item defer={{ unmountRecycled: true }} item-key="1">
|
|
485
484
|
<WillBeUnmountIfRecycled />
|
|
486
|
-
</list-item
|
|
485
|
+
</list-item>
|
|
487
486
|
```
|
|
488
487
|
|
|
489
488
|
Now the component will be unmounted when it is recycled, which can help with performance in certain scenarios.
|
|
@@ -491,7 +490,7 @@
|
|
|
491
490
|
- Avoid some unexpected `__SetAttribute` in hydrate when `undefined` is passed as an attribute value to intrinsic elements, for example: ([#1318](https://github.com/lynx-family/lynx-stack/pull/1318))
|
|
492
491
|
|
|
493
492
|
```jsx
|
|
494
|
-
<image async-mode={undefined}
|
|
493
|
+
<image async-mode={undefined} />
|
|
495
494
|
```
|
|
496
495
|
|
|
497
496
|
## 0.111.1
|
|
@@ -530,14 +529,13 @@
|
|
|
530
529
|
- Fixed: An issue where the `lynxViewDidUpdate` callback did not trigger when data was updated from native. ([#1171](https://github.com/lynx-family/lynx-stack/pull/1171))
|
|
531
530
|
|
|
532
531
|
Notice:
|
|
533
|
-
|
|
534
532
|
- Even if no data changes are actually processed after calling `updateData()`, the `lynxViewDidUpdate` callback will still be triggered.
|
|
535
533
|
- Only one `lynxViewDidUpdate` callback will be triggered per render cycle. Consequently, if multiple `updateData()` calls are made within a single cycle but the data updates are batched, the number of `lynxViewDidUpdate` callbacks triggered may be less than the number of `updateData()` calls.
|
|
536
534
|
|
|
537
535
|
- Supports `act` in testing library. ([#1182](https://github.com/lynx-family/lynx-stack/pull/1182))
|
|
538
536
|
|
|
539
537
|
```js
|
|
540
|
-
import { act } from
|
|
538
|
+
import { act } from "@lynx-js/react/testing-library";
|
|
541
539
|
|
|
542
540
|
act(() => {
|
|
543
541
|
// ...
|
|
@@ -557,14 +555,12 @@
|
|
|
557
555
|
- Fixed closure variable capture issue in effect hooks to prevent stale values and ensured proper execution order between refs, effects, and event handlers. ([#770](https://github.com/lynx-family/lynx-stack/pull/770))
|
|
558
556
|
|
|
559
557
|
**Breaking Changes**:
|
|
560
|
-
|
|
561
558
|
- The execution timing of `ref`, `useEffect()` callback, `componentDidMount`, `componentDidUpdate`, `componentWillUnmount` and the callback of `setState` have been moved forward. These effects will now execute before hydration is complete, rather than waiting for the main thread update to complete.
|
|
562
559
|
- For components inside `<list />`, `ref` callbacks will now be triggered during background thread rendering, regardless of component visibility. If your code depends on component visibility timing, use `main-thread:ref` instead of regular `ref`.
|
|
563
560
|
|
|
564
561
|
### Patch Changes
|
|
565
562
|
|
|
566
563
|
- Fixed two memory leaks: ([#1071](https://github.com/lynx-family/lynx-stack/pull/1071))
|
|
567
|
-
|
|
568
564
|
1. When JSX is rendered on the main thread and removed, FiberElement can still be referenced by `__root.__jsx` through `props.children`;
|
|
569
565
|
|
|
570
566
|
2. When the SnapshotInstance tree is removed from the root node, its child nodes form a cycle reference because the `__previousSibling` and `__nextSibling` properties point to each other, thus causing a FiberElement leak.
|
|
@@ -643,8 +639,7 @@
|
|
|
643
639
|
* 3: Full Resolution - Batch render with async property and element tree resolution for list item subtree
|
|
644
640
|
*/
|
|
645
641
|
experimental-batch-render-strategy={3}
|
|
646
|
-
>
|
|
647
|
-
</list>;
|
|
642
|
+
></list>
|
|
648
643
|
```
|
|
649
644
|
|
|
650
645
|
- rename @lynx-js/test-environment to @lynx-js/testing-environment ([#704](https://github.com/lynx-family/lynx-stack/pull/704))
|
|
@@ -670,7 +665,6 @@
|
|
|
670
665
|
### Minor Changes
|
|
671
666
|
|
|
672
667
|
- Some of the timing keys are renamed to match the naming convention of the Lynx Engine. ([#438](https://github.com/lynx-family/lynx-stack/pull/438))
|
|
673
|
-
|
|
674
668
|
- `update_set_state_trigger` -> `updateSetStateTrigger`
|
|
675
669
|
- `update_diff_vdom_start` -> `updateDiffVdomStart`
|
|
676
670
|
- `update_diff_vdom_end` -> `updateDiffVdomEnd`
|
|
@@ -762,7 +756,7 @@
|
|
|
762
756
|
You can now use `useErrorBoundary` it in TypeScript like this:
|
|
763
757
|
|
|
764
758
|
```tsx
|
|
765
|
-
import { useErrorBoundary } from
|
|
759
|
+
import { useErrorBoundary } from "@lynx-js/react";
|
|
766
760
|
```
|
|
767
761
|
|
|
768
762
|
- Modified the format of data sent from background threads to the main thread. ([#207](https://github.com/lynx-family/lynx-stack/pull/207))
|
|
@@ -814,13 +808,13 @@
|
|
|
814
808
|
Now you can get the return value from `runOnBackground()` and `runOnMainThread()`, which enables more flexible data flow between the main thread and the background thread.
|
|
815
809
|
|
|
816
810
|
```js
|
|
817
|
-
import { runOnBackground } from
|
|
811
|
+
import { runOnBackground } from "@lynx-js/react";
|
|
818
812
|
|
|
819
813
|
const onTap = async () => {
|
|
820
|
-
|
|
814
|
+
"main thread";
|
|
821
815
|
const text = await runOnBackground(() => {
|
|
822
|
-
|
|
823
|
-
return
|
|
816
|
+
"background only";
|
|
817
|
+
return "Hello, world!";
|
|
824
818
|
})();
|
|
825
819
|
console.log(text);
|
|
826
820
|
};
|
|
@@ -855,9 +849,9 @@
|
|
|
855
849
|
|
|
856
850
|
```ts
|
|
857
851
|
// These imports will be removed from the final bundle
|
|
858
|
-
import type { Foo } from
|
|
859
|
-
import { type Bar } from
|
|
860
|
-
import { xyz } from
|
|
852
|
+
import type { Foo } from "xyz";
|
|
853
|
+
import { type Bar } from "xyz";
|
|
854
|
+
import { xyz } from "xyz"; // When xyz is not used
|
|
861
855
|
```
|
|
862
856
|
|
|
863
857
|
See [TypeScript - verbatimModuleSyntax](https://www.typescriptlang.org/tsconfig/#verbatimModuleSyntax) for details.
|
|
@@ -897,7 +891,7 @@
|
|
|
897
891
|
const f = undefined;
|
|
898
892
|
|
|
899
893
|
function mts() {
|
|
900
|
-
|
|
894
|
+
"main thread";
|
|
901
895
|
// throws in background rendering
|
|
902
896
|
f && runOnBackground(f)();
|
|
903
897
|
}
|
|
@@ -931,14 +925,14 @@
|
|
|
931
925
|
- a30c83d: Add `compat.removeComponentAttrRegex`.
|
|
932
926
|
|
|
933
927
|
```js
|
|
934
|
-
import { pluginReactLynx } from
|
|
935
|
-
import { defineConfig } from
|
|
928
|
+
import { pluginReactLynx } from "@lynx-js/react-rsbuild-plugin";
|
|
929
|
+
import { defineConfig } from "@lynx-js/rspeedy";
|
|
936
930
|
|
|
937
931
|
export default defineConfig({
|
|
938
932
|
plugins: [
|
|
939
933
|
pluginReactLynx({
|
|
940
934
|
compat: {
|
|
941
|
-
removeComponentAttrRegex:
|
|
935
|
+
removeComponentAttrRegex: "YOUR REGEX",
|
|
942
936
|
},
|
|
943
937
|
}),
|
|
944
938
|
],
|
|
@@ -1015,7 +1009,6 @@
|
|
|
1015
1009
|
</table>
|
|
1016
1010
|
|
|
1017
1011
|
This requires `@lynx-js/react-rsbuild-plugin` v0.5.1 to work.
|
|
1018
|
-
|
|
1019
1012
|
- Inject `globDynamicComponentEntry` for background script. ([#311](https://github.com/lynx-wg/lynx-stack/pull/311))
|
|
1020
1013
|
- Inject `globDynamicComponentEntry` for main thread script. ([#312](https://github.com/lynx-wg/lynx-stack/pull/312))
|
|
1021
1014
|
|
|
@@ -1024,22 +1017,22 @@
|
|
|
1024
1017
|
Gesture Handler is a set of gesture handling capabilities built on top of the Main Thread Script. It currently supports drag, inertial scrolling, long press, and tap gestures for `<view>`, `<scroll-view>`, `<list>`, and `<text>`. In the future, it will also support multi-finger zoom, multi-finger rotation, and other gesture capabilities.
|
|
1025
1018
|
|
|
1026
1019
|
```tsx
|
|
1027
|
-
import { useGesture, PanGesture } from
|
|
1020
|
+
import { useGesture, PanGesture } from "@lynx-js/gesture-runtime";
|
|
1028
1021
|
|
|
1029
1022
|
function App() {
|
|
1030
1023
|
const pan = useGesture(PanGesture);
|
|
1031
1024
|
|
|
1032
1025
|
pan
|
|
1033
1026
|
.onBegin((event, stateManager) => {
|
|
1034
|
-
|
|
1027
|
+
"main thread";
|
|
1035
1028
|
// some logic
|
|
1036
1029
|
})
|
|
1037
1030
|
.onUpdate((event, stateManager) => {
|
|
1038
|
-
|
|
1031
|
+
"main thread";
|
|
1039
1032
|
// some logic
|
|
1040
1033
|
})
|
|
1041
1034
|
.onEnd((event, stateManager) => {
|
|
1042
|
-
|
|
1035
|
+
"main thread";
|
|
1043
1036
|
// some logic
|
|
1044
1037
|
});
|
|
1045
1038
|
|
|
@@ -1059,7 +1052,7 @@
|
|
|
1059
1052
|
return;
|
|
1060
1053
|
}
|
|
1061
1054
|
|
|
1062
|
-
console.log(
|
|
1055
|
+
console.log("not __LEPUS__"); // This can be removed now
|
|
1063
1056
|
}
|
|
1064
1057
|
```
|
|
1065
1058
|
|
package/package.json
CHANGED
|
@@ -10,7 +10,9 @@
|
|
|
10
10
|
* @param element - The element
|
|
11
11
|
*/
|
|
12
12
|
export function onWorkletCtxUpdate(worklet, oldWorklet, isFirstScreen, element) {
|
|
13
|
-
|
|
13
|
+
if (worklet._execId !== undefined) {
|
|
14
|
+
globalThis.lynxWorkletImpl?._jsFunctionLifecycleManager?.addRef(worklet._execId, worklet);
|
|
15
|
+
}
|
|
14
16
|
if (isFirstScreen && oldWorklet) {
|
|
15
17
|
globalThis.lynxWorkletImpl?._hydrateCtx(worklet, oldWorklet);
|
|
16
18
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"observers.js","sourceRoot":"","sources":["../../src/bindings/observers.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAI1D;;;;;;;GAOG;AACH,MAAM,UAAU,kBAAkB,CAChC,OAAgB,EAChB,UAAsC,EACtC,aAAsB,EACtB,OAAoB;IAEpB,UAAU,CAAC,eAAe,EAAE,2BAA2B,EAAE,MAAM,CAAC,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"observers.js","sourceRoot":"","sources":["../../src/bindings/observers.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAI1D;;;;;;;GAOG;AACH,MAAM,UAAU,kBAAkB,CAChC,OAAgB,EAChB,UAAsC,EACtC,aAAsB,EACtB,OAAoB;IAEpB,IAAI,OAAO,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;QAClC,UAAU,CAAC,eAAe,EAAE,2BAA2B,EAAE,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC5F,CAAC;IACD,IAAI,aAAa,IAAI,UAAU,EAAE,CAAC;QAChC,UAAU,CAAC,eAAe,EAAE,WAAW,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;IAC/D,CAAC;IACD,mDAAmD;IACnD,IAAI,aAAa,EAAE,CAAC;QAClB,UAAU,CAAC,eAAe,EAAE,eAAe,CAAC,iBAAiB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAClF,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,mBAAmB;IACjC,UAAU,CAAC,eAAe,EAAE,yBAAyB,CAAC,6BAA6B,EAAE,CAAC;IACtF,UAAU,CAAC,eAAe,EAAE,QAAQ,CAAC,6BAA6B,EAAE,CAAC;IACrE,mDAAmD;IACnD,UAAU,CAAC,eAAe,EAAE,eAAe,CAAC,oBAAoB,EAAE,CAAC;AACrE,CAAC"}
|