@lemoncloud/chatic-apps-sdk 0.2.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 +34 -7
- package/GUIDE.ko.md +419 -0
- package/GUIDE.md +218 -6
- package/README.ko.md +582 -0
- package/README.md +364 -46
- package/chatic-apps-sdk.global.js +1 -1
- package/index.cjs +1 -1
- package/index.d.cts +1295 -6
- package/index.d.ts +1295 -6
- package/index.js +282 -196
- package/mock.cjs +1 -1
- package/mock.d.cts +1203 -3
- package/mock.d.ts +1203 -3
- package/mock.js +306 -118
- 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 u, b as
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}, o.remaining));
|
|
11
|
-
}, w = () => {
|
|
12
|
-
for (const [a, o] of n)
|
|
13
|
-
o.remaining !== null && (R() ? (o.timer && clearTimeout(o.timer), o.timer = null, o.remaining = Math.max(0, o.remaining - (Date.now() - o.startedAt))) : o.timer || (o.remaining = Math.max(o.remaining, N), v(a, o)));
|
|
14
|
-
};
|
|
15
|
-
typeof document < "u" && document.addEventListener("visibilitychange", w);
|
|
16
|
-
const g = r.listen((a) => {
|
|
17
|
-
let o;
|
|
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
|
-
o
|
|
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
|
-
h = !0, g(), typeof document < "u" && document.removeEventListener("visibilitychange", w);
|
|
63
|
-
for (const a of n.values())
|
|
64
|
-
a.timer && clearTimeout(a.timer), a.reject(new u("DISCONNECTED", "The connection to the app was closed."));
|
|
65
|
-
n.clear(), s.clear();
|
|
66
|
-
}
|
|
118
|
+
dispose: () => {
|
|
119
|
+
i(), d(), f.clear();
|
|
67
120
|
}
|
|
68
121
|
};
|
|
69
|
-
},
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
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: () => () => {
|
|
140
|
+
}
|
|
141
|
+
};
|
|
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
149
|
return window.addEventListener("message", t), document.addEventListener("message", t), () => {
|
|
77
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",
|
|
@@ -89,243 +162,256 @@ const q = () => `cas-${Date.now().toString(36)}-${(++W).toString(36)}`, R = () =
|
|
|
89
162
|
closeGuard: "SetSubWebViewCloseGuard",
|
|
90
163
|
errorReport: "ReportSubWebViewError",
|
|
91
164
|
storage: "GetSubWebViewStorage",
|
|
92
|
-
permissions: "RequestSubWebViewPermission"
|
|
93
|
-
|
|
165
|
+
permissions: "RequestSubWebViewPermission",
|
|
166
|
+
data: "RuntimeHello"
|
|
167
|
+
}, W = 1, ne = 1e3, oe = 4e3, $ = () => typeof window < "u" && window.ChaticSubWebView || null, re = () => new Promise((e) => {
|
|
94
168
|
if (typeof document > "u" || document.readyState === "complete") {
|
|
95
|
-
|
|
169
|
+
e($());
|
|
96
170
|
return;
|
|
97
171
|
}
|
|
98
|
-
window.addEventListener("load", () =>
|
|
99
|
-
}),
|
|
100
|
-
let t,
|
|
172
|
+
window.addEventListener("load", () => e($()), { once: !0 });
|
|
173
|
+
}), se = (e) => {
|
|
174
|
+
let t, a;
|
|
101
175
|
try {
|
|
102
|
-
|
|
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)}`;
|
|
103
177
|
} catch {
|
|
104
178
|
t = "An error that could not be read was thrown";
|
|
105
179
|
}
|
|
106
180
|
return {
|
|
107
|
-
message: (t || "Unknown error").slice(0,
|
|
108
|
-
...
|
|
181
|
+
message: (t || "Unknown error").slice(0, ne),
|
|
182
|
+
...a ? { stack: a.slice(0, oe) } : {}
|
|
109
183
|
};
|
|
110
|
-
},
|
|
111
|
-
if (
|
|
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))
|
|
112
186
|
throw new u("INVALID", "link() takes an object of query params, such as { level: 3 }.");
|
|
113
187
|
const t = new URLSearchParams();
|
|
114
|
-
for (const [
|
|
115
|
-
const
|
|
116
|
-
return
|
|
117
|
-
},
|
|
118
|
-
let
|
|
119
|
-
const
|
|
120
|
-
throw
|
|
121
|
-
})),
|
|
122
|
-
const
|
|
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);
|
|
123
197
|
try {
|
|
124
|
-
const
|
|
125
|
-
return
|
|
126
|
-
} catch (
|
|
127
|
-
throw
|
|
198
|
+
const r = await M(a, !0);
|
|
199
|
+
return ie(a, r, t);
|
|
200
|
+
} catch (r) {
|
|
201
|
+
throw a.close(), r;
|
|
128
202
|
}
|
|
129
|
-
},
|
|
130
|
-
const
|
|
131
|
-
if (
|
|
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)
|
|
132
206
|
throw new u(
|
|
133
207
|
"UNSUPPORTED_PROTOCOL",
|
|
134
|
-
`The app speaks protocol ${String(
|
|
208
|
+
`The app speaks protocol ${String(r.protocolVersion)}; this library speaks ${W}.`
|
|
135
209
|
);
|
|
136
210
|
return {
|
|
137
|
-
supported: new Set(Array.isArray(
|
|
138
|
-
context:
|
|
211
|
+
supported: new Set(Array.isArray(a.supportedWebMessages) ? a.supportedWebMessages : []),
|
|
212
|
+
context: r
|
|
139
213
|
};
|
|
140
|
-
},
|
|
141
|
-
let
|
|
142
|
-
const
|
|
143
|
-
const
|
|
144
|
-
return t.supported.has(
|
|
145
|
-
},
|
|
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) => {
|
|
146
228
|
try {
|
|
147
|
-
i(
|
|
148
|
-
} catch (
|
|
149
|
-
|
|
229
|
+
i(n);
|
|
230
|
+
} catch (d) {
|
|
231
|
+
w.reportError(d);
|
|
150
232
|
}
|
|
151
|
-
}),
|
|
152
|
-
|
|
153
|
-
}),
|
|
233
|
+
}), m = () => {
|
|
234
|
+
y("back") && e.request(O.back, { canGoBack: !!r }).catch(() => {
|
|
235
|
+
}), y("closeGuard") && e.request(O.closeGuard, { enabled: !!v }).catch(() => {
|
|
154
236
|
});
|
|
155
|
-
},
|
|
156
|
-
if (!
|
|
157
|
-
|
|
237
|
+
}, A = (n) => {
|
|
238
|
+
if (!n.persisted) {
|
|
239
|
+
m();
|
|
158
240
|
return;
|
|
159
241
|
}
|
|
160
|
-
|
|
161
|
-
const
|
|
162
|
-
t.supported = i.supported, i.context && (t.context = i.context),
|
|
163
|
-
const
|
|
164
|
-
|
|
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);
|
|
165
247
|
}).catch(() => {
|
|
166
248
|
});
|
|
167
249
|
};
|
|
168
|
-
typeof window < "u" && (window.addEventListener("pageshow",
|
|
169
|
-
|
|
250
|
+
typeof window < "u" && (window.addEventListener("pageshow", A), p.push(() => window.removeEventListener("pageshow", A))), p.push(
|
|
251
|
+
e.onPush("OnBackPressed", () => {
|
|
170
252
|
try {
|
|
171
|
-
|
|
172
|
-
} catch (
|
|
173
|
-
|
|
253
|
+
r?.();
|
|
254
|
+
} catch (n) {
|
|
255
|
+
w.reportError(n);
|
|
174
256
|
}
|
|
175
257
|
})
|
|
176
|
-
),
|
|
177
|
-
|
|
178
|
-
const i =
|
|
258
|
+
), p.push(
|
|
259
|
+
e.onPush("OnSubWebViewCloseRequested", (n) => {
|
|
260
|
+
const i = v;
|
|
179
261
|
if (!i) return;
|
|
180
|
-
const
|
|
181
|
-
Promise.resolve().then(() => i(
|
|
262
|
+
const d = n?.trigger ?? "control";
|
|
263
|
+
Promise.resolve().then(() => i(d)).then((l) => l ? w.finish() : void 0).catch((l) => w.reportError(l));
|
|
182
264
|
})
|
|
183
|
-
),
|
|
184
|
-
|
|
185
|
-
t.context && (t.context = { ...t.context, ...
|
|
265
|
+
), p.push(
|
|
266
|
+
e.onPush("OnSubWebViewContextChanged", (n) => {
|
|
267
|
+
t.context && (t.context = { ...t.context, ...n }, R(t.context));
|
|
186
268
|
})
|
|
187
269
|
);
|
|
188
|
-
const
|
|
270
|
+
const w = {
|
|
189
271
|
inApp: !0,
|
|
190
272
|
get context() {
|
|
191
273
|
return t.context;
|
|
192
274
|
},
|
|
193
|
-
supports:
|
|
194
|
-
finish: (
|
|
275
|
+
supports: y,
|
|
276
|
+
finish: (n) => g("finish", n === void 0 ? {} : { result: n }).then(() => {
|
|
195
277
|
}),
|
|
196
|
-
setTitle: (
|
|
278
|
+
setTitle: (n) => g("title", { title: n }).then(() => {
|
|
197
279
|
}),
|
|
198
|
-
haptic: (
|
|
199
|
-
|
|
280
|
+
haptic: (n) => {
|
|
281
|
+
y("haptic") && e.request(O.haptic, { kind: n }).catch(() => {
|
|
200
282
|
});
|
|
201
283
|
},
|
|
202
|
-
copy: (
|
|
284
|
+
copy: (n) => g("clipboard", { text: n }).then(() => {
|
|
203
285
|
}),
|
|
204
|
-
openUrl: (
|
|
286
|
+
openUrl: (n) => g("openUrl", { url: n }).then(() => {
|
|
205
287
|
}),
|
|
206
|
-
share: (
|
|
288
|
+
share: (n) => g("share", n, null).then(
|
|
207
289
|
(i) => i?.action === "dismissedAction" ? "dismissed" : "shared"
|
|
208
290
|
),
|
|
209
|
-
getUserKey: () =>
|
|
291
|
+
getUserKey: () => g("userKey").then((n) => n.key),
|
|
210
292
|
permissions: {
|
|
211
|
-
query: (
|
|
293
|
+
query: (n) => g("permissions", { kind: n }, void 0, "GetSubWebViewPermission").then(
|
|
212
294
|
(i) => i.state
|
|
213
295
|
),
|
|
214
296
|
// Waits for the user, however long they take.
|
|
215
|
-
request: (
|
|
297
|
+
request: (n) => g("permissions", { kind: n }, null).then((i) => i.state)
|
|
216
298
|
},
|
|
217
|
-
openSettings: () =>
|
|
299
|
+
openSettings: () => g("permissions", {}, void 0, "OpenSettings").then(() => {
|
|
218
300
|
}),
|
|
219
|
-
reportError: (
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
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", {})
|
|
226
309
|
}),
|
|
227
|
-
onBack: (
|
|
228
|
-
|
|
310
|
+
onBack: (n) => {
|
|
311
|
+
r = n, m();
|
|
229
312
|
},
|
|
230
|
-
onCloseRequest: (
|
|
231
|
-
|
|
313
|
+
onCloseRequest: (n) => {
|
|
314
|
+
v = n, m();
|
|
232
315
|
},
|
|
233
|
-
onContextChange: (
|
|
234
|
-
link: (
|
|
235
|
-
const i =
|
|
236
|
-
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);
|
|
237
320
|
},
|
|
238
321
|
disconnect: () => {
|
|
239
|
-
|
|
322
|
+
p.forEach((n) => n()), e.close(), T = null;
|
|
240
323
|
}
|
|
241
324
|
};
|
|
242
|
-
if (
|
|
243
|
-
const
|
|
244
|
-
|
|
245
|
-
}, i = (
|
|
246
|
-
|
|
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);
|
|
247
330
|
};
|
|
248
|
-
window.addEventListener("error",
|
|
249
|
-
window.removeEventListener("error",
|
|
331
|
+
window.addEventListener("error", n), window.addEventListener("unhandledrejection", i), p.push(() => {
|
|
332
|
+
window.removeEventListener("error", n), window.removeEventListener("unhandledrejection", i);
|
|
250
333
|
});
|
|
251
334
|
}
|
|
252
|
-
return
|
|
253
|
-
},
|
|
254
|
-
const
|
|
335
|
+
return w;
|
|
336
|
+
}, ce = () => {
|
|
337
|
+
const e = async (t) => {
|
|
255
338
|
try {
|
|
256
|
-
const
|
|
257
|
-
return
|
|
339
|
+
const a = await navigator.permissions.query({ name: t });
|
|
340
|
+
return a.state === "granted" ? "granted" : a.state === "denied" ? "blocked" : "prompt";
|
|
258
341
|
} catch {
|
|
259
342
|
return "prompt";
|
|
260
343
|
}
|
|
261
344
|
};
|
|
262
345
|
return {
|
|
263
|
-
query:
|
|
346
|
+
query: e,
|
|
264
347
|
request: async (t) => {
|
|
265
348
|
if (typeof navigator > "u" || !navigator.mediaDevices?.getUserMedia)
|
|
266
349
|
throw new u("NOT_SUPPORTED", `This browser cannot capture the ${t}.`);
|
|
267
350
|
try {
|
|
268
351
|
return (await navigator.mediaDevices.getUserMedia(
|
|
269
352
|
t === "camera" ? { video: !0 } : { audio: !0 }
|
|
270
|
-
)).getTracks().forEach((
|
|
271
|
-
} catch (
|
|
272
|
-
const
|
|
273
|
-
if (
|
|
353
|
+
)).getTracks().forEach((r) => r.stop()), "granted";
|
|
354
|
+
} catch (a) {
|
|
355
|
+
const r = a?.name;
|
|
356
|
+
if (r === "NotFoundError" || r === "OverconstrainedError")
|
|
274
357
|
throw new u("UNAVAILABLE", `This device has no ${t}.`);
|
|
275
|
-
if (
|
|
276
|
-
throw new u("INTERNAL_ERROR", `The ${t} could not be used: ${
|
|
277
|
-
return await
|
|
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";
|
|
278
361
|
}
|
|
279
362
|
}
|
|
280
363
|
};
|
|
281
|
-
},
|
|
282
|
-
const
|
|
364
|
+
}, de = () => {
|
|
365
|
+
const e = (t) => typeof navigator < "u" && navigator.clipboard ? navigator.clipboard.writeText(t) : Promise.reject(I("The clipboard"));
|
|
283
366
|
return {
|
|
284
367
|
inApp: !1,
|
|
285
368
|
context: null,
|
|
286
369
|
supports: () => !1,
|
|
287
|
-
finish: () =>
|
|
370
|
+
finish: () => N("Finishing the view"),
|
|
288
371
|
setTitle: async (t) => {
|
|
289
372
|
typeof document < "u" && (document.title = t);
|
|
290
373
|
},
|
|
291
374
|
haptic: () => {
|
|
292
375
|
typeof navigator < "u" && navigator.vibrate?.(10);
|
|
293
376
|
},
|
|
294
|
-
copy:
|
|
377
|
+
copy: e,
|
|
295
378
|
openUrl: async (t) => {
|
|
296
379
|
typeof window < "u" && window.open(t, "_blank", "noopener,noreferrer");
|
|
297
380
|
},
|
|
298
381
|
share: async (t) => {
|
|
299
|
-
const
|
|
300
|
-
if (!
|
|
382
|
+
const a = [t.message, t.url].filter(Boolean).join(" ");
|
|
383
|
+
if (!a) throw new u("INVALID", "Share a message or a url.");
|
|
301
384
|
if (typeof navigator < "u" && navigator.share)
|
|
302
385
|
try {
|
|
303
386
|
return await navigator.share(t), "shared";
|
|
304
|
-
} catch (
|
|
305
|
-
if (
|
|
387
|
+
} catch (r) {
|
|
388
|
+
if (r?.name === "AbortError") return "dismissed";
|
|
306
389
|
}
|
|
307
|
-
return await
|
|
390
|
+
return await e(a), "copied";
|
|
308
391
|
},
|
|
309
|
-
getUserKey: () =>
|
|
310
|
-
permissions:
|
|
311
|
-
|
|
392
|
+
getUserKey: () => N("A user key"),
|
|
393
|
+
permissions: ce(),
|
|
394
|
+
data: Z(),
|
|
395
|
+
openSettings: () => N("Opening the settings"),
|
|
312
396
|
reportError: async (t) => (console.error(t), !1),
|
|
313
|
-
storage:
|
|
397
|
+
storage: K(),
|
|
314
398
|
onBack: () => {
|
|
315
399
|
},
|
|
316
400
|
onCloseRequest: () => {
|
|
317
401
|
},
|
|
318
402
|
onContextChange: () => () => {
|
|
319
403
|
},
|
|
320
|
-
link: (t) =>
|
|
404
|
+
link: (t) => G(j(t)),
|
|
321
405
|
disconnect: () => {
|
|
322
|
-
|
|
406
|
+
T = null;
|
|
323
407
|
}
|
|
324
408
|
};
|
|
325
409
|
};
|
|
326
410
|
export {
|
|
327
411
|
u as ChaticAppsError,
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
412
|
+
z as LISTENER,
|
|
413
|
+
fe as SDK_BRIDGE_VERSION,
|
|
414
|
+
J as SDK_DATA_CONTRACTS,
|
|
415
|
+
ue as connect,
|
|
416
|
+
ee as isInApp
|
|
331
417
|
};
|