@lynx-js/react-canary 0.115.1-canary-20251212-12a98f76 → 0.115.1

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,11 +1,28 @@
1
1
  # @lynx-js/react
2
2
 
3
- ## 0.115.1-canary-20251212065701-12a98f76be08e5c45e147867ea57fecdc968b102
3
+ ## 0.115.1
4
4
 
5
5
  ### Patch Changes
6
6
 
7
7
  - Auto define lynx.loadLazyBundle when using `import(/* relative path */)`. ([#1956](https://github.com/lynx-family/lynx-stack/pull/1956))
8
8
 
9
+ - 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))
10
+
11
+ - Usage: Add `with { runtime: "shared" }` to the `import` statement. For example:
12
+
13
+ ```ts
14
+ import { func } from './utils.js' with { runtime: 'shared' };
15
+
16
+ function worklet() {
17
+ 'main thread';
18
+ func(); // callable inside a main thread function
19
+ }
20
+ ```
21
+
22
+ - Limitations:
23
+ - Only directly imported identifiers are treated as shared; assigning the import to a new variable will result in the loss of this shared capability.
24
+ - Functions defined within shared modules do not automatically become Main Thread Functions. Accessing main-thread-only APIs (e.g., `MainThreadRef`) will cause errors.
25
+
9
26
  ## 0.115.0
10
27
 
11
28
  ### Minor Changes
@@ -74,11 +91,11 @@
74
91
  - 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))
75
92
 
76
93
  ```js
77
- import { defineConfig, mergeConfig } from "vitest/config";
78
- import { createVitestConfig } from "@lynx-js/react/testing-library/vitest-config";
94
+ import { defineConfig, mergeConfig } from 'vitest/config';
95
+ import { createVitestConfig } from '@lynx-js/react/testing-library/vitest-config';
79
96
 
80
97
  const defaultConfig = await createVitestConfig({
81
- runtimePkgName: "@lynx-js/react",
98
+ runtimePkgName: '@lynx-js/react',
82
99
  experimental_enableReactCompiler: true,
83
100
  });
84
101
 
@@ -108,7 +125,7 @@
108
125
  ```tsx
109
126
  function App() {
110
127
  function handleInnerTap(event: MainThread.TouchEvent) {
111
- "main thread";
128
+ 'main thread';
112
129
  event.stopPropagation();
113
130
  // Or stop immediate propagation with
114
131
  // event.stopImmediatePropagation();
@@ -206,10 +223,10 @@
206
223
  - 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))
207
224
 
208
225
  ```ts
209
- import type { MainThread } from "@lynx-js/types";
226
+ import type { MainThread } from '@lynx-js/types';
210
227
 
211
228
  function startAnimation(ele: MainThread.Element) {
212
- "main thread";
229
+ 'main thread';
213
230
  const animation = ele.animate([{ opacity: 0 }, { opacity: 1 }], {
214
231
  duration: 3000,
215
232
  });
@@ -238,7 +255,7 @@
238
255
  - 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))
239
256
 
240
257
  ```jsx
241
- <list-item recyclable={false} />
258
+ <list-item recyclable={false} />;
242
259
  ```
243
260
 
244
261
  - feat: Support using a host element as direct child of Suspense ([#1455](https://github.com/lynx-family/lynx-stack/pull/1455))
@@ -259,7 +276,7 @@
259
276
 
260
277
  ```ts
261
278
  function handleTap() {
262
- "main thread";
279
+ 'main thread';
263
280
  // The following check always returned false before this fix
264
281
  if (myHandleTap) {
265
282
  runOnBackground(myHandleTap)();
@@ -320,10 +337,10 @@
320
337
  Add the import to `@lynx-js/react/debug` at the first line of the entry:
321
338
 
322
339
  ```js
323
- import "@lynx-js/react/debug";
324
- import { root } from "@lynx-js/react";
340
+ import '@lynx-js/react/debug';
341
+ import { root } from '@lynx-js/react';
325
342
 
326
- import { App } from "./App.jsx";
343
+ import { App } from './App.jsx';
327
344
 
328
345
  root.render(<App />);
329
346
  ```
@@ -333,9 +350,9 @@
333
350
  For example, you can use it like this:
334
351
 
335
352
  ```jsx
336
- <list-item defer={{ unmountRecycled: true }} item-key="1">
353
+ <list-item defer={{ unmountRecycled: true }} item-key='1'>
337
354
  <WillBeUnmountIfRecycled />
338
- </list-item>
355
+ </list-item>;
339
356
  ```
340
357
 
341
358
  Now the component will be unmounted when it is recycled, which can help with performance in certain scenarios.
@@ -343,7 +360,7 @@
343
360
  - 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))
344
361
 
345
362
  ```jsx
346
- <image async-mode={undefined} />
363
+ <image async-mode={undefined} />;
347
364
  ```
348
365
 
349
366
  ## 0.111.1
@@ -389,7 +406,7 @@
389
406
  - Supports `act` in testing library. ([#1182](https://github.com/lynx-family/lynx-stack/pull/1182))
390
407
 
391
408
  ```js
392
- import { act } from "@lynx-js/react/testing-library";
409
+ import { act } from '@lynx-js/react/testing-library';
393
410
 
394
411
  act(() => {
395
412
  // ...
@@ -495,7 +512,8 @@
495
512
  * 3: Full Resolution - Batch render with async property and element tree resolution for list item subtree
496
513
  */
497
514
  experimental-batch-render-strategy={3}
498
- ></list>
515
+ >
516
+ </list>;
499
517
  ```
500
518
 
501
519
  - rename @lynx-js/test-environment to @lynx-js/testing-environment ([#704](https://github.com/lynx-family/lynx-stack/pull/704))
@@ -613,7 +631,7 @@
613
631
  You can now use `useErrorBoundary` it in TypeScript like this:
614
632
 
615
633
  ```tsx
616
- import { useErrorBoundary } from "@lynx-js/react";
634
+ import { useErrorBoundary } from '@lynx-js/react';
617
635
  ```
618
636
 
619
637
  - Modified the format of data sent from background threads to the main thread. ([#207](https://github.com/lynx-family/lynx-stack/pull/207))
@@ -665,13 +683,13 @@
665
683
  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.
666
684
 
667
685
  ```js
668
- import { runOnBackground } from "@lynx-js/react";
686
+ import { runOnBackground } from '@lynx-js/react';
669
687
 
670
688
  const onTap = async () => {
671
- "main thread";
689
+ 'main thread';
672
690
  const text = await runOnBackground(() => {
673
- "background only";
674
- return "Hello, world!";
691
+ 'background only';
692
+ return 'Hello, world!';
675
693
  })();
676
694
  console.log(text);
677
695
  };
@@ -706,9 +724,9 @@
706
724
 
707
725
  ```ts
708
726
  // These imports will be removed from the final bundle
709
- import type { Foo } from "xyz";
710
- import { type Bar } from "xyz";
711
- import { xyz } from "xyz"; // When xyz is not used
727
+ import type { Foo } from 'xyz';
728
+ import { type Bar } from 'xyz';
729
+ import { xyz } from 'xyz'; // When xyz is not used
712
730
  ```
713
731
 
714
732
  See [TypeScript - verbatimModuleSyntax](https://www.typescriptlang.org/tsconfig/#verbatimModuleSyntax) for details.
@@ -748,7 +766,7 @@
748
766
  const f = undefined;
749
767
 
750
768
  function mts() {
751
- "main thread";
769
+ 'main thread';
752
770
  // throws in background rendering
753
771
  f && runOnBackground(f)();
754
772
  }
@@ -782,14 +800,14 @@
782
800
  - a30c83d: Add `compat.removeComponentAttrRegex`.
783
801
 
784
802
  ```js
785
- import { pluginReactLynx } from "@lynx-js/react-rsbuild-plugin";
786
- import { defineConfig } from "@lynx-js/rspeedy";
803
+ import { pluginReactLynx } from '@lynx-js/react-rsbuild-plugin';
804
+ import { defineConfig } from '@lynx-js/rspeedy';
787
805
 
788
806
  export default defineConfig({
789
807
  plugins: [
790
808
  pluginReactLynx({
791
809
  compat: {
792
- removeComponentAttrRegex: "YOUR REGEX",
810
+ removeComponentAttrRegex: 'YOUR REGEX',
793
811
  },
794
812
  }),
795
813
  ],
@@ -875,22 +893,22 @@
875
893
  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.
876
894
 
877
895
  ```tsx
878
- import { useGesture, PanGesture } from "@lynx-js/gesture-runtime";
896
+ import { useGesture, PanGesture } from '@lynx-js/gesture-runtime';
879
897
 
880
898
  function App() {
881
899
  const pan = useGesture(PanGesture);
882
900
 
883
901
  pan
884
902
  .onBegin((event, stateManager) => {
885
- "main thread";
903
+ 'main thread';
886
904
  // some logic
887
905
  })
888
906
  .onUpdate((event, stateManager) => {
889
- "main thread";
907
+ 'main thread';
890
908
  // some logic
891
909
  })
892
910
  .onEnd((event, stateManager) => {
893
- "main thread";
911
+ 'main thread';
894
912
  // some logic
895
913
  });
896
914
 
@@ -910,7 +928,7 @@
910
928
  return;
911
929
  }
912
930
 
913
- console.log("not __LEPUS__"); // This can be removed now
931
+ console.log('not __LEPUS__'); // This can be removed now
914
932
  }
915
933
  ```
916
934
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lynx-js/react-canary",
3
- "version": "0.115.1-canary-20251212-12a98f76",
3
+ "version": "0.115.1",
4
4
  "description": "ReactLynx is a framework for developing Lynx applications with familiar React.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -5,7 +5,7 @@
5
5
  Rslib v0.15.0
6
6
 
7
7
  info build started...
8
- ready built in 0.26 s
8
+ ready built in 0.14 s
9
9
 
10
10
  File (esm) Size 
11
11
  dist/index.js 10.1 kB