@lynx-js/react 0.129.2 → 0.129.3
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 +8 -0
- package/package.json +1 -1
- package/runtime/__test__/snapshot/compat/export.test.jsx +8 -2
- package/runtime/__test__/worklet-runtime/initEntry.test.js +12 -0
- package/runtime/compat/index.d.ts +17 -1
- package/runtime/compat/index.js +3 -2
- package/runtime/lazy/compat.js +1 -0
- package/runtime/lib/tsconfig.tsbuildinfo +1 -1
- package/runtime/lib/worklet-runtime/utils/version.js +4 -1
- package/runtime/lib/worklet-runtime/utils/version.js.map +1 -1
- package/runtime/src/worklet-runtime/utils/version.ts +4 -1
- package/testing-library/.turbo/turbo-build.log +6 -6
- package/transform/.turbo/turbo-build$colon$wasm.log +85 -198
- package/transform/swc-plugin-reactlynx/.turbo/turbo-build.log +128 -155
- package/transform/swc-plugin-reactlynx-compat/.turbo/turbo-build.log +289 -177
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @lynx-js/react
|
|
2
2
|
|
|
3
|
+
## 0.129.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Export `useDeferredValue` from `@lynx-js/react/compat`. It is Preact's implementation, so it has no concurrent rendering. ([#4327](https://github.com/lynx-family/lynx-stack/pull/4327))
|
|
8
|
+
|
|
9
|
+
- Allow the worklet runtime to read the SDK version from `lynx.SystemInfo` when it initializes before the global `SystemInfo` alias is available. ([#4342](https://github.com/lynx-family/lynx-stack/pull/4342))
|
|
10
|
+
|
|
3
11
|
## 0.129.2
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -3,6 +3,7 @@ import ReactLynx from '@lynx-js/react';
|
|
|
3
3
|
import {
|
|
4
4
|
startTransition as preactStartTransition,
|
|
5
5
|
use as preactUse,
|
|
6
|
+
useDeferredValue as preactUseDeferredValue,
|
|
6
7
|
useTransition as preactUseTransition,
|
|
7
8
|
} from 'preact/compat';
|
|
8
9
|
|
|
@@ -21,6 +22,11 @@ describe('Default export', () => {
|
|
|
21
22
|
expect(compat.use).toBe(preactUse);
|
|
22
23
|
});
|
|
23
24
|
|
|
25
|
+
it('should include useDeferredValue', () => {
|
|
26
|
+
expect(compat).toHaveProperty('useDeferredValue');
|
|
27
|
+
expect(compat.useDeferredValue).toBe(preactUseDeferredValue);
|
|
28
|
+
});
|
|
29
|
+
|
|
24
30
|
it('should include useInsertionEffect', () => {
|
|
25
31
|
expect(compat).toHaveProperty('useInsertionEffect');
|
|
26
32
|
expect(compat.useInsertionEffect).toBe(ReactLynx.useEffect);
|
|
@@ -35,8 +41,8 @@ describe('Default export', () => {
|
|
|
35
41
|
});
|
|
36
42
|
|
|
37
43
|
it('should have correct number of exports', () => {
|
|
38
|
-
// +
|
|
39
|
-
const expectedExportCount = Object.keys(ReactLynx).length +
|
|
44
|
+
// +5 for startTransition, use, useDeferredValue, useInsertionEffect and useTransition
|
|
45
|
+
const expectedExportCount = Object.keys(ReactLynx).length + 5;
|
|
40
46
|
expect(Object.keys(compat).length).toBe(expectedExportCount);
|
|
41
47
|
});
|
|
42
48
|
});
|
|
@@ -61,9 +61,11 @@ describe('worklet-runtime init entry', () => {
|
|
|
61
61
|
});
|
|
62
62
|
|
|
63
63
|
it('initializes the main-thread runtime through the public entry', async () => {
|
|
64
|
+
globalThis.lynx.SystemInfo = { lynxSdkVersion: '2.15' };
|
|
64
65
|
const { registerWorklet } = await import('@lynx-js/react/worklet-runtime/init');
|
|
65
66
|
|
|
66
67
|
expect(globalThis.lynxWorkletImpl).toBeDefined();
|
|
68
|
+
expect(globalThis.lynxWorkletImpl._jsFunctionLifecycleManager).toBeDefined();
|
|
67
69
|
expect(globalThis.registerWorklet).toBeTypeOf('function');
|
|
68
70
|
expect(globalThis.registerWorkletInternal).toBeTypeOf('function');
|
|
69
71
|
expect(globalThis.runWorklet).toBeTypeOf('function');
|
|
@@ -75,6 +77,16 @@ describe('worklet-runtime init entry', () => {
|
|
|
75
77
|
expect(globalThis.runWorklet({ _wkltId: 'cold-entry' }, [41])).toBe(42);
|
|
76
78
|
});
|
|
77
79
|
|
|
80
|
+
it('uses host SystemInfo when initialized before the global alias', async () => {
|
|
81
|
+
delete globalThis.SystemInfo;
|
|
82
|
+
globalThis.lynx.SystemInfo = { lynxSdkVersion: '2.16' };
|
|
83
|
+
|
|
84
|
+
await import('@lynx-js/react/worklet-runtime/init');
|
|
85
|
+
|
|
86
|
+
expect(globalThis.lynxWorkletImpl._jsFunctionLifecycleManager).toBeDefined();
|
|
87
|
+
expect('SystemInfo' in globalThis).toBe(false);
|
|
88
|
+
});
|
|
89
|
+
|
|
78
90
|
it('preserves runtime state when the init entry is evaluated again', async () => {
|
|
79
91
|
const initialEntry = await import('@lynx-js/react/worklet-runtime/init');
|
|
80
92
|
expect(initialEntry.registerWorklet).toBe(globalThis.registerWorkletInternal);
|
|
@@ -51,6 +51,21 @@ declare function useTransition(): [false, typeof startTransition];
|
|
|
51
51
|
*/
|
|
52
52
|
declare function use<T>(resource: Promise<T> | Context<T>): T;
|
|
53
53
|
|
|
54
|
+
/**
|
|
55
|
+
* Returns a deferred copy of a value.
|
|
56
|
+
*
|
|
57
|
+
* Note: This is Preact's `useDeferredValue` implementation, which differs from React's:
|
|
58
|
+
* - React defers the value with interruptible, low-priority rendering
|
|
59
|
+
* - Preact returns the previous value first and updates it in a follow-up render
|
|
60
|
+
* once the current one has finished, without true concurrent rendering
|
|
61
|
+
*
|
|
62
|
+
* @param value - The value to defer
|
|
63
|
+
* @returns The deferred value
|
|
64
|
+
*
|
|
65
|
+
* @public
|
|
66
|
+
*/
|
|
67
|
+
declare function useDeferredValue<T>(value: T): T;
|
|
68
|
+
|
|
54
69
|
/**
|
|
55
70
|
* Runs an effect whose write is meant to be visible to the effects that read it.
|
|
56
71
|
*
|
|
@@ -75,12 +90,13 @@ declare function use<T>(resource: Promise<T> | Context<T>): T;
|
|
|
75
90
|
* @deprecated `useInsertionEffect` in the background thread is an alias of `useEffect` and cannot offer React's insertion-phase timing: the effect has not run when `render` returns, and its cleanup is deferred to a later flush instead of running inside the unmount commit.
|
|
76
91
|
*/
|
|
77
92
|
declare const useInsertionEffect: typeof import('@lynx-js/react').useEffect;
|
|
78
|
-
export { startTransition, use, useInsertionEffect, useTransition };
|
|
93
|
+
export { startTransition, use, useDeferredValue, useInsertionEffect, useTransition };
|
|
79
94
|
|
|
80
95
|
// type for the default export
|
|
81
96
|
declare const _default: typeof import('@lynx-js/react') & {
|
|
82
97
|
startTransition: typeof startTransition;
|
|
83
98
|
use: typeof use;
|
|
99
|
+
useDeferredValue: typeof useDeferredValue;
|
|
84
100
|
useInsertionEffect: typeof useInsertionEffect;
|
|
85
101
|
useTransition: typeof useTransition;
|
|
86
102
|
};
|
package/runtime/compat/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Copyright 2025 The Lynx Authors. All rights reserved.
|
|
2
2
|
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
3
|
// LICENSE file in the root directory of this source tree.
|
|
4
|
-
import { startTransition, use, useTransition } from 'preact/compat';
|
|
4
|
+
import { startTransition, use, useDeferredValue, useTransition } from 'preact/compat';
|
|
5
5
|
|
|
6
6
|
/* eslint-disable-next-line import/default */
|
|
7
7
|
import ReactLynx, { useEffect } from '@lynx-js/react';
|
|
@@ -11,9 +11,10 @@ const useInsertionEffect = useEffect;
|
|
|
11
11
|
export default /*#__PURE__*/ Object.assign({}, ReactLynx, {
|
|
12
12
|
startTransition,
|
|
13
13
|
use,
|
|
14
|
+
useDeferredValue,
|
|
14
15
|
useInsertionEffect,
|
|
15
16
|
useTransition,
|
|
16
17
|
});
|
|
17
18
|
|
|
18
19
|
export * from '@lynx-js/react';
|
|
19
|
-
export { startTransition, use, useInsertionEffect, useTransition };
|
|
20
|
+
export { startTransition, use, useDeferredValue, useInsertionEffect, useTransition };
|