@cloudlet/toast 1.0.0-rc.3 → 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 +42 -7
- package/README.md +5 -4
- package/dist/contracts/events.d.ts +1 -1
- package/dist/contracts/events.d.ts.map +1 -1
- 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 +113 -3
- package/dist/core/controller.d.ts.map +1 -1
- package/dist/core/controller.js +416 -583
- package/dist/core/controller.js.map +1 -1
- package/dist/react/announcer.d.ts.map +1 -1
- package/dist/react/announcer.js +29 -23
- package/dist/react/announcer.js.map +1 -1
- package/dist/react/bindings.d.ts +9 -0
- package/dist/react/bindings.d.ts.map +1 -1
- package/dist/react/bindings.js +32 -69
- package/dist/react/bindings.js.map +1 -1
- package/dist/react/card.d.ts +1 -1
- package/dist/react/card.js.map +1 -1
- package/dist/react/generators.d.ts +2 -2
- package/dist/react/generators.js.map +1 -1
- package/dist/react/gestures.js.map +1 -1
- package/dist/react/host.d.ts.map +1 -1
- package/dist/react/host.js +1 -1
- package/dist/react/host.js.map +1 -1
- package/dist/react/motion.d.ts +3 -3
- package/dist/react/motion.js.map +1 -1
- package/dist/react/plan.d.ts +1 -1
- package/dist/react/plan.d.ts.map +1 -1
- package/dist/react/plan.js.map +1 -1
- 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.d.ts +4 -4
- package/dist/react.d.ts.map +1 -1
- package/package.json +4 -2
- package/src/contracts/events.ts +2 -1
- package/src/core/bridge.ts +280 -0
- package/src/core/controller.ts +83 -268
- package/src/react/announcer.ts +9 -0
- package/src/react/bindings.tsx +28 -72
- package/src/react/card.tsx +3 -3
- package/src/react/generators.ts +2 -2
- package/src/react/gestures.ts +1 -1
- package/src/react/host.tsx +10 -4
- package/src/react/motion.ts +4 -4
- package/src/react/plan.ts +2 -2
- package/src/react/renderer.tsx +77 -0
- package/src/react.ts +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,11 +1,46 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.0.0 — 2026-10-29
|
|
4
|
+
|
|
5
|
+
The first stable release, published to npm as `latest` (`npm install @cloudlet/toast`). The API is the
|
|
6
|
+
one of 1.0.0-rc.3 plus one diagnostic code; it follows semantic versioning from here. Not yet checked by
|
|
7
|
+
hand: screen readers beyond VoiceOver on macOS, physical phones and the minimum browser versions
|
|
8
|
+
(listed on the documentation's Accessibility page).
|
|
9
|
+
|
|
10
|
+
### Performance
|
|
11
|
+
|
|
12
|
+
- `Toaster` loads its renderer (host, motion, cards, gestures, announcer) as a separate chunk through
|
|
13
|
+
`import()`, once per page, on the client after mount. The JavaScript an app pays for at start drops
|
|
14
|
+
from 27953 to 8602 B min+gzip; the renderer chunk follows right after. Notifications shown meanwhile
|
|
15
|
+
wait in the controller. No `React.lazy` or `Suspense` is needed in the app, and server rendering is
|
|
16
|
+
unchanged: Toaster renders nothing on the server.
|
|
17
|
+
|
|
18
|
+
### API
|
|
19
|
+
|
|
20
|
+
- New diagnostic `renderer-load-error`: the renderer chunk failed to load (offline, for example). The
|
|
21
|
+
notifications wait in the controller, and the next Toaster mount loads the chunk again.
|
|
22
|
+
|
|
23
|
+
### Fixes
|
|
24
|
+
|
|
25
|
+
- The Island's background no longer counts as layout shift while it morphs at the bottom edge: it is
|
|
26
|
+
placed with a transform instead of `bottom: 0`. Pixels are unchanged.
|
|
27
|
+
- On a slow first frame, the queue aggregate ("2 notifications queued") was spoken alone before the
|
|
28
|
+
newest record's title. The announcer now waits until the pill is readable and speaks the title first
|
|
29
|
+
and the queue after it, as on fast devices.
|
|
30
|
+
|
|
31
|
+
### shadcn item
|
|
32
|
+
|
|
33
|
+
- The wrapper takes a controller that may still be `null` (`ReactCloudletController | null`), so an app
|
|
34
|
+
can render it before its client owner has created the controller.
|
|
35
|
+
|
|
3
36
|
## 1.0.0-rc.3 — 2026-10-25
|
|
4
37
|
|
|
5
|
-
|
|
6
|
-
(
|
|
7
|
-
|
|
8
|
-
|
|
38
|
+
Release candidate, published to npm on 2026-10-27 under the `next` dist-tag
|
|
39
|
+
(`npm install @cloudlet/toast@next`; integrity
|
|
40
|
+
`sha512-iYdZ7n/eH5gtLD4+QQTwQp/mtKCMNoCi89BWwTJw2G+qT86V9OwrK1pE3kwaxModaFO7t4EHvS8wQoS1iOIbFA==`).
|
|
41
|
+
It carries the fixes from the VoiceOver + Safari gate on 1.0.0-rc.2 (slide revisits, assertive text in
|
|
42
|
+
the open Island, repeated messages) and localizable role words, so that gate can be closed on an
|
|
43
|
+
archive.
|
|
9
44
|
|
|
10
45
|
### Migrating from 1.0.0-rc.2
|
|
11
46
|
|
|
@@ -38,7 +73,7 @@ that gate can be closed on an archive. Stable release readiness stays **not read
|
|
|
38
73
|
Local, private release candidate. It closes the library questions collected while building the landing
|
|
39
74
|
page and the documentation site (own motion generators, export map, provider/auto-dismiss/theme API and
|
|
40
75
|
interaction fixes) before the manual accessibility, device and Safari gates, which now run on this
|
|
41
|
-
candidate. Stable release readiness stays **not ready
|
|
76
|
+
candidate. Stable release readiness stays **not ready**; nothing has been
|
|
42
77
|
published.
|
|
43
78
|
|
|
44
79
|
### Migrating from 1.0.0-rc.1
|
|
@@ -82,7 +117,7 @@ published.
|
|
|
82
117
|
`Home`/`End` on that body scroll it instead of switching slides.
|
|
83
118
|
- The JS fallbacks of `--cloudlet-tail-offset`/`--cloudlet-tail-scale` match the stylesheet (4 / 0.9).
|
|
84
119
|
|
|
85
|
-
### Size (experiment E1
|
|
120
|
+
### Size (experiment E1)
|
|
86
121
|
|
|
87
122
|
- `motion` is no longer a dependency of the package: the shell sampler runs on Cloudlet's own numeric
|
|
88
123
|
generators (`src/react/generators.ts`), the spring and two-keyframe `easeOut` tween ported from
|
|
@@ -105,7 +140,7 @@ published.
|
|
|
105
140
|
|
|
106
141
|
Local, private release candidate of the stack → Island model (DESIGN.md, tasks 12–18). No compatibility
|
|
107
142
|
with rc.0 is promised: see Migrating from 1.0.0-rc.0 below. Stable release readiness stays
|
|
108
|
-
**not ready
|
|
143
|
+
**not ready**; nothing has been published.
|
|
109
144
|
|
|
110
145
|
### Verification (task 18)
|
|
111
146
|
|
package/README.md
CHANGED
|
@@ -6,14 +6,15 @@ over every notification. Activating the pill opens the Island; a notification th
|
|
|
6
6
|
opens it on its own after a short delay, without moving keyboard focus. The same controller follows
|
|
7
7
|
promises from pending to success or failure, with retry and cooperative cancellation.
|
|
8
8
|
|
|
9
|
-
**Status.** `1.0.0
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
**Status.** `1.0.0` is the first stable release; the API follows semantic versioning from here. The
|
|
10
|
+
checks not yet done by hand (screen readers beyond VoiceOver on macOS, physical phones, the minimum
|
|
11
|
+
browser versions) are listed under
|
|
12
|
+
[What is tested](https://cloudlet.dev/toaster/docs/accessibility#what-is-tested).
|
|
12
13
|
|
|
13
14
|
## Installation
|
|
14
15
|
|
|
15
16
|
```sh
|
|
16
|
-
npm install @cloudlet/toast
|
|
17
|
+
npm install @cloudlet/toast
|
|
17
18
|
```
|
|
18
19
|
|
|
19
20
|
React and React DOM `^18.2.0 || ^19.0.0` are peers; use a matching pair. The package is ESM only, has
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ActionAttemptToken, ControllerIdentity, NotificationHandle, OperationAttemptToken } from './identity.js';
|
|
2
2
|
import type { CloseReason } from './notifications.js';
|
|
3
3
|
import type { OperationStatus } from './operations.js';
|
|
4
|
-
export type DiagnosticCode = 'invalid-input' | 'second-host' | 'stale-host' | 'mapper-error' | 'callback-error' | 'listener-error' | 'cancellation-error' | 'slot-error' | 'formatter-error' | 'invalid-container';
|
|
4
|
+
export type DiagnosticCode = 'invalid-input' | 'second-host' | 'stale-host' | 'mapper-error' | 'callback-error' | 'listener-error' | 'cancellation-error' | 'slot-error' | 'formatter-error' | 'invalid-container' | 'renderer-load-error';
|
|
5
5
|
export interface Diagnostic {
|
|
6
6
|
readonly code: DiagnosticCode;
|
|
7
7
|
readonly source: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/contracts/events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACvH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAEvD,MAAM,MAAM,cAAc,GACtB,eAAe,GACf,aAAa,GACb,YAAY,GACZ,cAAc,GACd,gBAAgB,GAChB,gBAAgB,GAChB,oBAAoB,GACpB,YAAY,GACZ,iBAAiB,GACjB,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/contracts/events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACvH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAEvD,MAAM,MAAM,cAAc,GACtB,eAAe,GACf,aAAa,GACb,YAAY,GACZ,cAAc,GACd,gBAAgB,GAChB,gBAAgB,GAChB,oBAAoB,GACpB,YAAY,GACZ,iBAAiB,GACjB,mBAAmB,GACnB,qBAAqB,CAAC;AAE1B,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,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js';
|
|
3
|
+
import type { CloudletController } from '../contracts/controller.js';
|
|
4
|
+
export declare function getRendererBridge<Slot, Signal extends CancellationSignal>(controller: CloudletController<Slot, Signal>): RendererBridge<Slot>;
|
|
5
|
+
//# sourceMappingURL=bridge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bridge.d.ts","sourceRoot":"","sources":["../../src/core/bridge.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAES,cAAc,EAClC,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AACrE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAarE,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,SAAS,kBAAkB,EAAE,UAAU,EAAE,kBAAkB,CAAC,IAAI,EAAE,MAAM,CAAC,GAAG,cAAc,CAAC,IAAI,CAAC,CAO7I"}
|
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
import { validDelay as e } from "./validation.js";
|
|
2
|
+
import { APPLIED as t, RENDERER_SERVER as n, UNCHANGED as r, getControllerKernel as i, reject as a } from "./controller.js";
|
|
3
|
+
//#region src/core/bridge.ts
|
|
4
|
+
var o = Object.freeze, s = /* @__PURE__ */ new WeakMap();
|
|
5
|
+
function c(e) {
|
|
6
|
+
let t = s.get(e);
|
|
7
|
+
return t || (t = l(i(e)), s.set(e, t)), t;
|
|
8
|
+
}
|
|
9
|
+
function l(i) {
|
|
10
|
+
let s = (e) => i.disposed ? "disposed" : i.lease === null || e !== i.lease ? "stale-lease" : void 0, c = (e) => i.handleError(e) ?? (i.records.get(e.id) === i.presented ? void 0 : "not-current");
|
|
11
|
+
function l(e) {
|
|
12
|
+
return i.withRecord((t, ...n) => t === i.presented ? e(t, ...n) : a("not-current"));
|
|
13
|
+
}
|
|
14
|
+
function u(e) {
|
|
15
|
+
return i.withRecord((t, n, ...r) => {
|
|
16
|
+
let i = t.operation;
|
|
17
|
+
return i ? i.getSnapshot().token === n ? e(i, ...r) : a("stale-operation-token") : a("no-operation");
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
function d(t) {
|
|
21
|
+
return t === void 0 || typeof t == "object" && !!t && Object.keys(t).every((e) => e === "attentionDelay") && (t.attentionDelay === void 0 || e(t.attentionDelay));
|
|
22
|
+
}
|
|
23
|
+
function f(e) {
|
|
24
|
+
return (t, ...n) => {
|
|
25
|
+
let r = s(t);
|
|
26
|
+
return r ? a(r) : e(...n);
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
let p = o({
|
|
30
|
+
renderError: i.options.messages?.renderError ?? "Content unavailable",
|
|
31
|
+
reportInvalidContainer(e, t) {
|
|
32
|
+
i.disposed || i.diagnostic({
|
|
33
|
+
code: "invalid-container",
|
|
34
|
+
source: "Toaster.container",
|
|
35
|
+
message: e,
|
|
36
|
+
...t === void 0 ? {} : { error: t }
|
|
37
|
+
});
|
|
38
|
+
},
|
|
39
|
+
attach(e) {
|
|
40
|
+
if (i.disposed) return a("disposed");
|
|
41
|
+
if (i.lease !== null) return i.diagnostic({
|
|
42
|
+
code: "second-host",
|
|
43
|
+
source: "attach",
|
|
44
|
+
message: "A renderer is already attached"
|
|
45
|
+
}), a("host-exists");
|
|
46
|
+
if (!d(e)) return a("invalid-input");
|
|
47
|
+
let t = i.token();
|
|
48
|
+
return i.mutate(() => {
|
|
49
|
+
i.lease = i.lastLease = t, i.hostDelay = e?.attentionDelay, i.presented && i.assign(i.presented);
|
|
50
|
+
}), {
|
|
51
|
+
status: "attached",
|
|
52
|
+
lease: t
|
|
53
|
+
};
|
|
54
|
+
},
|
|
55
|
+
detach(e) {
|
|
56
|
+
if (i.disposed) return a("disposed");
|
|
57
|
+
if (i.lease === null && i.lastLease !== null && e === i.lastLease) return r;
|
|
58
|
+
let t = s(e);
|
|
59
|
+
return t ? a(t) : i.mutate(() => {
|
|
60
|
+
i.lease = null, i.hostDelay = void 0, i.setHostAutoDismiss(void 0), i.focusRequest = null, i.focused = null, i.globalPauses.clear();
|
|
61
|
+
for (let e of i.records.values()) e.pauses.clear(), e.readable = !1, e.presentation = null;
|
|
62
|
+
});
|
|
63
|
+
},
|
|
64
|
+
getSnapshot: () => i.rendererSnapshot,
|
|
65
|
+
getServerSnapshot: () => n,
|
|
66
|
+
subscribe: i.subscribe,
|
|
67
|
+
onEvent: i.onEvent,
|
|
68
|
+
openIsland: f((e, t) => {
|
|
69
|
+
if (e !== "user" && e !== "attention") return a("invalid-input");
|
|
70
|
+
let n;
|
|
71
|
+
if (t === void 0) n = i.newest();
|
|
72
|
+
else {
|
|
73
|
+
let e = i.handleError(t);
|
|
74
|
+
if (e) return a(e);
|
|
75
|
+
n = i.records.get(t.id);
|
|
76
|
+
}
|
|
77
|
+
if (!n) return a("empty");
|
|
78
|
+
let o = n;
|
|
79
|
+
return i.island?.current === o ? r : i.mutate(() => {
|
|
80
|
+
i.island ? i.island.current = o : i.island = {
|
|
81
|
+
reason: e,
|
|
82
|
+
current: o
|
|
83
|
+
};
|
|
84
|
+
});
|
|
85
|
+
}),
|
|
86
|
+
collapseIsland: f(() => i.island ? i.mutate(() => {
|
|
87
|
+
i.island = null;
|
|
88
|
+
}) : r),
|
|
89
|
+
setAutoDismiss: f((e) => e !== void 0 && typeof e != "boolean" ? a("invalid-input") : i.autoDismissing(e) === i.autoDismissing(i.hostAutoDismiss) ? (i.hostAutoDismiss = e, r) : i.mutate(() => i.setHostAutoDismiss(e))),
|
|
90
|
+
navigate: f(i.withRecord((e) => i.island ? i.island.current === e ? r : i.mutate(() => {
|
|
91
|
+
i.island.current = e, i.attention?.record === e ? i.attention = null : i.attention && (i.attention.waiting = !1, i.attention.due = i.clock.now() + (i.hostDelay ?? i.options.attentionDelay ?? 600));
|
|
92
|
+
}) : a("island-closed"))),
|
|
93
|
+
setPause: f((e) => {
|
|
94
|
+
if (!e || typeof e.active != "boolean") return a("invalid-input");
|
|
95
|
+
let t;
|
|
96
|
+
if (e.scope === "host") {
|
|
97
|
+
if (![
|
|
98
|
+
"hover",
|
|
99
|
+
"focus",
|
|
100
|
+
"document-hidden",
|
|
101
|
+
"window-blur"
|
|
102
|
+
].includes(e.reason)) return a("invalid-input");
|
|
103
|
+
t = i.globalPauses;
|
|
104
|
+
} else if (e.scope === "notification") {
|
|
105
|
+
let n = c(e.handle);
|
|
106
|
+
if (n) return a(n);
|
|
107
|
+
if (!["gesture", "content-transition"].includes(e.reason)) return a("invalid-input");
|
|
108
|
+
t = i.records.get(e.handle.id).pauses;
|
|
109
|
+
} else return a("invalid-input");
|
|
110
|
+
return t.has(e.reason) === e.active ? r : i.mutate(() => {
|
|
111
|
+
e.active ? t.add(e.reason) : t.delete(e.reason);
|
|
112
|
+
});
|
|
113
|
+
}),
|
|
114
|
+
setFocused: f((e) => {
|
|
115
|
+
let n = e === null ? void 0 : c(e);
|
|
116
|
+
return n ? a(n) : i.focused === e ? r : (i.focused = e, t);
|
|
117
|
+
}),
|
|
118
|
+
beginPresentation: f(l((e, t) => {
|
|
119
|
+
if (e.presentation !== t) return a("stale-presentation");
|
|
120
|
+
let n = i.token();
|
|
121
|
+
return i.mutate(() => {
|
|
122
|
+
e.presentation = n, e.readable = !1;
|
|
123
|
+
}), {
|
|
124
|
+
status: "started",
|
|
125
|
+
token: n
|
|
126
|
+
};
|
|
127
|
+
})),
|
|
128
|
+
acknowledgePresentation: f(l((e, t) => e.presentation === t ? e.readable ? r : i.mutate((t) => {
|
|
129
|
+
t.push({
|
|
130
|
+
type: "presented",
|
|
131
|
+
handle: e.handle,
|
|
132
|
+
firstPresentation: !e.everPresented
|
|
133
|
+
}), e.readable = e.everPresented = !0;
|
|
134
|
+
}) : a("stale-presentation"))),
|
|
135
|
+
acknowledgeFocus: f((e, t) => i.focusRequest?.token === e ? t !== "focused" && t !== "unavailable" ? a("invalid-input") : i.mutate(() => {
|
|
136
|
+
i.focusRequest = null;
|
|
137
|
+
}) : a("stale-focus-request")),
|
|
138
|
+
acknowledgeOverflow: f(() => i.acknowledgeOverflow()),
|
|
139
|
+
acknowledgeAnnouncements: f((e) => m(e)),
|
|
140
|
+
dismiss: f((e, t) => {
|
|
141
|
+
let n = i.handleError(e);
|
|
142
|
+
return n ? a(n) : [
|
|
143
|
+
"close-button",
|
|
144
|
+
"swipe",
|
|
145
|
+
"navigation"
|
|
146
|
+
].includes(t) ? i.dismiss(e, t) : a("invalid-input");
|
|
147
|
+
}),
|
|
148
|
+
invokeAction: f(i.withRecord((e) => {
|
|
149
|
+
let t = e.handle, n = e.content.action;
|
|
150
|
+
if (!n || n.kind !== "command") return a("no-command");
|
|
151
|
+
if (e.action.status === "pending") return a("already-pending");
|
|
152
|
+
let r = i.token(), s = () => !i.disposed && i.records.get(t.id) === e && e.action.status === "pending" && e.action.token === r, c = i.settle();
|
|
153
|
+
e.action = o({
|
|
154
|
+
status: "pending",
|
|
155
|
+
token: r
|
|
156
|
+
}), i.commit([{
|
|
157
|
+
type: "action-started",
|
|
158
|
+
handle: t,
|
|
159
|
+
token: r
|
|
160
|
+
}], c);
|
|
161
|
+
function l(a) {
|
|
162
|
+
if (!s()) return;
|
|
163
|
+
let c = i.options.messages?.actionError ?? "Action failed";
|
|
164
|
+
if (n?.kind === "command" && n.errorMessage) try {
|
|
165
|
+
let e = n.errorMessage(a);
|
|
166
|
+
if (typeof e != "string" || !e.trim()) throw TypeError("Invalid action error message");
|
|
167
|
+
c = e;
|
|
168
|
+
} catch (e) {
|
|
169
|
+
i.disposed || i.failure("mapper-error", "action.errorMessage", e, t);
|
|
170
|
+
}
|
|
171
|
+
if (!s()) return;
|
|
172
|
+
let l = i.settle();
|
|
173
|
+
e.action = o({
|
|
174
|
+
status: "failed",
|
|
175
|
+
token: r,
|
|
176
|
+
message: c
|
|
177
|
+
}), i.commit([{
|
|
178
|
+
type: "action-failed",
|
|
179
|
+
handle: t,
|
|
180
|
+
token: r,
|
|
181
|
+
message: c
|
|
182
|
+
}], l);
|
|
183
|
+
}
|
|
184
|
+
let u;
|
|
185
|
+
try {
|
|
186
|
+
u = Promise.resolve(n.run(o({
|
|
187
|
+
handle: t,
|
|
188
|
+
token: r
|
|
189
|
+
})));
|
|
190
|
+
} catch (e) {
|
|
191
|
+
u = Promise.reject(e);
|
|
192
|
+
}
|
|
193
|
+
return u.then(() => {
|
|
194
|
+
s() && i.dismiss(t, "action-success");
|
|
195
|
+
}, l).catch((e) => {
|
|
196
|
+
i.disposed || i.failure("callback-error", "action-settlement", e, t);
|
|
197
|
+
}), { status: "started" };
|
|
198
|
+
})),
|
|
199
|
+
retryOperation: f(u((e) => {
|
|
200
|
+
let t = e.retry();
|
|
201
|
+
return t.status === "started" ? {
|
|
202
|
+
status: "started",
|
|
203
|
+
token: t.attempt.token
|
|
204
|
+
} : t;
|
|
205
|
+
})),
|
|
206
|
+
cancelOperation: f(u((e, t) => e.cancel(t))),
|
|
207
|
+
reportDiagnostic: f((e) => !e || typeof e.source != "string" || typeof e.message != "string" || ![
|
|
208
|
+
"invalid-input",
|
|
209
|
+
"second-host",
|
|
210
|
+
"stale-host",
|
|
211
|
+
"mapper-error",
|
|
212
|
+
"callback-error",
|
|
213
|
+
"listener-error",
|
|
214
|
+
"cancellation-error",
|
|
215
|
+
"slot-error",
|
|
216
|
+
"formatter-error",
|
|
217
|
+
"invalid-container"
|
|
218
|
+
].includes(e.code) ? a("invalid-input") : (i.diagnostic(e), t))
|
|
219
|
+
});
|
|
220
|
+
function m(e) {
|
|
221
|
+
if (!Array.isArray(e)) return a("invalid-input");
|
|
222
|
+
let t = [], n = (e, t) => Number.isSafeInteger(e) && e >= 0 && e <= t;
|
|
223
|
+
for (let r of e) {
|
|
224
|
+
if (!r || typeof r != "object") return a("invalid-input");
|
|
225
|
+
if (r.kind === "overflow") {
|
|
226
|
+
if (!n(r.count, i.overflow)) return a("invalid-input");
|
|
227
|
+
r.count > i.overflowAnnounced && t.push(() => {
|
|
228
|
+
i.overflowAnnounced = Math.max(i.overflowAnnounced, r.count);
|
|
229
|
+
});
|
|
230
|
+
continue;
|
|
231
|
+
}
|
|
232
|
+
let e = i.handleError(r.handle);
|
|
233
|
+
if (e) return a(e);
|
|
234
|
+
let s = i.records.get(r.handle.id);
|
|
235
|
+
if (r.kind === "operation") {
|
|
236
|
+
let e = s.operation?.getSnapshot();
|
|
237
|
+
if (!e || e.token !== r.token) return a("stale-operation-token");
|
|
238
|
+
if (![
|
|
239
|
+
"started",
|
|
240
|
+
"fulfilled",
|
|
241
|
+
"rejected",
|
|
242
|
+
"cancelled",
|
|
243
|
+
"cancel-requested"
|
|
244
|
+
].includes(r.phase) || (r.phase === "cancel-requested" ? !e.cancelRequested : r.phase !== "started" && r.phase !== e.status)) return a("invalid-input");
|
|
245
|
+
s.operationAnnounced.has(r.phase) || t.push(() => {
|
|
246
|
+
s.operationAnnounced.add(r.phase);
|
|
247
|
+
});
|
|
248
|
+
} else if (r.kind === "action") {
|
|
249
|
+
if (s.action.status === "idle" || s.action.token !== r.token || s.action.status !== r.status) return a("invalid-input");
|
|
250
|
+
(s.actionAnnounced?.token !== r.token || s.actionAnnounced?.status !== r.status) && t.push(() => {
|
|
251
|
+
s.actionAnnounced = o({
|
|
252
|
+
token: r.token,
|
|
253
|
+
status: r.status
|
|
254
|
+
});
|
|
255
|
+
});
|
|
256
|
+
} else if (r.kind === "occurrences") {
|
|
257
|
+
if (!n(r.count, s.occurrences)) return a("invalid-input");
|
|
258
|
+
r.count > s.occurrencesAnnounced && t.push(() => {
|
|
259
|
+
s.occurrencesAnnounced = Math.max(s.occurrencesAnnounced, r.count);
|
|
260
|
+
});
|
|
261
|
+
} else if (r.kind === "queued" || r.kind === "first-presentation") {
|
|
262
|
+
let e = r.kind === "queued" ? "queuedAnnounced" : "firstAnnounced";
|
|
263
|
+
s[e] || t.push(() => {
|
|
264
|
+
s[e] = !0;
|
|
265
|
+
});
|
|
266
|
+
} else return a("invalid-input");
|
|
267
|
+
}
|
|
268
|
+
return t.length ? i.mutate(() => {
|
|
269
|
+
for (let e of t) e();
|
|
270
|
+
}) : r;
|
|
271
|
+
}
|
|
272
|
+
return p;
|
|
273
|
+
}
|
|
274
|
+
//#endregion
|
|
275
|
+
export { c as getRendererBridge };
|
|
276
|
+
|
|
277
|
+
//# sourceMappingURL=bridge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bridge.js","names":["freeze","bridges","getRendererBridge","bridge","controller","createRendererBridge","getControllerKernel","leaseError","k","value","currentError","handle","withCurrent","args","record","action","reject","withOperation","operation","expected","validHostOptions","key","validDelay","withLease","error","hostOptions","nextLease","UNCHANGED","RENDERER_SERVER","reason","target","change","set","APPLIED","previous","presentation","deliveries","focusToken","outcome","acknowledgeAnnouncements","acknowledgements","actionToken","live","now","failed","message","mapped","result","report","acks","changes","validCount","count","maximum","ack","apply"],"sources":["../../src/core/bridge.ts"],"sourcesContent":["import type { Diagnostic } from '../contracts/events.js';\nimport type { ActionAttemptToken, NotificationHandle, OperationAttemptToken } from '../contracts/identity.js';\nimport type {\n AnnouncementAcknowledgement, BridgeRejection, BridgeResult, FocusRequestToken, HostLease, HostOptions, PauseChange,\n PresentationToken, RendererBridge,\n} from '../contracts/internal.js';\nimport type { CancellationSignal } from '../contracts/operations.js';\nimport type { CloudletController } from '../contracts/controller.js';\nimport type { IslandReason, PauseReason } from '../contracts/snapshots.js';\nimport {\n APPLIED, ATTENTION_DELAY, RENDERER_SERVER, UNCHANGED, getControllerKernel, reject,\n type ControllerKernel, type OperationBinding, type RecordState,\n} from './controller.js';\nimport { validDelay } from './validation.js';\n\n// The renderer's side of a controller. It is imported only by react/renderer.tsx, so it travels\n// in the lazily loaded renderer chunk; the controller keeps a kernel of the state it touches.\nconst freeze = Object.freeze;\nconst bridges = new WeakMap<object, RendererBridge<unknown>>();\n\nexport function getRendererBridge<Slot, Signal extends CancellationSignal>(controller: CloudletController<Slot, Signal>): RendererBridge<Slot> {\n let bridge = bridges.get(controller);\n if (!bridge) {\n bridge = createRendererBridge(getControllerKernel<Slot>(controller)) as RendererBridge<unknown>;\n bridges.set(controller, bridge);\n }\n return bridge as RendererBridge<Slot>;\n}\n\nfunction createRendererBridge<Slot>(k: ControllerKernel<Slot>): RendererBridge<Slot> {\n const leaseError = (value: HostLease): 'disposed' | 'stale-lease' | undefined =>\n k.disposed ? 'disposed' : k.lease === null || value !== k.lease ? 'stale-lease' : undefined;\n const currentError = (handle: NotificationHandle): BridgeRejection | undefined =>\n k.handleError(handle) ?? (k.records.get(handle.id) !== k.presented ? 'not-current' : undefined);\n function withCurrent<Args extends unknown[], Result>(action: (record: RecordState<Slot>, ...args: Args) => Result) {\n return k.withRecord((record, ...args: Args) => record !== k.presented ? reject('not-current') : action(record, ...args));\n }\n function withOperation<Args extends unknown[], Result>(action: (operation: OperationBinding, ...args: Args) => Result) {\n return k.withRecord((record, expected: OperationAttemptToken, ...args: Args) => {\n const operation = record.operation;\n return !operation ? reject('no-operation') : operation.getSnapshot().token !== expected\n ? reject('stale-operation-token') : action(operation, ...args);\n });\n }\n function validHostOptions(value: HostOptions | undefined): boolean {\n if (value === undefined) return true;\n return value !== null && typeof value === 'object' && Object.keys(value).every((key) => key === 'attentionDelay')\n && (value.attentionDelay === undefined || validDelay(value.attentionDelay));\n }\n // Preserve the bridge's lease-first validation order in one entry guard.\n function withLease<Args extends unknown[], Result>(action: (...args: Args) => Result) {\n return (value: HostLease, ...args: Args) => {\n const error = leaseError(value);\n return error ? reject(error) : action(...args);\n };\n }\n const bridge = freeze<RendererBridge<Slot>>({\n renderError: k.options.messages?.renderError ?? 'Content unavailable',\n reportInvalidContainer(message, error) {\n if (!k.disposed) k.diagnostic({ code: 'invalid-container', source: 'Toaster.container', message, ...(error === undefined ? {} : { error }) });\n },\n attach(hostOptions) {\n if (k.disposed) return reject('disposed');\n if (k.lease !== null) {\n k.diagnostic({ code: 'second-host', source: 'attach', message: 'A renderer is already attached' });\n return reject('host-exists');\n }\n if (!validHostOptions(hostOptions)) return reject('invalid-input');\n const nextLease = k.token() as HostLease;\n k.mutate(() => {\n k.lease = k.lastLease = nextLease;\n k.hostDelay = hostOptions?.attentionDelay;\n if (k.presented) k.assign(k.presented);\n });\n return { status: 'attached', lease: nextLease };\n },\n detach(value) {\n if (k.disposed) return reject('disposed');\n if (k.lease === null && k.lastLease !== null && value === k.lastLease) return UNCHANGED;\n const error = leaseError(value);\n if (error) return reject(error);\n return k.mutate(() => {\n k.lease = null;\n k.hostDelay = undefined;\n k.setHostAutoDismiss(undefined);\n k.focusRequest = null;\n k.focused = null;\n k.globalPauses.clear();\n for (const record of k.records.values()) { record.pauses.clear(); record.readable = false; record.presentation = null; }\n });\n },\n getSnapshot: () => k.rendererSnapshot,\n getServerSnapshot: () => RENDERER_SERVER,\n subscribe: k.subscribe,\n onEvent: k.onEvent,\n openIsland: withLease((reason: IslandReason, handle?: NotificationHandle) => {\n if (reason !== 'user' && reason !== 'attention') return reject('invalid-input');\n let record: RecordState<Slot> | null;\n if (handle === undefined) record = k.newest();\n else {\n const error = k.handleError(handle);\n if (error) return reject(error);\n record = k.records.get(handle.id)!;\n }\n if (!record) return reject('empty');\n const target = record;\n if (k.island?.current === target) return UNCHANGED;\n // An open Island only moves its slider; the opening reason is kept.\n return k.mutate(() => {\n if (k.island) k.island.current = target;\n else k.island = { reason, current: target };\n });\n }),\n collapseIsland: withLease(() => k.island ? k.mutate(() => { k.island = null; }) : UNCHANGED),\n setAutoDismiss: withLease((value?: boolean) => {\n if (value !== undefined && typeof value !== 'boolean') return reject('invalid-input');\n if (k.autoDismissing(value) === k.autoDismissing(k.hostAutoDismiss)) { k.hostAutoDismiss = value; return UNCHANGED; }\n return k.mutate(() => k.setHostAutoDismiss(value));\n }),\n navigate: withLease(k.withRecord((record) => {\n if (!k.island) return reject('island-closed');\n if (k.island.current === record) return UNCHANGED;\n return k.mutate(() => {\n k.island!.current = record;\n // Navigation is interaction: a pending auto-open restarts its delay,\n // and reaching the initiator by hand fulfils it.\n if (k.attention?.record === record) k.attention = null;\n else if (k.attention) { k.attention.waiting = false; k.attention.due = k.clock.now() + (k.hostDelay ?? k.options.attentionDelay ?? ATTENTION_DELAY); }\n });\n })),\n setPause: withLease((change: PauseChange) => {\n if (!change || typeof change.active !== 'boolean') return reject('invalid-input');\n let set: Set<PauseReason>;\n if (change.scope === 'host') {\n if (!['hover', 'focus', 'document-hidden', 'window-blur'].includes(change.reason)) return reject('invalid-input');\n set = k.globalPauses;\n } else if (change.scope === 'notification') {\n const error = currentError(change.handle);\n if (error) return reject(error);\n if (!['gesture', 'content-transition'].includes(change.reason)) return reject('invalid-input');\n set = k.records.get(change.handle.id)!.pauses;\n } else return reject('invalid-input');\n if (set.has(change.reason) === change.active) return UNCHANGED;\n return k.mutate(() => {\n if (change.active) set.add(change.reason); else set.delete(change.reason);\n });\n }),\n // Informational since the stack has no slots to protect; it has no observable effect.\n setFocused: withLease((handle: NotificationHandle | null) => {\n const error = (handle === null ? undefined : currentError(handle));\n if (error) return reject(error);\n if (k.focused === handle) return UNCHANGED;\n k.focused = handle;\n return APPLIED;\n }),\n beginPresentation: withLease(withCurrent((record, previous: PresentationToken) => {\n if (record.presentation !== previous) return reject('stale-presentation');\n const presentation = k.token() as PresentationToken;\n k.mutate(() => { record.presentation = presentation; record.readable = false; });\n return { status: 'started' as const, token: presentation };\n })),\n acknowledgePresentation: withLease(withCurrent((record, presentation: PresentationToken) => {\n if (record.presentation !== presentation) return reject('stale-presentation');\n if (record.readable) return UNCHANGED;\n return k.mutate((deliveries) => {\n deliveries.push({ type: 'presented', handle: record.handle, firstPresentation: !record.everPresented });\n record.readable = record.everPresented = true;\n });\n })),\n acknowledgeFocus: withLease((focusToken: FocusRequestToken, outcome: 'focused' | 'unavailable') => {\n if (k.focusRequest?.token !== focusToken) return reject('stale-focus-request');\n if (outcome !== 'focused' && outcome !== 'unavailable') return reject('invalid-input');\n return k.mutate(() => { k.focusRequest = null; });\n }),\n acknowledgeOverflow: withLease(() => {\n return k.acknowledgeOverflow();\n }),\n acknowledgeAnnouncements: withLease((acknowledgements: readonly AnnouncementAcknowledgement[]) => {\n return acknowledgeAnnouncements(acknowledgements);\n }),\n dismiss: withLease((handle: NotificationHandle, reason: 'close-button' | 'swipe' | 'navigation') => {\n const error = k.handleError(handle);\n if (error) return reject(error);\n // Renderer close reasons are a closed protocol, never an exit callback.\n if (!['close-button', 'swipe', 'navigation'].includes(reason)) return reject('invalid-input');\n return k.dismiss(handle, reason);\n }),\n invokeAction: withLease(k.withRecord((record) => {\n const handle = record.handle;\n const action = record.content.action;\n if (!action || action.kind !== 'command') return reject('no-command');\n if (record.action.status === 'pending') return reject('already-pending');\n const actionToken = k.token() as ActionAttemptToken;\n const live = () => !k.disposed && k.records.get(handle.id) === record &&\n record.action.status === 'pending' && record.action.token === actionToken;\n const now = k.settle();\n record.action = freeze({ status: 'pending', token: actionToken });\n k.commit([{ type: 'action-started', handle, token: actionToken }], now);\n function failed(reason: unknown): void {\n if (!live()) return;\n let message = k.options.messages?.actionError ?? 'Action failed';\n if (action?.kind === 'command' && action.errorMessage) {\n try {\n const mapped = action.errorMessage(reason);\n if (typeof mapped !== 'string' || !mapped.trim()) throw new TypeError('Invalid action error message');\n message = mapped;\n } catch (error) {\n if (!k.disposed) k.failure('mapper-error', 'action.errorMessage', error, handle);\n }\n }\n if (!live()) return;\n const now = k.settle();\n record.action = freeze({ status: 'failed', token: actionToken, message });\n k.commit([{ type: 'action-failed', handle, token: actionToken, message }], now);\n }\n let result: Promise<unknown>;\n try { result = Promise.resolve(action.run(freeze({ handle, token: actionToken }))); }\n catch (error) { result = Promise.reject(error); }\n void result.then(() => {\n if (live()) k.dismiss(handle, 'action-success');\n }, failed).catch((error: unknown) => {\n if (!k.disposed) k.failure('callback-error', 'action-settlement', error, handle);\n });\n return { status: 'started' as const };\n })),\n retryOperation: withLease(withOperation((operation) => {\n const result = operation.retry();\n return result.status === 'started' ? { status: 'started' as const, token: result.attempt.token } : result;\n })),\n cancelOperation: withLease(withOperation((operation, reason?: unknown) => operation.cancel(reason))),\n reportDiagnostic: withLease((report: Diagnostic) => {\n if (!report || typeof report.source !== 'string' || typeof report.message !== 'string'\n || !['invalid-input', 'second-host', 'stale-host', 'mapper-error', 'callback-error', 'listener-error', 'cancellation-error', 'slot-error', 'formatter-error', 'invalid-container'].includes(report.code)) return reject('invalid-input');\n k.diagnostic(report);\n return APPLIED;\n }),\n });\n\n function acknowledgeAnnouncements(acks: readonly AnnouncementAcknowledgement[]): BridgeResult {\n if (!Array.isArray(acks)) return reject('invalid-input');\n // Stage only effective changes; no ledger mutation occurs until every\n // acknowledgement has passed validation. Repeated counts remain monotonic.\n const changes: (() => void)[] = [];\n const validCount = (count: number, maximum: number) => Number.isSafeInteger(count) && count >= 0 && count <= maximum;\n for (const ack of acks) {\n if (!ack || typeof ack !== 'object') return reject('invalid-input');\n if (ack.kind === 'overflow') {\n if (!validCount(ack.count, k.overflow)) return reject('invalid-input');\n if (ack.count > k.overflowAnnounced) changes.push(() => { k.overflowAnnounced = Math.max(k.overflowAnnounced, ack.count); });\n continue;\n }\n const error = k.handleError(ack.handle);\n if (error) return reject(error);\n const record = k.records.get(ack.handle.id)!;\n if (ack.kind === 'operation') {\n const operation = record.operation?.getSnapshot();\n if (!operation || operation.token !== ack.token) return reject('stale-operation-token');\n if (!['started', 'fulfilled', 'rejected', 'cancelled', 'cancel-requested'].includes(ack.phase)) return reject('invalid-input');\n if (ack.phase === 'cancel-requested' ? !operation.cancelRequested\n : ack.phase !== 'started' && ack.phase !== operation.status) return reject('invalid-input');\n if (!record.operationAnnounced.has(ack.phase)) changes.push(() => { record.operationAnnounced.add(ack.phase); });\n } else if (ack.kind === 'action') {\n if (record.action.status === 'idle' || record.action.token !== ack.token || record.action.status !== ack.status) return reject('invalid-input');\n if (record.actionAnnounced?.token !== ack.token || record.actionAnnounced?.status !== ack.status) {\n changes.push(() => { record.actionAnnounced = freeze({ token: ack.token, status: ack.status }); });\n }\n } else if (ack.kind === 'occurrences') {\n if (!validCount(ack.count, record.occurrences)) return reject('invalid-input');\n if (ack.count > record.occurrencesAnnounced) changes.push(() => { record.occurrencesAnnounced = Math.max(record.occurrencesAnnounced, ack.count); });\n } else if (ack.kind === 'queued' || ack.kind === 'first-presentation') {\n const key = ack.kind === 'queued' ? 'queuedAnnounced' : 'firstAnnounced';\n if (!record[key]) changes.push(() => { record[key] = true; });\n } else return reject('invalid-input');\n }\n if (!changes.length) return UNCHANGED;\n return k.mutate(() => { for (const apply of changes) apply(); });\n }\n\n return bridge;\n}\n"],"mappings":";;;AAiBA,IAAMA,IAAS,OAAO,QAChBC,oBAAU,IAAI,QAAyC;AAE7D,SAAgBC,EAA2D,GAAoE;CAC7I,IAAIC,IAASF,EAAQ,IAAIG,CAAU;CAKnC,OAJKD,MACH,IAASE,EAAqBC,EAA0BF,CAAU,CAAC,GACnEH,EAAQ,IAAIG,GAAYD,CAAM,IAEzBA;AACT;AAEA,SAASE,EAA2B,GAAiD;CACnF,IAAME,KAAc,MAClBC,EAAE,WAAW,aAAaA,EAAE,UAAU,QAAQC,MAAUD,EAAE,QAAQ,gBAAgB,KAAA,GAC9EE,KAAgB,MACpBF,EAAE,YAAYG,CAAM,MAAMH,EAAE,QAAQ,IAAIG,EAAO,EAAE,MAAMH,EAAE,YAA4B,KAAA,IAAhB;CACvE,SAASI,EAA4C,GAA8D;EACjH,OAAOJ,EAAE,YAAY,GAAQ,GAAGK,MAAeC,MAAWN,EAAE,YAAoCO,EAAOD,GAAQ,GAAGD,CAAI,IAA9CG,EAAO,aAAa,CAA2B;CACzH;CACA,SAASC,EAA8C,GAAgE;EACrH,OAAOT,EAAE,YAAY,GAAQ,GAAiC,GAAGK,MAAe;GAC9E,IAAMK,IAAYJ,EAAO;GACzB,OAAQI,IAAqCA,EAAU,YAAY,CAAC,CAAC,UAAUC,IACzCJ,EAAOG,GAAW,GAAGL,CAAI,IAA3DG,EAAO,uBAAuB,IADdA,EAAO,cAAc;EAE3C,CAAC;CACH;CACA,SAASI,EAAiB,GAAyC;EAEjE,OADIX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AAOxC,EAAO,WAAW,GAAG,OAAOE,EAAO,eAAe;IAC7E,AAAIsC,EAAI,QAAQxC,EAAO,wBAAsBoC,EAAQ,WAAW;KAAE,EAAO,uBAAuB,KAAK,IAAIpC,EAAO,sBAAsBwC,EAAI,KAAK;IAAG,CAAC;GACrJ,OAAO,IAAIA,EAAI,SAAS,YAAYA,EAAI,SAAS,sBAAsB;IACrE,IAAMjC,IAAMiC,EAAI,SAAS,WAAW,oBAAoB;IACxD,AAAKxC,EAAOO,MAAM6B,EAAQ,WAAW;KAAE,EAAO7B,KAAO;IAAM,CAAC;GAC9D,OAAO,OAAOL,EAAO,eAAe;EACtC;EAEA,OADKkC,EAAQ,SACN1C,EAAE,aAAa;GAAE,KAAK,IAAM+C,KAASL,GAAS,EAAM;EAAG,CAAC,IADnCvB;CAE9B;CAEA,OAAOxB;AACT"}
|
|
@@ -1,7 +1,117 @@
|
|
|
1
1
|
import type { CloudletController, ControllerOptions } from '../contracts/controller.js';
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
4
|
-
|
|
2
|
+
import type { Diagnostic, EventBase, SemanticEvent } from '../contracts/events.js';
|
|
3
|
+
import type { ActionAttemptToken, HandleRejection, NotificationHandle } from '../contracts/identity.js';
|
|
4
|
+
import type { FocusRequest, ControllerDependencies, HostLease, OperationAnnouncementPhase, PresentationToken, RendererSnapshot } from '../contracts/internal.js';
|
|
5
|
+
import type { CloseReason, NotificationContent, NotificationKind, NotificationSpec, Priority } from '../contracts/notifications.js';
|
|
6
|
+
import type { AttemptStartResult, CancellationSignal, CancelResult, OperationSnapshot } from '../contracts/operations.js';
|
|
7
|
+
import type { ActionSnapshot, IslandReason, PauseReason } from '../contracts/snapshots.js';
|
|
8
|
+
import { validateOptions } from './validation.js';
|
|
9
|
+
export interface OperationBinding {
|
|
10
|
+
readonly getSnapshot: () => OperationSnapshot;
|
|
11
|
+
readonly retry: () => AttemptStartResult<unknown>;
|
|
12
|
+
readonly cancel: (reason?: unknown) => CancelResult;
|
|
13
|
+
readonly detach: () => Delivery;
|
|
14
|
+
}
|
|
15
|
+
type EventPayload = SemanticEvent extends infer E ? E extends SemanticEvent ? Omit<E, keyof EventBase> : never : never;
|
|
16
|
+
export type Delivery = EventPayload | {
|
|
17
|
+
readonly callback: () => void;
|
|
18
|
+
readonly source: string;
|
|
19
|
+
readonly handle?: NotificationHandle;
|
|
20
|
+
};
|
|
21
|
+
export interface RecordState<Slot> {
|
|
22
|
+
readonly handle: NotificationHandle;
|
|
23
|
+
readonly dedupeKey: string | undefined;
|
|
24
|
+
readonly onClose: NotificationSpec<Slot>['onClose'];
|
|
25
|
+
content: Readonly<NotificationContent<Slot>>;
|
|
26
|
+
kind: NotificationKind;
|
|
27
|
+
priority: Priority;
|
|
28
|
+
occurrences: number;
|
|
29
|
+
remaining: number | null;
|
|
30
|
+
activeSince: number | null;
|
|
31
|
+
presentation: PresentationToken | null;
|
|
32
|
+
readable: boolean;
|
|
33
|
+
everPresented: boolean;
|
|
34
|
+
readonly pauses: Set<PauseReason>;
|
|
35
|
+
queuedAnnounced: boolean;
|
|
36
|
+
firstAnnounced: boolean;
|
|
37
|
+
occurrencesAnnounced: number;
|
|
38
|
+
operation: OperationBinding | null;
|
|
39
|
+
readonly operationAnnounced: Set<OperationAnnouncementPhase>;
|
|
40
|
+
action: ActionSnapshot;
|
|
41
|
+
actionAnnounced?: {
|
|
42
|
+
readonly token: ActionAttemptToken;
|
|
43
|
+
readonly status: 'pending' | 'failed';
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
/** Open Island state; `null` is the collapsed stack. */
|
|
47
|
+
export interface IslandState<Slot> {
|
|
48
|
+
readonly reason: IslandReason;
|
|
49
|
+
current: RecordState<Slot>;
|
|
50
|
+
}
|
|
51
|
+
export interface AttentionCandidate<Slot> {
|
|
52
|
+
readonly record: RecordState<Slot>;
|
|
53
|
+
due: number;
|
|
54
|
+
/** Expired during user interaction or without a host; restarts the delay afterwards. */
|
|
55
|
+
waiting: boolean;
|
|
56
|
+
}
|
|
57
|
+
export declare const ATTENTION_DELAY = 600;
|
|
58
|
+
export declare const RENDERER_SERVER: RendererSnapshot<never>;
|
|
59
|
+
export declare const APPLIED: Readonly<{
|
|
60
|
+
status: 'applied';
|
|
61
|
+
}>;
|
|
62
|
+
export declare const UNCHANGED: Readonly<{
|
|
63
|
+
status: 'unchanged';
|
|
64
|
+
}>;
|
|
65
|
+
export declare const reject: <Reason extends string>(reason: Reason) => {
|
|
66
|
+
status: 'rejected';
|
|
67
|
+
reason: Reason;
|
|
68
|
+
};
|
|
69
|
+
type Rejected<Reason extends string> = {
|
|
70
|
+
status: 'rejected';
|
|
71
|
+
reason: Reason;
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* Controller state and transactions the renderer bridge needs (core/bridge.ts). The bridge travels
|
|
75
|
+
* in the lazily loaded renderer chunk, so the start bundle carries only this accessor object.
|
|
76
|
+
*/
|
|
77
|
+
export interface ControllerKernel<Slot> {
|
|
78
|
+
readonly options: ReturnType<typeof validateOptions>;
|
|
79
|
+
readonly clock: ControllerDependencies<CancellationSignal>['clock'];
|
|
80
|
+
readonly records: Map<string, RecordState<Slot>>;
|
|
81
|
+
readonly globalPauses: Set<PauseReason>;
|
|
82
|
+
readonly subscribe: CloudletController<Slot, CancellationSignal>['subscribe'];
|
|
83
|
+
readonly onEvent: CloudletController<Slot, CancellationSignal>['onEvent'];
|
|
84
|
+
readonly disposed: boolean;
|
|
85
|
+
readonly presented: RecordState<Slot> | null;
|
|
86
|
+
readonly rendererSnapshot: RendererSnapshot<Slot>;
|
|
87
|
+
readonly overflow: number;
|
|
88
|
+
lease: HostLease | null;
|
|
89
|
+
lastLease: HostLease | null;
|
|
90
|
+
hostDelay: number | undefined;
|
|
91
|
+
hostAutoDismiss: boolean | undefined;
|
|
92
|
+
island: IslandState<Slot> | null;
|
|
93
|
+
attention: AttentionCandidate<Slot> | null;
|
|
94
|
+
focusRequest: FocusRequest | null;
|
|
95
|
+
focused: NotificationHandle | null;
|
|
96
|
+
overflowAnnounced: number;
|
|
97
|
+
readonly token: () => string;
|
|
98
|
+
readonly diagnostic: (diagnostic: Diagnostic) => void;
|
|
99
|
+
readonly failure: (code: Diagnostic['code'], source: string, error: unknown, handle?: NotificationHandle) => void;
|
|
100
|
+
readonly mutate: (apply: (deliveries: Delivery[]) => void, final?: boolean) => typeof APPLIED;
|
|
101
|
+
readonly commit: (deliveries?: readonly Delivery[], now?: number, final?: boolean) => void;
|
|
102
|
+
readonly settle: () => number;
|
|
103
|
+
readonly assign: (record: RecordState<Slot>) => void;
|
|
104
|
+
readonly newest: () => RecordState<Slot> | null;
|
|
105
|
+
readonly handleError: (handle: NotificationHandle) => HandleRejection | 'disposed' | undefined;
|
|
106
|
+
readonly withRecord: <Args extends unknown[], Result>(action: (record: RecordState<Slot>, ...args: Args) => Result) => (handle: NotificationHandle, ...args: Args) => Result | Rejected<HandleRejection | 'disposed'>;
|
|
107
|
+
readonly autoDismissing: (host: boolean | undefined) => boolean;
|
|
108
|
+
readonly setHostAutoDismiss: (value: boolean | undefined) => void;
|
|
109
|
+
readonly dismiss: (handle: NotificationHandle, reason: CloseReason) => typeof APPLIED | Rejected<HandleRejection | 'disposed'>;
|
|
110
|
+
readonly acknowledgeOverflow: () => typeof APPLIED | typeof UNCHANGED | Rejected<'disposed'>;
|
|
111
|
+
readonly reportRendererLoadError: (error: unknown) => void;
|
|
112
|
+
}
|
|
113
|
+
export declare function getControllerKernel<Slot>(controller: object): ControllerKernel<Slot>;
|
|
5
114
|
/** The sole owner of notification state, the stack/Island, budgets, attention and host leases. */
|
|
6
115
|
export declare function createCloudletCore<Slot = never, Signal extends CancellationSignal = CancellationSignal>(inputOptions: ControllerOptions | undefined, dependencies: ControllerDependencies<Signal>): CloudletController<Slot, Signal>;
|
|
116
|
+
export {};
|
|
7
117
|
//# sourceMappingURL=controller.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../src/core/controller.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,iBAAiB,EAAe,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../src/core/controller.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,iBAAiB,EAAe,MAAM,4BAA4B,CAAC;AACrG,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACnF,OAAO,KAAK,EAAE,kBAAkB,EAAkC,eAAe,EAAE,kBAAkB,EAAsC,MAAM,0BAA0B,CAAC;AAC5K,OAAO,KAAK,EACV,YAAY,EAAqB,sBAAsB,EAAE,SAAS,EAAE,0BAA0B,EAAE,iBAAiB,EACjH,gBAAgB,EACjB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAmB,WAAW,EAAE,mBAAmB,EAAE,gBAAgB,EAAqB,gBAAgB,EAA4B,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AAClM,OAAO,KAAK,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,YAAY,EAAuD,iBAAiB,EAAkD,MAAM,4BAA4B,CAAC;AAC/N,OAAO,KAAK,EAAE,cAAc,EAAsB,YAAY,EAAkB,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAC/H,OAAO,EAA8C,eAAe,EAAqD,MAAM,iBAAiB,CAAC;AAEjJ,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,WAAW,EAAE,MAAM,iBAAiB,CAAC;IAC9C,QAAQ,CAAC,KAAK,EAAE,MAAM,kBAAkB,CAAC,OAAO,CAAC,CAAC;IAClD,QAAQ,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,EAAE,OAAO,KAAK,YAAY,CAAC;IACpD,QAAQ,CAAC,MAAM,EAAE,MAAM,QAAQ,CAAC;CACjC;AAED,KAAK,YAAY,GAAG,aAAa,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