@lingxia/bridge 0.5.0
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/boot.d.ts +10 -0
- package/dist/bridge.d.ts +5 -0
- package/dist/error.d.ts +4 -0
- package/dist/image-proxy.d.ts +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/nativecomponents/coverage-monitor.d.ts +7 -0
- package/dist/runtime-env.d.ts +11 -0
- package/dist/runtime.es2020.js +1663 -0
- package/dist/runtime.es5.js +1 -0
- package/dist/types.d.ts +164 -0
- package/dist/ui/action-sheet.d.ts +5 -0
- package/dist/ui/index.d.ts +1 -0
- package/dist/ui/modal.d.ts +6 -0
- package/dist/ui/toast.d.ts +2 -0
- package/package.json +43 -0
|
@@ -0,0 +1,1663 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var LingXiaRuntime = (function(I) {
|
|
3
|
+
Object.defineProperty(I, Symbol.toStringTag, { value: "Module" });
|
|
4
|
+
const x = {
|
|
5
|
+
NOT_READY: "BRIDGE_NOT_READY",
|
|
6
|
+
TIMEOUT: "BRIDGE_TIMEOUT",
|
|
7
|
+
CANCELED: "BRIDGE_CANCELED",
|
|
8
|
+
PROTOCOL_MISMATCH: "BRIDGE_PROTOCOL_MISMATCH",
|
|
9
|
+
HANDSHAKE_FAILED: "BRIDGE_HANDSHAKE_FAILED",
|
|
10
|
+
MALFORMED_MESSAGE: "BRIDGE_MALFORMED_MESSAGE",
|
|
11
|
+
METHOD_NOT_FOUND: "BRIDGE_METHOD_NOT_FOUND",
|
|
12
|
+
TOPIC_NOT_FOUND: "BRIDGE_TOPIC_NOT_FOUND",
|
|
13
|
+
CAPABILITY_DENIED: "BRIDGE_CAPABILITY_DENIED",
|
|
14
|
+
INTERNAL_ERROR: "BRIDGE_INTERNAL_ERROR",
|
|
15
|
+
OUTBOX_FULL: "BRIDGE_OUTBOX_FULL",
|
|
16
|
+
STREAM_OVERFLOW: "BRIDGE_STREAM_OVERFLOW",
|
|
17
|
+
STREAM_CLOSED: "BRIDGE_STREAM_CLOSED"
|
|
18
|
+
};
|
|
19
|
+
function mt({ os: e, send: t }) {
|
|
20
|
+
if (typeof window > "u" || typeof document > "u") return;
|
|
21
|
+
const n = e === "iOS";
|
|
22
|
+
if (!n && e !== "Android") return;
|
|
23
|
+
const r = Symbol.for("LingXia.NativeComponentCoverageMonitor");
|
|
24
|
+
if (window[r]?.installed) return;
|
|
25
|
+
const o = {
|
|
26
|
+
installed: !0,
|
|
27
|
+
coveredById: /* @__PURE__ */ new Map(),
|
|
28
|
+
coveredCount: 0,
|
|
29
|
+
anyCovered: !1,
|
|
30
|
+
scheduled: !1,
|
|
31
|
+
hasAnyVideo: !1,
|
|
32
|
+
scrollLocked: !1,
|
|
33
|
+
scrollY: 0,
|
|
34
|
+
htmlOverflow: "",
|
|
35
|
+
bodyOverflow: "",
|
|
36
|
+
bodyPosition: "",
|
|
37
|
+
bodyTop: "",
|
|
38
|
+
bodyWidth: ""
|
|
39
|
+
};
|
|
40
|
+
window[r] = o;
|
|
41
|
+
function i() {
|
|
42
|
+
if (!n || o.scrollLocked) return;
|
|
43
|
+
const d = document.documentElement, m = document.body;
|
|
44
|
+
!d || !m || (o.scrollLocked = !0, o.scrollY = window.scrollY || d.scrollTop || 0, o.htmlOverflow = d.style.overflow || "", o.bodyOverflow = m.style.overflow || "", o.bodyPosition = m.style.position || "", o.bodyTop = m.style.top || "", o.bodyWidth = m.style.width || "", d.style.overflow = "hidden", m.style.overflow = "hidden", m.style.position = "fixed", m.style.top = `${-o.scrollY}px`, m.style.width = "100%");
|
|
45
|
+
}
|
|
46
|
+
function a() {
|
|
47
|
+
if (!n || !o.scrollLocked) return;
|
|
48
|
+
const d = document.documentElement, m = document.body;
|
|
49
|
+
!d || !m || (o.scrollLocked = !1, d.style.overflow = o.htmlOverflow, m.style.overflow = o.bodyOverflow, m.style.position = o.bodyPosition, m.style.top = o.bodyTop, m.style.width = o.bodyWidth, window.scrollTo(0, o.scrollY));
|
|
50
|
+
}
|
|
51
|
+
function s(d) {
|
|
52
|
+
const m = d.getBoundingClientRect?.();
|
|
53
|
+
if (!m || m.width < 2 || m.height < 2) return !1;
|
|
54
|
+
const y = m.left + m.width / 2, f = m.top + m.height / 2;
|
|
55
|
+
if (y < 0 || f < 0 || y >= window.innerWidth || f >= window.innerHeight) return !1;
|
|
56
|
+
const p = document.elementFromPoint?.(y, f);
|
|
57
|
+
return !p || p === document.documentElement || p === document.body ? !1 : !(p === d || d.contains(p));
|
|
58
|
+
}
|
|
59
|
+
function u() {
|
|
60
|
+
o.scheduled = !1;
|
|
61
|
+
const d = document.querySelectorAll("lx-video[id]");
|
|
62
|
+
if (o.hasAnyVideo = d.length > 0, !o.hasAnyVideo && o.coveredById.size === 0 && !o.anyCovered) return;
|
|
63
|
+
const m = /* @__PURE__ */ new Set();
|
|
64
|
+
for (const p of Array.from(d)) {
|
|
65
|
+
const g = p.id;
|
|
66
|
+
if (!g) continue;
|
|
67
|
+
m.add(g);
|
|
68
|
+
const ce = s(p), ut = o.coveredById.get(g);
|
|
69
|
+
ut !== ce && (ut === !0 && (o.coveredCount -= 1), ce === !0 && (o.coveredCount += 1), o.coveredById.set(g, ce), t({
|
|
70
|
+
id: g,
|
|
71
|
+
action: "component.coverage",
|
|
72
|
+
covered: ce
|
|
73
|
+
}));
|
|
74
|
+
}
|
|
75
|
+
const y = [];
|
|
76
|
+
for (const [p, g] of o.coveredById.entries()) m.has(p) || (y.push(p), g === !0 && (o.coveredCount -= 1));
|
|
77
|
+
for (const p of y) o.coveredById.delete(p), t({
|
|
78
|
+
id: p,
|
|
79
|
+
action: "component.coverage",
|
|
80
|
+
covered: !1
|
|
81
|
+
});
|
|
82
|
+
const f = o.coveredCount > 0;
|
|
83
|
+
f !== o.anyCovered && (o.anyCovered = f, n && (f ? i() : a()));
|
|
84
|
+
}
|
|
85
|
+
function l() {
|
|
86
|
+
o.scheduled || (o.scheduled = !0, requestAnimationFrame(u));
|
|
87
|
+
}
|
|
88
|
+
function c() {
|
|
89
|
+
!o.hasAnyVideo && o.coveredById.size === 0 || l();
|
|
90
|
+
}
|
|
91
|
+
new MutationObserver(l).observe(document.documentElement, {
|
|
92
|
+
subtree: !0,
|
|
93
|
+
childList: !0,
|
|
94
|
+
attributes: !0
|
|
95
|
+
}), window.addEventListener("scroll", { handleEvent: () => c() }, {
|
|
96
|
+
capture: !0,
|
|
97
|
+
passive: !0
|
|
98
|
+
}), window.addEventListener("resize", { handleEvent: () => l() }), l();
|
|
99
|
+
}
|
|
100
|
+
const _ = typeof window < "u" && window.__LX_BRIDGE_CFG || {};
|
|
101
|
+
function W() {
|
|
102
|
+
return _.os || "unknown";
|
|
103
|
+
}
|
|
104
|
+
function ft() {
|
|
105
|
+
return _.os === "Harmony";
|
|
106
|
+
}
|
|
107
|
+
function _e() {
|
|
108
|
+
return _.os === "iOS";
|
|
109
|
+
}
|
|
110
|
+
function pt() {
|
|
111
|
+
return _.os === "Android";
|
|
112
|
+
}
|
|
113
|
+
function de() {
|
|
114
|
+
return _.os === "macOS";
|
|
115
|
+
}
|
|
116
|
+
function ht() {
|
|
117
|
+
return de();
|
|
118
|
+
}
|
|
119
|
+
function gt() {
|
|
120
|
+
return _.os === "iOS" || _.os === "macOS" ? "webkit" : _.os === "Harmony" ? "messageport" : _.os === "Android" ? window.LingXiaProxy?.supportsMessagePort?.() ? "messageport" : "jsinterface" : "unknown";
|
|
121
|
+
}
|
|
122
|
+
const yt = "LingXia", ue = "__LingXiaRecvMessage", me = 5e3, xt = 1e4, Me = 3, fe = "[LX.Bridge]", z = "messageport", pe = "jsinterface", bt = 256, wt = "/__lingxia/bridge/downstream", Le = 200, vt = 2e3, he = {
|
|
123
|
+
data: !1,
|
|
124
|
+
proto: !1,
|
|
125
|
+
all: !1
|
|
126
|
+
}, Y = [];
|
|
127
|
+
function Et() {
|
|
128
|
+
typeof window > "u" || typeof window[ue] != "function" && (window[ue] = (e) => {
|
|
129
|
+
Y.push(e);
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
function kt(e) {
|
|
133
|
+
if (typeof window > "u" || (window[ue] = e, Y.length === 0)) return;
|
|
134
|
+
const t = Y.splice(0, Y.length);
|
|
135
|
+
for (const n of t) try {
|
|
136
|
+
e(n);
|
|
137
|
+
} catch (r) {
|
|
138
|
+
h("Failed to replay queued native message:", r);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
function B(e) {
|
|
142
|
+
return he.all || he[e];
|
|
143
|
+
}
|
|
144
|
+
function $(...e) {
|
|
145
|
+
console.log(fe, ...e);
|
|
146
|
+
}
|
|
147
|
+
function h(...e) {
|
|
148
|
+
console.warn(fe, ...e);
|
|
149
|
+
}
|
|
150
|
+
function L(...e) {
|
|
151
|
+
console.error(fe, ...e);
|
|
152
|
+
}
|
|
153
|
+
function Ct(e, t) {
|
|
154
|
+
const n = /* @__PURE__ */ new WeakSet();
|
|
155
|
+
return JSON.stringify(e, (r, o) => {
|
|
156
|
+
if (typeof o == "object" && o !== null) {
|
|
157
|
+
if (n.has(o)) return "[Circular]";
|
|
158
|
+
n.add(o);
|
|
159
|
+
}
|
|
160
|
+
return o;
|
|
161
|
+
}, t);
|
|
162
|
+
}
|
|
163
|
+
function Oe(e) {
|
|
164
|
+
try {
|
|
165
|
+
return JSON.stringify(e);
|
|
166
|
+
} catch {
|
|
167
|
+
return Ct(e);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
function H(e) {
|
|
171
|
+
try {
|
|
172
|
+
return typeof structuredClone == "function" ? structuredClone(e) : JSON.parse(JSON.stringify(e));
|
|
173
|
+
} catch {
|
|
174
|
+
return {};
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
var j = class extends Error {
|
|
178
|
+
constructor(e, t, n) {
|
|
179
|
+
super(t), this.name = "BridgeError", this.code = e, this.data = n;
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
function U(e) {
|
|
183
|
+
if (e instanceof j) return e;
|
|
184
|
+
if (e && typeof e == "object") {
|
|
185
|
+
const n = e;
|
|
186
|
+
let r = x.INTERNAL_ERROR;
|
|
187
|
+
(typeof n.code == "string" && n.code.trim() !== "" || typeof n.code == "number" && Number.isFinite(n.code)) && (r = n.code);
|
|
188
|
+
const o = typeof n.message == "string" && n.message.trim() !== "" ? n.message : "Unknown error";
|
|
189
|
+
return new j(r, o, "data" in n ? n.data : void 0);
|
|
190
|
+
}
|
|
191
|
+
const t = e instanceof Error ? e.message : typeof e == "string" ? e : "Unknown error";
|
|
192
|
+
return new j(x.INTERNAL_ERROR, t);
|
|
193
|
+
}
|
|
194
|
+
const k = gt();
|
|
195
|
+
Et();
|
|
196
|
+
let M = null, J = !1, ge = null, V = null, G = null, K = Le;
|
|
197
|
+
const b = {
|
|
198
|
+
listenerInstalled: !1,
|
|
199
|
+
promise: null,
|
|
200
|
+
resolve: null,
|
|
201
|
+
reject: null,
|
|
202
|
+
timer: null
|
|
203
|
+
}, It = { handleEvent: (e) => {
|
|
204
|
+
const t = e;
|
|
205
|
+
if (t.data !== "LingXia-port-init") return;
|
|
206
|
+
const n = t.ports?.[0];
|
|
207
|
+
n && (P._connectWebMessagePort(n), b.resolve?.(n));
|
|
208
|
+
} };
|
|
209
|
+
function Te() {
|
|
210
|
+
b.listenerInstalled || (b.listenerInstalled = !0, window.addEventListener("message", It));
|
|
211
|
+
}
|
|
212
|
+
function Se() {
|
|
213
|
+
b.timer !== null && (window.clearTimeout(b.timer), b.timer = null), b.resolve = null, b.reject = null, b.promise = null;
|
|
214
|
+
}
|
|
215
|
+
function Q() {
|
|
216
|
+
return k === "webkit" && (_e() || de());
|
|
217
|
+
}
|
|
218
|
+
function Ae() {
|
|
219
|
+
G !== null && (clearTimeout(G), G = null);
|
|
220
|
+
}
|
|
221
|
+
function _t(e) {
|
|
222
|
+
for (const [t, n] of Array.from(D.entries())) D.delete(t), n._emitClose(x.STREAM_CLOSED, e);
|
|
223
|
+
}
|
|
224
|
+
function Mt(e) {
|
|
225
|
+
for (const t of Array.from(v.keys())) q(t, {
|
|
226
|
+
code: x.STREAM_CLOSED,
|
|
227
|
+
message: e
|
|
228
|
+
});
|
|
229
|
+
for (const t of Array.from(w.keys())) re(t, {
|
|
230
|
+
code: x.STREAM_CLOSED,
|
|
231
|
+
message: e
|
|
232
|
+
});
|
|
233
|
+
_t(e);
|
|
234
|
+
}
|
|
235
|
+
function Lt(e, t) {
|
|
236
|
+
ie(), Z = null, S = !1, A = !1, F = 0, t && Mt(e);
|
|
237
|
+
}
|
|
238
|
+
function Ot(e) {
|
|
239
|
+
let t = e;
|
|
240
|
+
for (;;) {
|
|
241
|
+
const n = t.indexOf(`
|
|
242
|
+
`);
|
|
243
|
+
if (n < 0) break;
|
|
244
|
+
const r = t.slice(0, n).trim();
|
|
245
|
+
if (t = t.slice(n + 1), !!r) try {
|
|
246
|
+
se(JSON.parse(r));
|
|
247
|
+
} catch (o) {
|
|
248
|
+
h("Apple downstream parse error:", o, r);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
return t;
|
|
252
|
+
}
|
|
253
|
+
async function Tt() {
|
|
254
|
+
const e = new AbortController();
|
|
255
|
+
V = e;
|
|
256
|
+
let t;
|
|
257
|
+
try {
|
|
258
|
+
t = await fetch(wt, {
|
|
259
|
+
method: "GET",
|
|
260
|
+
cache: "no-store",
|
|
261
|
+
headers: { Accept: "application/x-ndjson" },
|
|
262
|
+
signal: e.signal
|
|
263
|
+
});
|
|
264
|
+
} catch (i) {
|
|
265
|
+
if (e.signal.aborted) return;
|
|
266
|
+
throw i;
|
|
267
|
+
}
|
|
268
|
+
if (!t.ok) throw new Error(`Apple downstream HTTP ${t.status}`);
|
|
269
|
+
if (!t.body) throw new Error("Apple downstream response body unavailable");
|
|
270
|
+
J = !0, K = Le, B("proto") && $("Apple downstream connected"), R();
|
|
271
|
+
const n = t.body.getReader(), r = new TextDecoder();
|
|
272
|
+
let o = "";
|
|
273
|
+
try {
|
|
274
|
+
for (;;) {
|
|
275
|
+
const { value: a, done: s } = await n.read();
|
|
276
|
+
if (s) break;
|
|
277
|
+
o += r.decode(a, { stream: !0 }), o = Ot(o);
|
|
278
|
+
}
|
|
279
|
+
o += r.decode();
|
|
280
|
+
const i = o.trim();
|
|
281
|
+
if (i) try {
|
|
282
|
+
se(JSON.parse(i));
|
|
283
|
+
} catch (a) {
|
|
284
|
+
h("Apple downstream trailing parse error:", a, i);
|
|
285
|
+
}
|
|
286
|
+
} finally {
|
|
287
|
+
try {
|
|
288
|
+
n.releaseLock();
|
|
289
|
+
} catch {}
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
function St(e) {
|
|
293
|
+
if (!Q()) return;
|
|
294
|
+
Ae();
|
|
295
|
+
const t = K;
|
|
296
|
+
K = Math.min(K * 2, vt), h(`Apple downstream disconnected, retrying in ${t}ms: ${e}`), G = setTimeout(() => {
|
|
297
|
+
G = null, Ne();
|
|
298
|
+
}, t);
|
|
299
|
+
}
|
|
300
|
+
function Ne() {
|
|
301
|
+
Q() && (ge || (Ae(), ge = Tt().catch((e) => {
|
|
302
|
+
V?.signal.aborted || h("Apple downstream failed:", e);
|
|
303
|
+
}).finally(() => {
|
|
304
|
+
const e = V?.signal.aborted ?? !1;
|
|
305
|
+
ge = null, V = null;
|
|
306
|
+
const t = J;
|
|
307
|
+
J = !1, Lt("Apple downstream closed", t), e || St("stream closed");
|
|
308
|
+
})));
|
|
309
|
+
}
|
|
310
|
+
function At() {
|
|
311
|
+
if (M) return Promise.resolve(M);
|
|
312
|
+
if (b.promise) return b.promise;
|
|
313
|
+
const e = 5e3;
|
|
314
|
+
Te(), b.promise = new Promise((t, n) => {
|
|
315
|
+
b.resolve = (r) => {
|
|
316
|
+
Se(), t(r);
|
|
317
|
+
}, b.reject = (r) => {
|
|
318
|
+
Se(), n(r);
|
|
319
|
+
}, b.timer = window.setTimeout(() => {
|
|
320
|
+
b.reject?.(/* @__PURE__ */ new Error(`MessagePort init timed out after ${e}ms`));
|
|
321
|
+
}, e);
|
|
322
|
+
});
|
|
323
|
+
try {
|
|
324
|
+
window.LingXiaProxy?.getPort("LingXiaPort");
|
|
325
|
+
} catch (t) {
|
|
326
|
+
b.reject?.(t);
|
|
327
|
+
}
|
|
328
|
+
return b.promise;
|
|
329
|
+
}
|
|
330
|
+
function ye(e) {
|
|
331
|
+
const t = e.kind;
|
|
332
|
+
(t === "req" || t === "notify") && $(`postToNative: ${t} ${e.method}`), B("proto") && console.log("→", JSON.stringify(e, null, 2));
|
|
333
|
+
try {
|
|
334
|
+
if (k === "webkit") {
|
|
335
|
+
window.webkit?.messageHandlers[yt]?.postMessage(e);
|
|
336
|
+
return;
|
|
337
|
+
}
|
|
338
|
+
const n = Oe(e);
|
|
339
|
+
if (k === z && M) {
|
|
340
|
+
M.postMessage(n);
|
|
341
|
+
return;
|
|
342
|
+
}
|
|
343
|
+
if (k === pe && window.LingXiaProxy?.postMessage) {
|
|
344
|
+
window.LingXiaProxy.postMessage(n);
|
|
345
|
+
return;
|
|
346
|
+
}
|
|
347
|
+
h("Transport not ready");
|
|
348
|
+
} catch (n) {
|
|
349
|
+
L("Send error:", n);
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
let Z = null, S = !1, A = !1, F = 0, ee = null;
|
|
353
|
+
const Re = {};
|
|
354
|
+
let Nt = 0;
|
|
355
|
+
function Pe() {
|
|
356
|
+
return {
|
|
357
|
+
data: /* @__PURE__ */ new Set(),
|
|
358
|
+
end: /* @__PURE__ */ new Set(),
|
|
359
|
+
error: /* @__PURE__ */ new Set(),
|
|
360
|
+
close: /* @__PURE__ */ new Set()
|
|
361
|
+
};
|
|
362
|
+
}
|
|
363
|
+
function De(e, t) {
|
|
364
|
+
const n = Pe();
|
|
365
|
+
let r = !1, o = () => {}, i = () => {};
|
|
366
|
+
const a = [], s = [], u = new Promise((l, c) => {
|
|
367
|
+
o = l, i = c;
|
|
368
|
+
});
|
|
369
|
+
return {
|
|
370
|
+
id: e,
|
|
371
|
+
result: u,
|
|
372
|
+
on(l, c) {
|
|
373
|
+
return l === "data" && n.data.add(c), l === "end" && n.end.add(c), l === "error" && n.error.add(c), this;
|
|
374
|
+
},
|
|
375
|
+
[Symbol.asyncIterator]() {
|
|
376
|
+
return { next() {
|
|
377
|
+
return a.length > 0 ? Promise.resolve({
|
|
378
|
+
done: !1,
|
|
379
|
+
value: a.shift()
|
|
380
|
+
}) : r ? u.then((l) => ({
|
|
381
|
+
done: !0,
|
|
382
|
+
value: l
|
|
383
|
+
}), (l) => Promise.reject(l)) : new Promise((l, c) => {
|
|
384
|
+
s.push({
|
|
385
|
+
resolve: l,
|
|
386
|
+
reject: c
|
|
387
|
+
});
|
|
388
|
+
});
|
|
389
|
+
} };
|
|
390
|
+
},
|
|
391
|
+
cancel() {
|
|
392
|
+
r || t();
|
|
393
|
+
},
|
|
394
|
+
_emitData(l) {
|
|
395
|
+
if (!r) {
|
|
396
|
+
s.length > 0 ? s.shift().resolve({
|
|
397
|
+
done: !1,
|
|
398
|
+
value: l
|
|
399
|
+
}) : a.push(l);
|
|
400
|
+
for (const c of n.data) try {
|
|
401
|
+
c(l);
|
|
402
|
+
} catch (d) {
|
|
403
|
+
h("Stream data listener failed:", d);
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
},
|
|
407
|
+
_resolve(l) {
|
|
408
|
+
if (!r) {
|
|
409
|
+
for (r = !0, o(l); s.length > 0;) s.shift().resolve({
|
|
410
|
+
done: !0,
|
|
411
|
+
value: l
|
|
412
|
+
});
|
|
413
|
+
for (const c of n.end) try {
|
|
414
|
+
c(l);
|
|
415
|
+
} catch (d) {
|
|
416
|
+
h("Stream end listener failed:", d);
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
},
|
|
420
|
+
_reject(l) {
|
|
421
|
+
if (!r) {
|
|
422
|
+
for (r = !0, i(l); s.length > 0;) s.shift().reject(l);
|
|
423
|
+
for (const c of n.error) try {
|
|
424
|
+
c(l);
|
|
425
|
+
} catch (d) {
|
|
426
|
+
h("Stream error listener failed:", d);
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
};
|
|
431
|
+
}
|
|
432
|
+
function Rt(e, t, n) {
|
|
433
|
+
const r = Pe();
|
|
434
|
+
let o = !1, i = 0, a = !1;
|
|
435
|
+
const s = [], u = [], l = {
|
|
436
|
+
id: e,
|
|
437
|
+
send(c) {
|
|
438
|
+
if (!o) {
|
|
439
|
+
l._reject({
|
|
440
|
+
code: x.STREAM_CLOSED,
|
|
441
|
+
message: `Channel '${e}' is closed`
|
|
442
|
+
});
|
|
443
|
+
return;
|
|
444
|
+
}
|
|
445
|
+
t(c, i++);
|
|
446
|
+
},
|
|
447
|
+
on(c, d) {
|
|
448
|
+
return c === "data" && r.data.add(d), c === "close" && r.close.add(d), c === "error" && r.error.add(d), this;
|
|
449
|
+
},
|
|
450
|
+
[Symbol.asyncIterator]() {
|
|
451
|
+
return { next() {
|
|
452
|
+
return s.length > 0 ? Promise.resolve({
|
|
453
|
+
done: !1,
|
|
454
|
+
value: s.shift()
|
|
455
|
+
}) : a ? Promise.resolve({
|
|
456
|
+
done: !0,
|
|
457
|
+
value: void 0
|
|
458
|
+
}) : new Promise((c, d) => {
|
|
459
|
+
u.push({
|
|
460
|
+
resolve: c,
|
|
461
|
+
reject: d
|
|
462
|
+
});
|
|
463
|
+
});
|
|
464
|
+
} };
|
|
465
|
+
},
|
|
466
|
+
close(c, d) {
|
|
467
|
+
o && (o = !1, a = !0, n(c, d), l._emitClose(c, d));
|
|
468
|
+
},
|
|
469
|
+
_emitData(c) {
|
|
470
|
+
if (o) {
|
|
471
|
+
u.length > 0 ? u.shift().resolve({
|
|
472
|
+
done: !1,
|
|
473
|
+
value: c
|
|
474
|
+
}) : s.push(c);
|
|
475
|
+
for (const d of r.data) try {
|
|
476
|
+
d(c);
|
|
477
|
+
} catch (m) {
|
|
478
|
+
h("Channel listener failed:", m);
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
},
|
|
482
|
+
_emitClose(c, d) {
|
|
483
|
+
for (a = !0; u.length > 0;) u.shift().resolve({
|
|
484
|
+
done: !0,
|
|
485
|
+
value: void 0
|
|
486
|
+
});
|
|
487
|
+
for (const m of r.close) try {
|
|
488
|
+
m(c, d);
|
|
489
|
+
} catch (y) {
|
|
490
|
+
h("Channel close listener failed:", y);
|
|
491
|
+
}
|
|
492
|
+
},
|
|
493
|
+
_reject(c) {
|
|
494
|
+
for (a = !0; u.length > 0;) u.shift().reject(c);
|
|
495
|
+
for (const d of r.error) try {
|
|
496
|
+
d(c);
|
|
497
|
+
} catch (m) {
|
|
498
|
+
h("Channel error listener failed:", m);
|
|
499
|
+
}
|
|
500
|
+
},
|
|
501
|
+
_markOpen() {
|
|
502
|
+
o = !0, a = !1;
|
|
503
|
+
},
|
|
504
|
+
_isOpen() {
|
|
505
|
+
return o;
|
|
506
|
+
},
|
|
507
|
+
_nextSeq() {
|
|
508
|
+
return i++;
|
|
509
|
+
}
|
|
510
|
+
};
|
|
511
|
+
return l;
|
|
512
|
+
}
|
|
513
|
+
const v = /* @__PURE__ */ new Map(), w = /* @__PURE__ */ new Map(), D = /* @__PURE__ */ new Map(), O = [];
|
|
514
|
+
let C = -1, N = {};
|
|
515
|
+
const xe = /* @__PURE__ */ new Set(), te = /* @__PURE__ */ new WeakMap(), Be = /* @__PURE__ */ new Map();
|
|
516
|
+
function ne(e, t) {
|
|
517
|
+
Be.set(e, t);
|
|
518
|
+
}
|
|
519
|
+
function X(e) {
|
|
520
|
+
if (e.startsWith("host.")) return "host";
|
|
521
|
+
const t = e.indexOf(".");
|
|
522
|
+
return t > 0 ? e.slice(0, t) : "page";
|
|
523
|
+
}
|
|
524
|
+
function oe(e) {
|
|
525
|
+
if (e != null) return e;
|
|
526
|
+
}
|
|
527
|
+
function $e() {
|
|
528
|
+
return k === z ? !!M : Q() ? J : k === "webkit" || k === pe;
|
|
529
|
+
}
|
|
530
|
+
function je() {
|
|
531
|
+
return $e() && S;
|
|
532
|
+
}
|
|
533
|
+
function q(e, t) {
|
|
534
|
+
const n = v.get(e);
|
|
535
|
+
if (n) {
|
|
536
|
+
v.delete(e), n.timerId !== null && clearTimeout(n.timerId);
|
|
537
|
+
const r = U(t);
|
|
538
|
+
if (n.mode === "stream" && n.stream) {
|
|
539
|
+
n.stream._reject(r);
|
|
540
|
+
return;
|
|
541
|
+
}
|
|
542
|
+
n.reject?.(r);
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
function re(e, t) {
|
|
546
|
+
const n = w.get(e);
|
|
547
|
+
if (!n) return;
|
|
548
|
+
w.delete(e), n.timerId !== null && clearTimeout(n.timerId);
|
|
549
|
+
const r = U(t);
|
|
550
|
+
n.channel._reject(r), n.reject(r);
|
|
551
|
+
}
|
|
552
|
+
function Fe(e, t) {
|
|
553
|
+
if (v.has(e)) {
|
|
554
|
+
q(e, t);
|
|
555
|
+
return;
|
|
556
|
+
}
|
|
557
|
+
w.has(e) && re(e, t);
|
|
558
|
+
}
|
|
559
|
+
function He(e) {
|
|
560
|
+
const t = v.get(e);
|
|
561
|
+
if (t) {
|
|
562
|
+
if (!Number.isFinite(t.timeoutMs) || t.timeoutMs <= 0) {
|
|
563
|
+
t.timerId !== null && (clearTimeout(t.timerId), t.timerId = null);
|
|
564
|
+
return;
|
|
565
|
+
}
|
|
566
|
+
t.timerId !== null && clearTimeout(t.timerId), t.timerId = setTimeout(() => {
|
|
567
|
+
v.has(e) && q(e, new j(x.TIMEOUT, `'${t.method}' timed out`));
|
|
568
|
+
}, t.timeoutMs);
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
function Pt(e) {
|
|
572
|
+
const t = w.get(e);
|
|
573
|
+
t && (t.timerId !== null && clearTimeout(t.timerId), t.timerId = setTimeout(() => {
|
|
574
|
+
re(e, {
|
|
575
|
+
code: x.TIMEOUT,
|
|
576
|
+
message: `Channel '${t.topic}' timed out`
|
|
577
|
+
});
|
|
578
|
+
}, me));
|
|
579
|
+
}
|
|
580
|
+
function Ue(e) {
|
|
581
|
+
if (v.has(e)) {
|
|
582
|
+
He(e);
|
|
583
|
+
return;
|
|
584
|
+
}
|
|
585
|
+
w.has(e) && Pt(e);
|
|
586
|
+
}
|
|
587
|
+
function Ge(e) {
|
|
588
|
+
for (let t = O.length - 1; t >= 0; t--) if (O[t]?.reqId === e) return O.splice(t, 1), !0;
|
|
589
|
+
return !1;
|
|
590
|
+
}
|
|
591
|
+
function E(e, t) {
|
|
592
|
+
const n = e.kind, r = n === "hello" || n === "helloAck" || n === "ready";
|
|
593
|
+
if (!je() && !r) {
|
|
594
|
+
if (O.length >= bt) {
|
|
595
|
+
L("Outbox full"), t && Fe(t, {
|
|
596
|
+
code: x.OUTBOX_FULL,
|
|
597
|
+
message: "Bridge outbox is full"
|
|
598
|
+
});
|
|
599
|
+
return;
|
|
600
|
+
}
|
|
601
|
+
O.push({
|
|
602
|
+
msg: e,
|
|
603
|
+
reqId: t
|
|
604
|
+
});
|
|
605
|
+
return;
|
|
606
|
+
}
|
|
607
|
+
t && Ue(t), ye(e);
|
|
608
|
+
}
|
|
609
|
+
function Dt() {
|
|
610
|
+
if (je()) for (; O.length;) {
|
|
611
|
+
const e = O.shift();
|
|
612
|
+
e && (e.reqId && Ue(e.reqId), ye(e.msg));
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
function ie() {
|
|
616
|
+
ee !== null && (clearTimeout(ee), ee = null);
|
|
617
|
+
}
|
|
618
|
+
function R() {
|
|
619
|
+
if (S || !$e()) return;
|
|
620
|
+
ie();
|
|
621
|
+
const e = {
|
|
622
|
+
v: 2,
|
|
623
|
+
kind: "hello",
|
|
624
|
+
nonce: _.nonce || "",
|
|
625
|
+
role: "view",
|
|
626
|
+
protocolsSupported: [2]
|
|
627
|
+
};
|
|
628
|
+
A = !0, ye(e), ee = setTimeout(() => {
|
|
629
|
+
if (!S) if (F++, F < Me) h(`Handshake timeout (${F}/${Me}), retrying...`), A = !1, R();
|
|
630
|
+
else {
|
|
631
|
+
for (L("Handshake failed"), ie(), A = !1, F = 0; O.length;) {
|
|
632
|
+
const t = O.shift();
|
|
633
|
+
t?.reqId && Fe(t.reqId, {
|
|
634
|
+
code: x.HANDSHAKE_FAILED,
|
|
635
|
+
message: "Bridge handshake failed"
|
|
636
|
+
});
|
|
637
|
+
}
|
|
638
|
+
for (const t of Array.from(w.keys())) re(t, {
|
|
639
|
+
code: x.HANDSHAKE_FAILED,
|
|
640
|
+
message: "Bridge handshake failed"
|
|
641
|
+
});
|
|
642
|
+
}
|
|
643
|
+
}, xt);
|
|
644
|
+
}
|
|
645
|
+
function Bt(e) {
|
|
646
|
+
if (!e || typeof e != "object") return null;
|
|
647
|
+
const t = e.v, n = e.kind;
|
|
648
|
+
return t !== 2 || typeof n != "string" ? null : e;
|
|
649
|
+
}
|
|
650
|
+
function $t(e) {
|
|
651
|
+
return e.replace(/~1/g, "/").replace(/~0/g, "~");
|
|
652
|
+
}
|
|
653
|
+
function jt(e) {
|
|
654
|
+
if (e === "") return [];
|
|
655
|
+
if (!e.startsWith("/")) throw new Error(`Invalid JSON pointer: ${e}`);
|
|
656
|
+
return e.split("/").slice(1).map($t);
|
|
657
|
+
}
|
|
658
|
+
function Ft(e, t, n = !1) {
|
|
659
|
+
const r = jt(t);
|
|
660
|
+
if (r.length === 0) return {
|
|
661
|
+
container: { $root: e },
|
|
662
|
+
key: "$root"
|
|
663
|
+
};
|
|
664
|
+
let o = e;
|
|
665
|
+
for (let i = 0; i < r.length - 1; i++) {
|
|
666
|
+
const a = r[i];
|
|
667
|
+
if (Array.isArray(o)) o = o[Number(a)];
|
|
668
|
+
else if (o && typeof o == "object") {
|
|
669
|
+
const s = o;
|
|
670
|
+
if (n && s[a] === void 0) {
|
|
671
|
+
const u = r[i + 1];
|
|
672
|
+
s[a] = u && /^\d+$/.test(u) ? [] : {};
|
|
673
|
+
}
|
|
674
|
+
o = s[a];
|
|
675
|
+
} else throw new Error(`Invalid container at ${a}`);
|
|
676
|
+
}
|
|
677
|
+
return {
|
|
678
|
+
container: o,
|
|
679
|
+
key: r[r.length - 1]
|
|
680
|
+
};
|
|
681
|
+
}
|
|
682
|
+
function Ht(e, t) {
|
|
683
|
+
for (const n of t) {
|
|
684
|
+
const r = n.op === "add" || n.op === "replace", { container: o, key: i } = Ft(e, n.path, r);
|
|
685
|
+
if (i === "$root") {
|
|
686
|
+
for (const s of Object.keys(e)) delete e[s];
|
|
687
|
+
if (n.op !== "remove") {
|
|
688
|
+
const s = n.value;
|
|
689
|
+
s && typeof s == "object" && Object.assign(e, s);
|
|
690
|
+
}
|
|
691
|
+
continue;
|
|
692
|
+
}
|
|
693
|
+
if (Array.isArray(o)) {
|
|
694
|
+
const s = i === "-" ? o.length : Number(i);
|
|
695
|
+
if (!Number.isFinite(s) || s < 0) throw new Error("Invalid index");
|
|
696
|
+
n.op === "remove" ? o.splice(s, 1) : n.op === "add" ? o.splice(s, 0, n.value) : n.op === "replace" && (o[s] = n.value);
|
|
697
|
+
continue;
|
|
698
|
+
}
|
|
699
|
+
if (!o || typeof o != "object") throw new Error("Invalid container");
|
|
700
|
+
const a = o;
|
|
701
|
+
n.op === "remove" ? delete a[i] : a[i] = n.value;
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
function be(e) {
|
|
705
|
+
xe.forEach((t) => {
|
|
706
|
+
try {
|
|
707
|
+
if (!te.has(t)) {
|
|
708
|
+
te.set(t, !0), t(H(N), {
|
|
709
|
+
rev: C,
|
|
710
|
+
initial: !0
|
|
711
|
+
});
|
|
712
|
+
return;
|
|
713
|
+
}
|
|
714
|
+
t(H(N), {
|
|
715
|
+
rev: C,
|
|
716
|
+
initial: e
|
|
717
|
+
});
|
|
718
|
+
} catch (n) {
|
|
719
|
+
h("Subscriber error:", n);
|
|
720
|
+
}
|
|
721
|
+
});
|
|
722
|
+
}
|
|
723
|
+
function Ut(e) {
|
|
724
|
+
if (typeof e != "function") return () => {};
|
|
725
|
+
if (xe.add(e), C >= 0) {
|
|
726
|
+
te.set(e, !0);
|
|
727
|
+
try {
|
|
728
|
+
e(H(N), {
|
|
729
|
+
rev: C,
|
|
730
|
+
initial: !0
|
|
731
|
+
});
|
|
732
|
+
} catch (t) {
|
|
733
|
+
L("Callback error:", t);
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
return () => {
|
|
737
|
+
xe.delete(e), te.delete(e);
|
|
738
|
+
};
|
|
739
|
+
}
|
|
740
|
+
function Xe(e) {
|
|
741
|
+
P.call("state.getSnapshot", { scope: e }).catch(() => {});
|
|
742
|
+
}
|
|
743
|
+
function Gt(e) {
|
|
744
|
+
if (!e || typeof e != "object") return !1;
|
|
745
|
+
const t = e;
|
|
746
|
+
return typeof t.rev != "number" || !Number.isFinite(t.rev) || !t.state || typeof t.state != "object" ? !1 : (N = t.state, C = t.rev, B("data") && (console.group("[LX] snapshot(res)"), console.log("rev:", C, "state:", H(N)), console.groupEnd()), be(!0), !0);
|
|
747
|
+
}
|
|
748
|
+
function se(e) {
|
|
749
|
+
if (e && typeof e == "object") {
|
|
750
|
+
const n = e;
|
|
751
|
+
if (n.type === "event" && n.name === "nativecomponent" && n.payload) {
|
|
752
|
+
const r = n.payload, o = r.id || r.componentId;
|
|
753
|
+
if (typeof o == "string") {
|
|
754
|
+
const i = ae.get(o);
|
|
755
|
+
if (i) try {
|
|
756
|
+
i(r);
|
|
757
|
+
} catch (a) {
|
|
758
|
+
L("NC handler error:", a);
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
return;
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
const t = Bt(e);
|
|
765
|
+
if (!t) {
|
|
766
|
+
h("Invalid V2 message:", e);
|
|
767
|
+
return;
|
|
768
|
+
}
|
|
769
|
+
switch (t.kind) {
|
|
770
|
+
case "helloAck":
|
|
771
|
+
Z = t.sessionId;
|
|
772
|
+
return;
|
|
773
|
+
case "ready":
|
|
774
|
+
if (Z && t.sessionId !== Z) {
|
|
775
|
+
h("sessionId mismatch");
|
|
776
|
+
return;
|
|
777
|
+
}
|
|
778
|
+
if (ie(), S = !0, F = 0, t.hostMethods) for (const [n, r] of Object.entries(t.hostMethods)) Re[n] = r;
|
|
779
|
+
B("proto") && $("Handshake complete, hostMethods:", Object.keys(Re).length), Dt();
|
|
780
|
+
return;
|
|
781
|
+
case "res": {
|
|
782
|
+
const n = v.get(t.id);
|
|
783
|
+
if (!n) return;
|
|
784
|
+
if (v.delete(t.id), n.timerId !== null && clearTimeout(n.timerId), t.ok) {
|
|
785
|
+
if (n.method === "state.getSnapshot" && (Gt(t.result) || h("Invalid state.getSnapshot result")), n.mode === "stream" && n.stream) {
|
|
786
|
+
n.stream._resolve(t.result);
|
|
787
|
+
return;
|
|
788
|
+
}
|
|
789
|
+
n.resolve?.(t.result);
|
|
790
|
+
} else {
|
|
791
|
+
const r = U(t.error);
|
|
792
|
+
if (n.mode === "stream" && n.stream) {
|
|
793
|
+
n.stream._reject(r);
|
|
794
|
+
return;
|
|
795
|
+
}
|
|
796
|
+
n.reject?.(r);
|
|
797
|
+
}
|
|
798
|
+
return;
|
|
799
|
+
}
|
|
800
|
+
case "event":
|
|
801
|
+
if (v.has(t.id)) {
|
|
802
|
+
const n = v.get(t.id);
|
|
803
|
+
n?.mode === "stream" && n.stream ? (He(t.id), n.stream._emitData(t.payload)) : h(`Received event for non-stream request '${t.id}'`);
|
|
804
|
+
return;
|
|
805
|
+
}
|
|
806
|
+
return;
|
|
807
|
+
case "state.snapshot":
|
|
808
|
+
N = t.state || {}, C = t.rev, B("data") && (console.group("[LX] snapshot"), console.log("rev:", C, "state:", H(N)), console.groupEnd()), be(!0);
|
|
809
|
+
return;
|
|
810
|
+
case "state.patch":
|
|
811
|
+
if (t.baseRev !== C) {
|
|
812
|
+
h("baseRev mismatch", {
|
|
813
|
+
have: C,
|
|
814
|
+
want: t.baseRev
|
|
815
|
+
}), Xe(t.scope);
|
|
816
|
+
return;
|
|
817
|
+
}
|
|
818
|
+
try {
|
|
819
|
+
Ht(N, t.ops || []), C = t.rev;
|
|
820
|
+
} catch (n) {
|
|
821
|
+
L("Patch failed:", n), Xe(t.scope);
|
|
822
|
+
return;
|
|
823
|
+
}
|
|
824
|
+
B("data") && (console.group("[LX] patch"), console.log("rev:", C, "ops:", t.ops), console.groupEnd()), be(!1), t.ack && E({
|
|
825
|
+
v: 2,
|
|
826
|
+
kind: "state.ack",
|
|
827
|
+
scope: t.scope,
|
|
828
|
+
rev: t.rev
|
|
829
|
+
});
|
|
830
|
+
return;
|
|
831
|
+
case "ch.ack": {
|
|
832
|
+
const n = w.get(t.id);
|
|
833
|
+
if (!n) return;
|
|
834
|
+
if (w.delete(t.id), n.timerId !== null && clearTimeout(n.timerId), t.ok) n.channel._markOpen(), D.set(t.id, n.channel), n.resolve(n.channel);
|
|
835
|
+
else {
|
|
836
|
+
const r = U(t.error);
|
|
837
|
+
n.channel._reject(r), n.reject(r);
|
|
838
|
+
}
|
|
839
|
+
return;
|
|
840
|
+
}
|
|
841
|
+
case "ch.data": {
|
|
842
|
+
const n = D.get(t.id);
|
|
843
|
+
if (!n) return;
|
|
844
|
+
n._emitData(t.payload);
|
|
845
|
+
return;
|
|
846
|
+
}
|
|
847
|
+
case "ch.close": {
|
|
848
|
+
const n = w.get(t.id);
|
|
849
|
+
if (n) {
|
|
850
|
+
w.delete(t.id), n.channel._emitClose(t.code, t.reason);
|
|
851
|
+
return;
|
|
852
|
+
}
|
|
853
|
+
const r = D.get(t.id);
|
|
854
|
+
if (!r) return;
|
|
855
|
+
D.delete(t.id), r._emitClose(t.code, t.reason);
|
|
856
|
+
return;
|
|
857
|
+
}
|
|
858
|
+
case "req": {
|
|
859
|
+
const n = t, r = X(n.method);
|
|
860
|
+
if (!n.cap || n.cap !== r) {
|
|
861
|
+
E({
|
|
862
|
+
v: 2,
|
|
863
|
+
kind: "res",
|
|
864
|
+
id: n.id,
|
|
865
|
+
ok: !1,
|
|
866
|
+
error: {
|
|
867
|
+
code: x.CAPABILITY_DENIED,
|
|
868
|
+
message: `Invalid cap for ${n.method}`
|
|
869
|
+
}
|
|
870
|
+
});
|
|
871
|
+
return;
|
|
872
|
+
}
|
|
873
|
+
const o = Be.get(n.method);
|
|
874
|
+
if (!o) {
|
|
875
|
+
E({
|
|
876
|
+
v: 2,
|
|
877
|
+
kind: "res",
|
|
878
|
+
id: n.id,
|
|
879
|
+
ok: !1,
|
|
880
|
+
error: {
|
|
881
|
+
code: x.METHOD_NOT_FOUND,
|
|
882
|
+
message: `View handler not found: ${n.method}`
|
|
883
|
+
}
|
|
884
|
+
});
|
|
885
|
+
return;
|
|
886
|
+
}
|
|
887
|
+
Promise.resolve().then(() => o(n.params)).then((i) => {
|
|
888
|
+
E({
|
|
889
|
+
v: 2,
|
|
890
|
+
kind: "res",
|
|
891
|
+
id: n.id,
|
|
892
|
+
ok: !0,
|
|
893
|
+
result: i
|
|
894
|
+
});
|
|
895
|
+
}).catch((i) => {
|
|
896
|
+
E({
|
|
897
|
+
v: 2,
|
|
898
|
+
kind: "res",
|
|
899
|
+
id: n.id,
|
|
900
|
+
ok: !1,
|
|
901
|
+
error: U(i)
|
|
902
|
+
});
|
|
903
|
+
});
|
|
904
|
+
return;
|
|
905
|
+
}
|
|
906
|
+
}
|
|
907
|
+
}
|
|
908
|
+
const ae = /* @__PURE__ */ new Map(), le = [];
|
|
909
|
+
let qe = !1;
|
|
910
|
+
function we() {
|
|
911
|
+
return typeof window > "u" ? !1 : !!(window.webkit?.messageHandlers?.NativeComponent || window.NativeComponentBridge?.postMessage);
|
|
912
|
+
}
|
|
913
|
+
function We(e) {
|
|
914
|
+
try {
|
|
915
|
+
if (window.webkit?.messageHandlers?.NativeComponent) {
|
|
916
|
+
window.webkit.messageHandlers.NativeComponent.postMessage(e);
|
|
917
|
+
return;
|
|
918
|
+
}
|
|
919
|
+
if (window.NativeComponentBridge?.postMessage) {
|
|
920
|
+
window.NativeComponentBridge.postMessage(Oe(e));
|
|
921
|
+
return;
|
|
922
|
+
}
|
|
923
|
+
} catch (t) {
|
|
924
|
+
L("NativeComponent send error:", t);
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
function ze() {
|
|
928
|
+
if (!(!we() || le.length === 0)) for (qe = !0; le.length;) {
|
|
929
|
+
const e = le.shift();
|
|
930
|
+
try {
|
|
931
|
+
We(e);
|
|
932
|
+
} catch {
|
|
933
|
+
break;
|
|
934
|
+
}
|
|
935
|
+
}
|
|
936
|
+
}
|
|
937
|
+
function Ye(e) {
|
|
938
|
+
try {
|
|
939
|
+
if (!we()) {
|
|
940
|
+
le.push(e);
|
|
941
|
+
return;
|
|
942
|
+
}
|
|
943
|
+
qe || ze(), We(e);
|
|
944
|
+
} catch (t) {
|
|
945
|
+
L("NC send failed:", t);
|
|
946
|
+
}
|
|
947
|
+
}
|
|
948
|
+
function ve(e) {
|
|
949
|
+
return `${e}_${Date.now()}_${Nt++}`;
|
|
950
|
+
}
|
|
951
|
+
function Je(e, t, n) {
|
|
952
|
+
if (!t) return;
|
|
953
|
+
if (t.aborted) {
|
|
954
|
+
n();
|
|
955
|
+
return;
|
|
956
|
+
}
|
|
957
|
+
let r = { handleEvent: () => {
|
|
958
|
+
t.removeEventListener("abort", r), n();
|
|
959
|
+
} };
|
|
960
|
+
t.addEventListener("abort", r);
|
|
961
|
+
}
|
|
962
|
+
const P = {
|
|
963
|
+
call(e, t, n) {
|
|
964
|
+
return new Promise((r, o) => {
|
|
965
|
+
if (!e || typeof e != "string") {
|
|
966
|
+
o(new j(x.MALFORMED_MESSAGE, "Method name must be a non-empty string"));
|
|
967
|
+
return;
|
|
968
|
+
}
|
|
969
|
+
A || R();
|
|
970
|
+
const i = ve("c"), a = n?.cap || X(e), s = n?.timeoutMs ?? me;
|
|
971
|
+
v.set(i, {
|
|
972
|
+
method: e,
|
|
973
|
+
mode: "call",
|
|
974
|
+
resolve: r,
|
|
975
|
+
reject: (u) => o(u),
|
|
976
|
+
timeoutMs: s,
|
|
977
|
+
timerId: null
|
|
978
|
+
}), E({
|
|
979
|
+
v: 2,
|
|
980
|
+
kind: "req",
|
|
981
|
+
id: i,
|
|
982
|
+
method: e,
|
|
983
|
+
params: oe(t),
|
|
984
|
+
cap: a
|
|
985
|
+
}, i), Je(i, n?.signal, () => {
|
|
986
|
+
const u = Ge(i);
|
|
987
|
+
q(i, {
|
|
988
|
+
code: x.CANCELED,
|
|
989
|
+
message: "Bridge request aborted"
|
|
990
|
+
}), !u && S && E({
|
|
991
|
+
v: 2,
|
|
992
|
+
kind: "cancel",
|
|
993
|
+
id: i
|
|
994
|
+
});
|
|
995
|
+
});
|
|
996
|
+
});
|
|
997
|
+
},
|
|
998
|
+
stream(e, t, n) {
|
|
999
|
+
if (!e || typeof e != "string") {
|
|
1000
|
+
const s = De("invalid", () => {});
|
|
1001
|
+
return s._reject({
|
|
1002
|
+
code: x.MALFORMED_MESSAGE,
|
|
1003
|
+
message: "Method name must be a non-empty string"
|
|
1004
|
+
}), s;
|
|
1005
|
+
}
|
|
1006
|
+
A || R();
|
|
1007
|
+
const r = ve("c"), o = De(r, () => {
|
|
1008
|
+
if (Ge(r)) {
|
|
1009
|
+
q(r, {
|
|
1010
|
+
code: x.CANCELED,
|
|
1011
|
+
message: "Bridge request aborted"
|
|
1012
|
+
});
|
|
1013
|
+
return;
|
|
1014
|
+
}
|
|
1015
|
+
S && E({
|
|
1016
|
+
v: 2,
|
|
1017
|
+
kind: "cancel",
|
|
1018
|
+
id: r
|
|
1019
|
+
});
|
|
1020
|
+
}), i = n?.cap || X(e), a = n?.timeoutMs ?? me;
|
|
1021
|
+
return v.set(r, {
|
|
1022
|
+
method: e,
|
|
1023
|
+
mode: "stream",
|
|
1024
|
+
stream: o,
|
|
1025
|
+
timeoutMs: a,
|
|
1026
|
+
timerId: null
|
|
1027
|
+
}), E({
|
|
1028
|
+
v: 2,
|
|
1029
|
+
kind: "req",
|
|
1030
|
+
id: r,
|
|
1031
|
+
method: e,
|
|
1032
|
+
params: oe(t),
|
|
1033
|
+
cap: i
|
|
1034
|
+
}, r), Je(r, n?.signal, () => o.cancel()), o;
|
|
1035
|
+
},
|
|
1036
|
+
notify(e, t, n) {
|
|
1037
|
+
!e || typeof e != "string" || (A || R(), E({
|
|
1038
|
+
v: 2,
|
|
1039
|
+
kind: "notify",
|
|
1040
|
+
method: e,
|
|
1041
|
+
params: oe(t),
|
|
1042
|
+
cap: n?.cap || X(e)
|
|
1043
|
+
}));
|
|
1044
|
+
},
|
|
1045
|
+
state: { subscribe: Ut },
|
|
1046
|
+
channel: { open(e, t, n) {
|
|
1047
|
+
return !e || typeof e != "string" ? Promise.reject(new j(x.MALFORMED_MESSAGE, "Topic name must be a non-empty string")) : (A || R(), new Promise((r, o) => {
|
|
1048
|
+
const i = ve("ch"), a = Rt(i, (s, u) => {
|
|
1049
|
+
E({
|
|
1050
|
+
v: 2,
|
|
1051
|
+
kind: "ch.data",
|
|
1052
|
+
id: i,
|
|
1053
|
+
seq: u,
|
|
1054
|
+
payload: s
|
|
1055
|
+
});
|
|
1056
|
+
}, (s, u) => {
|
|
1057
|
+
const l = w.get(i);
|
|
1058
|
+
l && l.timerId !== null && clearTimeout(l.timerId), w.delete(i), D.delete(i), E({
|
|
1059
|
+
v: 2,
|
|
1060
|
+
kind: "ch.close",
|
|
1061
|
+
id: i,
|
|
1062
|
+
code: s,
|
|
1063
|
+
reason: u
|
|
1064
|
+
});
|
|
1065
|
+
});
|
|
1066
|
+
w.set(i, {
|
|
1067
|
+
topic: e,
|
|
1068
|
+
channel: a,
|
|
1069
|
+
resolve: r,
|
|
1070
|
+
reject: o,
|
|
1071
|
+
timerId: null
|
|
1072
|
+
}), E({
|
|
1073
|
+
v: 2,
|
|
1074
|
+
kind: "ch.open",
|
|
1075
|
+
id: i,
|
|
1076
|
+
topic: e,
|
|
1077
|
+
params: oe(t),
|
|
1078
|
+
cap: n?.cap || X(e)
|
|
1079
|
+
}, i);
|
|
1080
|
+
}));
|
|
1081
|
+
} },
|
|
1082
|
+
_connectWebMessagePort(e) {
|
|
1083
|
+
if (k === z) {
|
|
1084
|
+
if (M && M !== e) try {
|
|
1085
|
+
M.onmessage = null, M.close();
|
|
1086
|
+
} catch {}
|
|
1087
|
+
M = e, e.onmessage = (t) => {
|
|
1088
|
+
let n = t.data;
|
|
1089
|
+
if (typeof n == "string") try {
|
|
1090
|
+
n = JSON.parse(n);
|
|
1091
|
+
} catch {
|
|
1092
|
+
return;
|
|
1093
|
+
}
|
|
1094
|
+
se(n);
|
|
1095
|
+
};
|
|
1096
|
+
try {
|
|
1097
|
+
e.start();
|
|
1098
|
+
} catch {}
|
|
1099
|
+
$("Port connected"), R();
|
|
1100
|
+
}
|
|
1101
|
+
},
|
|
1102
|
+
_receiveEvaluateMessage(e) {
|
|
1103
|
+
try {
|
|
1104
|
+
e && se(JSON.parse(e));
|
|
1105
|
+
} catch (t) {
|
|
1106
|
+
L("Parse error:", t);
|
|
1107
|
+
}
|
|
1108
|
+
},
|
|
1109
|
+
debug: new Proxy(he, {
|
|
1110
|
+
get(e, t) {
|
|
1111
|
+
return e[t];
|
|
1112
|
+
},
|
|
1113
|
+
set(e, t, n) {
|
|
1114
|
+
return t in e ? (e[t] = !!n, console.log(`[LX] ${t}: ${n}`), !0) : !1;
|
|
1115
|
+
}
|
|
1116
|
+
}),
|
|
1117
|
+
platform: {
|
|
1118
|
+
isHarmony: ft,
|
|
1119
|
+
isIOS: _e,
|
|
1120
|
+
isAndroid: pt,
|
|
1121
|
+
isMacOS: de,
|
|
1122
|
+
isDesktop: ht,
|
|
1123
|
+
getOS: W
|
|
1124
|
+
},
|
|
1125
|
+
dom: { measureById(e) {
|
|
1126
|
+
try {
|
|
1127
|
+
if (!e) return null;
|
|
1128
|
+
const t = document.getElementById(e);
|
|
1129
|
+
if (!t) return null;
|
|
1130
|
+
const n = t.getBoundingClientRect();
|
|
1131
|
+
let r = 0;
|
|
1132
|
+
try {
|
|
1133
|
+
r = parseFloat(getComputedStyle(t).borderRadius) || 0;
|
|
1134
|
+
} catch {}
|
|
1135
|
+
return [
|
|
1136
|
+
n.left + window.scrollX,
|
|
1137
|
+
n.top + window.scrollY,
|
|
1138
|
+
n.width,
|
|
1139
|
+
n.height,
|
|
1140
|
+
r
|
|
1141
|
+
];
|
|
1142
|
+
} catch {
|
|
1143
|
+
return null;
|
|
1144
|
+
}
|
|
1145
|
+
} },
|
|
1146
|
+
nativeComponents: {
|
|
1147
|
+
send: Ye,
|
|
1148
|
+
hasHandler: we,
|
|
1149
|
+
flush: ze,
|
|
1150
|
+
register(e, t) {
|
|
1151
|
+
return !e || typeof t != "function" ? () => {} : (ae.set(e, t), () => ae.delete(e));
|
|
1152
|
+
},
|
|
1153
|
+
unregister(e) {
|
|
1154
|
+
ae.delete(e);
|
|
1155
|
+
}
|
|
1156
|
+
},
|
|
1157
|
+
isReady() {
|
|
1158
|
+
return S;
|
|
1159
|
+
}
|
|
1160
|
+
};
|
|
1161
|
+
function Ve(e) {
|
|
1162
|
+
const t = () => {};
|
|
1163
|
+
return new Proxy(t, {
|
|
1164
|
+
apply(n, r, o) {
|
|
1165
|
+
const i = e.join("."), a = o.length === 0 ? void 0 : o.length === 1 ? o[0] : o, s = P.stream(`host.${i}`, a, {
|
|
1166
|
+
cap: "host",
|
|
1167
|
+
timeoutMs: 0
|
|
1168
|
+
}), u = s.result;
|
|
1169
|
+
return new Proxy(s, { get(l, c) {
|
|
1170
|
+
if (c === "then") return u.then.bind(u);
|
|
1171
|
+
if (c === "catch") return u.catch.bind(u);
|
|
1172
|
+
const d = l[c];
|
|
1173
|
+
return typeof d == "function" ? d.bind(l) : d;
|
|
1174
|
+
} });
|
|
1175
|
+
},
|
|
1176
|
+
get(n, r) {
|
|
1177
|
+
if (r !== "then") {
|
|
1178
|
+
if (r === "__funcName") return `host.${e.join(".")}`;
|
|
1179
|
+
if (r === "__bridgeMode") return "stream";
|
|
1180
|
+
if (typeof r == "string") return Ve([...e, r]);
|
|
1181
|
+
}
|
|
1182
|
+
}
|
|
1183
|
+
});
|
|
1184
|
+
}
|
|
1185
|
+
function Ke(e) {
|
|
1186
|
+
const t = () => {};
|
|
1187
|
+
return new Proxy(t, {
|
|
1188
|
+
apply(n, r, o) {
|
|
1189
|
+
const i = e.join("."), a = o.length === 0 ? void 0 : o.length === 1 ? o[0] : o;
|
|
1190
|
+
return P.channel.open(`host.${i}`, a, { cap: "host" });
|
|
1191
|
+
},
|
|
1192
|
+
get(n, r) {
|
|
1193
|
+
if (r !== "then") {
|
|
1194
|
+
if (r === "__funcName") return `host.${e.join(".")}`;
|
|
1195
|
+
if (r === "__bridgeMode") return "channel";
|
|
1196
|
+
if (r === "open") return (...o) => {
|
|
1197
|
+
const i = e.join("."), a = o.length === 0 ? void 0 : o.length === 1 ? o[0] : o;
|
|
1198
|
+
return P.channel.open(`host.${i}`, a, { cap: "host" });
|
|
1199
|
+
};
|
|
1200
|
+
if (typeof r == "string") return Ke([...e, r]);
|
|
1201
|
+
}
|
|
1202
|
+
}
|
|
1203
|
+
});
|
|
1204
|
+
}
|
|
1205
|
+
const Qe = new Proxy({}, { get(e, t) {
|
|
1206
|
+
if (typeof t == "string") return t === "channel" ? new Proxy({}, { get(n, r) {
|
|
1207
|
+
if (typeof r == "string") return Ke([r]);
|
|
1208
|
+
} }) : Ve([t]);
|
|
1209
|
+
} });
|
|
1210
|
+
function Ee() {
|
|
1211
|
+
$(`Method: ${k}`), kt(P._receiveEvaluateMessage), Q() ? Ne() : k === z ? (Te(), At().catch((e) => h("Port init failed:", e))) : k === "webkit" || k === pe ? R() : h("Unknown method"), window.LingXiaBridge = P, window.host = Qe, mt({
|
|
1212
|
+
os: W(),
|
|
1213
|
+
send: Ye
|
|
1214
|
+
}), $("Init complete");
|
|
1215
|
+
}
|
|
1216
|
+
const Xt = `
|
|
1217
|
+
* { margin: 0; padding: 0; box-sizing: border-box; }
|
|
1218
|
+
body {
|
|
1219
|
+
font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, sans-serif;
|
|
1220
|
+
display: flex;
|
|
1221
|
+
align-items: center;
|
|
1222
|
+
justify-content: center;
|
|
1223
|
+
min-height: 100vh;
|
|
1224
|
+
background: #f5f5f7;
|
|
1225
|
+
color: #1d1d1f;
|
|
1226
|
+
padding: 20px;
|
|
1227
|
+
-webkit-font-smoothing: antialiased;
|
|
1228
|
+
}
|
|
1229
|
+
.lx-error {
|
|
1230
|
+
text-align: center;
|
|
1231
|
+
max-width: 400px;
|
|
1232
|
+
}
|
|
1233
|
+
.lx-error-code {
|
|
1234
|
+
font-size: 120px;
|
|
1235
|
+
font-weight: 700;
|
|
1236
|
+
color: #d1d1d6;
|
|
1237
|
+
line-height: 1;
|
|
1238
|
+
letter-spacing: -4px;
|
|
1239
|
+
}
|
|
1240
|
+
.lx-error-title {
|
|
1241
|
+
font-size: 21px;
|
|
1242
|
+
font-weight: 600;
|
|
1243
|
+
margin: 16px 0 8px;
|
|
1244
|
+
color: #1d1d1f;
|
|
1245
|
+
}
|
|
1246
|
+
.lx-error-desc {
|
|
1247
|
+
font-size: 15px;
|
|
1248
|
+
color: #86868b;
|
|
1249
|
+
line-height: 1.5;
|
|
1250
|
+
}
|
|
1251
|
+
.lx-error-path {
|
|
1252
|
+
display: inline-block;
|
|
1253
|
+
margin-top: 20px;
|
|
1254
|
+
padding: 10px 16px;
|
|
1255
|
+
background: rgba(0,0,0,0.04);
|
|
1256
|
+
border-radius: 8px;
|
|
1257
|
+
font-family: 'SF Mono', ui-monospace, Menlo, Monaco, monospace;
|
|
1258
|
+
font-size: 13px;
|
|
1259
|
+
color: #1d1d1f;
|
|
1260
|
+
word-break: break-all;
|
|
1261
|
+
max-width: 100%;
|
|
1262
|
+
}
|
|
1263
|
+
@media (prefers-color-scheme: dark) {
|
|
1264
|
+
body { background: #000; color: #f5f5f7; }
|
|
1265
|
+
.lx-error-code { color: #3a3a3c; }
|
|
1266
|
+
.lx-error-title { color: #f5f5f7; }
|
|
1267
|
+
.lx-error-desc { color: #86868b; }
|
|
1268
|
+
.lx-error-path { background: rgba(255,255,255,0.08); color: #f5f5f7; }
|
|
1269
|
+
}
|
|
1270
|
+
`;
|
|
1271
|
+
function Ze(e) {
|
|
1272
|
+
const t = document.createElement("div");
|
|
1273
|
+
return t.textContent = e, t.innerHTML;
|
|
1274
|
+
}
|
|
1275
|
+
function et(e) {
|
|
1276
|
+
const { failedPath: t, reason: n } = e, r = document.createElement("style");
|
|
1277
|
+
r.textContent = Xt, document.head.appendChild(r), document.body.innerHTML = "", document.body.style.cssText = "";
|
|
1278
|
+
const o = document.createElement("div");
|
|
1279
|
+
o.className = "lx-error";
|
|
1280
|
+
let i = "<div class=\"lx-error-code\">404</div>";
|
|
1281
|
+
i += "<h1 class=\"lx-error-title\">Page Not Found</h1>", i += `<p class="lx-error-desc">The page you're looking for doesn't exist.</p>`, t && (i += `<div class="lx-error-path">${Ze(t)}</div>`), n && (i += `<p class="lx-error-desc" style="margin-top:12px">${Ze(n)}</p>`), o.innerHTML = i, document.body.appendChild(o);
|
|
1282
|
+
}
|
|
1283
|
+
function tt() {
|
|
1284
|
+
const e = window.__LX_RUNTIME_CONFIG;
|
|
1285
|
+
return !!(e && e.error);
|
|
1286
|
+
}
|
|
1287
|
+
function nt() {
|
|
1288
|
+
return window.__LX_RUNTIME_CONFIG?.error || null;
|
|
1289
|
+
}
|
|
1290
|
+
const qt = { handleEvent: () => ke() };
|
|
1291
|
+
function ke() {
|
|
1292
|
+
if (tt()) {
|
|
1293
|
+
const e = nt();
|
|
1294
|
+
e && et(e);
|
|
1295
|
+
}
|
|
1296
|
+
}
|
|
1297
|
+
function Wt() {
|
|
1298
|
+
Ee(), ke();
|
|
1299
|
+
}
|
|
1300
|
+
function ot() {
|
|
1301
|
+
Ee(), document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", qt) : ke();
|
|
1302
|
+
}
|
|
1303
|
+
const zt = "lx://proxy/";
|
|
1304
|
+
function Yt(e) {
|
|
1305
|
+
return e.length === 0 || e.startsWith("lx://") || e.startsWith("data:") || e.startsWith("blob:") || e.startsWith("file:") ? !1 : e.startsWith("http://") || e.startsWith("https://");
|
|
1306
|
+
}
|
|
1307
|
+
function Jt(e) {
|
|
1308
|
+
return `${zt}${btoa(e).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/g, "")}`;
|
|
1309
|
+
}
|
|
1310
|
+
function Ce(e) {
|
|
1311
|
+
const t = e.trim();
|
|
1312
|
+
return Yt(t) ? Jt(t) : e;
|
|
1313
|
+
}
|
|
1314
|
+
function Vt() {
|
|
1315
|
+
const e = W();
|
|
1316
|
+
if (e !== "iOS" && e !== "macOS" || typeof window > "u" || typeof document > "u" || typeof HTMLImageElement > "u") return;
|
|
1317
|
+
const t = HTMLImageElement.prototype;
|
|
1318
|
+
if (t.__lxProxyPatched) return;
|
|
1319
|
+
t.__lxProxyPatched = !0;
|
|
1320
|
+
const n = t.setAttribute;
|
|
1321
|
+
t.setAttribute = function(i, a) {
|
|
1322
|
+
return typeof i == "string" && i.toLowerCase() === "src" && typeof a == "string" ? n.call(this, i, Ce(a)) : n.call(this, i, a);
|
|
1323
|
+
};
|
|
1324
|
+
const r = Object.getOwnPropertyDescriptor(t, "src");
|
|
1325
|
+
r?.set && Object.defineProperty(t, "src", {
|
|
1326
|
+
configurable: r.configurable,
|
|
1327
|
+
enumerable: r.enumerable,
|
|
1328
|
+
get: r.get,
|
|
1329
|
+
set(i) {
|
|
1330
|
+
typeof i == "string" ? r.set?.call(this, Ce(i)) : r.set?.call(this, i);
|
|
1331
|
+
}
|
|
1332
|
+
});
|
|
1333
|
+
const o = () => {
|
|
1334
|
+
document.querySelectorAll("img[src]").forEach((i) => {
|
|
1335
|
+
const a = i.getAttribute("src");
|
|
1336
|
+
if (!a) return;
|
|
1337
|
+
const s = Ce(a);
|
|
1338
|
+
s !== a && n.call(i, "src", s);
|
|
1339
|
+
});
|
|
1340
|
+
};
|
|
1341
|
+
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", { handleEvent: () => o() }) : o();
|
|
1342
|
+
}
|
|
1343
|
+
const Ie = 300, rt = "lx-action-sheet-style";
|
|
1344
|
+
let it = null;
|
|
1345
|
+
function Kt() {
|
|
1346
|
+
return W() === "macOS";
|
|
1347
|
+
}
|
|
1348
|
+
function Qt() {
|
|
1349
|
+
if (document.getElementById(rt)) return;
|
|
1350
|
+
const e = document.createElement("style");
|
|
1351
|
+
e.id = rt, e.textContent = `
|
|
1352
|
+
.lx-as-backdrop {
|
|
1353
|
+
position: fixed; inset: 0; z-index: 99999;
|
|
1354
|
+
background: rgba(0,0,0,0.4);
|
|
1355
|
+
opacity: 0; transition: opacity ${Ie}ms ease;
|
|
1356
|
+
}
|
|
1357
|
+
.lx-as-backdrop.lx-as-visible { opacity: 1; }
|
|
1358
|
+
|
|
1359
|
+
.lx-as-sheet {
|
|
1360
|
+
position: fixed; left: 0; right: 0; bottom: 0; z-index: 100000;
|
|
1361
|
+
transform: translateY(100%);
|
|
1362
|
+
transition: transform ${Ie}ms ease;
|
|
1363
|
+
font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, sans-serif;
|
|
1364
|
+
-webkit-font-smoothing: antialiased;
|
|
1365
|
+
}
|
|
1366
|
+
.lx-as-sheet.lx-as-visible { transform: translateY(0); }
|
|
1367
|
+
.lx-as-sheet.lx-as-desktop {
|
|
1368
|
+
left: 50%;
|
|
1369
|
+
right: auto;
|
|
1370
|
+
bottom: auto;
|
|
1371
|
+
top: 50%;
|
|
1372
|
+
width: min(92vw, 460px);
|
|
1373
|
+
transform: translate(-50%, calc(-50% + 16px));
|
|
1374
|
+
}
|
|
1375
|
+
.lx-as-sheet.lx-as-desktop.lx-as-visible { transform: translate(-50%, -50%); }
|
|
1376
|
+
|
|
1377
|
+
.lx-as-container {
|
|
1378
|
+
background: #fff;
|
|
1379
|
+
border-radius: 16px 16px 0 0;
|
|
1380
|
+
overflow: hidden;
|
|
1381
|
+
}
|
|
1382
|
+
.lx-as-container.lx-as-desktop {
|
|
1383
|
+
border-radius: 16px;
|
|
1384
|
+
}
|
|
1385
|
+
|
|
1386
|
+
.lx-as-item {
|
|
1387
|
+
display: block; width: 100%;
|
|
1388
|
+
height: 56px;
|
|
1389
|
+
line-height: 56px;
|
|
1390
|
+
padding: 0;
|
|
1391
|
+
border: none; background: none;
|
|
1392
|
+
font-size: 18px; font-weight: 400;
|
|
1393
|
+
text-align: center;
|
|
1394
|
+
cursor: pointer;
|
|
1395
|
+
-webkit-tap-highlight-color: transparent;
|
|
1396
|
+
position: relative;
|
|
1397
|
+
}
|
|
1398
|
+
.lx-as-item:active { background: rgba(0,0,0,0.08); }
|
|
1399
|
+
.lx-as-item + .lx-as-item::before {
|
|
1400
|
+
content: ''; position: absolute; top: 0; left: 0; right: 0;
|
|
1401
|
+
height: 1px; background: #E0E0E0;
|
|
1402
|
+
}
|
|
1403
|
+
.lx-as-separator {
|
|
1404
|
+
height: 8px;
|
|
1405
|
+
background: #F2F2F2;
|
|
1406
|
+
}
|
|
1407
|
+
.lx-as-cancel-btn { font-weight: 500; color: #000; }
|
|
1408
|
+
`, document.head.appendChild(e);
|
|
1409
|
+
}
|
|
1410
|
+
function Zt(e) {
|
|
1411
|
+
const t = e, n = t?.itemList ?? [], r = t?.cancelText ?? "Cancel", o = t?.itemColor ?? "#007AFF", i = (it ?? Promise.resolve()).then(() => st(n, r, o), () => st(n, r, o));
|
|
1412
|
+
return it = i, i;
|
|
1413
|
+
}
|
|
1414
|
+
function st(e, t, n) {
|
|
1415
|
+
return new Promise((r) => {
|
|
1416
|
+
let o = !1;
|
|
1417
|
+
const i = Kt();
|
|
1418
|
+
Qt();
|
|
1419
|
+
const a = document.createElement("div");
|
|
1420
|
+
a.className = "lx-as-backdrop";
|
|
1421
|
+
const s = document.createElement("div");
|
|
1422
|
+
s.className = "lx-as-sheet", i && s.classList.add("lx-as-desktop");
|
|
1423
|
+
const u = document.createElement("div");
|
|
1424
|
+
u.className = "lx-as-container", i && u.classList.add("lx-as-desktop"), e.forEach((m, y) => {
|
|
1425
|
+
const f = document.createElement("button");
|
|
1426
|
+
f.className = "lx-as-item", f.textContent = m, f.style.color = n, f.addEventListener("click", () => d(y)), u.appendChild(f);
|
|
1427
|
+
});
|
|
1428
|
+
const l = document.createElement("div");
|
|
1429
|
+
l.className = "lx-as-separator", u.appendChild(l);
|
|
1430
|
+
const c = document.createElement("button");
|
|
1431
|
+
c.className = "lx-as-item lx-as-cancel-btn", c.textContent = t, c.addEventListener("click", () => d(-1)), u.appendChild(c), s.appendChild(u), document.body.appendChild(a), document.body.appendChild(s), requestAnimationFrame(() => {
|
|
1432
|
+
a.classList.add("lx-as-visible"), s.classList.add("lx-as-visible");
|
|
1433
|
+
}), a.addEventListener("click", () => d(-1));
|
|
1434
|
+
function d(m) {
|
|
1435
|
+
o || (o = !0, a.classList.remove("lx-as-visible"), s.classList.remove("lx-as-visible"), setTimeout(() => {
|
|
1436
|
+
a.remove(), s.remove(), r({ tapIndex: m });
|
|
1437
|
+
}, Ie));
|
|
1438
|
+
}
|
|
1439
|
+
});
|
|
1440
|
+
}
|
|
1441
|
+
const at = "lx-modal-style";
|
|
1442
|
+
let lt = null;
|
|
1443
|
+
function en() {
|
|
1444
|
+
if (document.getElementById(at)) return;
|
|
1445
|
+
const e = document.createElement("style");
|
|
1446
|
+
e.id = at, e.textContent = `
|
|
1447
|
+
.lx-modal-backdrop {
|
|
1448
|
+
position: fixed; inset: 0; z-index: 99999;
|
|
1449
|
+
background: rgba(0,0,0,0.4);
|
|
1450
|
+
opacity: 0; transition: opacity 200ms ease;
|
|
1451
|
+
display: flex; align-items: center; justify-content: center;
|
|
1452
|
+
}
|
|
1453
|
+
.lx-modal-backdrop.lx-modal-visible { opacity: 1; }
|
|
1454
|
+
|
|
1455
|
+
.lx-modal-dialog {
|
|
1456
|
+
width: min(92vw, 320px);
|
|
1457
|
+
background: #fff;
|
|
1458
|
+
border-radius: 14px;
|
|
1459
|
+
overflow: hidden;
|
|
1460
|
+
font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, sans-serif;
|
|
1461
|
+
-webkit-font-smoothing: antialiased;
|
|
1462
|
+
transform: scale(0.95); opacity: 0;
|
|
1463
|
+
transition: transform 200ms ease, opacity 200ms ease;
|
|
1464
|
+
}
|
|
1465
|
+
.lx-modal-backdrop.lx-modal-visible .lx-modal-dialog {
|
|
1466
|
+
transform: scale(1); opacity: 1;
|
|
1467
|
+
}
|
|
1468
|
+
|
|
1469
|
+
.lx-modal-body {
|
|
1470
|
+
padding: 24px 20px 16px;
|
|
1471
|
+
text-align: center;
|
|
1472
|
+
}
|
|
1473
|
+
.lx-modal-title {
|
|
1474
|
+
margin: 0 0 8px;
|
|
1475
|
+
font-size: 17px;
|
|
1476
|
+
font-weight: 600;
|
|
1477
|
+
color: #000;
|
|
1478
|
+
line-height: 1.35;
|
|
1479
|
+
}
|
|
1480
|
+
.lx-modal-content {
|
|
1481
|
+
margin: 0;
|
|
1482
|
+
font-size: 14px;
|
|
1483
|
+
color: #666;
|
|
1484
|
+
line-height: 1.5;
|
|
1485
|
+
word-break: break-word;
|
|
1486
|
+
}
|
|
1487
|
+
.lx-modal-body:has(.lx-modal-title:empty) .lx-modal-content {
|
|
1488
|
+
font-size: 17px;
|
|
1489
|
+
font-weight: 600;
|
|
1490
|
+
color: #000;
|
|
1491
|
+
}
|
|
1492
|
+
|
|
1493
|
+
.lx-modal-footer {
|
|
1494
|
+
display: flex;
|
|
1495
|
+
border-top: 1px solid #E0E0E0;
|
|
1496
|
+
}
|
|
1497
|
+
.lx-modal-btn {
|
|
1498
|
+
flex: 1;
|
|
1499
|
+
height: 44px;
|
|
1500
|
+
line-height: 44px;
|
|
1501
|
+
padding: 0;
|
|
1502
|
+
border: none;
|
|
1503
|
+
background: none;
|
|
1504
|
+
font-size: 17px;
|
|
1505
|
+
text-align: center;
|
|
1506
|
+
cursor: pointer;
|
|
1507
|
+
-webkit-tap-highlight-color: transparent;
|
|
1508
|
+
}
|
|
1509
|
+
.lx-modal-btn:active { background: rgba(0,0,0,0.06); }
|
|
1510
|
+
.lx-modal-btn + .lx-modal-btn {
|
|
1511
|
+
border-left: 1px solid #E0E0E0;
|
|
1512
|
+
}
|
|
1513
|
+
.lx-modal-btn-cancel {
|
|
1514
|
+
color: #666;
|
|
1515
|
+
font-weight: 400;
|
|
1516
|
+
}
|
|
1517
|
+
.lx-modal-btn-confirm {
|
|
1518
|
+
font-weight: 600;
|
|
1519
|
+
}
|
|
1520
|
+
|
|
1521
|
+
@media (prefers-color-scheme: dark) {
|
|
1522
|
+
.lx-modal-dialog { background: #2c2c2e; }
|
|
1523
|
+
.lx-modal-title { color: #f5f5f7; }
|
|
1524
|
+
.lx-modal-content { color: #ababab; }
|
|
1525
|
+
.lx-modal-body:has(.lx-modal-title:empty) .lx-modal-content {
|
|
1526
|
+
color: #f5f5f7;
|
|
1527
|
+
}
|
|
1528
|
+
.lx-modal-footer { border-top-color: #3a3a3c; }
|
|
1529
|
+
.lx-modal-btn:active { background: rgba(255,255,255,0.08); }
|
|
1530
|
+
.lx-modal-btn + .lx-modal-btn { border-left-color: #3a3a3c; }
|
|
1531
|
+
.lx-modal-btn-cancel { color: #ababab; }
|
|
1532
|
+
}
|
|
1533
|
+
`, document.head.appendChild(e);
|
|
1534
|
+
}
|
|
1535
|
+
function tn(e) {
|
|
1536
|
+
const t = e, n = t?.title ?? "", r = t?.content ?? "", o = t?.showCancel ?? !0, i = t?.cancelText ?? "Cancel", a = t?.cancelColor, s = t?.confirmText ?? "OK", u = t?.confirmColor ?? "#007AFF", l = (lt ?? Promise.resolve()).then(() => ct(n, r, o, i, a, s, u), () => ct(n, r, o, i, a, s, u));
|
|
1537
|
+
return lt = l, l;
|
|
1538
|
+
}
|
|
1539
|
+
function ct(e, t, n, r, o, i, a) {
|
|
1540
|
+
return new Promise((s) => {
|
|
1541
|
+
let u = !1;
|
|
1542
|
+
en();
|
|
1543
|
+
const l = document.createElement("div");
|
|
1544
|
+
l.className = "lx-modal-backdrop";
|
|
1545
|
+
const c = document.createElement("div");
|
|
1546
|
+
c.className = "lx-modal-dialog";
|
|
1547
|
+
const d = document.createElement("div");
|
|
1548
|
+
d.className = "lx-modal-body";
|
|
1549
|
+
const m = document.createElement("div");
|
|
1550
|
+
if (m.className = "lx-modal-title", m.textContent = e, d.appendChild(m), t) {
|
|
1551
|
+
const g = document.createElement("p");
|
|
1552
|
+
g.className = "lx-modal-content", g.textContent = t, d.appendChild(g);
|
|
1553
|
+
}
|
|
1554
|
+
c.appendChild(d);
|
|
1555
|
+
const y = document.createElement("div");
|
|
1556
|
+
if (y.className = "lx-modal-footer", n) {
|
|
1557
|
+
const g = document.createElement("button");
|
|
1558
|
+
g.className = "lx-modal-btn lx-modal-btn-cancel", g.textContent = r, o && (g.style.color = o), g.addEventListener("click", () => p(!1)), y.appendChild(g);
|
|
1559
|
+
}
|
|
1560
|
+
const f = document.createElement("button");
|
|
1561
|
+
f.className = "lx-modal-btn lx-modal-btn-confirm", f.textContent = i, f.style.color = a, f.addEventListener("click", () => p(!0)), y.appendChild(f), c.appendChild(y), l.appendChild(c), document.body.appendChild(l), requestAnimationFrame(() => {
|
|
1562
|
+
l.classList.add("lx-modal-visible");
|
|
1563
|
+
});
|
|
1564
|
+
function p(g) {
|
|
1565
|
+
u || (u = !0, l.classList.remove("lx-modal-visible"), setTimeout(() => {
|
|
1566
|
+
l.remove(), s({
|
|
1567
|
+
confirm: g,
|
|
1568
|
+
cancel: !g
|
|
1569
|
+
});
|
|
1570
|
+
}, 200));
|
|
1571
|
+
}
|
|
1572
|
+
});
|
|
1573
|
+
}
|
|
1574
|
+
const dt = "lx-toast-style";
|
|
1575
|
+
let T = null;
|
|
1576
|
+
const nn = "<svg width=\"36\" height=\"36\" viewBox=\"0 0 36 36\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\"><circle cx=\"18\" cy=\"18\" r=\"17\" stroke=\"currentColor\" stroke-width=\"2\"/><path d=\"M11 18l5 5 9-9\" stroke=\"currentColor\" stroke-width=\"2.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/></svg>", on = "<svg width=\"36\" height=\"36\" viewBox=\"0 0 36 36\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\"><circle cx=\"18\" cy=\"18\" r=\"17\" stroke=\"currentColor\" stroke-width=\"2\"/><path d=\"M13 13l10 10M23 13l-10 10\" stroke=\"currentColor\" stroke-width=\"2.5\" stroke-linecap=\"round\"/></svg>", rn = "<svg width=\"36\" height=\"36\" viewBox=\"0 0 36 36\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M18 4a14 14 0 0 1 14 14\" stroke=\"currentColor\" stroke-width=\"2.5\" stroke-linecap=\"round\"><animateTransform attributeName=\"transform\" type=\"rotate\" from=\"0 18 18\" to=\"360 18 18\" dur=\"0.8s\" repeatCount=\"indefinite\"/></path></svg>";
|
|
1577
|
+
function sn() {
|
|
1578
|
+
if (document.getElementById(dt)) return;
|
|
1579
|
+
const e = document.createElement("style");
|
|
1580
|
+
e.id = dt, e.textContent = `
|
|
1581
|
+
.lx-toast-mask {
|
|
1582
|
+
position: fixed; inset: 0; z-index: 99998;
|
|
1583
|
+
}
|
|
1584
|
+
.lx-toast-container {
|
|
1585
|
+
position: fixed; left: 0; right: 0; z-index: 99999;
|
|
1586
|
+
display: flex; justify-content: center;
|
|
1587
|
+
pointer-events: none;
|
|
1588
|
+
}
|
|
1589
|
+
.lx-toast-container.lx-toast-top { top: 0; padding-top: 80px; }
|
|
1590
|
+
.lx-toast-container.lx-toast-center { top: 0; bottom: 0; align-items: center; }
|
|
1591
|
+
.lx-toast-container.lx-toast-bottom { bottom: 0; padding-bottom: 80px; }
|
|
1592
|
+
|
|
1593
|
+
.lx-toast-box {
|
|
1594
|
+
display: flex; flex-direction: column; align-items: center; gap: 10px;
|
|
1595
|
+
min-width: 120px; max-width: 280px;
|
|
1596
|
+
padding: 20px;
|
|
1597
|
+
background: rgba(0,0,0,0.8);
|
|
1598
|
+
border-radius: 12px;
|
|
1599
|
+
color: #fff;
|
|
1600
|
+
pointer-events: auto;
|
|
1601
|
+
transform: scale(0.8); opacity: 0;
|
|
1602
|
+
transition: transform 200ms ease, opacity 200ms ease;
|
|
1603
|
+
}
|
|
1604
|
+
.lx-toast-box.lx-toast-no-icon {
|
|
1605
|
+
min-width: auto; min-height: auto;
|
|
1606
|
+
padding: 12px 20px;
|
|
1607
|
+
}
|
|
1608
|
+
.lx-toast-box.lx-toast-visible {
|
|
1609
|
+
transform: scale(1); opacity: 1;
|
|
1610
|
+
}
|
|
1611
|
+
.lx-toast-icon {
|
|
1612
|
+
width: 36px; height: 36px;
|
|
1613
|
+
color: #fff;
|
|
1614
|
+
line-height: 0;
|
|
1615
|
+
}
|
|
1616
|
+
.lx-toast-title {
|
|
1617
|
+
font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, sans-serif;
|
|
1618
|
+
font-size: 16px; font-weight: 500;
|
|
1619
|
+
text-align: center;
|
|
1620
|
+
line-height: 1.4;
|
|
1621
|
+
word-break: break-word;
|
|
1622
|
+
-webkit-font-smoothing: antialiased;
|
|
1623
|
+
}
|
|
1624
|
+
`, document.head.appendChild(e);
|
|
1625
|
+
}
|
|
1626
|
+
function an(e) {
|
|
1627
|
+
const t = e, n = t?.title ?? "", r = t?.icon ?? "none", o = t?.duration ?? 1500, i = t?.mask ?? !1, a = t?.position ?? "center";
|
|
1628
|
+
T && (T.dismiss(), T = null), sn();
|
|
1629
|
+
let s = null;
|
|
1630
|
+
i && (s = document.createElement("div"), s.className = "lx-toast-mask", document.body.appendChild(s));
|
|
1631
|
+
const u = document.createElement("div");
|
|
1632
|
+
u.className = "lx-toast-container", a === "top" ? u.classList.add("lx-toast-top") : a === "bottom" ? u.classList.add("lx-toast-bottom") : u.classList.add("lx-toast-center");
|
|
1633
|
+
const l = document.createElement("div");
|
|
1634
|
+
l.className = "lx-toast-box";
|
|
1635
|
+
const c = r !== "none";
|
|
1636
|
+
if (c || l.classList.add("lx-toast-no-icon"), c) {
|
|
1637
|
+
const p = document.createElement("div");
|
|
1638
|
+
p.className = "lx-toast-icon", r === "success" ? p.innerHTML = nn : r === "error" ? p.innerHTML = on : r === "loading" && (p.innerHTML = rn), l.appendChild(p);
|
|
1639
|
+
}
|
|
1640
|
+
const d = document.createElement("div");
|
|
1641
|
+
d.className = "lx-toast-title", d.textContent = n, l.appendChild(d), u.appendChild(l), document.body.appendChild(u), requestAnimationFrame(() => {
|
|
1642
|
+
l.classList.add("lx-toast-visible");
|
|
1643
|
+
});
|
|
1644
|
+
let m = !1;
|
|
1645
|
+
function y() {
|
|
1646
|
+
m || (m = !0, T?.dismiss === y && (T = null), l.classList.remove("lx-toast-visible"), f && clearTimeout(f), setTimeout(() => {
|
|
1647
|
+
u.remove(), s?.remove();
|
|
1648
|
+
}, 200));
|
|
1649
|
+
}
|
|
1650
|
+
let f = null;
|
|
1651
|
+
return o > 0 && (f = setTimeout(y, o)), T = {
|
|
1652
|
+
dismiss: y,
|
|
1653
|
+
timer: f
|
|
1654
|
+
}, Promise.resolve();
|
|
1655
|
+
}
|
|
1656
|
+
function ln() {
|
|
1657
|
+
return T && (T.dismiss(), T = null), Promise.resolve();
|
|
1658
|
+
}
|
|
1659
|
+
function cn() {
|
|
1660
|
+
ne("ui.showActionSheet", Zt), ne("ui.showModal", tn), ne("ui.showToast", an), ne("ui.hideToast", ln);
|
|
1661
|
+
}
|
|
1662
|
+
return cn(), Vt(), ot(), I.LingXiaBridge = P, I.boot = Wt, I.bootWhenReady = ot, I.getErrorInfo = nt, I.hasError = tt, I.host = Qe, I.initBridge = Ee, I.renderErrorUI = et, I;
|
|
1663
|
+
})({});
|