@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 @@
|
|
|
1
|
+
{"version":3,"file":"shape.js","names":["finite","value","number","curve","createRoundedRectPath","w","width","h","height","r","radius","left","x","top","y","right","bottom","k","p","px","py"],"sources":["../../src/react/shape.ts"],"sourcesContent":["const finite = (value: number) => Number.isFinite(value) ? Math.max(0, value) : 0;\nconst number = (value: number) => String(Math.round(value * 1000) / 1000);\n// Cubic Bézier handle length for a quarter circle.\nconst curve = 0.5522847498;\n\n/**\n * One whole rounded rectangle, the only silhouette of the pill and the Island.\n * The same string feeds the SVG background `d` and the HTML `clip-path: path()`.\n * Invalid or negative sizes collapse to zero; the radius never exceeds half a side.\n */\nexport function createRoundedRectPath(width: number, height: number, radius: number, x = 0, y = 0): string {\n const w = finite(width);\n const h = finite(height);\n const r = Math.min(finite(radius), w / 2, h / 2);\n const left = Number.isFinite(x) ? x : 0;\n const top = Number.isFinite(y) ? y : 0;\n const right = left + w;\n const bottom = top + h;\n const k = r * curve;\n const p = (px: number, py: number) => `${number(px)} ${number(py)}`;\n return [\n `M ${p(left + r, top)}`,\n `L ${p(right - r, top)}`,\n `C ${p(right - r + k, top)} ${p(right, top + r - k)} ${p(right, top + r)}`,\n `L ${p(right, bottom - r)}`,\n `C ${p(right, bottom - r + k)} ${p(right - r + k, bottom)} ${p(right - r, bottom)}`,\n `L ${p(left + r, bottom)}`,\n `C ${p(left + r - k, bottom)} ${p(left, bottom - r + k)} ${p(left, bottom - r)}`,\n `L ${p(left, top + r)}`,\n `C ${p(left, top + r - k)} ${p(left + r - k, top)} ${p(left + r, top)}`,\n 'Z',\n ].join(' ');\n}\n"],"mappings":";AAAA,IAAMA,KAAU,MAAkB,OAAO,SAASC,CAAK,IAAI,KAAK,IAAI,GAAGA,CAAK,IAAI,GAC1EC,KAAU,MAAkB,OAAO,KAAK,M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OF,GAAGI,CAAG;EACpE;CACF,CAAC,CAAC,KAAK,GAAG;AACZ"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** Layout-viewport CSS pixels. Deliberately never read VisualViewport.scale. */
|
|
2
|
+
export declare function visibleViewport(width: number, height: number, visual?: {
|
|
3
|
+
readonly offsetLeft: number;
|
|
4
|
+
readonly offsetTop: number;
|
|
5
|
+
readonly width: number;
|
|
6
|
+
readonly height: number;
|
|
7
|
+
} | null): {
|
|
8
|
+
left: number;
|
|
9
|
+
top: number;
|
|
10
|
+
right: number;
|
|
11
|
+
bottom: number;
|
|
12
|
+
width: number;
|
|
13
|
+
height: number;
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=viewport.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"viewport.d.ts","sourceRoot":"","sources":["../../src/react/viewport.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE;IACtE,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CAC1G,GAAG,IAAI;;;;;;;EAMP"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
//#region src/react/viewport.ts
|
|
2
|
+
function e(e, t, n) {
|
|
3
|
+
let r = Math.min(e, Math.max(0, n?.offsetLeft ?? 0)), i = Math.min(t, Math.max(0, n?.offsetTop ?? 0)), a = Math.max(r, Math.min(e, n ? n.offsetLeft + n.width : e)), o = Math.max(i, Math.min(t, n ? n.offsetTop + n.height : t));
|
|
4
|
+
return {
|
|
5
|
+
left: r,
|
|
6
|
+
top: i,
|
|
7
|
+
right: e - a,
|
|
8
|
+
bottom: t - o,
|
|
9
|
+
width: a - r,
|
|
10
|
+
height: o - i
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
export { e as visibleViewport };
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=viewport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"viewport.js","names":["visibleViewport","left","width","visual","top","height","right","bottom"],"sources":["../../src/react/viewport.ts"],"sourcesContent":["/** Layout-viewport CSS pixels. Deliberately never read VisualViewport.scale. */\nexport function visibleViewport(width: number, height: number, visual?: {\n readonly offsetLeft: number; readonly offsetTop: number; readonly width: number; readonly height: number;\n} | null) {\n const left = Math.min(width, Math.max(0, visual?.offsetLeft ?? 0));\n const top = Math.min(height, Math.max(0, visual?.offsetTop ?? 0));\n const right = Math.max(left, Math.min(width, visual ? visual.offsetLeft + visual.width : width));\n const bottom = Math.max(top, Math.min(height, visual ? visual.offsetTop + visual.height : height));\n return { left, top, right: width - right, bottom: height - bottom, width: right - left, height: bottom - top };\n}\n"],"mappings":";AACA,SAAgBA,EAAgB,GAAe,GAAgB,GAErD;CACR,IAAMC,IAAO,KAAK,IAAIC,GAAO,KAAK,IAAI,GAAGC,GAAQ,cAAc,CAAC,CAAC,GAC3DC,IAAM,KAAK,IAAIC,GAAQ,KAAK,IAAI,GAAGF,GAAQ,aAAa,CAAC,CAAC,GAC1DG,IAAQ,KAAK,IAAIL,GAAM,KAAK,IAAIC,GAAOC,IAASA,EAAO,aAAaA,EAAO,QAAQD,CAAK,CAAC,GACzFK,IAAS,KAAK,IAAIH,GAAK,KAAK,IAAIC,GAAQF,IAASA,EAAO,YAAYA,EAAO,SAASE,CAAM,CAAC;CACjG,OAAO;EAAE;EAAM;EAAK,OAAOH,IAAQI;EAAO,QAAQD,IAASE;EAAQ,OAAOD,IAAQL;EAAM,QAAQM,IAASH;CAAI;AAC/G"}
|
package/dist/react.d.ts
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import type { ReactElement, ReactNode } from 'react';
|
|
2
|
+
import type { CloudletController, ControllerOptions, FocusTarget } from './contracts/controller.js';
|
|
3
|
+
import type { NotificationHandle } from './contracts/identity.js';
|
|
4
|
+
import type { NotificationPatch, NotificationSpec } from './contracts/notifications.js';
|
|
5
|
+
import type { OperationContext, OperationFactory, TrackOptions } from './contracts/operations.js';
|
|
6
|
+
import type { ControllerSnapshot, NotificationSnapshot } from './contracts/snapshots.js';
|
|
7
|
+
export type ReactNotificationSpec = NotificationSpec<ReactNode>;
|
|
8
|
+
export type ReactNotificationPatch = NotificationPatch<ReactNode>;
|
|
9
|
+
export type ReactCloudletController = CloudletController<ReactNode, AbortSignal>;
|
|
10
|
+
export type ReactOperationContext = OperationContext<AbortSignal>;
|
|
11
|
+
export type ReactOperationFactory<T> = OperationFactory<T, AbortSignal>;
|
|
12
|
+
export type ReactTrackOptions<T> = TrackOptions<T, ReactNode, AbortSignal>;
|
|
13
|
+
/** Public web factory signature, including native cancellation signals. */
|
|
14
|
+
export type CreateCloudlet = (options?: ControllerOptions) => ReactCloudletController;
|
|
15
|
+
export interface CloudletProviderProps {
|
|
16
|
+
/** Null while an effect-owned controller does not exist yet (server render, first client render). */
|
|
17
|
+
readonly controller: ReactCloudletController | null;
|
|
18
|
+
readonly children?: ReactNode;
|
|
19
|
+
}
|
|
20
|
+
export interface EdgeInsets {
|
|
21
|
+
readonly top?: number;
|
|
22
|
+
readonly right?: number;
|
|
23
|
+
readonly bottom?: number;
|
|
24
|
+
readonly left?: number;
|
|
25
|
+
}
|
|
26
|
+
export interface ToasterOffsets {
|
|
27
|
+
/** CSS px added outside safe area; omitting an edge uses the CSS viewport-gutter token. */
|
|
28
|
+
readonly gutter?: EdgeInsets;
|
|
29
|
+
/** Additional obstruction beyond safe area; never include safe-area size again. */
|
|
30
|
+
readonly obstruction?: EdgeInsets;
|
|
31
|
+
}
|
|
32
|
+
export interface CloudletLabels {
|
|
33
|
+
readonly region: string;
|
|
34
|
+
/** Accessible name of the Island carousel region. */
|
|
35
|
+
readonly island: string;
|
|
36
|
+
/** Spoken role of the open Island (`aria-roledescription`), "carousel" by default. */
|
|
37
|
+
readonly carousel: string;
|
|
38
|
+
/** Spoken role of each slide in the Island (`aria-roledescription`), "slide" by default. */
|
|
39
|
+
readonly slide: string;
|
|
40
|
+
readonly close: string;
|
|
41
|
+
readonly retry: string;
|
|
42
|
+
readonly cancel: string;
|
|
43
|
+
readonly cancellationRequested: string;
|
|
44
|
+
readonly acknowledgeOverflow: string;
|
|
45
|
+
/** Hidden hint that Escape collapses the Island. */
|
|
46
|
+
readonly collapse: string;
|
|
47
|
+
/** Name of the collapsed stack button: top title, records in the stack, missed notifications. */
|
|
48
|
+
readonly stackSummary: (title: string, count: number, missed: number) => string;
|
|
49
|
+
/** 1-based slide position. */
|
|
50
|
+
readonly page: (index: number, total: number) => string;
|
|
51
|
+
readonly overflowCount: (count: number) => string;
|
|
52
|
+
}
|
|
53
|
+
export interface AnnouncementFormatters {
|
|
54
|
+
readonly notification: (notification: NotificationSnapshot<ReactNode>) => string;
|
|
55
|
+
readonly queued: (count: number) => string;
|
|
56
|
+
readonly occurrences: (notification: NotificationSnapshot<ReactNode>) => string;
|
|
57
|
+
readonly overflow: (count: number) => string;
|
|
58
|
+
readonly operation: (notification: NotificationSnapshot<ReactNode>, phase: 'started' | 'fulfilled' | 'rejected' | 'cancelled' | 'cancel-requested') => string;
|
|
59
|
+
readonly actionError: (notification: NotificationSnapshot<ReactNode>, message: string) => string;
|
|
60
|
+
/** Optional for compatibility with existing complete formatter objects. */
|
|
61
|
+
readonly actionPending?: (notification: NotificationSnapshot<ReactNode>) => string;
|
|
62
|
+
/** Current aggregate after returning from a hidden document; no event replay. */
|
|
63
|
+
readonly resumed?: (count: number) => string;
|
|
64
|
+
}
|
|
65
|
+
export interface ToasterAttention {
|
|
66
|
+
/** Milliseconds from admission before an auto-open; default 600. */
|
|
67
|
+
readonly delay?: number;
|
|
68
|
+
}
|
|
69
|
+
/** A physical spring of DESIGN §7. */
|
|
70
|
+
export interface CloudletSpring {
|
|
71
|
+
readonly stiffness: number;
|
|
72
|
+
readonly damping: number;
|
|
73
|
+
readonly mass: number;
|
|
74
|
+
}
|
|
75
|
+
/** A time-defined spring: settles in about `duration` ms; `bounce` 0 has no overshoot. */
|
|
76
|
+
export interface CloudletTimedSpring {
|
|
77
|
+
readonly duration: number;
|
|
78
|
+
readonly bounce: number;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* The motion constants of DESIGN §7: durations in ms at `timeScale: 1`, offsets and blur in CSS px.
|
|
82
|
+
* Reported by the laboratory's tuning panel; see `ToasterMotion.overrides`.
|
|
83
|
+
*/
|
|
84
|
+
export interface CloudletMotionConstants {
|
|
85
|
+
/** A new pill: opacity, scale from `scale` and translateY from `offset` px at the edge. */
|
|
86
|
+
readonly enter: CloudletTimedSpring & {
|
|
87
|
+
readonly scale: number;
|
|
88
|
+
readonly offset: number;
|
|
89
|
+
readonly fade: number;
|
|
90
|
+
};
|
|
91
|
+
/** The last record or a dismissed top pill leaving. */
|
|
92
|
+
readonly exit: CloudletTimedSpring;
|
|
93
|
+
/** Shape (width, height, radius) opening into the Island. */
|
|
94
|
+
readonly shapeOpen: CloudletSpring;
|
|
95
|
+
/** Shape collapsing into the pill and adjusting to new content. */
|
|
96
|
+
readonly shapeClose: CloudletSpring;
|
|
97
|
+
/** Slide between notifications inside the Island; swipes release with it. */
|
|
98
|
+
readonly slide: CloudletSpring;
|
|
99
|
+
/** Badge presence; `scale` is its hidden scale. */
|
|
100
|
+
readonly badge: CloudletTimedSpring & {
|
|
101
|
+
readonly scale: number;
|
|
102
|
+
};
|
|
103
|
+
/** Tails retracting on open and returning at the end of a collapse. */
|
|
104
|
+
readonly tails: number;
|
|
105
|
+
/** Close button, body and indicator: delay, fade in, fade out on collapse, rise in px. */
|
|
106
|
+
readonly chromeDelay: number;
|
|
107
|
+
readonly chromeIn: number;
|
|
108
|
+
readonly chromeOut: number;
|
|
109
|
+
readonly chromeOffset: number;
|
|
110
|
+
/** Title and icon blur swap: outgoing, incoming, blur radius in px. */
|
|
111
|
+
readonly headerOut: number;
|
|
112
|
+
readonly headerIn: number;
|
|
113
|
+
readonly blur: number;
|
|
114
|
+
/** Body crossfade: outgoing, incoming, rise of the incoming body in px. */
|
|
115
|
+
readonly bodyOut: number;
|
|
116
|
+
readonly bodyIn: number;
|
|
117
|
+
readonly bodyOffset: number;
|
|
118
|
+
/** A body update sooner than this after the previous one changes the text in place (no crossfade). */
|
|
119
|
+
readonly bodyQuiet: number;
|
|
120
|
+
/** Badge number and indicator text blur swap. */
|
|
121
|
+
readonly countSwap: number;
|
|
122
|
+
/** Progress ring value tween. */
|
|
123
|
+
readonly progress: number;
|
|
124
|
+
/** Hover: duration and the extra tail spread per step in px. */
|
|
125
|
+
readonly hover: number;
|
|
126
|
+
readonly hoverLift: number;
|
|
127
|
+
/** Reduced motion: every transition becomes an opacity change of this length. */
|
|
128
|
+
readonly reduced: number;
|
|
129
|
+
}
|
|
130
|
+
/** Partial `CloudletMotionConstants`; nested springs may be partial too. */
|
|
131
|
+
export type CloudletMotionOverrides = {
|
|
132
|
+
readonly [K in keyof CloudletMotionConstants]?: CloudletMotionConstants[K] extends number ? number : Partial<CloudletMotionConstants[K]>;
|
|
133
|
+
};
|
|
134
|
+
export interface ToasterMotion {
|
|
135
|
+
/**
|
|
136
|
+
* Debugging and laboratory aid: slows every transition (0.5 = twice as slow).
|
|
137
|
+
* Default 1; a non-finite or nonpositive value falls back to 1. Not recommended in production.
|
|
138
|
+
*/
|
|
139
|
+
readonly timeScale?: number;
|
|
140
|
+
/**
|
|
141
|
+
* Debugging and laboratory channel (task 16): replaces DESIGN §7 constants live, for
|
|
142
|
+
* transitions started after the change. A field that is not a finite number in range
|
|
143
|
+
* (stiffness and mass > 0, the rest ≥ 0) keeps its default. Not a styling API: the
|
|
144
|
+
* values may change between releases; do not ship overrides to production.
|
|
145
|
+
*/
|
|
146
|
+
readonly overrides?: CloudletMotionOverrides;
|
|
147
|
+
}
|
|
148
|
+
/** Styling hooks of the renderer (DESIGN §8); see `ToasterProps.classNames`. */
|
|
149
|
+
export type CloudletPart = 'host' | 'stack' | 'pill' | 'tail' | 'badge' | 'island' | 'header' | 'icon' | 'title' | 'close' | 'body' | 'description' | 'actions' | 'action' | 'indicator' | 'overflow';
|
|
150
|
+
export interface ToasterProps {
|
|
151
|
+
readonly position?: 'auto' | 'top-center' | 'bottom-center';
|
|
152
|
+
readonly theme?: 'system' | 'light' | 'dark';
|
|
153
|
+
readonly dir?: 'ltr' | 'rtl';
|
|
154
|
+
/** Read after mount; a connected HTML Element in the mounting root's document. Fixed until remount. */
|
|
155
|
+
readonly container?: Element | (() => Element | null) | null;
|
|
156
|
+
readonly offsets?: ToasterOffsets;
|
|
157
|
+
readonly nonce?: string;
|
|
158
|
+
readonly labels?: Partial<CloudletLabels>;
|
|
159
|
+
readonly announcements?: Partial<AnnouncementFormatters>;
|
|
160
|
+
/** Read on attach; changing it requires remount. */
|
|
161
|
+
readonly attention?: ToasterAttention;
|
|
162
|
+
/** Overrides the controller's `autoDismiss` while defined; changes apply without remount. */
|
|
163
|
+
readonly autoDismiss?: boolean;
|
|
164
|
+
/** Read on every render. */
|
|
165
|
+
readonly motion?: ToasterMotion;
|
|
166
|
+
/** Extra classes per part, added to the own `cloudlet-*` classes (never replacing them). Read on every render. */
|
|
167
|
+
readonly classNames?: Partial<Record<CloudletPart, string>>;
|
|
168
|
+
}
|
|
169
|
+
/** Public component and hook signatures. */
|
|
170
|
+
export type CloudletProviderComponent = (props: CloudletProviderProps) => ReactElement | null;
|
|
171
|
+
export type UseCloudlet = () => ReactCloudletController;
|
|
172
|
+
export type UseOptionalCloudlet = () => ReactCloudletController | null;
|
|
173
|
+
export type ToasterComponent = (props: ToasterProps) => ReactElement | null;
|
|
174
|
+
export type { ControllerSnapshot, FocusTarget, NotificationHandle };
|
|
175
|
+
export { CloudletProvider, useCloudlet, useOptionalCloudlet, Toaster } from './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et-host{--cloudlet-pill-height:44px;--cloudlet-pill-radius:9999px;--cloudlet-pill-max-width:22rem;--cloudlet-island-radius:24px;--cloudlet-island-max-width:26rem;--cloudlet-tail-offset:4px;--cloudlet-tail-scale:.9;--cloudlet-control-min-size:44px;--cloudlet-viewport-gutter:16px;--cloudlet-font-family:system-ui, sans-serif;--cloudlet-font-size:.875rem;--cloudlet-background:#fff;--cloudlet-foreground:#111113;--cloudlet-muted:#6e6e76;--cloudlet-border:color-mix(in oklab, var(--cloudlet-foreground) 10%, transparent);--cloudlet-action-background:color-mix(in oklab, var(--cloudlet-foreground) 8%, transparent);--cloudlet-shadow:0 10px 30px -12px #00000040, 0 1px 2px #00000014;--cloudlet-tail-background:var(--cloudlet-background);--cloudlet-tail-border:var(--cloudlet-border);--cloudlet-focus:#245cdb;--cloudlet-success:oklch(72.3% .219 142.136);--cloudlet-error:oklch(63.7% .237 25.331);--cloudlet-info:oklch(68.5% .169 237.323);--cloudlet-warning:oklch(79.5% .184 86.047);--cloudlet-loading:oklch(55.6% 0 0);--cloudlet-badge:#ff3b30;--cloudlet-badge-foreground:#fff;--cloudlet-z-index:1000;--cloudlet-safe-top:env(safe-area-inset-top,0px);--cloudlet-safe-right:env(safe-area-inset-right,0px);--cloudlet-safe-bottom:env(safe-area-inset-bottom,0px);--cloudlet-safe-left:env(safe-area-inset-left,0px);--cloudlet-top:calc(var(--cloudlet-safe-top) + var(--cloudlet-gutter-top,var(--cloudlet-viewport-gutter)) + var(--cloudlet-obstruction-top,0px));--cloudlet-bottom:calc(var(--cloudlet-safe-bottom) + var(--cloudlet-gutter-bottom,var(--cloudlet-viewport-gutter)) + var(--cloudlet-obstruction-bottom,0px));--cloudlet-left:calc(var(--cloudlet-safe-left) + var(--cloudlet-gutter-left,var(--cloudlet-viewport-gutter)) + var(--cloudlet-obstruction-left,0px));--cloudlet-right:calc(var(--cloudlet-safe-right) + var(--cloudlet-gutter-right,var(--cloudlet-viewport-gutter)) + var(--cloudlet-obstruction-right,0px));--cloudlet-host-height:max(0px, calc(var(--cloudlet-viewport-height,100dvh) - var(--cloudlet-top) - var(--cloudlet-bottom)));--cloudlet-available-height:max(0px, calc(var(--cloudlet-host-height) - var(--cloudlet-reserved-height,0px)));z-index:var(--cloudlet-z-index);left:calc(var(--cloudlet-viewport-left,0px) + var(--cloudlet-left));right:calc(var(--cloudlet-viewport-right,0px) + var(--cloudlet-right));bottom:calc(var(--cloudlet-viewport-bottom,0px) + var(--cloudlet-bottom));max-width:var(--cloudlet-island-max-width);max-height:var(--cloudlet-host-height);color:var(--cloudlet-foreground);font:400 var(--cloudlet-font-size)/1.43 var(--cloudlet-font-family);text-align:start;--lightningcss-light:initial;--lightningcss-dark: ;color-scheme:light;pointer-events:none;isolation:isolate;--cloudlet-status:var(--cloudlet-loading);flex-direction:column;margin-inline:auto;display:flex;position:fixed}.cloudlet-host,.cloudlet-host *,.cloudlet-host :before,.cloudlet-host :after{box-sizing:border-box}.cloudlet-host :where(h2,p,ol,li){margin:0;padding:0}.cloudlet-host :where(button,a){font:inherit;color:inherit;line-height:inherit;letter-spacing:inherit;text-transform:none;min-width:var(--cloudlet-control-min-size);min-height:var(--cloudlet-control-min-size);touch-action:manipulation}.cloudlet-host button{appearance:none;cursor:pointer;background:0 0;border:0;border-radius:24px;justify-content:center;align-items:center;margin:0;padding:10px;display:inline-flex}.cloudlet-host button[aria-disabled=true]{color:var(--cloudlet-muted);cursor:progress}.cloudlet-host a{border-radius:24px;align-items:center;padding:10px 16px;text-decoration:underline;display:inline-flex}.cloudlet-host :focus-visible{outline:2px solid var(--cloudlet-focus);outline-offset:2px}.cloudlet-host:focus-visible{outline:2px solid var(--cloudlet-focus);outline-offset:-2px}.cloudlet-host [hidden]{display:none!important}.cloudlet-host [data-kind=success]{--cloudlet-status:var(--cloudlet-success)}.cloudlet-host [data-kind=error]{--cloudlet-status:var(--cloudlet-error)}.cloudlet-host [data-kind=info]{--cloudlet-status:var(--cloudlet-info)}.cloudlet-host [data-kind=warning]{--cloudlet-status:var(--cloudlet-warning)}.cloudlet-host [data-kind=loading]{--cloudlet-status:var(--cloudlet-loading)}.cloudlet-host .cloudlet-stack{flex:none;align-self:center;width:fit-content;max-width:100%;position:relative}.cloudlet-host[data-state=island] .cloudlet-stack{width:100%}.cloudlet-host .cloudlet-shell{transform-origin:50% 0;z-index:1;position:relative}.cloudlet-host[data-edge=bottom] .cloudlet-shell{transform-origin:50% 100%}.cloudlet-host .cloudlet-bg{pointer-events:none;box-shadow:var(--cloudlet-shadow);position:absolute;top:0;left:50%;overflow:visible;transform:translate(-50%)}.cloudlet-host .cloudlet-bg path{fill:var(--cloudlet-background);stroke:var(--cloudlet-border);stroke-width:1px}.cloudlet-host :is(.cloudlet-tail,.cloudlet-exit){pointer-events:none;position:absolute;top:0;left:50%}.cloudlet-host .cloudlet-tail{z-index:0;border-radius:var(--cloudlet-pill-radius);background:var(--cloudlet-tail-background);border:1px solid var(--cloudlet-tail-border);box-shadow:var(--cloudlet-shadow);transform-origin:50% 100%;opacity:0}.cloudlet-host .cloudlet-tail[data-cloudlet-tail="2"]{z-index:-1;background:color-mix(in oklab, var(--cloudlet-tail-background) 60%, var(--cloudlet-background))}.cloudlet-host .cloudlet-exit{z-index:2;transform-origin:50% 0}.cloudlet-host[data-edge=bottom] :is(.cloudlet-bg,.cloudlet-tail,.cloudlet-exit,.cloudlet-badge){top:auto;bottom:0}.cloudlet-host[data-edge=bottom] .cloudlet-tail{transform-origin:50% 0}.cloudlet-host[data-edge=bottom] .cloudlet-exit{transform-origin:50% 100%}.cloudlet-host .cloudlet-exit:empty{display:none}.cloudlet-host .cloudlet-clip{pointer-events:auto;color:var(--cloudlet-foreground);overflow-wrap:anywhere;width:fit-content;min-width:0;max-width:min(100%, var(--cloudlet-pill-max-width));min-height:var(--cloudlet-pill-height);border-radius:var(--cloudlet-pill-radius);flex-direction:column;display:flex;position:relative}.cloudlet-host .cloudlet-shell[data-state=island]>.cloudlet-clip{width:100%;max-width:100%;max-height:var(--cloudlet-available-height);border-radius:var(--cloudlet-island-radius)}.cloudlet-host :is(.cloudlet-slide-out,.cloudlet-chrome-out){pointer-events:none;position:absolute;top:0;left:0}.cloudlet-host :is(.cloudlet-slide-out,.cloudlet-chrome-out):empty{display:none}.cloudlet-host .cloudlet-chrome-out .cloudlet-clip{width:100%;max-width:none}.cloudlet-host .cloudlet-ghost{visibility:hidden}.cloudlet-host .cloudlet-slide{flex-direction:column;flex:0 auto;min-height:0;display:flex;position:relative}.cloudlet-host .cloudlet-header{flex:none;min-width:0;display:flex;position:relative}.cloudlet-host .cloudlet-heading{min-width:0;min-height:var(--cloudlet-pill-height);flex:1;align-items:center;gap:10px;padding-block:6px;padding-inline:10px 16px;display:flex}.cloudlet-host .cloudlet-shell[data-state=island] .cloudlet-heading{padding-block:10px 6px;padding-inline:14px 52px}.cloudlet-host .cloudlet-heading-out{pointer-events:none;display:flex;position:absolute;inset:0}.cloudlet-host .cloudlet-heading-out:empty{display:none}.cloudlet-host .cloudlet-title{font:inherit;text-transform:none;text-overflow:ellipsis;white-space:nowrap;flex:1;min-width:0;font-weight:500;overflow:hidden}.cloudlet-host .cloudlet-shell[data-state=island] .cloudlet-title{white-space:normal;-webkit-line-clamp:2;line-clamp:2;-webkit-box-orient:vertical;display:-webkit-box}.cloudlet-host .cloudlet-title:focus{outline:none}.cloudlet-host .cloudlet-title:focus-visible{outline:2px solid var(--cloudlet-focus);outline-offset:2px;border-radius:4px}.cloudlet-host .cloudlet-pill{z-index:1;pointer-events:auto;border-radius:var(--cloudlet-pill-radius);width:100%;height:100%;padding:0;position:absolute;inset:0}.cloudlet-host .cloudlet-pill,.cloudlet-host .cloudlet-shell[data-state=island]>.cloudlet-clip,.cloudlet-host .cloudlet-shell[data-state=island] .cloudlet-body{touch-action:pan-y}.cloudlet-host .cloudlet-shell[data-state=island]>.cloudlet-clip>.cloudlet-slide>.cloudlet-header{touch-action:none}.cloudlet-host[data-dragging]{-webkit-user-select:none;user-select:none}.cloudlet-host .cloudlet-peek{pointer-events:none;position:absolute;top:0;left:0}.cloudlet-host .cloudlet-badge{z-index:2;background:var(--cloudlet-badge);min-width:20px;height:20px;color:var(--cloudlet-badge-foreground);box-shadow:0 0 0 2px var(--cloudlet-background);font:600 .6875rem/20px var(--cloudlet-font-family);font-variant-numeric:tabular-nums;text-align:center;pointer-events:none;opacity:0;border-radius:9999px;padding-inline:6px;display:grid;position:absolute;top:0;left:50%}.cloudlet-host .cloudlet-badge>*{grid-area:1/1}.cloudlet-host .cloudlet-icon{width:24px;height:24px;color:var(--cloudlet-status);background:color-mix(in oklab, var(--cloudlet-status) 18%, transparent);border-radius:50%;flex:none;place-items:center;display:grid;position:relative}.cloudlet-host .cloudlet-glyph{place-items:center;width:16px;height:16px;display:grid;overflow:hidden}.cloudlet-host .cloudlet-glyph>.cloudlet-slot{place-items:center;width:100%;height:100%;display:grid}.cloudlet-host .cloudlet-glyph :is(svg,img){max-width:100%;max-height:100%;display:block}.cloudlet-host :is(svg.cloudlet-glyph,button>svg){fill:none;stroke:currentColor;stroke-width:1.75px;stroke-linecap:round;stroke-linejoin:round;display:block}.cloudlet-host .cloudlet-ring{fill:none;stroke-width:2px;width:32px;height:32px;position:absolute;inset:-4px;overflow:visible}.cloudlet-host .cloudlet-ring-track{stroke:color-mix(in oklab, var(--cloudlet-status) 18%, transparent)}.cloudlet-host .cloudlet-progress-fill{stroke:color-mix(in oklab, var(--cloudlet-status) 75%, var(--cloudlet-foreground));stroke-linecap:round}.cloudlet-host .cloudlet-close{top:8px;z-index:1;width:32px;min-width:0;height:32px;min-height:0;color:var(--cloudlet-muted);background:var(--cloudlet-action-background);border-radius:50%;padding:0;position:absolute;inset-inline-end:8px}.cloudlet-host .cloudlet-close>svg{width:16px;height:16px}.cloudlet-host :is(.cloudlet-close,.cloudlet-action,.cloudlet-overflow button):before{content:"";inset-block:calc((var(--cloudlet-control-min-size) - 32px) / -2);position:absolute;inset-inline:0}.cloudlet-host button.cloudlet-close:before{inset-inline:calc((var(--cloudlet-control-min-size) - 32px) / -2);border-radius:50%}.cloudlet-host .cloudlet-body{overscroll-behavior:contain;min-height:0;max-height:min(calc(var(--cloudlet-available-height) * .6), 24rem);flex-direction:column;padding-block:0 10px;padding-inline:48px 16px;display:flex;position:relative;overflow:auto}.cloudlet-host .cloudlet-body:not(:has(>:not(.cloudlet-actions:empty))){padding-bottom:4px}.cloudlet-host .cloudlet-body-out{pointer-events:none;position:absolute;left:0;right:0}.cloudlet-host .cloudlet-body-out:empty{display:none}.cloudlet-host .cloudlet-description{color:var(--cloudlet-muted);padding-block:0 4px;font-size:.8125rem;line-height:1.45}.cloudlet-host .cloudlet-actions{flex-wrap:wrap;flex:none;gap:12px 8px;display:flex}.cloudlet-host .cloudlet-actions:empty{display:none}.cloudlet-host .cloudlet-actions:not(:empty){margin-block:8px 2px}.cloudlet-host :is(.cloudlet-action,.cloudlet-overflow button){overflow-wrap:anywhere;min-width:0;max-width:100%;min-height:32px;color:var(--cloudlet-foreground);background:var(--cloudlet-action-background);border-radius:9999px;padding:6px 14px;font-size:.8125rem;font-weight:500;line-height:1.5;text-decoration:none;position:relative}.cloudlet-host .cloudlet-action.cloudlet-primary{color:color-mix(in oklab, var(--cloudlet-status) 55%, var(--cloudlet-foreground));background:color-mix(in oklab, var(--cloudlet-status) 12%, transparent)}.cloudlet-host :is(.cloudlet-action,.cloudlet-overflow button)[aria-disabled=true]{color:var(--cloudlet-muted)}@media (hover:hover){.cloudlet-host :is(.cloudlet-close,.cloudlet-action,.cloudlet-overflow button):hover{background:color-mix(in oklab, var(--cloudlet-foreground) 13%, transparent)}.cloudlet-host .cloudlet-close:hover{color:var(--cloudlet-foreground)}.cloudlet-host .cloudlet-action.cloudlet-primary:hover{background:color-mix(in oklab, var(--cloudlet-status) 20%, transparent)}}.cloudlet-host .cloudlet-action-error{color:var(--cloudlet-muted);padding-block:4px;font-size:.8125rem}.cloudlet-host .cloudlet-indicator{color:var(--cloudlet-muted);flex-wrap:wrap;flex:none;justify-content:center;align-items:center;column-gap:8px;padding-bottom:6px;font-size:.75rem;display:flex}.cloudlet-host .cloudlet-indicator .cloudlet-dot-button{min-width:24px;min-height:24px;padding:8px}.cloudlet-host .cloudlet-dot{background:color-mix(in oklab, var(--cloudlet-foreground) 25%, transparent);border-radius:50%;width:6px;height:6px;display:block}.cloudlet-host .cloudlet-indicator [aria-current=true] .cloudlet-dot{background:var(--cloudlet-foreground)}.cloudlet-host .cloudlet-page{font-variant-numeric:tabular-nums;padding:8px;display:grid}.cloudlet-host .cloudlet-page>*{grid-area:1/1}.cloudlet-host .cloudlet-overflow{flex-wrap:wrap;justify-content:center;align-items:center;gap:4px 8px;min-width:0;display:flex}.cloudlet-host .cloudlet-overflow button{font-size:.75rem}.cloudlet-host .cloudlet-live{clip-path:inset(50%);white-space:nowrap;border:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}.cloudlet-announcer{clip-path:inset(50%);white-space:nowrap;pointer-events:none;border:0;width:1px;height:1px;margin:-1px;padding:0;position:fixed;top:0;left:0;overflow:hidden}.cloudlet-host[data-position=top-center]{top:calc(var(--cloudlet-viewport-top,0px) + var(--cloudlet-top));bottom:auto}@media (width>=48rem){.cloudlet-host[data-position=auto]{top:calc(var(--cloudlet-viewport-top,0px) + var(--cloudlet-top));bottom:auto}}.cloudlet-host[data-theme=dark]{--cloudlet-background:#1c1c1e;--cloudlet-foreground:#f5f5f7;--cloudlet-muted:#a1a1aa;--cloudlet-focus:#93b4ff;--cloudlet-shadow:0 12px 32px -12px #0009;--lightningcss-light: ;--lightningcss-dark:initial;color-scheme:dark;--cloudlet-tail-background:color-mix(in oklab, var(--cloudlet-foreground) 14%, var(--cloudlet-background));--cloudlet-tail-border:color-mix(in oklab, var(--cloudlet-foreground) 18%, transparent)}@media (prefers-color-scheme:dark){.cloudlet-host[data-theme=system]{--cloudlet-background:#1c1c1e;--cloudlet-foreground:#f5f5f7;--cloudlet-muted:#a1a1aa;--cloudlet-focus:#93b4ff;--cloudlet-shadow:0 12px 32px -12px #0009;--lightningcss-light: ;--lightningcss-dark:initial;color-scheme:dark;--cloudlet-tail-background:color-mix(in oklab, var(--cloudlet-foreground) 14%, var(--cloudlet-background));--cloudlet-tail-border:color-mix(in oklab, var(--cloudlet-foreground) 18%, transparent)}}@keyframes cloudlet-spin{to{transform:rotate(360deg)}}@media (prefers-reduced-motion:no-preference){.cloudlet-host .cloudlet-spinner{animation:.8s linear infinite cloudlet-spin}.cloudlet-host .cloudlet-ring[data-progress=indeterminate]{animation:1s linear infinite cloudlet-spin}.cloudlet-host[data-reduced-motion=true] :is(.cloudlet-spinner,.cloudlet-ring){animation:none}}@media (forced-colors:active){.cloudlet-host[data-theme]{--cloudlet-background:Canvas;--cloudlet-foreground:CanvasText;--cloudlet-muted:CanvasText;--cloudlet-border:CanvasText;--cloudlet-focus:Highlight;--cloudlet-action-background:Canvas;--cloudlet-status:CanvasText;--cloudlet-success:CanvasText;--cloudlet-error:CanvasText;--cloudlet-info:CanvasText;--cloudlet-warning:CanvasText;--cloudlet-loading:CanvasText;--cloudlet-badge:Highlight;--cloudlet-badge-foreground:HighlightText}.cloudlet-host :is(.cloudlet-bg,.cloudlet-icon,.cloudlet-badge,.cloudlet-dot){forced-color-adjust:none}.cloudlet-host .cloudlet-icon{outline-offset:-1px;background:canvas;outline:1px solid canvastext}.cloudlet-host .cloudlet-ring-track{stroke:graytext}.cloudlet-host .cloudlet-dot{background:canvas;outline:1px solid canvastext}.cloudlet-host .cloudlet-indicator [aria-current=true] .cloudlet-dot{background:canvastext}.cloudlet-host :is(.cloudlet-close,.cloudlet-action,.cloudlet-overflow button){border:1px solid buttontext}}
|
package/package.json
CHANGED
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudlet/toast",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.0.0-rc.3",
|
|
4
|
+
"description": "Cloudlet notifications and async operations with an SSR-safe React renderer",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"homepage": "https://cloudlet.dev/toaster",
|
|
7
|
+
"keywords": ["react", "notifications", "toast", "snackbar", "accessibility", "async", "operations", "ssr"],
|
|
8
|
+
"publishConfig": { "access": "public", "tag": "next" },
|
|
9
|
+
"type": "module",
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": { "types": "./dist/index.d.ts", "import": "./dist/index.js", "default": "./dist/index.js" },
|
|
13
|
+
"./styles.css": "./dist/styles.css"
|
|
14
|
+
},
|
|
15
|
+
"files": ["dist", "src/**/*.ts", "src/**/*.tsx", "LICENSE", "THIRD_PARTY_NOTICES.md", "README.md", "CHANGELOG.md"],
|
|
16
|
+
"sideEffects": ["**/*.css"],
|
|
17
|
+
"peerDependencies": { "react": "^18.2.0 || ^19.0.0", "react-dom": "^18.2.0 || ^19.0.0" },
|
|
18
|
+
"scripts": { "build": "vite build && tsc -p tsconfig.build.json" }
|
|
19
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { Diagnostic, SemanticEvent } from './events.js';
|
|
2
|
+
import type { HandleRejection, InputIssue, NotificationHandle, Unsubscribe } from './identity.js';
|
|
3
|
+
import type { AdmissionResult, NotificationPatch, NotificationSpec, OverflowSnapshot } from './notifications.js';
|
|
4
|
+
import type { CancellationSignal, OperationHandle, OperationSource, TrackOptions } from './operations.js';
|
|
5
|
+
import type { ControllerSnapshot } from './snapshots.js';
|
|
6
|
+
|
|
7
|
+
export interface FallbackMessages {
|
|
8
|
+
readonly operationSuccess: string;
|
|
9
|
+
readonly operationError: string;
|
|
10
|
+
readonly operationCancelled: string;
|
|
11
|
+
readonly cancellationRequested: string;
|
|
12
|
+
readonly actionError: string;
|
|
13
|
+
readonly renderError: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface ControllerOptions {
|
|
17
|
+
readonly autoDismiss?: boolean;
|
|
18
|
+
/** Auto-open delay after admission, in milliseconds; default 600. A host may override it. */
|
|
19
|
+
readonly attentionDelay?: number;
|
|
20
|
+
readonly messages?: Partial<FallbackMessages>;
|
|
21
|
+
readonly onOverflow?: (overflow: OverflowSnapshot) => void;
|
|
22
|
+
readonly onDiagnostic?: (diagnostic: Diagnostic) => void;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export type MutationRejection = HandleRejection | 'disposed' | 'invalid-input' | 'action-pending' | 'operation-owned';
|
|
26
|
+
export type MutationResult =
|
|
27
|
+
| { readonly status: 'applied' }
|
|
28
|
+
| { readonly status: 'unchanged' }
|
|
29
|
+
| { readonly status: 'rejected'; readonly reason: MutationRejection; readonly issues?: readonly InputIssue[] };
|
|
30
|
+
|
|
31
|
+
export type FocusTarget =
|
|
32
|
+
| { readonly kind: 'anchor' }
|
|
33
|
+
| { readonly kind: 'notification'; readonly handle: NotificationHandle; readonly control?: 'action' | 'close' }
|
|
34
|
+
| { readonly kind: 'overflow' };
|
|
35
|
+
|
|
36
|
+
export type FocusResult =
|
|
37
|
+
| { readonly status: 'requested' }
|
|
38
|
+
| { readonly status: 'rejected'; readonly reason: HandleRejection | 'disposed' | 'no-host' | 'not-visible' | 'unavailable' };
|
|
39
|
+
|
|
40
|
+
export type ClearResult =
|
|
41
|
+
| { readonly status: 'cleared'; readonly count: number }
|
|
42
|
+
| { readonly status: 'rejected'; readonly reason: 'disposed' };
|
|
43
|
+
|
|
44
|
+
export interface CloudletController<Slot = never, Signal extends CancellationSignal = CancellationSignal> {
|
|
45
|
+
readonly show: (spec: NotificationSpec<Slot>) => AdmissionResult;
|
|
46
|
+
readonly update: (handle: NotificationHandle, patch: NotificationPatch<Slot>) => MutationResult;
|
|
47
|
+
readonly getHandle: (id: string) => NotificationHandle | undefined;
|
|
48
|
+
readonly track: <T>(source: OperationSource<T, Signal>, options: TrackOptions<T, Slot, Signal>) => OperationHandle<T>;
|
|
49
|
+
readonly dismiss: (handle: NotificationHandle) => MutationResult;
|
|
50
|
+
readonly clear: () => ClearResult;
|
|
51
|
+
readonly requestFocus: (target?: FocusTarget) => FocusResult;
|
|
52
|
+
readonly acknowledgeOverflow: () => MutationResult;
|
|
53
|
+
readonly getSnapshot: () => ControllerSnapshot<Slot>;
|
|
54
|
+
readonly getServerSnapshot: () => ControllerSnapshot<Slot>;
|
|
55
|
+
readonly subscribe: (listener: () => void) => Unsubscribe;
|
|
56
|
+
readonly onEvent: (listener: (event: SemanticEvent) => void) => Unsubscribe;
|
|
57
|
+
readonly dispose: () => void;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** Notification-only view of a controller, useful to consumers that do not track operations. */
|
|
61
|
+
export type NotificationController<Slot = never> = Omit<CloudletController<Slot>, 'track'>;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { ActionAttemptToken, ControllerIdentity, NotificationHandle, OperationAttemptToken } from './identity.js';
|
|
2
|
+
import type { CloseReason } from './notifications.js';
|
|
3
|
+
import type { OperationStatus } from './operations.js';
|
|
4
|
+
|
|
5
|
+
export type DiagnosticCode =
|
|
6
|
+
| 'invalid-input'
|
|
7
|
+
| 'second-host'
|
|
8
|
+
| 'stale-host'
|
|
9
|
+
| 'mapper-error'
|
|
10
|
+
| 'callback-error'
|
|
11
|
+
| 'listener-error'
|
|
12
|
+
| 'cancellation-error'
|
|
13
|
+
| 'slot-error'
|
|
14
|
+
| 'formatter-error'
|
|
15
|
+
| 'invalid-container';
|
|
16
|
+
|
|
17
|
+
export interface Diagnostic {
|
|
18
|
+
readonly code: DiagnosticCode;
|
|
19
|
+
readonly source: string;
|
|
20
|
+
readonly message: string;
|
|
21
|
+
readonly handle?: NotificationHandle;
|
|
22
|
+
readonly error?: unknown;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface EventBase {
|
|
26
|
+
readonly controller: ControllerIdentity;
|
|
27
|
+
readonly sequence: number;
|
|
28
|
+
/** Monotonic milliseconds, not wall-clock time. */
|
|
29
|
+
readonly at: number;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export type SemanticEvent = EventBase & (
|
|
33
|
+
| { readonly type: 'admitted'; readonly handle: NotificationHandle }
|
|
34
|
+
| { readonly type: 'deduplicated'; readonly handle: NotificationHandle; readonly occurrences: number }
|
|
35
|
+
| { readonly type: 'updated'; readonly handle: NotificationHandle }
|
|
36
|
+
| { readonly type: 'closed'; readonly handle: NotificationHandle; readonly reason: CloseReason }
|
|
37
|
+
| { readonly type: 'presented'; readonly handle: NotificationHandle; readonly firstPresentation: boolean }
|
|
38
|
+
| { readonly type: 'operation-started'; readonly handle: NotificationHandle | null; readonly token: OperationAttemptToken; readonly attempt: number }
|
|
39
|
+
| { readonly type: 'operation-settled'; readonly handle: NotificationHandle | null; readonly token: OperationAttemptToken; readonly status: Exclude<OperationStatus, 'pending'>; readonly uiApplied: boolean }
|
|
40
|
+
| { readonly type: 'cancellation-requested'; readonly handle: NotificationHandle | null; readonly token: OperationAttemptToken }
|
|
41
|
+
| { readonly type: 'action-started'; readonly handle: NotificationHandle; readonly token: ActionAttemptToken }
|
|
42
|
+
| { readonly type: 'action-failed'; readonly handle: NotificationHandle; readonly token: ActionAttemptToken; readonly message: string }
|
|
43
|
+
| { readonly type: 'overflow'; readonly count: number }
|
|
44
|
+
| { readonly type: 'overflow-acknowledged'; readonly count: number }
|
|
45
|
+
| { readonly type: 'diagnostic'; readonly diagnostic: Diagnostic }
|
|
46
|
+
| { readonly type: 'disposed' }
|
|
47
|
+
);
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/** Opaque identities are minted by a controller, never reconstructed from IDs. */
|
|
2
|
+
declare const controllerBrand: unique symbol;
|
|
3
|
+
declare const generationBrand: unique symbol;
|
|
4
|
+
declare const notificationBrand: unique symbol;
|
|
5
|
+
declare const attemptBrand: unique symbol;
|
|
6
|
+
declare const actionBrand: unique symbol;
|
|
7
|
+
|
|
8
|
+
export type ControllerIdentity = string & { readonly [controllerBrand]: never };
|
|
9
|
+
export type Generation = string & { readonly [generationBrand]: never };
|
|
10
|
+
export type OperationAttemptToken = string & { readonly [attemptBrand]: never };
|
|
11
|
+
export type ActionAttemptToken = string & { readonly [actionBrand]: never };
|
|
12
|
+
|
|
13
|
+
export interface NotificationHandle {
|
|
14
|
+
readonly id: string;
|
|
15
|
+
readonly controller: ControllerIdentity;
|
|
16
|
+
readonly generation: Generation;
|
|
17
|
+
readonly [notificationBrand]: never;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export type Unsubscribe = () => void;
|
|
21
|
+
|
|
22
|
+
export type HandleRejection = 'invalid-handle' | 'foreign-controller' | 'stale-handle';
|
|
23
|
+
|
|
24
|
+
export interface InputIssue {
|
|
25
|
+
readonly path: string;
|
|
26
|
+
readonly message: string;
|
|
27
|
+
}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/** Package-private contracts; never exported from the package entrypoint. */
|
|
2
|
+
import type { CloudletController, ControllerOptions, FocusTarget, MutationResult } from './controller.js';
|
|
3
|
+
import type { Diagnostic, SemanticEvent } from './events.js';
|
|
4
|
+
import type { ActionAttemptToken, HandleRejection, NotificationHandle, OperationAttemptToken, Unsubscribe } from './identity.js';
|
|
5
|
+
import type { CloseReason } from './notifications.js';
|
|
6
|
+
import type { CancellationSignal } from './operations.js';
|
|
7
|
+
import type { ControllerSnapshot, IslandReason } from './snapshots.js';
|
|
8
|
+
|
|
9
|
+
declare const leaseBrand: unique symbol;
|
|
10
|
+
declare const presentationBrand: unique symbol;
|
|
11
|
+
declare const focusBrand: unique symbol;
|
|
12
|
+
|
|
13
|
+
export type HostLease = string & { readonly [leaseBrand]: never };
|
|
14
|
+
export type PresentationToken = string & { readonly [presentationBrand]: never };
|
|
15
|
+
export type FocusRequestToken = string & { readonly [focusBrand]: never };
|
|
16
|
+
|
|
17
|
+
export interface MonotonicClock {
|
|
18
|
+
readonly now: () => number;
|
|
19
|
+
/** Absolute deadline; never invokes callback synchronously. Cancellation is idempotent. */
|
|
20
|
+
readonly schedule: (deadline: number, callback: () => void) => Unsubscribe;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface CancellationSource<Signal extends CancellationSignal = CancellationSignal> {
|
|
24
|
+
readonly signal: Signal;
|
|
25
|
+
readonly abort: (reason?: unknown) => void;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface ControllerDependencies<Signal extends CancellationSignal = CancellationSignal> {
|
|
29
|
+
readonly clock: MonotonicClock;
|
|
30
|
+
readonly createCancellation: () => CancellationSource<Signal>;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export type CreateCloudletCore = <Slot = never, Signal extends CancellationSignal = CancellationSignal>(options: ControllerOptions | undefined, dependencies: ControllerDependencies<Signal>) => CloudletController<Slot, Signal>;
|
|
34
|
+
|
|
35
|
+
/** Stable package-private lookup for controllers minted by this package instance. */
|
|
36
|
+
export type GetRendererBridge = <Slot, Signal extends CancellationSignal>(controller: CloudletController<Slot, Signal>) => RendererBridge<Slot>;
|
|
37
|
+
|
|
38
|
+
/** Per-attachment settings; omitted fields fall back to ControllerOptions. */
|
|
39
|
+
export interface HostOptions {
|
|
40
|
+
/** Finite nonnegative milliseconds; overrides ControllerOptions.attentionDelay while attached. */
|
|
41
|
+
readonly attentionDelay?: number;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** The single presented record (`location: 'current'`) and its presentation token. */
|
|
45
|
+
export interface RendererPresentation {
|
|
46
|
+
readonly handle: NotificationHandle;
|
|
47
|
+
/** Null without an active host. */
|
|
48
|
+
readonly token: PresentationToken | null;
|
|
49
|
+
readonly readable: boolean;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export interface FocusRequest {
|
|
53
|
+
readonly token: FocusRequestToken;
|
|
54
|
+
readonly target: FocusTarget;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export type OperationAnnouncementPhase = 'started' | 'fulfilled' | 'rejected' | 'cancelled' | 'cancel-requested';
|
|
58
|
+
|
|
59
|
+
export interface NotificationAnnouncementLedger {
|
|
60
|
+
readonly handle: NotificationHandle;
|
|
61
|
+
readonly queued: boolean;
|
|
62
|
+
readonly firstPresentation: boolean;
|
|
63
|
+
readonly occurrences: number;
|
|
64
|
+
readonly action: { readonly token: ActionAttemptToken; readonly status: 'pending' | 'failed' } | null;
|
|
65
|
+
readonly operation: {
|
|
66
|
+
readonly token: OperationAttemptToken;
|
|
67
|
+
readonly phases: readonly OperationAnnouncementPhase[];
|
|
68
|
+
} | null;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export interface AnnouncementLedgerSnapshot {
|
|
72
|
+
readonly notifications: readonly NotificationAnnouncementLedger[];
|
|
73
|
+
readonly overflowCount: number;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export type AnnouncementAcknowledgement =
|
|
77
|
+
| { readonly kind: 'queued' | 'first-presentation'; readonly handle: NotificationHandle }
|
|
78
|
+
| { readonly kind: 'occurrences'; readonly handle: NotificationHandle; readonly count: number }
|
|
79
|
+
| { readonly kind: 'action'; readonly handle: NotificationHandle; readonly token: ActionAttemptToken; readonly status: 'pending' | 'failed' }
|
|
80
|
+
| { readonly kind: 'operation'; readonly handle: NotificationHandle; readonly token: OperationAttemptToken; readonly phase: OperationAnnouncementPhase }
|
|
81
|
+
| { readonly kind: 'overflow'; readonly count: number };
|
|
82
|
+
|
|
83
|
+
export interface RendererSnapshot<Slot = never> extends ControllerSnapshot<Slot> {
|
|
84
|
+
readonly presentation: RendererPresentation | null;
|
|
85
|
+
readonly focusRequest: FocusRequest | null;
|
|
86
|
+
readonly announcements: AnnouncementLedgerSnapshot;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export type AttachResult =
|
|
90
|
+
| { readonly status: 'attached'; readonly lease: HostLease }
|
|
91
|
+
| { readonly status: 'rejected'; readonly reason: 'disposed' | 'host-exists' | 'invalid-input' };
|
|
92
|
+
|
|
93
|
+
export type BridgeRejection = HandleRejection | 'disposed' | 'stale-lease' | 'not-current' | 'stale-presentation' | 'stale-operation-token' | 'stale-focus-request' | 'invalid-input' | 'empty' | 'island-closed';
|
|
94
|
+
export type BridgeResult =
|
|
95
|
+
| { readonly status: 'applied' }
|
|
96
|
+
| { readonly status: 'unchanged' }
|
|
97
|
+
| { readonly status: 'rejected'; readonly reason: BridgeRejection };
|
|
98
|
+
|
|
99
|
+
export type PauseChange =
|
|
100
|
+
| { readonly scope: 'host'; readonly reason: 'hover' | 'focus' | 'document-hidden' | 'window-blur'; readonly active: boolean }
|
|
101
|
+
/** Island navigation (swipe/drag) is reported as `gesture` on the current record. */
|
|
102
|
+
| { readonly scope: 'notification'; readonly handle: NotificationHandle; readonly reason: 'gesture' | 'content-transition'; readonly active: boolean };
|
|
103
|
+
|
|
104
|
+
export type RendererCloseReason = Extract<CloseReason, 'close-button' | 'swipe' | 'navigation'>;
|
|
105
|
+
|
|
106
|
+
export type ActionResult =
|
|
107
|
+
| { readonly status: 'started' }
|
|
108
|
+
| { readonly status: 'rejected'; readonly reason: BridgeRejection | 'no-command' | 'already-pending' };
|
|
109
|
+
|
|
110
|
+
export type RetryOperationResult =
|
|
111
|
+
| { readonly status: 'started'; readonly token: OperationAttemptToken }
|
|
112
|
+
| { readonly status: 'rejected'; readonly reason: BridgeRejection | 'not-retryable' | 'already-pending' | 'no-operation' };
|
|
113
|
+
|
|
114
|
+
export type CancelOperationResult =
|
|
115
|
+
| { readonly status: 'requested' }
|
|
116
|
+
| { readonly status: 'unchanged'; readonly reason: 'already-requested' | 'settled' }
|
|
117
|
+
| { readonly status: 'rejected'; readonly reason: BridgeRejection | 'not-cancellable' | 'no-operation' };
|
|
118
|
+
|
|
119
|
+
export interface RendererBridge<Slot = never> {
|
|
120
|
+
/** Immutable presentation fallback; user options remain controller-owned. */
|
|
121
|
+
readonly renderError: string;
|
|
122
|
+
/** A rejected portal has no lease. This reports without acquiring host ownership. */
|
|
123
|
+
readonly reportInvalidContainer: (message: string, error?: unknown) => void;
|
|
124
|
+
readonly attach: (options?: HostOptions) => AttachResult;
|
|
125
|
+
readonly detach: (lease: HostLease) => BridgeResult;
|
|
126
|
+
readonly getSnapshot: () => RendererSnapshot<Slot>;
|
|
127
|
+
readonly getServerSnapshot: () => RendererSnapshot<Slot>;
|
|
128
|
+
readonly subscribe: (listener: () => void) => Unsubscribe;
|
|
129
|
+
readonly onEvent: (listener: (event: SemanticEvent) => void) => Unsubscribe;
|
|
130
|
+
/** Without handle current becomes the top record. When already open only current changes. */
|
|
131
|
+
readonly openIsland: (lease: HostLease, reason: IslandReason, handle?: NotificationHandle) => BridgeResult;
|
|
132
|
+
readonly collapseIsland: (lease: HostLease) => BridgeResult;
|
|
133
|
+
/** Overrides ControllerOptions.autoDismiss while attached; undefined restores it. */
|
|
134
|
+
readonly setAutoDismiss: (lease: HostLease, value?: boolean) => BridgeResult;
|
|
135
|
+
readonly navigate: (lease: HostLease, handle: NotificationHandle) => BridgeResult;
|
|
136
|
+
readonly setPause: (lease: HostLease, change: PauseChange) => BridgeResult;
|
|
137
|
+
readonly setFocused: (lease: HostLease, handle: NotificationHandle | null) => BridgeResult;
|
|
138
|
+
readonly beginPresentation: (lease: HostLease, handle: NotificationHandle, previous: PresentationToken) =>
|
|
139
|
+
| { readonly status: 'started'; readonly token: PresentationToken }
|
|
140
|
+
| { readonly status: 'rejected'; readonly reason: BridgeRejection };
|
|
141
|
+
readonly acknowledgePresentation: (lease: HostLease, handle: NotificationHandle, token: PresentationToken) => BridgeResult;
|
|
142
|
+
readonly acknowledgeFocus: (lease: HostLease, token: FocusRequestToken, outcome: 'focused' | 'unavailable') => BridgeResult;
|
|
143
|
+
readonly acknowledgeOverflow: (lease: HostLease) => BridgeResult;
|
|
144
|
+
readonly acknowledgeAnnouncements: (lease: HostLease, acknowledgements: readonly AnnouncementAcknowledgement[]) => BridgeResult;
|
|
145
|
+
readonly dismiss: (lease: HostLease, handle: NotificationHandle, reason: RendererCloseReason) => MutationResult | { readonly status: 'rejected'; readonly reason: 'stale-lease' };
|
|
146
|
+
readonly invokeAction: (lease: HostLease, handle: NotificationHandle) => ActionResult;
|
|
147
|
+
readonly retryOperation: (lease: HostLease, handle: NotificationHandle, expected: OperationAttemptToken) => RetryOperationResult;
|
|
148
|
+
readonly cancelOperation: (lease: HostLease, handle: NotificationHandle, expected: OperationAttemptToken, reason?: unknown) => CancelOperationResult;
|
|
149
|
+
readonly reportDiagnostic: (lease: HostLease, diagnostic: Diagnostic) => BridgeResult;
|
|
150
|
+
}
|