@cloudlet/toast 0.0.0-stage → 1.0.0-rc.3
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/CHANGELOG.md +236 -0
- package/LICENSE +21 -0
- package/README.md +64 -2
- package/THIRD_PARTY_NOTICES.md +149 -0
- package/dist/contracts/controller.d.ts +71 -0
- package/dist/contracts/controller.d.ts.map +1 -0
- package/dist/contracts/events.d.ts +72 -0
- package/dist/contracts/events.d.ts.map +1 -0
- package/dist/contracts/identity.d.ts +32 -0
- package/dist/contracts/identity.d.ts.map +1 -0
- package/dist/contracts/internal.d.ts +188 -0
- package/dist/contracts/internal.d.ts.map +1 -0
- package/dist/contracts/notifications.d.ts +101 -0
- package/dist/contracts/notifications.d.ts.map +1 -0
- package/dist/contracts/operations.d.ts +76 -0
- package/dist/contracts/operations.d.ts.map +1 -0
- package/dist/contracts/snapshots.d.ts +48 -0
- package/dist/contracts/snapshots.d.ts.map +1 -0
- package/dist/core/controller.d.ts +7 -0
- package/dist/core/controller.d.ts.map +1 -0
- package/dist/core/controller.js +954 -0
- package/dist/core/controller.js.map +1 -0
- package/dist/core/validation.d.ts +17 -0
- package/dist/core/validation.d.ts.map +1 -0
- package/dist/core/validation.js +298 -0
- package/dist/core/validation.js.map +1 -0
- package/dist/create-cloudlet.d.ts +5 -0
- package/dist/create-cloudlet.d.ts.map +1 -0
- package/dist/create-cloudlet.js +34 -0
- package/dist/create-cloudlet.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/react/announcer.d.ts +15 -0
- package/dist/react/announcer.d.ts.map +1 -0
- package/dist/react/announcer.js +134 -0
- package/dist/react/announcer.js.map +1 -0
- package/dist/react/bindings.d.ts +8 -0
- package/dist/react/bindings.d.ts.map +1 -0
- package/dist/react/bindings.js +84 -0
- package/dist/react/bindings.js.map +1 -0
- package/dist/react/card.d.ts +58 -0
- package/dist/react/card.d.ts.map +1 -0
- package/dist/react/card.js +300 -0
- package/dist/react/card.js.map +1 -0
- package/dist/react/generators.d.ts +46 -0
- package/dist/react/generators.d.ts.map +1 -0
- package/dist/react/generators.js +115 -0
- package/dist/react/generators.js.map +1 -0
- package/dist/react/gestures.d.ts +50 -0
- package/dist/react/gestures.d.ts.map +1 -0
- package/dist/react/gestures.js +239 -0
- package/dist/react/gestures.js.map +1 -0
- package/dist/react/host.d.ts +37 -0
- package/dist/react/host.d.ts.map +1 -0
- package/dist/react/host.js +816 -0
- package/dist/react/host.js.map +1 -0
- package/dist/react/motion.d.ts +206 -0
- package/dist/react/motion.d.ts.map +1 -0
- package/dist/react/motion.js +414 -0
- package/dist/react/motion.js.map +1 -0
- package/dist/react/plan.d.ts +45 -0
- package/dist/react/plan.d.ts.map +1 -0
- package/dist/react/plan.js +58 -0
- package/dist/react/plan.js.map +1 -0
- package/dist/react/shape.d.ts +7 -0
- package/dist/react/shape.d.ts.map +1 -0
- package/dist/react/shape.js +21 -0
- package/dist/react/shape.js.map +1 -0
- package/dist/react/viewport.d.ts +15 -0
- package/dist/react/viewport.d.ts.map +1 -0
- package/dist/react/viewport.js +16 -0
- package/dist/react/viewport.js.map +1 -0
- package/dist/react.d.ts +176 -0
- package/dist/react.d.ts.map +1 -0
- package/dist/react.js +2 -0
- package/dist/styles.css +1 -0
- package/package.json +17 -4
- package/src/contracts/controller.ts +61 -0
- package/src/contracts/events.ts +47 -0
- package/src/contracts/identity.ts +27 -0
- package/src/contracts/internal.ts +150 -0
- package/src/contracts/notifications.ts +104 -0
- package/src/contracts/operations.ts +71 -0
- package/src/contracts/snapshots.ts +59 -0
- package/src/core/controller.ts +1038 -0
- package/src/core/validation.ts +290 -0
- package/src/create-cloudlet.ts +43 -0
- package/src/index.ts +34 -0
- package/src/react/announcer.ts +189 -0
- package/src/react/bindings.tsx +100 -0
- package/src/react/card.tsx +222 -0
- package/src/react/generators.ts +274 -0
- package/src/react/gestures.ts +296 -0
- package/src/react/host.tsx +947 -0
- package/src/react/motion.ts +484 -0
- package/src/react/plan.ts +101 -0
- package/src/react/shape.ts +33 -0
- package/src/react/viewport.ts +10 -0
- package/src/react.ts +190 -0
|
@@ -0,0 +1,954 @@
|
|
|
1
|
+
import { copyContent as e, patchContent as t, validDelay as n, validateContent as r, validateOptions as i, validatePatch as a, validateSpec as o, validateTrackOptions as s } from "./validation.js";
|
|
2
|
+
//#region src/core/controller.ts
|
|
3
|
+
var c = 600, l = Object.freeze, u = /* @__PURE__ */ new WeakSet(), ee = /* @__PURE__ */ new WeakMap(), d = 0, f = l([]), te = l({
|
|
4
|
+
open: !1,
|
|
5
|
+
reason: null,
|
|
6
|
+
current: null
|
|
7
|
+
}), p = l({
|
|
8
|
+
controller: null,
|
|
9
|
+
revision: 0,
|
|
10
|
+
disposed: !1,
|
|
11
|
+
notifications: f,
|
|
12
|
+
stack: f,
|
|
13
|
+
island: te,
|
|
14
|
+
overflow: l({
|
|
15
|
+
count: 0,
|
|
16
|
+
pending: !1
|
|
17
|
+
})
|
|
18
|
+
}), m = l({
|
|
19
|
+
...p,
|
|
20
|
+
presentation: null,
|
|
21
|
+
focusRequest: null,
|
|
22
|
+
announcements: l({
|
|
23
|
+
notifications: f,
|
|
24
|
+
overflowCount: 0
|
|
25
|
+
})
|
|
26
|
+
}), h = l({ status: "idle" }), g = l({ status: "applied" }), _ = l({ status: "unchanged" }), v = (e) => ({
|
|
27
|
+
status: "rejected",
|
|
28
|
+
reason: e
|
|
29
|
+
});
|
|
30
|
+
function y(e) {
|
|
31
|
+
let t = ee.get(e);
|
|
32
|
+
if (!t) throw TypeError("Controller was not created by this Cloudlet package instance");
|
|
33
|
+
return t;
|
|
34
|
+
}
|
|
35
|
+
function b(f, y) {
|
|
36
|
+
let b = i(f);
|
|
37
|
+
if (!y?.clock || typeof y.clock.now != "function" || typeof y.clock.schedule != "function") throw TypeError("Cloudlet requires a monotonic clock");
|
|
38
|
+
let x = y.clock;
|
|
39
|
+
if (typeof y.createCancellation != "function") throw TypeError("Cloudlet requires a cancellation source factory");
|
|
40
|
+
let S = `cloudlet-${++d}`, C = /* @__PURE__ */ new Map(), w = /* @__PURE__ */ new Set(), T = /* @__PURE__ */ new Set(), E = /* @__PURE__ */ new Map(), D = /* @__PURE__ */ new Set(), O = [], k = null, A = null, j = null, M = null, ne = 0, re = 0, ie = 0, ae = 0, N = null, P = null, F, I, L = null, R = null, oe = 0, z = 0, B = 0, V = !1, se = !1, ce = null, le = 0, ue, de, H = () => `${S}:${++ne}`, fe = () => [...C.values()].reverse(), pe = () => fe()[0] ?? null, me = (e) => {
|
|
41
|
+
let t = e.operation?.getSnapshot();
|
|
42
|
+
return !!t?.canRetry && t.status !== "fulfilled";
|
|
43
|
+
}, he = (e) => !!e.content.action || me(e) || e.content.attention === "open", ge = (e) => {
|
|
44
|
+
let t = e.content.attention ?? "auto";
|
|
45
|
+
return t === "open" || t === "auto" && (he(e) || !!e.content.description);
|
|
46
|
+
}, _e = () => D.has("hover") || D.has("focus") || [...C.values()].some((e) => e.pauses.has("gesture")), ve = (e) => {
|
|
47
|
+
let t = e === P;
|
|
48
|
+
return [
|
|
49
|
+
...t ? [] : ["inactive"],
|
|
50
|
+
...j === null ? ["no-host"] : [],
|
|
51
|
+
...t && !e.readable ? ["presentation-pending"] : [],
|
|
52
|
+
...t && N && (N.reason === "user" || he(e)) ? ["island"] : [],
|
|
53
|
+
...e.action.status === "pending" ? ["action-pending"] : [],
|
|
54
|
+
...D,
|
|
55
|
+
...e.pauses
|
|
56
|
+
];
|
|
57
|
+
}, U = (e) => {
|
|
58
|
+
if (V) return "disposed";
|
|
59
|
+
if (typeof e != "object" || !e || !u.has(e)) return "invalid-handle";
|
|
60
|
+
if (e.controller !== S) return "foreign-controller";
|
|
61
|
+
if (C.get(e.id)?.handle !== e) return "stale-handle";
|
|
62
|
+
}, ye = (e) => V ? "disposed" : j === null || e !== j ? "stale-lease" : void 0, be = (e) => U(e) ?? (C.get(e.id) === P ? void 0 : "not-current");
|
|
63
|
+
function W(e) {
|
|
64
|
+
return (t, ...n) => {
|
|
65
|
+
let r = U(t);
|
|
66
|
+
return r ? v(r) : e(C.get(t.id), ...n);
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
function xe(e) {
|
|
70
|
+
return W((t, ...n) => t === P ? e(t, ...n) : v("not-current"));
|
|
71
|
+
}
|
|
72
|
+
function Se(e) {
|
|
73
|
+
return W((t, n, ...r) => {
|
|
74
|
+
let i = t.operation;
|
|
75
|
+
return i ? i.getSnapshot().token === n ? e(i, ...r) : v("stale-operation-token") : v("no-operation");
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
function G(e) {
|
|
79
|
+
q([{
|
|
80
|
+
type: "diagnostic",
|
|
81
|
+
diagnostic: l({ ...e })
|
|
82
|
+
}]);
|
|
83
|
+
}
|
|
84
|
+
function K(e, t, n, r) {
|
|
85
|
+
G({
|
|
86
|
+
code: e,
|
|
87
|
+
source: t,
|
|
88
|
+
message: `${t} failed`,
|
|
89
|
+
error: n,
|
|
90
|
+
...r ? { handle: r } : {}
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
function Ce(e, t) {
|
|
94
|
+
for (let n of [...e]) if (e.has(n)) try {
|
|
95
|
+
n();
|
|
96
|
+
} catch (e) {
|
|
97
|
+
K("listener-error", t, e);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
function q(e, t = !1, n = x.now(), r = !1, i = !1) {
|
|
101
|
+
if (O.push(() => {
|
|
102
|
+
t && Ce(w, "subscribe");
|
|
103
|
+
for (let t of e) {
|
|
104
|
+
if ("callback" in t) {
|
|
105
|
+
try {
|
|
106
|
+
t.callback();
|
|
107
|
+
} catch (e) {
|
|
108
|
+
K("callback-error", t.source, e, t.handle);
|
|
109
|
+
}
|
|
110
|
+
continue;
|
|
111
|
+
}
|
|
112
|
+
let e = l({
|
|
113
|
+
...t,
|
|
114
|
+
controller: S,
|
|
115
|
+
sequence: ++ae,
|
|
116
|
+
at: i ? x.now() : n
|
|
117
|
+
});
|
|
118
|
+
for (let t of [...T]) if (T.has(t)) try {
|
|
119
|
+
t(e);
|
|
120
|
+
} catch (t) {
|
|
121
|
+
e.type !== "diagnostic" && K("listener-error", "onEvent", t);
|
|
122
|
+
}
|
|
123
|
+
if (e.type === "diagnostic") try {
|
|
124
|
+
b.onDiagnostic?.(e.diagnostic);
|
|
125
|
+
} catch {}
|
|
126
|
+
}
|
|
127
|
+
if (r && q([{ type: "disposed" }], !1, n, !1, !0), i) {
|
|
128
|
+
w.clear(), T.clear();
|
|
129
|
+
for (let e of E.keys()) e.clear();
|
|
130
|
+
E.clear();
|
|
131
|
+
}
|
|
132
|
+
}), !se) {
|
|
133
|
+
se = !0;
|
|
134
|
+
try {
|
|
135
|
+
let e;
|
|
136
|
+
for (; e = O.shift();) e();
|
|
137
|
+
} finally {
|
|
138
|
+
se = !1;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
function J() {
|
|
143
|
+
let e = x.now();
|
|
144
|
+
for (let t of C.values()) t.activeSince !== null && t.remaining !== null && (t.remaining = Math.max(0, t.remaining - Math.max(0, e - t.activeSince)), t.activeSince = e);
|
|
145
|
+
return e;
|
|
146
|
+
}
|
|
147
|
+
function we() {
|
|
148
|
+
++le, ce?.(), ce = null;
|
|
149
|
+
}
|
|
150
|
+
function Te(e) {
|
|
151
|
+
we();
|
|
152
|
+
let t = Infinity;
|
|
153
|
+
for (let n of C.values()) {
|
|
154
|
+
let r = n.remaining !== null && ve(n).length === 0 && !V;
|
|
155
|
+
n.activeSince = r ? e : null, r && (t = Math.min(t, e + n.remaining));
|
|
156
|
+
}
|
|
157
|
+
if (!Number.isFinite(t)) return;
|
|
158
|
+
let n = le;
|
|
159
|
+
ce = x.schedule(t, () => {
|
|
160
|
+
if (V || n !== le) return;
|
|
161
|
+
let e = J(), t = [...C.values()].filter((e) => e.activeSince !== null && e.remaining === 0), r = [];
|
|
162
|
+
for (let e of t) Pe(e, "timeout", r);
|
|
163
|
+
t.length ? Y(r, e) : Te(e);
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
function Ee() {
|
|
167
|
+
let e = [...C.values()], t = l(e.map((e) => l({
|
|
168
|
+
handle: e.handle,
|
|
169
|
+
kind: e.kind,
|
|
170
|
+
content: e.content,
|
|
171
|
+
priority: e.priority,
|
|
172
|
+
occurrences: e.occurrences,
|
|
173
|
+
location: e === P ? "current" : "stack",
|
|
174
|
+
remainingMs: e.remaining,
|
|
175
|
+
pauseReasons: l(ve(e)),
|
|
176
|
+
operation: e.operation?.getSnapshot() ?? null,
|
|
177
|
+
action: e.action
|
|
178
|
+
})));
|
|
179
|
+
ue = l({
|
|
180
|
+
controller: S,
|
|
181
|
+
revision: ie,
|
|
182
|
+
disposed: V,
|
|
183
|
+
notifications: t,
|
|
184
|
+
stack: l(fe().map((e) => e.handle)),
|
|
185
|
+
island: N ? l({
|
|
186
|
+
open: !0,
|
|
187
|
+
reason: N.reason,
|
|
188
|
+
current: N.current.handle
|
|
189
|
+
}) : te,
|
|
190
|
+
overflow: l({
|
|
191
|
+
count: z,
|
|
192
|
+
pending: z > 0
|
|
193
|
+
})
|
|
194
|
+
}), de = l({
|
|
195
|
+
...ue,
|
|
196
|
+
presentation: P ? l({
|
|
197
|
+
handle: P.handle,
|
|
198
|
+
token: P.presentation,
|
|
199
|
+
readable: P.readable
|
|
200
|
+
}) : null,
|
|
201
|
+
focusRequest: A,
|
|
202
|
+
announcements: l({
|
|
203
|
+
overflowCount: B,
|
|
204
|
+
notifications: l(e.map((e) => l({
|
|
205
|
+
handle: e.handle,
|
|
206
|
+
queued: e.queuedAnnounced,
|
|
207
|
+
firstPresentation: e.firstAnnounced,
|
|
208
|
+
occurrences: e.occurrencesAnnounced,
|
|
209
|
+
action: e.actionAnnounced ?? null,
|
|
210
|
+
operation: e.operation ? l({
|
|
211
|
+
token: e.operation.getSnapshot().token,
|
|
212
|
+
phases: l([...e.operationAnnounced])
|
|
213
|
+
}) : null
|
|
214
|
+
})))
|
|
215
|
+
})
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
function Y(e = [], t = x.now(), n = !1) {
|
|
219
|
+
ke(), Te(t), Me(t), ++ie, Ee(), q(e, !0, t, n);
|
|
220
|
+
}
|
|
221
|
+
function X(e, t = !1) {
|
|
222
|
+
let n = J(), r = [];
|
|
223
|
+
return e(r), Y(r, n, t), g;
|
|
224
|
+
}
|
|
225
|
+
function De(e) {
|
|
226
|
+
e.readable = !1, e.presentation = j === null ? null : H();
|
|
227
|
+
}
|
|
228
|
+
function Oe(e) {
|
|
229
|
+
e.presentation = null, e.readable = !1, e.pauses.clear(), k === e.handle && (k = null), A?.target.kind === "notification" && A.target.handle === e.handle && (A = null);
|
|
230
|
+
}
|
|
231
|
+
function ke() {
|
|
232
|
+
let e = N ? N.current : pe();
|
|
233
|
+
e !== P && (P && Oe(P), P = e, e && De(e));
|
|
234
|
+
}
|
|
235
|
+
function Ae() {
|
|
236
|
+
++oe, R?.(), R = null;
|
|
237
|
+
}
|
|
238
|
+
function je(e, t) {
|
|
239
|
+
ge(e) && (L = {
|
|
240
|
+
record: e,
|
|
241
|
+
due: t + (F ?? b.attentionDelay ?? c),
|
|
242
|
+
waiting: !1
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
function Me(e) {
|
|
246
|
+
Ae();
|
|
247
|
+
let t = L;
|
|
248
|
+
if (!t || V) return;
|
|
249
|
+
if (j === null) {
|
|
250
|
+
t.waiting = !0;
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
if (t.waiting) {
|
|
254
|
+
if (_e()) return;
|
|
255
|
+
t.waiting = !1, t.due = e + (F ?? b.attentionDelay ?? c);
|
|
256
|
+
}
|
|
257
|
+
let n = oe;
|
|
258
|
+
R = x.schedule(t.due, () => {
|
|
259
|
+
if (V || n !== oe || L !== t) return;
|
|
260
|
+
let e = x.now();
|
|
261
|
+
if (e < t.due) {
|
|
262
|
+
Me(e);
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
if (R = null, _e()) {
|
|
266
|
+
t.waiting = !0;
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
269
|
+
L = null;
|
|
270
|
+
let r = t.record;
|
|
271
|
+
ge(r) && N?.current !== r && X(() => {
|
|
272
|
+
N ? N.current = r : N = {
|
|
273
|
+
reason: "attention",
|
|
274
|
+
current: r
|
|
275
|
+
};
|
|
276
|
+
});
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
let Z = (e) => (e ?? b.autoDismiss) !== !1;
|
|
280
|
+
function Ne(e) {
|
|
281
|
+
let t = Z(e) !== Z(I);
|
|
282
|
+
if (I = e, t) for (let e of C.values()) e.remaining = Q(e);
|
|
283
|
+
}
|
|
284
|
+
function Q(e) {
|
|
285
|
+
return Z(I) ? e.content.duration === void 0 ? (e.kind === "info" || e.kind === "success") && !e.content.action ? 6e3 : null : e.content.duration : null;
|
|
286
|
+
}
|
|
287
|
+
function Pe(e, t, n) {
|
|
288
|
+
if (N?.current === e) {
|
|
289
|
+
let t = fe(), n = t.indexOf(e), r = t[n + 1] ?? t[n - 1];
|
|
290
|
+
r ? N.current = r : N = null;
|
|
291
|
+
}
|
|
292
|
+
if (L?.record === e && (L = null), C.delete(e.handle.id), e.operation && n.push(e.operation.detach()), n.push({
|
|
293
|
+
type: "closed",
|
|
294
|
+
handle: e.handle,
|
|
295
|
+
reason: t
|
|
296
|
+
}), e.onClose) {
|
|
297
|
+
let r = e.onClose, i = l({
|
|
298
|
+
handle: e.handle,
|
|
299
|
+
reason: t
|
|
300
|
+
});
|
|
301
|
+
n.push({
|
|
302
|
+
callback: () => r(i),
|
|
303
|
+
source: "onClose",
|
|
304
|
+
handle: e.handle
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
let Fe = W((e, t) => X((n) => Pe(e, t, n)));
|
|
309
|
+
function Ie() {
|
|
310
|
+
return V ? v("disposed") : z ? X((e) => {
|
|
311
|
+
e.push({
|
|
312
|
+
type: "overflow-acknowledged",
|
|
313
|
+
count: z
|
|
314
|
+
}), z = B = 0, A?.target.kind === "overflow" && (A = null);
|
|
315
|
+
}) : _;
|
|
316
|
+
}
|
|
317
|
+
function Le(e, t) {
|
|
318
|
+
if (typeof t != "function") throw TypeError("Listener must be a function");
|
|
319
|
+
return V ? () => {} : (e.add(t), () => {
|
|
320
|
+
e.delete(t);
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
function Re(e) {
|
|
324
|
+
if (V) return v("disposed");
|
|
325
|
+
let t = o(e);
|
|
326
|
+
return t.length ? (G({
|
|
327
|
+
code: "invalid-input",
|
|
328
|
+
source: "show",
|
|
329
|
+
message: "Invalid notification specification"
|
|
330
|
+
}), {
|
|
331
|
+
...v("invalid-input"),
|
|
332
|
+
issues: t
|
|
333
|
+
}) : ze(e);
|
|
334
|
+
}
|
|
335
|
+
function ze(t, n) {
|
|
336
|
+
if (t.id !== void 0 && C.has(t.id)) return v("id-conflict");
|
|
337
|
+
let r = t.dedupeKey === void 0 ? void 0 : [...C.values()].find((e) => e.dedupeKey === t.dedupeKey);
|
|
338
|
+
if (r) {
|
|
339
|
+
let e = r.occurrences;
|
|
340
|
+
return X((t) => {
|
|
341
|
+
e = r.occurrences = Math.min(2 ** 53 - 1, e + 1), t.push({
|
|
342
|
+
type: "deduplicated",
|
|
343
|
+
handle: r.handle,
|
|
344
|
+
occurrences: e
|
|
345
|
+
});
|
|
346
|
+
}), {
|
|
347
|
+
status: "deduplicated",
|
|
348
|
+
handle: r.handle,
|
|
349
|
+
occurrences: e
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
if (C.size >= 100) return X((e) => {
|
|
353
|
+
z = Math.min(2 ** 53 - 1, z + 1);
|
|
354
|
+
let t = l({
|
|
355
|
+
count: z,
|
|
356
|
+
pending: !0
|
|
357
|
+
});
|
|
358
|
+
e.push({
|
|
359
|
+
type: "overflow",
|
|
360
|
+
count: z
|
|
361
|
+
}), b.onOverflow && e.push({
|
|
362
|
+
callback: () => b.onOverflow(t),
|
|
363
|
+
source: "onOverflow"
|
|
364
|
+
});
|
|
365
|
+
}), v("capacity");
|
|
366
|
+
let i = J(), a = t.id;
|
|
367
|
+
if (a === void 0) do
|
|
368
|
+
a = `${S}:notification-${++re}`;
|
|
369
|
+
while (C.has(a));
|
|
370
|
+
let o = l({
|
|
371
|
+
id: a,
|
|
372
|
+
controller: S,
|
|
373
|
+
generation: H()
|
|
374
|
+
});
|
|
375
|
+
u.add(o);
|
|
376
|
+
let s = {
|
|
377
|
+
handle: o,
|
|
378
|
+
dedupeKey: t.dedupeKey,
|
|
379
|
+
onClose: t.onClose,
|
|
380
|
+
content: e(t),
|
|
381
|
+
kind: t.kind ?? "info",
|
|
382
|
+
priority: t.priority ?? "normal",
|
|
383
|
+
occurrences: 1,
|
|
384
|
+
remaining: null,
|
|
385
|
+
activeSince: null,
|
|
386
|
+
presentation: null,
|
|
387
|
+
readable: !1,
|
|
388
|
+
everPresented: !1,
|
|
389
|
+
pauses: /* @__PURE__ */ new Set(),
|
|
390
|
+
queuedAnnounced: !1,
|
|
391
|
+
firstAnnounced: !1,
|
|
392
|
+
occurrencesAnnounced: 0,
|
|
393
|
+
operation: null,
|
|
394
|
+
operationAnnounced: /* @__PURE__ */ new Set(),
|
|
395
|
+
action: h
|
|
396
|
+
};
|
|
397
|
+
s.remaining = Q(s), C.set(a, s), n?.(s), je(s, i);
|
|
398
|
+
let c = [{
|
|
399
|
+
type: "admitted",
|
|
400
|
+
handle: o
|
|
401
|
+
}];
|
|
402
|
+
if (s.operation) {
|
|
403
|
+
let e = s.operation.getSnapshot();
|
|
404
|
+
c.push({
|
|
405
|
+
type: "operation-started",
|
|
406
|
+
handle: o,
|
|
407
|
+
token: e.token,
|
|
408
|
+
attempt: e.attempt
|
|
409
|
+
});
|
|
410
|
+
}
|
|
411
|
+
return Y(c, i), {
|
|
412
|
+
status: "created",
|
|
413
|
+
handle: o
|
|
414
|
+
};
|
|
415
|
+
}
|
|
416
|
+
function Be(e) {
|
|
417
|
+
V || q(e);
|
|
418
|
+
}
|
|
419
|
+
function Ve(e, t, n) {
|
|
420
|
+
e.content = t, e.kind = n, e.remaining = n === "loading" ? null : Q(e), e.action = h, e === P && De(e), je(e, x.now()), A?.target.kind === "notification" && A.target.handle === e.handle && A.target.control === "action" && !t.action && (A = null);
|
|
421
|
+
}
|
|
422
|
+
function He(n, i) {
|
|
423
|
+
let a = typeof n == "function" ? n : null, o;
|
|
424
|
+
if (!a && (typeof n != "object" || !n || typeof (o = n.then) != "function")) throw TypeError("Operation source must be a factory or thenable");
|
|
425
|
+
let c = s(i, a !== null), u = (e) => i && typeof i == "object" ? Object.getOwnPropertyDescriptor(i, e)?.value : void 0, ee = u("cancel"), d = !a && typeof ee == "function" ? ee : null, f = u("isCancellation"), te = typeof f == "function" ? f : null, p = c.length ? null : l({
|
|
426
|
+
...i,
|
|
427
|
+
pending: e(i.pending),
|
|
428
|
+
success: typeof i.success == "function" ? i.success : e(i.success),
|
|
429
|
+
error: typeof i.error == "function" ? i.error : e(i.error),
|
|
430
|
+
...i.cancelled === void 0 ? {} : { cancelled: typeof i.cancelled == "function" ? i.cancelled : e(i.cancelled) }
|
|
431
|
+
}), m = /* @__PURE__ */ new Set(), h = null, g = !1, _, x = 0;
|
|
432
|
+
function S() {
|
|
433
|
+
let e = y.createCancellation(), t = l({
|
|
434
|
+
signal: e.signal,
|
|
435
|
+
token: H(),
|
|
436
|
+
attempt: ++x
|
|
437
|
+
}), n, r, i = new Promise((e, t) => {
|
|
438
|
+
n = e, r = t;
|
|
439
|
+
}), a = {
|
|
440
|
+
public: l({
|
|
441
|
+
token: t.token,
|
|
442
|
+
attempt: t.attempt,
|
|
443
|
+
result: i
|
|
444
|
+
}),
|
|
445
|
+
context: t,
|
|
446
|
+
abort: e.abort,
|
|
447
|
+
resolve: n,
|
|
448
|
+
reject: r,
|
|
449
|
+
status: "pending",
|
|
450
|
+
cancelRequested: !1
|
|
451
|
+
};
|
|
452
|
+
return i.then((e) => M(a, "fulfilled", e), (e) => M(a, "rejected", e)).catch((e) => {
|
|
453
|
+
V || K("callback-error", "operation-settlement", e);
|
|
454
|
+
}), a;
|
|
455
|
+
}
|
|
456
|
+
let w = S(), T = w;
|
|
457
|
+
function D() {
|
|
458
|
+
let e = {
|
|
459
|
+
token: T.context.token,
|
|
460
|
+
attempt: T.context.attempt,
|
|
461
|
+
status: T.status,
|
|
462
|
+
cancelRequested: T.cancelRequested,
|
|
463
|
+
canCancel: !V && T.status === "pending" && !T.cancelRequested && (!!a || !!d),
|
|
464
|
+
canRetry: !V && !!a && T.status !== "pending",
|
|
465
|
+
notification: g && !V ? h : null
|
|
466
|
+
};
|
|
467
|
+
return (!_ || Object.keys(e).some((t) => e[t] !== _[t])) && (_ = l(e)), _;
|
|
468
|
+
}
|
|
469
|
+
let O = {
|
|
470
|
+
source: "operation.subscribe",
|
|
471
|
+
callback: () => Ce(m, "operation.subscribe")
|
|
472
|
+
};
|
|
473
|
+
function k(e) {
|
|
474
|
+
if (V || T !== e || !g || !h) return;
|
|
475
|
+
let t = C.get(h.id);
|
|
476
|
+
return t?.handle === h && t.operation === N ? t : void 0;
|
|
477
|
+
}
|
|
478
|
+
function A(e) {
|
|
479
|
+
try {
|
|
480
|
+
e.resolve(a ? a(e.context) : { then: o.bind(n) });
|
|
481
|
+
} catch (t) {
|
|
482
|
+
e.reject(t);
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
function j(e, t) {
|
|
486
|
+
if (t) {
|
|
487
|
+
let n = J();
|
|
488
|
+
t(), Y(e, n);
|
|
489
|
+
} else Be(e);
|
|
490
|
+
}
|
|
491
|
+
function M(t, n, i) {
|
|
492
|
+
if (t.status = n, n === "rejected") try {
|
|
493
|
+
(te ? te(i, t.context) === !0 : t.cancelRequested && typeof i == "object" && i && "name" in i && i.name === "AbortError") && (t.status = "cancelled");
|
|
494
|
+
} catch (e) {
|
|
495
|
+
V || K("cancellation-error", "isCancellation", e);
|
|
496
|
+
}
|
|
497
|
+
let a;
|
|
498
|
+
if (k(t) && p) {
|
|
499
|
+
let n = t.status, o = n === "fulfilled" ? b.messages?.operationSuccess ?? "Completed" : n === "cancelled" ? b.messages?.operationCancelled ?? "Cancelled" : b.messages?.operationError ?? "Something went wrong";
|
|
500
|
+
try {
|
|
501
|
+
let t = n === "fulfilled" ? p.success : n === "cancelled" ? p.cancelled : p.error, s = typeof t == "function" ? t(i) : t ?? { title: o };
|
|
502
|
+
if (r(s).length) throw TypeError("Invalid terminal notification content");
|
|
503
|
+
a = e(s);
|
|
504
|
+
} catch (e) {
|
|
505
|
+
a = l({
|
|
506
|
+
title: o,
|
|
507
|
+
announcementPriority: "polite"
|
|
508
|
+
}), V || K("mapper-error", `track.${n}`, e, h ?? void 0);
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
let o = k(t), s = !!o && !!a;
|
|
512
|
+
j([...T === t ? [O] : [], {
|
|
513
|
+
type: "operation-settled",
|
|
514
|
+
handle: h,
|
|
515
|
+
token: t.context.token,
|
|
516
|
+
status: t.status,
|
|
517
|
+
uiApplied: s
|
|
518
|
+
}], o && a ? () => Ve(o, a, t.status === "fulfilled" ? "success" : t.status === "cancelled" ? "warning" : "error") : void 0);
|
|
519
|
+
}
|
|
520
|
+
function ne(e, n) {
|
|
521
|
+
e.cancelRequested = !0;
|
|
522
|
+
let r = k(e);
|
|
523
|
+
j([O, {
|
|
524
|
+
type: "cancellation-requested",
|
|
525
|
+
handle: h,
|
|
526
|
+
token: e.context.token
|
|
527
|
+
}], r ? () => {
|
|
528
|
+
r.content = t(r.content, { title: b.messages?.cancellationRequested ?? "Cancellation requested" });
|
|
529
|
+
} : void 0);
|
|
530
|
+
try {
|
|
531
|
+
e.abort(n), d?.(n);
|
|
532
|
+
} catch (e) {
|
|
533
|
+
V || K("cancellation-error", "cancel", e, h ?? void 0);
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
function re() {
|
|
537
|
+
let e = /* @__PURE__ */ Error("Cancellation requested");
|
|
538
|
+
return e.name = "AbortError", e;
|
|
539
|
+
}
|
|
540
|
+
function ie(e = re()) {
|
|
541
|
+
return V ? v("disposed") : T.status === "pending" ? !a && !d ? v("not-cancellable") : T.cancelRequested ? {
|
|
542
|
+
status: "unchanged",
|
|
543
|
+
reason: "already-requested"
|
|
544
|
+
} : (ne(T, e), { status: "requested" }) : {
|
|
545
|
+
status: "unchanged",
|
|
546
|
+
reason: "settled"
|
|
547
|
+
};
|
|
548
|
+
}
|
|
549
|
+
function ae(e) {
|
|
550
|
+
if (V) return v("disposed");
|
|
551
|
+
if (!a) return v("not-retryable");
|
|
552
|
+
if (T.status === "pending" && !e) return v("already-pending");
|
|
553
|
+
let t = T, n = S();
|
|
554
|
+
T = n;
|
|
555
|
+
let r = k(n);
|
|
556
|
+
return j([O, {
|
|
557
|
+
type: "operation-started",
|
|
558
|
+
handle: h,
|
|
559
|
+
token: n.context.token,
|
|
560
|
+
attempt: n.context.attempt
|
|
561
|
+
}], r && p ? () => {
|
|
562
|
+
r.operationAnnounced.clear(), Ve(r, p.pending, "loading");
|
|
563
|
+
} : void 0), t.status === "pending" && !t.cancelRequested && ne(t, re()), A(n), {
|
|
564
|
+
status: "started",
|
|
565
|
+
attempt: n.public
|
|
566
|
+
};
|
|
567
|
+
}
|
|
568
|
+
let N = {
|
|
569
|
+
getSnapshot: D,
|
|
570
|
+
retry: () => ae(!1),
|
|
571
|
+
cancel: ie,
|
|
572
|
+
detach: () => (g = !1, O)
|
|
573
|
+
}, P;
|
|
574
|
+
if (V) P = v("disposed");
|
|
575
|
+
else if (!p) P = {
|
|
576
|
+
...v("invalid-input"),
|
|
577
|
+
issues: c
|
|
578
|
+
}, G({
|
|
579
|
+
code: "invalid-input",
|
|
580
|
+
source: "track",
|
|
581
|
+
message: "Invalid operation options"
|
|
582
|
+
});
|
|
583
|
+
else {
|
|
584
|
+
let e = ze({
|
|
585
|
+
...p.pending,
|
|
586
|
+
...p,
|
|
587
|
+
kind: "loading"
|
|
588
|
+
}, (e) => {
|
|
589
|
+
h = e.handle, g = !0, e.operation = N;
|
|
590
|
+
});
|
|
591
|
+
if (e.status === "deduplicated") throw Error("Tracked operation cannot be deduplicated");
|
|
592
|
+
P = e;
|
|
593
|
+
}
|
|
594
|
+
return P.status === "rejected" && Be([{
|
|
595
|
+
type: "operation-started",
|
|
596
|
+
handle: null,
|
|
597
|
+
token: w.context.token,
|
|
598
|
+
attempt: 1
|
|
599
|
+
}]), A(w), l({
|
|
600
|
+
...w.public,
|
|
601
|
+
admission: l(P),
|
|
602
|
+
getSnapshot: D,
|
|
603
|
+
subscribe(e) {
|
|
604
|
+
let t = Le(m, e);
|
|
605
|
+
return m.size && E.set(m, O), () => {
|
|
606
|
+
t(), m.size || E.delete(m);
|
|
607
|
+
};
|
|
608
|
+
},
|
|
609
|
+
cancel: ie,
|
|
610
|
+
retry: () => ae(!1),
|
|
611
|
+
restart: () => ae(!0)
|
|
612
|
+
});
|
|
613
|
+
}
|
|
614
|
+
let Ue = l({
|
|
615
|
+
show: (e) => Re(e),
|
|
616
|
+
track: He,
|
|
617
|
+
update: W((e, n) => {
|
|
618
|
+
let r = e.handle, i = a(n);
|
|
619
|
+
if (i.length) return G({
|
|
620
|
+
code: "invalid-input",
|
|
621
|
+
source: "update",
|
|
622
|
+
message: "Invalid notification patch",
|
|
623
|
+
handle: r
|
|
624
|
+
}), {
|
|
625
|
+
...v("invalid-input"),
|
|
626
|
+
issues: i
|
|
627
|
+
};
|
|
628
|
+
if (e.action.status === "pending" && Object.prototype.hasOwnProperty.call(n, "action")) return v("action-pending");
|
|
629
|
+
if (e.operation && (Object.prototype.hasOwnProperty.call(n, "kind") || e.operation.getSnapshot().status === "pending" && Object.prototype.hasOwnProperty.call(n, "duration"))) return v("operation-owned");
|
|
630
|
+
let o = t(e.content, n), s = n.kind ?? e.kind, c = n.priority ?? e.priority, l = Object.prototype.hasOwnProperty.call(n, "duration");
|
|
631
|
+
return o === e.content && s === e.kind && c === e.priority && !l && !(Object.prototype.hasOwnProperty.call(n, "action") && e.action.status === "failed") ? _ : X((t) => {
|
|
632
|
+
let i = Q(e);
|
|
633
|
+
e.content = o, Object.prototype.hasOwnProperty.call(n, "action") && (e.action = h), e.kind = s, e.priority = c;
|
|
634
|
+
let a = Q(e);
|
|
635
|
+
(l || i !== a) && (e.remaining = a), A?.target.kind === "notification" && A.target.handle === r && A.target.control === "action" && !o.action && (A = null), L?.record === e && !ge(e) && (L = null), t.push({
|
|
636
|
+
type: "updated",
|
|
637
|
+
handle: r
|
|
638
|
+
});
|
|
639
|
+
});
|
|
640
|
+
}),
|
|
641
|
+
getHandle: (e) => !V && typeof e == "string" ? C.get(e)?.handle : void 0,
|
|
642
|
+
dismiss: (e) => Fe(e, "programmatic"),
|
|
643
|
+
clear() {
|
|
644
|
+
if (V) return v("disposed");
|
|
645
|
+
let e = C.size;
|
|
646
|
+
return e && X((e) => {
|
|
647
|
+
for (let t of C.values()) Pe(t, "clear", e);
|
|
648
|
+
}), {
|
|
649
|
+
status: "cleared",
|
|
650
|
+
count: e
|
|
651
|
+
};
|
|
652
|
+
},
|
|
653
|
+
requestFocus(e = { kind: "anchor" }) {
|
|
654
|
+
if (V) return v("disposed");
|
|
655
|
+
if (e?.kind === "notification") {
|
|
656
|
+
let t = U(e.handle);
|
|
657
|
+
if (t) return v(t);
|
|
658
|
+
}
|
|
659
|
+
if (!j) return v("no-host");
|
|
660
|
+
if (!e || ![
|
|
661
|
+
"anchor",
|
|
662
|
+
"notification",
|
|
663
|
+
"overflow"
|
|
664
|
+
].includes(e.kind)) return v("unavailable");
|
|
665
|
+
if (e.kind === "notification") {
|
|
666
|
+
let t = C.get(e.handle.id);
|
|
667
|
+
if (t !== P) return v("not-visible");
|
|
668
|
+
if (e.control !== void 0 && !["action", "close"].includes(e.control) || e.control === "action" && !t.content.action) return v("unavailable");
|
|
669
|
+
if (e.control !== void 0 && !N) return v("not-visible");
|
|
670
|
+
}
|
|
671
|
+
return e.kind === "overflow" && !z ? v("unavailable") : (X(() => {
|
|
672
|
+
let t = e.kind === "notification" ? l({
|
|
673
|
+
kind: e.kind,
|
|
674
|
+
handle: e.handle,
|
|
675
|
+
...e.control ? { control: e.control } : {}
|
|
676
|
+
}) : l({ kind: e.kind });
|
|
677
|
+
A = l({
|
|
678
|
+
token: H(),
|
|
679
|
+
target: t
|
|
680
|
+
});
|
|
681
|
+
}), { status: "requested" });
|
|
682
|
+
},
|
|
683
|
+
acknowledgeOverflow: Ie,
|
|
684
|
+
getSnapshot: () => ue,
|
|
685
|
+
getServerSnapshot: () => p,
|
|
686
|
+
subscribe: (e) => Le(w, e),
|
|
687
|
+
onEvent: (e) => Le(T, e),
|
|
688
|
+
dispose() {
|
|
689
|
+
V || X((e) => {
|
|
690
|
+
V = !0;
|
|
691
|
+
for (let t of C.values()) Pe(t, "dispose", e);
|
|
692
|
+
for (let t of E.values()) e.includes(t) || e.push(t);
|
|
693
|
+
j = M = null, N = null, L = null, Ae(), A = null, D.clear(), z = B = 0;
|
|
694
|
+
}, !0);
|
|
695
|
+
}
|
|
696
|
+
});
|
|
697
|
+
function We(e) {
|
|
698
|
+
return e === void 0 || typeof e == "object" && !!e && Object.keys(e).every((e) => e === "attentionDelay") && (e.attentionDelay === void 0 || n(e.attentionDelay));
|
|
699
|
+
}
|
|
700
|
+
function $(e) {
|
|
701
|
+
return (t, ...n) => {
|
|
702
|
+
let r = ye(t);
|
|
703
|
+
return r ? v(r) : e(...n);
|
|
704
|
+
};
|
|
705
|
+
}
|
|
706
|
+
let Ge = l({
|
|
707
|
+
renderError: b.messages?.renderError ?? "Content unavailable",
|
|
708
|
+
reportInvalidContainer(e, t) {
|
|
709
|
+
V || G({
|
|
710
|
+
code: "invalid-container",
|
|
711
|
+
source: "Toaster.container",
|
|
712
|
+
message: e,
|
|
713
|
+
...t === void 0 ? {} : { error: t }
|
|
714
|
+
});
|
|
715
|
+
},
|
|
716
|
+
attach(e) {
|
|
717
|
+
if (V) return v("disposed");
|
|
718
|
+
if (j !== null) return G({
|
|
719
|
+
code: "second-host",
|
|
720
|
+
source: "attach",
|
|
721
|
+
message: "A renderer is already attached"
|
|
722
|
+
}), v("host-exists");
|
|
723
|
+
if (!We(e)) return v("invalid-input");
|
|
724
|
+
let t = H();
|
|
725
|
+
return X(() => {
|
|
726
|
+
j = M = t, F = e?.attentionDelay, P && De(P);
|
|
727
|
+
}), {
|
|
728
|
+
status: "attached",
|
|
729
|
+
lease: t
|
|
730
|
+
};
|
|
731
|
+
},
|
|
732
|
+
detach(e) {
|
|
733
|
+
if (V) return v("disposed");
|
|
734
|
+
if (j === null && M !== null && e === M) return _;
|
|
735
|
+
let t = ye(e);
|
|
736
|
+
return t ? v(t) : X(() => {
|
|
737
|
+
j = null, F = void 0, Ne(void 0), A = null, k = null, D.clear();
|
|
738
|
+
for (let e of C.values()) e.pauses.clear(), e.readable = !1, e.presentation = null;
|
|
739
|
+
});
|
|
740
|
+
},
|
|
741
|
+
getSnapshot: () => de,
|
|
742
|
+
getServerSnapshot: () => m,
|
|
743
|
+
subscribe: Ue.subscribe,
|
|
744
|
+
onEvent: Ue.onEvent,
|
|
745
|
+
openIsland: $((e, t) => {
|
|
746
|
+
if (e !== "user" && e !== "attention") return v("invalid-input");
|
|
747
|
+
let n;
|
|
748
|
+
if (t === void 0) n = pe();
|
|
749
|
+
else {
|
|
750
|
+
let e = U(t);
|
|
751
|
+
if (e) return v(e);
|
|
752
|
+
n = C.get(t.id);
|
|
753
|
+
}
|
|
754
|
+
if (!n) return v("empty");
|
|
755
|
+
let r = n;
|
|
756
|
+
return N?.current === r ? _ : X(() => {
|
|
757
|
+
N ? N.current = r : N = {
|
|
758
|
+
reason: e,
|
|
759
|
+
current: r
|
|
760
|
+
};
|
|
761
|
+
});
|
|
762
|
+
}),
|
|
763
|
+
collapseIsland: $(() => N ? X(() => {
|
|
764
|
+
N = null;
|
|
765
|
+
}) : _),
|
|
766
|
+
setAutoDismiss: $((e) => e !== void 0 && typeof e != "boolean" ? v("invalid-input") : Z(e) === Z(I) ? (I = e, _) : X(() => Ne(e))),
|
|
767
|
+
navigate: $(W((e) => N ? N.current === e ? _ : X(() => {
|
|
768
|
+
N.current = e, L?.record === e ? L = null : L && (L.waiting = !1, L.due = x.now() + (F ?? b.attentionDelay ?? c));
|
|
769
|
+
}) : v("island-closed"))),
|
|
770
|
+
setPause: $((e) => {
|
|
771
|
+
if (!e || typeof e.active != "boolean") return v("invalid-input");
|
|
772
|
+
let t;
|
|
773
|
+
if (e.scope === "host") {
|
|
774
|
+
if (![
|
|
775
|
+
"hover",
|
|
776
|
+
"focus",
|
|
777
|
+
"document-hidden",
|
|
778
|
+
"window-blur"
|
|
779
|
+
].includes(e.reason)) return v("invalid-input");
|
|
780
|
+
t = D;
|
|
781
|
+
} else if (e.scope === "notification") {
|
|
782
|
+
let n = be(e.handle);
|
|
783
|
+
if (n) return v(n);
|
|
784
|
+
if (!["gesture", "content-transition"].includes(e.reason)) return v("invalid-input");
|
|
785
|
+
t = C.get(e.handle.id).pauses;
|
|
786
|
+
} else return v("invalid-input");
|
|
787
|
+
return t.has(e.reason) === e.active ? _ : X(() => {
|
|
788
|
+
e.active ? t.add(e.reason) : t.delete(e.reason);
|
|
789
|
+
});
|
|
790
|
+
}),
|
|
791
|
+
setFocused: $((e) => {
|
|
792
|
+
let t = e === null ? void 0 : be(e);
|
|
793
|
+
return t ? v(t) : k === e ? _ : (k = e, g);
|
|
794
|
+
}),
|
|
795
|
+
beginPresentation: $(xe((e, t) => {
|
|
796
|
+
if (e.presentation !== t) return v("stale-presentation");
|
|
797
|
+
let n = H();
|
|
798
|
+
return X(() => {
|
|
799
|
+
e.presentation = n, e.readable = !1;
|
|
800
|
+
}), {
|
|
801
|
+
status: "started",
|
|
802
|
+
token: n
|
|
803
|
+
};
|
|
804
|
+
})),
|
|
805
|
+
acknowledgePresentation: $(xe((e, t) => e.presentation === t ? e.readable ? _ : X((t) => {
|
|
806
|
+
t.push({
|
|
807
|
+
type: "presented",
|
|
808
|
+
handle: e.handle,
|
|
809
|
+
firstPresentation: !e.everPresented
|
|
810
|
+
}), e.readable = e.everPresented = !0;
|
|
811
|
+
}) : v("stale-presentation"))),
|
|
812
|
+
acknowledgeFocus: $((e, t) => A?.token === e ? t !== "focused" && t !== "unavailable" ? v("invalid-input") : X(() => {
|
|
813
|
+
A = null;
|
|
814
|
+
}) : v("stale-focus-request")),
|
|
815
|
+
acknowledgeOverflow: $(() => Ie()),
|
|
816
|
+
acknowledgeAnnouncements: $((e) => Ke(e)),
|
|
817
|
+
dismiss: $((e, t) => {
|
|
818
|
+
let n = U(e);
|
|
819
|
+
return n ? v(n) : [
|
|
820
|
+
"close-button",
|
|
821
|
+
"swipe",
|
|
822
|
+
"navigation"
|
|
823
|
+
].includes(t) ? Fe(e, t) : v("invalid-input");
|
|
824
|
+
}),
|
|
825
|
+
invokeAction: $(W((e) => {
|
|
826
|
+
let t = e.handle, n = e.content.action;
|
|
827
|
+
if (!n || n.kind !== "command") return v("no-command");
|
|
828
|
+
if (e.action.status === "pending") return v("already-pending");
|
|
829
|
+
let r = H(), i = () => !V && C.get(t.id) === e && e.action.status === "pending" && e.action.token === r, a = J();
|
|
830
|
+
e.action = l({
|
|
831
|
+
status: "pending",
|
|
832
|
+
token: r
|
|
833
|
+
}), Y([{
|
|
834
|
+
type: "action-started",
|
|
835
|
+
handle: t,
|
|
836
|
+
token: r
|
|
837
|
+
}], a);
|
|
838
|
+
function o(a) {
|
|
839
|
+
if (!i()) return;
|
|
840
|
+
let o = b.messages?.actionError ?? "Action failed";
|
|
841
|
+
if (n?.kind === "command" && n.errorMessage) try {
|
|
842
|
+
let e = n.errorMessage(a);
|
|
843
|
+
if (typeof e != "string" || !e.trim()) throw TypeError("Invalid action error message");
|
|
844
|
+
o = e;
|
|
845
|
+
} catch (e) {
|
|
846
|
+
V || K("mapper-error", "action.errorMessage", e, t);
|
|
847
|
+
}
|
|
848
|
+
if (!i()) return;
|
|
849
|
+
let s = J();
|
|
850
|
+
e.action = l({
|
|
851
|
+
status: "failed",
|
|
852
|
+
token: r,
|
|
853
|
+
message: o
|
|
854
|
+
}), Y([{
|
|
855
|
+
type: "action-failed",
|
|
856
|
+
handle: t,
|
|
857
|
+
token: r,
|
|
858
|
+
message: o
|
|
859
|
+
}], s);
|
|
860
|
+
}
|
|
861
|
+
let s;
|
|
862
|
+
try {
|
|
863
|
+
s = Promise.resolve(n.run(l({
|
|
864
|
+
handle: t,
|
|
865
|
+
token: r
|
|
866
|
+
})));
|
|
867
|
+
} catch (e) {
|
|
868
|
+
s = Promise.reject(e);
|
|
869
|
+
}
|
|
870
|
+
return s.then(() => {
|
|
871
|
+
i() && Fe(t, "action-success");
|
|
872
|
+
}, o).catch((e) => {
|
|
873
|
+
V || K("callback-error", "action-settlement", e, t);
|
|
874
|
+
}), { status: "started" };
|
|
875
|
+
})),
|
|
876
|
+
retryOperation: $(Se((e) => {
|
|
877
|
+
let t = e.retry();
|
|
878
|
+
return t.status === "started" ? {
|
|
879
|
+
status: "started",
|
|
880
|
+
token: t.attempt.token
|
|
881
|
+
} : t;
|
|
882
|
+
})),
|
|
883
|
+
cancelOperation: $(Se((e, t) => e.cancel(t))),
|
|
884
|
+
reportDiagnostic: $((e) => !e || typeof e.source != "string" || typeof e.message != "string" || ![
|
|
885
|
+
"invalid-input",
|
|
886
|
+
"second-host",
|
|
887
|
+
"stale-host",
|
|
888
|
+
"mapper-error",
|
|
889
|
+
"callback-error",
|
|
890
|
+
"listener-error",
|
|
891
|
+
"cancellation-error",
|
|
892
|
+
"slot-error",
|
|
893
|
+
"formatter-error",
|
|
894
|
+
"invalid-container"
|
|
895
|
+
].includes(e.code) ? v("invalid-input") : (G(e), g))
|
|
896
|
+
});
|
|
897
|
+
function Ke(e) {
|
|
898
|
+
if (!Array.isArray(e)) return v("invalid-input");
|
|
899
|
+
let t = [], n = (e, t) => Number.isSafeInteger(e) && e >= 0 && e <= t;
|
|
900
|
+
for (let r of e) {
|
|
901
|
+
if (!r || typeof r != "object") return v("invalid-input");
|
|
902
|
+
if (r.kind === "overflow") {
|
|
903
|
+
if (!n(r.count, z)) return v("invalid-input");
|
|
904
|
+
r.count > B && t.push(() => {
|
|
905
|
+
B = Math.max(B, r.count);
|
|
906
|
+
});
|
|
907
|
+
continue;
|
|
908
|
+
}
|
|
909
|
+
let e = U(r.handle);
|
|
910
|
+
if (e) return v(e);
|
|
911
|
+
let i = C.get(r.handle.id);
|
|
912
|
+
if (r.kind === "operation") {
|
|
913
|
+
let e = i.operation?.getSnapshot();
|
|
914
|
+
if (!e || e.token !== r.token) return v("stale-operation-token");
|
|
915
|
+
if (![
|
|
916
|
+
"started",
|
|
917
|
+
"fulfilled",
|
|
918
|
+
"rejected",
|
|
919
|
+
"cancelled",
|
|
920
|
+
"cancel-requested"
|
|
921
|
+
].includes(r.phase) || (r.phase === "cancel-requested" ? !e.cancelRequested : r.phase !== "started" && r.phase !== e.status)) return v("invalid-input");
|
|
922
|
+
i.operationAnnounced.has(r.phase) || t.push(() => {
|
|
923
|
+
i.operationAnnounced.add(r.phase);
|
|
924
|
+
});
|
|
925
|
+
} else if (r.kind === "action") {
|
|
926
|
+
if (i.action.status === "idle" || i.action.token !== r.token || i.action.status !== r.status) return v("invalid-input");
|
|
927
|
+
(i.actionAnnounced?.token !== r.token || i.actionAnnounced?.status !== r.status) && t.push(() => {
|
|
928
|
+
i.actionAnnounced = l({
|
|
929
|
+
token: r.token,
|
|
930
|
+
status: r.status
|
|
931
|
+
});
|
|
932
|
+
});
|
|
933
|
+
} else if (r.kind === "occurrences") {
|
|
934
|
+
if (!n(r.count, i.occurrences)) return v("invalid-input");
|
|
935
|
+
r.count > i.occurrencesAnnounced && t.push(() => {
|
|
936
|
+
i.occurrencesAnnounced = Math.max(i.occurrencesAnnounced, r.count);
|
|
937
|
+
});
|
|
938
|
+
} else if (r.kind === "queued" || r.kind === "first-presentation") {
|
|
939
|
+
let e = r.kind === "queued" ? "queuedAnnounced" : "firstAnnounced";
|
|
940
|
+
i[e] || t.push(() => {
|
|
941
|
+
i[e] = !0;
|
|
942
|
+
});
|
|
943
|
+
} else return v("invalid-input");
|
|
944
|
+
}
|
|
945
|
+
return t.length ? X(() => {
|
|
946
|
+
for (let e of t) e();
|
|
947
|
+
}) : _;
|
|
948
|
+
}
|
|
949
|
+
return Ee(), ee.set(Ue, Ge), Ue;
|
|
950
|
+
}
|
|
951
|
+
//#endregion
|
|
952
|
+
export { b as createCloudletCore, y as getRendererBridge };
|
|
953
|
+
|
|
954
|
+
//# sourceMappingURL=controller.js.map
|