@aippy/runtime 0.4.2-dev.4 → 0.4.2-dev.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/README.md +6 -0
- package/dist/ai/index.d.ts +2 -1
- package/dist/ai/index.js +18 -14
- package/dist/ai/viggle/generate.d.ts +46 -13
- package/dist/ai/viggle/models.d.ts +46 -0
- package/dist/{app-version-checker-Bz7FrEZz.js → app-version-checker-YVIFbytA.js} +18 -17
- package/dist/{bridge-D_-7nPNC.js → bridge-K3HqQwdj.js} +1 -1
- package/dist/{container-message-DmIChz4h.js → container-message-D-wg98Oh.js} +2 -2
- package/dist/core/index.js +2 -2
- package/dist/helper-DnJHjgMg.js +622 -0
- package/dist/{hooks-Ct9qEjM6.js → hooks-CMKwSLcQ.js} +1 -1
- package/dist/index/index.js +61 -56
- package/dist/ministore/app-authorization.d.ts +1 -1
- package/dist/ministore/index.js +64 -880
- package/dist/ministore/purchase.d.ts +1 -1
- package/dist/ministore/types.d.ts +5 -0
- package/dist/recharge-BOY8wLs6.js +993 -0
- package/dist/user/index.js +3 -3
- package/dist/utils/app-version-requirements.json.d.ts +4 -0
- package/dist/utils/index.js +1 -1
- package/package.json +1 -1
- package/dist/helper-BWszI06u.js +0 -346
- package/dist/wallet-recharge-BqOljLWn.js +0 -140
package/dist/user/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { c as o, u as s } from "../hooks-
|
|
2
|
-
import { g as f } from "../bridge-
|
|
3
|
-
import { i as t } from "../app-version-checker-
|
|
1
|
+
import { c as o, u as s } from "../hooks-CMKwSLcQ.js";
|
|
2
|
+
import { g as f } from "../bridge-K3HqQwdj.js";
|
|
3
|
+
import { i as t } from "../app-version-checker-YVIFbytA.js";
|
|
4
4
|
export {
|
|
5
5
|
o as clearUserInfoCache,
|
|
6
6
|
f as getAuthTokenAsync,
|
package/dist/utils/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { P as a, a as s, c as o, b as t, g as p, i, p as m, r as n, s as f } from "../app-version-checker-
|
|
1
|
+
import { P as a, a as s, c as o, b as t, g as p, i, p as m, r as n, s as f } from "../app-version-checker-YVIFbytA.js";
|
|
2
2
|
import { a as c, P as l, p as P, b as F } from "../pwa-C5nXU0DN.js";
|
|
3
3
|
import { j as g } from "../url-c26cuIpu.js";
|
|
4
4
|
export {
|
package/package.json
CHANGED
package/dist/helper-BWszI06u.js
DELETED
|
@@ -1,346 +0,0 @@
|
|
|
1
|
-
import { createOpenAICompatible as C } from "@ai-sdk/openai-compatible";
|
|
2
|
-
import { j as O } from "./url-c26cuIpu.js";
|
|
3
|
-
import { AISDKError as p, DefaultChatTransport as E } from "ai";
|
|
4
|
-
import { E as f, b as m, a as g } from "./errors-B3bDbQbD.js";
|
|
5
|
-
import { r as l } from "./bridge-D_-7nPNC.js";
|
|
6
|
-
import { s as b, a as _ } from "./container-message-DmIChz4h.js";
|
|
7
|
-
import { s as v } from "./wallet-recharge-BqOljLWn.js";
|
|
8
|
-
const T = `${l()}/aisdk/v1/`, ne = `${l()}/aisdk/v1/ui/`, S = "gpt-5-nano", U = "";
|
|
9
|
-
function M(t = {}) {
|
|
10
|
-
return {
|
|
11
|
-
baseUrl: t.baseUrl ?? `${l()}/aisdk/v1/`
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
function N(t = {}) {
|
|
15
|
-
return {
|
|
16
|
-
baseUrl: t.baseUrl ?? `${l()}/aisdk/v1/ui/`
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
const D = 100003, $ = "insufficient_quota";
|
|
20
|
-
function F(t, e) {
|
|
21
|
-
const n = t.status;
|
|
22
|
-
if (e && typeof e == "object" && "error" in e) {
|
|
23
|
-
const r = e, s = r.error.code, o = s != null ? `AippyAIError_${s}` : `AippyAIError_${n}`, a = e;
|
|
24
|
-
return "appMessage" in a && a.appMessage !== void 0 && b(a.appMessage), R(r.error) && v(), new p({
|
|
25
|
-
name: o,
|
|
26
|
-
message: `${f.RUNTIME} ${r.error.message}`,
|
|
27
|
-
cause: {
|
|
28
|
-
type: r.error.type ?? void 0,
|
|
29
|
-
param: r.error.param ?? void 0,
|
|
30
|
-
status: n
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
if (e && typeof e == "object" && e !== null) {
|
|
35
|
-
const r = e;
|
|
36
|
-
"appMessage" in r && r.appMessage !== void 0 && b(r.appMessage);
|
|
37
|
-
}
|
|
38
|
-
return new p({
|
|
39
|
-
name: `AippyAIError_${n}`,
|
|
40
|
-
message: `${f.RUNTIME} Request failed with status ${n}`,
|
|
41
|
-
cause: { status: n }
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
function R(t) {
|
|
45
|
-
return t.code === D || t.type === $;
|
|
46
|
-
}
|
|
47
|
-
function y() {
|
|
48
|
-
return async (t, e) => {
|
|
49
|
-
const n = await _(e?.headers), r = await globalThis.fetch(t, { ...e, headers: n });
|
|
50
|
-
if (!r.ok) {
|
|
51
|
-
const s = await r.text().catch(() => null);
|
|
52
|
-
let o = null;
|
|
53
|
-
if (s)
|
|
54
|
-
try {
|
|
55
|
-
o = JSON.parse(s);
|
|
56
|
-
} catch {
|
|
57
|
-
o = { message: s };
|
|
58
|
-
}
|
|
59
|
-
throw F(r, o);
|
|
60
|
-
}
|
|
61
|
-
return r;
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
const L = [
|
|
65
|
-
"gpt-image-1",
|
|
66
|
-
"gpt-image-1-mini",
|
|
67
|
-
"gpt-image-1.5"
|
|
68
|
-
];
|
|
69
|
-
function j(t) {
|
|
70
|
-
try {
|
|
71
|
-
const e = JSON.parse(t);
|
|
72
|
-
if (e.model && L.some((n) => e.model.startsWith(n))) {
|
|
73
|
-
const { response_format: n, ...r } = e;
|
|
74
|
-
return JSON.stringify(r);
|
|
75
|
-
}
|
|
76
|
-
} catch {
|
|
77
|
-
}
|
|
78
|
-
return t;
|
|
79
|
-
}
|
|
80
|
-
function oe(t = {}) {
|
|
81
|
-
const { baseUrl: e } = M(t), n = y();
|
|
82
|
-
return C({
|
|
83
|
-
name: "aippy",
|
|
84
|
-
baseURL: e,
|
|
85
|
-
fetch: async (s, o) => s.toString().includes("/images/generations") && o?.method?.toUpperCase() === "POST" && o?.body ? n(s, {
|
|
86
|
-
...o,
|
|
87
|
-
body: j(o.body)
|
|
88
|
-
}) : n(s, o),
|
|
89
|
-
// Enable structured outputs support (json_schema response format)
|
|
90
|
-
// This is required for Output.object() and Output.array() to work properly
|
|
91
|
-
supportsStructuredOutputs: !0
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
const x = "/chat";
|
|
95
|
-
function se(t = {}) {
|
|
96
|
-
const { baseUrl: e } = N(t), n = t.model ?? S, r = t.system ?? U, s = t.api ?? O(e, x), o = { model: n, system: r }, a = y();
|
|
97
|
-
return {
|
|
98
|
-
transport: new E({
|
|
99
|
-
api: s,
|
|
100
|
-
body: o,
|
|
101
|
-
// Ensure token is fetched fresh for every request
|
|
102
|
-
fetch: a
|
|
103
|
-
})
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
function h(t) {
|
|
107
|
-
return [...t].length;
|
|
108
|
-
}
|
|
109
|
-
const B = 3e3, P = 5e3, J = 300 * 1e3, H = 360 * 1e3;
|
|
110
|
-
async function ae(t) {
|
|
111
|
-
const e = t.prompt?.trim() ?? "", n = t.imageUrl?.trim() ?? "", r = t.image;
|
|
112
|
-
h(e) > 1e3 && c("generateCharacter3D prompt must be at most 1000 characters"), r != null && !(r instanceof Blob) && c("generateCharacter3D image must be a file"), r instanceof Blob && r.size === 0 && c("generateCharacter3D image is empty");
|
|
113
|
-
const s = t;
|
|
114
|
-
return I(
|
|
115
|
-
"viggle/characters",
|
|
116
|
-
r instanceof Blob ? V(r, e) : k(n, e),
|
|
117
|
-
s.pollIntervalMs ?? B,
|
|
118
|
-
s.timeoutMs ?? J,
|
|
119
|
-
t.signal
|
|
120
|
-
);
|
|
121
|
-
}
|
|
122
|
-
function V(t, e) {
|
|
123
|
-
const n = new FormData(), r = t instanceof File && t.name ? t.name : "image.png";
|
|
124
|
-
return n.append("image", t, r), e && n.append("prompt", e), { body: n };
|
|
125
|
-
}
|
|
126
|
-
function k(t, e) {
|
|
127
|
-
!e && !t && c(
|
|
128
|
-
"generateCharacter3D requires an image, an https imageUrl, or a prompt"
|
|
129
|
-
), t && !t.startsWith("https://") && c("generateCharacter3D imageUrl must be an https URL");
|
|
130
|
-
const n = {};
|
|
131
|
-
return t && (n.imageUrl = t), e && (n.prompt = e), {
|
|
132
|
-
headers: { "Content-Type": "application/json" },
|
|
133
|
-
body: JSON.stringify(n)
|
|
134
|
-
};
|
|
135
|
-
}
|
|
136
|
-
async function ie(t) {
|
|
137
|
-
const e = t.text?.trim() ?? "";
|
|
138
|
-
(h(e) < 1 || h(e) > 400) && c("generateMotion text must be 1 to 400 characters"), t.durationSeconds != null && (!Number.isInteger(t.durationSeconds) || t.durationSeconds < 3 || t.durationSeconds > 60) && c("generateMotion durationSeconds must be an integer from 3 to 60");
|
|
139
|
-
const n = { text: e };
|
|
140
|
-
t.durationSeconds != null && (n.durationSeconds = t.durationSeconds);
|
|
141
|
-
const r = t;
|
|
142
|
-
return I(
|
|
143
|
-
"viggle/motions",
|
|
144
|
-
{
|
|
145
|
-
headers: { "Content-Type": "application/json" },
|
|
146
|
-
body: JSON.stringify(n)
|
|
147
|
-
},
|
|
148
|
-
r.pollIntervalMs ?? P,
|
|
149
|
-
r.timeoutMs ?? H,
|
|
150
|
-
t.signal
|
|
151
|
-
);
|
|
152
|
-
}
|
|
153
|
-
async function I(t, e, n, r, s) {
|
|
154
|
-
const o = y(), a = Date.now();
|
|
155
|
-
let i = await A(o, t, {
|
|
156
|
-
method: "POST",
|
|
157
|
-
...e,
|
|
158
|
-
signal: s
|
|
159
|
-
});
|
|
160
|
-
for (; i.status !== "ready"; )
|
|
161
|
-
i.status === "failed" && d(i.error || "Viggle generation failed"), Date.now() - a > r && d("Viggle generation timed out"), await q(n, s), i = await A(o, `${t}/${i.id}`, {
|
|
162
|
-
method: "GET",
|
|
163
|
-
signal: s
|
|
164
|
-
});
|
|
165
|
-
return i.url || d("Viggle generation finished without a file URL"), { url: i.url, thumbnailUrl: i.thumbnailUrl };
|
|
166
|
-
}
|
|
167
|
-
async function A(t, e, n) {
|
|
168
|
-
return await (await t(G(T, e), {
|
|
169
|
-
...n,
|
|
170
|
-
cache: "no-store"
|
|
171
|
-
})).json();
|
|
172
|
-
}
|
|
173
|
-
function G(t, e) {
|
|
174
|
-
return `${t.replace(/\/$/, "")}/${e.replace(/^\//, "")}`;
|
|
175
|
-
}
|
|
176
|
-
function q(t, e) {
|
|
177
|
-
if (e?.aborted)
|
|
178
|
-
throw e.reason ?? new DOMException("The operation was aborted", "AbortError");
|
|
179
|
-
return new Promise((n, r) => {
|
|
180
|
-
const s = setTimeout(n, t);
|
|
181
|
-
e?.addEventListener(
|
|
182
|
-
"abort",
|
|
183
|
-
() => {
|
|
184
|
-
clearTimeout(s), r(
|
|
185
|
-
e.reason ?? new DOMException("The operation was aborted", "AbortError")
|
|
186
|
-
);
|
|
187
|
-
},
|
|
188
|
-
{ once: !0 }
|
|
189
|
-
);
|
|
190
|
-
});
|
|
191
|
-
}
|
|
192
|
-
function c(t) {
|
|
193
|
-
throw new p({
|
|
194
|
-
name: "AippyAIError_viggle_input",
|
|
195
|
-
message: `${f.CODE} ${t}`
|
|
196
|
-
});
|
|
197
|
-
}
|
|
198
|
-
function d(t) {
|
|
199
|
-
throw new p({
|
|
200
|
-
name: "AippyAIError_viggle",
|
|
201
|
-
message: `${f.RUNTIME} ${t}`
|
|
202
|
-
});
|
|
203
|
-
}
|
|
204
|
-
function w(t) {
|
|
205
|
-
const e = [];
|
|
206
|
-
if (!t || typeof t != "object")
|
|
207
|
-
throw m("AIConfig must be an object", g.INVALID_CONFIG);
|
|
208
|
-
const n = t;
|
|
209
|
-
for (const [r, s] of Object.entries(n)) {
|
|
210
|
-
if (!s || typeof s != "object") {
|
|
211
|
-
e.push({ key: r, message: "Item must be an object" });
|
|
212
|
-
continue;
|
|
213
|
-
}
|
|
214
|
-
const o = s;
|
|
215
|
-
typeof o.index != "number" && e.push({ key: r, message: "index must be a number" }), typeof o.name != "string" && e.push({ key: r, message: "name must be a string" }), typeof o.description != "string" && e.push({ key: r, message: "description must be a string" });
|
|
216
|
-
const a = o.type;
|
|
217
|
-
if (!["number", "boolean", "text", "enum"].includes(a)) {
|
|
218
|
-
e.push({
|
|
219
|
-
key: r,
|
|
220
|
-
message: `type must be one of: number, boolean, text, enum (got: ${a})`
|
|
221
|
-
});
|
|
222
|
-
continue;
|
|
223
|
-
}
|
|
224
|
-
if (a === "number")
|
|
225
|
-
typeof o.value != "number" && e.push({ key: r, message: 'value must be a number for type "number"' }), o.min !== void 0 && typeof o.min != "number" && e.push({ key: r, message: "min must be a number" }), o.max !== void 0 && typeof o.max != "number" && e.push({ key: r, message: "max must be a number" }), o.step !== void 0 && typeof o.step != "number" && e.push({ key: r, message: "step must be a number" });
|
|
226
|
-
else if (a === "boolean")
|
|
227
|
-
typeof o.value != "boolean" && e.push({ key: r, message: 'value must be a boolean for type "boolean"' });
|
|
228
|
-
else if (a === "text")
|
|
229
|
-
typeof o.value != "string" && e.push({ key: r, message: 'value must be a string for type "text"' });
|
|
230
|
-
else if (a === "enum") {
|
|
231
|
-
if (!Array.isArray(o.options))
|
|
232
|
-
e.push({ key: r, message: 'options must be an array for type "enum"' });
|
|
233
|
-
else if (o.options.length === 0)
|
|
234
|
-
e.push({ key: r, message: 'options array cannot be empty for type "enum"' });
|
|
235
|
-
else
|
|
236
|
-
for (let u = 0; u < o.options.length; u++)
|
|
237
|
-
typeof o.options[u] != "string" && e.push({
|
|
238
|
-
key: r,
|
|
239
|
-
message: `options[${u}] must be a string`
|
|
240
|
-
});
|
|
241
|
-
typeof o.value != "string" ? e.push({ key: r, message: 'value must be a string for type "enum"' }) : Array.isArray(o.options) && !o.options.includes(o.value) && e.push({
|
|
242
|
-
key: r,
|
|
243
|
-
message: `value "${o.value}" is not in options: [${o.options.join(", ")}]`
|
|
244
|
-
});
|
|
245
|
-
}
|
|
246
|
-
o.group !== void 0 && typeof o.group != "string" && e.push({ key: r, message: "group must be a string" });
|
|
247
|
-
}
|
|
248
|
-
if (e.length > 0)
|
|
249
|
-
throw m(
|
|
250
|
-
`AIConfig validation failed with ${e.length} error(s)`,
|
|
251
|
-
g.INVALID_CONFIG,
|
|
252
|
-
{ errors: e }
|
|
253
|
-
);
|
|
254
|
-
}
|
|
255
|
-
function ce(t) {
|
|
256
|
-
let e;
|
|
257
|
-
try {
|
|
258
|
-
e = JSON.parse(t);
|
|
259
|
-
} catch (n) {
|
|
260
|
-
throw m(
|
|
261
|
-
`Invalid JSON: ${n instanceof Error ? n.message : String(n)}`,
|
|
262
|
-
g.INVALID_CONFIG
|
|
263
|
-
);
|
|
264
|
-
}
|
|
265
|
-
return w(e), e;
|
|
266
|
-
}
|
|
267
|
-
function z(t) {
|
|
268
|
-
return w(t), t;
|
|
269
|
-
}
|
|
270
|
-
function Q(t, e) {
|
|
271
|
-
const n = t[e];
|
|
272
|
-
if (!n)
|
|
273
|
-
throw m(
|
|
274
|
-
`AIConfig key "${e}" not found`,
|
|
275
|
-
g.INVALID_CONFIG,
|
|
276
|
-
{ key: e }
|
|
277
|
-
);
|
|
278
|
-
return n.value;
|
|
279
|
-
}
|
|
280
|
-
function W(t) {
|
|
281
|
-
if (!(typeof window > "u"))
|
|
282
|
-
try {
|
|
283
|
-
const e = window.webkit?.messageHandlers?.aippyListener;
|
|
284
|
-
if (e)
|
|
285
|
-
try {
|
|
286
|
-
const n = {
|
|
287
|
-
command: "ai.initialize",
|
|
288
|
-
parameters: JSON.stringify(t)
|
|
289
|
-
};
|
|
290
|
-
e.postMessage(n);
|
|
291
|
-
} catch (n) {
|
|
292
|
-
console.warn("❌ [Aippy AI Config] Failed to send config to iOS app:", n);
|
|
293
|
-
}
|
|
294
|
-
if (window.parent && window.parent !== window)
|
|
295
|
-
try {
|
|
296
|
-
const n = {
|
|
297
|
-
type: "ai.initialize",
|
|
298
|
-
config: JSON.stringify(t)
|
|
299
|
-
};
|
|
300
|
-
window.parent.postMessage(n, "*");
|
|
301
|
-
} catch (n) {
|
|
302
|
-
console.warn("❌ [Aippy AI Config] Failed to send config to parent window:", n);
|
|
303
|
-
}
|
|
304
|
-
} catch (e) {
|
|
305
|
-
console.warn("⚠️ [Aippy AI Config] Failed to send config:", e);
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
function ue(t) {
|
|
309
|
-
const e = z(t);
|
|
310
|
-
return W(e), new Proxy({}, {
|
|
311
|
-
get(n, r) {
|
|
312
|
-
if (typeof r == "string")
|
|
313
|
-
try {
|
|
314
|
-
return Q(e, r);
|
|
315
|
-
} catch {
|
|
316
|
-
return;
|
|
317
|
-
}
|
|
318
|
-
},
|
|
319
|
-
has(n, r) {
|
|
320
|
-
return typeof r != "string" ? !1 : r in e;
|
|
321
|
-
},
|
|
322
|
-
ownKeys(n) {
|
|
323
|
-
return Object.keys(e);
|
|
324
|
-
}
|
|
325
|
-
});
|
|
326
|
-
}
|
|
327
|
-
export {
|
|
328
|
-
T as D,
|
|
329
|
-
x as U,
|
|
330
|
-
oe as a,
|
|
331
|
-
se as b,
|
|
332
|
-
ne as c,
|
|
333
|
-
S as d,
|
|
334
|
-
U as e,
|
|
335
|
-
N as f,
|
|
336
|
-
ae as g,
|
|
337
|
-
ie as h,
|
|
338
|
-
Q as i,
|
|
339
|
-
ue as j,
|
|
340
|
-
z as l,
|
|
341
|
-
F as n,
|
|
342
|
-
ce as p,
|
|
343
|
-
M as r,
|
|
344
|
-
W as s,
|
|
345
|
-
w as v
|
|
346
|
-
};
|
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
import { a as v } from "./bridge-D_-7nPNC.js";
|
|
2
|
-
const l = "wallet.showRecharge", R = 3e5;
|
|
3
|
-
class s extends Error {
|
|
4
|
-
constructor(t, r) {
|
|
5
|
-
super(r), this.type = t, this.name = "WalletRechargeError";
|
|
6
|
-
}
|
|
7
|
-
}
|
|
8
|
-
const c = /* @__PURE__ */ new WeakMap();
|
|
9
|
-
function h() {
|
|
10
|
-
if (typeof window > "u" || typeof document < "u" && document.visibilityState === "hidden")
|
|
11
|
-
return;
|
|
12
|
-
const e = window.webkit?.messageHandlers?.aippyListener;
|
|
13
|
-
if (typeof e?.postMessage == "function")
|
|
14
|
-
return { host: window, listener: e };
|
|
15
|
-
}
|
|
16
|
-
function y(e) {
|
|
17
|
-
e.host.processRechargeResult === e.dispatch && (e.hadPrevious ? e.host.processRechargeResult = e.previous : delete e.host.processRechargeResult), c.delete(e.host);
|
|
18
|
-
}
|
|
19
|
-
function p(e) {
|
|
20
|
-
const t = {
|
|
21
|
-
host: e,
|
|
22
|
-
previous: e.processRechargeResult,
|
|
23
|
-
hadPrevious: Object.prototype.hasOwnProperty.call(
|
|
24
|
-
e,
|
|
25
|
-
"processRechargeResult"
|
|
26
|
-
),
|
|
27
|
-
dispatch: (r) => {
|
|
28
|
-
const a = r && typeof r == "object" && !Array.isArray(r) ? r : void 0;
|
|
29
|
-
if (a?.status === "success" ? t.succeeded = !0 : a?.status === "closed" && typeof a.purchased == "boolean" ? (y(t), t.succeeded && !a.purchased ? t.waiter?.reject(
|
|
30
|
-
new s("protocol", "Inconsistent recharge closure")
|
|
31
|
-
) : t.waiter?.resolve(a.purchased)) : (t.quarantined = !0, t.waiter?.reject(
|
|
32
|
-
new s("protocol", "Invalid recharge result")
|
|
33
|
-
)), typeof t.previous == "function")
|
|
34
|
-
try {
|
|
35
|
-
t.previous.call(e, r);
|
|
36
|
-
} catch {
|
|
37
|
-
console.warn("Native recharge observer failed");
|
|
38
|
-
}
|
|
39
|
-
},
|
|
40
|
-
succeeded: !1,
|
|
41
|
-
quarantined: !1
|
|
42
|
-
};
|
|
43
|
-
return e.processRechargeResult = t.dispatch, c.set(e, t), t;
|
|
44
|
-
}
|
|
45
|
-
function m() {
|
|
46
|
-
let e;
|
|
47
|
-
try {
|
|
48
|
-
if (typeof document < "u" && document.visibilityState === "hidden")
|
|
49
|
-
return;
|
|
50
|
-
const t = h();
|
|
51
|
-
if (t) {
|
|
52
|
-
if (c.has(t.host)) return;
|
|
53
|
-
e = p(t.host), t.listener.postMessage({ command: l });
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
const r = v();
|
|
57
|
-
if (!r) return;
|
|
58
|
-
window.parent.postMessage({ type: l }, r);
|
|
59
|
-
} catch {
|
|
60
|
-
e && (e.quarantined = !0), console.warn("Failed to request native recharge");
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
function E(e) {
|
|
64
|
-
return new Promise((t, r) => {
|
|
65
|
-
if (e?.aborted) {
|
|
66
|
-
r(new s("cancelled", "Recharge wait cancelled"));
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
const a = h();
|
|
70
|
-
if (!a) {
|
|
71
|
-
r(
|
|
72
|
-
new s("unavailable", "Native recharge is unavailable")
|
|
73
|
-
);
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
let n = c.get(a.host);
|
|
77
|
-
if (n?.waiter || n?.quarantined) {
|
|
78
|
-
r(
|
|
79
|
-
new s(
|
|
80
|
-
"busy",
|
|
81
|
-
"Another recharge continuation is active"
|
|
82
|
-
)
|
|
83
|
-
);
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
if (n && a.host.processRechargeResult !== n.dispatch) {
|
|
87
|
-
n.quarantined = !0, r(
|
|
88
|
-
new s(
|
|
89
|
-
"protocol",
|
|
90
|
-
"Native recharge callback was replaced"
|
|
91
|
-
)
|
|
92
|
-
);
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
const f = !n;
|
|
96
|
-
try {
|
|
97
|
-
n ?? (n = p(a.host));
|
|
98
|
-
} catch {
|
|
99
|
-
r(
|
|
100
|
-
new s(
|
|
101
|
-
"unavailable",
|
|
102
|
-
"Native recharge callback is unavailable"
|
|
103
|
-
)
|
|
104
|
-
);
|
|
105
|
-
return;
|
|
106
|
-
}
|
|
107
|
-
let d = !1;
|
|
108
|
-
const o = (i, g = !1) => {
|
|
109
|
-
i && (n.quarantined = !0), !d && (d = !0, clearTimeout(w), e?.removeEventListener("abort", u), i ? r(i) : t(g));
|
|
110
|
-
}, u = () => o(new s("cancelled", "Recharge wait cancelled")), w = setTimeout(
|
|
111
|
-
() => o(
|
|
112
|
-
new s(
|
|
113
|
-
"timeout",
|
|
114
|
-
"Recharge closure was not received"
|
|
115
|
-
)
|
|
116
|
-
),
|
|
117
|
-
R
|
|
118
|
-
);
|
|
119
|
-
if (n.waiter = {
|
|
120
|
-
resolve: (i) => o(void 0, i),
|
|
121
|
-
reject: (i) => o(i)
|
|
122
|
-
}, e?.addEventListener("abort", u, { once: !0 }), e?.aborted) {
|
|
123
|
-
u();
|
|
124
|
-
return;
|
|
125
|
-
}
|
|
126
|
-
if (f)
|
|
127
|
-
try {
|
|
128
|
-
a.listener.postMessage({ command: l });
|
|
129
|
-
} catch {
|
|
130
|
-
o(
|
|
131
|
-
new s("bridge", "Native recharge request failed")
|
|
132
|
-
);
|
|
133
|
-
}
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
export {
|
|
137
|
-
s as W,
|
|
138
|
-
m as s,
|
|
139
|
-
E as w
|
|
140
|
-
};
|