@lynx-js/react-canary 0.115.0 → 0.115.1-canary-20251208-a01fa58b

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,5 +1,11 @@
1
1
  # @lynx-js/react
2
2
 
3
+ ## 0.115.1-canary-20251208100710-a01fa58b9801a6f163a067063ab448fc4fb0ea5a
4
+
5
+ ### Patch Changes
6
+
7
+ - Auto define lynx.loadLazyBundle when using `import(/* relative path */)`. ([#1956](https://github.com/lynx-family/lynx-stack/pull/1956))
8
+
3
9
  ## 0.115.0
4
10
 
5
11
  ### Minor Changes
@@ -68,11 +74,11 @@
68
74
  - 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))
69
75
 
70
76
  ```js
71
- import { defineConfig, mergeConfig } from 'vitest/config';
72
- import { createVitestConfig } from '@lynx-js/react/testing-library/vitest-config';
77
+ import { defineConfig, mergeConfig } from "vitest/config";
78
+ import { createVitestConfig } from "@lynx-js/react/testing-library/vitest-config";
73
79
 
74
80
  const defaultConfig = await createVitestConfig({
75
- runtimePkgName: '@lynx-js/react',
81
+ runtimePkgName: "@lynx-js/react",
76
82
  experimental_enableReactCompiler: true,
77
83
  });
78
84
 
@@ -102,7 +108,7 @@
102
108
  ```tsx
103
109
  function App() {
104
110
  function handleInnerTap(event: MainThread.TouchEvent) {
105
- 'main thread';
111
+ "main thread";
106
112
  event.stopPropagation();
107
113
  // Or stop immediate propagation with
108
114
  // event.stopImmediatePropagation();
@@ -200,10 +206,10 @@
200
206
  - 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))
201
207
 
202
208
  ```ts
203
- import type { MainThread } from '@lynx-js/types';
209
+ import type { MainThread } from "@lynx-js/types";
204
210
 
205
211
  function startAnimation(ele: MainThread.Element) {
206
- 'main thread';
212
+ "main thread";
207
213
  const animation = ele.animate([{ opacity: 0 }, { opacity: 1 }], {
208
214
  duration: 3000,
209
215
  });
@@ -232,7 +238,7 @@
232
238
  - 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))
233
239
 
234
240
  ```jsx
235
- <list-item recyclable={false} />;
241
+ <list-item recyclable={false} />
236
242
  ```
237
243
 
238
244
  - feat: Support using a host element as direct child of Suspense ([#1455](https://github.com/lynx-family/lynx-stack/pull/1455))
@@ -253,7 +259,7 @@
253
259
 
254
260
  ```ts
255
261
  function handleTap() {
256
- 'main thread';
262
+ "main thread";
257
263
  // The following check always returned false before this fix
258
264
  if (myHandleTap) {
259
265
  runOnBackground(myHandleTap)();
@@ -314,10 +320,10 @@
314
320
  Add the import to `@lynx-js/react/debug` at the first line of the entry:
315
321
 
316
322
  ```js
317
- import '@lynx-js/react/debug';
318
- import { root } from '@lynx-js/react';
323
+ import "@lynx-js/react/debug";
324
+ import { root } from "@lynx-js/react";
319
325
 
320
- import { App } from './App.jsx';
326
+ import { App } from "./App.jsx";
321
327
 
322
328
  root.render(<App />);
323
329
  ```
@@ -327,9 +333,9 @@
327
333
  For example, you can use it like this:
328
334
 
329
335
  ```jsx
330
- <list-item defer={{ unmountRecycled: true }} item-key='1'>
336
+ <list-item defer={{ unmountRecycled: true }} item-key="1">
331
337
  <WillBeUnmountIfRecycled />
332
- </list-item>;
338
+ </list-item>
333
339
  ```
334
340
 
335
341
  Now the component will be unmounted when it is recycled, which can help with performance in certain scenarios.
@@ -337,7 +343,7 @@
337
343
  - 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))
338
344
 
339
345
  ```jsx
340
- <image async-mode={undefined} />;
346
+ <image async-mode={undefined} />
341
347
  ```
342
348
 
343
349
  ## 0.111.1
@@ -383,7 +389,7 @@
383
389
  - Supports `act` in testing library. ([#1182](https://github.com/lynx-family/lynx-stack/pull/1182))
384
390
 
385
391
  ```js
386
- import { act } from '@lynx-js/react/testing-library';
392
+ import { act } from "@lynx-js/react/testing-library";
387
393
 
388
394
  act(() => {
389
395
  // ...
@@ -489,8 +495,7 @@
489
495
  * 3: Full Resolution - Batch render with async property and element tree resolution for list item subtree
490
496
  */
491
497
  experimental-batch-render-strategy={3}
492
- >
493
- </list>;
498
+ ></list>
494
499
  ```
495
500
 
496
501
  - rename @lynx-js/test-environment to @lynx-js/testing-environment ([#704](https://github.com/lynx-family/lynx-stack/pull/704))
@@ -608,7 +613,7 @@
608
613
  You can now use `useErrorBoundary` it in TypeScript like this:
609
614
 
610
615
  ```tsx
611
- import { useErrorBoundary } from '@lynx-js/react';
616
+ import { useErrorBoundary } from "@lynx-js/react";
612
617
  ```
613
618
 
614
619
  - Modified the format of data sent from background threads to the main thread. ([#207](https://github.com/lynx-family/lynx-stack/pull/207))
@@ -660,13 +665,13 @@
660
665
  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.
661
666
 
662
667
  ```js
663
- import { runOnBackground } from '@lynx-js/react';
668
+ import { runOnBackground } from "@lynx-js/react";
664
669
 
665
670
  const onTap = async () => {
666
- 'main thread';
671
+ "main thread";
667
672
  const text = await runOnBackground(() => {
668
- 'background only';
669
- return 'Hello, world!';
673
+ "background only";
674
+ return "Hello, world!";
670
675
  })();
671
676
  console.log(text);
672
677
  };
@@ -701,9 +706,9 @@
701
706
 
702
707
  ```ts
703
708
  // These imports will be removed from the final bundle
704
- import type { Foo } from 'xyz';
705
- import { type Bar } from 'xyz';
706
- import { xyz } from 'xyz'; // When xyz is not used
709
+ import type { Foo } from "xyz";
710
+ import { type Bar } from "xyz";
711
+ import { xyz } from "xyz"; // When xyz is not used
707
712
  ```
708
713
 
709
714
  See [TypeScript - verbatimModuleSyntax](https://www.typescriptlang.org/tsconfig/#verbatimModuleSyntax) for details.
@@ -743,7 +748,7 @@
743
748
  const f = undefined;
744
749
 
745
750
  function mts() {
746
- 'main thread';
751
+ "main thread";
747
752
  // throws in background rendering
748
753
  f && runOnBackground(f)();
749
754
  }
@@ -777,14 +782,14 @@
777
782
  - a30c83d: Add `compat.removeComponentAttrRegex`.
778
783
 
779
784
  ```js
780
- import { pluginReactLynx } from '@lynx-js/react-rsbuild-plugin';
781
- import { defineConfig } from '@lynx-js/rspeedy';
785
+ import { pluginReactLynx } from "@lynx-js/react-rsbuild-plugin";
786
+ import { defineConfig } from "@lynx-js/rspeedy";
782
787
 
783
788
  export default defineConfig({
784
789
  plugins: [
785
790
  pluginReactLynx({
786
791
  compat: {
787
- removeComponentAttrRegex: 'YOUR REGEX',
792
+ removeComponentAttrRegex: "YOUR REGEX",
788
793
  },
789
794
  }),
790
795
  ],
@@ -870,22 +875,22 @@
870
875
  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.
871
876
 
872
877
  ```tsx
873
- import { useGesture, PanGesture } from '@lynx-js/gesture-runtime';
878
+ import { useGesture, PanGesture } from "@lynx-js/gesture-runtime";
874
879
 
875
880
  function App() {
876
881
  const pan = useGesture(PanGesture);
877
882
 
878
883
  pan
879
884
  .onBegin((event, stateManager) => {
880
- 'main thread';
885
+ "main thread";
881
886
  // some logic
882
887
  })
883
888
  .onUpdate((event, stateManager) => {
884
- 'main thread';
889
+ "main thread";
885
890
  // some logic
886
891
  })
887
892
  .onEnd((event, stateManager) => {
888
- 'main thread';
893
+ "main thread";
889
894
  // some logic
890
895
  });
891
896
 
@@ -905,7 +910,7 @@
905
910
  return;
906
911
  }
907
912
 
908
- console.log('not __LEPUS__'); // This can be removed now
913
+ console.log("not __LEPUS__"); // This can be removed now
909
914
  }
910
915
  ```
911
916
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lynx-js/react-canary",
3
- "version": "0.115.0",
3
+ "version": "0.115.1-canary-20251208-a01fa58b",
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.17 s
8
+ ready built in 0.31 s
9
9
 
10
10
  File (esm) Size 
11
11
  dist/index.js 10.1 kB
@@ -1,10 +1,9 @@
1
1
  import './lynx.js';
2
2
  import './lynx/component.js';
3
- import { Children, Fragment, cloneElement, createElement, createRef, forwardRef, isValidElement, memo, useSyncExternalStore } from 'preact/compat';
3
+ import { Children, Fragment, cloneElement, createElement, createRef, forwardRef, isValidElement, lazy, memo, useSyncExternalStore } from 'preact/compat';
4
4
  import { Suspense } from './lynx/suspense.js';
5
5
  export { Component, createContext } from 'preact';
6
6
  export { PureComponent } from 'preact/compat';
7
7
  export * from './hooks/react.js';
8
- declare const lazy: typeof import('preact/compat').lazy;
9
8
  export { Children, createRef, Fragment, isValidElement, memo, forwardRef, Suspense, lazy, createElement, cloneElement, useSyncExternalStore, };
10
9
  export * from './lynx-api.js';
@@ -3,17 +3,12 @@
3
3
  // LICENSE file in the root directory of this source tree.
4
4
  import './lynx.js';
5
5
  import './lynx/component.js';
6
- import { Children, Component, Fragment, PureComponent, cloneElement, createContext, createElement, createRef, forwardRef, isValidElement, memo, lazy as preactLazy, useSyncExternalStore, } from 'preact/compat';
6
+ import { Children, Component, Fragment, PureComponent, cloneElement, createContext, createElement, createRef, forwardRef, isValidElement, lazy, memo, useSyncExternalStore, } from 'preact/compat';
7
7
  import { useCallback, useContext, useDebugValue, useEffect, useImperativeHandle, useLayoutEffect, useMemo, useReducer, useRef, useState, } from './hooks/react.js';
8
- import { loadLazyBundle } from './lynx/lazy-bundle.js';
9
8
  import { Suspense } from './lynx/suspense.js';
10
9
  export { Component, createContext } from 'preact';
11
10
  export { PureComponent } from 'preact/compat';
12
11
  export * from './hooks/react.js';
13
- const lazy = /*#__PURE__*/ (() => {
14
- lynx.loadLazyBundle = loadLazyBundle;
15
- return preactLazy;
16
- })();
17
12
  /**
18
13
  * @internal
19
14
  */
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,WAAW,CAAC;AACnB,OAAO,qBAAqB,CAAC;AAC7B,OAAO,EACL,QAAQ,EACR,SAAS,EACT,QAAQ,EACR,aAAa,EACb,YAAY,EACZ,aAAa,EACb,aAAa,EACb,SAAS,EACT,UAAU,EACV,cAAc,EACd,IAAI,EACJ,IAAI,IAAI,UAAU,EAClB,oBAAoB,GACrB,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,WAAW,EACX,UAAU,EACV,aAAa,EACb,SAAS,EACT,mBAAmB,EACnB,eAAe,EACf,OAAO,EACP,UAAU,EACV,MAAM,EACN,QAAQ,GACT,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAE9C,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,cAAc,kBAAkB,CAAC;AAEjC,MAAM,IAAI,GAAwC,aAAa,CAAC,CAAC,GAAG,EAAE;IACpE,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;IACrC,OAAO,UAAU,CAAC;AACpB,CAAC,CAAC,EAAE,CAAC;AAEL;;GAEG;AACH,eAAe;IACb,QAAQ;IACR,QAAQ;IACR,UAAU;IACV,SAAS;IACT,eAAe;IACf,MAAM;IACN,mBAAmB;IACnB,OAAO;IACP,WAAW;IACX,UAAU;IACV,a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IACR,cAAc;IACd,QAAQ;IACR,SAAS;IACT,aAAa;IACb,IAAI;IACJ,UAAU;IACV,QAAQ;IACR,IAAI;IACJ,aAAa;CACd,CAAC;AAEF,OAAO,EACL,QAAQ,EACR,SAAS,EACT,QAAQ,EACR,cAAc,EACd,IAAI,EACJ,UAAU,EACV,QAAQ,EACR,IAAI,EACJ,aAAa,EACb,YAAY,EACZ,oBAAoB,GACrB,CAAC;AAEF,cAAc,eAAe,CAAC"}
@@ -192,6 +192,11 @@ const createVitestConfig = async (options)=>{
192
192
  target: 'MIXED'
193
193
  },
194
194
  engineVersion: options?.engineVersion ?? '',
195
+ dynamicImport: {
196
+ injectLazyBundle: false,
197
+ layer: 'test',
198
+ runtimePkg: `${runtimePkgName}/internal`
199
+ },
195
200
  directiveDCE: false,
196
201
  defineDCE: false,
197
202
  shake: false,