@sigx/lynx-runtime-main 0.2.4 → 0.2.7
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/THIRD_PARTY_NOTICES.md +196 -0
- package/dist/{entry-main-odx1uWxp.js → entry-main-CBM2DHsU.js} +152 -144
- package/dist/entry-main-CBM2DHsU.js.map +1 -0
- package/dist/entry-main.js +1 -1
- package/dist/index.js +1 -1
- package/dist/upstream/observers.d.ts +14 -0
- package/package.json +4 -4
- package/dist/entry-main-odx1uWxp.js.map +0 -1
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
# Third-party notices
|
|
2
|
+
|
|
3
|
+
This package contains code derived from third-party open-source projects.
|
|
4
|
+
Each item below lists the upstream source and its license.
|
|
5
|
+
|
|
6
|
+
## `@lynx-js/react`
|
|
7
|
+
|
|
8
|
+
Files derived from [`@lynx-js/react`](https://github.com/lynx-family/lynx-stack):
|
|
9
|
+
|
|
10
|
+
- `src/upstream/processGesture.ts` — verbatim TS port of `runtime/lib/gesture/processGesture.js` (`@lynx-js/react@0.119.0`).
|
|
11
|
+
- `src/upstream/observers.ts` — verbatim TS port of `runtime/lib/worklet-runtime/bindings/observers.js` (`@lynx-js/react@0.120.0`).
|
|
12
|
+
|
|
13
|
+
These files retain their original copyright (`Copyright 2024-2025 The Lynx Authors`) and are used here under the terms of the Apache License, Version 2.0. Modifications by SignalX contributors are limited to adding TypeScript types; no behavior was changed.
|
|
14
|
+
|
|
15
|
+
The full text of the Apache License 2.0 is reproduced below.
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
Apache License
|
|
21
|
+
Version 2.0, January 2004
|
|
22
|
+
http://www.apache.org/licenses/
|
|
23
|
+
|
|
24
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
25
|
+
|
|
26
|
+
1. Definitions.
|
|
27
|
+
|
|
28
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
29
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
30
|
+
|
|
31
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
32
|
+
the copyright owner that is granting the License.
|
|
33
|
+
|
|
34
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
35
|
+
other entities that control, are controlled by, or are under common
|
|
36
|
+
control with that entity. For the purposes of this definition,
|
|
37
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
38
|
+
direction or management of such entity, whether by contract or
|
|
39
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
40
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
41
|
+
|
|
42
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
43
|
+
exercising permissions granted by this License.
|
|
44
|
+
|
|
45
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
46
|
+
including but not limited to software source code, documentation
|
|
47
|
+
source, and configuration files.
|
|
48
|
+
|
|
49
|
+
"Object" form shall mean any form resulting from mechanical
|
|
50
|
+
transformation or translation of a Source form, including but
|
|
51
|
+
not limited to compiled object code, generated documentation,
|
|
52
|
+
and conversions to other media types.
|
|
53
|
+
|
|
54
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
55
|
+
Object form, made available under the License, as indicated by a
|
|
56
|
+
copyright notice that is included in or attached to the work
|
|
57
|
+
(an example is provided in the Appendix below).
|
|
58
|
+
|
|
59
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
60
|
+
form, that is based on (or derived from) the Work and for which the
|
|
61
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
62
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
63
|
+
of this License, Derivative Works shall not include works that remain
|
|
64
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
65
|
+
the Work and Derivative Works thereof.
|
|
66
|
+
|
|
67
|
+
"Contribution" shall mean any work of authorship, including
|
|
68
|
+
the original version of the Work and any modifications or additions
|
|
69
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
70
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
71
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
72
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
73
|
+
means any form of electronic, verbal, or written communication sent
|
|
74
|
+
to the Licensor or its representatives, including but not limited to
|
|
75
|
+
communication on electronic mailing lists, source code control systems,
|
|
76
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
77
|
+
Licensor for the purpose of tracking or otherwise improving the Work,
|
|
78
|
+
but excluding communication that is conspicuously marked or otherwise
|
|
79
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
80
|
+
|
|
81
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
82
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
83
|
+
subsequently incorporated within the Work.
|
|
84
|
+
|
|
85
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
86
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
87
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
88
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
89
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
90
|
+
Work and such Derivative Works in Source or Object form.
|
|
91
|
+
|
|
92
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
93
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
94
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
95
|
+
(except as stated in this section) patent license to make, have made,
|
|
96
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
97
|
+
where such license applies only to those patent claims licensable
|
|
98
|
+
by such Contributor that are necessarily infringed by their
|
|
99
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
100
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
101
|
+
institute patent litigation against any entity (including a
|
|
102
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
103
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
104
|
+
or contributory patent infringement, then any patent licenses
|
|
105
|
+
granted to You under this License for that Work shall terminate
|
|
106
|
+
as of the date such litigation is filed.
|
|
107
|
+
|
|
108
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
109
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
110
|
+
modifications, and in Source or Object form, provided that You
|
|
111
|
+
meet the following conditions:
|
|
112
|
+
|
|
113
|
+
(a) You must give any other recipients of the Work or
|
|
114
|
+
Derivative Works a copy of this License; and
|
|
115
|
+
|
|
116
|
+
(b) You must cause any modified files to carry prominent notices
|
|
117
|
+
stating that You changed the files; and
|
|
118
|
+
|
|
119
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
120
|
+
that You distribute, all copyright, patent, trademark, and
|
|
121
|
+
attribution notices from the Source form of the Work,
|
|
122
|
+
excluding those notices that do not pertain to any part of
|
|
123
|
+
the Derivative Works; and
|
|
124
|
+
|
|
125
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
126
|
+
distribution, then any Derivative Works that You distribute must
|
|
127
|
+
include a readable copy of the attribution notices contained
|
|
128
|
+
within such NOTICE file, excluding those notices that do not
|
|
129
|
+
pertain to any part of the Derivative Works, in at least one
|
|
130
|
+
of the following places: within a NOTICE text file distributed
|
|
131
|
+
as part of the Derivative Works; within the Source form or
|
|
132
|
+
documentation, if provided along with the Derivative Works; or,
|
|
133
|
+
within a display generated by the Derivative Works, if and
|
|
134
|
+
wherever such third-party notices normally appear. The contents
|
|
135
|
+
of the NOTICE file are for informational purposes only and
|
|
136
|
+
do not modify the License. You may add Your own attribution
|
|
137
|
+
notices within Derivative Works that You distribute, alongside
|
|
138
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
139
|
+
that such additional attribution notices cannot be construed
|
|
140
|
+
as modifying the License.
|
|
141
|
+
|
|
142
|
+
You may add Your own copyright statement to Your modifications and
|
|
143
|
+
may provide additional or different license terms and conditions
|
|
144
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
145
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
146
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
147
|
+
the conditions stated in this License.
|
|
148
|
+
|
|
149
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
150
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
151
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
152
|
+
this License, without any additional terms or conditions.
|
|
153
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
154
|
+
the terms of any separate license agreement you may have executed
|
|
155
|
+
with Licensor regarding such Contributions.
|
|
156
|
+
|
|
157
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
158
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
159
|
+
except as required for describing the origin of the Work and
|
|
160
|
+
reproducing the content of the NOTICE file.
|
|
161
|
+
|
|
162
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
163
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
164
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
165
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
166
|
+
implied, including, without limitation, any warranties or conditions
|
|
167
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
168
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
169
|
+
appropriateness of using or redistributing the Work and assume any
|
|
170
|
+
risks associated with Your exercise of permissions under this License.
|
|
171
|
+
|
|
172
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
173
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
174
|
+
unless required by applicable law (such as deliberate and grossly
|
|
175
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
176
|
+
liable to You for damages, including any direct, indirect, special,
|
|
177
|
+
incidental, or consequential damages of any character arising as a
|
|
178
|
+
result of this License or out of the use or inability to use the
|
|
179
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
180
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
181
|
+
other commercial damages or losses), even if such Contributor
|
|
182
|
+
has been advised of the possibility of such damages.
|
|
183
|
+
|
|
184
|
+
9. Accepting Warranty or Support. While redistributing
|
|
185
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
186
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
187
|
+
or other liability obligations and/or rights consistent with this
|
|
188
|
+
License. However, in accepting such obligations, You may act only
|
|
189
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
190
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
191
|
+
defend, and hold each Contributor harmless for any liability
|
|
192
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
193
|
+
of your accepting any such warranty or support.
|
|
194
|
+
|
|
195
|
+
END OF TERMS AND CONDITIONS
|
|
196
|
+
```
|
|
@@ -1,66 +1,74 @@
|
|
|
1
1
|
import { n as e } from "./hybrid-worklet-nTcCh-mA.js";
|
|
2
2
|
import { OP as t } from "@sigx/lynx-runtime-internal";
|
|
3
|
-
import { onWorkletCtxUpdate as n } from "@lynx-js/react/worklet-runtime/bindings";
|
|
4
3
|
//#region src/element-registry.ts
|
|
5
|
-
var
|
|
6
|
-
function
|
|
7
|
-
|
|
4
|
+
var n = /* @__PURE__ */ new Map(), r = 1;
|
|
5
|
+
function i(e) {
|
|
6
|
+
r = e;
|
|
7
|
+
}
|
|
8
|
+
//#endregion
|
|
9
|
+
//#region src/upstream/observers.ts
|
|
10
|
+
function a() {
|
|
11
|
+
return globalThis.lynxWorkletImpl;
|
|
12
|
+
}
|
|
13
|
+
function o(e, t, n, r) {
|
|
14
|
+
let i = a();
|
|
15
|
+
e._execId !== void 0 && i?._jsFunctionLifecycleManager?.addRef(e._execId, e), n && t && i?._hydrateCtx(e, t), n && i?._eventDelayImpl.runDelayedWorklet(e, r);
|
|
8
16
|
}
|
|
9
17
|
//#endregion
|
|
10
18
|
//#region src/upstream/processGesture.ts
|
|
11
|
-
var
|
|
12
|
-
function
|
|
19
|
+
var s = -1;
|
|
20
|
+
function c(e) {
|
|
13
21
|
return e?.__isSerialized === !0;
|
|
14
22
|
}
|
|
15
|
-
function
|
|
16
|
-
if (!(!e || !
|
|
23
|
+
function l(e) {
|
|
24
|
+
if (!(!e || !c(e)) && e.type !== s) return e;
|
|
17
25
|
}
|
|
18
|
-
function
|
|
19
|
-
if (!e || !
|
|
20
|
-
if (e.type ===
|
|
21
|
-
for (let r of e.gestures)
|
|
26
|
+
function u(e, t, n) {
|
|
27
|
+
if (!e || !c(e)) return;
|
|
28
|
+
if (e.type === s) {
|
|
29
|
+
for (let r of e.gestures) u(r, t, n);
|
|
22
30
|
return;
|
|
23
31
|
}
|
|
24
32
|
let r = e;
|
|
25
33
|
n.has(r.id) || (n.add(r.id), t.push(r));
|
|
26
34
|
}
|
|
27
|
-
function
|
|
28
|
-
if (!e || !
|
|
29
|
-
if (e.type ===
|
|
30
|
-
for (let r of e.gestures)
|
|
35
|
+
function d(e, t, n) {
|
|
36
|
+
if (!e || !c(e)) return;
|
|
37
|
+
if (e.type === s) {
|
|
38
|
+
for (let r of e.gestures) d(r, t, n);
|
|
31
39
|
return;
|
|
32
40
|
}
|
|
33
41
|
let r = e;
|
|
34
42
|
n.has(r.id) || (n.set(r.id, r), t.push(r));
|
|
35
43
|
}
|
|
36
|
-
function
|
|
44
|
+
function ee(e) {
|
|
37
45
|
let t = [], n = /* @__PURE__ */ new Map();
|
|
38
|
-
return
|
|
46
|
+
return d(e, t, n), {
|
|
39
47
|
uniqOldBaseGestures: t,
|
|
40
48
|
oldBaseGesturesById: n
|
|
41
49
|
};
|
|
42
50
|
}
|
|
43
|
-
function
|
|
51
|
+
function f(e, t, n) {
|
|
44
52
|
let r = n.get(e.id);
|
|
45
53
|
if (r) return n.delete(e.id), r;
|
|
46
54
|
let i = t.find((e) => n.has(e.id));
|
|
47
55
|
if (i) return n.delete(i.id), i;
|
|
48
56
|
}
|
|
49
|
-
function
|
|
57
|
+
function p(e, t) {
|
|
50
58
|
typeof __RemoveGestureDetector == "function" && __RemoveGestureDetector(e, t);
|
|
51
59
|
}
|
|
52
|
-
function
|
|
53
|
-
let
|
|
54
|
-
e.config && (
|
|
55
|
-
for (let
|
|
56
|
-
let s = e.callbacks[
|
|
57
|
-
|
|
58
|
-
name:
|
|
60
|
+
function m(e, t, n, r) {
|
|
61
|
+
let i = { callbacks: [] };
|
|
62
|
+
e.config && (i.config = e.config);
|
|
63
|
+
for (let a of Object.keys(e.callbacks)) {
|
|
64
|
+
let s = e.callbacks[a], c = t?.callbacks[a];
|
|
65
|
+
o(s, c, n, r), i.callbacks.push({
|
|
66
|
+
name: a,
|
|
59
67
|
callback: s
|
|
60
68
|
});
|
|
61
69
|
}
|
|
62
70
|
return {
|
|
63
|
-
config:
|
|
71
|
+
config: i,
|
|
64
72
|
relationMap: {
|
|
65
73
|
waitFor: e.waitFor?.map((e) => e.id) ?? [],
|
|
66
74
|
simultaneous: e.simultaneousWith?.map((e) => e.id) ?? [],
|
|
@@ -68,34 +76,34 @@ function p(e, t, r, i) {
|
|
|
68
76
|
}
|
|
69
77
|
};
|
|
70
78
|
}
|
|
71
|
-
function
|
|
72
|
-
let a = i?.domSet === !0, { uniqOldBaseGestures: o, oldBaseGesturesById: s } =
|
|
73
|
-
if (
|
|
74
|
-
a || (__SetAttribute(e, "has-react-gesture", !0), __SetAttribute(e, "flatten", !1)),
|
|
75
|
-
let { config: t, relationMap: n } =
|
|
76
|
-
__SetGestureDetector(e,
|
|
79
|
+
function h(e, t, n, r, i) {
|
|
80
|
+
let a = i?.domSet === !0, { uniqOldBaseGestures: o, oldBaseGesturesById: s } = ee(n), c = l(t), d = l(n);
|
|
81
|
+
if (c && (!n || d)) {
|
|
82
|
+
a || (__SetAttribute(e, "has-react-gesture", !0), __SetAttribute(e, "flatten", !1)), d && p(e, d.id);
|
|
83
|
+
let { config: t, relationMap: n } = m(c, d, r, e);
|
|
84
|
+
__SetGestureDetector(e, c.id, c.type, t, n);
|
|
77
85
|
return;
|
|
78
86
|
}
|
|
79
87
|
let h = [];
|
|
80
|
-
if (
|
|
81
|
-
for (let t of s.values())
|
|
88
|
+
if (u(t, h, /* @__PURE__ */ new Set()), h.length === 0) {
|
|
89
|
+
for (let t of s.values()) p(e, t.id);
|
|
82
90
|
a || __SetAttribute(e, "has-react-gesture", null);
|
|
83
91
|
return;
|
|
84
92
|
}
|
|
85
93
|
a || (__SetAttribute(e, "has-react-gesture", !0), __SetAttribute(e, "flatten", !1));
|
|
86
|
-
for (let t of s.values())
|
|
94
|
+
for (let t of s.values()) p(e, t.id);
|
|
87
95
|
for (let t of h) {
|
|
88
|
-
let { config: n, relationMap: i } =
|
|
96
|
+
let { config: n, relationMap: i } = m(t, f(t, o, s), r, e);
|
|
89
97
|
__SetGestureDetector(e, t.id, t.type, n, i);
|
|
90
98
|
}
|
|
91
99
|
}
|
|
92
100
|
//#endregion
|
|
93
101
|
//#region src/worklet-events.ts
|
|
94
|
-
function
|
|
102
|
+
function te() {
|
|
95
103
|
return globalThis.lynxWorkletImpl;
|
|
96
104
|
}
|
|
97
105
|
function g(e, t, n) {
|
|
98
|
-
let r =
|
|
106
|
+
let r = te();
|
|
99
107
|
if (!r) {
|
|
100
108
|
console.log("[sigx-mt] lynxWorkletImpl not initialized");
|
|
101
109
|
return;
|
|
@@ -132,7 +140,7 @@ function S(e, t, n, r) {
|
|
|
132
140
|
let i = y(e, t, n);
|
|
133
141
|
i.bgSign = r, b(e, t, n);
|
|
134
142
|
}
|
|
135
|
-
function
|
|
143
|
+
function ne(t) {
|
|
136
144
|
let { worklet: n, bgSign: r } = t;
|
|
137
145
|
if (!(!n && !r)) return n && !r ? {
|
|
138
146
|
type: "worklet",
|
|
@@ -142,29 +150,29 @@ function C(t) {
|
|
|
142
150
|
value: e(n, r)
|
|
143
151
|
};
|
|
144
152
|
}
|
|
145
|
-
function
|
|
153
|
+
function C() {
|
|
146
154
|
for (let e of v) {
|
|
147
|
-
let t = e.indexOf("|"),
|
|
155
|
+
let t = e.indexOf("|"), r = Number(e.slice(0, t)), i = e.slice(t + 1), a = i.indexOf(":"), o = i.slice(0, a), s = i.slice(a + 1), c = n.get(r);
|
|
148
156
|
if (!c) continue;
|
|
149
|
-
let l = _.get(
|
|
157
|
+
let l = _.get(r)?.get(i);
|
|
150
158
|
if (!l) continue;
|
|
151
|
-
let u =
|
|
152
|
-
|
|
159
|
+
let u = ne(l);
|
|
160
|
+
re(u, l.installed) || (__AddEvent(c, o, s, u), l.installed = u);
|
|
153
161
|
}
|
|
154
162
|
v.clear();
|
|
155
163
|
}
|
|
156
|
-
function
|
|
164
|
+
function re(e, t) {
|
|
157
165
|
return e === t;
|
|
158
166
|
}
|
|
159
|
-
function
|
|
167
|
+
function w() {
|
|
160
168
|
_.clear(), v.clear();
|
|
161
169
|
}
|
|
162
170
|
//#endregion
|
|
163
171
|
//#region src/animated-style-mappers.ts
|
|
164
|
-
function
|
|
172
|
+
function T(e) {
|
|
165
173
|
return typeof e == "object" && !!e && "inputRange" in e && "outputRange" in e;
|
|
166
174
|
}
|
|
167
|
-
function
|
|
175
|
+
function E(e, t, n, r = "clamp") {
|
|
168
176
|
let i = t.length;
|
|
169
177
|
if (i < 2) return n[0] ?? e;
|
|
170
178
|
if (e <= t[0]) {
|
|
@@ -183,42 +191,42 @@ function D(e, t, n, r = "clamp") {
|
|
|
183
191
|
}
|
|
184
192
|
return n[i - 1];
|
|
185
193
|
}
|
|
186
|
-
var
|
|
187
|
-
translateX: (e, t) =>
|
|
188
|
-
translateY: (e, t) =>
|
|
194
|
+
var ie = {
|
|
195
|
+
translateX: (e, t) => T(t) ? { transform: `translateX(${E(e, t.inputRange, t.outputRange, t.extrapolate)}px)` } : { transform: `translateX(${e * (t?.factor ?? 1)}px)` },
|
|
196
|
+
translateY: (e, t) => T(t) ? { transform: `translateY(${E(e, t.inputRange, t.outputRange, t.extrapolate)}px)` } : { transform: `translateY(${e * (t?.factor ?? 1)}px)` },
|
|
189
197
|
translate: (e, t) => {
|
|
190
198
|
let n = t ?? {}, r = n.factorX ?? 1, i = n.factorY ?? 1, a = e;
|
|
191
199
|
return { transform: `translate(${a.x * r}px, ${a.y * i}px)` };
|
|
192
200
|
},
|
|
193
|
-
scale: (e, t) =>
|
|
201
|
+
scale: (e, t) => T(t) ? { transform: `scale(${E(e, t.inputRange, t.outputRange, t.extrapolate)})` } : { transform: `scale(${e + (t?.offset ?? 0)})` },
|
|
194
202
|
opacity: (e, t) => {
|
|
195
|
-
if (
|
|
196
|
-
let n =
|
|
203
|
+
if (T(t)) {
|
|
204
|
+
let n = E(e, t.inputRange, t.outputRange, t.extrapolate);
|
|
197
205
|
return { opacity: String(Math.max(0, Math.min(1, n))) };
|
|
198
206
|
}
|
|
199
207
|
let n = t ?? {}, r = n.factor ?? 1, i = n.offset ?? 0, a = Math.max(0, Math.min(1, e * r + i));
|
|
200
208
|
return { opacity: String(a) };
|
|
201
209
|
},
|
|
202
210
|
rotate: (e) => ({ transform: `rotate(${e}deg)` }),
|
|
203
|
-
paddingTop: (e, t) => ({ paddingTop: `${
|
|
204
|
-
paddingRight: (e, t) => ({ paddingRight: `${
|
|
205
|
-
paddingBottom: (e, t) => ({ paddingBottom: `${
|
|
206
|
-
paddingLeft: (e, t) => ({ paddingLeft: `${
|
|
207
|
-
marginTop: (e, t) => ({ marginTop: `${
|
|
208
|
-
marginRight: (e, t) => ({ marginRight: `${
|
|
209
|
-
marginBottom: (e, t) => ({ marginBottom: `${
|
|
210
|
-
marginLeft: (e, t) => ({ marginLeft: `${
|
|
211
|
+
paddingTop: (e, t) => ({ paddingTop: `${D(e, t)}px` }),
|
|
212
|
+
paddingRight: (e, t) => ({ paddingRight: `${D(e, t)}px` }),
|
|
213
|
+
paddingBottom: (e, t) => ({ paddingBottom: `${D(e, t)}px` }),
|
|
214
|
+
paddingLeft: (e, t) => ({ paddingLeft: `${D(e, t)}px` }),
|
|
215
|
+
marginTop: (e, t) => ({ marginTop: `${D(e, t)}px` }),
|
|
216
|
+
marginRight: (e, t) => ({ marginRight: `${D(e, t)}px` }),
|
|
217
|
+
marginBottom: (e, t) => ({ marginBottom: `${D(e, t)}px` }),
|
|
218
|
+
marginLeft: (e, t) => ({ marginLeft: `${D(e, t)}px` })
|
|
211
219
|
};
|
|
212
|
-
function
|
|
213
|
-
return
|
|
220
|
+
function D(e, t) {
|
|
221
|
+
return T(t) ? E(e, t.inputRange, t.outputRange, t.extrapolate) : e * (t?.factor ?? 1);
|
|
214
222
|
}
|
|
215
|
-
function
|
|
216
|
-
return
|
|
223
|
+
function ae(e) {
|
|
224
|
+
return ie[e];
|
|
217
225
|
}
|
|
218
226
|
//#endregion
|
|
219
227
|
//#region src/animated-bridge-mt.ts
|
|
220
|
-
var
|
|
221
|
-
function
|
|
228
|
+
var oe = "Lynx.Sigx.AvPublish";
|
|
229
|
+
function O() {
|
|
222
230
|
if (L.size === 0) return;
|
|
223
231
|
let e = globalThis.lynxWorkletImpl?._refImpl?._workletRefMap;
|
|
224
232
|
if (!e) return;
|
|
@@ -240,13 +248,13 @@ function A() {
|
|
|
240
248
|
return;
|
|
241
249
|
}
|
|
242
250
|
n.dispatchEvent({
|
|
243
|
-
type:
|
|
251
|
+
type: oe,
|
|
244
252
|
data: r
|
|
245
253
|
});
|
|
246
254
|
}
|
|
247
|
-
var
|
|
248
|
-
function
|
|
249
|
-
|
|
255
|
+
var k = /* @__PURE__ */ new Map();
|
|
256
|
+
function A(e, t, n, r, i) {
|
|
257
|
+
k.set(e, {
|
|
250
258
|
elementWvid: t,
|
|
251
259
|
avWvid: n,
|
|
252
260
|
mapperName: r,
|
|
@@ -254,18 +262,18 @@ function ie(e, t, n, r, i) {
|
|
|
254
262
|
lastValue: {}
|
|
255
263
|
});
|
|
256
264
|
}
|
|
257
|
-
function
|
|
258
|
-
|
|
259
|
-
}
|
|
260
|
-
function oe() {
|
|
261
|
-
j.clear();
|
|
265
|
+
function j(e) {
|
|
266
|
+
k.delete(e);
|
|
262
267
|
}
|
|
263
268
|
function M() {
|
|
264
|
-
|
|
269
|
+
k.clear();
|
|
270
|
+
}
|
|
271
|
+
function N() {
|
|
272
|
+
if (k.size === 0) return;
|
|
265
273
|
let e = globalThis.lynxWorkletImpl?._refImpl?._workletRefMap;
|
|
266
274
|
if (!e) return;
|
|
267
275
|
let t;
|
|
268
|
-
for (let n of
|
|
276
|
+
for (let n of k.values()) {
|
|
269
277
|
let r = e[n.avWvid];
|
|
270
278
|
if (!r) continue;
|
|
271
279
|
let i = r.current?.value;
|
|
@@ -273,11 +281,11 @@ function M() {
|
|
|
273
281
|
}
|
|
274
282
|
if (!t) return;
|
|
275
283
|
let n = /* @__PURE__ */ new Map();
|
|
276
|
-
for (let r of
|
|
284
|
+
for (let r of k.values()) {
|
|
277
285
|
if (!t.has(r.elementWvid)) continue;
|
|
278
286
|
let i = e[r.avWvid];
|
|
279
287
|
if (!i) continue;
|
|
280
|
-
let a = i.current?.value, o =
|
|
288
|
+
let a = i.current?.value, o = ae(r.mapperName);
|
|
281
289
|
if (!o) continue;
|
|
282
290
|
let s;
|
|
283
291
|
try {
|
|
@@ -299,19 +307,19 @@ function M() {
|
|
|
299
307
|
}
|
|
300
308
|
}
|
|
301
309
|
}
|
|
302
|
-
var
|
|
303
|
-
function
|
|
310
|
+
var P = Symbol.for("sigx.avBridgeFlushHookInstalled");
|
|
311
|
+
function se() {
|
|
304
312
|
let e = globalThis;
|
|
305
|
-
if (e[
|
|
313
|
+
if (e[P]) return;
|
|
306
314
|
let t = e.__FlushElementTree;
|
|
307
|
-
typeof t == "function" && (e[
|
|
315
|
+
typeof t == "function" && (e[P] = !0, e.__FlushElementTree = function(...e) {
|
|
308
316
|
try {
|
|
309
|
-
|
|
317
|
+
O();
|
|
310
318
|
} catch (e) {
|
|
311
319
|
console.log("[sigx-mt] av-bridge flush threw:", String(e));
|
|
312
320
|
}
|
|
313
321
|
try {
|
|
314
|
-
|
|
322
|
+
N();
|
|
315
323
|
} catch (e) {
|
|
316
324
|
console.log("[sigx-mt] av-style bindings flush threw:", String(e));
|
|
317
325
|
}
|
|
@@ -323,7 +331,7 @@ function P() {
|
|
|
323
331
|
var F = null, I = null, L = /* @__PURE__ */ new Set(), R = /* @__PURE__ */ new Map(), z = /* @__PURE__ */ new Map(), B = /* @__PURE__ */ new Map(), V = /* @__PURE__ */ new Map();
|
|
324
332
|
function H(e) {
|
|
325
333
|
let t = V.get(e);
|
|
326
|
-
if (t !== void 0) return
|
|
334
|
+
if (t !== void 0) return n.get(t);
|
|
327
335
|
}
|
|
328
336
|
function U(e, t) {
|
|
329
337
|
F = e, I = t;
|
|
@@ -342,46 +350,46 @@ function G(e, t) {
|
|
|
342
350
|
}
|
|
343
351
|
}
|
|
344
352
|
function K(e) {
|
|
345
|
-
let
|
|
346
|
-
if (
|
|
347
|
-
if (W(),
|
|
353
|
+
let i = e.length;
|
|
354
|
+
if (i === 0) return;
|
|
355
|
+
if (W(), i >= 3 && e[0] === t.CREATE) {
|
|
348
356
|
let t = e[1];
|
|
349
|
-
if (
|
|
357
|
+
if (n.has(t)) return;
|
|
350
358
|
}
|
|
351
359
|
let a = 0;
|
|
352
|
-
for (; a <
|
|
360
|
+
for (; a < i;) switch (e[a++]) {
|
|
353
361
|
case t.CREATE: {
|
|
354
|
-
let t = e[a++],
|
|
355
|
-
|
|
362
|
+
let t = e[a++], i = e[a++], o;
|
|
363
|
+
i === "__comment" ? o = __CreateRawText("") : (o = G(i, r), __SetCSSId([o], 0)), n.set(t, o), i !== "__comment" && __SetAttribute(o, `sigx-ref-${t}`, 1);
|
|
356
364
|
break;
|
|
357
365
|
}
|
|
358
366
|
case t.CREATE_TEXT: {
|
|
359
|
-
let t = e[a++],
|
|
360
|
-
__SetCSSId([
|
|
367
|
+
let t = e[a++], i = __CreateText(r);
|
|
368
|
+
__SetCSSId([i], 0), n.set(t, i), __SetAttribute(i, `sigx-ref-${t}`, 1);
|
|
361
369
|
break;
|
|
362
370
|
}
|
|
363
371
|
case t.INSERT: {
|
|
364
|
-
let t = e[a++],
|
|
372
|
+
let t = e[a++], r = e[a++], i = e[a++], o = n.get(t), s = n.get(r);
|
|
365
373
|
if (o && s) if (i === -1) __AppendElement(o, s);
|
|
366
374
|
else {
|
|
367
|
-
let e =
|
|
375
|
+
let e = n.get(i);
|
|
368
376
|
e && __InsertElementBefore(o, s, e);
|
|
369
377
|
}
|
|
370
378
|
break;
|
|
371
379
|
}
|
|
372
380
|
case t.REMOVE: {
|
|
373
|
-
let t = e[a++],
|
|
381
|
+
let t = e[a++], r = e[a++], i = n.get(t), o = n.get(r);
|
|
374
382
|
i && o && __RemoveElement(i, o);
|
|
375
383
|
break;
|
|
376
384
|
}
|
|
377
385
|
case t.SET_PROP: {
|
|
378
|
-
let t = e[a++],
|
|
379
|
-
o && __SetAttribute(o,
|
|
386
|
+
let t = e[a++], r = e[a++], i = e[a++], o = n.get(t);
|
|
387
|
+
o && __SetAttribute(o, r, i);
|
|
380
388
|
break;
|
|
381
389
|
}
|
|
382
390
|
case t.SET_TEXT: {
|
|
383
|
-
let t = e[a++],
|
|
384
|
-
i && __SetAttribute(i, "text",
|
|
391
|
+
let t = e[a++], r = e[a++], i = n.get(t);
|
|
392
|
+
i && __SetAttribute(i, "text", r);
|
|
385
393
|
break;
|
|
386
394
|
}
|
|
387
395
|
case t.SET_EVENT: {
|
|
@@ -395,18 +403,18 @@ function K(e) {
|
|
|
395
403
|
break;
|
|
396
404
|
}
|
|
397
405
|
case t.SET_STYLE: {
|
|
398
|
-
let t = e[a++],
|
|
399
|
-
i && __SetInlineStyles(i,
|
|
406
|
+
let t = e[a++], r = e[a++], i = n.get(t);
|
|
407
|
+
i && __SetInlineStyles(i, r);
|
|
400
408
|
break;
|
|
401
409
|
}
|
|
402
410
|
case t.SET_CLASS: {
|
|
403
|
-
let t = e[a++],
|
|
404
|
-
i && __SetClasses(i,
|
|
411
|
+
let t = e[a++], r = e[a++], i = n.get(t);
|
|
412
|
+
i && __SetClasses(i, r);
|
|
405
413
|
break;
|
|
406
414
|
}
|
|
407
415
|
case t.SET_ID: {
|
|
408
|
-
let t = e[a++],
|
|
409
|
-
i && __SetID(i,
|
|
416
|
+
let t = e[a++], r = e[a++], i = n.get(t);
|
|
417
|
+
i && __SetID(i, r ?? void 0);
|
|
410
418
|
break;
|
|
411
419
|
}
|
|
412
420
|
case t.SET_WORKLET_EVENT: {
|
|
@@ -415,17 +423,17 @@ function K(e) {
|
|
|
415
423
|
break;
|
|
416
424
|
}
|
|
417
425
|
case t.SET_MT_REF: {
|
|
418
|
-
let t = e[a++],
|
|
426
|
+
let t = e[a++], r = e[a++], i = n.get(t);
|
|
419
427
|
if (i) {
|
|
420
428
|
let e = globalThis.lynxWorkletImpl;
|
|
421
429
|
if (e?._refImpl) {
|
|
422
430
|
let t = e._refImpl._workletRefMap;
|
|
423
|
-
|
|
431
|
+
r in t || (t[r] = {
|
|
424
432
|
current: null,
|
|
425
|
-
_wvid:
|
|
426
|
-
}), e._refImpl.updateWorkletRef({ _wvid:
|
|
433
|
+
_wvid: r
|
|
434
|
+
}), e._refImpl.updateWorkletRef({ _wvid: r }, i);
|
|
427
435
|
}
|
|
428
|
-
V.set(
|
|
436
|
+
V.set(r, t);
|
|
429
437
|
}
|
|
430
438
|
break;
|
|
431
439
|
}
|
|
@@ -457,12 +465,12 @@ function K(e) {
|
|
|
457
465
|
}
|
|
458
466
|
case t.REGISTER_AV_STYLE_BINDING: {
|
|
459
467
|
let t = e[a++], n = e[a++], r = e[a++], i = e[a++], o = e[a++];
|
|
460
|
-
|
|
468
|
+
A(t, n, r, i, o);
|
|
461
469
|
break;
|
|
462
470
|
}
|
|
463
471
|
case t.UNREGISTER_AV_STYLE_BINDING: {
|
|
464
472
|
let t = e[a++];
|
|
465
|
-
|
|
473
|
+
j(t);
|
|
466
474
|
break;
|
|
467
475
|
}
|
|
468
476
|
case t.SET_GESTURE_DETECTOR: {
|
|
@@ -480,7 +488,7 @@ function K(e) {
|
|
|
480
488
|
continueWith: l(o.continueWith),
|
|
481
489
|
...i.config ? { config: i.config } : {}
|
|
482
490
|
};
|
|
483
|
-
|
|
491
|
+
h(s, u, void 0, !1), B.set(t, u);
|
|
484
492
|
let d = z.get(t);
|
|
485
493
|
d || (d = /* @__PURE__ */ new Set(), z.set(t, d)), d.add(n);
|
|
486
494
|
break;
|
|
@@ -496,34 +504,34 @@ function K(e) {
|
|
|
496
504
|
}
|
|
497
505
|
default: break;
|
|
498
506
|
}
|
|
499
|
-
|
|
507
|
+
C(), O(), N(), __FlushElementTree();
|
|
500
508
|
}
|
|
501
509
|
function q() {
|
|
502
|
-
|
|
510
|
+
n.clear(), i(1), F = null, I = null, w(), L.clear(), R.clear(), z.clear(), B.clear(), V.clear(), M();
|
|
503
511
|
let e = globalThis.lynxWorkletImpl;
|
|
504
512
|
e?._refImpl && (e._refImpl._workletRefMap = {});
|
|
505
513
|
}
|
|
506
514
|
//#endregion
|
|
507
515
|
//#region src/run-on-background-mt.ts
|
|
508
|
-
var
|
|
509
|
-
function
|
|
516
|
+
var ce = "Lynx.Sigx.RunOnBackground", J = "Lynx.Sigx.FunctionCallRet", Y, le = 1;
|
|
517
|
+
function X() {
|
|
510
518
|
return globalThis.lynx?.getJSContext?.();
|
|
511
519
|
}
|
|
512
|
-
function
|
|
513
|
-
|
|
520
|
+
function ue() {
|
|
521
|
+
Y = /* @__PURE__ */ new Map(), X()?.addEventListener?.(J, (e) => {
|
|
514
522
|
let t;
|
|
515
523
|
try {
|
|
516
524
|
t = JSON.parse(e.data);
|
|
517
525
|
} catch {
|
|
518
526
|
return;
|
|
519
527
|
}
|
|
520
|
-
let n =
|
|
521
|
-
n && (
|
|
528
|
+
let n = Y?.get(t.resolveId);
|
|
529
|
+
n && (Y.delete(t.resolveId), n(t.returnValue));
|
|
522
530
|
});
|
|
523
531
|
}
|
|
524
532
|
function Z(e, t, n, r) {
|
|
525
|
-
|
|
526
|
-
type:
|
|
533
|
+
X()?.dispatchEvent?.({
|
|
534
|
+
type: ce,
|
|
527
535
|
data: JSON.stringify({
|
|
528
536
|
obj: {
|
|
529
537
|
_jsFnId: e,
|
|
@@ -534,16 +542,16 @@ function Z(e, t, n, r) {
|
|
|
534
542
|
})
|
|
535
543
|
});
|
|
536
544
|
}
|
|
537
|
-
function
|
|
545
|
+
function de(e) {
|
|
538
546
|
return (...t) => new Promise((n) => {
|
|
539
|
-
|
|
547
|
+
Y || ue();
|
|
540
548
|
let r = le++;
|
|
541
|
-
if (
|
|
549
|
+
if (Y.set(r, n), e._isFirstScreen && typeof lynxWorkletImpl < "u" && lynxWorkletImpl?._runOnBackgroundDelayImpl) {
|
|
542
550
|
lynxWorkletImpl._runOnBackgroundDelayImpl.delayRunOnBackground(e, (e, n) => Z(e, t, n, r));
|
|
543
551
|
return;
|
|
544
552
|
}
|
|
545
553
|
if (e._jsFnId == null || e._execId == null) {
|
|
546
|
-
|
|
554
|
+
Y.delete(r), n(void 0);
|
|
547
555
|
return;
|
|
548
556
|
}
|
|
549
557
|
Z(e._jsFnId, t, e._execId, r);
|
|
@@ -559,16 +567,16 @@ Q.processData = function(e, t) {
|
|
|
559
567
|
}, Q.renderPage = function(e) {
|
|
560
568
|
q();
|
|
561
569
|
let t = __CreatePage("0", 0);
|
|
562
|
-
__SetCSSId([t], 0),
|
|
563
|
-
let
|
|
564
|
-
__SetCSSId([
|
|
570
|
+
__SetCSSId([t], 0), i(__GetElementUniqueID(t)), n.set($, t);
|
|
571
|
+
let r = __CreateView(__GetElementUniqueID(t));
|
|
572
|
+
__SetCSSId([r], 0), __AppendElement(t, r), U(t, r), __FlushElementTree(t);
|
|
565
573
|
}, Q.updatePage = function(e) {}, Q.updateGlobalProps = function(e) {}, Q.sigxHotReload = function() {
|
|
566
|
-
let e =
|
|
574
|
+
let e = n.get($);
|
|
567
575
|
q();
|
|
568
576
|
let t = e ?? __CreatePage("0", 0);
|
|
569
|
-
__SetCSSId([t], 0),
|
|
570
|
-
let
|
|
571
|
-
__SetCSSId([
|
|
577
|
+
__SetCSSId([t], 0), i(__GetElementUniqueID(t)), n.set($, t);
|
|
578
|
+
let r = __CreateView(__GetElementUniqueID(t));
|
|
579
|
+
__SetCSSId([r], 0), __AppendElement(t, r), U(t, r), __FlushElementTree(t);
|
|
572
580
|
}, Q.sigxApplyMtHotUpdate = function({ code: e }) {
|
|
573
581
|
if (e) try {
|
|
574
582
|
Function(e)();
|
|
@@ -600,8 +608,8 @@ Q.processData = function(e, t) {
|
|
|
600
608
|
}
|
|
601
609
|
else a = g(e, n, i);
|
|
602
610
|
typeof r == "function" && r(a);
|
|
603
|
-
},
|
|
611
|
+
}, se(), Q.runOnBackground = de;
|
|
604
612
|
//#endregion
|
|
605
|
-
export { S as a,
|
|
613
|
+
export { S as a, n as c, w as i, r as l, q as n, x as o, C as r, g as s, K as t, i as u };
|
|
606
614
|
|
|
607
|
-
//# sourceMappingURL=entry-main-
|
|
615
|
+
//# sourceMappingURL=entry-main-CBM2DHsU.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entry-main-CBM2DHsU.js","names":[],"sources":["../src/element-registry.ts","../src/upstream/observers.ts","../src/upstream/processGesture.ts","../src/worklet-events.ts","../src/event-slots.ts","../src/animated-style-mappers.ts","../src/animated-bridge-mt.ts","../src/ops-apply.ts","../src/run-on-background-mt.ts","../src/entry-main.ts"],"sourcesContent":["/**\n * Element registry — maps BG-thread ShadowElement IDs to Lynx Main Thread\n * element handles.\n */\n\n/** Map from BG-thread ShadowElement id to Lynx Main Thread element handle */\nexport const elements = new Map<number, MainThreadElement>();\n\n/**\n * PAPI unique ID of the root PageElement.\n * Passed as `parentComponentUniqueId` to element creation PAPI calls.\n * `__SetCSSId` sets `css_style_sheet_manager_` directly on each element,\n * so CSS rendering works without a ComponentElement ancestor.\n */\nexport let pageUniqueId = 1;\n\nexport function setPageUniqueId(id: number): void {\n pageUniqueId = id;\n}\n","// Copyright 2025 The Lynx Authors. All rights reserved.\n// TypeScript types added 2026 by SignalX contributors.\n//\n// Licensed under the Apache License, Version 2.0. The full license text and\n// upstream attribution are reproduced in `THIRD_PARTY_NOTICES.md` at the\n// root of this package (`@sigx/lynx-runtime-main`). The MIT LICENSE at the\n// repository root governs the rest of this repository; it does NOT apply\n// to this file.\n//\n// Vendored from `@lynx-js/react@0.120.0`'s\n// `runtime/lib/worklet-runtime/bindings/observers.js`. Source preserved\n// verbatim; only types added. We vendor this 15-LOC helper to drop the\n// `@lynx-js/react` runtime dependency from `@sigx/lynx-runtime-main`, which\n// in turn keeps `@types/react` out of the install tree of consumer apps\n// (sigx-lynx apps use sigx primitives, not ReactLynx JSX).\n\ninterface WorkletLike {\n _execId?: number;\n}\n\ninterface JsFunctionLifecycleManager {\n addRef(execId: number, worklet: WorkletLike): void;\n}\n\ninterface EventDelayImpl {\n runDelayedWorklet(worklet: WorkletLike, element: unknown): void;\n}\n\ninterface LynxWorkletImpl {\n _jsFunctionLifecycleManager?: JsFunctionLifecycleManager;\n _eventDelayImpl: EventDelayImpl;\n _hydrateCtx(worklet: WorkletLike, oldWorklet: WorkletLike): void;\n}\n\nfunction impl(): LynxWorkletImpl | undefined {\n return (globalThis as { lynxWorkletImpl?: LynxWorkletImpl }).lynxWorkletImpl;\n}\n\n/**\n * Must be called when a worklet context is updated. Mirrors the upstream\n * ReactLynx behaviour:\n * 1. Register the new worklet with the JS-side lifecycle manager (so the\n * background thread can free it).\n * 2. On first screen with a previous ctx, hydrate the new ctx from the old.\n * 3. On first screen, flush any worklets that were delayed waiting for this\n * element (legacy dynamic-component compat path).\n */\nexport function onWorkletCtxUpdate(\n worklet: WorkletLike,\n oldWorklet: WorkletLike | null | undefined,\n isFirstScreen: boolean,\n element: unknown,\n): void {\n const w = impl();\n if (worklet._execId !== undefined) {\n w?._jsFunctionLifecycleManager?.addRef(worklet._execId, worklet);\n }\n if (isFirstScreen && oldWorklet) {\n w?._hydrateCtx(worklet, oldWorklet);\n }\n if (isFirstScreen) {\n w?._eventDelayImpl.runDelayedWorklet(worklet, element);\n }\n}\n","// Copyright 2024 The Lynx Authors. All rights reserved.\n// TypeScript types added 2026 by SignalX contributors.\n//\n// Licensed under the Apache License, Version 2.0. The full license text and\n// upstream attribution are reproduced in `THIRD_PARTY_NOTICES.md` at the\n// root of this package (`@sigx/lynx-runtime-main`). The MIT LICENSE at the\n// repository root governs the rest of this repository; it does NOT apply\n// to this file.\n//\n// TS port of `@lynx-js/react@0.119.0`'s\n// `runtime/lib/gesture/processGesture.js`. Source preserved verbatim; only\n// types added. Why vendor: upstream's `gesture/processGesture.js` is the\n// canonical platform-call sequence used by `@lynx-js/react`'s snapshot\n// pipeline. Calling our hand-rolled equivalent on a real device shows the\n// gesture arena doesn't engage; vendoring eliminates any subtle divergence.\n//\n// Sigx-specific deltas:\n// - `dom` is sigx's raw `MainThreadElement`, not a SnapshotInstance member.\n// - Caller passes `isFirstScreen=false` (no SSR/hydration in sigx).\n// - `gestureOptions` always undefined.\n\nimport { onWorkletCtxUpdate } from './observers.js';\n\nconst COMPOSED = -1;\n\ninterface GestureWorklet {\n _wkltId: string;\n _execId?: number;\n _c?: Record<string, unknown>;\n _jsFn?: Record<string, unknown>;\n _workletType?: string;\n}\n\ninterface BaseGesture {\n __isSerialized: true;\n type: number;\n id: number;\n callbacks: Record<string, GestureWorklet>;\n waitFor?: BaseGesture[];\n simultaneousWith?: BaseGesture[];\n continueWith?: BaseGesture[];\n config?: Record<string, unknown>;\n}\n\ninterface ComposedGesture {\n __isSerialized: true;\n type: -1;\n gestures: AnyGesture[];\n}\n\ntype AnyGesture = BaseGesture | ComposedGesture;\n\ninterface GestureOptions {\n domSet?: boolean;\n}\n\ninterface RelationMap {\n waitFor: number[];\n simultaneous: number[];\n continueWith: number[];\n}\n\ninterface GestureConfig {\n callbacks: { name: string; callback: GestureWorklet }[];\n config?: Record<string, unknown>;\n}\n\nfunction isSerializedGesture(gesture: unknown): gesture is AnyGesture {\n return (gesture as { __isSerialized?: boolean })?.__isSerialized === true;\n}\n\nfunction getSerializedBaseGesture(\n gesture: AnyGesture | undefined,\n): BaseGesture | undefined {\n if (!gesture || !isSerializedGesture(gesture)) return undefined;\n if (gesture.type !== COMPOSED) return gesture as BaseGesture;\n return undefined;\n}\n\nfunction appendUniqueSerializedBaseGestures(\n gesture: AnyGesture | undefined,\n out: BaseGesture[],\n seenIds: Set<number>,\n): void {\n if (!gesture || !isSerializedGesture(gesture)) return;\n if (gesture.type === COMPOSED) {\n for (const sub of (gesture as ComposedGesture).gestures) {\n appendUniqueSerializedBaseGestures(sub, out, seenIds);\n }\n return;\n }\n const base = gesture as BaseGesture;\n if (seenIds.has(base.id)) return;\n seenIds.add(base.id);\n out.push(base);\n}\n\ninterface OldGestureInfo {\n uniqOldBaseGestures: BaseGesture[];\n oldBaseGesturesById: Map<number, BaseGesture>;\n}\n\nfunction appendOldGestureInfo(\n gesture: AnyGesture | undefined,\n out: BaseGesture[],\n byId: Map<number, BaseGesture>,\n): void {\n if (!gesture || !isSerializedGesture(gesture)) return;\n if (gesture.type === COMPOSED) {\n for (const sub of (gesture as ComposedGesture).gestures) {\n appendOldGestureInfo(sub, out, byId);\n }\n return;\n }\n const base = gesture as BaseGesture;\n if (!byId.has(base.id)) {\n byId.set(base.id, base);\n out.push(base);\n }\n}\n\nfunction collectOldGestureInfo(\n oldGesture: AnyGesture | undefined,\n): OldGestureInfo {\n const uniqOldBaseGestures: BaseGesture[] = [];\n const oldBaseGesturesById = new Map<number, BaseGesture>();\n appendOldGestureInfo(oldGesture, uniqOldBaseGestures, oldBaseGesturesById);\n return { uniqOldBaseGestures, oldBaseGesturesById };\n}\n\nfunction consumeOldBaseGesture(\n baseGesture: BaseGesture,\n uniqOldBaseGestures: BaseGesture[],\n oldBaseGesturesById: Map<number, BaseGesture>,\n): BaseGesture | undefined {\n const idMatched = oldBaseGesturesById.get(baseGesture.id);\n if (idMatched) {\n oldBaseGesturesById.delete(baseGesture.id);\n return idMatched;\n }\n const fallback = uniqOldBaseGestures.find((og) =>\n oldBaseGesturesById.has(og.id),\n );\n if (!fallback) return undefined;\n oldBaseGesturesById.delete(fallback.id);\n return fallback;\n}\n\nfunction removeGestureDetector(dom: MainThreadElement, id: number): void {\n if (typeof __RemoveGestureDetector === 'function') {\n __RemoveGestureDetector(dom, id);\n }\n}\n\nfunction getGestureInfo(\n gesture: BaseGesture,\n oldGesture: BaseGesture | undefined,\n isFirstScreen: boolean,\n dom: MainThreadElement,\n): { config: GestureConfig; relationMap: RelationMap } {\n const config: GestureConfig = { callbacks: [] };\n if (gesture.config) {\n config.config = gesture.config;\n }\n for (const key of Object.keys(gesture.callbacks)) {\n const callback = gesture.callbacks[key]!;\n const oldCallback = oldGesture?.callbacks[key];\n // Upstream types `Worklet._c` as `Record<string, ClosureValueType>`; ours\n // is `Record<string, unknown>` from the wire. The runtime contract is\n // identical — cast through `unknown` to satisfy the upstream signature.\n onWorkletCtxUpdate(\n callback as unknown as Parameters<typeof onWorkletCtxUpdate>[0],\n oldCallback as unknown as Parameters<typeof onWorkletCtxUpdate>[1],\n isFirstScreen,\n dom as unknown as Parameters<typeof onWorkletCtxUpdate>[3],\n );\n config.callbacks.push({ name: key, callback });\n }\n const relationMap: RelationMap = {\n waitFor: gesture.waitFor?.map((g) => g.id) ?? [],\n simultaneous: gesture.simultaneousWith?.map((g) => g.id) ?? [],\n continueWith: gesture.continueWith?.map((g) => g.id) ?? [],\n };\n return { config, relationMap };\n}\n\nexport function processGesture(\n dom: MainThreadElement,\n gesture: AnyGesture | undefined,\n oldGesture: AnyGesture | undefined,\n isFirstScreen: boolean,\n gestureOptions?: GestureOptions,\n): void {\n const domSet = gestureOptions?.domSet === true;\n const { uniqOldBaseGestures, oldBaseGesturesById } =\n collectOldGestureInfo(oldGesture);\n\n const singleBaseGesture = getSerializedBaseGesture(gesture);\n const singleOldBaseGesture = getSerializedBaseGesture(oldGesture);\n\n if (singleBaseGesture && (!oldGesture || singleOldBaseGesture)) {\n if (!domSet) {\n __SetAttribute(dom, 'has-react-gesture', true);\n __SetAttribute(dom, 'flatten', false);\n }\n if (singleOldBaseGesture) {\n removeGestureDetector(dom, singleOldBaseGesture.id);\n }\n const { config, relationMap } = getGestureInfo(\n singleBaseGesture,\n singleOldBaseGesture,\n isFirstScreen,\n dom,\n );\n __SetGestureDetector(\n dom,\n singleBaseGesture.id,\n singleBaseGesture.type,\n config,\n relationMap,\n );\n return;\n }\n\n const uniqBaseGestures: BaseGesture[] = [];\n appendUniqueSerializedBaseGestures(gesture, uniqBaseGestures, new Set());\n if (uniqBaseGestures.length === 0) {\n for (const og of oldBaseGesturesById.values()) {\n removeGestureDetector(dom, og.id);\n }\n if (!domSet) {\n __SetAttribute(dom, 'has-react-gesture', null);\n }\n return;\n }\n\n if (!domSet) {\n __SetAttribute(dom, 'has-react-gesture', true);\n __SetAttribute(dom, 'flatten', false);\n }\n\n for (const og of oldBaseGesturesById.values()) {\n removeGestureDetector(dom, og.id);\n }\n\n for (const base of uniqBaseGestures) {\n const oldBase = consumeOldBaseGesture(\n base,\n uniqOldBaseGestures,\n oldBaseGesturesById,\n );\n const { config, relationMap } = getGestureInfo(\n base,\n oldBase,\n isFirstScreen,\n dom,\n );\n __SetGestureDetector(dom, base.id, base.type, config, relationMap);\n }\n}\n","/**\n * Helpers for invoking worklets from the BG → MT bridge.\n *\n * Most of the worklet machinery (registry, ref map, event dispatch) is owned\n * by `@lynx-js/react/worklet-runtime`, which is side-effect-imported from\n * `entry-main.ts`. That runtime installs `globalThis.lynxWorkletImpl`,\n * `globalThis.registerWorkletInternal`, and `globalThis.runWorklet`. Lynx\n * native dispatches MT-routed events directly into `runWorklet`.\n *\n * What sigx-lynx still needs to provide is the `runOnMainThread` BG → MT call\n * path: BG ships `{ wkltId, args }` over `callLepusMethod('sigxRunOnMT')`, the\n * MT bridge handler in `entry-main.ts` calls `invokeWorklet()` here, and we\n * look up the function in upstream's `_workletMap`.\n */\n\ninterface WorkletImpl {\n _workletMap: Record<string, Function>;\n _refImpl?: {\n _workletRefMap: Record<number, { current: unknown; _wvid: number }>;\n };\n}\n\nexport interface WorkletPlaceholder {\n _wkltId: string;\n _c?: Record<string, unknown>;\n}\n\nfunction getWorkletImpl(): WorkletImpl | undefined {\n return (globalThis as Record<string, unknown>)['lynxWorkletImpl'] as\n | WorkletImpl\n | undefined;\n}\n\n/**\n * Invoke a worklet by id with the given args. Used by the runOnMainThread\n * bridge — event-driven worklets go through Lynx's native runWorklet path\n * and never touch this function.\n */\nexport function invokeWorklet(\n wkltId: string,\n captured: Record<string, unknown> | undefined,\n args: unknown[],\n): unknown {\n const impl = getWorkletImpl();\n if (!impl) {\n console.log('[sigx-mt] lynxWorkletImpl not initialized');\n return undefined;\n }\n const fn = impl._workletMap[wkltId];\n if (!fn) {\n console.log('[sigx-mt] worklet not registered:', wkltId);\n return undefined;\n }\n // Match upstream's calling convention: `function(arg) { let { x } = this[\"_c\"]; ... }`\n try {\n return fn.apply({ _c: captured ?? {} }, args);\n } catch (e) {\n console.log('[sigx-mt] worklet threw:', String(e));\n return undefined;\n }\n}\n\n/** Reset hook — for testing. The upstream worklet-runtime has its own state. */\nexport function resetWorkletEvents(): void {\n // No sigx-side state to clear; upstream's _workletMap survives module reset\n // (registrations re-run when the user module re-evaluates on hot reload).\n}\n","/**\n * MT-side per-slot event registration state machine.\n *\n * Lynx native's `__AddEvent(el, eventType, eventName, value)` only stores ONE\n * value per `(el, eventType, eventName)` slot — the second call wins. When\n * sigx user code declares both a `main-thread-bind*` worklet AND a regular\n * `bind*` BG handler on the same element, two ops arrive in the same patch\n * batch (SET_WORKLET_EVENT + SET_EVENT). Calling `__AddEvent` eagerly per op\n * means the second one silently overwrites the first.\n *\n * This module defers the `__AddEvent` call. Each op updates per-slot state\n * (`worklet?`, `bgSign?`) and marks the slot dirty. After the entire op\n * batch is processed (`flushDirtySlots` is called at the tail of `applyOps`),\n * we issue ONE `__AddEvent` per dirty slot using whichever shape combines\n * the present handlers — string sign, worklet ctx, or hybrid ctx.\n *\n * State persists across batches because re-renders may update only one of\n * the two handlers (the BG event-registry already deduplicates SET_EVENT\n * after the first registration, and `sentWorklets` deduplicates\n * SET_WORKLET_EVENT by `_wkltId`).\n */\n\nimport { elements } from './element-registry.js';\nimport { hybridCtx } from './hybrid-worklet.js';\nimport type { WorkletPlaceholder } from './worklet-events.js';\n\ninterface SlotState {\n worklet?: WorkletPlaceholder;\n bgSign?: string;\n /** Last value passed to __AddEvent, kept for skip-if-unchanged diffing. */\n installed?: unknown;\n}\n\n/** elementId → typeName ('bindEvent:tap' etc.) → slot state */\nconst slotStates = new Map<number, Map<string, SlotState>>();\n/** Set of `${elementId}|${typeName}` keys that need __AddEvent re-issuing. */\nconst dirtySlots = new Set<string>();\n\nfunction getOrCreateSlot(elId: number, type: string, name: string): SlotState {\n let perEl = slotStates.get(elId);\n if (!perEl) {\n perEl = new Map();\n slotStates.set(elId, perEl);\n }\n const typeName = `${type}:${name}`;\n let slot = perEl.get(typeName);\n if (!slot) {\n slot = {};\n perEl.set(typeName, slot);\n }\n return slot;\n}\n\nfunction markDirty(elId: number, type: string, name: string): void {\n dirtySlots.add(`${elId}|${type}:${name}`);\n}\n\nexport function setSlotWorklet(\n elId: number,\n type: string,\n name: string,\n ctx: WorkletPlaceholder | undefined,\n): void {\n const slot = getOrCreateSlot(elId, type, name);\n slot.worklet = ctx;\n markDirty(elId, type, name);\n}\n\nexport function setSlotBgSign(\n elId: number,\n type: string,\n name: string,\n sign: string | undefined,\n): void {\n const slot = getOrCreateSlot(elId, type, name);\n slot.bgSign = sign;\n markDirty(elId, type, name);\n}\n\n/**\n * Pick the right __AddEvent value given which handlers are present.\n * Returns `undefined` to mean \"unregister this slot\".\n */\nfunction computeAddEventValue(slot: SlotState): unknown {\n const { worklet, bgSign } = slot;\n if (!worklet && !bgSign) return undefined;\n if (worklet && !bgSign) {\n return { type: 'worklet', value: worklet };\n }\n if (!worklet && bgSign) {\n return bgSign;\n }\n return { type: 'worklet', value: hybridCtx(worklet!, bgSign!) };\n}\n\n/**\n * Commit __AddEvent for every slot that changed since the last flush.\n * Called from `applyOps` after the op loop, before `__FlushElementTree()`.\n */\nexport function flushDirtySlots(): void {\n for (const key of dirtySlots) {\n const sep = key.indexOf('|');\n const elId = Number(key.slice(0, sep));\n const typeName = key.slice(sep + 1);\n const colon = typeName.indexOf(':');\n const type = typeName.slice(0, colon);\n const name = typeName.slice(colon + 1);\n\n const el = elements.get(elId);\n if (!el) continue;\n\n const slot = slotStates.get(elId)?.get(typeName);\n if (!slot) continue;\n\n const value = computeAddEventValue(slot);\n if (sameRef(value, slot.installed)) continue;\n\n // Lynx PAPI: undefined as the 4th arg unregisters.\n __AddEvent(el, type, name, value as string | undefined);\n slot.installed = value;\n }\n dirtySlots.clear();\n}\n\nfunction sameRef(a: unknown, b: unknown): boolean {\n // Reference equality is enough for our usage:\n // - undefined === undefined\n // - bgSign string deduplicated by event-registry, so identity stable\n // - worklet ctx is a fresh object per SET_WORKLET_EVENT op (never compared\n // to itself across batches because the prev value would always differ),\n // so this is mostly a defensive no-op for the first three branches.\n return a === b;\n}\n\n/** Hot-reload / test reset hook — clears all slot state. */\nexport function resetSlotStates(): void {\n slotStates.clear();\n dirtySlots.clear();\n}\n","/**\n * MT-side mapper registry for `useAnimatedStyle`.\n *\n * Maps a `SharedValue`'s current scalar to a partial style object that the\n * binding flush passes to `setStyleProperties` on the bound element. Keyed by\n * a string name (`'translateX'`, `'scale'`, ...) so the SWC worklet transform\n * can capture the selection trivially: a string is a primitive `_c` value\n * with no special lifting required (unlike arbitrary functions, which can't\n * be captured into a worklet's closure).\n *\n * Custom mappers can be registered via `registerMapper(name, fn)` from MT\n * code (e.g. a `'main thread'`-marked module body in a user app). BG-side\n * `useAnimatedStyle` validates the name only against the type union; a\n * lookup mismatch on MT is a silent no-op at flush time.\n *\n * Param shapes are mapper-specific. The `MapperParams` type in\n * `@sigx/lynx-runtime-internal` is the single source of truth — both\n * BG-side `useAnimatedStyle` and the MT runtime import it from there.\n *\n * Range mapping: `translateX` / `translateY` / `scale` / `opacity` accept\n * either their linear `factor`/`offset` shape or a `RangeParams` shape\n * (`{ inputRange, outputRange, extrapolate? }`). The mapper picks the branch\n * by looking for `inputRange` on the params.\n */\n\nimport type {\n MapperParams,\n RangeParams,\n AnimatedStyleMapper,\n} from '@sigx/lynx-runtime-internal';\n\n// Re-export so that consumers importing from lynx-runtime-main don't have\n// to reach into lynx-runtime-internal directly.\nexport type {\n MapperParams,\n BuiltinMapperName,\n AnimatedStyleMapper,\n RangeParams,\n} from '@sigx/lynx-runtime-internal';\n\nfunction isRangeParams(p: unknown): p is RangeParams {\n return (\n typeof p === 'object' && p !== null\n && 'inputRange' in p\n && 'outputRange' in p\n );\n}\n\n/**\n * Linear interpolation across a multi-stop range. Locates the input segment\n * via simple linear scan (inputRange is small in practice — typically 2-4\n * stops) and lerps within it. Out-of-range behavior controlled by\n * `extrapolate`: `'clamp'` (default) caps at endpoint outputs; `'identity'`\n * extends linearly using the slope of the nearest segment.\n */\nfunction interpolateLinear(\n v: number,\n inputRange: number[],\n outputRange: number[],\n extrapolate: 'clamp' | 'identity' = 'clamp',\n): number {\n const n = inputRange.length;\n if (n < 2) return outputRange[0] ?? v;\n\n if (v <= inputRange[0]!) {\n if (extrapolate === 'clamp') return outputRange[0]!;\n const dx = inputRange[1]! - inputRange[0]!;\n const dy = outputRange[1]! - outputRange[0]!;\n return outputRange[0]! + (v - inputRange[0]!) * (dy / dx);\n }\n if (v >= inputRange[n - 1]!) {\n if (extrapolate === 'clamp') return outputRange[n - 1]!;\n const dx = inputRange[n - 1]! - inputRange[n - 2]!;\n const dy = outputRange[n - 1]! - outputRange[n - 2]!;\n return outputRange[n - 1]! + (v - inputRange[n - 1]!) * (dy / dx);\n }\n for (let i = 1; i < n; i++) {\n if (v <= inputRange[i]!) {\n const t = (v - inputRange[i - 1]!) / (inputRange[i]! - inputRange[i - 1]!);\n return outputRange[i - 1]! + t * (outputRange[i]! - outputRange[i - 1]!);\n }\n }\n return outputRange[n - 1]!;\n}\n\nconst mtMappers: Record<string, AnimatedStyleMapper> = {\n translateX: (v, p) => {\n if (isRangeParams(p)) {\n const out = interpolateLinear(v as number, p.inputRange, p.outputRange, p.extrapolate);\n return { transform: `translateX(${out}px)` };\n }\n const factor = (p as { factor?: number } | undefined)?.factor ?? 1;\n return { transform: `translateX(${(v as number) * factor}px)` };\n },\n translateY: (v, p) => {\n if (isRangeParams(p)) {\n const out = interpolateLinear(v as number, p.inputRange, p.outputRange, p.extrapolate);\n return { transform: `translateY(${out}px)` };\n }\n const factor = (p as { factor?: number } | undefined)?.factor ?? 1;\n return { transform: `translateY(${(v as number) * factor}px)` };\n },\n translate: (v, p) => {\n const params = (p as MapperParams['translate'] | undefined) ?? {};\n const fx = params.factorX ?? 1;\n const fy = params.factorY ?? 1;\n const xy = v as { x: number; y: number };\n return { transform: `translate(${xy.x * fx}px, ${xy.y * fy}px)` };\n },\n scale: (v, p) => {\n if (isRangeParams(p)) {\n const out = interpolateLinear(v as number, p.inputRange, p.outputRange, p.extrapolate);\n return { transform: `scale(${out})` };\n }\n const offset = (p as { offset?: number } | undefined)?.offset ?? 0;\n return { transform: `scale(${(v as number) + offset})` };\n },\n opacity: (v, p) => {\n if (isRangeParams(p)) {\n const raw = interpolateLinear(v as number, p.inputRange, p.outputRange, p.extrapolate);\n const out = Math.max(0, Math.min(1, raw));\n return { opacity: String(out) };\n }\n const params = (p as { factor?: number; offset?: number } | undefined) ?? {};\n const factor = params.factor ?? 1;\n const offset = params.offset ?? 0;\n const out = Math.max(0, Math.min(1, (v as number) * factor + offset));\n return { opacity: String(out) };\n },\n rotate: (v) => ({ transform: `rotate(${v as number}deg)` }),\n paddingTop: (v, p) => ({ paddingTop: `${linearOrRange(v, p)}px` }),\n paddingRight: (v, p) => ({ paddingRight: `${linearOrRange(v, p)}px` }),\n paddingBottom: (v, p) => ({ paddingBottom: `${linearOrRange(v, p)}px` }),\n paddingLeft: (v, p) => ({ paddingLeft: `${linearOrRange(v, p)}px` }),\n marginTop: (v, p) => ({ marginTop: `${linearOrRange(v, p)}px` }),\n marginRight: (v, p) => ({ marginRight: `${linearOrRange(v, p)}px` }),\n marginBottom: (v, p) => ({ marginBottom: `${linearOrRange(v, p)}px` }),\n marginLeft: (v, p) => ({ marginLeft: `${linearOrRange(v, p)}px` }),\n};\n\nfunction linearOrRange(v: unknown, p: unknown): number {\n if (isRangeParams(p)) {\n return interpolateLinear(v as number, p.inputRange, p.outputRange, p.extrapolate);\n }\n const factor = (p as { factor?: number } | undefined)?.factor ?? 1;\n return (v as number) * factor;\n}\n\n/**\n * Look up a registered mapper by name. Returns `undefined` if the name\n * isn't registered — the binding flush treats that as a no-op.\n */\nexport function lookupMapper(name: string): AnimatedStyleMapper | undefined {\n return mtMappers[name];\n}\n\n/**\n * Register a custom MT-side mapper. Idempotent on (name, fn) — last\n * registration wins for the same name. Intended for `'main thread'`-marked\n * user modules that ship project-specific styling math.\n */\nexport function registerMapper(name: string, mapper: AnimatedStyleMapper): void {\n mtMappers[name] = mapper;\n}\n\n/**\n * Reset hook — drops every custom mapper, reseats the built-ins. Used by\n * the MT-side resetMainThreadState path (HMR / tests).\n */\nconst BUILTIN_NAMES = new Set([\n 'translateX', 'translateY', 'translate', 'scale', 'opacity', 'rotate',\n 'paddingTop', 'paddingRight', 'paddingBottom', 'paddingLeft',\n 'marginTop', 'marginRight', 'marginBottom', 'marginLeft',\n]);\n\nexport function resetMappers(): void {\n for (const k in mtMappers) {\n if (!BUILTIN_NAMES.has(k)) {\n delete mtMappers[k];\n }\n }\n}\n","/**\n * MT-side SharedValue bridge — publishes MT-thread mutations to BG.\n *\n * Diffs every registered SharedValue against its last-published snapshot\n * and dispatches one batched `Lynx.Sigx.AvPublish` event per flush boundary\n * with the changed `[wvid, value]` tuples. The BG side ingests these via\n * `@sigx/lynx-runtime/src/animated-bridge.ts` and writes them into the\n * mirror signal so any sigx `effect` reading `sv.value` re-runs.\n *\n * Bridge state (`bridgedAvWvids` / `bridgedAvLastValues`) lives in\n * `ops-apply.ts` because the BG→MT op handlers mutate it; this module\n * imports the references and reads them on every flush.\n *\n * Two flush hook points:\n * 1. `ops-apply.ts` calls `flushAvBridgePublishes()` at its tail (covers\n * every BG-driven ops batch).\n * 2. `installAvBridgeFlushHook()` wraps `globalThis.__FlushElementTree`\n * so spontaneous MT writes (e.g. a touchmove worklet that eventually\n * calls `setStyleProperties`) also trigger a publish on the same\n * tick the native tree flushes. Called once from `entry-main.ts`\n * after PAPI globals are present.\n *\n * Coalescing: `===` per-wvid diff. Identical writes are filtered. N writes\n * within one flush window collapse to one BG event with N entries.\n */\n\nimport { bridgedAvWvids, bridgedAvLastValues } from './ops-apply.js';\nimport { lookupMapper } from './animated-style-mappers.js';\n\nconst AV_PUBLISH = 'Lynx.Sigx.AvPublish';\n\ninterface AvRef {\n current: { value?: unknown };\n _wvid: number;\n}\n\ninterface WorkletImpl {\n _refImpl?: {\n _workletRefMap: Record<number, AvRef>;\n };\n}\n\ninterface JSContextLike {\n dispatchEvent?: (e: { type: string; data: string }) => void;\n}\n\ninterface LynxLike {\n getJSContext?: () => JSContextLike;\n}\n\n/**\n * Diff registered AVs against their last-published snapshots; dispatch one\n * batched `Lynx.Sigx.AvPublish` event with all changed tuples. No-op when\n * the bridge set is empty or when nothing has changed since the last call.\n */\nexport function flushAvBridgePublishes(): void {\n if (bridgedAvWvids.size === 0) return;\n\n const impl = (globalThis as { lynxWorkletImpl?: WorkletImpl }).lynxWorkletImpl;\n const refMap = impl?._refImpl?._workletRefMap;\n if (!refMap) return;\n\n let updates: Array<[number, unknown]> | undefined;\n for (const wvid of bridgedAvWvids) {\n const ref = refMap[wvid];\n if (!ref) continue;\n const v = ref.current?.value;\n if (v !== bridgedAvLastValues.get(wvid)) {\n (updates ??= []).push([wvid, v]);\n bridgedAvLastValues.set(wvid, v);\n }\n }\n\n if (!updates) return;\n\n const lynxObj = (globalThis as { lynx?: LynxLike }).lynx;\n const ctx = lynxObj?.getJSContext?.();\n if (!ctx?.dispatchEvent) return;\n\n let data: string;\n try {\n data = JSON.stringify(updates);\n } catch (e) {\n console.log('[sigx-mt] av-bridge: JSON.stringify failed:', String(e));\n return;\n }\n\n ctx.dispatchEvent({ type: AV_PUBLISH, data });\n}\n\n// ---------------------------------------------------------------------------\n// useAnimatedStyle bindings\n//\n// Each registered binding maps a SharedValue -> a partial style object\n// applied to a bound element on every flush where the SharedValue's value\n// changed. The MT side never sees the user's mapper code directly — the BG\n// ops carry only the mapper's *name*, which the MT runtime resolves via\n// lookupMapper().\n// ---------------------------------------------------------------------------\n\ninterface AnimatedStyleBinding {\n elementWvid: number;\n avWvid: number;\n mapperName: string;\n params: unknown;\n lastValue: unknown;\n}\n\nconst animatedStyleBindings = new Map<number, AnimatedStyleBinding>();\n\n/**\n * Register a binding (called from the OP.REGISTER_AV_STYLE_BINDING op\n * handler in `ops-apply.ts`). Initializes `lastValue` to a sentinel so the\n * first flush always applies the mapper, even when the AV is at its initial.\n */\nexport function registerAnimatedStyleBinding(\n bindingId: number,\n elementWvid: number,\n avWvid: number,\n mapperName: string,\n params: unknown,\n): void {\n // Sentinel — guaranteed not to equal any user value, so the first flush\n // applies the mapper regardless of whether the AV ever gets written.\n const sentinel = {} as unknown;\n animatedStyleBindings.set(bindingId, {\n elementWvid,\n avWvid,\n mapperName,\n params,\n lastValue: sentinel,\n });\n}\n\nexport function unregisterAnimatedStyleBinding(bindingId: number): void {\n animatedStyleBindings.delete(bindingId);\n}\n\nexport function resetAnimatedStyleBindings(): void {\n animatedStyleBindings.clear();\n}\n\nexport function animatedStyleBindingCount(): number {\n return animatedStyleBindings.size;\n}\n\ninterface ElementWithStyleApply {\n setStyleProperties?: (styles: Record<string, string | number>) => void;\n}\n\n/**\n * For each element with at least one *dirty* binding (AV value changed since\n * the last apply), re-run **all** of that element's bindings, merge their\n * mapper outputs, and apply the result with a single `setStyleProperties`\n * call. Called from the wrapped `__FlushElementTree` *before* the native\n * tree flush.\n *\n * Why \"all bindings on a dirty element\" rather than \"only changed bindings\":\n * - Multiple bindings on the same element can write the same style key\n * (e.g. `translateX` + `translateY` both produce `transform`). If we\n * applied only the changed ones, the unchanged-binding's contribution\n * would be lost and the element would visibly snap. By re-running every\n * binding on the dirty element and merging, all contributions land in\n * the same `setStyleProperties` call.\n *\n * Merge semantics:\n * - `transform` values from multiple bindings *concatenate* in registration\n * order (e.g. `translateX(50px)` + `translateY(20px)` ->\n * `translateX(50px) translateY(20px)`).\n * - All other keys merge by last-write-wins; a binding registered later on\n * the same element overwrites an earlier binding's same-key output.\n *\n * Skip cases (silent, by design):\n * - AV ref missing in `_workletRefMap` (race with unregister).\n * - Element ref's `current` is null (component not yet mounted, or\n * unmounted before the binding's UNREGISTER op landed).\n * - Mapper name not registered (typo or missing custom registration).\n */\nexport function flushAnimatedStyleBindings(): void {\n if (animatedStyleBindings.size === 0) return;\n\n const impl = (globalThis as { lynxWorkletImpl?: WorkletImpl }).lynxWorkletImpl;\n const refMap = impl?._refImpl?._workletRefMap;\n if (!refMap) return;\n\n // Phase 1 — find which elements have at least one dirty binding. Update\n // each binding's lastValue so the next flush only re-applies on further\n // change. Skip bindings whose AV ref is missing.\n let dirtyElements: Set<number> | undefined;\n for (const binding of animatedStyleBindings.values()) {\n const avRef = refMap[binding.avWvid];\n if (!avRef) continue;\n const v = avRef.current?.value;\n if (v === binding.lastValue) continue;\n binding.lastValue = v;\n (dirtyElements ??= new Set()).add(binding.elementWvid);\n }\n if (!dirtyElements) return;\n\n // Phase 2 — for each dirty element, run *all* its bindings and merge the\n // outputs into one style object. Iteration order over the Map is insertion\n // order, which equals registration order — so transform concatenations\n // come out in the order the user registered them.\n const merged = new Map<number, Record<string, string | number>>();\n for (const binding of animatedStyleBindings.values()) {\n if (!dirtyElements.has(binding.elementWvid)) continue;\n\n const avRef = refMap[binding.avWvid];\n if (!avRef) continue;\n const v = avRef.current?.value;\n\n const mapper = lookupMapper(binding.mapperName);\n if (!mapper) continue;\n\n let out: Record<string, string | number>;\n try {\n out = mapper(v, binding.params);\n } catch (e) {\n console.log('[sigx-mt] av-style mapper threw:', binding.mapperName, String(e));\n continue;\n }\n\n let acc = merged.get(binding.elementWvid);\n if (!acc) {\n acc = {};\n merged.set(binding.elementWvid, acc);\n }\n for (const k in out) {\n if (k === 'transform' && typeof acc.transform === 'string') {\n acc.transform = `${acc.transform} ${String(out.transform)}`;\n } else {\n acc[k] = out[k]!;\n }\n }\n }\n\n // Phase 3 — one setStyleProperties per dirty element.\n for (const [elementWvid, styleObj] of merged) {\n const elRef = refMap[elementWvid];\n const el = elRef?.current as unknown as ElementWithStyleApply | null | undefined;\n if (!el?.setStyleProperties) continue;\n try {\n el.setStyleProperties(styleObj);\n } catch (e) {\n console.log('[sigx-mt] av-style setStyleProperties threw:', String(e));\n }\n }\n}\n\nconst INSTALLED = Symbol.for('sigx.avBridgeFlushHookInstalled');\n\n/**\n * Wrap `globalThis.__FlushElementTree` once so every flush also runs the AV\n * bridge publish step. Idempotent — safe to call across hot reloads. Test\n * setups that `vi.stubGlobal('__FlushElementTree', ...)` AFTER this hook\n * installs will replace our wrapper, which is the correct behavior for\n * unit tests that drive `flushAvBridgePublishes` directly.\n */\nexport function installAvBridgeFlushHook(): void {\n const g = globalThis as Record<string | symbol, unknown>;\n if (g[INSTALLED]) return;\n const original = g['__FlushElementTree'];\n if (typeof original !== 'function') return;\n g[INSTALLED] = true;\n g['__FlushElementTree'] = function wrappedFlushElementTree(\n this: unknown,\n ...args: unknown[]\n ): unknown {\n try {\n flushAvBridgePublishes();\n } catch (e) {\n console.log('[sigx-mt] av-bridge flush threw:', String(e));\n }\n try {\n flushAnimatedStyleBindings();\n } catch (e) {\n console.log('[sigx-mt] av-style bindings flush threw:', String(e));\n }\n return (original as (...a: unknown[]) => unknown).apply(this, args);\n };\n}\n","/**\n * Main Thread ops executor.\n *\n * Receives the flat-array ops buffer sent by the Background Thread via\n * callLepusMethod('sigxPatchUpdate', { data: JSON.stringify(ops) }) and applies\n * each operation using Lynx PAPI.\n */\n\nimport { OP } from '@sigx/lynx-runtime-internal';\n\nimport { processGesture } from './upstream/processGesture.js';\nimport {\n elements,\n pageUniqueId,\n setPageUniqueId,\n} from './element-registry.js';\nimport { resetWorkletEvents, type WorkletPlaceholder } from './worklet-events.js';\nimport {\n setSlotBgSign,\n setSlotWorklet,\n flushDirtySlots,\n resetSlotStates,\n} from './event-slots.js';\nimport {\n flushAvBridgePublishes,\n flushAnimatedStyleBindings,\n registerAnimatedStyleBinding,\n unregisterAnimatedStyleBinding,\n resetAnimatedStyleBindings,\n} from './animated-bridge-mt.js';\n\n/**\n * Placeholder element inserted by renderPage() to give the host a non-empty\n * tree immediately, suppressing the \"loadCard failed USER_RUNTIME_ERROR\"\n * timeout. Removed on the first applyOps() call.\n */\nlet placeholderParent: MainThreadElement | null = null;\nlet placeholderEl: MainThreadElement | null = null;\n\n/**\n * SharedValue bridge state — registered wvids and last-published snapshots.\n * The op handlers (`OP.REGISTER_AV_BRIDGE` / `OP.UNREGISTER_AV_BRIDGE` below)\n * mutate these collections; `animated-bridge-mt.ts:flushAvBridgePublishes`\n * reads them on every flush boundary to compute the diff to publish to BG.\n */\nexport const bridgedAvWvids = new Set<number>();\nexport const bridgedAvLastValues = new Map<number, unknown>();\n\n/**\n * Gesture-detector tracking — per-element wvid → set of attached gesture ids.\n * Used to drive the `has-react-gesture` setup attribute lifecycle: set on the\n * first SET_GESTURE_DETECTOR for an element, cleared when the last gesture is\n * removed via REMOVE_GESTURE_DETECTOR.\n */\nconst gesturesByElementWvid = new Map<number, Set<number>>();\n\n/**\n * Last-set BaseGesture tree per element wvid. Vendored upstream\n * `processGesture` takes an `oldGesture` arg to diff against — pass the prior\n * tree so callback updates wire correctly through `onWorkletCtxUpdate`.\n */\nconst lastTreeByElementWvid = new Map<number, unknown>();\n\n/**\n * elementWvid → elementId mapping populated by SET_MT_REF when a\n * `main-thread:ref` binds to an element. Gesture ops carry the elRef's wvid\n * (set at BG-side useGestureDetector time, before the renderer assigns an\n * element id), so resolution is wvid → elementId → raw MainThreadElement.\n *\n * We deliberately do NOT use `lynxWorkletImpl._refImpl._workletRefMap[wvid].current`:\n * that map stores the upstream-wrapped `Element` class (with `setStyleProperties`\n * etc.) which is what worklets need, but the platform's `__SetAttribute` /\n * `__SetGestureDetector` PAPI expect the raw RefCounted element handle.\n * Passing the wrapper trips the `FiberSetAttribute param 0 should be RefCounted`\n * native error.\n */\nconst elementIdByWvid = new Map<number, number>();\n\nfunction resolveElementByWvid(wvid: number): MainThreadElement | undefined {\n const elementId = elementIdByWvid.get(wvid);\n if (elementId === undefined) return undefined;\n return elements.get(elementId);\n}\n\nexport function setPlaceholder(parent: MainThreadElement, el: MainThreadElement): void {\n placeholderParent = parent;\n placeholderEl = el;\n}\n\nfunction removePlaceholderOnce(): void {\n if (placeholderEl != null && placeholderParent != null) {\n __RemoveElement(placeholderParent, placeholderEl);\n placeholderParent = null;\n placeholderEl = null;\n }\n}\n\n/**\n * Use typed PAPI creators for known element types.\n * Native Lynx may set up type-specific internals (e.g. overflow clipping\n * for View, hardware-accelerated decoding for Image) via the typed functions\n * that the generic __CreateElement does not.\n */\nfunction createTypedElement(\n type: string,\n parentComponentUniqueId: number,\n): MainThreadElement {\n switch (type) {\n case 'view':\n return __CreateView(parentComponentUniqueId);\n case 'text':\n return __CreateText(parentComponentUniqueId);\n case 'image':\n return __CreateImage(parentComponentUniqueId);\n case 'scroll-view':\n return __CreateScrollView(parentComponentUniqueId);\n case 'page':\n // The page root is special — it's created once by __CreatePage() in\n // renderPage() and aliased to ShadowElement id=1 in BG. Lynx hosts\n // (e.g. Lynx Go) have no behavior class for a second `page` element\n // and will throw \"No BehaviorController defined for class page\".\n // If user code wraps content in <page>...</page>, treat it as a\n // transparent <view> on the Main Thread so the tree stays valid.\n return __CreateView(parentComponentUniqueId);\n default:\n return __CreateElement(type, parentComponentUniqueId);\n }\n}\n\nexport function applyOps(ops: unknown[]): void {\n const len = ops.length;\n if (len === 0) return;\n\n // On the first real ops batch, remove the placeholder element that\n // renderPage() inserted to suppress the host's USER_RUNTIME_ERROR timeout.\n removePlaceholderOnce();\n\n // Detect duplicate batch from double BG bundle evaluation.\n // Each __init_card_bundle__ invocation gets a fresh webpack module cache, so\n // ShadowElement.nextId resets to 2, producing the same element IDs.\n // If the first CREATE op targets an ID that already exists in our elements Map,\n // this is a duplicate batch — skip it entirely.\n if (len >= 3 && ops[0] === OP.CREATE) {\n const firstId = ops[1] as number;\n if (elements.has(firstId)) {\n return;\n }\n }\n\n let i = 0;\n\n while (i < len) {\n const code = ops[i++] as number;\n\n switch (code) {\n case OP.CREATE: {\n const id = ops[i++] as number;\n const type = ops[i++] as string;\n let el: MainThreadElement;\n if (type === '__comment') {\n el = __CreateRawText('');\n } else {\n el = createTypedElement(type, pageUniqueId);\n __SetCSSId([el], 0);\n }\n elements.set(id, el);\n if (type !== '__comment') {\n __SetAttribute(el, `sigx-ref-${id}`, 1);\n }\n break;\n }\n\n case OP.CREATE_TEXT: {\n const id = ops[i++] as number;\n const el = __CreateText(pageUniqueId);\n __SetCSSId([el], 0);\n elements.set(id, el);\n __SetAttribute(el, `sigx-ref-${id}`, 1);\n break;\n }\n\n case OP.INSERT: {\n const parentId = ops[i++] as number;\n const childId = ops[i++] as number;\n const anchorId = ops[i++] as number;\n const parent = elements.get(parentId);\n const child = elements.get(childId);\n if (parent && child) {\n if (anchorId === -1) {\n __AppendElement(parent, child);\n } else {\n const anchor = elements.get(anchorId);\n if (anchor) __InsertElementBefore(parent, child, anchor);\n }\n }\n break;\n }\n\n case OP.REMOVE: {\n const _parentId = ops[i++] as number;\n const childId = ops[i++] as number;\n const parent = elements.get(_parentId);\n const child = elements.get(childId);\n if (parent && child) {\n __RemoveElement(parent, child);\n }\n break;\n }\n\n case OP.SET_PROP: {\n const id = ops[i++] as number;\n const key = ops[i++] as string;\n const value = ops[i++];\n const el = elements.get(id);\n if (el) __SetAttribute(el, key, value);\n break;\n }\n\n case OP.SET_TEXT: {\n const id = ops[i++] as number;\n const text = ops[i++] as string;\n const el = elements.get(id);\n if (el) __SetAttribute(el, 'text', text);\n break;\n }\n\n case OP.SET_EVENT: {\n const id = ops[i++] as number;\n const eventType = ops[i++] as string;\n const eventName = ops[i++] as string;\n const sign = ops[i++] as string;\n // Defer __AddEvent to flushDirtySlots (end of batch). When a worklet\n // is also registered for the same slot, the slot machine combines\n // them into a single hybrid registration.\n setSlotBgSign(id, eventType, eventName, sign);\n break;\n }\n\n case OP.REMOVE_EVENT: {\n const id = ops[i++] as number;\n const eventType = ops[i++] as string;\n const eventName = ops[i++] as string;\n // Clear the BG side of this slot. The MT worklet (if any) survives.\n // No worklet-removal op exists yet (see plan Open items).\n setSlotBgSign(id, eventType, eventName, undefined);\n break;\n }\n\n case OP.SET_STYLE: {\n const id = ops[i++] as number;\n const value = ops[i++] as string | object;\n const el = elements.get(id);\n if (el) __SetInlineStyles(el, value);\n break;\n }\n\n case OP.SET_CLASS: {\n const id = ops[i++] as number;\n const cls = ops[i++] as string;\n const el = elements.get(id);\n if (el) __SetClasses(el, cls);\n break;\n }\n\n case OP.SET_ID: {\n const id = ops[i++] as number;\n const idStr = ops[i++] as string | null | undefined;\n const el = elements.get(id);\n if (el) __SetID(el, idStr ?? undefined);\n break;\n }\n\n case OP.SET_WORKLET_EVENT: {\n const id = ops[i++] as number;\n const eventType = ops[i++] as string;\n const eventName = ops[i++] as string;\n const ctx = ops[i++] as WorkletPlaceholder;\n if (ctx && ctx._wkltId) {\n (ctx as unknown as Record<string, unknown>)['_workletType'] = 'main-thread';\n // Defer __AddEvent — flushDirtySlots will pick the right shape:\n // worklet-only ({type:'worklet', value: ctx}) when no BG handler\n // shares this slot, or hybrid ctx when one does.\n setSlotWorklet(id, eventType, eventName, ctx);\n }\n break;\n }\n\n case OP.SET_MT_REF: {\n const id = ops[i++] as number;\n const wvid = ops[i++] as number;\n const el = elements.get(id);\n if (el) {\n // Delegate to upstream's worklet-runtime. updateWorkletRef wraps the\n // element in its own Element class and stores it under _wvid.\n const impl = (globalThis as Record<string, unknown>)['lynxWorkletImpl'] as\n { _refImpl: { _workletRefMap: Record<number, { current: unknown; _wvid: number }>; updateWorkletRef: (refImpl: unknown, el: unknown) => void } } | undefined;\n if (impl?._refImpl) {\n const refMap = impl._refImpl._workletRefMap;\n if (!(wvid in refMap)) {\n refMap[wvid] = { current: null, _wvid: wvid };\n }\n impl._refImpl.updateWorkletRef({ _wvid: wvid }, el);\n }\n // Record wvid → raw elementId so SET_GESTURE_DETECTOR can resolve\n // the unwrapped MainThreadElement for `__SetAttribute` /\n // `__SetGestureDetector` (which require RefCounted handles, not\n // upstream's Element wrapper).\n elementIdByWvid.set(wvid, id);\n }\n break;\n }\n\n case OP.INIT_MT_REF: {\n const wvid = ops[i++] as number;\n const initValue = ops[i++];\n const impl = (globalThis as Record<string, unknown>)['lynxWorkletImpl'] as\n { _refImpl: { _workletRefMap: Record<number, { current: unknown; _wvid: number }> } } | undefined;\n if (impl?._refImpl) {\n const refMap = impl._refImpl._workletRefMap;\n if (!(wvid in refMap)) {\n refMap[wvid] = { current: initValue, _wvid: wvid };\n }\n }\n break;\n }\n\n case OP.RELEASE_MT_REF: {\n // Owning component unmounted on BG; drop the MT-side holder so the\n // worklet ref map doesn't grow unbounded across navigation. Mirrors\n // upstream's WorkletEvents.releaseWorkletRef path (we don't dispatch\n // upstream's event because we manage the map ourselves via ops).\n const wvid = ops[i++] as number;\n const impl = (globalThis as Record<string, unknown>)['lynxWorkletImpl'] as\n { _refImpl: { _workletRefMap: Record<number, unknown> } } | undefined;\n if (impl?._refImpl) {\n delete impl._refImpl._workletRefMap[wvid];\n }\n elementIdByWvid.delete(wvid);\n break;\n }\n\n case OP.REGISTER_AV_BRIDGE: {\n const wvid = ops[i++] as number;\n const initValue = ops[i++];\n bridgedAvWvids.add(wvid);\n bridgedAvLastValues.set(wvid, initValue);\n break;\n }\n\n case OP.UNREGISTER_AV_BRIDGE: {\n const wvid = ops[i++] as number;\n bridgedAvWvids.delete(wvid);\n bridgedAvLastValues.delete(wvid);\n break;\n }\n\n case OP.REGISTER_AV_STYLE_BINDING: {\n const bindingId = ops[i++] as number;\n const elementWvid = ops[i++] as number;\n const avWvid = ops[i++] as number;\n const mapperName = ops[i++] as string;\n const params = ops[i++];\n registerAnimatedStyleBinding(bindingId, elementWvid, avWvid, mapperName, params);\n break;\n }\n\n case OP.UNREGISTER_AV_STYLE_BINDING: {\n const bindingId = ops[i++] as number;\n unregisterAnimatedStyleBinding(bindingId);\n break;\n }\n\n case OP.SET_GESTURE_DETECTOR: {\n // Wire format: [op, wvid, gestureId, type, config, relationMap].\n // We reconstruct upstream's BaseGesture shape and delegate to vendored\n // `processGesture` so the platform-call sequence is byte-for-byte\n // identical to `@lynx-js/react`'s snapshot pipeline. Per-base wire\n // means we register one base per op; processGesture handles the\n // single-base fast path. Composed gestures arrive as multiple ops,\n // each carrying its relationMap.\n const elementWvid = ops[i++] as number;\n const gestureId = ops[i++] as number;\n const type = ops[i++] as number;\n const config = ops[i++] as {\n callbacks: { name: string; callback: Record<string, unknown> }[];\n config?: Record<string, unknown>;\n };\n const relationMap = ops[i++] as {\n waitFor: number[];\n simultaneous: number[];\n continueWith: number[];\n };\n const el = resolveElementByWvid(elementWvid);\n if (!el) break;\n\n // Reconstruct callbacks Record from the wire's array shape.\n const callbacksRecord: Record<string, Record<string, unknown>> = {};\n for (const cb of config.callbacks) {\n callbacksRecord[cb.name] = cb.callback;\n }\n\n // Build a fake BaseGesture: relation arrays are id-stubs `[{id}]`\n // because vendored `getGestureInfo` reads `.id` off each entry to\n // produce the relationMap. The platform never sees these objects.\n const stub = (ids: number[]) => ids.map((id) => ({ id }));\n const fakeBaseGesture = {\n __isSerialized: true as const,\n type,\n id: gestureId,\n callbacks: callbacksRecord,\n waitFor: stub(relationMap.waitFor),\n simultaneousWith: stub(relationMap.simultaneous),\n continueWith: stub(relationMap.continueWith),\n ...(config.config ? { config: config.config } : {}),\n };\n\n // Phase 2.12.1 bug fix: pass `undefined` as oldGesture, NOT the last\n // tree we saw on this element.\n //\n // Our wire format is one SET_GESTURE_DETECTOR op per BaseGesture.\n // When `<Pressable>` registers `Simultaneous(Tap, LongPress)`, two\n // ops arrive in sequence on the same element. If we pass the previous\n // tree to `processGesture`, its diff path treats the second op as\n // \"Tap → LongPress\" and emits a `__RemoveGestureDetector` for Tap\n // before installing LongPress. Result: only the last gesture stays\n // registered; all earlier gestures are silently uninstalled.\n //\n // The right model for our wire is additive: each op installs ONE\n // gesture without disturbing siblings. Removal is explicit via the\n // REMOVE_GESTURE_DETECTOR op (emitted from `useGestureDetector`'s\n // unmount cleanup), which calls `__RemoveGestureDetector` directly.\n // Note: this means we don't get diff-based callback updates if the\n // BG side re-emits a gesture with the same id — but our wire never\n // does that today; on prop changes BG emits REMOVE then SET.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n processGesture(el, fakeBaseGesture as any, undefined, false);\n lastTreeByElementWvid.set(elementWvid, fakeBaseGesture);\n\n // Track for REMOVE op cleanup and to drive `has-react-gesture` toggle\n // when the last gesture goes (vendored function clears it on remove).\n let attached = gesturesByElementWvid.get(elementWvid);\n if (!attached) {\n attached = new Set();\n gesturesByElementWvid.set(elementWvid, attached);\n }\n attached.add(gestureId);\n break;\n }\n\n case OP.REMOVE_GESTURE_DETECTOR: {\n const elementWvid = ops[i++] as number;\n const gestureId = ops[i++] as number;\n const el = resolveElementByWvid(elementWvid);\n if (el && typeof __RemoveGestureDetector === 'function') {\n __RemoveGestureDetector(el, gestureId);\n const attached = gesturesByElementWvid.get(elementWvid);\n if (attached) {\n attached.delete(gestureId);\n if (attached.size === 0) {\n gesturesByElementWvid.delete(elementWvid);\n lastTreeByElementWvid.delete(elementWvid);\n __SetAttribute(el, 'has-react-gesture', null);\n }\n }\n }\n break;\n }\n\n default:\n // Unknown op – skip (future-compat)\n break;\n }\n }\n\n // Commit deferred __AddEvent registrations now that the entire batch is\n // processed — this is what lets worklet + BG handler on the same slot\n // coexist via the hybrid worklet ctx, without one overwriting the other.\n flushDirtySlots();\n\n // Diff registered SharedValues against their last-published snapshots\n // and dispatch a batched Lynx.Sigx.AvPublish event with anything that\n // changed during this op batch. See animated-bridge-mt.ts for details.\n flushAvBridgePublishes();\n\n // Apply any useAnimatedStyle bindings whose source SharedValue changed\n // during this batch. Runs after flushAvBridgePublishes so the BG mirror\n // stays consistent with the styles we're about to commit.\n flushAnimatedStyleBindings();\n\n // Flush all pending PAPI changes to the native layer in one shot.\n __FlushElementTree();\n}\n\n/** Reset module state — for testing and hot reload. */\nexport function resetMainThreadState(): void {\n elements.clear();\n setPageUniqueId(1);\n placeholderParent = null;\n placeholderEl = null;\n // Also defined in this module's imports — reset worklet state\n resetWorkletEvents();\n resetSlotStates();\n bridgedAvWvids.clear();\n bridgedAvLastValues.clear();\n gesturesByElementWvid.clear();\n lastTreeByElementWvid.clear();\n elementIdByWvid.clear();\n resetAnimatedStyleBindings();\n // Clear upstream's worklet ref map too on hard reset (HMR / test).\n const impl = (globalThis as Record<string, unknown>)['lynxWorkletImpl'] as\n { _refImpl: { _workletRefMap: Record<number, unknown> } } | undefined;\n if (impl?._refImpl) impl._refImpl._workletRefMap = {};\n}\n","/**\n * MT-side runOnBackground — dispatches function calls from the Main Thread\n * to the Background Thread via 'Lynx.Sigx.RunOnBackground' events.\n *\n * Called inside extracted worklet bodies on the Main Thread. The SWC LEPUS\n * pass leaves bare `runOnBackground(_jsFnK)` references in the registered\n * worklet body; we install this implementation as `globalThis.runOnBackground`\n * from `entry-main.ts` so the bare identifier resolves at runtime.\n *\n * Mirrors @lynx-js/react/runtime/lib/worklet/call/runOnMainThread (the dual\n * direction) and vue-lynx's run-on-background-mt.ts. Sigx-namespaced event\n * types so we don't conflict with upstream's own bridge if it ships in the\n * same lynx process.\n */\n\nconst RUN_ON_BACKGROUND = 'Lynx.Sigx.RunOnBackground';\nconst FUNCTION_CALL_RET = 'Lynx.Sigx.FunctionCallRet';\n\n// ---------------------------------------------------------------------------\n// JsFnHandle shape — matches BG-side @sigx/lynx-runtime/run-on-background.ts\n// ---------------------------------------------------------------------------\n\ninterface JsFnHandle {\n _jsFnId?: number;\n _execId?: number;\n _isFirstScreen?: boolean;\n _error?: string;\n}\n\n// ---------------------------------------------------------------------------\n// Return-value resolver — correlates resolveId → Promise resolve callback\n// ---------------------------------------------------------------------------\n\nlet resolveMap: Map<number, (v: unknown) => void> | undefined;\nlet nextResolveId = 1;\n\ninterface JSContextLike {\n addEventListener?: (type: string, listener: (e: { data?: unknown }) => void) => void;\n dispatchEvent?: (e: { type: string; data: string }) => void;\n}\ninterface LynxLike {\n getJSContext?: () => JSContextLike;\n}\n\nfunction getJSContext(): JSContextLike | undefined {\n // On MT, `lynx` is a globalThis property (no closure injection like BG).\n const lynxObj = (globalThis as { lynx?: LynxLike }).lynx;\n return lynxObj?.getJSContext?.();\n}\n\nfunction initReturnListener(): void {\n resolveMap = new Map();\n getJSContext()?.addEventListener?.(FUNCTION_CALL_RET, (event) => {\n let payload: { resolveId: number; returnValue: unknown };\n try {\n payload = JSON.parse(event.data as string);\n } catch {\n return;\n }\n const resolve = resolveMap?.get(payload.resolveId);\n if (resolve) {\n resolveMap!.delete(payload.resolveId);\n resolve(payload.returnValue);\n }\n });\n}\n\n// ---------------------------------------------------------------------------\n// dispatch — ship the call across to BG\n// ---------------------------------------------------------------------------\n\nfunction dispatch(fnId: number, params: unknown[], execId: number, resolveId: number): void {\n getJSContext()?.dispatchEvent?.({\n type: RUN_ON_BACKGROUND,\n data: JSON.stringify({\n obj: { _jsFnId: fnId, _execId: execId },\n params,\n resolveId,\n }),\n });\n}\n\n// ---------------------------------------------------------------------------\n// First-screen delay hook — lynxWorkletImpl provides this when the MT runtime\n// hasn't finished bootstrapping yet (worklet was loaded directly into the\n// LEPUS template, no _execId stamped). Delegate to upstream's implementation\n// when available; otherwise, the call is a no-op.\n// ---------------------------------------------------------------------------\n\ninterface LynxWorkletImpl {\n _runOnBackgroundDelayImpl?: {\n delayRunOnBackground(\n handle: JsFnHandle,\n cb: (fnId: number, execId: number) => void,\n ): void;\n };\n}\n\ndeclare const lynxWorkletImpl: LynxWorkletImpl | undefined;\n\n// ---------------------------------------------------------------------------\n// runOnBackground — the global function called in extracted LEPUS code\n// ---------------------------------------------------------------------------\n\nexport function runOnBackground(\n handle: JsFnHandle,\n): (...args: unknown[]) => Promise<unknown> {\n return (...params: unknown[]): Promise<unknown> => {\n return new Promise((resolve) => {\n if (!resolveMap) initReturnListener();\n const resolveId = nextResolveId++;\n resolveMap!.set(resolveId, resolve);\n\n if (\n handle._isFirstScreen\n && typeof lynxWorkletImpl !== 'undefined'\n && lynxWorkletImpl?._runOnBackgroundDelayImpl\n ) {\n lynxWorkletImpl._runOnBackgroundDelayImpl.delayRunOnBackground(\n handle,\n (fnId, execId) => dispatch(fnId, params, execId, resolveId),\n );\n return;\n }\n\n if (handle._jsFnId == null || handle._execId == null) {\n // Handle never carried a (fnId, execId) pair — most likely the BG\n // sender did not call registerWorkletCtx. Resolve undefined so the\n // worklet promise settles instead of leaking.\n resolveMap!.delete(resolveId);\n resolve(undefined);\n return;\n }\n\n dispatch(handle._jsFnId, params, handle._execId, resolveId);\n });\n };\n}\n\n// ---------------------------------------------------------------------------\n// Reset — for testing only\n// ---------------------------------------------------------------------------\n\nexport function resetRunOnBackgroundMtState(): void {\n resolveMap = undefined;\n nextResolveId = 1;\n}\n","/**\n * Main Thread (Lepus) bootstrap entry.\n *\n * Injected by @sigx/lynx-plugin as the sole content of the main-thread bundle.\n * Sets up:\n * - globalThis.processData — required by Lynx Lepus runtime (data processor)\n * - globalThis.renderPage — creates the Lynx page root (id=1)\n * - globalThis.updatePage — no-op stub (required by Lynx Lepus runtime)\n * - globalThis.sigxPatchUpdate — receives ops from Background Thread\n */\n\nimport { elements, setPageUniqueId } from './element-registry.js';\nimport { applyOps, resetMainThreadState, setPlaceholder } from './ops-apply.js';\nimport { invokeWorklet } from './worklet-events.js';\nimport { runOnBackground } from './run-on-background-mt.js';\nimport { installAvBridgeFlushHook } from './animated-bridge-mt.js';\n\nconst g = globalThis as Record<string, unknown>;\n\n// CRITICAL: SystemInfo must be set BEFORE the @lynx-js/react/worklet-runtime\n// IIFE evaluates (it reads SystemInfo as a free identifier at init time).\n// lynx-plugin orders MT entries [entry-main, worklet-runtime, ...userImports]\n// so this module body runs before the worklet-runtime entry. Keeping the\n// install in module body (not an import) prevents vite from hoisting it.\nif (g['SystemInfo'] === undefined) {\n const lynxObj = (g as { lynx?: { SystemInfo?: unknown } })['lynx'];\n g['SystemInfo'] = lynxObj?.SystemInfo ?? {};\n}\n\n/** PAGE_ROOT_ID must match the value used in the BG-thread renderer */\nconst PAGE_ROOT_ID = 1;\n\n// Lynx Lepus runtime requires globalThis.processData to be set.\n// It is called to transform initial data before renderPage runs.\n// For sigx we have no data processors, so just pass data through.\ng['processData'] = function (data: unknown, _processorName?: string): unknown {\n return data ?? {};\n};\n\n// Lynx calls renderPage on the Main Thread first (before Background JS runs).\n// We create the root page element and store it as id=1 so Background ops that\n// target the root can resolve it correctly.\ng['renderPage'] = function (_data: unknown): void {\n resetMainThreadState();\n const page = __CreatePage('0', 0);\n __SetCSSId([page], 0);\n setPageUniqueId(__GetElementUniqueID(page));\n elements.set(PAGE_ROOT_ID, page);\n\n // Append a placeholder __CreateView under the page root so the host sees a\n // non-empty tree immediately. Without this, the host's \"no UI within timeout\"\n // check fires before the BG thread's first ops batch arrives, producing a\n // phantom USER_RUNTIME_ERROR. The placeholder is removed on the first\n // applyOps() call (see ops-apply.ts).\n const placeholder = __CreateView(__GetElementUniqueID(page));\n __SetCSSId([placeholder], 0);\n __AppendElement(page, placeholder);\n setPlaceholder(page, placeholder);\n\n __FlushElementTree(page);\n};\n\n// Lynx may call updatePage / updateGlobalProps after data changes.\n// We have no data binding on Main Thread, so these are no-ops.\ng['updatePage'] = function (_data: unknown): void {\n // no-op\n};\n\ng['updateGlobalProps'] = function (_data: unknown): void {\n // no-op\n};\n\n// Called by the BG Thread via callLepusMethod('sigxHotReload', {}) when a\n// webpack HMR update is about to be applied. Resets the Main Thread element\n// registry and re-creates the page root so the next sigxPatchUpdate batch\n// builds on a clean tree.\n//\n// NOTE: With component-level HMR, component file changes are self-accepted\n// by the HMR loader and patched in-place on the BG thread — this handler\n// is NOT involved. It exists as a safety net for future non-component\n// reload scenarios (e.g., if a host decides to send sigxHotReload\n// explicitly). See docs/hmr-investigation.md.\ng['sigxHotReload'] = function (): void {\n const existingPage = elements.get(PAGE_ROOT_ID);\n resetMainThreadState();\n\n const page = existingPage ?? __CreatePage('0', 0);\n __SetCSSId([page], 0);\n setPageUniqueId(__GetElementUniqueID(page));\n elements.set(PAGE_ROOT_ID, page);\n\n const placeholder = __CreateView(__GetElementUniqueID(page));\n __SetCSSId([placeholder], 0);\n __AppendElement(page, placeholder);\n setPlaceholder(page, placeholder);\n\n __FlushElementTree(page);\n};\n\n// Called by the BG Thread via callLepusMethod('sigxApplyMtHotUpdate', { code }).\n// `code` is the concatenated `registerWorkletInternal(...)` calls extracted\n// from the matching `main__main-thread.<hash>.hot-update.js` file. Eval'd in\n// the existing realm so new content-hash worklet IDs land in the live\n// `_workletMap` before the user taps a re-rendered button.\n//\n// See `lynx-runtime/src/mt-hmr-bridge.ts` for the BG-side fetch + forward.\ng['sigxApplyMtHotUpdate'] = function ({ code }: { code: string }): void {\n if (!code) return;\n try {\n new Function(code)();\n } catch (e) {\n console.log('[sigx-mt] sigxApplyMtHotUpdate eval failed:', String(e));\n }\n};\n\n// Called by the BG Thread via callLepusMethod('sigxPatchUpdate', { data }).\ng['sigxPatchUpdate'] = function ({ data }: { data: string }): void {\n let ops: unknown[];\n try {\n ops = JSON.parse(data) as unknown[];\n } catch (e) {\n console.log('[sigx-mt] sigxPatchUpdate JSON parse failed:', String(e));\n return;\n }\n try {\n applyOps(ops);\n } catch (e) {\n console.log('[sigx-mt] applyOps threw:', String(e));\n }\n // applyOps() already calls __FlushElementTree() at its tail.\n};\n\n// ---------------------------------------------------------------------------\n// runOnMainThread bridge (BG → MT worklet invocation)\n//\n// Called by the BG Thread via callLepusMethod('sigxRunOnMT',\n// { wkltId, args, captured }). When `captured` is supplied, route through\n// upstream's `runWorklet({_wkltId, _c}, args)` so its `I()` walker hydrates\n// the placeholders inside `_c` (resolves nested `{_wkltId}` worklet refs to\n// callable functions and `{_wvid}` ref placeholders to live MainThreadRefs\n// from `_workletRefMap`). This matches the path SET_WORKLET_EVENT uses for\n// JSX-attached MT handlers, and is what makes captures like\n// `runOnMainThread(() => { 'main thread'; withSpring(sv, 0); })` work\n// (`withSpring` is a worklet placeholder that needs hydration before the\n// destructure-and-call inside the body).\n//\n// `invokeWorklet` is kept as a fallback for the `captured === undefined`\n// case (no captures to hydrate) and for direct-from-MT callers that already\n// hand over a hydrated ctx.\n// ---------------------------------------------------------------------------\n\ng['sigxRunOnMT'] = function (\n { wkltId, args, captured }: { wkltId: string; args: unknown[]; captured?: Record<string, unknown> },\n callback?: (result: unknown) => void,\n): void {\n const argsArr = args ?? [];\n let result: unknown;\n const runWorkletFn = (globalThis as Record<string, unknown>)['runWorklet'] as\n | ((placeholder: { _wkltId: string; _c?: Record<string, unknown> }, args: unknown[]) => unknown)\n | undefined;\n if (captured && typeof runWorkletFn === 'function') {\n try {\n result = runWorkletFn({ _wkltId: wkltId, _c: captured }, argsArr);\n } catch (e) {\n console.log('[sigx-mt] sigxRunOnMT worklet threw:', String(e));\n result = undefined;\n }\n } else {\n result = invokeWorklet(wkltId, captured, argsArr);\n }\n if (typeof callback === 'function') {\n callback(result);\n }\n};\n\n// MT-side worklet event dispatch is handled natively: the SET_WORKLET_EVENT\n// op handler in ops-apply.ts calls __AddEvent with `{ type: 'worklet', value }`,\n// and Lynx native routes those to globalThis.runWorklet (installed by the\n// @lynx-js/react/worklet-runtime side-effect import above).\n\n// Install the SharedValue bridge flush hook. Wraps __FlushElementTree so\n// every native flush also runs flushAvBridgePublishes (covers the\n// touchmove path: worklet writes SharedValue → calls setStyleProperties →\n// upstream queues a __FlushElementTree microtask → our wrapper publishes\n// diffed SharedValues to BG before the tree flush). Idempotent.\ninstallAvBridgeFlushHook();\n\n// ---------------------------------------------------------------------------\n// runOnBackground bridge (MT → BG worklet invocation)\n//\n// SWC's LEPUS pass leaves bare `runOnBackground(_jsFnK)` references in the\n// extracted worklet body — they resolve as a free identifier. Install our\n// MT-side dispatcher as a global so those calls reach the BG event bus.\n// ---------------------------------------------------------------------------\ng['runOnBackground'] = runOnBackground;\n"],"mappings":";;;AAMA,IAAa,oBAAW,IAAI,KAAgC,EAQjD,IAAe;AAE1B,SAAgB,EAAgB,GAAkB;CAChD,IAAe;;;;ACiBjB,SAAS,IAAoC;CAC3C,OAAQ,WAAqD;;AAY/D,SAAgB,EACd,GACA,GACA,GACA,GACM;CACN,IAAM,IAAI,GAAM;CAOhB,AANI,EAAQ,YAAY,KAAA,KACtB,GAAG,6BAA6B,OAAO,EAAQ,SAAS,EAAQ,EAE9D,KAAiB,KACnB,GAAG,YAAY,GAAS,EAAW,EAEjC,KACF,GAAG,gBAAgB,kBAAkB,GAAS,EAAQ;;;;ACtC1D,IAAM,IAAW;AA4CjB,SAAS,EAAoB,GAAyC;CACpE,OAAQ,GAA0C,mBAAmB;;AAGvE,SAAS,EACP,GACyB;CACrB,OAAC,KAAW,CAAC,EAAoB,EAAQ,KACzC,EAAQ,SAAS,GAAU,OAAO;;AAIxC,SAAS,EACP,GACA,GACA,GACM;CACN,IAAI,CAAC,KAAW,CAAC,EAAoB,EAAQ,EAAE;CAC/C,IAAI,EAAQ,SAAS,GAAU;EAC7B,KAAK,IAAM,KAAQ,EAA4B,UAC7C,EAAmC,GAAK,GAAK,EAAQ;EAEvD;;CAEF,IAAM,IAAO;CACT,EAAQ,IAAI,EAAK,GAAG,KACxB,EAAQ,IAAI,EAAK,GAAG,EACpB,EAAI,KAAK,EAAK;;AAQhB,SAAS,EACP,GACA,GACA,GACM;CACN,IAAI,CAAC,KAAW,CAAC,EAAoB,EAAQ,EAAE;CAC/C,IAAI,EAAQ,SAAS,GAAU;EAC7B,KAAK,IAAM,KAAQ,EAA4B,UAC7C,EAAqB,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as t, i as n, l as r, n as i, o as a, r as o, s, t as c, u as l } from "./entry-main-
|
|
1
|
+
import { a as e, c as t, i as n, l as r, n as i, o as a, r as o, s, t as c, u as l } from "./entry-main-CBM2DHsU.js";
|
|
2
2
|
import { n as u, r as d, t as f } from "./hybrid-worklet-nTcCh-mA.js";
|
|
3
3
|
//#region src/mt-element.ts
|
|
4
4
|
var p = !1, m = class e {
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
interface WorkletLike {
|
|
2
|
+
_execId?: number;
|
|
3
|
+
}
|
|
4
|
+
/**
|
|
5
|
+
* Must be called when a worklet context is updated. Mirrors the upstream
|
|
6
|
+
* ReactLynx behaviour:
|
|
7
|
+
* 1. Register the new worklet with the JS-side lifecycle manager (so the
|
|
8
|
+
* background thread can free it).
|
|
9
|
+
* 2. On first screen with a previous ctx, hydrate the new ctx from the old.
|
|
10
|
+
* 3. On first screen, flush any worklets that were delayed waiting for this
|
|
11
|
+
* element (legacy dynamic-component compat path).
|
|
12
|
+
*/
|
|
13
|
+
export declare function onWorkletCtxUpdate(worklet: WorkletLike, oldWorklet: WorkletLike | null | undefined, isFirstScreen: boolean, element: unknown): void;
|
|
14
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sigx/lynx-runtime-main",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.7",
|
|
4
4
|
"description": "Main Thread (Lepus) entry and ops applier for SignalX Lynx renderer",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -22,7 +22,8 @@
|
|
|
22
22
|
"./package.json": "./package.json"
|
|
23
23
|
},
|
|
24
24
|
"files": [
|
|
25
|
-
"dist"
|
|
25
|
+
"dist",
|
|
26
|
+
"THIRD_PARTY_NOTICES.md"
|
|
26
27
|
],
|
|
27
28
|
"keywords": [
|
|
28
29
|
"sigx",
|
|
@@ -41,8 +42,7 @@
|
|
|
41
42
|
"url": "https://github.com/signalxjs/lynx/issues"
|
|
42
43
|
},
|
|
43
44
|
"dependencies": {
|
|
44
|
-
"@lynx-
|
|
45
|
-
"@sigx/lynx-runtime-internal": "0.2.4"
|
|
45
|
+
"@sigx/lynx-runtime-internal": "0.2.6"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
48
|
"@lynx-js/types": ">=3.0.0"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"entry-main-odx1uWxp.js","names":[],"sources":["../src/element-registry.ts","../src/upstream/processGesture.ts","../src/worklet-events.ts","../src/event-slots.ts","../src/animated-style-mappers.ts","../src/animated-bridge-mt.ts","../src/ops-apply.ts","../src/run-on-background-mt.ts","../src/entry-main.ts"],"sourcesContent":["/**\n * Element registry — maps BG-thread ShadowElement IDs to Lynx Main Thread\n * element handles.\n */\n\n/** Map from BG-thread ShadowElement id to Lynx Main Thread element handle */\nexport const elements = new Map<number, MainThreadElement>();\n\n/**\n * PAPI unique ID of the root PageElement.\n * Passed as `parentComponentUniqueId` to element creation PAPI calls.\n * `__SetCSSId` sets `css_style_sheet_manager_` directly on each element,\n * so CSS rendering works without a ComponentElement ancestor.\n */\nexport let pageUniqueId = 1;\n\nexport function setPageUniqueId(id: number): void {\n pageUniqueId = id;\n}\n","// Copyright 2024 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n//\n// TS port of `@lynx-js/react@0.119.0`'s\n// `runtime/lib/gesture/processGesture.js`. Source preserved verbatim; only\n// types added. Why vendor: upstream's `gesture/processGesture.js` is the\n// canonical platform-call sequence used by `@lynx-js/react`'s snapshot\n// pipeline. Calling our hand-rolled equivalent on a real device shows the\n// gesture arena doesn't engage; vendoring eliminates any subtle divergence.\n//\n// Sigx-specific deltas:\n// - `dom` is sigx's raw `MainThreadElement`, not a SnapshotInstance member.\n// - Caller passes `isFirstScreen=false` (no SSR/hydration in sigx).\n// - `gestureOptions` always undefined.\n\nimport { onWorkletCtxUpdate } from '@lynx-js/react/worklet-runtime/bindings';\n\nconst COMPOSED = -1;\n\ninterface GestureWorklet {\n _wkltId: string;\n _execId?: number;\n _c?: Record<string, unknown>;\n _jsFn?: Record<string, unknown>;\n _workletType?: string;\n}\n\ninterface BaseGesture {\n __isSerialized: true;\n type: number;\n id: number;\n callbacks: Record<string, GestureWorklet>;\n waitFor?: BaseGesture[];\n simultaneousWith?: BaseGesture[];\n continueWith?: BaseGesture[];\n config?: Record<string, unknown>;\n}\n\ninterface ComposedGesture {\n __isSerialized: true;\n type: -1;\n gestures: AnyGesture[];\n}\n\ntype AnyGesture = BaseGesture | ComposedGesture;\n\ninterface GestureOptions {\n domSet?: boolean;\n}\n\ninterface RelationMap {\n waitFor: number[];\n simultaneous: number[];\n continueWith: number[];\n}\n\ninterface GestureConfig {\n callbacks: { name: string; callback: GestureWorklet }[];\n config?: Record<string, unknown>;\n}\n\nfunction isSerializedGesture(gesture: unknown): gesture is AnyGesture {\n return (gesture as { __isSerialized?: boolean })?.__isSerialized === true;\n}\n\nfunction getSerializedBaseGesture(\n gesture: AnyGesture | undefined,\n): BaseGesture | undefined {\n if (!gesture || !isSerializedGesture(gesture)) return undefined;\n if (gesture.type !== COMPOSED) return gesture as BaseGesture;\n return undefined;\n}\n\nfunction appendUniqueSerializedBaseGestures(\n gesture: AnyGesture | undefined,\n out: BaseGesture[],\n seenIds: Set<number>,\n): void {\n if (!gesture || !isSerializedGesture(gesture)) return;\n if (gesture.type === COMPOSED) {\n for (const sub of (gesture as ComposedGesture).gestures) {\n appendUniqueSerializedBaseGestures(sub, out, seenIds);\n }\n return;\n }\n const base = gesture as BaseGesture;\n if (seenIds.has(base.id)) return;\n seenIds.add(base.id);\n out.push(base);\n}\n\ninterface OldGestureInfo {\n uniqOldBaseGestures: BaseGesture[];\n oldBaseGesturesById: Map<number, BaseGesture>;\n}\n\nfunction appendOldGestureInfo(\n gesture: AnyGesture | undefined,\n out: BaseGesture[],\n byId: Map<number, BaseGesture>,\n): void {\n if (!gesture || !isSerializedGesture(gesture)) return;\n if (gesture.type === COMPOSED) {\n for (const sub of (gesture as ComposedGesture).gestures) {\n appendOldGestureInfo(sub, out, byId);\n }\n return;\n }\n const base = gesture as BaseGesture;\n if (!byId.has(base.id)) {\n byId.set(base.id, base);\n out.push(base);\n }\n}\n\nfunction collectOldGestureInfo(\n oldGesture: AnyGesture | undefined,\n): OldGestureInfo {\n const uniqOldBaseGestures: BaseGesture[] = [];\n const oldBaseGesturesById = new Map<number, BaseGesture>();\n appendOldGestureInfo(oldGesture, uniqOldBaseGestures, oldBaseGesturesById);\n return { uniqOldBaseGestures, oldBaseGesturesById };\n}\n\nfunction consumeOldBaseGesture(\n baseGesture: BaseGesture,\n uniqOldBaseGestures: BaseGesture[],\n oldBaseGesturesById: Map<number, BaseGesture>,\n): BaseGesture | undefined {\n const idMatched = oldBaseGesturesById.get(baseGesture.id);\n if (idMatched) {\n oldBaseGesturesById.delete(baseGesture.id);\n return idMatched;\n }\n const fallback = uniqOldBaseGestures.find((og) =>\n oldBaseGesturesById.has(og.id),\n );\n if (!fallback) return undefined;\n oldBaseGesturesById.delete(fallback.id);\n return fallback;\n}\n\nfunction removeGestureDetector(dom: MainThreadElement, id: number): void {\n if (typeof __RemoveGestureDetector === 'function') {\n __RemoveGestureDetector(dom, id);\n }\n}\n\nfunction getGestureInfo(\n gesture: BaseGesture,\n oldGesture: BaseGesture | undefined,\n isFirstScreen: boolean,\n dom: MainThreadElement,\n): { config: GestureConfig; relationMap: RelationMap } {\n const config: GestureConfig = { callbacks: [] };\n if (gesture.config) {\n config.config = gesture.config;\n }\n for (const key of Object.keys(gesture.callbacks)) {\n const callback = gesture.callbacks[key]!;\n const oldCallback = oldGesture?.callbacks[key];\n // Upstream types `Worklet._c` as `Record<string, ClosureValueType>`; ours\n // is `Record<string, unknown>` from the wire. The runtime contract is\n // identical — cast through `unknown` to satisfy the upstream signature.\n onWorkletCtxUpdate(\n callback as unknown as Parameters<typeof onWorkletCtxUpdate>[0],\n oldCallback as unknown as Parameters<typeof onWorkletCtxUpdate>[1],\n isFirstScreen,\n dom as unknown as Parameters<typeof onWorkletCtxUpdate>[3],\n );\n config.callbacks.push({ name: key, callback });\n }\n const relationMap: RelationMap = {\n waitFor: gesture.waitFor?.map((g) => g.id) ?? [],\n simultaneous: gesture.simultaneousWith?.map((g) => g.id) ?? [],\n continueWith: gesture.continueWith?.map((g) => g.id) ?? [],\n };\n return { config, relationMap };\n}\n\nexport function processGesture(\n dom: MainThreadElement,\n gesture: AnyGesture | undefined,\n oldGesture: AnyGesture | undefined,\n isFirstScreen: boolean,\n gestureOptions?: GestureOptions,\n): void {\n const domSet = gestureOptions?.domSet === true;\n const { uniqOldBaseGestures, oldBaseGesturesById } =\n collectOldGestureInfo(oldGesture);\n\n const singleBaseGesture = getSerializedBaseGesture(gesture);\n const singleOldBaseGesture = getSerializedBaseGesture(oldGesture);\n\n if (singleBaseGesture && (!oldGesture || singleOldBaseGesture)) {\n if (!domSet) {\n __SetAttribute(dom, 'has-react-gesture', true);\n __SetAttribute(dom, 'flatten', false);\n }\n if (singleOldBaseGesture) {\n removeGestureDetector(dom, singleOldBaseGesture.id);\n }\n const { config, relationMap } = getGestureInfo(\n singleBaseGesture,\n singleOldBaseGesture,\n isFirstScreen,\n dom,\n );\n __SetGestureDetector(\n dom,\n singleBaseGesture.id,\n singleBaseGesture.type,\n config,\n relationMap,\n );\n return;\n }\n\n const uniqBaseGestures: BaseGesture[] = [];\n appendUniqueSerializedBaseGestures(gesture, uniqBaseGestures, new Set());\n if (uniqBaseGestures.length === 0) {\n for (const og of oldBaseGesturesById.values()) {\n removeGestureDetector(dom, og.id);\n }\n if (!domSet) {\n __SetAttribute(dom, 'has-react-gesture', null);\n }\n return;\n }\n\n if (!domSet) {\n __SetAttribute(dom, 'has-react-gesture', true);\n __SetAttribute(dom, 'flatten', false);\n }\n\n for (const og of oldBaseGesturesById.values()) {\n removeGestureDetector(dom, og.id);\n }\n\n for (const base of uniqBaseGestures) {\n const oldBase = consumeOldBaseGesture(\n base,\n uniqOldBaseGestures,\n oldBaseGesturesById,\n );\n const { config, relationMap } = getGestureInfo(\n base,\n oldBase,\n isFirstScreen,\n dom,\n );\n __SetGestureDetector(dom, base.id, base.type, config, relationMap);\n }\n}\n","/**\n * Helpers for invoking worklets from the BG → MT bridge.\n *\n * Most of the worklet machinery (registry, ref map, event dispatch) is owned\n * by `@lynx-js/react/worklet-runtime`, which is side-effect-imported from\n * `entry-main.ts`. That runtime installs `globalThis.lynxWorkletImpl`,\n * `globalThis.registerWorkletInternal`, and `globalThis.runWorklet`. Lynx\n * native dispatches MT-routed events directly into `runWorklet`.\n *\n * What sigx-lynx still needs to provide is the `runOnMainThread` BG → MT call\n * path: BG ships `{ wkltId, args }` over `callLepusMethod('sigxRunOnMT')`, the\n * MT bridge handler in `entry-main.ts` calls `invokeWorklet()` here, and we\n * look up the function in upstream's `_workletMap`.\n */\n\ninterface WorkletImpl {\n _workletMap: Record<string, Function>;\n _refImpl?: {\n _workletRefMap: Record<number, { current: unknown; _wvid: number }>;\n };\n}\n\nexport interface WorkletPlaceholder {\n _wkltId: string;\n _c?: Record<string, unknown>;\n}\n\nfunction getWorkletImpl(): WorkletImpl | undefined {\n return (globalThis as Record<string, unknown>)['lynxWorkletImpl'] as\n | WorkletImpl\n | undefined;\n}\n\n/**\n * Invoke a worklet by id with the given args. Used by the runOnMainThread\n * bridge — event-driven worklets go through Lynx's native runWorklet path\n * and never touch this function.\n */\nexport function invokeWorklet(\n wkltId: string,\n captured: Record<string, unknown> | undefined,\n args: unknown[],\n): unknown {\n const impl = getWorkletImpl();\n if (!impl) {\n console.log('[sigx-mt] lynxWorkletImpl not initialized');\n return undefined;\n }\n const fn = impl._workletMap[wkltId];\n if (!fn) {\n console.log('[sigx-mt] worklet not registered:', wkltId);\n return undefined;\n }\n // Match upstream's calling convention: `function(arg) { let { x } = this[\"_c\"]; ... }`\n try {\n return fn.apply({ _c: captured ?? {} }, args);\n } catch (e) {\n console.log('[sigx-mt] worklet threw:', String(e));\n return undefined;\n }\n}\n\n/** Reset hook — for testing. The upstream worklet-runtime has its own state. */\nexport function resetWorkletEvents(): void {\n // No sigx-side state to clear; upstream's _workletMap survives module reset\n // (registrations re-run when the user module re-evaluates on hot reload).\n}\n","/**\n * MT-side per-slot event registration state machine.\n *\n * Lynx native's `__AddEvent(el, eventType, eventName, value)` only stores ONE\n * value per `(el, eventType, eventName)` slot — the second call wins. When\n * sigx user code declares both a `main-thread-bind*` worklet AND a regular\n * `bind*` BG handler on the same element, two ops arrive in the same patch\n * batch (SET_WORKLET_EVENT + SET_EVENT). Calling `__AddEvent` eagerly per op\n * means the second one silently overwrites the first.\n *\n * This module defers the `__AddEvent` call. Each op updates per-slot state\n * (`worklet?`, `bgSign?`) and marks the slot dirty. After the entire op\n * batch is processed (`flushDirtySlots` is called at the tail of `applyOps`),\n * we issue ONE `__AddEvent` per dirty slot using whichever shape combines\n * the present handlers — string sign, worklet ctx, or hybrid ctx.\n *\n * State persists across batches because re-renders may update only one of\n * the two handlers (the BG event-registry already deduplicates SET_EVENT\n * after the first registration, and `sentWorklets` deduplicates\n * SET_WORKLET_EVENT by `_wkltId`).\n */\n\nimport { elements } from './element-registry.js';\nimport { hybridCtx } from './hybrid-worklet.js';\nimport type { WorkletPlaceholder } from './worklet-events.js';\n\ninterface SlotState {\n worklet?: WorkletPlaceholder;\n bgSign?: string;\n /** Last value passed to __AddEvent, kept for skip-if-unchanged diffing. */\n installed?: unknown;\n}\n\n/** elementId → typeName ('bindEvent:tap' etc.) → slot state */\nconst slotStates = new Map<number, Map<string, SlotState>>();\n/** Set of `${elementId}|${typeName}` keys that need __AddEvent re-issuing. */\nconst dirtySlots = new Set<string>();\n\nfunction getOrCreateSlot(elId: number, type: string, name: string): SlotState {\n let perEl = slotStates.get(elId);\n if (!perEl) {\n perEl = new Map();\n slotStates.set(elId, perEl);\n }\n const typeName = `${type}:${name}`;\n let slot = perEl.get(typeName);\n if (!slot) {\n slot = {};\n perEl.set(typeName, slot);\n }\n return slot;\n}\n\nfunction markDirty(elId: number, type: string, name: string): void {\n dirtySlots.add(`${elId}|${type}:${name}`);\n}\n\nexport function setSlotWorklet(\n elId: number,\n type: string,\n name: string,\n ctx: WorkletPlaceholder | undefined,\n): void {\n const slot = getOrCreateSlot(elId, type, name);\n slot.worklet = ctx;\n markDirty(elId, type, name);\n}\n\nexport function setSlotBgSign(\n elId: number,\n type: string,\n name: string,\n sign: string | undefined,\n): void {\n const slot = getOrCreateSlot(elId, type, name);\n slot.bgSign = sign;\n markDirty(elId, type, name);\n}\n\n/**\n * Pick the right __AddEvent value given which handlers are present.\n * Returns `undefined` to mean \"unregister this slot\".\n */\nfunction computeAddEventValue(slot: SlotState): unknown {\n const { worklet, bgSign } = slot;\n if (!worklet && !bgSign) return undefined;\n if (worklet && !bgSign) {\n return { type: 'worklet', value: worklet };\n }\n if (!worklet && bgSign) {\n return bgSign;\n }\n return { type: 'worklet', value: hybridCtx(worklet!, bgSign!) };\n}\n\n/**\n * Commit __AddEvent for every slot that changed since the last flush.\n * Called from `applyOps` after the op loop, before `__FlushElementTree()`.\n */\nexport function flushDirtySlots(): void {\n for (const key of dirtySlots) {\n const sep = key.indexOf('|');\n const elId = Number(key.slice(0, sep));\n const typeName = key.slice(sep + 1);\n const colon = typeName.indexOf(':');\n const type = typeName.slice(0, colon);\n const name = typeName.slice(colon + 1);\n\n const el = elements.get(elId);\n if (!el) continue;\n\n const slot = slotStates.get(elId)?.get(typeName);\n if (!slot) continue;\n\n const value = computeAddEventValue(slot);\n if (sameRef(value, slot.installed)) continue;\n\n // Lynx PAPI: undefined as the 4th arg unregisters.\n __AddEvent(el, type, name, value as string | undefined);\n slot.installed = value;\n }\n dirtySlots.clear();\n}\n\nfunction sameRef(a: unknown, b: unknown): boolean {\n // Reference equality is enough for our usage:\n // - undefined === undefined\n // - bgSign string deduplicated by event-registry, so identity stable\n // - worklet ctx is a fresh object per SET_WORKLET_EVENT op (never compared\n // to itself across batches because the prev value would always differ),\n // so this is mostly a defensive no-op for the first three branches.\n return a === b;\n}\n\n/** Hot-reload / test reset hook — clears all slot state. */\nexport function resetSlotStates(): void {\n slotStates.clear();\n dirtySlots.clear();\n}\n","/**\n * MT-side mapper registry for `useAnimatedStyle`.\n *\n * Maps a `SharedValue`'s current scalar to a partial style object that the\n * binding flush passes to `setStyleProperties` on the bound element. Keyed by\n * a string name (`'translateX'`, `'scale'`, ...) so the SWC worklet transform\n * can capture the selection trivially: a string is a primitive `_c` value\n * with no special lifting required (unlike arbitrary functions, which can't\n * be captured into a worklet's closure).\n *\n * Custom mappers can be registered via `registerMapper(name, fn)` from MT\n * code (e.g. a `'main thread'`-marked module body in a user app). BG-side\n * `useAnimatedStyle` validates the name only against the type union; a\n * lookup mismatch on MT is a silent no-op at flush time.\n *\n * Param shapes are mapper-specific. The `MapperParams` type in\n * `@sigx/lynx-runtime-internal` is the single source of truth — both\n * BG-side `useAnimatedStyle` and the MT runtime import it from there.\n *\n * Range mapping: `translateX` / `translateY` / `scale` / `opacity` accept\n * either their linear `factor`/`offset` shape or a `RangeParams` shape\n * (`{ inputRange, outputRange, extrapolate? }`). The mapper picks the branch\n * by looking for `inputRange` on the params.\n */\n\nimport type {\n MapperParams,\n RangeParams,\n AnimatedStyleMapper,\n} from '@sigx/lynx-runtime-internal';\n\n// Re-export so that consumers importing from lynx-runtime-main don't have\n// to reach into lynx-runtime-internal directly.\nexport type {\n MapperParams,\n BuiltinMapperName,\n AnimatedStyleMapper,\n RangeParams,\n} from '@sigx/lynx-runtime-internal';\n\nfunction isRangeParams(p: unknown): p is RangeParams {\n return (\n typeof p === 'object' && p !== null\n && 'inputRange' in p\n && 'outputRange' in p\n );\n}\n\n/**\n * Linear interpolation across a multi-stop range. Locates the input segment\n * via simple linear scan (inputRange is small in practice — typically 2-4\n * stops) and lerps within it. Out-of-range behavior controlled by\n * `extrapolate`: `'clamp'` (default) caps at endpoint outputs; `'identity'`\n * extends linearly using the slope of the nearest segment.\n */\nfunction interpolateLinear(\n v: number,\n inputRange: number[],\n outputRange: number[],\n extrapolate: 'clamp' | 'identity' = 'clamp',\n): number {\n const n = inputRange.length;\n if (n < 2) return outputRange[0] ?? v;\n\n if (v <= inputRange[0]!) {\n if (extrapolate === 'clamp') return outputRange[0]!;\n const dx = inputRange[1]! - inputRange[0]!;\n const dy = outputRange[1]! - outputRange[0]!;\n return outputRange[0]! + (v - inputRange[0]!) * (dy / dx);\n }\n if (v >= inputRange[n - 1]!) {\n if (extrapolate === 'clamp') return outputRange[n - 1]!;\n const dx = inputRange[n - 1]! - inputRange[n - 2]!;\n const dy = outputRange[n - 1]! - outputRange[n - 2]!;\n return outputRange[n - 1]! + (v - inputRange[n - 1]!) * (dy / dx);\n }\n for (let i = 1; i < n; i++) {\n if (v <= inputRange[i]!) {\n const t = (v - inputRange[i - 1]!) / (inputRange[i]! - inputRange[i - 1]!);\n return outputRange[i - 1]! + t * (outputRange[i]! - outputRange[i - 1]!);\n }\n }\n return outputRange[n - 1]!;\n}\n\nconst mtMappers: Record<string, AnimatedStyleMapper> = {\n translateX: (v, p) => {\n if (isRangeParams(p)) {\n const out = interpolateLinear(v as number, p.inputRange, p.outputRange, p.extrapolate);\n return { transform: `translateX(${out}px)` };\n }\n const factor = (p as { factor?: number } | undefined)?.factor ?? 1;\n return { transform: `translateX(${(v as number) * factor}px)` };\n },\n translateY: (v, p) => {\n if (isRangeParams(p)) {\n const out = interpolateLinear(v as number, p.inputRange, p.outputRange, p.extrapolate);\n return { transform: `translateY(${out}px)` };\n }\n const factor = (p as { factor?: number } | undefined)?.factor ?? 1;\n return { transform: `translateY(${(v as number) * factor}px)` };\n },\n translate: (v, p) => {\n const params = (p as MapperParams['translate'] | undefined) ?? {};\n const fx = params.factorX ?? 1;\n const fy = params.factorY ?? 1;\n const xy = v as { x: number; y: number };\n return { transform: `translate(${xy.x * fx}px, ${xy.y * fy}px)` };\n },\n scale: (v, p) => {\n if (isRangeParams(p)) {\n const out = interpolateLinear(v as number, p.inputRange, p.outputRange, p.extrapolate);\n return { transform: `scale(${out})` };\n }\n const offset = (p as { offset?: number } | undefined)?.offset ?? 0;\n return { transform: `scale(${(v as number) + offset})` };\n },\n opacity: (v, p) => {\n if (isRangeParams(p)) {\n const raw = interpolateLinear(v as number, p.inputRange, p.outputRange, p.extrapolate);\n const out = Math.max(0, Math.min(1, raw));\n return { opacity: String(out) };\n }\n const params = (p as { factor?: number; offset?: number } | undefined) ?? {};\n const factor = params.factor ?? 1;\n const offset = params.offset ?? 0;\n const out = Math.max(0, Math.min(1, (v as number) * factor + offset));\n return { opacity: String(out) };\n },\n rotate: (v) => ({ transform: `rotate(${v as number}deg)` }),\n paddingTop: (v, p) => ({ paddingTop: `${linearOrRange(v, p)}px` }),\n paddingRight: (v, p) => ({ paddingRight: `${linearOrRange(v, p)}px` }),\n paddingBottom: (v, p) => ({ paddingBottom: `${linearOrRange(v, p)}px` }),\n paddingLeft: (v, p) => ({ paddingLeft: `${linearOrRange(v, p)}px` }),\n marginTop: (v, p) => ({ marginTop: `${linearOrRange(v, p)}px` }),\n marginRight: (v, p) => ({ marginRight: `${linearOrRange(v, p)}px` }),\n marginBottom: (v, p) => ({ marginBottom: `${linearOrRange(v, p)}px` }),\n marginLeft: (v, p) => ({ marginLeft: `${linearOrRange(v, p)}px` }),\n};\n\nfunction linearOrRange(v: unknown, p: unknown): number {\n if (isRangeParams(p)) {\n return interpolateLinear(v as number, p.inputRange, p.outputRange, p.extrapolate);\n }\n const factor = (p as { factor?: number } | undefined)?.factor ?? 1;\n return (v as number) * factor;\n}\n\n/**\n * Look up a registered mapper by name. Returns `undefined` if the name\n * isn't registered — the binding flush treats that as a no-op.\n */\nexport function lookupMapper(name: string): AnimatedStyleMapper | undefined {\n return mtMappers[name];\n}\n\n/**\n * Register a custom MT-side mapper. Idempotent on (name, fn) — last\n * registration wins for the same name. Intended for `'main thread'`-marked\n * user modules that ship project-specific styling math.\n */\nexport function registerMapper(name: string, mapper: AnimatedStyleMapper): void {\n mtMappers[name] = mapper;\n}\n\n/**\n * Reset hook — drops every custom mapper, reseats the built-ins. Used by\n * the MT-side resetMainThreadState path (HMR / tests).\n */\nconst BUILTIN_NAMES = new Set([\n 'translateX', 'translateY', 'translate', 'scale', 'opacity', 'rotate',\n 'paddingTop', 'paddingRight', 'paddingBottom', 'paddingLeft',\n 'marginTop', 'marginRight', 'marginBottom', 'marginLeft',\n]);\n\nexport function resetMappers(): void {\n for (const k in mtMappers) {\n if (!BUILTIN_NAMES.has(k)) {\n delete mtMappers[k];\n }\n }\n}\n","/**\n * MT-side SharedValue bridge — publishes MT-thread mutations to BG.\n *\n * Diffs every registered SharedValue against its last-published snapshot\n * and dispatches one batched `Lynx.Sigx.AvPublish` event per flush boundary\n * with the changed `[wvid, value]` tuples. The BG side ingests these via\n * `@sigx/lynx-runtime/src/animated-bridge.ts` and writes them into the\n * mirror signal so any sigx `effect` reading `sv.value` re-runs.\n *\n * Bridge state (`bridgedAvWvids` / `bridgedAvLastValues`) lives in\n * `ops-apply.ts` because the BG→MT op handlers mutate it; this module\n * imports the references and reads them on every flush.\n *\n * Two flush hook points:\n * 1. `ops-apply.ts` calls `flushAvBridgePublishes()` at its tail (covers\n * every BG-driven ops batch).\n * 2. `installAvBridgeFlushHook()` wraps `globalThis.__FlushElementTree`\n * so spontaneous MT writes (e.g. a touchmove worklet that eventually\n * calls `setStyleProperties`) also trigger a publish on the same\n * tick the native tree flushes. Called once from `entry-main.ts`\n * after PAPI globals are present.\n *\n * Coalescing: `===` per-wvid diff. Identical writes are filtered. N writes\n * within one flush window collapse to one BG event with N entries.\n */\n\nimport { bridgedAvWvids, bridgedAvLastValues } from './ops-apply.js';\nimport { lookupMapper } from './animated-style-mappers.js';\n\nconst AV_PUBLISH = 'Lynx.Sigx.AvPublish';\n\ninterface AvRef {\n current: { value?: unknown };\n _wvid: number;\n}\n\ninterface WorkletImpl {\n _refImpl?: {\n _workletRefMap: Record<number, AvRef>;\n };\n}\n\ninterface JSContextLike {\n dispatchEvent?: (e: { type: string; data: string }) => void;\n}\n\ninterface LynxLike {\n getJSContext?: () => JSContextLike;\n}\n\n/**\n * Diff registered AVs against their last-published snapshots; dispatch one\n * batched `Lynx.Sigx.AvPublish` event with all changed tuples. No-op when\n * the bridge set is empty or when nothing has changed since the last call.\n */\nexport function flushAvBridgePublishes(): void {\n if (bridgedAvWvids.size === 0) return;\n\n const impl = (globalThis as { lynxWorkletImpl?: WorkletImpl }).lynxWorkletImpl;\n const refMap = impl?._refImpl?._workletRefMap;\n if (!refMap) return;\n\n let updates: Array<[number, unknown]> | undefined;\n for (const wvid of bridgedAvWvids) {\n const ref = refMap[wvid];\n if (!ref) continue;\n const v = ref.current?.value;\n if (v !== bridgedAvLastValues.get(wvid)) {\n (updates ??= []).push([wvid, v]);\n bridgedAvLastValues.set(wvid, v);\n }\n }\n\n if (!updates) return;\n\n const lynxObj = (globalThis as { lynx?: LynxLike }).lynx;\n const ctx = lynxObj?.getJSContext?.();\n if (!ctx?.dispatchEvent) return;\n\n let data: string;\n try {\n data = JSON.stringify(updates);\n } catch (e) {\n console.log('[sigx-mt] av-bridge: JSON.stringify failed:', String(e));\n return;\n }\n\n ctx.dispatchEvent({ type: AV_PUBLISH, data });\n}\n\n// ---------------------------------------------------------------------------\n// useAnimatedStyle bindings\n//\n// Each registered binding maps a SharedValue -> a partial style object\n// applied to a bound element on every flush where the SharedValue's value\n// changed. The MT side never sees the user's mapper code directly — the BG\n// ops carry only the mapper's *name*, which the MT runtime resolves via\n// lookupMapper().\n// ---------------------------------------------------------------------------\n\ninterface AnimatedStyleBinding {\n elementWvid: number;\n avWvid: number;\n mapperName: string;\n params: unknown;\n lastValue: unknown;\n}\n\nconst animatedStyleBindings = new Map<number, AnimatedStyleBinding>();\n\n/**\n * Register a binding (called from the OP.REGISTER_AV_STYLE_BINDING op\n * handler in `ops-apply.ts`). Initializes `lastValue` to a sentinel so the\n * first flush always applies the mapper, even when the AV is at its initial.\n */\nexport function registerAnimatedStyleBinding(\n bindingId: number,\n elementWvid: number,\n avWvid: number,\n mapperName: string,\n params: unknown,\n): void {\n // Sentinel — guaranteed not to equal any user value, so the first flush\n // applies the mapper regardless of whether the AV ever gets written.\n const sentinel = {} as unknown;\n animatedStyleBindings.set(bindingId, {\n elementWvid,\n avWvid,\n mapperName,\n params,\n lastValue: sentinel,\n });\n}\n\nexport function unregisterAnimatedStyleBinding(bindingId: number): void {\n animatedStyleBindings.delete(bindingId);\n}\n\nexport function resetAnimatedStyleBindings(): void {\n animatedStyleBindings.clear();\n}\n\nexport function animatedStyleBindingCount(): number {\n return animatedStyleBindings.size;\n}\n\ninterface ElementWithStyleApply {\n setStyleProperties?: (styles: Record<string, string | number>) => void;\n}\n\n/**\n * For each element with at least one *dirty* binding (AV value changed since\n * the last apply), re-run **all** of that element's bindings, merge their\n * mapper outputs, and apply the result with a single `setStyleProperties`\n * call. Called from the wrapped `__FlushElementTree` *before* the native\n * tree flush.\n *\n * Why \"all bindings on a dirty element\" rather than \"only changed bindings\":\n * - Multiple bindings on the same element can write the same style key\n * (e.g. `translateX` + `translateY` both produce `transform`). If we\n * applied only the changed ones, the unchanged-binding's contribution\n * would be lost and the element would visibly snap. By re-running every\n * binding on the dirty element and merging, all contributions land in\n * the same `setStyleProperties` call.\n *\n * Merge semantics:\n * - `transform` values from multiple bindings *concatenate* in registration\n * order (e.g. `translateX(50px)` + `translateY(20px)` ->\n * `translateX(50px) translateY(20px)`).\n * - All other keys merge by last-write-wins; a binding registered later on\n * the same element overwrites an earlier binding's same-key output.\n *\n * Skip cases (silent, by design):\n * - AV ref missing in `_workletRefMap` (race with unregister).\n * - Element ref's `current` is null (component not yet mounted, or\n * unmounted before the binding's UNREGISTER op landed).\n * - Mapper name not registered (typo or missing custom registration).\n */\nexport function flushAnimatedStyleBindings(): void {\n if (animatedStyleBindings.size === 0) return;\n\n const impl = (globalThis as { lynxWorkletImpl?: WorkletImpl }).lynxWorkletImpl;\n const refMap = impl?._refImpl?._workletRefMap;\n if (!refMap) return;\n\n // Phase 1 — find which elements have at least one dirty binding. Update\n // each binding's lastValue so the next flush only re-applies on further\n // change. Skip bindings whose AV ref is missing.\n let dirtyElements: Set<number> | undefined;\n for (const binding of animatedStyleBindings.values()) {\n const avRef = refMap[binding.avWvid];\n if (!avRef) continue;\n const v = avRef.current?.value;\n if (v === binding.lastValue) continue;\n binding.lastValue = v;\n (dirtyElements ??= new Set()).add(binding.elementWvid);\n }\n if (!dirtyElements) return;\n\n // Phase 2 — for each dirty element, run *all* its bindings and merge the\n // outputs into one style object. Iteration order over the Map is insertion\n // order, which equals registration order — so transform concatenations\n // come out in the order the user registered them.\n const merged = new Map<number, Record<string, string | number>>();\n for (const binding of animatedStyleBindings.values()) {\n if (!dirtyElements.has(binding.elementWvid)) continue;\n\n const avRef = refMap[binding.avWvid];\n if (!avRef) continue;\n const v = avRef.current?.value;\n\n const mapper = lookupMapper(binding.mapperName);\n if (!mapper) continue;\n\n let out: Record<string, string | number>;\n try {\n out = mapper(v, binding.params);\n } catch (e) {\n console.log('[sigx-mt] av-style mapper threw:', binding.mapperName, String(e));\n continue;\n }\n\n let acc = merged.get(binding.elementWvid);\n if (!acc) {\n acc = {};\n merged.set(binding.elementWvid, acc);\n }\n for (const k in out) {\n if (k === 'transform' && typeof acc.transform === 'string') {\n acc.transform = `${acc.transform} ${String(out.transform)}`;\n } else {\n acc[k] = out[k]!;\n }\n }\n }\n\n // Phase 3 — one setStyleProperties per dirty element.\n for (const [elementWvid, styleObj] of merged) {\n const elRef = refMap[elementWvid];\n const el = elRef?.current as unknown as ElementWithStyleApply | null | undefined;\n if (!el?.setStyleProperties) continue;\n try {\n el.setStyleProperties(styleObj);\n } catch (e) {\n console.log('[sigx-mt] av-style setStyleProperties threw:', String(e));\n }\n }\n}\n\nconst INSTALLED = Symbol.for('sigx.avBridgeFlushHookInstalled');\n\n/**\n * Wrap `globalThis.__FlushElementTree` once so every flush also runs the AV\n * bridge publish step. Idempotent — safe to call across hot reloads. Test\n * setups that `vi.stubGlobal('__FlushElementTree', ...)` AFTER this hook\n * installs will replace our wrapper, which is the correct behavior for\n * unit tests that drive `flushAvBridgePublishes` directly.\n */\nexport function installAvBridgeFlushHook(): void {\n const g = globalThis as Record<string | symbol, unknown>;\n if (g[INSTALLED]) return;\n const original = g['__FlushElementTree'];\n if (typeof original !== 'function') return;\n g[INSTALLED] = true;\n g['__FlushElementTree'] = function wrappedFlushElementTree(\n this: unknown,\n ...args: unknown[]\n ): unknown {\n try {\n flushAvBridgePublishes();\n } catch (e) {\n console.log('[sigx-mt] av-bridge flush threw:', String(e));\n }\n try {\n flushAnimatedStyleBindings();\n } catch (e) {\n console.log('[sigx-mt] av-style bindings flush threw:', String(e));\n }\n return (original as (...a: unknown[]) => unknown).apply(this, args);\n };\n}\n","/**\n * Main Thread ops executor.\n *\n * Receives the flat-array ops buffer sent by the Background Thread via\n * callLepusMethod('sigxPatchUpdate', { data: JSON.stringify(ops) }) and applies\n * each operation using Lynx PAPI.\n */\n\nimport { OP } from '@sigx/lynx-runtime-internal';\n\nimport { processGesture } from './upstream/processGesture.js';\nimport {\n elements,\n pageUniqueId,\n setPageUniqueId,\n} from './element-registry.js';\nimport { resetWorkletEvents, type WorkletPlaceholder } from './worklet-events.js';\nimport {\n setSlotBgSign,\n setSlotWorklet,\n flushDirtySlots,\n resetSlotStates,\n} from './event-slots.js';\nimport {\n flushAvBridgePublishes,\n flushAnimatedStyleBindings,\n registerAnimatedStyleBinding,\n unregisterAnimatedStyleBinding,\n resetAnimatedStyleBindings,\n} from './animated-bridge-mt.js';\n\n/**\n * Placeholder element inserted by renderPage() to give the host a non-empty\n * tree immediately, suppressing the \"loadCard failed USER_RUNTIME_ERROR\"\n * timeout. Removed on the first applyOps() call.\n */\nlet placeholderParent: MainThreadElement | null = null;\nlet placeholderEl: MainThreadElement | null = null;\n\n/**\n * SharedValue bridge state — registered wvids and last-published snapshots.\n * The op handlers (`OP.REGISTER_AV_BRIDGE` / `OP.UNREGISTER_AV_BRIDGE` below)\n * mutate these collections; `animated-bridge-mt.ts:flushAvBridgePublishes`\n * reads them on every flush boundary to compute the diff to publish to BG.\n */\nexport const bridgedAvWvids = new Set<number>();\nexport const bridgedAvLastValues = new Map<number, unknown>();\n\n/**\n * Gesture-detector tracking — per-element wvid → set of attached gesture ids.\n * Used to drive the `has-react-gesture` setup attribute lifecycle: set on the\n * first SET_GESTURE_DETECTOR for an element, cleared when the last gesture is\n * removed via REMOVE_GESTURE_DETECTOR.\n */\nconst gesturesByElementWvid = new Map<number, Set<number>>();\n\n/**\n * Last-set BaseGesture tree per element wvid. Vendored upstream\n * `processGesture` takes an `oldGesture` arg to diff against — pass the prior\n * tree so callback updates wire correctly through `onWorkletCtxUpdate`.\n */\nconst lastTreeByElementWvid = new Map<number, unknown>();\n\n/**\n * elementWvid → elementId mapping populated by SET_MT_REF when a\n * `main-thread:ref` binds to an element. Gesture ops carry the elRef's wvid\n * (set at BG-side useGestureDetector time, before the renderer assigns an\n * element id), so resolution is wvid → elementId → raw MainThreadElement.\n *\n * We deliberately do NOT use `lynxWorkletImpl._refImpl._workletRefMap[wvid].current`:\n * that map stores the upstream-wrapped `Element` class (with `setStyleProperties`\n * etc.) which is what worklets need, but the platform's `__SetAttribute` /\n * `__SetGestureDetector` PAPI expect the raw RefCounted element handle.\n * Passing the wrapper trips the `FiberSetAttribute param 0 should be RefCounted`\n * native error.\n */\nconst elementIdByWvid = new Map<number, number>();\n\nfunction resolveElementByWvid(wvid: number): MainThreadElement | undefined {\n const elementId = elementIdByWvid.get(wvid);\n if (elementId === undefined) return undefined;\n return elements.get(elementId);\n}\n\nexport function setPlaceholder(parent: MainThreadElement, el: MainThreadElement): void {\n placeholderParent = parent;\n placeholderEl = el;\n}\n\nfunction removePlaceholderOnce(): void {\n if (placeholderEl != null && placeholderParent != null) {\n __RemoveElement(placeholderParent, placeholderEl);\n placeholderParent = null;\n placeholderEl = null;\n }\n}\n\n/**\n * Use typed PAPI creators for known element types.\n * Native Lynx may set up type-specific internals (e.g. overflow clipping\n * for View, hardware-accelerated decoding for Image) via the typed functions\n * that the generic __CreateElement does not.\n */\nfunction createTypedElement(\n type: string,\n parentComponentUniqueId: number,\n): MainThreadElement {\n switch (type) {\n case 'view':\n return __CreateView(parentComponentUniqueId);\n case 'text':\n return __CreateText(parentComponentUniqueId);\n case 'image':\n return __CreateImage(parentComponentUniqueId);\n case 'scroll-view':\n return __CreateScrollView(parentComponentUniqueId);\n case 'page':\n // The page root is special — it's created once by __CreatePage() in\n // renderPage() and aliased to ShadowElement id=1 in BG. Lynx hosts\n // (e.g. Lynx Go) have no behavior class for a second `page` element\n // and will throw \"No BehaviorController defined for class page\".\n // If user code wraps content in <page>...</page>, treat it as a\n // transparent <view> on the Main Thread so the tree stays valid.\n return __CreateView(parentComponentUniqueId);\n default:\n return __CreateElement(type, parentComponentUniqueId);\n }\n}\n\nexport function applyOps(ops: unknown[]): void {\n const len = ops.length;\n if (len === 0) return;\n\n // On the first real ops batch, remove the placeholder element that\n // renderPage() inserted to suppress the host's USER_RUNTIME_ERROR timeout.\n removePlaceholderOnce();\n\n // Detect duplicate batch from double BG bundle evaluation.\n // Each __init_card_bundle__ invocation gets a fresh webpack module cache, so\n // ShadowElement.nextId resets to 2, producing the same element IDs.\n // If the first CREATE op targets an ID that already exists in our elements Map,\n // this is a duplicate batch — skip it entirely.\n if (len >= 3 && ops[0] === OP.CREATE) {\n const firstId = ops[1] as number;\n if (elements.has(firstId)) {\n return;\n }\n }\n\n let i = 0;\n\n while (i < len) {\n const code = ops[i++] as number;\n\n switch (code) {\n case OP.CREATE: {\n const id = ops[i++] as number;\n const type = ops[i++] as string;\n let el: MainThreadElement;\n if (type === '__comment') {\n el = __CreateRawText('');\n } else {\n el = createTypedElement(type, pageUniqueId);\n __SetCSSId([el], 0);\n }\n elements.set(id, el);\n if (type !== '__comment') {\n __SetAttribute(el, `sigx-ref-${id}`, 1);\n }\n break;\n }\n\n case OP.CREATE_TEXT: {\n const id = ops[i++] as number;\n const el = __CreateText(pageUniqueId);\n __SetCSSId([el], 0);\n elements.set(id, el);\n __SetAttribute(el, `sigx-ref-${id}`, 1);\n break;\n }\n\n case OP.INSERT: {\n const parentId = ops[i++] as number;\n const childId = ops[i++] as number;\n const anchorId = ops[i++] as number;\n const parent = elements.get(parentId);\n const child = elements.get(childId);\n if (parent && child) {\n if (anchorId === -1) {\n __AppendElement(parent, child);\n } else {\n const anchor = elements.get(anchorId);\n if (anchor) __InsertElementBefore(parent, child, anchor);\n }\n }\n break;\n }\n\n case OP.REMOVE: {\n const _parentId = ops[i++] as number;\n const childId = ops[i++] as number;\n const parent = elements.get(_parentId);\n const child = elements.get(childId);\n if (parent && child) {\n __RemoveElement(parent, child);\n }\n break;\n }\n\n case OP.SET_PROP: {\n const id = ops[i++] as number;\n const key = ops[i++] as string;\n const value = ops[i++];\n const el = elements.get(id);\n if (el) __SetAttribute(el, key, value);\n break;\n }\n\n case OP.SET_TEXT: {\n const id = ops[i++] as number;\n const text = ops[i++] as string;\n const el = elements.get(id);\n if (el) __SetAttribute(el, 'text', text);\n break;\n }\n\n case OP.SET_EVENT: {\n const id = ops[i++] as number;\n const eventType = ops[i++] as string;\n const eventName = ops[i++] as string;\n const sign = ops[i++] as string;\n // Defer __AddEvent to flushDirtySlots (end of batch). When a worklet\n // is also registered for the same slot, the slot machine combines\n // them into a single hybrid registration.\n setSlotBgSign(id, eventType, eventName, sign);\n break;\n }\n\n case OP.REMOVE_EVENT: {\n const id = ops[i++] as number;\n const eventType = ops[i++] as string;\n const eventName = ops[i++] as string;\n // Clear the BG side of this slot. The MT worklet (if any) survives.\n // No worklet-removal op exists yet (see plan Open items).\n setSlotBgSign(id, eventType, eventName, undefined);\n break;\n }\n\n case OP.SET_STYLE: {\n const id = ops[i++] as number;\n const value = ops[i++] as string | object;\n const el = elements.get(id);\n if (el) __SetInlineStyles(el, value);\n break;\n }\n\n case OP.SET_CLASS: {\n const id = ops[i++] as number;\n const cls = ops[i++] as string;\n const el = elements.get(id);\n if (el) __SetClasses(el, cls);\n break;\n }\n\n case OP.SET_ID: {\n const id = ops[i++] as number;\n const idStr = ops[i++] as string | null | undefined;\n const el = elements.get(id);\n if (el) __SetID(el, idStr ?? undefined);\n break;\n }\n\n case OP.SET_WORKLET_EVENT: {\n const id = ops[i++] as number;\n const eventType = ops[i++] as string;\n const eventName = ops[i++] as string;\n const ctx = ops[i++] as WorkletPlaceholder;\n if (ctx && ctx._wkltId) {\n (ctx as unknown as Record<string, unknown>)['_workletType'] = 'main-thread';\n // Defer __AddEvent — flushDirtySlots will pick the right shape:\n // worklet-only ({type:'worklet', value: ctx}) when no BG handler\n // shares this slot, or hybrid ctx when one does.\n setSlotWorklet(id, eventType, eventName, ctx);\n }\n break;\n }\n\n case OP.SET_MT_REF: {\n const id = ops[i++] as number;\n const wvid = ops[i++] as number;\n const el = elements.get(id);\n if (el) {\n // Delegate to upstream's worklet-runtime. updateWorkletRef wraps the\n // element in its own Element class and stores it under _wvid.\n const impl = (globalThis as Record<string, unknown>)['lynxWorkletImpl'] as\n { _refImpl: { _workletRefMap: Record<number, { current: unknown; _wvid: number }>; updateWorkletRef: (refImpl: unknown, el: unknown) => void } } | undefined;\n if (impl?._refImpl) {\n const refMap = impl._refImpl._workletRefMap;\n if (!(wvid in refMap)) {\n refMap[wvid] = { current: null, _wvid: wvid };\n }\n impl._refImpl.updateWorkletRef({ _wvid: wvid }, el);\n }\n // Record wvid → raw elementId so SET_GESTURE_DETECTOR can resolve\n // the unwrapped MainThreadElement for `__SetAttribute` /\n // `__SetGestureDetector` (which require RefCounted handles, not\n // upstream's Element wrapper).\n elementIdByWvid.set(wvid, id);\n }\n break;\n }\n\n case OP.INIT_MT_REF: {\n const wvid = ops[i++] as number;\n const initValue = ops[i++];\n const impl = (globalThis as Record<string, unknown>)['lynxWorkletImpl'] as\n { _refImpl: { _workletRefMap: Record<number, { current: unknown; _wvid: number }> } } | undefined;\n if (impl?._refImpl) {\n const refMap = impl._refImpl._workletRefMap;\n if (!(wvid in refMap)) {\n refMap[wvid] = { current: initValue, _wvid: wvid };\n }\n }\n break;\n }\n\n case OP.RELEASE_MT_REF: {\n // Owning component unmounted on BG; drop the MT-side holder so the\n // worklet ref map doesn't grow unbounded across navigation. Mirrors\n // upstream's WorkletEvents.releaseWorkletRef path (we don't dispatch\n // upstream's event because we manage the map ourselves via ops).\n const wvid = ops[i++] as number;\n const impl = (globalThis as Record<string, unknown>)['lynxWorkletImpl'] as\n { _refImpl: { _workletRefMap: Record<number, unknown> } } | undefined;\n if (impl?._refImpl) {\n delete impl._refImpl._workletRefMap[wvid];\n }\n elementIdByWvid.delete(wvid);\n break;\n }\n\n case OP.REGISTER_AV_BRIDGE: {\n const wvid = ops[i++] as number;\n const initValue = ops[i++];\n bridgedAvWvids.add(wvid);\n bridgedAvLastValues.set(wvid, initValue);\n break;\n }\n\n case OP.UNREGISTER_AV_BRIDGE: {\n const wvid = ops[i++] as number;\n bridgedAvWvids.delete(wvid);\n bridgedAvLastValues.delete(wvid);\n break;\n }\n\n case OP.REGISTER_AV_STYLE_BINDING: {\n const bindingId = ops[i++] as number;\n const elementWvid = ops[i++] as number;\n const avWvid = ops[i++] as number;\n const mapperName = ops[i++] as string;\n const params = ops[i++];\n registerAnimatedStyleBinding(bindingId, elementWvid, avWvid, mapperName, params);\n break;\n }\n\n case OP.UNREGISTER_AV_STYLE_BINDING: {\n const bindingId = ops[i++] as number;\n unregisterAnimatedStyleBinding(bindingId);\n break;\n }\n\n case OP.SET_GESTURE_DETECTOR: {\n // Wire format: [op, wvid, gestureId, type, config, relationMap].\n // We reconstruct upstream's BaseGesture shape and delegate to vendored\n // `processGesture` so the platform-call sequence is byte-for-byte\n // identical to `@lynx-js/react`'s snapshot pipeline. Per-base wire\n // means we register one base per op; processGesture handles the\n // single-base fast path. Composed gestures arrive as multiple ops,\n // each carrying its relationMap.\n const elementWvid = ops[i++] as number;\n const gestureId = ops[i++] as number;\n const type = ops[i++] as number;\n const config = ops[i++] as {\n callbacks: { name: string; callback: Record<string, unknown> }[];\n config?: Record<string, unknown>;\n };\n const relationMap = ops[i++] as {\n waitFor: number[];\n simultaneous: number[];\n continueWith: number[];\n };\n const el = resolveElementByWvid(elementWvid);\n if (!el) break;\n\n // Reconstruct callbacks Record from the wire's array shape.\n const callbacksRecord: Record<string, Record<string, unknown>> = {};\n for (const cb of config.callbacks) {\n callbacksRecord[cb.name] = cb.callback;\n }\n\n // Build a fake BaseGesture: relation arrays are id-stubs `[{id}]`\n // because vendored `getGestureInfo` reads `.id` off each entry to\n // produce the relationMap. The platform never sees these objects.\n const stub = (ids: number[]) => ids.map((id) => ({ id }));\n const fakeBaseGesture = {\n __isSerialized: true as const,\n type,\n id: gestureId,\n callbacks: callbacksRecord,\n waitFor: stub(relationMap.waitFor),\n simultaneousWith: stub(relationMap.simultaneous),\n continueWith: stub(relationMap.continueWith),\n ...(config.config ? { config: config.config } : {}),\n };\n\n // Phase 2.12.1 bug fix: pass `undefined` as oldGesture, NOT the last\n // tree we saw on this element.\n //\n // Our wire format is one SET_GESTURE_DETECTOR op per BaseGesture.\n // When `<Pressable>` registers `Simultaneous(Tap, LongPress)`, two\n // ops arrive in sequence on the same element. If we pass the previous\n // tree to `processGesture`, its diff path treats the second op as\n // \"Tap → LongPress\" and emits a `__RemoveGestureDetector` for Tap\n // before installing LongPress. Result: only the last gesture stays\n // registered; all earlier gestures are silently uninstalled.\n //\n // The right model for our wire is additive: each op installs ONE\n // gesture without disturbing siblings. Removal is explicit via the\n // REMOVE_GESTURE_DETECTOR op (emitted from `useGestureDetector`'s\n // unmount cleanup), which calls `__RemoveGestureDetector` directly.\n // Note: this means we don't get diff-based callback updates if the\n // BG side re-emits a gesture with the same id — but our wire never\n // does that today; on prop changes BG emits REMOVE then SET.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n processGesture(el, fakeBaseGesture as any, undefined, false);\n lastTreeByElementWvid.set(elementWvid, fakeBaseGesture);\n\n // Track for REMOVE op cleanup and to drive `has-react-gesture` toggle\n // when the last gesture goes (vendored function clears it on remove).\n let attached = gesturesByElementWvid.get(elementWvid);\n if (!attached) {\n attached = new Set();\n gesturesByElementWvid.set(elementWvid, attached);\n }\n attached.add(gestureId);\n break;\n }\n\n case OP.REMOVE_GESTURE_DETECTOR: {\n const elementWvid = ops[i++] as number;\n const gestureId = ops[i++] as number;\n const el = resolveElementByWvid(elementWvid);\n if (el && typeof __RemoveGestureDetector === 'function') {\n __RemoveGestureDetector(el, gestureId);\n const attached = gesturesByElementWvid.get(elementWvid);\n if (attached) {\n attached.delete(gestureId);\n if (attached.size === 0) {\n gesturesByElementWvid.delete(elementWvid);\n lastTreeByElementWvid.delete(elementWvid);\n __SetAttribute(el, 'has-react-gesture', null);\n }\n }\n }\n break;\n }\n\n default:\n // Unknown op – skip (future-compat)\n break;\n }\n }\n\n // Commit deferred __AddEvent registrations now that the entire batch is\n // processed — this is what lets worklet + BG handler on the same slot\n // coexist via the hybrid worklet ctx, without one overwriting the other.\n flushDirtySlots();\n\n // Diff registered SharedValues against their last-published snapshots\n // and dispatch a batched Lynx.Sigx.AvPublish event with anything that\n // changed during this op batch. See animated-bridge-mt.ts for details.\n flushAvBridgePublishes();\n\n // Apply any useAnimatedStyle bindings whose source SharedValue changed\n // during this batch. Runs after flushAvBridgePublishes so the BG mirror\n // stays consistent with the styles we're about to commit.\n flushAnimatedStyleBindings();\n\n // Flush all pending PAPI changes to the native layer in one shot.\n __FlushElementTree();\n}\n\n/** Reset module state — for testing and hot reload. */\nexport function resetMainThreadState(): void {\n elements.clear();\n setPageUniqueId(1);\n placeholderParent = null;\n placeholderEl = null;\n // Also defined in this module's imports — reset worklet state\n resetWorkletEvents();\n resetSlotStates();\n bridgedAvWvids.clear();\n bridgedAvLastValues.clear();\n gesturesByElementWvid.clear();\n lastTreeByElementWvid.clear();\n elementIdByWvid.clear();\n resetAnimatedStyleBindings();\n // Clear upstream's worklet ref map too on hard reset (HMR / test).\n const impl = (globalThis as Record<string, unknown>)['lynxWorkletImpl'] as\n { _refImpl: { _workletRefMap: Record<number, unknown> } } | undefined;\n if (impl?._refImpl) impl._refImpl._workletRefMap = {};\n}\n","/**\n * MT-side runOnBackground — dispatches function calls from the Main Thread\n * to the Background Thread via 'Lynx.Sigx.RunOnBackground' events.\n *\n * Called inside extracted worklet bodies on the Main Thread. The SWC LEPUS\n * pass leaves bare `runOnBackground(_jsFnK)` references in the registered\n * worklet body; we install this implementation as `globalThis.runOnBackground`\n * from `entry-main.ts` so the bare identifier resolves at runtime.\n *\n * Mirrors @lynx-js/react/runtime/lib/worklet/call/runOnMainThread (the dual\n * direction) and vue-lynx's run-on-background-mt.ts. Sigx-namespaced event\n * types so we don't conflict with upstream's own bridge if it ships in the\n * same lynx process.\n */\n\nconst RUN_ON_BACKGROUND = 'Lynx.Sigx.RunOnBackground';\nconst FUNCTION_CALL_RET = 'Lynx.Sigx.FunctionCallRet';\n\n// ---------------------------------------------------------------------------\n// JsFnHandle shape — matches BG-side @sigx/lynx-runtime/run-on-background.ts\n// ---------------------------------------------------------------------------\n\ninterface JsFnHandle {\n _jsFnId?: number;\n _execId?: number;\n _isFirstScreen?: boolean;\n _error?: string;\n}\n\n// ---------------------------------------------------------------------------\n// Return-value resolver — correlates resolveId → Promise resolve callback\n// ---------------------------------------------------------------------------\n\nlet resolveMap: Map<number, (v: unknown) => void> | undefined;\nlet nextResolveId = 1;\n\ninterface JSContextLike {\n addEventListener?: (type: string, listener: (e: { data?: unknown }) => void) => void;\n dispatchEvent?: (e: { type: string; data: string }) => void;\n}\ninterface LynxLike {\n getJSContext?: () => JSContextLike;\n}\n\nfunction getJSContext(): JSContextLike | undefined {\n // On MT, `lynx` is a globalThis property (no closure injection like BG).\n const lynxObj = (globalThis as { lynx?: LynxLike }).lynx;\n return lynxObj?.getJSContext?.();\n}\n\nfunction initReturnListener(): void {\n resolveMap = new Map();\n getJSContext()?.addEventListener?.(FUNCTION_CALL_RET, (event) => {\n let payload: { resolveId: number; returnValue: unknown };\n try {\n payload = JSON.parse(event.data as string);\n } catch {\n return;\n }\n const resolve = resolveMap?.get(payload.resolveId);\n if (resolve) {\n resolveMap!.delete(payload.resolveId);\n resolve(payload.returnValue);\n }\n });\n}\n\n// ---------------------------------------------------------------------------\n// dispatch — ship the call across to BG\n// ---------------------------------------------------------------------------\n\nfunction dispatch(fnId: number, params: unknown[], execId: number, resolveId: number): void {\n getJSContext()?.dispatchEvent?.({\n type: RUN_ON_BACKGROUND,\n data: JSON.stringify({\n obj: { _jsFnId: fnId, _execId: execId },\n params,\n resolveId,\n }),\n });\n}\n\n// ---------------------------------------------------------------------------\n// First-screen delay hook — lynxWorkletImpl provides this when the MT runtime\n// hasn't finished bootstrapping yet (worklet was loaded directly into the\n// LEPUS template, no _execId stamped). Delegate to upstream's implementation\n// when available; otherwise, the call is a no-op.\n// ---------------------------------------------------------------------------\n\ninterface LynxWorkletImpl {\n _runOnBackgroundDelayImpl?: {\n delayRunOnBackground(\n handle: JsFnHandle,\n cb: (fnId: number, execId: number) => void,\n ): void;\n };\n}\n\ndeclare const lynxWorkletImpl: LynxWorkletImpl | undefined;\n\n// ---------------------------------------------------------------------------\n// runOnBackground — the global function called in extracted LEPUS code\n// ---------------------------------------------------------------------------\n\nexport function runOnBackground(\n handle: JsFnHandle,\n): (...args: unknown[]) => Promise<unknown> {\n return (...params: unknown[]): Promise<unknown> => {\n return new Promise((resolve) => {\n if (!resolveMap) initReturnListener();\n const resolveId = nextResolveId++;\n resolveMap!.set(resolveId, resolve);\n\n if (\n handle._isFirstScreen\n && typeof lynxWorkletImpl !== 'undefined'\n && lynxWorkletImpl?._runOnBackgroundDelayImpl\n ) {\n lynxWorkletImpl._runOnBackgroundDelayImpl.delayRunOnBackground(\n handle,\n (fnId, execId) => dispatch(fnId, params, execId, resolveId),\n );\n return;\n }\n\n if (handle._jsFnId == null || handle._execId == null) {\n // Handle never carried a (fnId, execId) pair — most likely the BG\n // sender did not call registerWorkletCtx. Resolve undefined so the\n // worklet promise settles instead of leaking.\n resolveMap!.delete(resolveId);\n resolve(undefined);\n return;\n }\n\n dispatch(handle._jsFnId, params, handle._execId, resolveId);\n });\n };\n}\n\n// ---------------------------------------------------------------------------\n// Reset — for testing only\n// ---------------------------------------------------------------------------\n\nexport function resetRunOnBackgroundMtState(): void {\n resolveMap = undefined;\n nextResolveId = 1;\n}\n","/**\n * Main Thread (Lepus) bootstrap entry.\n *\n * Injected by @sigx/lynx-plugin as the sole content of the main-thread bundle.\n * Sets up:\n * - globalThis.processData — required by Lynx Lepus runtime (data processor)\n * - globalThis.renderPage — creates the Lynx page root (id=1)\n * - globalThis.updatePage — no-op stub (required by Lynx Lepus runtime)\n * - globalThis.sigxPatchUpdate — receives ops from Background Thread\n */\n\nimport { elements, setPageUniqueId } from './element-registry.js';\nimport { applyOps, resetMainThreadState, setPlaceholder } from './ops-apply.js';\nimport { invokeWorklet } from './worklet-events.js';\nimport { runOnBackground } from './run-on-background-mt.js';\nimport { installAvBridgeFlushHook } from './animated-bridge-mt.js';\n\nconst g = globalThis as Record<string, unknown>;\n\n// CRITICAL: SystemInfo must be set BEFORE the @lynx-js/react/worklet-runtime\n// IIFE evaluates (it reads SystemInfo as a free identifier at init time).\n// lynx-plugin orders MT entries [entry-main, worklet-runtime, ...userImports]\n// so this module body runs before the worklet-runtime entry. Keeping the\n// install in module body (not an import) prevents vite from hoisting it.\nif (g['SystemInfo'] === undefined) {\n const lynxObj = (g as { lynx?: { SystemInfo?: unknown } })['lynx'];\n g['SystemInfo'] = lynxObj?.SystemInfo ?? {};\n}\n\n/** PAGE_ROOT_ID must match the value used in the BG-thread renderer */\nconst PAGE_ROOT_ID = 1;\n\n// Lynx Lepus runtime requires globalThis.processData to be set.\n// It is called to transform initial data before renderPage runs.\n// For sigx we have no data processors, so just pass data through.\ng['processData'] = function (data: unknown, _processorName?: string): unknown {\n return data ?? {};\n};\n\n// Lynx calls renderPage on the Main Thread first (before Background JS runs).\n// We create the root page element and store it as id=1 so Background ops that\n// target the root can resolve it correctly.\ng['renderPage'] = function (_data: unknown): void {\n resetMainThreadState();\n const page = __CreatePage('0', 0);\n __SetCSSId([page], 0);\n setPageUniqueId(__GetElementUniqueID(page));\n elements.set(PAGE_ROOT_ID, page);\n\n // Append a placeholder __CreateView under the page root so the host sees a\n // non-empty tree immediately. Without this, the host's \"no UI within timeout\"\n // check fires before the BG thread's first ops batch arrives, producing a\n // phantom USER_RUNTIME_ERROR. The placeholder is removed on the first\n // applyOps() call (see ops-apply.ts).\n const placeholder = __CreateView(__GetElementUniqueID(page));\n __SetCSSId([placeholder], 0);\n __AppendElement(page, placeholder);\n setPlaceholder(page, placeholder);\n\n __FlushElementTree(page);\n};\n\n// Lynx may call updatePage / updateGlobalProps after data changes.\n// We have no data binding on Main Thread, so these are no-ops.\ng['updatePage'] = function (_data: unknown): void {\n // no-op\n};\n\ng['updateGlobalProps'] = function (_data: unknown): void {\n // no-op\n};\n\n// Called by the BG Thread via callLepusMethod('sigxHotReload', {}) when a\n// webpack HMR update is about to be applied. Resets the Main Thread element\n// registry and re-creates the page root so the next sigxPatchUpdate batch\n// builds on a clean tree.\n//\n// NOTE: With component-level HMR, component file changes are self-accepted\n// by the HMR loader and patched in-place on the BG thread — this handler\n// is NOT involved. It exists as a safety net for future non-component\n// reload scenarios (e.g., if a host decides to send sigxHotReload\n// explicitly). See docs/hmr-investigation.md.\ng['sigxHotReload'] = function (): void {\n const existingPage = elements.get(PAGE_ROOT_ID);\n resetMainThreadState();\n\n const page = existingPage ?? __CreatePage('0', 0);\n __SetCSSId([page], 0);\n setPageUniqueId(__GetElementUniqueID(page));\n elements.set(PAGE_ROOT_ID, page);\n\n const placeholder = __CreateView(__GetElementUniqueID(page));\n __SetCSSId([placeholder], 0);\n __AppendElement(page, placeholder);\n setPlaceholder(page, placeholder);\n\n __FlushElementTree(page);\n};\n\n// Called by the BG Thread via callLepusMethod('sigxApplyMtHotUpdate', { code }).\n// `code` is the concatenated `registerWorkletInternal(...)` calls extracted\n// from the matching `main__main-thread.<hash>.hot-update.js` file. Eval'd in\n// the existing realm so new content-hash worklet IDs land in the live\n// `_workletMap` before the user taps a re-rendered button.\n//\n// See `lynx-runtime/src/mt-hmr-bridge.ts` for the BG-side fetch + forward.\ng['sigxApplyMtHotUpdate'] = function ({ code }: { code: string }): void {\n if (!code) return;\n try {\n new Function(code)();\n } catch (e) {\n console.log('[sigx-mt] sigxApplyMtHotUpdate eval failed:', String(e));\n }\n};\n\n// Called by the BG Thread via callLepusMethod('sigxPatchUpdate', { data }).\ng['sigxPatchUpdate'] = function ({ data }: { data: string }): void {\n let ops: unknown[];\n try {\n ops = JSON.parse(data) as unknown[];\n } catch (e) {\n console.log('[sigx-mt] sigxPatchUpdate JSON parse failed:', String(e));\n return;\n }\n try {\n applyOps(ops);\n } catch (e) {\n console.log('[sigx-mt] applyOps threw:', String(e));\n }\n // applyOps() already calls __FlushElementTree() at its tail.\n};\n\n// ---------------------------------------------------------------------------\n// runOnMainThread bridge (BG → MT worklet invocation)\n//\n// Called by the BG Thread via callLepusMethod('sigxRunOnMT',\n// { wkltId, args, captured }). When `captured` is supplied, route through\n// upstream's `runWorklet({_wkltId, _c}, args)` so its `I()` walker hydrates\n// the placeholders inside `_c` (resolves nested `{_wkltId}` worklet refs to\n// callable functions and `{_wvid}` ref placeholders to live MainThreadRefs\n// from `_workletRefMap`). This matches the path SET_WORKLET_EVENT uses for\n// JSX-attached MT handlers, and is what makes captures like\n// `runOnMainThread(() => { 'main thread'; withSpring(sv, 0); })` work\n// (`withSpring` is a worklet placeholder that needs hydration before the\n// destructure-and-call inside the body).\n//\n// `invokeWorklet` is kept as a fallback for the `captured === undefined`\n// case (no captures to hydrate) and for direct-from-MT callers that already\n// hand over a hydrated ctx.\n// ---------------------------------------------------------------------------\n\ng['sigxRunOnMT'] = function (\n { wkltId, args, captured }: { wkltId: string; args: unknown[]; captured?: Record<string, unknown> },\n callback?: (result: unknown) => void,\n): void {\n const argsArr = args ?? [];\n let result: unknown;\n const runWorkletFn = (globalThis as Record<string, unknown>)['runWorklet'] as\n | ((placeholder: { _wkltId: string; _c?: Record<string, unknown> }, args: unknown[]) => unknown)\n | undefined;\n if (captured && typeof runWorkletFn === 'function') {\n try {\n result = runWorkletFn({ _wkltId: wkltId, _c: captured }, argsArr);\n } catch (e) {\n console.log('[sigx-mt] sigxRunOnMT worklet threw:', String(e));\n result = undefined;\n }\n } else {\n result = invokeWorklet(wkltId, captured, argsArr);\n }\n if (typeof callback === 'function') {\n callback(result);\n }\n};\n\n// MT-side worklet event dispatch is handled natively: the SET_WORKLET_EVENT\n// op handler in ops-apply.ts calls __AddEvent with `{ type: 'worklet', value }`,\n// and Lynx native routes those to globalThis.runWorklet (installed by the\n// @lynx-js/react/worklet-runtime side-effect import above).\n\n// Install the SharedValue bridge flush hook. Wraps __FlushElementTree so\n// every native flush also runs flushAvBridgePublishes (covers the\n// touchmove path: worklet writes SharedValue → calls setStyleProperties →\n// upstream queues a __FlushElementTree microtask → our wrapper publishes\n// diffed SharedValues to BG before the tree flush). Idempotent.\ninstallAvBridgeFlushHook();\n\n// ---------------------------------------------------------------------------\n// runOnBackground bridge (MT → BG worklet invocation)\n//\n// SWC's LEPUS pass leaves bare `runOnBackground(_jsFnK)` references in the\n// extracted worklet body — they resolve as a free identifier. Install our\n// MT-side dispatcher as a global so those calls reach the BG event bus.\n// ---------------------------------------------------------------------------\ng['runOnBackground'] = runOnBackground;\n"],"mappings":";;;;AAMA,IAAa,oBAAW,IAAI,KAAgC,EAQjD,IAAe;AAE1B,SAAgB,EAAgB,GAAkB;CAChD,IAAe;;;;ACCjB,IAAM,IAAW;AA4CjB,SAAS,EAAoB,GAAyC;CACpE,OAAQ,GAA0C,mBAAmB;;AAGvE,SAAS,EACP,GACyB;CACrB,OAAC,KAAW,CAAC,EAAoB,EAAQ,KACzC,EAAQ,SAAS,GAAU,OAAO;;AAIxC,SAAS,EACP,GACA,GACA,GACM;CACN,IAAI,C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