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