@lynx-js/react 0.129.1 → 0.129.3

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 (129) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/components/tsconfig.tsbuildinfo +1 -1
  3. package/package.json +1 -1
  4. package/refresh/.turbo/turbo-build.log +1 -1
  5. package/runtime/__test__/core/globalProps.test.ts +27 -6
  6. package/runtime/__test__/element-template/fixtures/gesture/direct/index.tsx +33 -0
  7. package/runtime/__test__/element-template/fixtures/spread/mts/index.tsx +197 -0
  8. package/runtime/__test__/element-template/native/callDestroyLifetimeFun.test.ts +89 -3
  9. package/runtime/__test__/element-template/native/mts-destroy.test.ts +8 -3
  10. package/runtime/__test__/element-template/native/reload.test.ts +87 -0
  11. package/runtime/__test__/element-template/runtime/background/global-props/compiled-fixtures.test.tsx +5 -5
  12. package/runtime/__test__/element-template/runtime/background/global-props.test.tsx +1 -1
  13. package/runtime/__test__/element-template/runtime/background/hydrate.test.ts +70 -0
  14. package/runtime/__test__/element-template/runtime/background/ref/compiled-fixtures.test.tsx +3 -4
  15. package/runtime/__test__/element-template/runtime/background/reload.test.ts +74 -0
  16. package/runtime/__test__/element-template/runtime/patch/element-template-patch.test.tsx +15 -0
  17. package/runtime/__test__/element-template/runtime/prop-adapters/gesture-compiled.test.ts +200 -0
  18. package/runtime/__test__/element-template/runtime/prop-adapters/gesture.test.ts +420 -0
  19. package/runtime/__test__/element-template/runtime/prop-adapters/spread-mts-compiled.test.ts +527 -0
  20. package/runtime/__test__/element-template/runtime/prop-adapters/spread.test.ts +185 -6
  21. package/runtime/__test__/element-template/runtime/render/render-direct-native.test.tsx +21 -1
  22. package/runtime/__test__/element-template/runtime/template/main-thread-dynamic-attr-state.test.ts +188 -0
  23. package/runtime/__test__/snapshot/compat/export.test.jsx +8 -2
  24. package/runtime/__test__/snapshot/lifecycle/updateGlobalProps.event.test.jsx +2 -2
  25. package/runtime/__test__/snapshot/lifecycle/updateGlobalProps.test.jsx +3 -3
  26. package/runtime/__test__/snapshot/ref.test.jsx +30 -0
  27. package/runtime/__test__/worklet-runtime/initEntry.test.js +12 -0
  28. package/runtime/compat/index.d.ts +17 -1
  29. package/runtime/compat/index.js +3 -2
  30. package/runtime/lazy/compat.js +1 -0
  31. package/runtime/lazy/element-template-internal.js +1 -0
  32. package/runtime/lib/core/globalProps.js +1 -1
  33. package/runtime/lib/core/globalProps.js.map +1 -1
  34. package/runtime/lib/element-template/background/attr-slots.js +5 -2
  35. package/runtime/lib/element-template/background/attr-slots.js.map +1 -1
  36. package/runtime/lib/element-template/background/destroy.js +16 -11
  37. package/runtime/lib/element-template/background/destroy.js.map +1 -1
  38. package/runtime/lib/element-template/background/hydrate.js +23 -0
  39. package/runtime/lib/element-template/background/hydrate.js.map +1 -1
  40. package/runtime/lib/element-template/debug/alog.d.ts +1 -1
  41. package/runtime/lib/element-template/debug/alog.js +4 -1
  42. package/runtime/lib/element-template/debug/alog.js.map +1 -1
  43. package/runtime/lib/element-template/internal.d.ts +1 -1
  44. package/runtime/lib/element-template/internal.js +1 -1
  45. package/runtime/lib/element-template/internal.js.map +1 -1
  46. package/runtime/lib/element-template/native/callDestroyLifetimeFun.js +6 -1
  47. package/runtime/lib/element-template/native/callDestroyLifetimeFun.js.map +1 -1
  48. package/runtime/lib/element-template/native/patch-listener.js +1 -1
  49. package/runtime/lib/element-template/native/patch-listener.js.map +1 -1
  50. package/runtime/lib/element-template/native/reload-background.js +1 -1
  51. package/runtime/lib/element-template/native/reload-background.js.map +1 -1
  52. package/runtime/lib/element-template/native/reload-main-thread.js +33 -9
  53. package/runtime/lib/element-template/native/reload-main-thread.js.map +1 -1
  54. package/runtime/lib/element-template/prop-adapters/gesture.d.ts +23 -0
  55. package/runtime/lib/element-template/prop-adapters/gesture.js +97 -0
  56. package/runtime/lib/element-template/prop-adapters/gesture.js.map +1 -0
  57. package/runtime/lib/element-template/prop-adapters/spread.d.ts +6 -1
  58. package/runtime/lib/element-template/prop-adapters/spread.js +72 -2
  59. package/runtime/lib/element-template/prop-adapters/spread.js.map +1 -1
  60. package/runtime/lib/element-template/protocol/opcodes.d.ts +1 -0
  61. package/runtime/lib/element-template/protocol/opcodes.js +1 -0
  62. package/runtime/lib/element-template/protocol/opcodes.js.map +1 -1
  63. package/runtime/lib/element-template/protocol/types.d.ts +7 -1
  64. package/runtime/lib/element-template/protocol/types.js.map +1 -1
  65. package/runtime/lib/element-template/runtime/patch.js +27 -2
  66. package/runtime/lib/element-template/runtime/patch.js.map +1 -1
  67. package/runtime/lib/element-template/runtime/template/attr-slot-plan.d.ts +4 -2
  68. package/runtime/lib/element-template/runtime/template/attr-slot-plan.js +17 -4
  69. package/runtime/lib/element-template/runtime/template/attr-slot-plan.js.map +1 -1
  70. package/runtime/lib/element-template/runtime/template/main-thread-dynamic-attr-state.d.ts +7 -2
  71. package/runtime/lib/element-template/runtime/template/main-thread-dynamic-attr-state.js +368 -58
  72. package/runtime/lib/element-template/runtime/template/main-thread-dynamic-attr-state.js.map +1 -1
  73. package/runtime/lib/element-template/runtime/template/main-thread-ref-ctx.d.ts +2 -1
  74. package/runtime/lib/element-template/runtime/template/main-thread-ref-ctx.js +10 -1
  75. package/runtime/lib/element-template/runtime/template/main-thread-ref-ctx.js.map +1 -1
  76. package/runtime/lib/element-template/runtime/template/typed-attributes.js +3 -3
  77. package/runtime/lib/element-template/runtime/template/typed-attributes.js.map +1 -1
  78. package/runtime/lib/snapshot/lifecycle/destroy.js +23 -17
  79. package/runtime/lib/snapshot/lifecycle/destroy.js.map +1 -1
  80. package/runtime/lib/snapshot/lifecycle/ref/delay.d.ts +5 -0
  81. package/runtime/lib/snapshot/lifecycle/ref/delay.js +1 -1
  82. package/runtime/lib/snapshot/lifecycle/ref/delay.js.map +1 -1
  83. package/runtime/lib/tsconfig.tsbuildinfo +1 -1
  84. package/runtime/lib/worklet-runtime/utils/version.js +4 -1
  85. package/runtime/lib/worklet-runtime/utils/version.js.map +1 -1
  86. package/runtime/src/core/globalProps.ts +1 -1
  87. package/runtime/src/element-template/background/attr-slots.ts +5 -1
  88. package/runtime/src/element-template/background/destroy.ts +16 -13
  89. package/runtime/src/element-template/background/hydrate.ts +23 -0
  90. package/runtime/src/element-template/debug/alog.ts +5 -2
  91. package/runtime/src/element-template/internal.ts +1 -0
  92. package/runtime/src/element-template/native/callDestroyLifetimeFun.ts +5 -1
  93. package/runtime/src/element-template/native/patch-listener.ts +1 -1
  94. package/runtime/src/element-template/native/reload-background.ts +1 -1
  95. package/runtime/src/element-template/native/reload-main-thread.ts +30 -10
  96. package/runtime/src/element-template/prop-adapters/gesture.ts +144 -0
  97. package/runtime/src/element-template/prop-adapters/spread.ts +110 -2
  98. package/runtime/src/element-template/protocol/opcodes.ts +1 -0
  99. package/runtime/src/element-template/protocol/types.ts +8 -0
  100. package/runtime/src/element-template/runtime/patch.ts +33 -0
  101. package/runtime/src/element-template/runtime/template/attr-slot-plan.ts +31 -4
  102. package/runtime/src/element-template/runtime/template/main-thread-dynamic-attr-state.ts +441 -65
  103. package/runtime/src/element-template/runtime/template/main-thread-ref-ctx.ts +12 -2
  104. package/runtime/src/element-template/runtime/template/typed-attributes.ts +3 -3
  105. package/runtime/src/snapshot/lifecycle/destroy.ts +23 -18
  106. package/runtime/src/snapshot/lifecycle/ref/delay.ts +1 -1
  107. package/runtime/src/worklet-runtime/utils/version.ts +4 -1
  108. package/runtime/types/types.d.ts +2 -1
  109. package/testing-library/.turbo/turbo-build.log +7 -7
  110. package/transform/.turbo/turbo-build$colon$wasm.log +72 -71
  111. package/transform/__test__/fixture.spec.js +11 -11
  112. package/transform/__test__/main-thread-object-compat.spec.js +111 -0
  113. package/transform/crates/swc_plugin_element_template/lib.rs +11 -0
  114. package/transform/crates/swc_plugin_element_template/tests/element_template_contract.rs +113 -0
  115. package/transform/crates/swc_plugin_worklet/gen_stmt.rs +7 -9
  116. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_capture_env_js.js +3 -3
  117. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_capture_env_lepus.js +3 -3
  118. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_member_expr_2_js.js +7 -7
  119. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_member_expr_2_lepus.js +7 -7
  120. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_member_expr_js.js +8 -8
  121. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_member_expr_lepus.js +8 -8
  122. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_preserve_main_thread_objects_in_class_js.js +5 -5
  123. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_preserve_main_thread_objects_in_class_lepus.js +5 -5
  124. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_js.js +1 -1
  125. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_lepus.js +1 -1
  126. package/transform/dist/wasm.cjs +1 -1
  127. package/transform/swc-plugin-reactlynx/.turbo/turbo-build.log +97 -97
  128. package/transform/swc-plugin-reactlynx/swc_plugin_reactlynx.wasm +0 -0
  129. package/transform/swc-plugin-reactlynx-compat/.turbo/turbo-build.log +177 -178
@@ -8,6 +8,7 @@ import { delayedEvents } from './event/delayEvents.js';
8
8
  import { delayedLifecycleEvents } from './event/delayLifecycleEvents.js';
9
9
  import { globalCommitTaskMap } from './patch/commit.js';
10
10
  import { deinitGlobalSnapshotPatch } from './patch/snapshotPatch.js';
11
+ import { delayedUiOps } from './ref/delay.js';
11
12
  import { profileEnd, profileStart } from '../../shared/profile.js';
12
13
  import { withSyncEffectFlush } from '../../utils.js';
13
14
  import { resetSnapshotMainThreadFunctionRuntime } from '../worklet/call/runOnMainThread.js';
@@ -20,25 +21,29 @@ function destroyBackground(): void {
20
21
 
21
22
  deinitGlobalSnapshotPatch();
22
23
 
23
- withSyncEffectFlush(() => {
24
- // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
25
- render(null, __root as any);
26
- });
24
+ try {
25
+ withSyncEffectFlush(() => {
26
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
27
+ render(null, __root as any);
28
+ });
27
29
 
28
- globalCommitTaskMap.forEach(task => {
29
- task();
30
- });
31
- globalCommitTaskMap.clear();
32
- // Clear delayed events which should not be executed after destroyed.
33
- // This is important when the page is performing a reload.
34
- delayedLifecycleEvents.length = 0;
35
- if (delayedEvents) {
36
- delayedEvents.length = 0;
37
- }
38
- resetSnapshotBackgroundFunctionRuntime();
39
- resetSnapshotMainThreadFunctionRuntime();
40
- if (typeof __PROFILE__ !== 'undefined' && __PROFILE__) {
41
- profileEnd();
30
+ globalCommitTaskMap.forEach(task => {
31
+ task();
32
+ });
33
+ } finally {
34
+ globalCommitTaskMap.clear();
35
+ // Clear delayed events which should not be executed after destroyed.
36
+ // This is important when the page is performing a reload.
37
+ delayedLifecycleEvents.length = 0;
38
+ if (delayedEvents) {
39
+ delayedEvents.length = 0;
40
+ }
41
+ delayedUiOps.length = 0;
42
+ resetSnapshotBackgroundFunctionRuntime();
43
+ resetSnapshotMainThreadFunctionRuntime();
44
+ if (typeof __PROFILE__ !== 'undefined' && __PROFILE__) {
45
+ profileEnd();
46
+ }
42
47
  }
43
48
  }
44
49
 
@@ -79,4 +79,4 @@ interface RefProxy extends RefProxyForwardedMethods<RefProxy> {}
79
79
  /**
80
80
  * @internal
81
81
  */
82
- export { RefProxy, runDelayedUiOps, shouldDelayUiOps };
82
+ export { delayedUiOps, RefProxy, runDelayedUiOps, shouldDelayUiOps };
@@ -2,7 +2,10 @@
2
2
  // Licensed under the Apache License Version 2.0 that can be found in the
3
3
  // LICENSE file in the root directory of this source tree.
4
4
  export function isSdkVersionGt(major: number, minor: number): boolean {
5
- const lynxSdkVersion: string = SystemInfo.lynxSdkVersion ?? '1.0';
5
+ // Worklet initialization can run before ReactLynx installs the global alias.
6
+ const lynxSdkVersion = (globalThis as typeof globalThis & { SystemInfo?: ISystemInfo }).SystemInfo?.lynxSdkVersion
7
+ ?? (lynx as typeof lynx & { SystemInfo?: ISystemInfo }).SystemInfo?.lynxSdkVersion
8
+ ?? '1.0';
6
9
  const version = lynxSdkVersion.split('.');
7
10
  return (
8
11
  Number(version[0]) > major
@@ -11,6 +11,7 @@ import type { InitData, InitDataRaw } from '../src/lynx-api.js';
11
11
 
12
12
  interface ReactLynxRuntimeConfig {
13
13
  [key: string]: unknown;
14
+ globalPropsMode?: 'reactive' | 'event';
14
15
  transformBuiltinAttributeNames?:
15
16
  | boolean
16
17
  | TransformBuiltinAttributeNamesOptions;
@@ -21,6 +22,7 @@ declare global {
21
22
  declare const __REF_FIRE_IMMEDIATELY__: boolean;
22
23
  declare const __TESTING_FORCE_RENDER_TO_OPCODE__: boolean;
23
24
  declare const __FIRST_SCREEN_SYNC_TIMING__: 'immediately' | 'jsReady' | 'manual';
25
+ declare const __GLOBAL_PROPS_MODE__: 'reactive' | 'event' | undefined;
24
26
  declare const __DEV__: boolean;
25
27
  declare const __JS__: boolean;
26
28
  declare const __LEPUS__: boolean;
@@ -32,7 +34,6 @@ declare global {
32
34
  declare const __ALOG__: boolean | undefined;
33
35
  declare const __ALOG_ELEMENT_API__: boolean | undefined;
34
36
  declare const __ENABLE_SSR__: boolean;
35
- declare const __GLOBAL_PROPS_MODE__: 'reactive' | 'event' | undefined;
36
37
  declare const __LAZY_BUNDLE_FETCHER__: 'FetchBundle' | 'QueryComponent';
37
38
  declare const __RUNTIME_VERSION__: string | undefined;
38
39
  declare const __EXPERIMENTAL_RE_EVAL_JS_ON_RELOAD__: boolean | undefined;
@@ -2,14 +2,14 @@ $ rslib
2
2
  Rslib v1.0.2
3
3
 
4
4
  info build started...
5
- start generating declaration files... (esm2)
6
5
  start generating declaration files... (esm0)
7
- ready built in 0.71s (esm2)
8
- ready built in 0.82s (esm1)
9
- ready built in 1.15s (esm0)
10
- info declaration files prepared with tsgo in 1.45 s (esm2)
11
- ready declaration files generated in 6.22 s (esm0)
12
- ready declaration files bundled successfully: dist/index.d.ts in 3.79 s (esm2)
6
+ start generating declaration files... (esm2)
7
+ ready built in 0.57s (esm2)
8
+ ready built in 0.67s (esm1)
9
+ ready built in 0.84s (esm0)
10
+ info declaration files prepared with tsgo in 1.25 s (esm2)
11
+ ready declaration files bundled successfully: dist/index.d.ts in 1.96 s (esm2)
12
+ ready declaration files generated in 4.87 s (esm0)
13
13
 
14
14
  File (esm0) Size
15
15
  dist/rslib-runtime-0.js 1.6 kB
@@ -1,15 +1,16 @@
1
1
  $ node ./scripts/build_wasm.js
2
2
  Blocking waiting for file lock on package cache
3
3
  Blocking waiting for file lock on package cache
4
+ Blocking waiting for file lock on package cache
4
5
  Downloading crates ...
5
- Downloaded napi-build v2.3.2
6
6
  Downloaded convert_case v0.6.0
7
- Downloaded napi-sys v2.4.0
8
- Downloaded ctor v0.1.26
9
7
  Downloaded bitflags v1.3.2
10
- Downloaded napi-derive-backend v1.0.40
8
+ Downloaded ctor v0.1.26
11
9
  Downloaded napi v2.10.4
10
+ Downloaded napi-build v2.3.2
12
11
  Downloaded napi-derive v2.9.3
12
+ Downloaded napi-sys v2.4.0
13
+ Downloaded napi-derive-backend v1.0.40
13
14
  Downloaded version-compare v0.2.1
14
15
  Blocking waiting for file lock on build directory
15
16
  Compiling cfg-if v1.0.4
@@ -17,8 +18,8 @@ $ node ./scripts/build_wasm.js
17
18
  Compiling allocator-api2 v0.2.21
18
19
  Compiling serde v1.0.229
19
20
  Compiling once_cell v1.21.4
20
- Compiling stable_deref_trait v1.2.1
21
21
  Compiling memchr v2.8.3
22
+ Compiling stable_deref_trait v1.2.1
22
23
  Compiling zerofrom v0.1.8
23
24
  Compiling equivalent v1.0.2
24
25
  Compiling foldhash v0.2.0
@@ -36,50 +37,50 @@ $ node ./scripts/build_wasm.js
36
37
  Compiling litemap v0.8.2
37
38
  Compiling writeable v0.6.3
38
39
  Compiling potential_utf v0.1.5
39
- Compiling zerotrie v0.2.4
40
40
  Compiling icu_locale_core v2.2.0
41
+ Compiling zerotrie v0.2.4
41
42
  Compiling utf8_iter v1.0.4
42
43
  Compiling icu_collections v2.2.0
43
44
  Compiling indexmap v2.14.0
44
45
  Compiling icu_provider v2.2.0
45
46
  Compiling num-traits v0.2.19
46
- Compiling icu_normalizer_data v2.2.0
47
47
  Compiling icu_properties_data v2.2.0
48
+ Compiling icu_normalizer_data v2.2.0
48
49
  Compiling rustc-hash v2.1.3
49
50
  Compiling parking_lot_core v0.9.12
50
- Compiling icu_normalizer v2.2.0
51
51
  Compiling icu_properties v2.2.0
52
+ Compiling icu_normalizer v2.2.0
53
+ Compiling hashbrown v0.14.5
52
54
  Compiling either v1.17.0
53
55
  Compiling scopeguard v1.2.0
54
56
  Compiling lock_api v0.4.14
55
57
  Compiling radium v0.7.0
56
- Compiling hashbrown v0.14.5
57
- Compiling tracing-core v0.1.36
58
58
  Compiling idna_adapter v1.2.2
59
- Compiling tap v1.0.1
59
+ Compiling tracing-core v0.1.36
60
60
  Compiling percent-encoding v2.3.2
61
- Compiling idna v1.1.0
62
- Compiling wyz v0.5.1
61
+ Compiling tap v1.0.1
63
62
  Compiling form_urlencoded v1.2.2
63
+ Compiling wyz v0.5.1
64
+ Compiling idna v1.1.0
64
65
  Compiling anyhow v1.0.104
66
+ Compiling funty v2.0.0
65
67
  Compiling bytes v1.12.1
68
+ Compiling vsimd v0.8.0
66
69
  Compiling pin-project-lite v0.2.17
67
- Compiling uuid v1.24.0
68
70
  Compiling outref v0.5.2
69
- Compiling vsimd v0.8.0
70
- Compiling funty v2.0.0
71
+ Compiling uuid v1.24.0
71
72
  Compiling base64-simd v0.8.0
72
- Compiling bytes-str v0.2.8
73
- Compiling debugid v0.8.0
74
- Compiling url v2.5.8
75
73
  Compiling tracing v0.1.44
74
+ Compiling debugid v0.8.0
75
+ Compiling bytes-str v0.2.8
76
76
  Compiling bitvec v1.1.1
77
+ Compiling url v2.5.8
77
78
  Compiling triomphe v0.1.16
78
- Compiling unicode-width v0.2.2
79
79
  Compiling new_debug_unreachable v1.0.6
80
80
  Compiling data-encoding v2.11.0
81
- Compiling unicode-id-start v1.4.0
82
81
  Compiling if_chain v1.0.3
82
+ Compiling unicode-id-start v1.4.0
83
+ Compiling unicode-width v0.2.2
83
84
  Compiling hstr v4.0.0
84
85
  Compiling num-integer v0.1.46
85
86
  Compiling scoped-tls v1.0.1
@@ -89,131 +90,131 @@ $ node ./scripts/build_wasm.js
89
90
  Compiling parking_lot v0.12.5
90
91
  Compiling swc_visit v2.0.2
91
92
  Compiling termcolor v1.4.1
92
- Compiling swc_sourcemap v10.0.2
93
93
  Compiling siphasher v0.3.11
94
+ Compiling swc_sourcemap v10.0.2
94
95
  Compiling bitflags v2.13.1
95
96
  Compiling siphasher v1.0.3
96
97
  Compiling phf_shared v0.11.3
97
98
  Compiling libc v0.2.189
98
99
  Compiling dragonbox_ecma v0.1.12
99
- Compiling par-core v2.0.0
100
100
  Compiling phf v0.11.3
101
+ Compiling par-core v2.0.0
101
102
  Compiling num_cpus v1.17.0
102
103
  Compiling castaway v0.2.4
103
- Compiling ryu v1.0.23
104
104
  Compiling static_assertions v1.1.0
105
+ Compiling ryu v1.0.23
105
106
  Compiling aho-corasick v1.1.4
106
107
  Compiling compact_str v0.7.1
107
108
  Compiling swc_common v26.0.0
108
109
  Compiling regex-syntax v0.8.11
109
110
  Compiling swc_ecma_ast v29.0.0
110
111
  Compiling regex-automata v0.4.16
111
- Compiling typenum v1.20.1
112
112
  Compiling swc_ecma_regexp_common v0.0.1
113
+ Compiling typenum v1.20.1
113
114
  Compiling swc_ecma_regexp_ast v3.0.0
114
115
  Compiling crossbeam-utils v0.8.22
115
116
  Compiling swc_ecma_regexp_visit v0.15.0
116
- Compiling swc_ecma_regexp v0.15.0
117
- Compiling swc_ecma_compat_regexp v9.0.0
118
117
  Compiling swc_ecma_visit v29.0.0
119
118
  Compiling swc_ecma_parser v45.1.1
120
119
  Compiling regex v1.13.1
120
+ Compiling swc_ecma_regexp v0.15.0
121
+ Compiling swc_ecma_compat_regexp v9.0.0
121
122
  Compiling dashmap v6.2.1
122
123
  Compiling generic-array v0.14.7
123
- Compiling bstr v1.13.0
124
124
  Compiling hashbrown v0.16.1
125
- Compiling regress v0.11.1
125
+ Compiling bstr v1.13.0
126
126
  Compiling globset v0.4.19
127
- Compiling crypto-common v0.1.7
127
+ Compiling regress v0.11.1
128
128
  Compiling block-buffer v0.10.4
129
- Compiling swc_config v6.0.0
129
+ Compiling crypto-common v0.1.7
130
130
  Compiling digest v0.10.7
131
131
  Compiling arrayvec v0.7.8
132
132
  Compiling thiserror v1.0.69
133
133
  Compiling owo-colors v4.3.0
134
134
  Compiling semver v1.0.28
135
- Compiling unicode-linebreak v0.1.5
136
135
  Compiling fixedbitset v0.5.7
137
- Compiling base64 v0.22.1
138
- Compiling petgraph v0.7.1
139
- Compiling textwrap v0.16.2
136
+ Compiling swc_config v6.0.0
140
137
  Compiling swc_ecma_utils v35.0.0
141
138
  Compiling swc_ecma_hooks v1.0.0
139
+ Compiling base64 v0.22.1
140
+ Compiling unicode-linebreak v0.1.5
141
+ Compiling textwrap v0.16.2
142
+ Compiling swc_ecma_transforms_base v49.0.1
143
+ Compiling petgraph v0.7.1
144
+ Compiling swc_ecma_transformer v21.0.1
145
+ Compiling swc_ecma_transforms_classes v49.0.0
146
+ Compiling swc_ecma_compat_common v45.0.0
142
147
  Compiling bumpalo v3.20.3
143
148
  Compiling thread_local v1.1.10
144
149
  Compiling unicode-width v0.1.14
145
- Compiling miette v7.6.0
146
- Compiling swc_ecma_transforms_base v49.0.1
147
150
  Compiling camino v1.2.4
151
+ Compiling miette v7.6.0
148
152
  Compiling swc_allocator v5.0.0
153
+ Compiling swc_ecma_compat_es2015 v55.0.0
154
+ Compiling swc_ecma_compat_es2022 v53.0.0
155
+ Compiling swc_ecma_transforms_optimization v52.0.0
149
156
  Compiling sha1 v0.10.7
150
157
  Compiling chrono v0.4.45
151
158
  Compiling syn v1.0.109
152
- Compiling lazy_static v1.5.0
153
159
  Compiling ascii v1.1.0
154
160
  Compiling log v0.4.33
161
+ Compiling lazy_static v1.5.0
162
+ Compiling sharded-slab v0.1.7
155
163
  Compiling tracing-log v0.2.0
156
- Compiling browserslist-data v0.2.0
157
- Compiling swc_ecma_transformer v21.0.1
158
- Compiling swc_ecma_transforms_classes v49.0.0
159
- Compiling swc_ecma_compat_common v45.0.0
160
- Compiling swc_ecma_compat_es2015 v55.0.0
161
- Compiling swc_ecma_compat_es2022 v53.0.0
162
- Compiling swc_ecma_transforms_optimization v52.0.0
164
+ Compiling swc_ecma_codegen v32.0.0
163
165
  Compiling swc_ecma_compat_bugfixes v56.0.0
166
+ Compiling browserslist-data v0.2.0
167
+ Compiling swc_ecma_transforms_react v55.0.1
164
168
  Compiling swc_ecma_compat_es2020 v53.0.0
169
+ Compiling swc_error_reporters v28.0.0
170
+ Compiling swc_ecma_compat_es2019 v50.0.0
165
171
  Compiling swc_ecma_compat_es2017 v50.0.0
166
172
  Compiling swc_ecma_compat_es2021 v50.0.0
167
- Compiling swc_ecma_compat_es2016 v50.0.0
168
173
  Compiling swc_ecma_compat_es2018 v51.0.0
169
- Compiling swc_ecma_compat_es2019 v50.0.0
170
- Compiling swc_ecma_transforms_react v55.0.1
171
- Compiling swc_ecma_codegen v32.0.0
172
- Compiling sharded-slab v0.1.7
173
- Compiling swc_error_reporters v28.0.0
174
+ Compiling swc_ecma_compat_es2016 v50.0.0
174
175
  Compiling matchers v0.2.0
175
176
  Compiling itertools v0.15.0
176
177
  Compiling cargo-platform v0.1.9
177
178
  Compiling nom v8.0.0
178
- Compiling nu-ansi-term v0.50.3
179
179
  Compiling yansi v1.0.1
180
180
  Compiling diff v0.1.13
181
+ Compiling nu-ansi-term v0.50.3
181
182
  Compiling pretty_assertions v1.4.1
182
183
  Compiling tracing-subscriber v0.3.23
183
184
  Compiling st-map v0.2.4
184
185
  Compiling cargo_metadata v0.18.1
185
186
  Compiling browserslist-rs v0.20.0
186
- Compiling swc_ecma_transforms_typescript v55.0.1
187
187
  Compiling swc_ecma_transforms_compat v57.0.1
188
+ Compiling swc_ecma_transforms_typescript v55.0.1
188
189
  Compiling swc_ecma_transforms_proposal v49.0.0
189
190
  Compiling par-iter v2.0.0
190
191
  Compiling difference v2.0.0
192
+ Compiling radix_fmt v1.0.0
191
193
  Compiling ryu-js v1.0.3
192
194
  Compiling pathdiff v0.2.3
193
- Compiling radix_fmt v1.0.0
194
- Compiling swc_ecma_transforms v62.0.0
195
195
  Compiling testing v27.0.0
196
+ Compiling swc_ecma_minifier v61.0.4
197
+ Compiling swc_ecma_transforms v62.0.0
196
198
  Compiling preset_env_base v9.0.0
197
199
  Compiling swc_ecma_preset_env v63.0.0
198
- Compiling swc_ecma_minifier v61.0.4
199
200
  Compiling sha2 v0.10.9
200
201
  Compiling lru v0.18.4
201
- Compiling precomputed-map v0.2.0
202
+ Compiling fastrand v2.5.0
202
203
  Compiling hex v0.4.3
203
204
  Compiling foldhash v0.1.5
204
- Compiling unicode-segmentation v1.13.3
205
205
  Compiling path-clean v1.0.1
206
- Compiling fastrand v2.5.0
207
- Compiling tempfile v3.27.0
208
- Compiling swc_ecma_loader v27.0.0
206
+ Compiling precomputed-map v0.2.0
207
+ Compiling unicode-segmentation v1.13.3
209
208
  Compiling convert_case v0.6.0
209
+ Compiling swc_ecma_loader v27.0.0
210
210
  Compiling swc_ecma_testing v27.0.0
211
+ Compiling tempfile v3.27.0
211
212
  Compiling swc_ecma_ext_transforms v35.0.0
212
213
  Compiling swc_node_comments v27.0.0
213
214
  Compiling swc_transform_common v20.0.0
214
215
  Compiling jsonc-parser v0.26.3
215
- Compiling ansi_term v0.12.1
216
216
  Compiling swc_core v77.1.2
217
+ Compiling ansi_term v0.12.1
217
218
  Compiling swc_ecma_transforms_testing v53.0.0
218
219
  Compiling napi-derive-backend v1.0.40
219
220
  Compiling swc_compiler_base v64.0.0
@@ -223,16 +224,16 @@ $ node ./scripts/build_wasm.js
223
224
  Compiling napi-sys v2.4.0
224
225
  Compiling napi v2.10.4
225
226
  Compiling napi-derive v2.9.3
226
- Compiling convert_case v0.11.0
227
227
  Compiling sha-1 v0.10.1
228
228
  Compiling sugar_path v1.2.1
229
- Compiling swc_plugins_shared v0.1.0 (/home/runner/work/lynx-stack/lynx-stack/packages/react/transform/crates/swc_plugins_shared)
230
229
  Compiling hybrid-array v0.4.13
230
+ Compiling convert_case v0.11.0
231
+ Compiling swc_plugins_shared v0.1.0 (/home/runner/work/lynx-stack/lynx-stack/packages/react/transform/crates/swc_plugins_shared)
231
232
  Compiling crypto-common v0.2.2
232
233
  Compiling block-buffer v0.12.1
233
234
  Compiling const-oid v0.10.2
234
- Compiling digest v0.11.3
235
235
  Compiling napi-build v2.3.2
236
+ Compiling digest v0.11.3
236
237
  Compiling getrandom v0.4.3
237
238
  Compiling react-transform v0.0.0 (/home/runner/work/lynx-stack/lynx-stack/packages/react/transform)
238
239
  Compiling sha2 v0.11.0
@@ -241,13 +242,13 @@ $ node ./scripts/build_wasm.js
241
242
  Compiling swc_plugin_directive_dce v0.1.0 (/home/runner/work/lynx-stack/lynx-stack/packages/react/transform/crates/swc_plugin_directive_dce)
242
243
  Compiling swc_plugin_element_template v0.1.0 (/home/runner/work/lynx-stack/lynx-stack/packages/react/transform/crates/swc_plugin_element_template)
243
244
  Compiling swc_plugin_list v0.1.0 (/home/runner/work/lynx-stack/lynx-stack/packages/react/transform/crates/swc_plugin_list)
244
- Compiling swc_plugin_inject v0.1.0 (/home/runner/work/lynx-stack/lynx-stack/packages/react/transform/crates/swc_plugin_inject)
245
- Compiling swc_plugin_compat v0.1.0 (/home/runner/work/lynx-stack/lynx-stack/packages/react/transform/crates/swc_plugin_compat)
246
- Compiling swc_plugin_dynamic_import v0.1.0 (/home/runner/work/lynx-stack/lynx-stack/packages/react/transform/crates/swc_plugin_dynamic_import)
245
+ Compiling swc_plugin_css_scope v0.1.0 (/home/runner/work/lynx-stack/lynx-stack/packages/react/transform/crates/swc_plugin_css_scope)
247
246
  Compiling swc_plugin_shake v0.1.0 (/home/runner/work/lynx-stack/lynx-stack/packages/react/transform/crates/swc_plugin_shake)
248
- Compiling swc_plugin_worklet v0.1.0 (/home/runner/work/lynx-stack/lynx-stack/packages/react/transform/crates/swc_plugin_worklet)
247
+ Compiling swc_plugin_dynamic_import v0.1.0 (/home/runner/work/lynx-stack/lynx-stack/packages/react/transform/crates/swc_plugin_dynamic_import)
249
248
  Compiling swc_plugin_text v0.1.0 (/home/runner/work/lynx-stack/lynx-stack/packages/react/transform/crates/swc_plugin_text)
250
- Compiling swc_plugin_css_scope v0.1.0 (/home/runner/work/lynx-stack/lynx-stack/packages/react/transform/crates/swc_plugin_css_scope)
249
+ Compiling swc_plugin_compat v0.1.0 (/home/runner/work/lynx-stack/lynx-stack/packages/react/transform/crates/swc_plugin_compat)
250
+ Compiling swc_plugin_worklet v0.1.0 (/home/runner/work/lynx-stack/lynx-stack/packages/react/transform/crates/swc_plugin_worklet)
251
+ Compiling swc_plugin_inject v0.1.0 (/home/runner/work/lynx-stack/lynx-stack/packages/react/transform/crates/swc_plugin_inject)
251
252
  Compiling swc_plugin_background_only v0.1.0 (/home/runner/work/lynx-stack/lynx-stack/packages/react/transform/crates/swc_plugin_background_only)
252
253
  Compiling version-compare v0.2.1
253
- Finished `release` profile [optimized] target(s) in 6m 28s
254
+ Finished `release` profile [optimized] target(s) in 4m 55s
@@ -2186,8 +2186,8 @@ export function getCurrentDelta(event) {
2186
2186
  var captureMainThreadObject = __captureMainThreadObject;
2187
2187
  export let getCurrentDelta = {
2188
2188
  _c: {
2189
- foo: captureMainThreadObject(foo) ?? {
2190
- bar: ((__mainThreadObjectSource)=>captureMainThreadObject(__mainThreadObjectSource) ?? {
2189
+ foo: captureMainThreadObject?.(foo) ?? {
2190
+ bar: ((__mainThreadObjectSource)=>captureMainThreadObject?.(__mainThreadObjectSource) ?? {
2191
2191
  baz: __mainThreadObjectSource.baz
2192
2192
  })(foo.bar)
2193
2193
  }
@@ -2208,8 +2208,8 @@ export function getCurrentDelta(event) {
2208
2208
  var captureMainThreadObject = __captureMainThreadObject;
2209
2209
  export let getCurrentDelta = {
2210
2210
  _c: {
2211
- foo: captureMainThreadObject(foo) ?? {
2212
- bar: ((__mainThreadObjectSource)=>captureMainThreadObject(__mainThreadObjectSource) ?? {
2211
+ foo: captureMainThreadObject?.(foo) ?? {
2212
+ bar: ((__mainThreadObjectSource)=>captureMainThreadObject?.(__mainThreadObjectSource) ?? {
2213
2213
  baz: __mainThreadObjectSource.baz
2214
2214
  })(foo.bar)
2215
2215
  }
@@ -2225,8 +2225,8 @@ export function getCurrentDelta(event) {
2225
2225
  var captureMainThreadObject = __captureMainThreadObject;
2226
2226
  export let getCurrentDelta = {
2227
2227
  _c: {
2228
- foo: captureMainThreadObject(foo) ?? {
2229
- bar: ((__mainThreadObjectSource)=>captureMainThreadObject(__mainThreadObjectSource) ?? {
2228
+ foo: captureMainThreadObject?.(foo) ?? {
2229
+ bar: ((__mainThreadObjectSource)=>captureMainThreadObject?.(__mainThreadObjectSource) ?? {
2230
2230
  baz: __mainThreadObjectSource.baz
2231
2231
  })(foo.bar)
2232
2232
  }
@@ -2286,16 +2286,16 @@ export function foo(event) {
2286
2286
  var captureMainThreadObject = __captureMainThreadObject;
2287
2287
  export let foo = {
2288
2288
  _c: {
2289
- bar: captureMainThreadObject(bar) ?? {
2290
- baz: ((__mainThreadObjectSource)=>captureMainThreadObject(__mainThreadObjectSource) ?? {
2289
+ bar: captureMainThreadObject?.(bar) ?? {
2290
+ baz: ((__mainThreadObjectSource)=>captureMainThreadObject?.(__mainThreadObjectSource) ?? {
2291
2291
  'qux': __mainThreadObjectSource['qux']
2292
2292
  })(bar.baz),
2293
- qux: ((__mainThreadObjectSource)=>captureMainThreadObject(__mainThreadObjectSource) ?? {
2293
+ qux: ((__mainThreadObjectSource)=>captureMainThreadObject?.(__mainThreadObjectSource) ?? {
2294
2294
  'baz': __mainThreadObjectSource['baz']
2295
2295
  })(bar.qux)
2296
2296
  },
2297
- qux: captureMainThreadObject(qux) ?? {
2298
- bar: ((__mainThreadObjectSource)=>captureMainThreadObject(__mainThreadObjectSource) ?? {
2297
+ qux: captureMainThreadObject?.(qux) ?? {
2298
+ bar: ((__mainThreadObjectSource)=>captureMainThreadObject?.(__mainThreadObjectSource) ?? {
2299
2299
  baz: __mainThreadObjectSource.baz
2300
2300
  })(qux.bar)
2301
2301
  }
@@ -0,0 +1,111 @@
1
+ // Copyright 2026 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
+
5
+ import { describe, expect, it } from 'vitest';
6
+
7
+ import { captureMainThreadObject } from '../../runtime/src/core/capture-main-thread-object.js';
8
+ import { registerMainThreadObjectHandle } from '../../runtime/src/core/main-thread-object-handle-registry.js';
9
+ import { transformReactLynx } from '../main.js';
10
+
11
+ async function compile(target, helper) {
12
+ const result = await transformReactLynx(
13
+ `
14
+ export function create(rect) {
15
+ return () => {
16
+ 'main thread';
17
+ return rect.top + rect.bottom;
18
+ };
19
+ }
20
+ export function createNested(props) {
21
+ return () => {
22
+ 'main thread';
23
+ return props?.rect?.top;
24
+ };
25
+ }
26
+ `,
27
+ {
28
+ mode: 'test',
29
+ pluginName: '',
30
+ filename: 'test.jsx',
31
+ sourcemap: false,
32
+ cssScope: false,
33
+ shake: false,
34
+ compat: false,
35
+ refresh: false,
36
+ defineDCE: false,
37
+ directiveDCE: false,
38
+ worklet: {
39
+ target,
40
+ filename: 'test.jsx',
41
+ runtimePkg: '@lynx-js/react/internal',
42
+ },
43
+ },
44
+ );
45
+ expect(result.errors).toEqual([]);
46
+ const functions = new Map();
47
+ const factories = new Function(
48
+ '__registerWorklet',
49
+ '__captureMainThreadObject',
50
+ `${result.code.replace(/^import .*;$/gm, '').replace(/^export /gm, '')}
51
+ return { create, createNested };`,
52
+ )(
53
+ (_type, id, fn) => functions.set(id, fn),
54
+ helper,
55
+ );
56
+ return {
57
+ ...factories,
58
+ invoke: worklet => functions.get(worklet._wkltId).call(worklet),
59
+ };
60
+ }
61
+
62
+ describe.each(['JS', 'LEPUS', 'MIXED'])('MTO helper compatibility (%s)', target => {
63
+ it.each([undefined, null, captureMainThreadObject])(
64
+ 'keeps ordinary MTS captures working with helper %s',
65
+ async helper => {
66
+ const { create, createNested, invoke } = await compile(target, helper);
67
+ const worklet = create({ top: 10, bottom: 20, unused: 30 });
68
+ expect(worklet._c).toEqual({ rect: { top: 10, bottom: 20 } });
69
+
70
+ let reads = 0;
71
+ const nested = createNested({
72
+ get rect() {
73
+ reads += 1;
74
+ return { top: 42, unused: 99 };
75
+ },
76
+ });
77
+ expect(reads).toBe(1);
78
+ expect(nested._c).toEqual({ props: { rect: { top: 42 } } });
79
+ expect(createNested(null)._c.props).toBeNull();
80
+ expect(createNested(undefined)._c.props).toBeUndefined();
81
+ expect(createNested({ rect: null })._c.props.rect).toBeNull();
82
+ expect(createNested({ rect: undefined })._c.props.rect).toBeUndefined();
83
+
84
+ if (target !== 'JS') {
85
+ expect(invoke(worklet)).toBe(30);
86
+ expect(invoke(nested)).toBe(42);
87
+ expect(invoke(createNested(null))).toBeUndefined();
88
+ expect(invoke(createNested({ rect: null }))).toBeUndefined();
89
+ }
90
+ },
91
+ );
92
+
93
+ it('preserves registered MTO handles without reading their properties', async () => {
94
+ const { create, createNested } = await compile(target, captureMainThreadObject);
95
+ const handle = Object.defineProperties({}, {
96
+ top: {
97
+ get() {
98
+ throw new Error('opaque handle must not be read');
99
+ },
100
+ },
101
+ bottom: {
102
+ get() {
103
+ throw new Error('opaque handle must not be read');
104
+ },
105
+ },
106
+ });
107
+ registerMainThreadObjectHandle(handle, 'compat-test');
108
+ expect(create(handle)._c.rect).toBe(handle);
109
+ expect(createNested({ rect: handle })._c.props.rect).toBe(handle);
110
+ });
111
+ });
@@ -449,6 +449,7 @@ where
449
449
  MTEvent,
450
450
  Ref,
451
451
  MTRef,
452
+ Gesture,
452
453
  Spread,
453
454
  }
454
455
 
@@ -475,6 +476,11 @@ where
475
476
  slot_index,
476
477
  ..
477
478
  } => Some((*slot_index, AttrPlanAdapter::MTRef)),
479
+ DynamicAttributePart::Attr {
480
+ attr_name: AttrName::Gesture,
481
+ slot_index,
482
+ ..
483
+ } => Some((*slot_index, AttrPlanAdapter::Gesture)),
478
484
  DynamicAttributePart::Spread { slot_index, .. } => {
479
485
  Some((*slot_index, AttrPlanAdapter::Spread))
480
486
  }
@@ -489,6 +495,7 @@ where
489
495
  AttrPlanAdapter::MTEvent => "mt-event",
490
496
  AttrPlanAdapter::Ref => "ref",
491
497
  AttrPlanAdapter::MTRef => "mt-ref",
498
+ AttrPlanAdapter::Gesture => "gesture",
492
499
  AttrPlanAdapter::Spread => "spread",
493
500
  };
494
501
  format!("{slot_index}:{adapter}")
@@ -641,6 +648,10 @@ where
641
648
  "$internal_runtime_id.adaptMTRefAttrSlot" as Expr,
642
649
  internal_runtime_id: Expr = internal_runtime_id.clone(),
643
650
  ),
651
+ AttrPlanAdapter::Gesture => quote!(
652
+ "$internal_runtime_id.adaptGestureAttrSlot" as Expr,
653
+ internal_runtime_id: Expr = internal_runtime_id.clone(),
654
+ ),
644
655
  AttrPlanAdapter::Spread => quote!(
645
656
  "$internal_runtime_id.adaptSpreadAttrSlot" as Expr,
646
657
  internal_runtime_id: Expr = internal_runtime_id.clone(),