@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.
- package/CHANGELOG.md +10 -0
- package/components/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/refresh/.turbo/turbo-build.log +1 -1
- package/runtime/__test__/core/globalProps.test.ts +27 -6
- package/runtime/__test__/element-template/fixtures/gesture/direct/index.tsx +33 -0
- package/runtime/__test__/element-template/fixtures/spread/mts/index.tsx +197 -0
- package/runtime/__test__/element-template/native/callDestroyLifetimeFun.test.ts +89 -3
- package/runtime/__test__/element-template/native/mts-destroy.test.ts +8 -3
- package/runtime/__test__/element-template/native/reload.test.ts +87 -0
- package/runtime/__test__/element-template/runtime/background/global-props/compiled-fixtures.test.tsx +5 -5
- package/runtime/__test__/element-template/runtime/background/global-props.test.tsx +1 -1
- package/runtime/__test__/element-template/runtime/background/hydrate.test.ts +70 -0
- package/runtime/__test__/element-template/runtime/background/ref/compiled-fixtures.test.tsx +3 -4
- package/runtime/__test__/element-template/runtime/background/reload.test.ts +74 -0
- package/runtime/__test__/element-template/runtime/patch/element-template-patch.test.tsx +15 -0
- package/runtime/__test__/element-template/runtime/prop-adapters/gesture-compiled.test.ts +200 -0
- package/runtime/__test__/element-template/runtime/prop-adapters/gesture.test.ts +420 -0
- package/runtime/__test__/element-template/runtime/prop-adapters/spread-mts-compiled.test.ts +527 -0
- package/runtime/__test__/element-template/runtime/prop-adapters/spread.test.ts +185 -6
- package/runtime/__test__/element-template/runtime/render/render-direct-native.test.tsx +21 -1
- package/runtime/__test__/element-template/runtime/template/main-thread-dynamic-attr-state.test.ts +188 -0
- package/runtime/__test__/snapshot/lifecycle/updateGlobalProps.event.test.jsx +2 -2
- package/runtime/__test__/snapshot/lifecycle/updateGlobalProps.test.jsx +3 -3
- package/runtime/__test__/snapshot/ref.test.jsx +30 -0
- package/runtime/lazy/element-template-internal.js +1 -0
- package/runtime/lib/core/globalProps.js +1 -1
- package/runtime/lib/core/globalProps.js.map +1 -1
- package/runtime/lib/element-template/background/attr-slots.js +5 -2
- package/runtime/lib/element-template/background/attr-slots.js.map +1 -1
- package/runtime/lib/element-template/background/destroy.js +16 -11
- package/runtime/lib/element-template/background/destroy.js.map +1 -1
- package/runtime/lib/element-template/background/hydrate.js +23 -0
- package/runtime/lib/element-template/background/hydrate.js.map +1 -1
- package/runtime/lib/element-template/debug/alog.d.ts +1 -1
- package/runtime/lib/element-template/debug/alog.js +4 -1
- package/runtime/lib/element-template/debug/alog.js.map +1 -1
- package/runtime/lib/element-template/internal.d.ts +1 -1
- package/runtime/lib/element-template/internal.js +1 -1
- package/runtime/lib/element-template/internal.js.map +1 -1
- package/runtime/lib/element-template/native/callDestroyLifetimeFun.js +6 -1
- package/runtime/lib/element-template/native/callDestroyLifetimeFun.js.map +1 -1
- package/runtime/lib/element-template/native/patch-listener.js +1 -1
- package/runtime/lib/element-template/native/patch-listener.js.map +1 -1
- package/runtime/lib/element-template/native/reload-background.js +1 -1
- package/runtime/lib/element-template/native/reload-background.js.map +1 -1
- package/runtime/lib/element-template/native/reload-main-thread.js +33 -9
- package/runtime/lib/element-template/native/reload-main-thread.js.map +1 -1
- package/runtime/lib/element-template/prop-adapters/gesture.d.ts +23 -0
- package/runtime/lib/element-template/prop-adapters/gesture.js +97 -0
- package/runtime/lib/element-template/prop-adapters/gesture.js.map +1 -0
- package/runtime/lib/element-template/prop-adapters/spread.d.ts +6 -1
- package/runtime/lib/element-template/prop-adapters/spread.js +72 -2
- package/runtime/lib/element-template/prop-adapters/spread.js.map +1 -1
- package/runtime/lib/element-template/protocol/opcodes.d.ts +1 -0
- package/runtime/lib/element-template/protocol/opcodes.js +1 -0
- package/runtime/lib/element-template/protocol/opcodes.js.map +1 -1
- package/runtime/lib/element-template/protocol/types.d.ts +7 -1
- package/runtime/lib/element-template/protocol/types.js.map +1 -1
- package/runtime/lib/element-template/runtime/patch.js +27 -2
- package/runtime/lib/element-template/runtime/patch.js.map +1 -1
- package/runtime/lib/element-template/runtime/template/attr-slot-plan.d.ts +4 -2
- package/runtime/lib/element-template/runtime/template/attr-slot-plan.js +17 -4
- package/runtime/lib/element-template/runtime/template/attr-slot-plan.js.map +1 -1
- package/runtime/lib/element-template/runtime/template/main-thread-dynamic-attr-state.d.ts +7 -2
- package/runtime/lib/element-template/runtime/template/main-thread-dynamic-attr-state.js +368 -58
- package/runtime/lib/element-template/runtime/template/main-thread-dynamic-attr-state.js.map +1 -1
- package/runtime/lib/element-template/runtime/template/main-thread-ref-ctx.d.ts +2 -1
- package/runtime/lib/element-template/runtime/template/main-thread-ref-ctx.js +10 -1
- package/runtime/lib/element-template/runtime/template/main-thread-ref-ctx.js.map +1 -1
- package/runtime/lib/element-template/runtime/template/typed-attributes.js +3 -3
- package/runtime/lib/element-template/runtime/template/typed-attributes.js.map +1 -1
- package/runtime/lib/snapshot/lifecycle/destroy.js +23 -17
- package/runtime/lib/snapshot/lifecycle/destroy.js.map +1 -1
- package/runtime/lib/snapshot/lifecycle/ref/delay.d.ts +5 -0
- package/runtime/lib/snapshot/lifecycle/ref/delay.js +1 -1
- package/runtime/lib/snapshot/lifecycle/ref/delay.js.map +1 -1
- package/runtime/lib/tsconfig.tsbuildinfo +1 -1
- package/runtime/src/core/globalProps.ts +1 -1
- package/runtime/src/element-template/background/attr-slots.ts +5 -1
- package/runtime/src/element-template/background/destroy.ts +16 -13
- package/runtime/src/element-template/background/hydrate.ts +23 -0
- package/runtime/src/element-template/debug/alog.ts +5 -2
- package/runtime/src/element-template/internal.ts +1 -0
- package/runtime/src/element-template/native/callDestroyLifetimeFun.ts +5 -1
- package/runtime/src/element-template/native/patch-listener.ts +1 -1
- package/runtime/src/element-template/native/reload-background.ts +1 -1
- package/runtime/src/element-template/native/reload-main-thread.ts +30 -10
- package/runtime/src/element-template/prop-adapters/gesture.ts +144 -0
- package/runtime/src/element-template/prop-adapters/spread.ts +110 -2
- package/runtime/src/element-template/protocol/opcodes.ts +1 -0
- package/runtime/src/element-template/protocol/types.ts +8 -0
- package/runtime/src/element-template/runtime/patch.ts +33 -0
- package/runtime/src/element-template/runtime/template/attr-slot-plan.ts +31 -4
- package/runtime/src/element-template/runtime/template/main-thread-dynamic-attr-state.ts +441 -65
- package/runtime/src/element-template/runtime/template/main-thread-ref-ctx.ts +12 -2
- package/runtime/src/element-template/runtime/template/typed-attributes.ts +3 -3
- package/runtime/src/snapshot/lifecycle/destroy.ts +23 -18
- package/runtime/src/snapshot/lifecycle/ref/delay.ts +1 -1
- package/runtime/types/types.d.ts +2 -1
- package/testing-library/.turbo/turbo-build.log +7 -7
- package/transform/.turbo/turbo-build$colon$wasm.log +205 -91
- package/transform/__test__/fixture.spec.js +11 -11
- package/transform/__test__/main-thread-object-compat.spec.js +111 -0
- package/transform/crates/swc_plugin_element_template/lib.rs +11 -0
- package/transform/crates/swc_plugin_element_template/tests/element_template_contract.rs +113 -0
- package/transform/crates/swc_plugin_worklet/gen_stmt.rs +7 -9
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_capture_env_js.js +3 -3
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_capture_env_lepus.js +3 -3
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_member_expr_2_js.js +7 -7
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_member_expr_2_lepus.js +7 -7
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_member_expr_js.js +8 -8
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_extract_member_expr_lepus.js +8 -8
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_preserve_main_thread_objects_in_class_js.js +5 -5
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_preserve_main_thread_objects_in_class_lepus.js +5 -5
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_js.js +1 -1
- package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_transform_lepus.js +1 -1
- package/transform/dist/wasm.cjs +1 -1
- package/transform/swc-plugin-reactlynx/.turbo/turbo-build.log +160 -133
- package/transform/swc-plugin-reactlynx/swc_plugin_reactlynx.wasm +0 -0
- package/transform/swc-plugin-reactlynx-compat/.turbo/turbo-build.log +180 -293
|
@@ -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(),
|
|
@@ -309,6 +309,119 @@ fn should_emit_direct_main_thread_ref_attr_plan_for_lepus_target() {
|
|
|
309
309
|
);
|
|
310
310
|
}
|
|
311
311
|
|
|
312
|
+
#[test]
|
|
313
|
+
fn should_emit_direct_gesture_attr_plan_for_both_targets() {
|
|
314
|
+
use swc_plugins_shared::target::TransformTarget;
|
|
315
|
+
|
|
316
|
+
for target in [TransformTarget::JS, TransformTarget::LEPUS] {
|
|
317
|
+
let (code, template) = first_user_template_json_with_code(
|
|
318
|
+
r#"<view main-thread:gesture={composedGesture} />"#,
|
|
319
|
+
JSXTransformerConfig {
|
|
320
|
+
target,
|
|
321
|
+
..element_template_config()
|
|
322
|
+
},
|
|
323
|
+
);
|
|
324
|
+
let code = without_whitespace(&code);
|
|
325
|
+
|
|
326
|
+
assert_attr_plan_assignment(
|
|
327
|
+
&code,
|
|
328
|
+
"0,ReactLynxInternal.adaptGestureAttrSlot",
|
|
329
|
+
"direct Gesture should use the same ET adapter on both targets",
|
|
330
|
+
);
|
|
331
|
+
let raw_value_transport = if target == TransformTarget::JS {
|
|
332
|
+
"attributeSlots={[composedGesture]}"
|
|
333
|
+
} else {
|
|
334
|
+
",void0,[composedGesture],void0,void0)"
|
|
335
|
+
};
|
|
336
|
+
assert!(
|
|
337
|
+
code.contains(raw_value_transport),
|
|
338
|
+
"Gesture composition must remain a raw runtime adapter input, got: {code}"
|
|
339
|
+
);
|
|
340
|
+
assert_eq!(
|
|
341
|
+
template["attributesArray"][0],
|
|
342
|
+
serde_json::json!({
|
|
343
|
+
"kind": "slot",
|
|
344
|
+
"key": "main-thread:gesture",
|
|
345
|
+
"attrSlotIndex": 0.0,
|
|
346
|
+
}),
|
|
347
|
+
"Native must receive the full Gesture namespace key"
|
|
348
|
+
);
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
#[test]
|
|
353
|
+
fn should_keep_gesture_targets_inside_one_compiled_template() {
|
|
354
|
+
use swc_plugins_shared::target::TransformTarget;
|
|
355
|
+
|
|
356
|
+
for target in [TransformTarget::JS, TransformTarget::LEPUS] {
|
|
357
|
+
let (templates, code) = transform_fixture(
|
|
358
|
+
r#"
|
|
359
|
+
<view id={rootId} main-thread:gesture={rootGesture}>
|
|
360
|
+
<text main-thread:gesture={textGesture}>Drag</text>
|
|
361
|
+
<view id={childId} main-thread:gesture={childGesture} />
|
|
362
|
+
</view>
|
|
363
|
+
"#,
|
|
364
|
+
JSXTransformerConfig {
|
|
365
|
+
target,
|
|
366
|
+
..element_template_config()
|
|
367
|
+
},
|
|
368
|
+
);
|
|
369
|
+
let user_templates = templates
|
|
370
|
+
.iter()
|
|
371
|
+
.filter(|template| template.template_id != BUILTIN_RAW_TEXT_TEMPLATE_ID)
|
|
372
|
+
.collect::<Vec<_>>();
|
|
373
|
+
assert_eq!(
|
|
374
|
+
user_templates.len(),
|
|
375
|
+
1,
|
|
376
|
+
"Gesture targets must not split the compiled tree or add wrappers"
|
|
377
|
+
);
|
|
378
|
+
let template = &user_templates[0].compiled_template;
|
|
379
|
+
let code = without_whitespace(&code);
|
|
380
|
+
assert_attr_plan_assignment(
|
|
381
|
+
&code,
|
|
382
|
+
"1,ReactLynxInternal.adaptGestureAttrSlot,2,ReactLynxInternal.adaptGestureAttrSlot,4,ReactLynxInternal.adaptGestureAttrSlot",
|
|
383
|
+
"Gesture adapters must retain the slot identity of each target",
|
|
384
|
+
);
|
|
385
|
+
assert!(
|
|
386
|
+
code.contains("[rootId,rootGesture,textGesture,childId,childGesture]"),
|
|
387
|
+
"runtime Gesture values must follow descriptor traversal order, got: {code}"
|
|
388
|
+
);
|
|
389
|
+
for (node, slot_index) in [
|
|
390
|
+
(template, 1.0),
|
|
391
|
+
(&template["children"][0], 2.0),
|
|
392
|
+
(&template["children"][1], 4.0),
|
|
393
|
+
] {
|
|
394
|
+
assert!(
|
|
395
|
+
node["attributesArray"]
|
|
396
|
+
.as_array()
|
|
397
|
+
.expect("target attributes")
|
|
398
|
+
.iter()
|
|
399
|
+
.any(|attr| *attr
|
|
400
|
+
== serde_json::json!({
|
|
401
|
+
"kind": "slot",
|
|
402
|
+
"key": "main-thread:gesture",
|
|
403
|
+
"attrSlotIndex": slot_index,
|
|
404
|
+
})),
|
|
405
|
+
"Gesture slot {slot_index} must remain on its declared node: {template:?}"
|
|
406
|
+
);
|
|
407
|
+
}
|
|
408
|
+
assert_eq!(template["children"][0]["type"], "text");
|
|
409
|
+
assert_eq!(template["children"][1]["type"], "view");
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
#[test]
|
|
414
|
+
fn should_only_adapt_direct_gesture_in_main_thread_namespace() {
|
|
415
|
+
let (code, _) = first_user_template_json_with_code(
|
|
416
|
+
r#"<view gesture={ordinaryValue} other:gesture={namespacedValue} />"#,
|
|
417
|
+
element_template_config(),
|
|
418
|
+
);
|
|
419
|
+
assert!(
|
|
420
|
+
!code.contains("adaptGestureAttrSlot"),
|
|
421
|
+
"ordinary and unrelated namespaced attributes must not become Gesture bindings: {code}"
|
|
422
|
+
);
|
|
423
|
+
}
|
|
424
|
+
|
|
312
425
|
#[test]
|
|
313
426
|
fn should_disable_flatten_for_direct_main_thread_ref_targets() {
|
|
314
427
|
let template = first_user_template_json(
|
|
@@ -311,18 +311,16 @@ impl StmtGen {
|
|
|
311
311
|
});
|
|
312
312
|
Expr::Ident(capture_source)
|
|
313
313
|
};
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
}
|
|
321
|
-
.into();
|
|
314
|
+
// Older externalized runtimes do not export this helper. Keep ordinary
|
|
315
|
+
// main-thread function captures working by using the narrowed fallback.
|
|
316
|
+
let captured = quote!(
|
|
317
|
+
"captureMainThreadObject?.($source)" as Expr,
|
|
318
|
+
source: Expr = capture_argument.clone(),
|
|
319
|
+
);
|
|
322
320
|
let captured_or_fallback: Expr = BinExpr {
|
|
323
321
|
span: DUMMY_SP,
|
|
324
322
|
op: BinaryOp::NullishCoalescing,
|
|
325
|
-
left: captured,
|
|
323
|
+
left: captured.into(),
|
|
326
324
|
right: fallback,
|
|
327
325
|
}
|
|
328
326
|
.into();
|
package/transform/crates/swc_plugin_worklet/tests/__swc_snapshots__/lib.rs/should_capture_env_js.js
CHANGED
|
@@ -6,11 +6,11 @@ let Y = {
|
|
|
6
6
|
y2,
|
|
7
7
|
y3,
|
|
8
8
|
y4,
|
|
9
|
-
y5: captureMainThreadObject(y5) ?? {
|
|
9
|
+
y5: captureMainThreadObject?.(y5) ?? {
|
|
10
10
|
r: y5.r
|
|
11
11
|
},
|
|
12
|
-
props: captureMainThreadObject(props) ?? {
|
|
13
|
-
value: ((__mainThreadObjectSource)=>captureMainThreadObject(__mainThreadObjectSource) ?? {
|
|
12
|
+
props: captureMainThreadObject?.(props) ?? {
|
|
13
|
+
value: ((__mainThreadObjectSource)=>captureMainThreadObject?.(__mainThreadObjectSource) ?? {
|
|
14
14
|
get: __mainThreadObjectSource.get
|
|
15
15
|
})(props.value)
|
|
16
16
|
}
|
|
@@ -7,11 +7,11 @@ let Y = {
|
|
|
7
7
|
y2,
|
|
8
8
|
y3,
|
|
9
9
|
y4,
|
|
10
|
-
y5: captureMainThreadObject(y5) ?? {
|
|
10
|
+
y5: captureMainThreadObject?.(y5) ?? {
|
|
11
11
|
r: y5.r
|
|
12
12
|
},
|
|
13
|
-
props: captureMainThreadObject(props) ?? {
|
|
14
|
-
value: ((__mainThreadObjectSource)=>captureMainThreadObject(__mainThreadObjectSource) ?? {
|
|
13
|
+
props: captureMainThreadObject?.(props) ?? {
|
|
14
|
+
value: ((__mainThreadObjectSource)=>captureMainThreadObject?.(__mainThreadObjectSource) ?? {
|
|
15
15
|
get: __mainThreadObjectSource.get
|
|
16
16
|
})(props.value)
|
|
17
17
|
}
|
|
@@ -10,25 +10,25 @@ let onTapLepus = {
|
|
|
10
10
|
_wkltId: "a123:test:1",
|
|
11
11
|
...{
|
|
12
12
|
aaaa: this.aaaa,
|
|
13
|
-
bbbb: ((__mainThreadObjectSource)=>captureMainThreadObject(__mainThreadObjectSource) ?? {
|
|
14
|
-
cccc: ((__mainThreadObjectSource)=>captureMainThreadObject(__mainThreadObjectSource) ?? {
|
|
13
|
+
bbbb: ((__mainThreadObjectSource)=>captureMainThreadObject?.(__mainThreadObjectSource) ?? {
|
|
14
|
+
cccc: ((__mainThreadObjectSource)=>captureMainThreadObject?.(__mainThreadObjectSource) ?? {
|
|
15
15
|
dddd: __mainThreadObjectSource.dddd
|
|
16
16
|
})(__mainThreadObjectSource.cccc)
|
|
17
17
|
})(this.bbbb),
|
|
18
18
|
eeee: this.eeee,
|
|
19
19
|
ffff: this.ffff,
|
|
20
|
-
hhhh: ((__mainThreadObjectSource)=>captureMainThreadObject(__mainThreadObjectSource) ?? {
|
|
20
|
+
hhhh: ((__mainThreadObjectSource)=>captureMainThreadObject?.(__mainThreadObjectSource) ?? {
|
|
21
21
|
'iiii': __mainThreadObjectSource['iiii'],
|
|
22
22
|
kkkk: __mainThreadObjectSource.kkkk
|
|
23
23
|
})(this.hhhh),
|
|
24
24
|
llll: this.llll,
|
|
25
|
-
mmmm: ((__mainThreadObjectSource)=>captureMainThreadObject(__mainThreadObjectSource) ?? {
|
|
26
|
-
nnnn: ((__mainThreadObjectSource)=>captureMainThreadObject(__mainThreadObjectSource) ?? {
|
|
25
|
+
mmmm: ((__mainThreadObjectSource)=>captureMainThreadObject?.(__mainThreadObjectSource) ?? {
|
|
26
|
+
nnnn: ((__mainThreadObjectSource)=>captureMainThreadObject?.(__mainThreadObjectSource) ?? {
|
|
27
27
|
'oooo': __mainThreadObjectSource['oooo']
|
|
28
28
|
})(__mainThreadObjectSource.nnnn)
|
|
29
29
|
})(this.mmmm),
|
|
30
|
-
pppp: ((__mainThreadObjectSource)=>__mainThreadObjectSource == null ? __mainThreadObjectSource : captureMainThreadObject(__mainThreadObjectSource) ?? {
|
|
31
|
-
qqqq: ((__mainThreadObjectSource)=>__mainThreadObjectSource == null ? __mainThreadObjectSource : captureMainThreadObject(__mainThreadObjectSource) ?? {
|
|
30
|
+
pppp: ((__mainThreadObjectSource)=>__mainThreadObjectSource == null ? __mainThreadObjectSource : captureMainThreadObject?.(__mainThreadObjectSource) ?? {
|
|
31
|
+
qqqq: ((__mainThreadObjectSource)=>__mainThreadObjectSource == null ? __mainThreadObjectSource : captureMainThreadObject?.(__mainThreadObjectSource) ?? {
|
|
32
32
|
rrrr: __mainThreadObjectSource.rrrr
|
|
33
33
|
})(__mainThreadObjectSource.qqqq)
|
|
34
34
|
})(this.pppp)
|
|
@@ -11,25 +11,25 @@ let onTapLepus = {
|
|
|
11
11
|
_wkltId: "a123:test:1",
|
|
12
12
|
...{
|
|
13
13
|
aaaa: this.aaaa,
|
|
14
|
-
bbbb: ((__mainThreadObjectSource)=>captureMainThreadObject(__mainThreadObjectSource) ?? {
|
|
15
|
-
cccc: ((__mainThreadObjectSource)=>captureMainThreadObject(__mainThreadObjectSource) ?? {
|
|
14
|
+
bbbb: ((__mainThreadObjectSource)=>captureMainThreadObject?.(__mainThreadObjectSource) ?? {
|
|
15
|
+
cccc: ((__mainThreadObjectSource)=>captureMainThreadObject?.(__mainThreadObjectSource) ?? {
|
|
16
16
|
dddd: __mainThreadObjectSource.dddd
|
|
17
17
|
})(__mainThreadObjectSource.cccc)
|
|
18
18
|
})(this.bbbb),
|
|
19
19
|
eeee: this.eeee,
|
|
20
20
|
ffff: this.ffff,
|
|
21
|
-
hhhh: ((__mainThreadObjectSource)=>captureMainThreadObject(__mainThreadObjectSource) ?? {
|
|
21
|
+
hhhh: ((__mainThreadObjectSource)=>captureMainThreadObject?.(__mainThreadObjectSource) ?? {
|
|
22
22
|
'iiii': __mainThreadObjectSource['iiii'],
|
|
23
23
|
kkkk: __mainThreadObjectSource.kkkk
|
|
24
24
|
})(this.hhhh),
|
|
25
25
|
llll: this.llll,
|
|
26
|
-
mmmm: ((__mainThreadObjectSource)=>captureMainThreadObject(__mainThreadObjectSource) ?? {
|
|
27
|
-
nnnn: ((__mainThreadObjectSource)=>captureMainThreadObject(__mainThreadObjectSource) ?? {
|
|
26
|
+
mmmm: ((__mainThreadObjectSource)=>captureMainThreadObject?.(__mainThreadObjectSource) ?? {
|
|
27
|
+
nnnn: ((__mainThreadObjectSource)=>captureMainThreadObject?.(__mainThreadObjectSource) ?? {
|
|
28
28
|
'oooo': __mainThreadObjectSource['oooo']
|
|
29
29
|
})(__mainThreadObjectSource.nnnn)
|
|
30
30
|
})(this.mmmm),
|
|
31
|
-
pppp: ((__mainThreadObjectSource)=>__mainThreadObjectSource == null ? __mainThreadObjectSource : captureMainThreadObject(__mainThreadObjectSource) ?? {
|
|
32
|
-
qqqq: ((__mainThreadObjectSource)=>__mainThreadObjectSource == null ? __mainThreadObjectSource : captureMainThreadObject(__mainThreadObjectSource) ?? {
|
|
31
|
+
pppp: ((__mainThreadObjectSource)=>__mainThreadObjectSource == null ? __mainThreadObjectSource : captureMainThreadObject?.(__mainThreadObjectSource) ?? {
|
|
32
|
+
qqqq: ((__mainThreadObjectSource)=>__mainThreadObjectSource == null ? __mainThreadObjectSource : captureMainThreadObject?.(__mainThreadObjectSource) ?? {
|
|
33
33
|
rrrr: __mainThreadObjectSource.rrrr
|
|
34
34
|
})(__mainThreadObjectSource.qqqq)
|
|
35
35
|
})(this.pppp)
|
|
@@ -2,30 +2,30 @@ import { captureMainThreadObject as __captureMainThreadObject } from "@lynx-js/r
|
|
|
2
2
|
var captureMainThreadObject = __captureMainThreadObject;
|
|
3
3
|
let onTapLepus = {
|
|
4
4
|
_c: {
|
|
5
|
-
aaaa: captureMainThreadObject(aaaa) ?? {
|
|
5
|
+
aaaa: captureMainThreadObject?.(aaaa) ?? {
|
|
6
6
|
bbbb: aaaa.bbbb
|
|
7
7
|
},
|
|
8
|
-
cccc: captureMainThreadObject(cccc) ?? {
|
|
8
|
+
cccc: captureMainThreadObject?.(cccc) ?? {
|
|
9
9
|
dddd: cccc.dddd
|
|
10
10
|
},
|
|
11
|
-
hhhh: captureMainThreadObject(hhhh) ?? {
|
|
11
|
+
hhhh: captureMainThreadObject?.(hhhh) ?? {
|
|
12
12
|
iiii: hhhh.iiii
|
|
13
13
|
},
|
|
14
14
|
llll,
|
|
15
|
-
oooo: captureMainThreadObject(oooo) ?? {
|
|
15
|
+
oooo: captureMainThreadObject?.(oooo) ?? {
|
|
16
16
|
pppp: oooo.pppp,
|
|
17
17
|
qqqq: oooo.qqqq
|
|
18
18
|
},
|
|
19
19
|
rrrr,
|
|
20
|
-
uuuu: captureMainThreadObject(uuuu) ?? {
|
|
20
|
+
uuuu: captureMainThreadObject?.(uuuu) ?? {
|
|
21
21
|
"__??__": uuuu["__??__"]
|
|
22
22
|
},
|
|
23
23
|
enabled,
|
|
24
|
-
handlers: handlers == null ? handlers : captureMainThreadObject(handlers) ?? {
|
|
24
|
+
handlers: handlers == null ? handlers : captureMainThreadObject?.(handlers) ?? {
|
|
25
25
|
start: handlers.start
|
|
26
26
|
},
|
|
27
|
-
vvvv: vvvv == null ? vvvv : captureMainThreadObject(vvvv) ?? {
|
|
28
|
-
wwww: ((__mainThreadObjectSource)=>__mainThreadObjectSource == null ? __mainThreadObjectSource : captureMainThreadObject(__mainThreadObjectSource) ?? {
|
|
27
|
+
vvvv: vvvv == null ? vvvv : captureMainThreadObject?.(vvvv) ?? {
|
|
28
|
+
wwww: ((__mainThreadObjectSource)=>__mainThreadObjectSource == null ? __mainThreadObjectSource : captureMainThreadObject?.(__mainThreadObjectSource) ?? {
|
|
29
29
|
xxxx: __mainThreadObjectSource.xxxx
|
|
30
30
|
})(vvvv.wwww)
|
|
31
31
|
}
|
|
@@ -3,30 +3,30 @@ import { captureMainThreadObject as __captureMainThreadObject } from "@lynx-js/r
|
|
|
3
3
|
var captureMainThreadObject = __captureMainThreadObject;
|
|
4
4
|
let onTapLepus = {
|
|
5
5
|
_c: {
|
|
6
|
-
aaaa: captureMainThreadObject(aaaa) ?? {
|
|
6
|
+
aaaa: captureMainThreadObject?.(aaaa) ?? {
|
|
7
7
|
bbbb: aaaa.bbbb
|
|
8
8
|
},
|
|
9
|
-
cccc: captureMainThreadObject(cccc) ?? {
|
|
9
|
+
cccc: captureMainThreadObject?.(cccc) ?? {
|
|
10
10
|
dddd: cccc.dddd
|
|
11
11
|
},
|
|
12
|
-
hhhh: captureMainThreadObject(hhhh) ?? {
|
|
12
|
+
hhhh: captureMainThreadObject?.(hhhh) ?? {
|
|
13
13
|
iiii: hhhh.iiii
|
|
14
14
|
},
|
|
15
15
|
llll,
|
|
16
|
-
oooo: captureMainThreadObject(oooo) ?? {
|
|
16
|
+
oooo: captureMainThreadObject?.(oooo) ?? {
|
|
17
17
|
pppp: oooo.pppp,
|
|
18
18
|
qqqq: oooo.qqqq
|
|
19
19
|
},
|
|
20
20
|
rrrr,
|
|
21
|
-
uuuu: captureMainThreadObject(uuuu) ?? {
|
|
21
|
+
uuuu: captureMainThreadObject?.(uuuu) ?? {
|
|
22
22
|
"__??__": uuuu["__??__"]
|
|
23
23
|
},
|
|
24
24
|
enabled,
|
|
25
|
-
handlers: handlers == null ? handlers : captureMainThreadObject(handlers) ?? {
|
|
25
|
+
handlers: handlers == null ? handlers : captureMainThreadObject?.(handlers) ?? {
|
|
26
26
|
start: handlers.start
|
|
27
27
|
},
|
|
28
|
-
vvvv: vvvv == null ? vvvv : captureMainThreadObject(vvvv) ?? {
|
|
29
|
-
wwww: ((__mainThreadObjectSource)=>__mainThreadObjectSource == null ? __mainThreadObjectSource : captureMainThreadObject(__mainThreadObjectSource) ?? {
|
|
28
|
+
vvvv: vvvv == null ? vvvv : captureMainThreadObject?.(vvvv) ?? {
|
|
29
|
+
wwww: ((__mainThreadObjectSource)=>__mainThreadObjectSource == null ? __mainThreadObjectSource : captureMainThreadObject?.(__mainThreadObjectSource) ?? {
|
|
30
30
|
xxxx: __mainThreadObjectSource.xxxx
|
|
31
31
|
})(vvvv.wwww)
|
|
32
32
|
}
|
|
@@ -8,12 +8,12 @@ class App extends Component {
|
|
|
8
8
|
return {
|
|
9
9
|
_wkltId: "a123:test:1",
|
|
10
10
|
...{
|
|
11
|
-
value: ((__mainThreadObjectSource)=>__mainThreadObjectSource == null ? __mainThreadObjectSource : captureMainThreadObject(__mainThreadObjectSource) ?? {
|
|
11
|
+
value: ((__mainThreadObjectSource)=>__mainThreadObjectSource == null ? __mainThreadObjectSource : captureMainThreadObject?.(__mainThreadObjectSource) ?? {
|
|
12
12
|
"get": __mainThreadObjectSource["get"],
|
|
13
13
|
set: __mainThreadObjectSource.set
|
|
14
14
|
})(this.value),
|
|
15
|
-
props: ((__mainThreadObjectSource)=>captureMainThreadObject(__mainThreadObjectSource) ?? {
|
|
16
|
-
value: ((__mainThreadObjectSource)=>captureMainThreadObject(__mainThreadObjectSource) ?? {
|
|
15
|
+
props: ((__mainThreadObjectSource)=>captureMainThreadObject?.(__mainThreadObjectSource) ?? {
|
|
16
|
+
value: ((__mainThreadObjectSource)=>captureMainThreadObject?.(__mainThreadObjectSource) ?? {
|
|
17
17
|
get: __mainThreadObjectSource.get
|
|
18
18
|
})(__mainThreadObjectSource.value)
|
|
19
19
|
})(this.props),
|
|
@@ -25,7 +25,7 @@ class App extends Component {
|
|
|
25
25
|
return {
|
|
26
26
|
_wkltId: "a123:test:2",
|
|
27
27
|
...{
|
|
28
|
-
value: ((__mainThreadObjectSource)=>captureMainThreadObject(__mainThreadObjectSource) ?? {
|
|
28
|
+
value: ((__mainThreadObjectSource)=>captureMainThreadObject?.(__mainThreadObjectSource) ?? {
|
|
29
29
|
get: __mainThreadObjectSource.get
|
|
30
30
|
})(this.value)
|
|
31
31
|
}
|
|
@@ -34,7 +34,7 @@ class App extends Component {
|
|
|
34
34
|
static onStatic = {
|
|
35
35
|
_wkltId: "a123:test:3",
|
|
36
36
|
...{
|
|
37
|
-
value: ((__mainThreadObjectSource)=>captureMainThreadObject(__mainThreadObjectSource) ?? {
|
|
37
|
+
value: ((__mainThreadObjectSource)=>captureMainThreadObject?.(__mainThreadObjectSource) ?? {
|
|
38
38
|
get: __mainThreadObjectSource.get
|
|
39
39
|
})(this.value)
|
|
40
40
|
}
|
|
@@ -8,12 +8,12 @@ class App extends Component {
|
|
|
8
8
|
onTap = {
|
|
9
9
|
_wkltId: "a123:test:1",
|
|
10
10
|
...{
|
|
11
|
-
value: ((__mainThreadObjectSource)=>__mainThreadObjectSource == null ? __mainThreadObjectSource : captureMainThreadObject(__mainThreadObjectSource) ?? {
|
|
11
|
+
value: ((__mainThreadObjectSource)=>__mainThreadObjectSource == null ? __mainThreadObjectSource : captureMainThreadObject?.(__mainThreadObjectSource) ?? {
|
|
12
12
|
"get": __mainThreadObjectSource["get"],
|
|
13
13
|
set: __mainThreadObjectSource.set
|
|
14
14
|
})(this.value),
|
|
15
|
-
props: ((__mainThreadObjectSource)=>captureMainThreadObject(__mainThreadObjectSource) ?? {
|
|
16
|
-
value: ((__mainThreadObjectSource)=>captureMainThreadObject(__mainThreadObjectSource) ?? {
|
|
15
|
+
props: ((__mainThreadObjectSource)=>captureMainThreadObject?.(__mainThreadObjectSource) ?? {
|
|
16
|
+
value: ((__mainThreadObjectSource)=>captureMainThreadObject?.(__mainThreadObjectSource) ?? {
|
|
17
17
|
get: __mainThreadObjectSource.get
|
|
18
18
|
})(__mainThreadObjectSource.value)
|
|
19
19
|
})(this.props),
|
|
@@ -23,7 +23,7 @@ class App extends Component {
|
|
|
23
23
|
onMove = {
|
|
24
24
|
_wkltId: "a123:test:2",
|
|
25
25
|
...{
|
|
26
|
-
value: ((__mainThreadObjectSource)=>captureMainThreadObject(__mainThreadObjectSource) ?? {
|
|
26
|
+
value: ((__mainThreadObjectSource)=>captureMainThreadObject?.(__mainThreadObjectSource) ?? {
|
|
27
27
|
get: __mainThreadObjectSource.get
|
|
28
28
|
})(this.value)
|
|
29
29
|
}
|
|
@@ -31,7 +31,7 @@ class App extends Component {
|
|
|
31
31
|
static onStatic = {
|
|
32
32
|
_wkltId: "a123:test:3",
|
|
33
33
|
...{
|
|
34
|
-
value: ((__mainThreadObjectSource)=>captureMainThreadObject(__mainThreadObjectSource) ?? {
|
|
34
|
+
value: ((__mainThreadObjectSource)=>captureMainThreadObject?.(__mainThreadObjectSource) ?? {
|
|
35
35
|
get: __mainThreadObjectSource.get
|
|
36
36
|
})(this.value)
|
|
37
37
|
}
|