@lynx-js/react-canary 0.123.2-canary-20260731-46dfcc21 → 0.123.2
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 +52 -51
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @lynx-js/react
|
|
2
2
|
|
|
3
|
-
## 0.123.2
|
|
3
|
+
## 0.123.2
|
|
4
4
|
|
|
5
5
|
### Patch Changes
|
|
6
6
|
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
screen blocks on the fetch with the `mode` import attribute:
|
|
39
39
|
|
|
40
40
|
```js
|
|
41
|
-
import(
|
|
42
|
-
import(
|
|
41
|
+
import('./Foo.jsx', { with: { mode: 'sync' } }); // block the first screen
|
|
42
|
+
import('./Foo.jsx', { with: { mode: 'async' } }); // default, non-blocking
|
|
43
43
|
```
|
|
44
44
|
|
|
45
45
|
Enable it by setting `engineVersion: '3.9'` (or higher) in `pluginReactLynx`. The
|
|
@@ -52,12 +52,12 @@
|
|
|
52
52
|
|
|
53
53
|
```js
|
|
54
54
|
pluginReactLynx({
|
|
55
|
-
firstScreenSyncTiming:
|
|
55
|
+
firstScreenSyncTiming: 'manual',
|
|
56
56
|
});
|
|
57
57
|
```
|
|
58
58
|
|
|
59
59
|
```js
|
|
60
|
-
import { markFirstScreenSyncReady } from
|
|
60
|
+
import { markFirstScreenSyncReady } from '@lynx-js/react';
|
|
61
61
|
|
|
62
62
|
markFirstScreenSyncReady();
|
|
63
63
|
```
|
|
@@ -67,8 +67,8 @@
|
|
|
67
67
|
- Add `compat.legacySlot` to `pluginReactLynx`. When enabled, dynamic children are compiled to the pre-SlotV2 form (JSX `children` + `wrapper` elements + `__DynamicPartChildren`/`__DynamicPartSlot` symbols instead of `$0`/`$1` slot props + `SlotV2`), so the compiled output stays compatible with legacy runtimes without `SlotV2` support (`< 0.120.0`, which shipped the SlotV2 refactor in #1764) — e.g. a standalone lazy bundle consumed by a host App that ships an older runtime. ([#2947](https://github.com/lynx-family/lynx-stack/pull/2947))
|
|
68
68
|
|
|
69
69
|
```js
|
|
70
|
-
import { defineConfig } from
|
|
71
|
-
import { pluginReactLynx } from
|
|
70
|
+
import { defineConfig } from '@lynx-js/rspeedy';
|
|
71
|
+
import { pluginReactLynx } from '@lynx-js/react-rsbuild-plugin';
|
|
72
72
|
|
|
73
73
|
export default defineConfig({
|
|
74
74
|
plugins: [
|
|
@@ -150,13 +150,13 @@
|
|
|
150
150
|
Previously, the compat transform could short-circuit while scanning opening attributes and treat:
|
|
151
151
|
|
|
152
152
|
```jsx
|
|
153
|
-
<Component removeComponentElement={true} {...props}
|
|
153
|
+
<Component removeComponentElement={true} {...props} />;
|
|
154
154
|
```
|
|
155
155
|
|
|
156
156
|
differently from:
|
|
157
157
|
|
|
158
158
|
```jsx
|
|
159
|
-
<Component {...props} removeComponentElement={true}
|
|
159
|
+
<Component {...props} removeComponentElement={true} />;
|
|
160
160
|
```
|
|
161
161
|
|
|
162
162
|
The transform now collects the full opening-attribute state first, so both prop orders compile the same way in normal and `compilerOnly` modes.
|
|
@@ -182,7 +182,7 @@
|
|
|
182
182
|
- Support `React.createElement(type, props, children)` API. ([#2360](https://github.com/lynx-family/lynx-stack/pull/2360))
|
|
183
183
|
|
|
184
184
|
```jsx
|
|
185
|
-
React.createElement(
|
|
185
|
+
React.createElement('view', { style }, <text>hello</text>);
|
|
186
186
|
// equivalent to
|
|
187
187
|
<view style={style}>
|
|
188
188
|
<text>hello</text>
|
|
@@ -275,8 +275,8 @@
|
|
|
275
275
|
Create a config file `rstest.config.ts` with the following content:
|
|
276
276
|
|
|
277
277
|
```ts
|
|
278
|
-
import { defineConfig } from
|
|
279
|
-
import { withLynxConfig } from
|
|
278
|
+
import { defineConfig } from '@rstest/core';
|
|
279
|
+
import { withLynxConfig } from '@lynx-js/react/testing-library/rstest-config';
|
|
280
280
|
|
|
281
281
|
export default defineConfig({
|
|
282
282
|
extends: withLynxConfig(),
|
|
@@ -448,9 +448,9 @@
|
|
|
448
448
|
|
|
449
449
|
```typescript
|
|
450
450
|
function getStyle(ele: MainThread.Element) {
|
|
451
|
-
|
|
452
|
-
const width = ele.getComputedStyleProperty(
|
|
453
|
-
const transformMatrix = ele.getComputedStyleProperty(
|
|
451
|
+
'main thread';
|
|
452
|
+
const width = ele.getComputedStyleProperty('width'); // Returns 300px
|
|
453
|
+
const transformMatrix = ele.getComputedStyleProperty('transform'); // Returns matrix(2, 0, 0, 2, 200, 400)
|
|
454
454
|
}
|
|
455
455
|
```
|
|
456
456
|
|
|
@@ -465,7 +465,7 @@
|
|
|
465
465
|
```ts
|
|
466
466
|
const LazyComponent = lazy(async () => {
|
|
467
467
|
try {
|
|
468
|
-
const mod = await import(
|
|
468
|
+
const mod = await import('./lazy-bundle');
|
|
469
469
|
return mod.default;
|
|
470
470
|
} catch (error) {
|
|
471
471
|
console.error(`Lazy Bundle load failed message: ${error.message}`);
|
|
@@ -497,10 +497,10 @@
|
|
|
497
497
|
- Usage: Add `with { runtime: "shared" }` to the `import` statement. For example:
|
|
498
498
|
|
|
499
499
|
```ts
|
|
500
|
-
import { func } from
|
|
500
|
+
import { func } from './utils.js' with { runtime: 'shared' };
|
|
501
501
|
|
|
502
502
|
function worklet() {
|
|
503
|
-
|
|
503
|
+
'main thread';
|
|
504
504
|
func(); // callable inside a main thread function
|
|
505
505
|
}
|
|
506
506
|
```
|
|
@@ -577,11 +577,11 @@
|
|
|
577
577
|
- 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))
|
|
578
578
|
|
|
579
579
|
```js
|
|
580
|
-
import { defineConfig, mergeConfig } from
|
|
581
|
-
import { createVitestConfig } from
|
|
580
|
+
import { defineConfig, mergeConfig } from 'vitest/config';
|
|
581
|
+
import { createVitestConfig } from '@lynx-js/react/testing-library/vitest-config';
|
|
582
582
|
|
|
583
583
|
const defaultConfig = await createVitestConfig({
|
|
584
|
-
runtimePkgName:
|
|
584
|
+
runtimePkgName: '@lynx-js/react',
|
|
585
585
|
experimental_enableReactCompiler: true,
|
|
586
586
|
});
|
|
587
587
|
|
|
@@ -611,7 +611,7 @@
|
|
|
611
611
|
```tsx
|
|
612
612
|
function App() {
|
|
613
613
|
function handleInnerTap(event: MainThread.TouchEvent) {
|
|
614
|
-
|
|
614
|
+
'main thread';
|
|
615
615
|
event.stopPropagation();
|
|
616
616
|
// Or stop immediate propagation with
|
|
617
617
|
// event.stopImmediatePropagation();
|
|
@@ -709,10 +709,10 @@
|
|
|
709
709
|
- 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))
|
|
710
710
|
|
|
711
711
|
```ts
|
|
712
|
-
import type { MainThread } from
|
|
712
|
+
import type { MainThread } from '@lynx-js/types';
|
|
713
713
|
|
|
714
714
|
function startAnimation(ele: MainThread.Element) {
|
|
715
|
-
|
|
715
|
+
'main thread';
|
|
716
716
|
const animation = ele.animate([{ opacity: 0 }, { opacity: 1 }], {
|
|
717
717
|
duration: 3000,
|
|
718
718
|
});
|
|
@@ -741,7 +741,7 @@
|
|
|
741
741
|
- 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))
|
|
742
742
|
|
|
743
743
|
```jsx
|
|
744
|
-
<list-item recyclable={false}
|
|
744
|
+
<list-item recyclable={false} />;
|
|
745
745
|
```
|
|
746
746
|
|
|
747
747
|
- feat: Support using a host element as direct child of Suspense ([#1455](https://github.com/lynx-family/lynx-stack/pull/1455))
|
|
@@ -762,7 +762,7 @@
|
|
|
762
762
|
|
|
763
763
|
```ts
|
|
764
764
|
function handleTap() {
|
|
765
|
-
|
|
765
|
+
'main thread';
|
|
766
766
|
// The following check always returned false before this fix
|
|
767
767
|
if (myHandleTap) {
|
|
768
768
|
runOnBackground(myHandleTap)();
|
|
@@ -823,10 +823,10 @@
|
|
|
823
823
|
Add the import to `@lynx-js/react/debug` at the first line of the entry:
|
|
824
824
|
|
|
825
825
|
```js
|
|
826
|
-
import
|
|
827
|
-
import { root } from
|
|
826
|
+
import '@lynx-js/react/debug';
|
|
827
|
+
import { root } from '@lynx-js/react';
|
|
828
828
|
|
|
829
|
-
import { App } from
|
|
829
|
+
import { App } from './App.jsx';
|
|
830
830
|
|
|
831
831
|
root.render(<App />);
|
|
832
832
|
```
|
|
@@ -836,9 +836,9 @@
|
|
|
836
836
|
For example, you can use it like this:
|
|
837
837
|
|
|
838
838
|
```jsx
|
|
839
|
-
<list-item defer={{ unmountRecycled: true }} item-key=
|
|
839
|
+
<list-item defer={{ unmountRecycled: true }} item-key='1'>
|
|
840
840
|
<WillBeUnmountIfRecycled />
|
|
841
|
-
</list-item
|
|
841
|
+
</list-item>;
|
|
842
842
|
```
|
|
843
843
|
|
|
844
844
|
Now the component will be unmounted when it is recycled, which can help with performance in certain scenarios.
|
|
@@ -846,7 +846,7 @@
|
|
|
846
846
|
- 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))
|
|
847
847
|
|
|
848
848
|
```jsx
|
|
849
|
-
<image async-mode={undefined}
|
|
849
|
+
<image async-mode={undefined} />;
|
|
850
850
|
```
|
|
851
851
|
|
|
852
852
|
## 0.111.1
|
|
@@ -892,7 +892,7 @@
|
|
|
892
892
|
- Supports `act` in testing library. ([#1182](https://github.com/lynx-family/lynx-stack/pull/1182))
|
|
893
893
|
|
|
894
894
|
```js
|
|
895
|
-
import { act } from
|
|
895
|
+
import { act } from '@lynx-js/react/testing-library';
|
|
896
896
|
|
|
897
897
|
act(() => {
|
|
898
898
|
// ...
|
|
@@ -998,7 +998,8 @@
|
|
|
998
998
|
* 3: Full Resolution - Batch render with async property and element tree resolution for list item subtree
|
|
999
999
|
*/
|
|
1000
1000
|
experimental-batch-render-strategy={3}
|
|
1001
|
-
|
|
1001
|
+
>
|
|
1002
|
+
</list>;
|
|
1002
1003
|
```
|
|
1003
1004
|
|
|
1004
1005
|
- rename @lynx-js/test-environment to @lynx-js/testing-environment ([#704](https://github.com/lynx-family/lynx-stack/pull/704))
|
|
@@ -1116,7 +1117,7 @@
|
|
|
1116
1117
|
You can now use `useErrorBoundary` it in TypeScript like this:
|
|
1117
1118
|
|
|
1118
1119
|
```tsx
|
|
1119
|
-
import { useErrorBoundary } from
|
|
1120
|
+
import { useErrorBoundary } from '@lynx-js/react';
|
|
1120
1121
|
```
|
|
1121
1122
|
|
|
1122
1123
|
- Modified the format of data sent from background threads to the main thread. ([#207](https://github.com/lynx-family/lynx-stack/pull/207))
|
|
@@ -1168,13 +1169,13 @@
|
|
|
1168
1169
|
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.
|
|
1169
1170
|
|
|
1170
1171
|
```js
|
|
1171
|
-
import { runOnBackground } from
|
|
1172
|
+
import { runOnBackground } from '@lynx-js/react';
|
|
1172
1173
|
|
|
1173
1174
|
const onTap = async () => {
|
|
1174
|
-
|
|
1175
|
+
'main thread';
|
|
1175
1176
|
const text = await runOnBackground(() => {
|
|
1176
|
-
|
|
1177
|
-
return
|
|
1177
|
+
'background only';
|
|
1178
|
+
return 'Hello, world!';
|
|
1178
1179
|
})();
|
|
1179
1180
|
console.log(text);
|
|
1180
1181
|
};
|
|
@@ -1209,9 +1210,9 @@
|
|
|
1209
1210
|
|
|
1210
1211
|
```ts
|
|
1211
1212
|
// These imports will be removed from the final bundle
|
|
1212
|
-
import type { Foo } from
|
|
1213
|
-
import { type Bar } from
|
|
1214
|
-
import { xyz } from
|
|
1213
|
+
import type { Foo } from 'xyz';
|
|
1214
|
+
import { type Bar } from 'xyz';
|
|
1215
|
+
import { xyz } from 'xyz'; // When xyz is not used
|
|
1215
1216
|
```
|
|
1216
1217
|
|
|
1217
1218
|
See [TypeScript - verbatimModuleSyntax](https://www.typescriptlang.org/tsconfig/#verbatimModuleSyntax) for details.
|
|
@@ -1251,7 +1252,7 @@
|
|
|
1251
1252
|
const f = undefined;
|
|
1252
1253
|
|
|
1253
1254
|
function mts() {
|
|
1254
|
-
|
|
1255
|
+
'main thread';
|
|
1255
1256
|
// throws in background rendering
|
|
1256
1257
|
f && runOnBackground(f)();
|
|
1257
1258
|
}
|
|
@@ -1285,14 +1286,14 @@
|
|
|
1285
1286
|
- a30c83d: Add `compat.removeComponentAttrRegex`.
|
|
1286
1287
|
|
|
1287
1288
|
```js
|
|
1288
|
-
import { pluginReactLynx } from
|
|
1289
|
-
import { defineConfig } from
|
|
1289
|
+
import { pluginReactLynx } from '@lynx-js/react-rsbuild-plugin';
|
|
1290
|
+
import { defineConfig } from '@lynx-js/rspeedy';
|
|
1290
1291
|
|
|
1291
1292
|
export default defineConfig({
|
|
1292
1293
|
plugins: [
|
|
1293
1294
|
pluginReactLynx({
|
|
1294
1295
|
compat: {
|
|
1295
|
-
removeComponentAttrRegex:
|
|
1296
|
+
removeComponentAttrRegex: 'YOUR REGEX',
|
|
1296
1297
|
},
|
|
1297
1298
|
}),
|
|
1298
1299
|
],
|
|
@@ -1378,22 +1379,22 @@
|
|
|
1378
1379
|
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.
|
|
1379
1380
|
|
|
1380
1381
|
```tsx
|
|
1381
|
-
import { useGesture, PanGesture } from
|
|
1382
|
+
import { useGesture, PanGesture } from '@lynx-js/gesture-runtime';
|
|
1382
1383
|
|
|
1383
1384
|
function App() {
|
|
1384
1385
|
const pan = useGesture(PanGesture);
|
|
1385
1386
|
|
|
1386
1387
|
pan
|
|
1387
1388
|
.onBegin((event, stateManager) => {
|
|
1388
|
-
|
|
1389
|
+
'main thread';
|
|
1389
1390
|
// some logic
|
|
1390
1391
|
})
|
|
1391
1392
|
.onUpdate((event, stateManager) => {
|
|
1392
|
-
|
|
1393
|
+
'main thread';
|
|
1393
1394
|
// some logic
|
|
1394
1395
|
})
|
|
1395
1396
|
.onEnd((event, stateManager) => {
|
|
1396
|
-
|
|
1397
|
+
'main thread';
|
|
1397
1398
|
// some logic
|
|
1398
1399
|
});
|
|
1399
1400
|
|
|
@@ -1413,7 +1414,7 @@
|
|
|
1413
1414
|
return;
|
|
1414
1415
|
}
|
|
1415
1416
|
|
|
1416
|
-
console.log(
|
|
1417
|
+
console.log('not __LEPUS__'); // This can be removed now
|
|
1417
1418
|
}
|
|
1418
1419
|
```
|
|
1419
1420
|
|
package/package.json
CHANGED