@lynx-js/react-canary 0.114.1 → 0.114.2-canary-20251010-e21c4e23
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 +36 -31
- package/package.json +2 -2
- package/testing-library/dist/index.d.ts +0 -2
- package/transform/dist/wasm.cjs +1 -1
- package/worklet-runtime/dist/dev.js +10 -2
- package/worklet-runtime/dist/main.js +1 -1
- package/worklet-runtime/lib/hydrate.js +9 -2
- package/worklet-runtime/lib/hydrate.js.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @lynx-js/react
|
|
2
2
|
|
|
3
|
+
## 0.114.2-canary-20251010135203-e21c4e23ca87c0783faaa4cfd2f8dfe6ca6d84eb
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- fix: main thread functions created during the initial render cannot correctly call `runOnBackground()` after hydration ([#1878](https://github.com/lynx-family/lynx-stack/pull/1878))
|
|
8
|
+
|
|
3
9
|
## 0.114.1
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
|
@@ -9,7 +15,7 @@
|
|
|
9
15
|
```tsx
|
|
10
16
|
function App() {
|
|
11
17
|
function handleInnerTap(event: MainThread.TouchEvent) {
|
|
12
|
-
|
|
18
|
+
"main thread";
|
|
13
19
|
event.stopPropagation();
|
|
14
20
|
// Or stop immediate propagation with
|
|
15
21
|
// event.stopImmediatePropagation();
|
|
@@ -107,10 +113,10 @@
|
|
|
107
113
|
- 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))
|
|
108
114
|
|
|
109
115
|
```ts
|
|
110
|
-
import type { MainThread } from
|
|
116
|
+
import type { MainThread } from "@lynx-js/types";
|
|
111
117
|
|
|
112
118
|
function startAnimation(ele: MainThread.Element) {
|
|
113
|
-
|
|
119
|
+
"main thread";
|
|
114
120
|
const animation = ele.animate([{ opacity: 0 }, { opacity: 1 }], {
|
|
115
121
|
duration: 3000,
|
|
116
122
|
});
|
|
@@ -139,7 +145,7 @@
|
|
|
139
145
|
- 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))
|
|
140
146
|
|
|
141
147
|
```jsx
|
|
142
|
-
<list-item recyclable={false}
|
|
148
|
+
<list-item recyclable={false} />
|
|
143
149
|
```
|
|
144
150
|
|
|
145
151
|
- feat: Support using a host element as direct child of Suspense ([#1455](https://github.com/lynx-family/lynx-stack/pull/1455))
|
|
@@ -160,7 +166,7 @@
|
|
|
160
166
|
|
|
161
167
|
```ts
|
|
162
168
|
function handleTap() {
|
|
163
|
-
|
|
169
|
+
"main thread";
|
|
164
170
|
// The following check always returned false before this fix
|
|
165
171
|
if (myHandleTap) {
|
|
166
172
|
runOnBackground(myHandleTap)();
|
|
@@ -221,10 +227,10 @@
|
|
|
221
227
|
Add the import to `@lynx-js/react/debug` at the first line of the entry:
|
|
222
228
|
|
|
223
229
|
```js
|
|
224
|
-
import
|
|
225
|
-
import { root } from
|
|
230
|
+
import "@lynx-js/react/debug";
|
|
231
|
+
import { root } from "@lynx-js/react";
|
|
226
232
|
|
|
227
|
-
import { App } from
|
|
233
|
+
import { App } from "./App.jsx";
|
|
228
234
|
|
|
229
235
|
root.render(<App />);
|
|
230
236
|
```
|
|
@@ -234,9 +240,9 @@
|
|
|
234
240
|
For example, you can use it like this:
|
|
235
241
|
|
|
236
242
|
```jsx
|
|
237
|
-
<list-item defer={{ unmountRecycled: true }} item-key=
|
|
243
|
+
<list-item defer={{ unmountRecycled: true }} item-key="1">
|
|
238
244
|
<WillBeUnmountIfRecycled />
|
|
239
|
-
</list-item
|
|
245
|
+
</list-item>
|
|
240
246
|
```
|
|
241
247
|
|
|
242
248
|
Now the component will be unmounted when it is recycled, which can help with performance in certain scenarios.
|
|
@@ -244,7 +250,7 @@
|
|
|
244
250
|
- 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))
|
|
245
251
|
|
|
246
252
|
```jsx
|
|
247
|
-
<image async-mode={undefined}
|
|
253
|
+
<image async-mode={undefined} />
|
|
248
254
|
```
|
|
249
255
|
|
|
250
256
|
## 0.111.1
|
|
@@ -290,7 +296,7 @@
|
|
|
290
296
|
- Supports `act` in testing library. ([#1182](https://github.com/lynx-family/lynx-stack/pull/1182))
|
|
291
297
|
|
|
292
298
|
```js
|
|
293
|
-
import { act } from
|
|
299
|
+
import { act } from "@lynx-js/react/testing-library";
|
|
294
300
|
|
|
295
301
|
act(() => {
|
|
296
302
|
// ...
|
|
@@ -396,8 +402,7 @@
|
|
|
396
402
|
* 3: Full Resolution - Batch render with async property and element tree resolution for list item subtree
|
|
397
403
|
*/
|
|
398
404
|
experimental-batch-render-strategy={3}
|
|
399
|
-
>
|
|
400
|
-
</list>;
|
|
405
|
+
></list>
|
|
401
406
|
```
|
|
402
407
|
|
|
403
408
|
- rename @lynx-js/test-environment to @lynx-js/testing-environment ([#704](https://github.com/lynx-family/lynx-stack/pull/704))
|
|
@@ -515,7 +520,7 @@
|
|
|
515
520
|
You can now use `useErrorBoundary` it in TypeScript like this:
|
|
516
521
|
|
|
517
522
|
```tsx
|
|
518
|
-
import { useErrorBoundary } from
|
|
523
|
+
import { useErrorBoundary } from "@lynx-js/react";
|
|
519
524
|
```
|
|
520
525
|
|
|
521
526
|
- Modified the format of data sent from background threads to the main thread. ([#207](https://github.com/lynx-family/lynx-stack/pull/207))
|
|
@@ -567,13 +572,13 @@
|
|
|
567
572
|
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.
|
|
568
573
|
|
|
569
574
|
```js
|
|
570
|
-
import { runOnBackground } from
|
|
575
|
+
import { runOnBackground } from "@lynx-js/react";
|
|
571
576
|
|
|
572
577
|
const onTap = async () => {
|
|
573
|
-
|
|
578
|
+
"main thread";
|
|
574
579
|
const text = await runOnBackground(() => {
|
|
575
|
-
|
|
576
|
-
return
|
|
580
|
+
"background only";
|
|
581
|
+
return "Hello, world!";
|
|
577
582
|
})();
|
|
578
583
|
console.log(text);
|
|
579
584
|
};
|
|
@@ -608,9 +613,9 @@
|
|
|
608
613
|
|
|
609
614
|
```ts
|
|
610
615
|
// These imports will be removed from the final bundle
|
|
611
|
-
import type { Foo } from
|
|
612
|
-
import { type Bar } from
|
|
613
|
-
import { xyz } from
|
|
616
|
+
import type { Foo } from "xyz";
|
|
617
|
+
import { type Bar } from "xyz";
|
|
618
|
+
import { xyz } from "xyz"; // When xyz is not used
|
|
614
619
|
```
|
|
615
620
|
|
|
616
621
|
See [TypeScript - verbatimModuleSyntax](https://www.typescriptlang.org/tsconfig/#verbatimModuleSyntax) for details.
|
|
@@ -650,7 +655,7 @@
|
|
|
650
655
|
const f = undefined;
|
|
651
656
|
|
|
652
657
|
function mts() {
|
|
653
|
-
|
|
658
|
+
"main thread";
|
|
654
659
|
// throws in background rendering
|
|
655
660
|
f && runOnBackground(f)();
|
|
656
661
|
}
|
|
@@ -684,14 +689,14 @@
|
|
|
684
689
|
- a30c83d: Add `compat.removeComponentAttrRegex`.
|
|
685
690
|
|
|
686
691
|
```js
|
|
687
|
-
import { pluginReactLynx } from
|
|
688
|
-
import { defineConfig } from
|
|
692
|
+
import { pluginReactLynx } from "@lynx-js/react-rsbuild-plugin";
|
|
693
|
+
import { defineConfig } from "@lynx-js/rspeedy";
|
|
689
694
|
|
|
690
695
|
export default defineConfig({
|
|
691
696
|
plugins: [
|
|
692
697
|
pluginReactLynx({
|
|
693
698
|
compat: {
|
|
694
|
-
removeComponentAttrRegex:
|
|
699
|
+
removeComponentAttrRegex: "YOUR REGEX",
|
|
695
700
|
},
|
|
696
701
|
}),
|
|
697
702
|
],
|
|
@@ -777,22 +782,22 @@
|
|
|
777
782
|
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.
|
|
778
783
|
|
|
779
784
|
```tsx
|
|
780
|
-
import { useGesture, PanGesture } from
|
|
785
|
+
import { useGesture, PanGesture } from "@lynx-js/gesture-runtime";
|
|
781
786
|
|
|
782
787
|
function App() {
|
|
783
788
|
const pan = useGesture(PanGesture);
|
|
784
789
|
|
|
785
790
|
pan
|
|
786
791
|
.onBegin((event, stateManager) => {
|
|
787
|
-
|
|
792
|
+
"main thread";
|
|
788
793
|
// some logic
|
|
789
794
|
})
|
|
790
795
|
.onUpdate((event, stateManager) => {
|
|
791
|
-
|
|
796
|
+
"main thread";
|
|
792
797
|
// some logic
|
|
793
798
|
})
|
|
794
799
|
.onEnd((event, stateManager) => {
|
|
795
|
-
|
|
800
|
+
"main thread";
|
|
796
801
|
// some logic
|
|
797
802
|
});
|
|
798
803
|
|
|
@@ -812,7 +817,7 @@
|
|
|
812
817
|
return;
|
|
813
818
|
}
|
|
814
819
|
|
|
815
|
-
console.log(
|
|
820
|
+
console.log("not __LEPUS__"); // This can be removed now
|
|
816
821
|
}
|
|
817
822
|
```
|
|
818
823
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lynx-js/react-canary",
|
|
3
|
-
"version": "0.114.
|
|
3
|
+
"version": "0.114.2-canary-20251010-e21c4e23",
|
|
4
4
|
"description": "ReactLynx is a framework for developing Lynx applications with familiar React.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -176,7 +176,7 @@
|
|
|
176
176
|
"devDependencies": {
|
|
177
177
|
"@lynx-js/types": "3.4.11",
|
|
178
178
|
"@microsoft/api-extractor": "7.52.15",
|
|
179
|
-
"@types/react": "^18.3.
|
|
179
|
+
"@types/react": "^18.3.25"
|
|
180
180
|
},
|
|
181
181
|
"peerDependencies": {
|
|
182
182
|
"@lynx-js/types": "*",
|
|
@@ -970,8 +970,6 @@ export declare class LynxTestingEnv {
|
|
|
970
970
|
injectGlobals(): void;
|
|
971
971
|
switchToBackgroundThread(): void;
|
|
972
972
|
switchToMainThread(): void;
|
|
973
|
-
// we do not use it because we have to keep background thread
|
|
974
|
-
// otherwise we will get error on __MAIN_THREAD__/__BACKGROUND__/lynx not defined etc.
|
|
975
973
|
clearGlobal(): void;
|
|
976
974
|
reset(): void;
|
|
977
975
|
}
|