@lynx-js/react 0.122.1 → 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 (76) hide show
  1. package/CHANGELOG.md +78 -0
  2. package/components/lib/Page.js +1 -1
  3. package/components/lib/Page.js.map +1 -1
  4. package/components/src/Page.ts +1 -1
  5. package/package.json +1 -1
  6. package/runtime/lazy/compat.js +1 -0
  7. package/runtime/lazy/react.js +1 -0
  8. package/runtime/lib/core/lynx/dynamic-import.d.ts +1 -0
  9. package/runtime/lib/core/lynx/dynamic-import.js +3 -2
  10. package/runtime/lib/core/lynx/dynamic-import.js.map +1 -1
  11. package/runtime/lib/core/lynx/lazy-bundle.d.ts +7 -1
  12. package/runtime/lib/core/lynx/lazy-bundle.js +182 -3
  13. package/runtime/lib/core/lynx/lazy-bundle.js.map +1 -1
  14. package/runtime/lib/core/lynx-data-processors.d.ts +1 -0
  15. package/runtime/lib/core/lynx-data-processors.js +19 -1
  16. package/runtime/lib/core/lynx-data-processors.js.map +1 -1
  17. package/runtime/lib/internal.js +9 -0
  18. package/runtime/lib/internal.js.map +1 -1
  19. package/runtime/lib/lynx-api.d.ts +19 -0
  20. package/runtime/lib/lynx-api.js +38 -5
  21. package/runtime/lib/lynx-api.js.map +1 -1
  22. package/runtime/lib/lynx.js +5 -0
  23. package/runtime/lib/lynx.js.map +1 -1
  24. package/runtime/lib/snapshot/lifecycle/constant.d.ts +3 -2
  25. package/runtime/lib/snapshot/lifecycle/constant.js +4 -1
  26. package/runtime/lib/snapshot/lifecycle/constant.js.map +1 -1
  27. package/runtime/lib/snapshot/lifecycle/event/firstScreenSync.d.ts +9 -0
  28. package/runtime/lib/snapshot/lifecycle/event/firstScreenSync.js +80 -0
  29. package/runtime/lib/snapshot/lifecycle/event/firstScreenSync.js.map +1 -0
  30. package/runtime/lib/snapshot/lifecycle/patch/snapshotPatchApply.js +5 -4
  31. package/runtime/lib/snapshot/lifecycle/patch/snapshotPatchApply.js.map +1 -1
  32. package/runtime/lib/snapshot/lifecycle/reload.js +3 -3
  33. package/runtime/lib/snapshot/lifecycle/reload.js.map +1 -1
  34. package/runtime/lib/snapshot/list/listUpdateInfo.js +8 -0
  35. package/runtime/lib/snapshot/list/listUpdateInfo.js.map +1 -1
  36. package/runtime/lib/snapshot/lynx/calledByNative.js +20 -9
  37. package/runtime/lib/snapshot/lynx/calledByNative.js.map +1 -1
  38. package/runtime/lib/snapshot/lynx/injectLepusMethods.js +1 -1
  39. package/runtime/lib/snapshot/lynx/injectLepusMethods.js.map +1 -1
  40. package/runtime/lib/snapshot/lynx/lazyBundleConstants.d.ts +4 -0
  41. package/runtime/lib/snapshot/lynx/lazyBundleConstants.js +8 -0
  42. package/runtime/lib/snapshot/lynx/lazyBundleConstants.js.map +1 -0
  43. package/runtime/lib/snapshot/lynx/prepareLazyBundleMTS.d.ts +1 -0
  44. package/runtime/lib/snapshot/lynx/prepareLazyBundleMTS.js +60 -0
  45. package/runtime/lib/snapshot/lynx/prepareLazyBundleMTS.js.map +1 -0
  46. package/runtime/lib/snapshot/lynx/tt.js +3 -3
  47. package/runtime/lib/snapshot/lynx/tt.js.map +1 -1
  48. package/runtime/lib/snapshot/renderToOpcodes/hydrate.js +7 -0
  49. package/runtime/lib/snapshot/renderToOpcodes/hydrate.js.map +1 -1
  50. package/runtime/lib/snapshot/snapshot/backgroundSnapshot.js +5 -2
  51. package/runtime/lib/snapshot/snapshot/backgroundSnapshot.js.map +1 -1
  52. package/runtime/lib/snapshot/snapshot/definition.js +4 -4
  53. package/runtime/lib/snapshot/snapshot/definition.js.map +1 -1
  54. package/runtime/lib/snapshot/snapshot/platformInfo.d.ts +3 -1
  55. package/runtime/lib/snapshot/snapshot/platformInfo.js +21 -2
  56. package/runtime/lib/snapshot/snapshot/platformInfo.js.map +1 -1
  57. package/runtime/lib/snapshot/snapshot/snapshot.d.ts +2 -5
  58. package/runtime/lib/snapshot/snapshot/snapshot.js +14 -16
  59. package/runtime/lib/snapshot/snapshot/snapshot.js.map +1 -1
  60. package/runtime/lib/snapshot/snapshot/snapshotCreatorMap.d.ts +16 -1
  61. package/runtime/lib/snapshot/snapshot/snapshotCreatorMap.js +8 -0
  62. package/runtime/lib/snapshot/snapshot/snapshotCreatorMap.js.map +1 -1
  63. package/runtime/lib/snapshot/snapshot/snapshotInstanceManager.d.ts +6 -0
  64. package/runtime/lib/snapshot/snapshot/snapshotInstanceManager.js +16 -0
  65. package/runtime/lib/snapshot/snapshot/snapshotInstanceManager.js.map +1 -0
  66. package/runtime/lib/snapshot/snapshot/spread.d.ts +1 -1
  67. package/runtime/lib/snapshot/snapshot/spread.js +11 -5
  68. package/runtime/lib/snapshot/snapshot/spread.js.map +1 -1
  69. package/runtime/lib/tsconfig.tsbuildinfo +1 -1
  70. package/testing-library/dist/0~@rstest/adapter-rsbuild.js +59 -7
  71. package/transform/dist/wasm.cjs +332 -125
  72. package/transform/index.d.ts +40 -0
  73. package/types/react.docs.d.ts +6 -0
  74. package/runtime/lib/snapshot/lifecycle/event/jsReady.d.ts +0 -6
  75. package/runtime/lib/snapshot/lifecycle/event/jsReady.js +0 -44
  76. 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 };