@lynx-js/react 0.122.0 → 0.123.0

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 (100) hide show
  1. package/CHANGELOG.md +99 -0
  2. package/components/lib/DeferredListItem.jsx +4 -3
  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 -4
  7. package/components/src/Page.ts +1 -1
  8. package/package.json +1 -1
  9. package/runtime/lazy/compat.js +1 -0
  10. package/runtime/lazy/internal.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/element-template/background/hydration-listener.js +91 -84
  22. package/runtime/lib/element-template/background/hydration-listener.js.map +1 -1
  23. package/runtime/lib/element-template/protocol/types.d.ts +1 -1
  24. package/runtime/lib/index.d.ts +2 -2
  25. package/runtime/lib/index.js +3 -2
  26. package/runtime/lib/index.js.map +1 -1
  27. package/runtime/lib/internal.d.ts +2 -0
  28. package/runtime/lib/internal.js +11 -1
  29. package/runtime/lib/internal.js.map +1 -1
  30. package/runtime/lib/lynx-api.d.ts +19 -0
  31. package/runtime/lib/lynx-api.js +38 -5
  32. package/runtime/lib/lynx-api.js.map +1 -1
  33. package/runtime/lib/lynx.js +9 -1
  34. package/runtime/lib/lynx.js.map +1 -1
  35. package/runtime/lib/snapshot/lifecycle/constant.d.ts +3 -2
  36. package/runtime/lib/snapshot/lifecycle/constant.js +4 -1
  37. package/runtime/lib/snapshot/lifecycle/constant.js.map +1 -1
  38. package/runtime/lib/snapshot/lifecycle/event/firstScreenSync.d.ts +9 -0
  39. package/runtime/lib/snapshot/lifecycle/event/firstScreenSync.js +80 -0
  40. package/runtime/lib/snapshot/lifecycle/event/firstScreenSync.js.map +1 -0
  41. package/runtime/lib/snapshot/lifecycle/patch/snapshotPatchApply.js +5 -4
  42. package/runtime/lib/snapshot/lifecycle/patch/snapshotPatchApply.js.map +1 -1
  43. package/runtime/lib/snapshot/lifecycle/reload.js +3 -3
  44. package/runtime/lib/snapshot/lifecycle/reload.js.map +1 -1
  45. package/runtime/lib/snapshot/list/listUpdateInfo.js +8 -0
  46. package/runtime/lib/snapshot/list/listUpdateInfo.js.map +1 -1
  47. package/runtime/lib/snapshot/lynx/calledByNative.js +20 -9
  48. package/runtime/lib/snapshot/lynx/calledByNative.js.map +1 -1
  49. package/runtime/lib/snapshot/lynx/element.d.ts +5 -0
  50. package/runtime/lib/snapshot/lynx/element.js +100 -10
  51. package/runtime/lib/snapshot/lynx/element.js.map +1 -1
  52. package/runtime/lib/snapshot/lynx/injectLepusMethods.js +1 -1
  53. package/runtime/lib/snapshot/lynx/injectLepusMethods.js.map +1 -1
  54. package/runtime/lib/snapshot/lynx/lazyBundleConstants.d.ts +4 -0
  55. package/runtime/lib/snapshot/lynx/lazyBundleConstants.js +8 -0
  56. package/runtime/lib/snapshot/lynx/lazyBundleConstants.js.map +1 -0
  57. package/runtime/lib/snapshot/lynx/prepareLazyBundleMTS.d.ts +1 -0
  58. package/runtime/lib/snapshot/lynx/prepareLazyBundleMTS.js +60 -0
  59. package/runtime/lib/snapshot/lynx/prepareLazyBundleMTS.js.map +1 -0
  60. package/runtime/lib/snapshot/lynx/tt.js +3 -3
  61. package/runtime/lib/snapshot/lynx/tt.js.map +1 -1
  62. package/runtime/lib/snapshot/renderToOpcodes/hydrate.d.ts +1 -1
  63. package/runtime/lib/snapshot/renderToOpcodes/hydrate.js +7 -0
  64. package/runtime/lib/snapshot/renderToOpcodes/hydrate.js.map +1 -1
  65. package/runtime/lib/snapshot/snapshot/backgroundSnapshot.d.ts +4 -0
  66. package/runtime/lib/snapshot/snapshot/backgroundSnapshot.js +35 -6
  67. package/runtime/lib/snapshot/snapshot/backgroundSnapshot.js.map +1 -1
  68. package/runtime/lib/snapshot/snapshot/constants.d.ts +4 -0
  69. package/runtime/lib/snapshot/snapshot/constants.js +4 -0
  70. package/runtime/lib/snapshot/snapshot/constants.js.map +1 -1
  71. package/runtime/lib/snapshot/snapshot/definition.d.ts +1 -0
  72. package/runtime/lib/snapshot/snapshot/definition.js +44 -2
  73. package/runtime/lib/snapshot/snapshot/definition.js.map +1 -1
  74. package/runtime/lib/snapshot/snapshot/platformInfo.d.ts +3 -1
  75. package/runtime/lib/snapshot/snapshot/platformInfo.js +21 -2
  76. package/runtime/lib/snapshot/snapshot/platformInfo.js.map +1 -1
  77. package/runtime/lib/snapshot/snapshot/snapshot.d.ts +5 -6
  78. package/runtime/lib/snapshot/snapshot/snapshot.js +42 -19
  79. package/runtime/lib/snapshot/snapshot/snapshot.js.map +1 -1
  80. package/runtime/lib/snapshot/snapshot/snapshotCreatorMap.d.ts +19 -0
  81. package/runtime/lib/snapshot/snapshot/snapshotCreatorMap.js +16 -0
  82. package/runtime/lib/snapshot/snapshot/snapshotCreatorMap.js.map +1 -0
  83. package/runtime/lib/snapshot/snapshot/snapshotInstanceManager.d.ts +6 -0
  84. package/runtime/lib/snapshot/snapshot/snapshotInstanceManager.js +16 -0
  85. package/runtime/lib/snapshot/snapshot/snapshotInstanceManager.js.map +1 -0
  86. package/runtime/lib/snapshot/snapshot/spread.d.ts +1 -1
  87. package/runtime/lib/snapshot/snapshot/spread.js +11 -5
  88. package/runtime/lib/snapshot/snapshot/spread.js.map +1 -1
  89. package/runtime/lib/snapshot/snapshot/types.d.ts +2 -0
  90. package/runtime/lib/snapshot/snapshot/utils.d.ts +6 -0
  91. package/runtime/lib/snapshot/snapshot/utils.js +19 -1
  92. package/runtime/lib/snapshot/snapshot/utils.js.map +1 -1
  93. package/runtime/lib/tsconfig.tsbuildinfo +1 -1
  94. package/testing-library/dist/0~@rstest/adapter-rsbuild.js +59 -7
  95. package/transform/dist/wasm.cjs +332 -125
  96. package/transform/index.d.ts +40 -0
  97. package/types/react.docs.d.ts +13 -0
  98. package/runtime/lib/snapshot/lifecycle/event/jsReady.d.ts +0 -6
  99. package/runtime/lib/snapshot/lifecycle/event/jsReady.js +0 -44
  100. package/runtime/lib/snapshot/lifecycle/event/jsReady.js.map +0 -1
@@ -1,19 +1,60 @@
1
+ import { dirname, isAbsolute as external_node_path_isAbsolute, normalize, resolve } from "node:path";
1
2
  import { mergeRsbuildConfig } from "@rsbuild/core";
2
- function toRstestConfig({ environmentName, rsbuildConfig: rawRsbuildConfig, modifyRsbuildConfig }) {
3
+ import "node:module";
4
+ const resolveCacheDependency = ({ dependency, configPath, root })=>{
5
+ if (external_node_path_isAbsolute(dependency)) return normalize(dependency);
6
+ if (configPath) return normalize(resolve(dirname(configPath), dependency));
7
+ return root ? normalize(resolve(root, dependency)) : dependency;
8
+ };
9
+ const resolveBuildCache = ({ buildCache, configPath, root })=>{
10
+ if (void 0 === buildCache) return;
11
+ if (false === buildCache) return false;
12
+ if (true === buildCache) return configPath ? {
13
+ buildDependencies: [
14
+ normalize(configPath)
15
+ ]
16
+ } : true;
17
+ const buildDependencies = buildCache.buildDependencies?.map((dependency)=>resolveCacheDependency({
18
+ dependency,
19
+ configPath,
20
+ root
21
+ }));
22
+ const nextBuildDependencies = configPath ? Array.from(new Set([
23
+ ...buildDependencies || [],
24
+ normalize(configPath)
25
+ ])) : buildDependencies;
26
+ return {
27
+ cacheDirectory: buildCache.cacheDirectory,
28
+ cacheDigest: buildCache.cacheDigest,
29
+ buildDependencies: nextBuildDependencies
30
+ };
31
+ };
32
+ const isNodeTarget = (target)=>{
33
+ const targets = Array.isArray(target) ? target.filter(Boolean) : 'string' == typeof target ? [
34
+ target
35
+ ] : [];
36
+ return targets.some((t)=>'async-node' === t || t.startsWith('node'));
37
+ };
38
+ const resolveTestEnvironmentFromTarget = (target)=>isNodeTarget(target) ? 'node' : 'happy-dom';
39
+ function toRstestConfig({ configPath, environmentName, rsbuildConfig: rawRsbuildConfig, modifyRsbuildConfig }) {
3
40
  const { environments, ...rawBuildConfig } = rawRsbuildConfig;
4
41
  const environmentConfig = environmentName ? environments?.[environmentName] : void 0;
5
42
  const rsbuildConfig = environmentConfig ? mergeRsbuildConfig(rawBuildConfig, environmentConfig) : rawBuildConfig;
6
43
  const finalBuildConfig = modifyRsbuildConfig ? modifyRsbuildConfig(rsbuildConfig) : rsbuildConfig;
7
44
  const { rspack, swc, bundlerChain } = finalBuildConfig.tools || {};
8
- const { cssModules, target, module } = finalBuildConfig.output || {};
9
- const { decorators, define, include, exclude, tsconfigPath } = finalBuildConfig.source || {};
10
- return {
45
+ const { buildCache } = finalBuildConfig.performance || {};
46
+ const { cssModules, emitAssets, target, module } = finalBuildConfig.output || {};
47
+ const { assetsInclude, decorators, define, include, exclude, tsconfigPath, transformImport } = finalBuildConfig.source || {};
48
+ const rstestConfig = {
11
49
  root: finalBuildConfig.root,
12
50
  name: environmentName,
51
+ forceRerunTriggers: configPath ? [
52
+ normalize(configPath)
53
+ ] : void 0,
13
54
  plugins: [
14
55
  ...finalBuildConfig.plugins || [],
15
56
  {
16
- name: 'remove-useless-plugins',
57
+ name: 'rsbuild-adapter:remove-useless-plugins',
17
58
  remove: [
18
59
  'rsbuild:type-check'
19
60
  ],
@@ -21,23 +62,34 @@ function toRstestConfig({ environmentName, rsbuildConfig: rawRsbuildConfig, modi
21
62
  }
22
63
  ],
23
64
  source: {
65
+ assetsInclude,
24
66
  decorators,
25
67
  define,
26
68
  include,
27
69
  exclude,
28
- tsconfigPath
70
+ tsconfigPath,
71
+ transformImport
29
72
  },
30
73
  resolve: finalBuildConfig.resolve,
31
74
  output: {
32
75
  cssModules,
76
+ emitAssets,
33
77
  module
34
78
  },
79
+ performance: {
80
+ buildCache: resolveBuildCache({
81
+ buildCache,
82
+ configPath,
83
+ root: finalBuildConfig.root
84
+ })
85
+ },
35
86
  tools: {
36
87
  rspack,
37
88
  swc,
38
89
  bundlerChain
39
90
  },
40
- testEnvironment: 'node' === target ? 'node' : 'happy-dom'
91
+ testEnvironment: resolveTestEnvironmentFromTarget(target)
41
92
  };
93
+ return rstestConfig;
42
94
  }
43
95
  export { toRstestConfig };