@lynx-js/react 0.122.1 → 0.123.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.
Files changed (92) hide show
  1. package/CHANGELOG.md +88 -0
  2. package/components/lib/DeferredListItem.d.ts +8 -2
  3. package/components/lib/DeferredListItem.jsx.map +1 -1
  4. package/components/lib/Page.js +1 -1
  5. package/components/lib/Page.js.map +1 -1
  6. package/components/src/DeferredListItem.tsx +7 -2
  7. package/components/src/Page.ts +1 -1
  8. package/package.json +4 -4
  9. package/refresh/dist/index.js +4 -2
  10. package/runtime/lazy/compat.js +1 -0
  11. package/runtime/lazy/react.js +1 -0
  12. package/runtime/lib/core/lynx/dynamic-import.d.ts +1 -0
  13. package/runtime/lib/core/lynx/dynamic-import.js +3 -2
  14. package/runtime/lib/core/lynx/dynamic-import.js.map +1 -1
  15. package/runtime/lib/core/lynx/lazy-bundle.d.ts +7 -1
  16. package/runtime/lib/core/lynx/lazy-bundle.js +182 -3
  17. package/runtime/lib/core/lynx/lazy-bundle.js.map +1 -1
  18. package/runtime/lib/core/lynx-data-processors.d.ts +1 -0
  19. package/runtime/lib/core/lynx-data-processors.js +19 -1
  20. package/runtime/lib/core/lynx-data-processors.js.map +1 -1
  21. package/runtime/lib/index.d.ts +1 -0
  22. package/runtime/lib/index.js.map +1 -1
  23. package/runtime/lib/internal.js +9 -0
  24. package/runtime/lib/internal.js.map +1 -1
  25. package/runtime/lib/lynx-api.d.ts +19 -0
  26. package/runtime/lib/lynx-api.js +38 -5
  27. package/runtime/lib/lynx-api.js.map +1 -1
  28. package/runtime/lib/lynx.js +5 -0
  29. package/runtime/lib/lynx.js.map +1 -1
  30. package/runtime/lib/snapshot/lifecycle/constant.d.ts +3 -2
  31. package/runtime/lib/snapshot/lifecycle/constant.js +4 -1
  32. package/runtime/lib/snapshot/lifecycle/constant.js.map +1 -1
  33. package/runtime/lib/snapshot/lifecycle/event/firstScreenSync.d.ts +9 -0
  34. package/runtime/lib/snapshot/lifecycle/event/firstScreenSync.js +80 -0
  35. package/runtime/lib/snapshot/lifecycle/event/firstScreenSync.js.map +1 -0
  36. package/runtime/lib/snapshot/lifecycle/patch/snapshotPatchApply.js +5 -4
  37. package/runtime/lib/snapshot/lifecycle/patch/snapshotPatchApply.js.map +1 -1
  38. package/runtime/lib/snapshot/lifecycle/reload.js +3 -3
  39. package/runtime/lib/snapshot/lifecycle/reload.js.map +1 -1
  40. package/runtime/lib/snapshot/list/listUpdateInfo.js +8 -0
  41. package/runtime/lib/snapshot/list/listUpdateInfo.js.map +1 -1
  42. package/runtime/lib/snapshot/lynx/calledByNative.js +20 -9
  43. package/runtime/lib/snapshot/lynx/calledByNative.js.map +1 -1
  44. package/runtime/lib/snapshot/lynx/element.d.ts +28 -5
  45. package/runtime/lib/snapshot/lynx/element.js +9 -5
  46. package/runtime/lib/snapshot/lynx/element.js.map +1 -1
  47. package/runtime/lib/snapshot/lynx/injectLepusMethods.js +1 -1
  48. package/runtime/lib/snapshot/lynx/injectLepusMethods.js.map +1 -1
  49. package/runtime/lib/snapshot/lynx/lazyBundleConstants.d.ts +4 -0
  50. package/runtime/lib/snapshot/lynx/lazyBundleConstants.js +8 -0
  51. package/runtime/lib/snapshot/lynx/lazyBundleConstants.js.map +1 -0
  52. package/runtime/lib/snapshot/lynx/prepareLazyBundleMTS.d.ts +1 -0
  53. package/runtime/lib/snapshot/lynx/prepareLazyBundleMTS.js +60 -0
  54. package/runtime/lib/snapshot/lynx/prepareLazyBundleMTS.js.map +1 -0
  55. package/runtime/lib/snapshot/lynx/tt.js +3 -3
  56. package/runtime/lib/snapshot/lynx/tt.js.map +1 -1
  57. package/runtime/lib/snapshot/renderToOpcodes/hydrate.js +7 -0
  58. package/runtime/lib/snapshot/renderToOpcodes/hydrate.js.map +1 -1
  59. package/runtime/lib/snapshot/snapshot/backgroundSnapshot.js +5 -2
  60. package/runtime/lib/snapshot/snapshot/backgroundSnapshot.js.map +1 -1
  61. package/runtime/lib/snapshot/snapshot/definition.js +4 -4
  62. package/runtime/lib/snapshot/snapshot/definition.js.map +1 -1
  63. package/runtime/lib/snapshot/snapshot/list.js +8 -1
  64. package/runtime/lib/snapshot/snapshot/list.js.map +1 -1
  65. package/runtime/lib/snapshot/snapshot/platformInfo.d.ts +3 -1
  66. package/runtime/lib/snapshot/snapshot/platformInfo.js +21 -2
  67. package/runtime/lib/snapshot/snapshot/platformInfo.js.map +1 -1
  68. package/runtime/lib/snapshot/snapshot/snapshot.d.ts +2 -5
  69. package/runtime/lib/snapshot/snapshot/snapshot.js +14 -16
  70. package/runtime/lib/snapshot/snapshot/snapshot.js.map +1 -1
  71. package/runtime/lib/snapshot/snapshot/snapshotCreatorMap.d.ts +16 -1
  72. package/runtime/lib/snapshot/snapshot/snapshotCreatorMap.js +8 -0
  73. package/runtime/lib/snapshot/snapshot/snapshotCreatorMap.js.map +1 -1
  74. package/runtime/lib/snapshot/snapshot/snapshotInstanceManager.d.ts +6 -0
  75. package/runtime/lib/snapshot/snapshot/snapshotInstanceManager.js +16 -0
  76. package/runtime/lib/snapshot/snapshot/snapshotInstanceManager.js.map +1 -0
  77. package/runtime/lib/snapshot/snapshot/spread.d.ts +1 -1
  78. package/runtime/lib/snapshot/snapshot/spread.js +11 -5
  79. package/runtime/lib/snapshot/snapshot/spread.js.map +1 -1
  80. package/runtime/lib/tsconfig.tsbuildinfo +1 -1
  81. package/testing-library/dist/0-@rstest/adapter-rsbuild.js +95 -0
  82. package/testing-library/dist/index.d.ts +2 -2
  83. package/testing-library/dist/pure.js +1 -1
  84. package/testing-library/dist/rstest-config.js +1 -1
  85. package/transform/dist/wasm.cjs +333 -126
  86. package/transform/index.d.ts +40 -0
  87. package/types/react.docs.d.ts +28 -2
  88. package/runtime/lib/snapshot/lifecycle/event/jsReady.d.ts +0 -6
  89. package/runtime/lib/snapshot/lifecycle/event/jsReady.js +0 -44
  90. package/runtime/lib/snapshot/lifecycle/event/jsReady.js.map +0 -1
  91. package/testing-library/dist/0~@rstest/adapter-rsbuild.js +0 -43
  92. /package/testing-library/dist/{0~rslib-runtime.js → 0-rslib-runtime.js} +0 -0
@@ -362,6 +362,40 @@ export interface CompatVisitorConfig {
362
362
  * ```
363
363
  */
364
364
  darkMode?: boolean | DarkModeConfig
365
+
366
+ /**
367
+ * Compile dynamic children as children + wrapper (the pre-SlotV2 slot
368
+ * codegen: `Slot`/`Children` dynamic parts rendered through wrapper
369
+ * elements) instead of the default SlotV2 codegen (`$N` slot props).
370
+ *
371
+ * @remarks
372
+ *
373
+ * Enable this when the compiled output needs to run on legacy
374
+ * `@lynx-js/react` runtimes without `SlotV2` support (`< 0.120.0`),
375
+ * e.g. a standalone lazy bundle consumed by a host App that ships an
376
+ * older runtime. It only changes the compile output; the runtime
377
+ * supports both forms.
378
+ *
379
+ * @example
380
+ *
381
+ * ```js
382
+ * import { defineConfig } from '@lynx-js/rspeedy'
383
+ * import { pluginReactLynx } from '@lynx-js/react-rsbuild-plugin'
384
+ *
385
+ * export default defineConfig({
386
+ * plugins: [
387
+ * pluginReactLynx({
388
+ * compat: {
389
+ * legacySlot: true,
390
+ * },
391
+ * })
392
+ * ],
393
+ * })
394
+ * ```
395
+ *
396
+ * @defaultValue `false`
397
+ */
398
+ legacySlot?: boolean
365
399
  }
366
400
  export interface CssScopeVisitorConfig {
367
401
  /** @public */
@@ -598,6 +632,10 @@ export interface JsxTransformerConfig {
598
632
  enableUiSourceMap?: boolean
599
633
  /** @internal */
600
634
  isDynamicComponent?: boolean
635
+ /** @internal */
636
+ isExternalBundle?: boolean
637
+ /** @internal */
638
+ legacySlot?: boolean
601
639
  }
602
640
  /** @internal */
603
641
  export interface ElementTemplateConfig {
@@ -613,6 +651,8 @@ export interface ElementTemplateConfig {
613
651
  target: 'LEPUS' | 'JS' | 'MIXED'
614
652
  /** @internal */
615
653
  isDynamicComponent?: boolean
654
+ /** @internal */
655
+ isExternalBundle?: boolean
616
656
  }
617
657
  export interface WorkletVisitorConfig {
618
658
  /**
@@ -40,6 +40,12 @@ declare global {
40
40
  * environment variable `REACT_DEVTOOL=true`.
41
41
  */
42
42
  let __REACT_DEVTOOL__: boolean | undefined;
43
+ /**
44
+ * Which lazy bundle fetcher the build is wired up to. `'FetchBundle'`
45
+ * enables the `lynx.fetchBundle`-based path (and `import(..., { with: { mode } })`
46
+ * mode hints); `'QueryComponent'` is the legacy `lynx.QueryComponent` path.
47
+ */
48
+ let __LAZY_BUNDLE_FETCHER__: 'FetchBundle' | 'QueryComponent';
43
49
  }
44
50
 
45
51
  /**
@@ -76,9 +82,9 @@ export { Fragment, Suspense } from 'react';
76
82
  * Legacy React APIs
77
83
  * @see https://react.dev/reference/react/legacy
78
84
  */
79
- export { Component, PureComponent, cloneElement, createElement, createRef, isValidElement } from 'react';
85
+ export { Component, PureComponent, createRef, isValidElement } from 'react';
80
86
 
81
- export type { ReactLynxChildren } from '../runtime/lib/index.js';
87
+ export type { CloneElement, CreateElement, ReactLynxChildren } from '../runtime/lib/index.js';
82
88
 
83
89
  /**
84
90
  * ReactLynx children utilities.
@@ -97,6 +103,26 @@ export const Children: ReactLynxChildren;
97
103
  */
98
104
  export { createPortal } from '../runtime/lib/index.js';
99
105
 
106
+ /**
107
+ * Creates a ReactLynx element from a Lynx intrinsic element name or a
108
+ * component type. Lynx intrinsic elements are processed by the ReactLynx
109
+ * snapshot runtime.
110
+ *
111
+ * @see https://react.dev/reference/react/createElement
112
+ * @public
113
+ */
114
+ export { createElement } from '../runtime/lib/index.js';
115
+
116
+ /**
117
+ * Clones an existing ReactLynx element and applies new props through the
118
+ * ReactLynx runtime. Runtime-created elements and components may also receive
119
+ * replacement children.
120
+ *
121
+ * @see https://react.dev/reference/react/cloneElement
122
+ * @public
123
+ */
124
+ export { cloneElement } from '../runtime/lib/index.js';
125
+
100
126
  /**
101
127
  * RL-defined Lynx APIs
102
128
  */
@@ -1,6 +0,0 @@
1
- declare let isJSReady: boolean;
2
- declare let jsReadyEventIdSwap: Record<string | number, number>;
3
- declare function jsReady(): void;
4
- declare function clearJSReadyEventIdSwap(): void;
5
- declare function resetJSReady(): void;
6
- export {};
@@ -1,44 +0,0 @@
1
- // Copyright 2025 The Lynx Authors. All rights reserved.
2
- // Licensed under the Apache License Version 2.0 that can be found in the
3
- // LICENSE file in the root directory of this source tree.
4
- import { __root } from '../../../root.js';
5
- import { profileEnd, profileStart } from '../../../shared/profile.js';
6
- import { LifecycleConstant } from '../../lifecycle/constant.js';
7
- let isJSReady;
8
- let jsReadyEventIdSwap;
9
- function jsReady() {
10
- isJSReady = true;
11
- if (typeof __PROFILE__ !== 'undefined' && __PROFILE__) {
12
- profileStart('ReactLynx::serializeRoot');
13
- }
14
- const root = JSON.stringify(__root);
15
- if (typeof __PROFILE__ !== 'undefined' && __PROFILE__) {
16
- profileEnd();
17
- }
18
- if (typeof __PROFILE__ !== 'undefined' && __PROFILE__) {
19
- profileStart('ReactLynx::transferRoot');
20
- }
21
- __OnLifecycleEvent([
22
- LifecycleConstant.firstScreen, /* FIRST_SCREEN */
23
- {
24
- root,
25
- jsReadyEventIdSwap,
26
- },
27
- ]);
28
- if (typeof __PROFILE__ !== 'undefined' && __PROFILE__) {
29
- profileEnd();
30
- }
31
- jsReadyEventIdSwap = {};
32
- }
33
- function clearJSReadyEventIdSwap() {
34
- jsReadyEventIdSwap = {};
35
- }
36
- function resetJSReady() {
37
- isJSReady = false;
38
- jsReadyEventIdSwap = {};
39
- }
40
- /**
41
- * @internal
42
- */
43
- export { jsReady, isJSReady, jsReadyEventIdSwap, clearJSReadyEventIdSwap, resetJSReady };
44
- //# sourceMappingURL=jsReady.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"jsReady.js","sourceRoot":"","sources":["../../../../src/snapshot/lifecycle/event/jsReady.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAEhE,IAAI,SAAkB,CAAC;AACvB,IAAI,kBAAmD,CAAC;AAExD,SAAS,OAAO;IACd,SAAS,GAAG,IAAI,CAAC;IAEjB,IAAI,OAAO,WAAW,KAAK,WAAW,IAAI,WAAW,EAAE,CAAC;QACtD,YAAY,CAAC,0BAA0B,CAAC,CAAC;IAC3C,CAAC;IACD,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IACpC,IAAI,OAAO,WAAW,KAAK,WAAW,IAAI,WAAW,EAAE,CAAC;QACtD,UAAU,EAAE,CAAC;IACf,CAAC;IACD,IAAI,OAAO,WAAW,KAAK,WAAW,IAAI,WAAW,EAAE,CAAC;QACtD,YAAY,CAAC,yBAAyB,CAAC,CAAC;IAC1C,CAAC;IACD,kBAAkB,CAAC;QACjB,iBAAiB,CAAC,WAAW,EAAE,kBAAkB;QACjD;YACE,IAAI;YACJ,kBAAkB;SACnB;KACF,CAAC,CAAC;IACH,IAAI,OAAO,WAAW,KAAK,WAAW,IAAI,WAAW,EAAE,CAAC;QACtD,UAAU,EAAE,CAAC;IACf,CAAC;IACD,kBAAkB,GAAG,EAAE,CAAC;AAC1B,CAAC;AAED,SAAS,uBAAuB;IAC9B,kBAAkB,GAAG,EAAE,CAAC;AAC1B,CAAC;AAED,SAAS,YAAY;IACnB,SAAS,GAAG,KAAK,CAAC;IAClB,kBAAkB,GAAG,EAAE,CAAC;AAC1B,CAAC;AAED;;GAEG;AACH,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,YAAY,EAAE,CAAC"}
@@ -1,43 +0,0 @@
1
- import { mergeRsbuildConfig } from "@rsbuild/core";
2
- function toRstestConfig({ environmentName, rsbuildConfig: rawRsbuildConfig, modifyRsbuildConfig }) {
3
- const { environments, ...rawBuildConfig } = rawRsbuildConfig;
4
- const environmentConfig = environmentName ? environments?.[environmentName] : void 0;
5
- const rsbuildConfig = environmentConfig ? mergeRsbuildConfig(rawBuildConfig, environmentConfig) : rawBuildConfig;
6
- const finalBuildConfig = modifyRsbuildConfig ? modifyRsbuildConfig(rsbuildConfig) : rsbuildConfig;
7
- const { rspack, swc, bundlerChain } = finalBuildConfig.tools || {};
8
- const { cssModules, target, module } = finalBuildConfig.output || {};
9
- const { decorators, define, include, exclude, tsconfigPath } = finalBuildConfig.source || {};
10
- return {
11
- root: finalBuildConfig.root,
12
- name: environmentName,
13
- plugins: [
14
- ...finalBuildConfig.plugins || [],
15
- {
16
- name: 'remove-useless-plugins',
17
- remove: [
18
- 'rsbuild:type-check'
19
- ],
20
- setup: ()=>{}
21
- }
22
- ],
23
- source: {
24
- decorators,
25
- define,
26
- include,
27
- exclude,
28
- tsconfigPath
29
- },
30
- resolve: finalBuildConfig.resolve,
31
- output: {
32
- cssModules,
33
- module
34
- },
35
- tools: {
36
- rspack,
37
- swc,
38
- bundlerChain
39
- },
40
- testEnvironment: 'node' === target ? 'node' : 'happy-dom'
41
- };
42
- }
43
- export { toRstestConfig };