@lemoncloud/chatic-apps-sdk 0.1.0 → 0.3.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/AGENTS.ko.md +82 -0
- package/AGENTS.md +83 -0
- package/GUIDE.ko.md +419 -0
- package/GUIDE.md +431 -0
- package/README.ko.md +582 -0
- package/README.md +381 -65
- package/chatic-apps-sdk.global.js +1 -1
- package/index.cjs +1 -1
- package/index.d.cts +1328 -6
- package/index.d.ts +1328 -6
- package/index.js +322 -193
- package/mock.cjs +1 -1
- package/mock.d.cts +1225 -3
- package/mock.d.ts +1225 -3
- package/mock.js +317 -108
- package/package.json +15 -2
- package/skill/SKILL.ko.md +263 -0
- package/skill/SKILL.md +275 -0
- package/storage-BXB76dd8.js +175 -0
- package/storage-C42PwRjA.cjs +1 -0
- package/storage-BuvWwLx2.js +0 -104
- package/storage-yeS4HWKZ.cjs +0 -1
package/index.js
CHANGED
|
@@ -1,83 +1,156 @@
|
|
|
1
|
-
import { C as
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}, n.remaining));
|
|
11
|
-
}, f = () => {
|
|
12
|
-
for (const [a, n] of r)
|
|
13
|
-
n.remaining !== null && (E() ? (n.timer && clearTimeout(n.timer), n.timer = null, n.remaining = Math.max(0, n.remaining - (Date.now() - n.startedAt))) : n.timer || (n.remaining = Math.max(n.remaining, V), v(a, n)));
|
|
14
|
-
};
|
|
15
|
-
typeof document < "u" && document.addEventListener("visibilitychange", f);
|
|
16
|
-
const h = t.listen((a) => {
|
|
17
|
-
let n;
|
|
1
|
+
import { C as u, c as H, b as K, s as F } from "./storage-BXB76dd8.js";
|
|
2
|
+
import { S as fe } from "./storage-BXB76dd8.js";
|
|
3
|
+
const J = [1], z = Object.freeze({ $listener: !0 }), D = "data", Q = (e) => typeof e == "object" && e !== null && e.$listener === !0, X = (e) => {
|
|
4
|
+
if (e === null || typeof e != "object" || Array.isArray(e)) return null;
|
|
5
|
+
const t = e.$ended;
|
|
6
|
+
return t && typeof t == "object" ? t : null;
|
|
7
|
+
}, Y = (e, t, a) => {
|
|
8
|
+
let r = null, v = null, h = null, p = null, y = !1, g = 0;
|
|
9
|
+
const f = /* @__PURE__ */ new Map(), S = /* @__PURE__ */ new Set(), R = /* @__PURE__ */ new Set(), m = (o) => {
|
|
18
10
|
try {
|
|
19
|
-
|
|
20
|
-
} catch {
|
|
21
|
-
|
|
11
|
+
o();
|
|
12
|
+
} catch (s) {
|
|
13
|
+
a(s);
|
|
22
14
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
15
|
+
}, A = () => {
|
|
16
|
+
y || (y = !0, R.forEach((o) => m(o)));
|
|
17
|
+
}, w = (o) => {
|
|
18
|
+
throw o instanceof u && o.code === "CLOUD_CHANGED" && A(), o;
|
|
19
|
+
}, n = (o) => {
|
|
20
|
+
const s = [...f.values()];
|
|
21
|
+
f.clear(), s.forEach((c) => m(() => c.onEnd?.(o)));
|
|
22
|
+
}, i = e.onPush("OnRuntimeEvent", (o) => {
|
|
23
|
+
const { subscriptionId: s, event: c } = o ?? {}, E = typeof s == "string" ? f.get(s) : void 0;
|
|
24
|
+
if (!E || typeof s != "string") return;
|
|
25
|
+
const b = X(c);
|
|
26
|
+
if (b) {
|
|
27
|
+
f.delete(s);
|
|
28
|
+
const L = typeof b.code == "string" ? b.code : "INTERNAL_ERROR", B = typeof b.message == "string" ? b.message : L;
|
|
29
|
+
L === "CLOUD_CHANGED" && A(), m(() => E.onEnd?.(new u(L, B)));
|
|
32
30
|
return;
|
|
33
31
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
32
|
+
m(() => E.listener(...Array.isArray(c) ? c : [c]));
|
|
33
|
+
}), d = e.onPush("OnRuntimeSessionChanged", (o) => {
|
|
34
|
+
const { seq: s, session: c } = o ?? {};
|
|
35
|
+
!h || typeof s != "number" || s <= h.seq || (h = { ...h, seq: s }, p = c ?? null, S.forEach((E) => m(() => E(p))));
|
|
36
|
+
}), l = () => {
|
|
37
|
+
if (!t())
|
|
38
|
+
return Promise.reject(
|
|
39
|
+
new u("NOT_SUPPORTED", "This app does not answer this page's cloud data requests.")
|
|
40
|
+
);
|
|
41
|
+
if (!r) {
|
|
42
|
+
const o = new Promise((c, E) => {
|
|
43
|
+
v = E;
|
|
44
|
+
}), s = Promise.race([
|
|
45
|
+
e.request("RuntimeHello", { contracts: [...J] }, { timeoutMs: null }),
|
|
46
|
+
o
|
|
47
|
+
]).then((c) => (r === s && (h = c, p = c.session ?? null), c)).catch((c) => (r === s && (r = null), w(c)));
|
|
48
|
+
r = s;
|
|
49
|
+
}
|
|
50
|
+
return r;
|
|
51
|
+
}, P = async (o, s) => {
|
|
52
|
+
if (!(await l()).allowed[o].includes(s))
|
|
53
|
+
throw new u(
|
|
54
|
+
"RUNTIME_NOT_ALLOWED",
|
|
55
|
+
`${s} is not one this page may ${o === "calls" ? "call" : "subscribe to"}.`
|
|
56
|
+
);
|
|
57
|
+
}, C = async (o, ...s) => (await P("calls", o), (await e.request("RuntimeCall", { target: D, method: o, args: s }).catch(w)).value), k = async (o, s, c, E) => {
|
|
58
|
+
await P("streams", o);
|
|
59
|
+
const b = `cas-s${(++g).toString(36)}`;
|
|
60
|
+
f.set(b, { listener: c, onEnd: E });
|
|
61
|
+
try {
|
|
62
|
+
await e.request("RuntimeSubscribe", {
|
|
63
|
+
subscriptionId: b,
|
|
64
|
+
target: D,
|
|
65
|
+
topic: o,
|
|
66
|
+
args: s.some(Q) ? s : [...s, z]
|
|
67
|
+
});
|
|
68
|
+
} catch (L) {
|
|
69
|
+
f.delete(b), w(L);
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
stop: async () => {
|
|
73
|
+
f.delete(b) && await e.request("RuntimeUnsubscribe", { subscriptionId: b }).catch(() => {
|
|
74
|
+
});
|
|
38
75
|
}
|
|
39
|
-
}
|
|
40
|
-
})
|
|
76
|
+
};
|
|
77
|
+
}, q = async () => {
|
|
78
|
+
await l();
|
|
79
|
+
const o = p?.committedSiteId;
|
|
80
|
+
if (!o)
|
|
81
|
+
throw new u(
|
|
82
|
+
"NOT_SUPPORTED",
|
|
83
|
+
"A place profile needs the session permission, while the session is on a place."
|
|
84
|
+
);
|
|
85
|
+
return o;
|
|
86
|
+
}, _ = async () => {
|
|
87
|
+
await l();
|
|
88
|
+
const o = p?.context.identity.userId;
|
|
89
|
+
if (!o) throw new u("NOT_SUPPORTED", "The user's own profile needs the session permission.");
|
|
90
|
+
return o;
|
|
91
|
+
}, V = async (o) => `${await q()}@${o}`, U = async (o) => C("profile.cacheRead", await V(o)), x = async (o, s, c) => k(
|
|
92
|
+
"profile.observeItem",
|
|
93
|
+
[await V(o)],
|
|
94
|
+
s,
|
|
95
|
+
c?.onEnd
|
|
96
|
+
);
|
|
41
97
|
return {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
98
|
+
connect: () => l().then(({ contract: o, allowed: s }) => ({ contract: o, allowed: s })),
|
|
99
|
+
can: (o) => !!h && (h.allowed.calls.includes(o) || h.allowed.streams.includes(o)),
|
|
100
|
+
call: C,
|
|
101
|
+
subscribe: k,
|
|
102
|
+
sendMessage: (o, s) => C("chat.sendChat", { channelId: o, content: s }),
|
|
103
|
+
react: (o, s, c) => C("chat.setReaction", { chatId: o, emoji: s, action: c ? "on" : "off" }),
|
|
104
|
+
placeProfile: U,
|
|
105
|
+
placeProfiles: async () => C("profile.cacheReadList", { sid: await q() }),
|
|
106
|
+
observePlaceProfile: x,
|
|
107
|
+
myProfile: async () => U(await _()),
|
|
108
|
+
observeMyProfile: async (o, s) => x(await _(), o, s),
|
|
109
|
+
session: () => p,
|
|
110
|
+
onSessionChange: (o) => (S.add(o), () => S.delete(o)),
|
|
111
|
+
onCloudChanged: (o) => (R.add(o), () => R.delete(o)),
|
|
112
|
+
// A page restored from the back-forward cache meets a new host: its streams are gone there.
|
|
113
|
+
reset: () => {
|
|
114
|
+
v?.(
|
|
115
|
+
new u("DISCONNECTED", "The page was restored before the app answered. Connect again.")
|
|
116
|
+
), v = null, r = null, h = null, p = null, n(new u("DISCONNECTED", "The page was restored; its streams ended. Subscribe again."));
|
|
59
117
|
},
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
118
|
+
dispose: () => {
|
|
119
|
+
i(), d(), f.clear();
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
}, Z = () => {
|
|
123
|
+
const e = () => Promise.reject(new u("NOT_IN_APP", "The app's data is read only in the app."));
|
|
124
|
+
return {
|
|
125
|
+
connect: e,
|
|
126
|
+
can: () => !1,
|
|
127
|
+
call: e,
|
|
128
|
+
subscribe: e,
|
|
129
|
+
sendMessage: e,
|
|
130
|
+
react: e,
|
|
131
|
+
placeProfile: e,
|
|
132
|
+
placeProfiles: e,
|
|
133
|
+
observePlaceProfile: e,
|
|
134
|
+
myProfile: e,
|
|
135
|
+
observeMyProfile: e,
|
|
136
|
+
session: () => null,
|
|
137
|
+
onSessionChange: () => () => {
|
|
138
|
+
},
|
|
139
|
+
onCloudChanged: () => () => {
|
|
67
140
|
}
|
|
68
141
|
};
|
|
69
|
-
},
|
|
70
|
-
send: (
|
|
71
|
-
listen: (
|
|
72
|
-
const
|
|
73
|
-
const
|
|
74
|
-
typeof
|
|
142
|
+
}, ee = () => typeof window < "u" && !!window.ReactNativeWebView, te = () => ({
|
|
143
|
+
send: (e) => window.ReactNativeWebView?.postMessage(e),
|
|
144
|
+
listen: (e) => {
|
|
145
|
+
const t = (a) => {
|
|
146
|
+
const r = a.data;
|
|
147
|
+
typeof r == "string" && e(r);
|
|
75
148
|
};
|
|
76
|
-
return window.addEventListener("message",
|
|
77
|
-
window.removeEventListener("message",
|
|
149
|
+
return window.addEventListener("message", t), document.addEventListener("message", t), () => {
|
|
150
|
+
window.removeEventListener("message", t), document.removeEventListener("message", t);
|
|
78
151
|
};
|
|
79
152
|
}
|
|
80
|
-
}),
|
|
153
|
+
}), O = {
|
|
81
154
|
finish: "FinishSubWebView",
|
|
82
155
|
title: "SetSubWebViewTitle",
|
|
83
156
|
haptic: "TriggerHaptic",
|
|
@@ -88,201 +161,257 @@ const M = () => `cas-${Date.now().toString(36)}-${(++W).toString(36)}`, E = () =
|
|
|
88
161
|
back: "SetCanGoBack",
|
|
89
162
|
closeGuard: "SetSubWebViewCloseGuard",
|
|
90
163
|
errorReport: "ReportSubWebViewError",
|
|
91
|
-
storage: "GetSubWebViewStorage"
|
|
92
|
-
|
|
164
|
+
storage: "GetSubWebViewStorage",
|
|
165
|
+
permissions: "RequestSubWebViewPermission",
|
|
166
|
+
data: "RuntimeHello"
|
|
167
|
+
}, W = 1, ne = 1e3, oe = 4e3, $ = () => typeof window < "u" && window.ChaticSubWebView || null, re = () => new Promise((e) => {
|
|
93
168
|
if (typeof document > "u" || document.readyState === "complete") {
|
|
94
|
-
|
|
169
|
+
e($());
|
|
95
170
|
return;
|
|
96
171
|
}
|
|
97
|
-
window.addEventListener("load", () =>
|
|
98
|
-
}),
|
|
99
|
-
let
|
|
172
|
+
window.addEventListener("load", () => e($()), { once: !0 });
|
|
173
|
+
}), se = (e) => {
|
|
174
|
+
let t, a;
|
|
100
175
|
try {
|
|
101
|
-
|
|
176
|
+
e instanceof Error ? (t = e.message || e.name, a = typeof e.stack == "string" ? e.stack : void 0) : typeof e == "string" ? t = e : t = `A non-Error value was thrown: ${Object.prototype.toString.call(e)}`;
|
|
102
177
|
} catch {
|
|
103
|
-
|
|
178
|
+
t = "An error that could not be read was thrown";
|
|
104
179
|
}
|
|
105
180
|
return {
|
|
106
|
-
message: (
|
|
107
|
-
...
|
|
181
|
+
message: (t || "Unknown error").slice(0, ne),
|
|
182
|
+
...a ? { stack: a.slice(0, oe) } : {}
|
|
108
183
|
};
|
|
109
|
-
},
|
|
110
|
-
if (
|
|
111
|
-
throw new
|
|
112
|
-
const
|
|
113
|
-
for (const [
|
|
114
|
-
const
|
|
115
|
-
return
|
|
116
|
-
},
|
|
117
|
-
let
|
|
118
|
-
const
|
|
119
|
-
throw
|
|
120
|
-
})),
|
|
121
|
-
const
|
|
184
|
+
}, I = (e) => new u("NOT_SUPPORTED", `${e} is not available here: an older app, or not granted.`), N = (e) => Promise.reject(new u("NOT_IN_APP", `${e} needs the app; this page is in a browser.`)), j = (e = {}) => {
|
|
185
|
+
if (e === null || typeof e != "object" || Array.isArray(e))
|
|
186
|
+
throw new u("INVALID", "link() takes an object of query params, such as { level: 3 }.");
|
|
187
|
+
const t = new URLSearchParams();
|
|
188
|
+
for (const [r, v] of Object.entries(e)) t.append(r, String(v));
|
|
189
|
+
const a = t.toString();
|
|
190
|
+
return a ? `?${a}` : "";
|
|
191
|
+
}, G = (e) => typeof location > "u" ? `/${e}` : `${location.origin}/${e}`;
|
|
192
|
+
let T = null;
|
|
193
|
+
const ue = (e = {}) => (T || (T = (ee() ? ae(te(), e) : Promise.resolve(de())).catch((t) => {
|
|
194
|
+
throw T = null, t;
|
|
195
|
+
})), T), ae = async (e, t = {}) => {
|
|
196
|
+
const a = H(e, t.timeoutMs);
|
|
122
197
|
try {
|
|
123
|
-
const
|
|
124
|
-
return
|
|
125
|
-
} catch (
|
|
126
|
-
throw
|
|
198
|
+
const r = await M(a, !0);
|
|
199
|
+
return ie(a, r, t);
|
|
200
|
+
} catch (r) {
|
|
201
|
+
throw a.close(), r;
|
|
127
202
|
}
|
|
128
|
-
},
|
|
129
|
-
const
|
|
130
|
-
if (
|
|
131
|
-
throw new
|
|
203
|
+
}, M = async (e, t) => {
|
|
204
|
+
const a = await e.request("WebAppReady", {}), r = a.subWebView ?? (t ? await re() : null);
|
|
205
|
+
if (r && r.protocolVersion !== W)
|
|
206
|
+
throw new u(
|
|
132
207
|
"UNSUPPORTED_PROTOCOL",
|
|
133
|
-
`The app speaks protocol ${String(
|
|
208
|
+
`The app speaks protocol ${String(r.protocolVersion)}; this library speaks ${W}.`
|
|
134
209
|
);
|
|
135
210
|
return {
|
|
136
|
-
supported: new Set(Array.isArray(
|
|
137
|
-
context:
|
|
211
|
+
supported: new Set(Array.isArray(a.supportedWebMessages) ? a.supportedWebMessages : []),
|
|
212
|
+
context: r
|
|
138
213
|
};
|
|
139
|
-
},
|
|
140
|
-
let
|
|
141
|
-
const
|
|
214
|
+
}, ie = (e, t, a) => {
|
|
215
|
+
let r = null, v = null;
|
|
216
|
+
const h = /* @__PURE__ */ new Set(), p = [], y = (n) => t.supported.has(O[n]), g = (n, i, d, l) => {
|
|
217
|
+
const P = l ?? O[n];
|
|
218
|
+
return t.supported.has(P) ? e.request(P, i, d === void 0 ? {} : { timeoutMs: d }) : Promise.reject(I(n));
|
|
219
|
+
}, f = Y(
|
|
220
|
+
e,
|
|
221
|
+
() => y("data"),
|
|
222
|
+
(n) => {
|
|
223
|
+
w.reportError(n);
|
|
224
|
+
}
|
|
225
|
+
);
|
|
226
|
+
p.push(() => f.dispose());
|
|
227
|
+
const S = (n, i) => y("storage") ? e.request(n, i) : Promise.reject(I("storage")), R = (n) => h.forEach((i) => {
|
|
142
228
|
try {
|
|
143
|
-
|
|
144
|
-
} catch (
|
|
145
|
-
|
|
229
|
+
i(n);
|
|
230
|
+
} catch (d) {
|
|
231
|
+
w.reportError(d);
|
|
146
232
|
}
|
|
147
|
-
}),
|
|
148
|
-
|
|
149
|
-
}),
|
|
233
|
+
}), m = () => {
|
|
234
|
+
y("back") && e.request(O.back, { canGoBack: !!r }).catch(() => {
|
|
235
|
+
}), y("closeGuard") && e.request(O.closeGuard, { enabled: !!v }).catch(() => {
|
|
150
236
|
});
|
|
151
|
-
},
|
|
152
|
-
if (!
|
|
153
|
-
|
|
237
|
+
}, A = (n) => {
|
|
238
|
+
if (!n.persisted) {
|
|
239
|
+
m();
|
|
154
240
|
return;
|
|
155
241
|
}
|
|
156
|
-
|
|
157
|
-
const
|
|
158
|
-
|
|
159
|
-
const
|
|
160
|
-
|
|
242
|
+
M(e, !1).then((i) => {
|
|
243
|
+
const d = t.context;
|
|
244
|
+
t.supported = i.supported, i.context && (t.context = i.context), m(), f.reset();
|
|
245
|
+
const l = t.context, P = l && (l.theme !== d?.theme || l.locale !== d?.locale || JSON.stringify(l.safeArea) !== JSON.stringify(d?.safeArea));
|
|
246
|
+
l && P && R(l);
|
|
161
247
|
}).catch(() => {
|
|
162
248
|
});
|
|
163
249
|
};
|
|
164
|
-
typeof window < "u" && (window.addEventListener("pageshow",
|
|
165
|
-
|
|
250
|
+
typeof window < "u" && (window.addEventListener("pageshow", A), p.push(() => window.removeEventListener("pageshow", A))), p.push(
|
|
251
|
+
e.onPush("OnBackPressed", () => {
|
|
166
252
|
try {
|
|
167
|
-
|
|
168
|
-
} catch (
|
|
169
|
-
|
|
253
|
+
r?.();
|
|
254
|
+
} catch (n) {
|
|
255
|
+
w.reportError(n);
|
|
170
256
|
}
|
|
171
257
|
})
|
|
172
|
-
),
|
|
173
|
-
|
|
174
|
-
const
|
|
175
|
-
if (!
|
|
176
|
-
const
|
|
177
|
-
Promise.resolve().then(() =>
|
|
258
|
+
), p.push(
|
|
259
|
+
e.onPush("OnSubWebViewCloseRequested", (n) => {
|
|
260
|
+
const i = v;
|
|
261
|
+
if (!i) return;
|
|
262
|
+
const d = n?.trigger ?? "control";
|
|
263
|
+
Promise.resolve().then(() => i(d)).then((l) => l ? w.finish() : void 0).catch((l) => w.reportError(l));
|
|
178
264
|
})
|
|
179
|
-
),
|
|
180
|
-
|
|
181
|
-
|
|
265
|
+
), p.push(
|
|
266
|
+
e.onPush("OnSubWebViewContextChanged", (n) => {
|
|
267
|
+
t.context && (t.context = { ...t.context, ...n }, R(t.context));
|
|
182
268
|
})
|
|
183
269
|
);
|
|
184
|
-
const
|
|
270
|
+
const w = {
|
|
185
271
|
inApp: !0,
|
|
186
272
|
get context() {
|
|
187
|
-
return
|
|
273
|
+
return t.context;
|
|
188
274
|
},
|
|
189
|
-
supports:
|
|
190
|
-
finish: (
|
|
275
|
+
supports: y,
|
|
276
|
+
finish: (n) => g("finish", n === void 0 ? {} : { result: n }).then(() => {
|
|
191
277
|
}),
|
|
192
|
-
setTitle: (
|
|
278
|
+
setTitle: (n) => g("title", { title: n }).then(() => {
|
|
193
279
|
}),
|
|
194
|
-
haptic: (
|
|
195
|
-
|
|
280
|
+
haptic: (n) => {
|
|
281
|
+
y("haptic") && e.request(O.haptic, { kind: n }).catch(() => {
|
|
196
282
|
});
|
|
197
283
|
},
|
|
198
|
-
copy: (
|
|
284
|
+
copy: (n) => g("clipboard", { text: n }).then(() => {
|
|
199
285
|
}),
|
|
200
|
-
openUrl: (
|
|
286
|
+
openUrl: (n) => g("openUrl", { url: n }).then(() => {
|
|
201
287
|
}),
|
|
202
|
-
share: (
|
|
203
|
-
(
|
|
288
|
+
share: (n) => g("share", n, null).then(
|
|
289
|
+
(i) => i?.action === "dismissedAction" ? "dismissed" : "shared"
|
|
204
290
|
),
|
|
205
|
-
getUserKey: () =>
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
291
|
+
getUserKey: () => g("userKey").then((n) => n.key),
|
|
292
|
+
permissions: {
|
|
293
|
+
query: (n) => g("permissions", { kind: n }, void 0, "GetSubWebViewPermission").then(
|
|
294
|
+
(i) => i.state
|
|
295
|
+
),
|
|
296
|
+
// Waits for the user, however long they take.
|
|
297
|
+
request: (n) => g("permissions", { kind: n }, null).then((i) => i.state)
|
|
298
|
+
},
|
|
299
|
+
openSettings: () => g("permissions", {}, void 0, "OpenSettings").then(() => {
|
|
213
300
|
}),
|
|
214
|
-
|
|
215
|
-
|
|
301
|
+
reportError: (n) => y("errorReport") ? e.request(O.errorReport, se(n)).then((i) => !!i?.recorded).catch(() => !1) : Promise.resolve(!1),
|
|
302
|
+
data: f,
|
|
303
|
+
storage: F({
|
|
304
|
+
get: (n) => S("GetSubWebViewStorage", { keys: n }),
|
|
305
|
+
set: (n) => S("SetSubWebViewStorage", { entries: n }),
|
|
306
|
+
remove: (n) => S("RemoveSubWebViewStorage", { keys: n }),
|
|
307
|
+
clear: () => S("ClearSubWebViewStorage", {}),
|
|
308
|
+
info: () => S("GetSubWebViewStorageInfo", {})
|
|
309
|
+
}),
|
|
310
|
+
onBack: (n) => {
|
|
311
|
+
r = n, m();
|
|
216
312
|
},
|
|
217
|
-
onCloseRequest: (
|
|
218
|
-
|
|
313
|
+
onCloseRequest: (n) => {
|
|
314
|
+
v = n, m();
|
|
219
315
|
},
|
|
220
|
-
onContextChange: (
|
|
221
|
-
link: (
|
|
222
|
-
const
|
|
223
|
-
return
|
|
316
|
+
onContextChange: (n) => (h.add(n), () => h.delete(n)),
|
|
317
|
+
link: (n) => {
|
|
318
|
+
const i = j(n), d = t.context?.appLink;
|
|
319
|
+
return d ? `${d}${i}` : G(i);
|
|
224
320
|
},
|
|
225
321
|
disconnect: () => {
|
|
226
|
-
|
|
322
|
+
p.forEach((n) => n()), e.close(), T = null;
|
|
227
323
|
}
|
|
228
324
|
};
|
|
229
|
-
if (
|
|
230
|
-
const
|
|
231
|
-
|
|
232
|
-
},
|
|
233
|
-
|
|
325
|
+
if (a.reportErrors !== !1 && typeof window < "u") {
|
|
326
|
+
const n = (d) => {
|
|
327
|
+
w.reportError(d.error ?? d.message);
|
|
328
|
+
}, i = (d) => {
|
|
329
|
+
w.reportError(d.reason);
|
|
234
330
|
};
|
|
235
|
-
window.addEventListener("error",
|
|
236
|
-
window.removeEventListener("error",
|
|
331
|
+
window.addEventListener("error", n), window.addEventListener("unhandledrejection", i), p.push(() => {
|
|
332
|
+
window.removeEventListener("error", n), window.removeEventListener("unhandledrejection", i);
|
|
237
333
|
});
|
|
238
334
|
}
|
|
239
|
-
return
|
|
240
|
-
},
|
|
241
|
-
const
|
|
335
|
+
return w;
|
|
336
|
+
}, ce = () => {
|
|
337
|
+
const e = async (t) => {
|
|
338
|
+
try {
|
|
339
|
+
const a = await navigator.permissions.query({ name: t });
|
|
340
|
+
return a.state === "granted" ? "granted" : a.state === "denied" ? "blocked" : "prompt";
|
|
341
|
+
} catch {
|
|
342
|
+
return "prompt";
|
|
343
|
+
}
|
|
344
|
+
};
|
|
345
|
+
return {
|
|
346
|
+
query: e,
|
|
347
|
+
request: async (t) => {
|
|
348
|
+
if (typeof navigator > "u" || !navigator.mediaDevices?.getUserMedia)
|
|
349
|
+
throw new u("NOT_SUPPORTED", `This browser cannot capture the ${t}.`);
|
|
350
|
+
try {
|
|
351
|
+
return (await navigator.mediaDevices.getUserMedia(
|
|
352
|
+
t === "camera" ? { video: !0 } : { audio: !0 }
|
|
353
|
+
)).getTracks().forEach((r) => r.stop()), "granted";
|
|
354
|
+
} catch (a) {
|
|
355
|
+
const r = a?.name;
|
|
356
|
+
if (r === "NotFoundError" || r === "OverconstrainedError")
|
|
357
|
+
throw new u("UNAVAILABLE", `This device has no ${t}.`);
|
|
358
|
+
if (r === "NotReadableError" || r === "SecurityError" || r === "TypeError" || r === "AbortError")
|
|
359
|
+
throw new u("INTERNAL_ERROR", `The ${t} could not be used: ${r}.`);
|
|
360
|
+
return await e(t) === "blocked" ? "blocked" : "prompt";
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
};
|
|
364
|
+
}, de = () => {
|
|
365
|
+
const e = (t) => typeof navigator < "u" && navigator.clipboard ? navigator.clipboard.writeText(t) : Promise.reject(I("The clipboard"));
|
|
242
366
|
return {
|
|
243
367
|
inApp: !1,
|
|
244
368
|
context: null,
|
|
245
369
|
supports: () => !1,
|
|
246
|
-
finish: () =>
|
|
247
|
-
setTitle: async (
|
|
248
|
-
typeof document < "u" && (document.title =
|
|
370
|
+
finish: () => N("Finishing the view"),
|
|
371
|
+
setTitle: async (t) => {
|
|
372
|
+
typeof document < "u" && (document.title = t);
|
|
249
373
|
},
|
|
250
374
|
haptic: () => {
|
|
251
375
|
typeof navigator < "u" && navigator.vibrate?.(10);
|
|
252
376
|
},
|
|
253
|
-
copy:
|
|
254
|
-
openUrl: async (
|
|
255
|
-
typeof window < "u" && window.open(
|
|
377
|
+
copy: e,
|
|
378
|
+
openUrl: async (t) => {
|
|
379
|
+
typeof window < "u" && window.open(t, "_blank", "noopener,noreferrer");
|
|
256
380
|
},
|
|
257
|
-
share: async (
|
|
258
|
-
const
|
|
259
|
-
if (!
|
|
381
|
+
share: async (t) => {
|
|
382
|
+
const a = [t.message, t.url].filter(Boolean).join(" ");
|
|
383
|
+
if (!a) throw new u("INVALID", "Share a message or a url.");
|
|
260
384
|
if (typeof navigator < "u" && navigator.share)
|
|
261
385
|
try {
|
|
262
|
-
return await navigator.share(
|
|
263
|
-
} catch (
|
|
264
|
-
if (
|
|
386
|
+
return await navigator.share(t), "shared";
|
|
387
|
+
} catch (r) {
|
|
388
|
+
if (r?.name === "AbortError") return "dismissed";
|
|
265
389
|
}
|
|
266
|
-
return await
|
|
390
|
+
return await e(a), "copied";
|
|
267
391
|
},
|
|
268
|
-
getUserKey: () =>
|
|
269
|
-
|
|
270
|
-
|
|
392
|
+
getUserKey: () => N("A user key"),
|
|
393
|
+
permissions: ce(),
|
|
394
|
+
data: Z(),
|
|
395
|
+
openSettings: () => N("Opening the settings"),
|
|
396
|
+
reportError: async (t) => (console.error(t), !1),
|
|
397
|
+
storage: K(),
|
|
271
398
|
onBack: () => {
|
|
272
399
|
},
|
|
273
400
|
onCloseRequest: () => {
|
|
274
401
|
},
|
|
275
402
|
onContextChange: () => () => {
|
|
276
403
|
},
|
|
277
|
-
link: (
|
|
404
|
+
link: (t) => G(j(t)),
|
|
278
405
|
disconnect: () => {
|
|
279
|
-
|
|
406
|
+
T = null;
|
|
280
407
|
}
|
|
281
408
|
};
|
|
282
409
|
};
|
|
283
410
|
export {
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
411
|
+
u as ChaticAppsError,
|
|
412
|
+
z as LISTENER,
|
|
413
|
+
fe as SDK_BRIDGE_VERSION,
|
|
414
|
+
J as SDK_DATA_CONTRACTS,
|
|
415
|
+
ue as connect,
|
|
416
|
+
ee as isInApp
|
|
288
417
|
};
|