@lynx-js/react 0.129.1 → 0.129.2

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 (121) hide show
  1. package/CHANGELOG.md +10 -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/lifecycle/updateGlobalProps.event.test.jsx +2 -2
  24. package/runtime/__test__/snapshot/lifecycle/updateGlobalProps.test.jsx +3 -3
  25. package/runtime/__test__/snapshot/ref.test.jsx +30 -0
  26. package/runtime/lazy/element-template-internal.js +1 -0
  27. package/runtime/lib/core/globalProps.js +1 -1
  28. package/runtime/lib/core/globalProps.js.map +1 -1
  29. package/runtime/lib/element-template/background/attr-slots.js +5 -2
  30. package/runtime/lib/element-template/background/attr-slots.js.map +1 -1
  31. package/runtime/lib/element-template/background/destroy.js +16 -11
  32. package/runtime/lib/element-template/background/destroy.js.map +1 -1
  33. package/runtime/lib/element-template/background/hydrate.js +23 -0
  34. package/runtime/lib/element-template/background/hydrate.js.map +1 -1
  35. package/runtime/lib/element-template/debug/alog.d.ts +1 -1
  36. package/runtime/lib/element-template/debug/alog.js +4 -1
  37. package/runtime/lib/element-template/debug/alog.js.map +1 -1
  38. package/runtime/lib/element-template/internal.d.ts +1 -1
  39. package/runtime/lib/element-template/internal.js +1 -1
  40. package/runtime/lib/element-template/internal.js.map +1 -1
  41. package/runtime/lib/element-template/native/callDestroyLifetimeFun.js +6 -1
  42. package/runtime/lib/element-template/native/callDestroyLifetimeFun.js.map +1 -1
  43. package/runtime/lib/element-template/native/patch-listener.js +1 -1
  44. package/runtime/lib/element-template/native/patch-listener.js.map +1 -1
  45. package/runtime/lib/element-template/native/reload-background.js +1 -1
  46. package/runtime/lib/element-template/native/reload-background.js.map +1 -1
  47. package/runtime/lib/element-template/native/reload-main-thread.js +33 -9
  48. package/runtime/lib/element-template/native/reload-main-thread.js.map +1 -1
  49. package/runtime/lib/element-template/prop-adapters/gesture.d.ts +23 -0
  50. package/runtime/lib/element-template/prop-adapters/gesture.js +97 -0
  51. package/runtime/lib/element-template/prop-adapters/gesture.js.map +1 -0
  52. package/runtime/lib/element-template/prop-adapters/spread.d.ts +6 -1
  53. package/runtime/lib/element-template/prop-adapters/spread.js +72 -2
  54. package/runtime/lib/element-template/prop-adapters/spread.js.map +1 -1
  55. package/runtime/lib/element-template/protocol/opcodes.d.ts +1 -0
  56. package/runtime/lib/element-template/protocol/opcodes.js +1 -0
  57. package/runtime/lib/element-template/protocol/opcodes.js.map +1 -1
  58. package/runtime/lib/element-template/protocol/types.d.ts +7 -1
  59. package/runtime/lib/element-template/protocol/types.js.map +1 -1
  60. package/runtime/lib/element-template/runtime/patch.js +27 -2
  61. package/runtime/lib/element-template/runtime/patch.js.map +1 -1
  62. package/runtime/lib/element-template/runtime/template/attr-slot-plan.d.ts +4 -2
  63. package/runtime/lib/element-template/runtime/template/attr-slot-plan.js +17 -4
  64. package/runtime/lib/element-template/runtime/template/attr-slot-plan.js.map +1 -1
  65. package/runtime/lib/element-template/runtime/template/main-thread-dynamic-attr-state.d.ts +7 -2
  66. package/runtime/lib/element-template/runtime/template/main-thread-dynamic-attr-state.js +368 -58
  67. package/runtime/lib/element-template/runtime/template/main-thread-dynamic-attr-state.js.map +1 -1
  68. package/runtime/lib/element-template/runtime/template/main-thread-ref-ctx.d.ts +2 -1
  69. package/runtime/lib/element-template/runtime/template/main-thread-ref-ctx.js +10 -1
  70. package/runtime/lib/element-template/runtime/template/main-thread-ref-ctx.js.map +1 -1
  71. package/runtime/lib/element-template/runtime/template/typed-attributes.js +3 -3
  72. package/runtime/lib/element-template/runtime/template/typed-attributes.js.map +1 -1
  73. package/runtime/lib/snapshot/lifecycle/destroy.js +23 -17
  74. package/runtime/lib/snapshot/lifecycle/destroy.js.map +1 -1
  75. package/runtime/lib/snapshot/lifecycle/ref/delay.d.ts +5 -0
  76. package/runtime/lib/snapshot/lifecycle/ref/delay.js +1 -1
  77. package/runtime/lib/snapshot/lifecycle/ref/delay.js.map +1 -1
  78. package/runtime/lib/tsconfig.tsbuildinfo +1 -1
  79. package/runtime/src/core/globalProps.ts +1 -1
  80. package/runtime/src/element-template/background/attr-slots.ts +5 -1
  81. package/runtime/src/element-template/background/destroy.ts +16 -13
  82. package/runtime/src/element-template/background/hydrate.ts +23 -0
  83. package/runtime/src/element-template/debug/alog.ts +5 -2
  84. package/runtime/src/element-template/internal.ts +1 -0
  85. package/runtime/src/element-template/native/callDestroyLifetimeFun.ts +5 -1
  86. package/runtime/src/element-template/native/patch-listener.ts +1 -1
  87. package/runtime/src/element-template/native/reload-background.ts +1 -1
  88. package/runtime/src/element-template/native/reload-main-thread.ts +30 -10
  89. package/runtime/src/element-template/prop-adapters/gesture.ts +144 -0
  90. package/runtime/src/element-template/prop-adapters/spread.ts +110 -2
  91. package/runtime/src/element-template/protocol/opcodes.ts +1 -0
  92. package/runtime/src/element-template/protocol/types.ts +8 -0
  93. package/runtime/src/element-template/runtime/patch.ts +33 -0
  94. package/runtime/src/element-template/runtime/template/attr-slot-plan.ts +31 -4
  95. package/runtime/src/element-template/runtime/template/main-thread-dynamic-attr-state.ts +441 -65
  96. package/runtime/src/element-template/runtime/template/main-thread-ref-ctx.ts +12 -2
  97. package/runtime/src/element-template/runtime/template/typed-attributes.ts +3 -3
  98. package/runtime/src/snapshot/lifecycle/destroy.ts +23 -18
  99. package/runtime/src/snapshot/lifecycle/ref/delay.ts +1 -1
  100. package/runtime/types/types.d.ts +2 -1
  101. package/testing-library/.turbo/turbo-build.log +7 -7
  102. package/transform/.turbo/turbo-build$colon$wasm.log +205 -91
  103. package/transform/__test__/fixture.spec.js +11 -11
  104. package/transform/__test__/main-thread-object-compat.spec.js +111 -0
  105. package/transform/crates/swc_plugin_element_template/lib.rs +11 -0
  106. package/transform/crates/swc_plugin_element_template/tests/element_template_contract.rs +113 -0
  107. package/transform/crates/swc_plugin_worklet/gen_stmt.rs +7 -9
  108. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_capture_env_js.js +3 -3
  109. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_capture_env_lepus.js +3 -3
  110. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_member_expr_2_js.js +7 -7
  111. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_member_expr_2_lepus.js +7 -7
  112. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_member_expr_js.js +8 -8
  113. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_member_expr_lepus.js +8 -8
  114. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_preserve_main_thread_objects_in_class_js.js +5 -5
  115. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_preserve_main_thread_objects_in_class_lepus.js +5 -5
  116. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_js.js +1 -1
  117. package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_lepus.js +1 -1
  118. package/transform/dist/wasm.cjs +1 -1
  119. package/transform/swc-plugin-reactlynx/.turbo/turbo-build.log +160 -133
  120. package/transform/swc-plugin-reactlynx/swc_plugin_reactlynx.wasm +0 -0
  121. package/transform/swc-plugin-reactlynx-compat/.turbo/turbo-build.log +180 -293
@@ -6,8 +6,10 @@ import { prepareMTEventCtxForNative } from './main-thread-event-ctx.js';
6
6
  import { prepareMTRefForNative } from './main-thread-ref-ctx.js';
7
7
  import { isMainThreadFunction } from '../../../core/main-thread-function.js';
8
8
  import { getEventValue } from '../../prop-adapters/event-value.js';
9
+ import { prepareGestureForNative } from '../../prop-adapters/gesture.js';
10
+ import type { GestureSlotValue } from '../../prop-adapters/gesture.js';
9
11
  import { prepareRefAttrSlot } from '../../prop-adapters/ref.js';
10
- import { prepareSpreadAttrSlot } from '../../prop-adapters/spread.js';
12
+ import { prepareSpreadAttrSlot, prepareTypedSpreadAttrSlot } from '../../prop-adapters/spread.js';
11
13
  import type { SerializableValue } from '../../protocol/types.js';
12
14
 
13
15
  export interface EtAttrAdapterContext {
@@ -31,7 +33,7 @@ export type EtAttrPlanMap = Record<
31
33
 
32
34
  export const __etAttrPlanMap = Object.create(null) as EtAttrPlanMap;
33
35
 
34
- export type MainThreadDynamicAttrKind = 'mt-event' | 'mt-ref';
36
+ export type MainThreadDynamicAttrKind = 'mt-event' | 'mt-ref' | 'gesture' | 'spread';
35
37
 
36
38
  const mainThreadDynamicAttrSlotKinds = new Map<
37
39
  string,
@@ -54,8 +56,12 @@ export function getMainThreadDynamicAttrSlotKinds(
54
56
  let kind: MainThreadDynamicAttrKind | undefined;
55
57
  if (adapter === adaptMTEventAttrSlot) {
56
58
  kind = 'mt-event';
59
+ } else if (adapter === adaptGestureAttrSlot) {
60
+ kind = 'gesture';
57
61
  } else if (adapter === adaptMTRefAttrSlot) {
58
62
  kind = 'mt-ref';
63
+ } else if (adapter === adaptSpreadAttrSlot) {
64
+ kind = 'spread';
59
65
  }
60
66
  if (kind) {
61
67
  (slotKinds ??= new Map()).set(attrPlan[planIndex] as number, kind);
@@ -72,7 +78,7 @@ export function hasMainThreadRefAttrSlot(templateType: string): boolean {
72
78
  return false;
73
79
  }
74
80
  for (const kind of slotKinds.values()) {
75
- if (kind === 'mt-ref') {
81
+ if (kind === 'mt-ref' || kind === 'spread') {
76
82
  return true;
77
83
  }
78
84
  }
@@ -135,12 +141,33 @@ export function adaptMTRefAttrSlot(
135
141
  );
136
142
  }
137
143
 
144
+ export function adaptGestureAttrSlot(
145
+ _handleId: number,
146
+ attrSlotIndex: number,
147
+ value: unknown,
148
+ context?: EtAttrAdapterContext,
149
+ ): SerializableValue | null {
150
+ return prepareGestureForNative(
151
+ value,
152
+ context?.previousPreparedSlots[attrSlotIndex] as GestureSlotValue | null | undefined,
153
+ ) as unknown as SerializableValue | null;
154
+ }
155
+
138
156
  export function adaptSpreadAttrSlot(
139
157
  handleId: number,
140
158
  attrSlotIndex: number,
141
159
  value: unknown,
160
+ context?: EtAttrAdapterContext,
161
+ ): SerializableValue | null {
162
+ return prepareSpreadAttrSlot(handleId, attrSlotIndex, value, context);
163
+ }
164
+
165
+ export function adaptTypedSpreadAttrSlot(
166
+ handleId: number,
167
+ attrSlotIndex: number,
168
+ value: unknown,
142
169
  ): SerializableValue | null {
143
- return prepareSpreadAttrSlot(handleId, attrSlotIndex, value);
170
+ return prepareTypedSpreadAttrSlot(handleId, attrSlotIndex, value);
144
171
  }
145
172
 
146
173
  export function clearEtAttrPlanMap(): void {