@sigx/lynx-runtime 0.2.6 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,849 +1,37 @@
1
- import { createRenderer as e, setDefaultMount as t, setPlatformModelProcessor as n } from "@sigx/runtime-core/internals";
2
- import { signal as r } from "@sigx/reactivity";
3
- import { OP as i, OP as a, OP as o } from "@sigx/lynx-runtime-internal";
4
- import { onMounted as s, onUnmounted as c } from "@sigx/runtime-core";
5
- //#region src/model-processor.ts
6
- n((e, t, [n, r], i) => {
7
- let a = (e) => {
8
- let t = n[`onUpdate:${r}`];
9
- typeof t == "function" ? t(e) : n[r] = e;
10
- };
11
- if (e === "input") {
12
- t.value = n[r] ?? "";
13
- let e = t.bindinput;
14
- t.bindinput = (t) => {
15
- a(t?.detail?.value ?? ""), e && e(t);
16
- };
17
- let i = t["onUpdate:modelValue"];
18
- return t["onUpdate:modelValue"] = (e) => {
19
- a(e), i && i(e);
20
- }, !0;
21
- }
22
- if (e === "textarea") {
23
- t.value = n[r] ?? "";
24
- let e = t.bindinput;
25
- t.bindinput = (t) => {
26
- a(t?.detail?.value ?? ""), e && e(t);
27
- };
28
- let i = t["onUpdate:modelValue"];
29
- return t["onUpdate:modelValue"] = (e) => {
30
- a(e), i && i(e);
31
- }, !0;
32
- }
33
- return !1;
34
- });
35
- //#endregion
36
- //#region src/event-registry.ts
37
- var l = "__SIGX_LYNX_EVENT_REGISTRY__";
38
- function u() {
39
- let e = globalThis, t = e[l];
40
- return t || (t = {
41
- signCounter: 0,
42
- handlers: /* @__PURE__ */ new Map()
43
- }, Object.defineProperty(e, l, {
44
- value: t,
45
- configurable: !0,
46
- enumerable: !1,
47
- writable: !0
48
- })), t;
49
- }
50
- function d(e) {
51
- let t = u(), n = `sigx:${t.signCounter++}`;
52
- return t.handlers.set(n, e), n;
53
- }
54
- function ee(e, t) {
55
- u().handlers.set(e, t);
56
- }
57
- function te(e) {
58
- return u().handlers.get(e);
59
- }
60
- function ne(e) {
61
- u().handlers.delete(e);
62
- }
63
- function f(e, t) {
64
- u().handlers.get(e)?.(t);
65
- }
66
- function re() {
67
- let e = u();
68
- e.signCounter = 0, e.handlers.clear();
69
- }
70
- //#endregion
71
- //#region src/animated-bridge.ts
72
- var p = /* @__PURE__ */ new Map();
73
- function m(e, t) {
74
- let n = p.get(e);
75
- if (n) return n;
76
- let i = r(t);
77
- return p.set(e, i), i;
78
- }
79
- function h(e) {
80
- p.delete(e);
81
- }
82
- function g(e) {
83
- for (let [t, n] of e) {
84
- let e = p.get(t);
85
- e && (e.value = n);
86
- }
87
- }
88
- function ie() {
89
- p.clear();
90
- }
91
- function ae() {
92
- return p.size;
93
- }
94
- //#endregion
95
- //#region src/bg-bridge.ts
96
- var _ = (typeof lynx < "u" ? lynx : void 0)?.getCoreContext?.();
97
- _?.addEventListener && (_.addEventListener("Lynx.Sigx.PublishEvent", (e) => {
98
- let t;
99
- try {
100
- t = JSON.parse(e.data);
101
- } catch {
102
- return;
103
- }
104
- typeof t.sign == "string" && f(t.sign, t.event);
105
- }), _.addEventListener("Lynx.Sigx.AvPublish", (e) => {
106
- let t;
107
- try {
108
- t = JSON.parse(e.data);
109
- } catch {
110
- return;
111
- }
112
- Array.isArray(t) && g(t);
113
- }));
114
- //#endregion
115
- //#region src/run-on-background.ts
116
- var oe = "Lynx.Sigx.RunOnBackground", se = "Lynx.Sigx.FunctionCallRet", v = 0;
117
- function ce(e) {
118
- let t = ++v;
119
- return typeof e == "function" ? (e.toJSON ??= () => "[BackgroundFunction]", {
120
- _jsFnId: t,
121
- _fn: e
122
- }) : {
123
- _jsFnId: t,
124
- _error: `Argument of runOnBackground should be a function, got [${typeof e}]`
125
- };
126
- }
127
- var le = class {
128
- lastIndex = 0;
129
- map = /* @__PURE__ */ new Map();
130
- add(e) {
131
- let t = ++this.lastIndex;
132
- return this.map.set(t, e), t;
133
- }
134
- get(e) {
135
- return this.map.get(e);
136
- }
137
- remove(e) {
138
- this.map.delete(e);
139
- }
140
- }, ue = class extends le {
141
- add(e) {
142
- let t = super.add(e);
143
- return e._execId = t, t;
144
- }
145
- findJsFnHandle(e, t) {
146
- let n = this.get(e);
147
- if (!n) return;
148
- let r = /* @__PURE__ */ new Set(), i = (e) => {
149
- if (typeof e != "object" || !e) return;
150
- let n = e;
151
- if (!r.has(n)) {
152
- if (r.add(n), "_jsFnId" in n && n._jsFnId === t) return n;
153
- for (let e in n) {
154
- let t = i(n[e]);
155
- if (t) return t;
156
- }
157
- }
158
- };
159
- return i(n);
160
- }
161
- }, y;
162
- function b() {
163
- if (typeof lynx > "u") return;
164
- let e = lynx;
165
- return typeof e.getCoreContext == "function" ? e.getCoreContext() : void 0;
166
- }
167
- function de() {
168
- y = new ue(), b()?.addEventListener?.(oe, pe);
169
- }
170
- function fe(e) {
171
- y || de(), y.add(e);
172
- }
173
- function pe(e) {
174
- let t;
175
- try {
176
- t = JSON.parse(e.data);
177
- } catch {
178
- return;
179
- }
180
- let n = y?.findJsFnHandle(t.obj._execId, t.obj._jsFnId);
181
- if (!n?._fn) {
182
- x(t.resolveId, void 0);
183
- return;
184
- }
185
- let r;
186
- try {
187
- r = n._fn(...t.params);
188
- } catch (e) {
189
- throw x(t.resolveId, void 0), e;
190
- }
191
- x(t.resolveId, r);
192
- }
193
- function x(e, t) {
194
- b()?.dispatchEvent?.({
195
- type: se,
196
- data: JSON.stringify({
197
- resolveId: e,
198
- returnValue: t
199
- })
200
- });
201
- }
202
- function me(e) {
203
- throw Error("runOnBackground() can only be used inside 'main thread' functions. The SWC worklet transform should replace this call at build time — verify @sigx/lynx-plugin's worklet-loader is wired into your bundler.");
204
- }
205
- function he() {
206
- y = void 0, v = 0;
207
- }
208
- //#endregion
209
- //#region src/op-queue.ts
210
- var S = [];
211
- function C(...e) {
212
- for (let t of e) S.push(t);
213
- }
214
- function w() {
215
- let e = S;
216
- return S = [], e;
217
- }
218
- var T = !1;
219
- function E() {
220
- T || (T = !0, Promise.resolve().then(_e));
221
- }
222
- function D() {
223
- T = !1;
224
- let e = w();
225
- e.length !== 0 && k(e);
226
- }
227
- function ge() {
228
- S = [], T = !1, O = null, ve = null;
229
- }
230
- function _e() {
231
- T = !1;
232
- let e = w();
233
- e.length !== 0 && k(e);
234
- }
235
- var O = null, ve = null;
236
- function k(e) {
237
- let t = JSON.stringify(e);
238
- if (new Promise((e) => {
239
- O = e;
240
- }), typeof lynx < "u") {
241
- let e = lynx?.getNativeApp?.();
242
- if (e && typeof e.callLepusMethod == "function") {
243
- e.callLepusMethod("sigxPatchUpdate", { data: t }, () => {
244
- O?.(), O = null;
245
- });
246
- return;
247
- }
248
- }
249
- let n = globalThis;
250
- if (typeof n.sigxPatchUpdate == "function") {
251
- n.sigxPatchUpdate({ data: t }), O?.(), O = null;
252
- return;
253
- }
254
- console.log("[sigx-bg] sendOps: no `lynx` global injected — bundle is missing RuntimeWrapperWebpackPlugin"), O?.(), O = null;
255
- }
256
- function A(e, t) {
257
- try {
258
- let n = globalThis.__SIGX_LYNX_EVENT_REGISTRY__;
259
- if (!n?.handlers || e == null) return;
260
- let r = n.handlers, i = r instanceof Map ? r.get(String(e)) : r[String(e)];
261
- typeof i == "function" && i(t);
262
- } catch (e) {
263
- console.log("[sigx-bg] event dispatch threw:", String(e));
264
- }
265
- }
266
- function j() {
267
- typeof lynxCoreInject < "u" && lynxCoreInject?.tt && (lynxCoreInject.tt.publishEvent = A, lynxCoreInject.tt.publicComponentEvent = (e, t, n) => A(t, n));
268
- let e = globalThis;
269
- typeof e.publishEvent != "function" && (e.publishEvent = A), typeof e.publicComponentEvent != "function" && (e.publicComponentEvent = ((e, t, n) => A(t, n)));
270
- }
271
- //#endregion
272
- //#region src/shadow-element.ts
273
- var M = class e {
274
- static nextId = 2;
275
- id;
276
- type;
277
- parent = null;
278
- firstChild = null;
279
- lastChild = null;
280
- prev = null;
281
- next = null;
282
- _style = {};
283
- _vShowHidden = !1;
284
- _baseClass = "";
285
- _transitionClasses = /* @__PURE__ */ new Set();
286
- constructor(t, n) {
287
- this.id = n === void 0 ? e.nextId++ : n, this.type = t;
288
- }
289
- insertBefore(e, t) {
290
- if (e.parent && e.parent.removeChild(e), e.parent = this, t) {
291
- let n = t.prev;
292
- e.next = t, e.prev = n, t.prev = e, n ? n.next = e : this.firstChild = e;
293
- } else this.lastChild ? (this.lastChild.next = e, e.prev = this.lastChild) : (this.firstChild = e, e.prev = null), this.lastChild = e, e.next = null;
294
- }
295
- removeChild(e) {
296
- let t = e.prev, n = e.next;
297
- t ? t.next = n : this.firstChild = n, n ? n.prev = t : this.lastChild = t, e.parent = null, e.prev = null, e.next = null;
298
- }
299
- };
300
- function N() {
301
- return new M("page", 1);
302
- }
303
- function ye() {
304
- M.nextId = 2;
305
- }
306
- //#endregion
307
- //#region src/main-thread-ref.ts
308
- var P = 1;
309
- function be() {
310
- P = 1;
311
- }
312
- var F = class {
313
- _wvid;
314
- _initValue;
315
- current;
316
- constructor(e) {
317
- this._wvid = P++, this._initValue = e, this.current = e;
318
- }
319
- };
320
- function I(e) {
321
- let t = {};
322
- for (let n in e) {
323
- let r = e[n];
324
- r instanceof F ? t[n] = {
325
- _wvid: r._wvid,
326
- _initValue: r._initValue
327
- } : t[n] = r;
328
- }
329
- return t;
330
- }
331
- function xe(e) {
332
- let t = new F(e);
333
- return C(o.INIT_MT_REF, t._wvid, e), E(), c(() => {
334
- C(o.RELEASE_MT_REF, t._wvid), E();
335
- }), t;
336
- }
337
- //#endregion
338
- //#region src/nodeOps.ts
339
- function Se(e) {
340
- return e.startsWith("main-thread-bind") ? {
341
- type: "bindEvent",
342
- name: e.slice(16),
343
- mainThread: !0
344
- } : e.startsWith("main-thread-catch") ? {
345
- type: "catchEvent",
346
- name: e.slice(17),
347
- mainThread: !0
348
- } : e.startsWith("main-thread:bind") ? {
349
- type: "bindEvent",
350
- name: e.slice(16),
351
- mainThread: !0
352
- } : e.startsWith("main-thread:catch") ? {
353
- type: "catchEvent",
354
- name: e.slice(17),
355
- mainThread: !0
356
- } : e.startsWith("global-bind") ? {
357
- type: "bindGlobalEvent",
358
- name: e.slice(11)
359
- } : e.startsWith("global-catch") ? {
360
- type: "catchGlobalEvent",
361
- name: e.slice(12)
362
- } : e.startsWith("catch") ? {
363
- type: "catchEvent",
364
- name: e.slice(5)
365
- } : /^bind(?!ingx)/.test(e) ? {
366
- type: "bindEvent",
367
- name: e.slice(4)
368
- } : /^on[A-Z]/.test(e) ? {
369
- type: "bindEvent",
370
- name: e.slice(2, 3).toLowerCase() + e.slice(3)
371
- } : null;
372
- }
373
- function Ce(e) {
374
- return typeof e == "object" && !!e && "_wkltId" in e;
375
- }
376
- var L = /* @__PURE__ */ new Map(), R = /* @__PURE__ */ new Map(), z = /* @__PURE__ */ new Map(), we = new Set([
377
- "flex",
378
- "flexGrow",
379
- "flexShrink",
380
- "flexOrder",
381
- "order",
382
- "opacity",
383
- "zIndex",
384
- "aspectRatio",
385
- "fontWeight",
386
- "lineClamp"
387
- ]);
388
- function Te(e) {
389
- let t = {};
390
- for (let n of Object.keys(e)) {
391
- let r = e[n];
392
- typeof r == "number" && !we.has(n) && r !== 0 ? t[n] = `${r}px` : t[n] = r;
393
- }
394
- return t;
395
- }
396
- function Ee(e, t) {
397
- let n = Object.keys(e), r = Object.keys(t);
398
- if (n.length !== r.length) return !1;
399
- for (let r of n) if (e[r] !== t[r]) return !1;
400
- return !0;
401
- }
402
- function De(e) {
403
- if (e._transitionClasses.size === 0) return e._baseClass;
404
- let t = [];
405
- e._baseClass && t.push(e._baseClass);
406
- for (let n of e._transitionClasses) t.push(n);
407
- return t.join(" ");
408
- }
409
- var B = {
410
- createElement(e) {
411
- let t = new M(e);
412
- return C(o.CREATE, t.id, e), E(), t;
413
- },
414
- createText(e) {
415
- let t = new M("#text");
416
- return C(o.CREATE_TEXT, t.id), e && C(o.SET_TEXT, t.id, e), E(), t;
417
- },
418
- createComment(e) {
419
- let t = new M("#comment");
420
- return C(o.CREATE, t.id, "__comment"), E(), t;
421
- },
422
- setText(e, t) {
423
- C(o.SET_TEXT, e.id, t), E();
424
- },
425
- setElementText(e, t) {
426
- for (; e.firstChild;) {
427
- let t = e.firstChild;
428
- e.removeChild(t), C(o.REMOVE, e.id, t.id);
429
- }
430
- C(o.SET_TEXT, e.id, t), E();
431
- },
432
- insert(e, t, n) {
433
- if (t.insertBefore(e, n ?? null), t.type === "list" && (e.type === "#comment" || e.type === "#text")) return;
434
- let r = n ?? null;
435
- if (t.type === "list") for (; r && (r.type === "#comment" || r.type === "#text");) r = r.next;
436
- let i = r ? r.id : -1;
437
- C(o.INSERT, t.id, e.id, i), E();
438
- },
439
- remove(e) {
440
- if (e.parent) {
441
- let t = e.parent.id;
442
- e.parent.removeChild(e), C(o.REMOVE, t, e.id), E();
443
- }
444
- },
445
- patchProp(e, t, n, r) {
446
- if (t === "main-thread:ref") {
447
- if (r != null) {
448
- let t = r;
449
- C(o.SET_MT_REF, e.id, t._wvid);
450
- }
451
- E();
452
- return;
453
- }
454
- let i = Se(t);
455
- if (i) {
456
- if (i.mainThread && r != null && Ce(r)) {
457
- let n = L.get(e.id);
458
- if (n?.get(t) !== r._wkltId) {
459
- n || (n = /* @__PURE__ */ new Map(), L.set(e.id, n)), n.set(t, r._wkltId);
460
- let a = { _wkltId: r._wkltId };
461
- r._c && (a._c = I(r._c)), r._jsFn && (a._jsFn = r._jsFn), fe(a), C(o.SET_WORKLET_EVENT, e.id, i.type, i.name, a), E();
462
- }
463
- return;
464
- }
465
- let n = R.get(e.id), a = `${i.type}:${i.name}`;
466
- if (r != null) {
467
- let s = r, c = z.get(e.id);
468
- c || (c = /* @__PURE__ */ new Map(), z.set(e.id, c));
469
- let l = c.get(a);
470
- if (!l) {
471
- let t = d((e) => {
472
- let t = c.get(a);
473
- if (t) for (let n of t.handlers.values()) n(e);
474
- });
475
- l = {
476
- sign: t,
477
- handlers: /* @__PURE__ */ new Map()
478
- }, c.set(a, l), C(o.SET_EVENT, e.id, i.type, i.name, t);
479
- }
480
- l.handlers.set(t, s), n || (n = /* @__PURE__ */ new Map(), R.set(e.id, n)), n.set(t, l.sign);
481
- } else {
482
- let r = z.get(e.id), s = r?.get(a);
483
- s && (s.handlers.delete(t), s.handlers.size === 0 && (ne(s.sign), r.delete(a), C(o.REMOVE_EVENT, e.id, i.type, i.name))), n?.delete(t);
484
- }
485
- } else if (t === "style") {
486
- let t = typeof r == "object" && r ? Te(r) : {}, n = e._vShowHidden ? {
487
- ...t,
488
- display: "none"
489
- } : t, i = e._style, a = i != null && Ee(i, n);
490
- e._style = t, a || C(o.SET_STYLE, e.id, n);
491
- } else if (t === "class") {
492
- e._baseClass = r ?? "";
493
- let t = De(e);
494
- C(o.SET_CLASS, e.id, t);
495
- } else t === "id" ? C(o.SET_ID, e.id, r) : C(o.SET_PROP, e.id, t, r);
496
- E();
497
- },
498
- parentNode(e) {
499
- return e.parent;
500
- },
501
- nextSibling(e) {
502
- return e.next;
503
- },
504
- cloneNode(e) {
505
- let t = new M(e.type);
506
- return e.type === "#text" ? C(o.CREATE_TEXT, t.id) : C(o.CREATE, t.id, e.type), E(), t;
507
- }
508
- };
509
- //#endregion
510
- //#region src/render.ts
511
- j();
512
- var { render: V } = e(B), H = !1, U = null, Oe = (e, t, n) => {
513
- if (j(), H && U) return console.log("[sigx-hmr] Non-component change — triggering full card reload"), W(), () => {};
514
- H = !0;
515
- let r = N();
516
- return U = r, V(e, r, n), D(), () => {
517
- V(null, r, n), D(), H = !1, U = null;
518
- };
519
- };
520
- t(Oe);
521
- function W() {
522
- try {
523
- if (typeof lynxCoreInject < "u" && lynxCoreInject?.tt) {
524
- let e = lynxCoreInject.tt.reloadCard;
525
- if (typeof e == "function") {
526
- e();
527
- return;
528
- }
529
- }
530
- if (typeof lynx < "u") {
531
- let e = lynx?.getNativeApp?.();
532
- if (e && typeof e.callLepusMethod == "function") {
533
- e.callLepusMethod("sigxReloadCard", {}, () => {});
534
- return;
535
- }
536
- }
537
- console.log("[sigx-hmr] No reload API available. Please manually reload the card.");
538
- } catch (e) {
539
- console.log("[sigx-hmr] triggerLiveReload error:", String(e));
540
- }
541
- }
542
- typeof module < "u" && module?.hot && module.hot.accept((e) => {
543
- e && (console.log("[sigx-hmr] Hot update failed, falling back to live reload:", String(e)), W());
544
- });
545
- //#endregion
546
- //#region src/animated/shared-value.ts
547
- var G = class extends F {
548
- _bgSignal;
549
- constructor(e) {
550
- super({ value: e });
551
- }
552
- _bind(e) {
553
- this._bgSignal = e;
554
- }
555
- get value() {
556
- return this._bgSignal.value;
557
- }
558
- set value(e) {
559
- globalThis.process?.env?.NODE_ENV !== "production" && console.warn("[sigx] SharedValue.value is read-only on the BG thread. Mutate via the MT worklet (sv.current.value = v).");
560
- }
561
- };
562
- function K(e) {
563
- let t = new G(e);
564
- return t._bind(m(t._wvid, e)), C(a.INIT_MT_REF, t._wvid, t._initValue), C(a.REGISTER_AV_BRIDGE, t._wvid, e), E(), c(() => {
565
- C(a.UNREGISTER_AV_BRIDGE, t._wvid), C(a.RELEASE_MT_REF, t._wvid), E(), h(t._wvid);
566
- }), t;
567
- }
568
- //#endregion
569
- //#region src/animated/use-animated-style.ts
570
- var q = 1;
571
- function ke() {
572
- q = 1;
573
- }
574
- function Ae() {
575
- return q++;
576
- }
577
- function je(e, t, n, r) {
578
- let i = Ae();
579
- C(a.REGISTER_AV_STYLE_BINDING, i, e._wvid, t._wvid, n, r ?? null), E(), c(() => {
580
- C(a.UNREGISTER_AV_STYLE_BINDING, i), E();
581
- });
582
- }
583
- //#endregion
584
- //#region src/threading.ts
585
- function Me(e) {
586
- return typeof e == "object" && !!e && "_wkltId" in e;
587
- }
588
- function Ne(e) {
589
- let t = {};
590
- for (let n in e) {
591
- let r = e[n];
592
- r instanceof F ? t[n] = {
593
- _wvid: r._wvid,
594
- _initValue: r._initValue
595
- } : t[n] = r;
596
- }
597
- return t;
598
- }
599
- function Pe(e) {
600
- if (typeof e == "function") return (...t) => {
601
- try {
602
- return Promise.resolve(e(...t));
603
- } catch (e) {
604
- return Promise.reject(e);
605
- }
606
- };
607
- if (!Me(e)) throw Error("runOnMainThread: argument is not a worklet placeholder. Did the build transform run?");
608
- let t = e._wkltId, n = e._c ? Ne(e._c) : void 0;
609
- return (...e) => new Promise((r) => {
610
- if (typeof lynx < "u") {
611
- let i = lynx?.getNativeApp?.();
612
- if (i && typeof i.callLepusMethod == "function") {
613
- i.callLepusMethod("sigxRunOnMT", {
614
- wkltId: t,
615
- args: e,
616
- captured: n
617
- }, (e) => r(e));
618
- return;
619
- }
620
- }
621
- let i = globalThis;
622
- if (typeof i.sigxRunOnMT == "function") {
623
- let a;
624
- i.sigxRunOnMT({
625
- wkltId: t,
626
- args: e,
627
- captured: n
628
- }, (e) => {
629
- a = e;
630
- }), r(a);
631
- return;
632
- }
633
- r(void 0);
634
- });
635
- }
636
- function Fe() {}
637
- //#endregion
638
- //#region src/native/gesture-detector.ts
639
- var J = {
640
- COMPOSED: -1,
641
- PAN: 0,
642
- FLING: 1,
643
- DEFAULT: 2,
644
- TAP: 3,
645
- LONGPRESS: 4,
646
- ROTATION: 5,
647
- PINCH: 6,
648
- NATIVE: 7
649
- }, Ie = 1;
650
- function Le() {
651
- Ie = 1;
652
- }
653
- function Re() {
654
- return Ie++;
655
- }
656
- var Y = class {
657
- gesture;
658
- constructor(e) {
659
- this.gesture = {
660
- __isSerialized: !0,
661
- type: e,
662
- id: Re(),
663
- callbacks: {},
664
- waitFor: [],
665
- simultaneousWith: [],
666
- continueWith: []
667
- };
668
- }
669
- setConfigKey(e, t) {
670
- return this.gesture.config || (this.gesture.config = {}), this.gesture.config[e] = t, this;
671
- }
672
- onBegin(e) {
673
- return this.gesture.callbacks.onBegin = e, this;
674
- }
675
- onStart(e) {
676
- return this.gesture.callbacks.onStart = e, this;
677
- }
678
- onUpdate(e) {
679
- return this.gesture.callbacks.onUpdate = e, this;
680
- }
681
- onEnd(e) {
682
- return this.gesture.callbacks.onEnd = e, this;
683
- }
684
- onFinalize(e) {
685
- return this.gesture.callbacks.onFinalize = e, this;
686
- }
687
- waitFor(...e) {
688
- return this.gesture.waitFor.push(...e), this;
689
- }
690
- simultaneousWith(...e) {
691
- return this.gesture.simultaneousWith.push(...e), this;
692
- }
693
- continueWith(...e) {
694
- return this.gesture.continueWith.push(...e), this;
695
- }
696
- build() {
697
- return this.gesture;
698
- }
699
- }, ze = class extends Y {
700
- constructor() {
701
- super(J.PAN);
702
- }
703
- axis(e) {
704
- return this.setConfigKey("axis", e);
705
- }
706
- minDistance(e) {
707
- return this.setConfigKey("minDistance", e);
708
- }
709
- }, Be = class extends Y {
710
- constructor() {
711
- super(J.FLING);
712
- }
713
- minVelocity(e) {
714
- return this.setConfigKey("minVelocity", e);
715
- }
716
- direction(e) {
717
- return this.setConfigKey("direction", e);
718
- }
719
- }, Ve = class extends Y {
720
- constructor() {
721
- super(J.TAP);
722
- }
723
- numberOfTaps(e) {
724
- return this.setConfigKey("numberOfTaps", e);
725
- }
726
- maxDistance(e) {
727
- return this.setConfigKey("maxDistance", e);
728
- }
729
- maxDuration(e) {
730
- return this.setConfigKey("maxDuration", e);
731
- }
732
- }, He = class extends Y {
733
- constructor() {
734
- super(J.LONGPRESS);
735
- }
736
- minDuration(e) {
737
- return this.setConfigKey("minDuration", e);
738
- }
739
- duration(e) {
740
- return this.setConfigKey("duration", e), this.setConfigKey("minDuration", e);
741
- }
742
- maxDistance(e) {
743
- return this.setConfigKey("maxDistance", e);
744
- }
745
- }, Ue = class extends Y {
746
- constructor() {
747
- super(J.PINCH);
748
- }
749
- }, We = class extends Y {
750
- constructor() {
751
- super(J.ROTATION);
752
- }
753
- }, Ge = class extends Y {
754
- constructor() {
755
- super(J.NATIVE);
756
- }
757
- };
758
- function Ke(e) {
759
- let t = Z(e), n = [];
760
- return X(t, n), n;
761
- }
762
- function X(e, t) {
763
- if (e.type === J.COMPOSED) {
764
- for (let n of e.gestures) X(n, t);
765
- return;
766
- }
767
- t.push(e);
768
- }
769
- function Z(e) {
770
- return e && typeof e.build == "function" && e.__isSerialized !== !0 ? e.build() : e;
771
- }
772
- function Q(e) {
773
- return {
774
- __isSerialized: !0,
775
- type: J.COMPOSED,
776
- gestures: e
777
- };
778
- }
779
- var qe = {
780
- Pan: () => new ze(),
781
- Fling: () => new Be(),
782
- Tap: () => new Ve(),
783
- LongPress: () => new He(),
784
- Pinch: () => new Ue(),
785
- Rotation: () => new We(),
786
- Native: () => new Ge(),
787
- Race(...e) {
788
- let t = Q(e.map(Z)), n = Ke(t);
789
- for (let e of n) for (let t of n) e !== t && e.waitFor.push(t);
790
- return t;
791
- },
792
- Simultaneous(...e) {
793
- let t = Q(e.map(Z)), n = Ke(t);
794
- for (let e of n) for (let t of n) e !== t && e.simultaneousWith.push(t);
795
- return t;
796
- },
797
- Exclusive(...e) {
798
- let t = e.map(Z), n = Q(t);
799
- for (let e = 1; e < t.length; e++) {
800
- let n = [];
801
- X(t[e], n);
802
- let r = [];
803
- for (let n = 0; n < e; n++) X(t[n], r);
804
- for (let e of n) e.waitFor.push(...r);
805
- }
806
- return n;
807
- }
808
- };
809
- function $(e, t, n) {
810
- if (e.type === J.COMPOSED) {
811
- for (let r of e.gestures) $(r, t, n);
812
- return;
813
- }
814
- let r = e;
815
- n.has(r.id) || (n.add(r.id), t.push(r));
816
- }
817
- function Je(e) {
818
- let t = [];
819
- for (let n in e.callbacks) {
820
- let r = e.callbacks[n], i = { ...r };
821
- r._c && (i._c = I(r._c)), fe(i), t.push({
822
- name: n,
823
- callback: i
824
- });
825
- }
826
- let n = { callbacks: t };
827
- return e.config && (n.config = e.config), n;
828
- }
829
- function Ye(e, t) {
830
- let n = Z(t), r = [];
831
- $(n, r, /* @__PURE__ */ new Set()), r.length !== 0 && (s(() => {
832
- for (let t of r) {
833
- let n = Je(t), r = {
834
- waitFor: t.waitFor.map((e) => e.id),
835
- simultaneous: t.simultaneousWith.map((e) => e.id),
836
- continueWith: t.continueWith.map((e) => e.id)
837
- };
838
- C(o.SET_GESTURE_DETECTOR, e._wvid, t.id, t.type, n, r);
839
- }
840
- E();
841
- }), c(() => {
842
- for (let t of r) C(o.REMOVE_GESTURE_DETECTOR, e._wvid, t.id);
843
- E();
844
- }));
845
- }
846
- //#endregion
847
- export { G as AnimatedValue, G as SharedValue, qe as Gesture, J as GestureType, F as MainThreadRef, i as OP, M as ShadowElement, ae as bgAvSinkCount, N as createPageRoot, D as flushNow, te as getHandler, g as ingestAvPublishes, Oe as lynxMount, B as nodeOps, f as publishEvent, C as pushOp, d as register, m as registerBgSink, V as render, ke as resetAnimatedStyleBindingIds, ie as resetBgAvBridge, Le as resetGestureIdCounter, ge as resetOpQueue, re as resetRegistry, he as resetRunOnBackgroundState, ye as resetShadowState, Fe as resetThreading, be as resetWvidCounter, me as runOnBackground, Pe as runOnMainThread, E as scheduleFlush, w as takeOps, ce as transformToWorklet, ne as unregister, h as unregisterBgSink, ee as updateHandler, je as useAnimatedStyle, K as useAnimatedValue, K as useSharedValue, Ye as useGestureDetector, xe as useMainThreadRef };
848
-
849
- //# sourceMappingURL=index.js.map
1
+ // Side-effect: importing this module registers lynxMount as the default mount,
2
+ // installs the platform model processor, augments PlatformTypes, and adds the
3
+ // global JSX intrinsic element types. Only activate when the app explicitly
4
+ // imports '@sigx/lynx-runtime'.
5
+ /// <reference path="./shims.d.ts" />
6
+ import './jsx.js';
7
+ import './types.js';
8
+ import './model-processor.js';
9
+ // Side-effect: subscribes to Lynx.Sigx.PublishEvent on the JS context so
10
+ // MT-side hybrid worklets can fire BG handlers via the existing event-registry.
11
+ import './bg-bridge.js';
12
+ // Side-effect (lazy): imports the runOnBackground module so its listener can
13
+ // be registered on the first registerWorkletCtx() call. The module's init()
14
+ // is gated to first-use, so this import is cheap.
15
+ import './run-on-background.js';
16
+ export { render, lynxMount } from './render.js';
17
+ export { nodeOps } from './nodeOps.js';
18
+ export { ShadowElement, createPageRoot, resetShadowState } from './shadow-element.js';
19
+ export { pushOp, takeOps, scheduleFlush, flushNow, resetOpQueue } from './op-queue.js';
20
+ export { OP } from '@sigx/lynx-runtime-internal';
21
+ export { register, updateHandler, unregister, getHandler, publishEvent, resetRegistry, } from './event-registry.js';
22
+ // ---------------------------------------------------------------------------
23
+ // Main Thread Script (MTS) APIs
24
+ // ---------------------------------------------------------------------------
25
+ export { MainThreadRef, useMainThreadRef, resetWvidCounter, } from './main-thread-ref.js';
26
+ export { useElementLayout } from './use-element-layout.js';
27
+ export { registerBgSink, unregisterBgSink, ingestAvPublishes, resetBgAvBridge, bgAvSinkCount, } from './animated-bridge.js';
28
+ export { useSharedValue, SharedValue, } from './animated/shared-value.js';
29
+ export { useAnimatedStyle, resetAnimatedStyleBindingIds, } from './animated/use-animated-style.js';
30
+ // @deprecated since Phase 2.8 — use `SharedValue` / `useSharedValue` /
31
+ // `SharedValueState` instead. Kept for one minor cycle.
32
+ export { useAnimatedValue, AnimatedValue, } from './animated/animated-value.js';
33
+ export { runOnMainThread, runOnBackground, resetThreading, transformToWorklet, resetRunOnBackgroundState, } from './threading.js';
34
+ // ---------------------------------------------------------------------------
35
+ // Native gesture detector — Gesture builder + useGestureDetector hook
36
+ // ---------------------------------------------------------------------------
37
+ export { Gesture, GestureType, useGestureDetector, resetGestureIdCounter, } from './native/index.js';