@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
@@ -0,0 +1,95 @@
1
+ import { dirname, isAbsolute as external_node_path_isAbsolute, normalize, resolve } from "node:path";
2
+ import { mergeRsbuildConfig } from "@rsbuild/core";
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 }) {
40
+ const { environments, ...rawBuildConfig } = rawRsbuildConfig;
41
+ const environmentConfig = environmentName ? environments?.[environmentName] : void 0;
42
+ const rsbuildConfig = environmentConfig ? mergeRsbuildConfig(rawBuildConfig, environmentConfig) : rawBuildConfig;
43
+ const finalBuildConfig = modifyRsbuildConfig ? modifyRsbuildConfig(rsbuildConfig) : rsbuildConfig;
44
+ const { rspack, swc, bundlerChain } = finalBuildConfig.tools || {};
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 = {
49
+ root: finalBuildConfig.root,
50
+ name: environmentName,
51
+ forceRerunTriggers: configPath ? [
52
+ normalize(configPath)
53
+ ] : void 0,
54
+ plugins: [
55
+ ...finalBuildConfig.plugins || [],
56
+ {
57
+ name: 'rsbuild-adapter:remove-useless-plugins',
58
+ remove: [
59
+ 'rsbuild:type-check'
60
+ ],
61
+ setup: ()=>{}
62
+ }
63
+ ],
64
+ source: {
65
+ assetsInclude,
66
+ decorators,
67
+ define,
68
+ include,
69
+ exclude,
70
+ tsconfigPath,
71
+ transformImport
72
+ },
73
+ resolve: finalBuildConfig.resolve,
74
+ output: {
75
+ cssModules,
76
+ emitAssets,
77
+ module
78
+ },
79
+ performance: {
80
+ buildCache: resolveBuildCache({
81
+ buildCache,
82
+ configPath,
83
+ root: finalBuildConfig.root
84
+ })
85
+ },
86
+ tools: {
87
+ rspack,
88
+ swc,
89
+ bundlerChain
90
+ },
91
+ testEnvironment: resolveTestEnvironmentFromTarget(target)
92
+ };
93
+ return rstestConfig;
94
+ }
95
+ export { toRstestConfig };
@@ -761,7 +761,7 @@ declare const initElementTree: () => {
761
761
  __CreateWrapperElement(parentComponentUniqueId: number): LynxElement;
762
762
  __AddInlineStyle(e: HTMLElement, key: number, value: string): void;
763
763
  __AppendElement(parent: LynxElement, child: LynxElement): void;
764
- __SetCSSId(e: LynxElement[] | LynxElement, id: string, entryName?: string | undefined): void;
764
+ __SetCSSId(e: LynxElement | LynxElement[], id: string, entryName?: string): void;
765
765
  __SetAttribute(e: LynxElement, key: string, value: any): void;
766
766
  __AddEvent(e: LynxElement, eventType: string, eventName: string, eventHandler: string | Record<string, any>): void;
767
767
  __GetEvent(e: LynxElement, eventType: string, eventName: string): {
@@ -777,7 +777,7 @@ declare const initElementTree: () => {
777
777
  __RemoveGestureDetector(e: LynxElement, id: number): void;
778
778
  __GetDataset(e: LynxElement): DOMStringMap;
779
779
  __RemoveElement(parent: LynxElement, child: LynxElement): void;
780
- __InsertElementBefore(parent: LynxElement, child: LynxElement, ref?: LynxElement | undefined): void;
780
+ __InsertElementBefore(parent: LynxElement, child: LynxElement, ref?: LynxElement): void;
781
781
  __ReplaceElement(newElement: LynxElement, oldElement: LynxElement): void;
782
782
  __FlushElementTree(): void;
783
783
  __UpdateListComponents(_list: LynxElement, _components: string[]): void;
@@ -6,7 +6,7 @@ import { act } from "preact/test-utils";
6
6
  import { __root } from "@lynx-js/react/internal";
7
7
  import { flushDelayedLifecycleEvents } from "../../runtime/lib/snapshot/lynx/tt.js";
8
8
  import { clearPage } from "../../runtime/lib/snapshot/index.js";
9
- import { __webpack_require__ } from "./0~rslib-runtime.js";
9
+ import { __webpack_require__ } from "./0-rslib-runtime.js";
10
10
  __webpack_require__.add({
11
11
  "../../../node_modules/.pnpm/ansi-regex@5.0.1/node_modules/ansi-regex/index.js" (module1) {
12
12
  module1.exports = ({ onlyFirst = false } = {})=>{
@@ -29,7 +29,7 @@ function withLynxConfig(options) {
29
29
  cwd: options?.rootPath,
30
30
  configPath: options?.configPath
31
31
  });
32
- const { toRstestConfig } = await import("./0~@rstest/adapter-rsbuild.js");
32
+ const { toRstestConfig } = await import("./0-@rstest/adapter-rsbuild.js");
33
33
  const rstestConfig = toRstestConfig({
34
34
  rsbuildConfig: lynxConfig.content
35
35
  });