@cloudlet/toast 0.0.0-stage → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +271 -0
- package/LICENSE +21 -0
- package/README.md +65 -2
- package/THIRD_PARTY_NOTICES.md +149 -0
- package/dist/contracts/controller.d.ts +71 -0
- package/dist/contracts/controller.d.ts.map +1 -0
- package/dist/contracts/events.d.ts +72 -0
- package/dist/contracts/events.d.ts.map +1 -0
- package/dist/contracts/identity.d.ts +32 -0
- package/dist/contracts/identity.d.ts.map +1 -0
- package/dist/contracts/internal.d.ts +188 -0
- package/dist/contracts/internal.d.ts.map +1 -0
- package/dist/contracts/notifications.d.ts +101 -0
- package/dist/contracts/notifications.d.ts.map +1 -0
- package/dist/contracts/operations.d.ts +76 -0
- package/dist/contracts/operations.d.ts.map +1 -0
- package/dist/contracts/snapshots.d.ts +48 -0
- package/dist/contracts/snapshots.d.ts.map +1 -0
- package/dist/core/bridge.d.ts +5 -0
- package/dist/core/bridge.d.ts.map +1 -0
- package/dist/core/bridge.js +277 -0
- package/dist/core/bridge.js.map +1 -0
- package/dist/core/controller.d.ts +117 -0
- package/dist/core/controller.d.ts.map +1 -0
- package/dist/core/controller.js +787 -0
- package/dist/core/controller.js.map +1 -0
- package/dist/core/validation.d.ts +17 -0
- package/dist/core/validation.d.ts.map +1 -0
- package/dist/core/validation.js +298 -0
- package/dist/core/validation.js.map +1 -0
- package/dist/create-cloudlet.d.ts +5 -0
- package/dist/create-cloudlet.d.ts.map +1 -0
- package/dist/create-cloudlet.js +34 -0
- package/dist/create-cloudlet.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/react/announcer.d.ts +15 -0
- package/dist/react/announcer.d.ts.map +1 -0
- package/dist/react/announcer.js +140 -0
- package/dist/react/announcer.js.map +1 -0
- package/dist/react/bindings.d.ts +17 -0
- package/dist/react/bindings.d.ts.map +1 -0
- package/dist/react/bindings.js +47 -0
- package/dist/react/bindings.js.map +1 -0
- package/dist/react/card.d.ts +58 -0
- package/dist/react/card.d.ts.map +1 -0
- package/dist/react/card.js +300 -0
- package/dist/react/card.js.map +1 -0
- package/dist/react/generators.d.ts +46 -0
- package/dist/react/generators.d.ts.map +1 -0
- package/dist/react/generators.js +115 -0
- package/dist/react/generators.js.map +1 -0
- package/dist/react/gestures.d.ts +50 -0
- package/dist/react/gestures.d.ts.map +1 -0
- package/dist/react/gestures.js +239 -0
- package/dist/react/gestures.js.map +1 -0
- package/dist/react/host.d.ts +37 -0
- package/dist/react/host.d.ts.map +1 -0
- package/dist/react/host.js +816 -0
- package/dist/react/host.js.map +1 -0
- package/dist/react/motion.d.ts +206 -0
- package/dist/react/motion.d.ts.map +1 -0
- package/dist/react/motion.js +414 -0
- package/dist/react/motion.js.map +1 -0
- package/dist/react/plan.d.ts +45 -0
- package/dist/react/plan.d.ts.map +1 -0
- package/dist/react/plan.js +58 -0
- package/dist/react/plan.js.map +1 -0
- package/dist/react/renderer.d.ts +7 -0
- package/dist/react/renderer.d.ts.map +1 -0
- package/dist/react/renderer.js +62 -0
- package/dist/react/renderer.js.map +1 -0
- package/dist/react/shape.d.ts +7 -0
- package/dist/react/shape.d.ts.map +1 -0
- package/dist/react/shape.js +21 -0
- package/dist/react/shape.js.map +1 -0
- package/dist/react/viewport.d.ts +15 -0
- package/dist/react/viewport.d.ts.map +1 -0
- package/dist/react/viewport.js +16 -0
- package/dist/react/viewport.js.map +1 -0
- package/dist/react.d.ts +176 -0
- package/dist/react.d.ts.map +1 -0
- package/dist/react.js +2 -0
- package/dist/styles.css +1 -0
- package/package.json +19 -4
- package/src/contracts/controller.ts +61 -0
- package/src/contracts/events.ts +48 -0
- package/src/contracts/identity.ts +27 -0
- package/src/contracts/internal.ts +150 -0
- package/src/contracts/notifications.ts +104 -0
- package/src/contracts/operations.ts +71 -0
- package/src/contracts/snapshots.ts +59 -0
- package/src/core/bridge.ts +280 -0
- package/src/core/controller.ts +853 -0
- package/src/core/validation.ts +290 -0
- package/src/create-cloudlet.ts +43 -0
- package/src/index.ts +34 -0
- package/src/react/announcer.ts +198 -0
- package/src/react/bindings.tsx +56 -0
- package/src/react/card.tsx +222 -0
- package/src/react/generators.ts +274 -0
- package/src/react/gestures.ts +296 -0
- package/src/react/host.tsx +953 -0
- package/src/react/motion.ts +484 -0
- package/src/react/plan.ts +101 -0
- package/src/react/renderer.tsx +77 -0
- package/src/react/shape.ts +33 -0
- package/src/react/viewport.ts +10 -0
- package/src/react.ts +190 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { getRendererBridge as e } from "../core/bridge.js";
|
|
2
|
+
import { Host as t } from "./host.js";
|
|
3
|
+
import { useEffect as n, useRef as r, useState as i, useSyncExternalStore as a } from "react";
|
|
4
|
+
import { Fragment as o, jsx as s, jsxs as c } from "react/jsx-runtime";
|
|
5
|
+
import { createPortal as l } from "react-dom";
|
|
6
|
+
//#region src/react/renderer.tsx
|
|
7
|
+
var u = () => () => {}, d = () => !0, f = () => !1;
|
|
8
|
+
function p({ controller: p, options: m }) {
|
|
9
|
+
let h = a(u, d, f), g = e(p), _ = a(g.subscribe, g.getSnapshot, g.getServerSnapshot), v = r(null), [y, b] = i(null);
|
|
10
|
+
n(() => {
|
|
11
|
+
if (!h || !v.current) return;
|
|
12
|
+
let e = v.current.ownerDocument, t;
|
|
13
|
+
try {
|
|
14
|
+
let n = (typeof m.container == "function" ? m.container() : m.container) ?? e.body;
|
|
15
|
+
if (!n || n.nodeType !== 1 || n.ownerDocument !== e || n.namespaceURI !== "http://www.w3.org/1999/xhtml" || !n.isConnected || n.getRootNode().nodeType === 11) {
|
|
16
|
+
g.reportInvalidContainer("Toaster container must be a connected HTML Element in the mounting document, outside Shadow DOM");
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
t = n;
|
|
20
|
+
} catch (e) {
|
|
21
|
+
g.reportInvalidContainer("Toaster container resolver failed", e);
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
let n = m.attention?.delay, r = g.attach(n === void 0 ? void 0 : { attentionDelay: n }), i = r.status === "rejected" && r.reason === "invalid-input";
|
|
25
|
+
if (i && (r = g.attach()), r.status !== "attached") return;
|
|
26
|
+
i && g.reportDiagnostic(r.lease, {
|
|
27
|
+
code: "invalid-input",
|
|
28
|
+
source: "Toaster.attention",
|
|
29
|
+
message: "attention.delay must be a finite nonnegative number of milliseconds"
|
|
30
|
+
});
|
|
31
|
+
let a = {
|
|
32
|
+
controller: p,
|
|
33
|
+
lease: r.lease,
|
|
34
|
+
container: t,
|
|
35
|
+
document: e
|
|
36
|
+
};
|
|
37
|
+
return x(a.lease, !1), b(a), () => {
|
|
38
|
+
g.detach(a.lease);
|
|
39
|
+
};
|
|
40
|
+
}, [p, h]);
|
|
41
|
+
function x(e, t) {
|
|
42
|
+
let n = m.autoDismiss, r = n === void 0 || typeof n == "boolean";
|
|
43
|
+
g.setAutoDismiss(e, r ? n : void 0), !r && t && g.reportDiagnostic(e, {
|
|
44
|
+
code: "invalid-input",
|
|
45
|
+
source: "Toaster.autoDismiss",
|
|
46
|
+
message: "autoDismiss must be a boolean"
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
return n(() => {
|
|
50
|
+
y && x(y.lease, !0);
|
|
51
|
+
}, [y, m.autoDismiss]), h ? /* @__PURE__ */ c(o, { children: [/* @__PURE__ */ s("template", { ref: v }), y?.controller === p && !_.disposed ? l(/* @__PURE__ */ s(t, {
|
|
52
|
+
bridge: g,
|
|
53
|
+
lease: y.lease,
|
|
54
|
+
snapshot: _,
|
|
55
|
+
options: m,
|
|
56
|
+
document: y.document
|
|
57
|
+
}, y.lease), y.container) : null] }) : null;
|
|
58
|
+
}
|
|
59
|
+
//#endregion
|
|
60
|
+
export { p as AttachedToaster };
|
|
61
|
+
|
|
62
|
+
//# sourceMappingURL=renderer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renderer.js","names":["_Fragment","subscribeMount","clientMounted","serverMounted","AttachedToaster","mounted","useSyncExternalStore","bridge","getRendererBridge","controller","snapshot","marker","useRef","attachment","setAttachment","useState","ownerDocument","container","candidate","options","error","delay","attached","invalidDelay","current","applyAutoDismiss","value","valid","lease","report","useEffect","Fragment","createPortal","Host"],"sources":["../../src/react/renderer.tsx"],"sourcesContent":["import { useEffect, useRef, useState, useSyncExternalStore } from 'react';\nimport type { ReactElement } from 'react';\nimport { createPortal } from 'react-dom';\nimport { getRendererBridge } from '../core/bridge.js';\nimport type { HostLease } from '../contracts/internal.js';\nimport type { ReactCloudletController, ToasterProps } from '../react.js';\nimport { Host } from './host.js';\n\n// The renderer chunk: Toaster in bindings.tsx loads this module on the client once, after mount.\nconst subscribeMount = () => () => {};\nconst clientMounted = () => true;\nconst serverMounted = () => false;\n\ninterface Attachment {\n readonly controller: ReactCloudletController;\n readonly lease: HostLease;\n readonly container: Element;\n readonly document: Document;\n}\n\nexport function AttachedToaster({ controller, options }: { controller: ReactCloudletController; options: ToasterProps }): ReactElement | null {\n // React supplies the server value during hydration, then the client value.\n // The inert marker can therefore identify the owner document without a store\n // or effect whose only purpose is an extra mounting render.\n const mounted = useSyncExternalStore(subscribeMount, clientMounted, serverMounted);\n const bridge = getRendererBridge(controller);\n const snapshot = useSyncExternalStore(bridge.subscribe, bridge.getSnapshot, bridge.getServerSnapshot);\n const marker = useRef<HTMLTemplateElement>(null);\n const [attachment, setAttachment] = useState<Attachment | null>(null);\n useEffect(() => {\n if (!mounted || !marker.current) return;\n const ownerDocument = marker.current.ownerDocument;\n let container: Element;\n try {\n const requested = typeof options.container === 'function' ? options.container() : options.container;\n const candidate = requested ?? ownerDocument.body;\n // nodeType/ownerDocument also work when the mounting React root is in another realm.\n if (!candidate || candidate.nodeType !== 1 || candidate.ownerDocument !== ownerDocument\n || candidate.namespaceURI !== 'http://www.w3.org/1999/xhtml' || !candidate.isConnected\n || candidate.getRootNode().nodeType === 11) {\n bridge.reportInvalidContainer('Toaster container must be a connected HTML Element in the mounting document, outside Shadow DOM');\n return;\n }\n container = candidate;\n } catch (error) {\n bridge.reportInvalidContainer('Toaster container resolver failed', error);\n return;\n }\n const delay = options.attention?.delay;\n let attached = bridge.attach(delay === undefined ? undefined : { attentionDelay: delay });\n // An invalid delay must not suppress the host: fall back to the controller default and report it.\n const invalidDelay = attached.status === 'rejected' && attached.reason === 'invalid-input';\n if (invalidDelay) attached = bridge.attach();\n if (attached.status !== 'attached') return;\n if (invalidDelay) bridge.reportDiagnostic(attached.lease, { code: 'invalid-input', source: 'Toaster.attention',\n message: 'attention.delay must be a finite nonnegative number of milliseconds' });\n const current = { controller, lease: attached.lease, container, document: ownerDocument };\n applyAutoDismiss(current.lease, false);\n setAttachment(current);\n return () => { bridge.detach(current.lease); };\n // Container and attention delay are fixed for this attachment; changing them requires remount.\n }, [controller, mounted]);\n // Applied before the first presentation, then whenever the prop changes (which reports an invalid value once).\n function applyAutoDismiss(lease: HostLease, report: boolean) {\n const value = options.autoDismiss;\n const valid = value === undefined || typeof value === 'boolean';\n bridge.setAutoDismiss(lease, valid ? value : undefined);\n if (!valid && report) bridge.reportDiagnostic(lease, { code: 'invalid-input', source: 'Toaster.autoDismiss',\n message: 'autoDismiss must be a boolean' });\n }\n useEffect(() => { if (attachment) applyAutoDismiss(attachment.lease, true); }, [attachment, options.autoDismiss]);\n\n if (!mounted) return null;\n return <><template ref={marker} />{attachment?.controller === controller && !snapshot.disposed\n ? createPortal(<Host key={attachment.lease} bridge={bridge} lease={attachment.lease} snapshot={snapshot}\n options={options} document={attachment.document} />, attachment.container) : null}</>;\n}\n"],"mappings":";;;;;;AASA,IAAMC,gBAA6B,CAAC,GAC9BC,UAAsB,IACtBC,UAAsB;AAS5B,SAAgBC,EAAgB,EAAE,eAAY,cAAgG;CAI5I,IAAMC,IAAUC,EAAqBL,GAAgBC,GAAeC,CAAa,GAC3EI,IAASC,EAAkBC,CAAU,GACrCC,IAAWJ,E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AEtD,AADAnB,EAAO,eAAeqB,GAAOD,IAAQD,IAAQ,KAAA,CAAS,GAClD,CAACC,KAASE,KAAQtB,EAAO,iBAAiBqB,GAAO;GAAE,MAAM;GAAiB,QAAQ;GACpF,SAAS;EAAgC,CAAC;CAC9C;CAIA,OAHAE,QAAgB;EAAE,AAAIjB,KAAYY,EAAiBZ,EAAW,OAAO,EAAI;CAAG,GAAG,CAACA,GAAYM,EAAQ,WAAW,CAAC,GAE3Gd,IACE,kBAAAL,GAAA,EAAA,UAAA,CAAE,kBAAC,YAAD,EAAU,KAAKW,EAAS,CAAA,GAAEE,GAAY,eAAeJ,KAAc,CAACC,EAAS,WAClFsB,EAAa,kBAACC,GAAD;EAAqC;EAAQ,OAAOpB,EAAW;EAAiB;EACpF;EAAS,UAAUA,EAAW;CAAW,GAD1BA,EAAW,KACe,GAAGA,EAAW,SAAS,IAAI,IAAO,EAAA,CAAA,IAHnE;AAIvB"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One whole rounded rectangle, the only silhouette of the pill and the Island.
|
|
3
|
+
* The same string feeds the SVG background `d` and the HTML `clip-path: path()`.
|
|
4
|
+
* Invalid or negative sizes collapse to zero; the radius never exceeds half a side.
|
|
5
|
+
*/
|
|
6
|
+
export declare function createRoundedRectPath(width: number, height: number, radius: number, x?: number, y?: number): string;
|
|
7
|
+
//# sourceMappingURL=shape.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shape.d.ts","sourceRoot":"","sources":["../../src/react/shape.ts"],"names":[],"mappings":"AAKA;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,SAAI,EAAE,CAAC,SAAI,GAAG,MAAM,CAsBzG"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
//#region src/react/shape.ts
|
|
2
|
+
var e = (e) => Number.isFinite(e) ? Math.max(0, e) : 0, t = (e) => String(Math.round(e * 1e3) / 1e3), n = .5522847498;
|
|
3
|
+
function r(r, i, a, o = 0, s = 0) {
|
|
4
|
+
let c = e(r), l = e(i), u = Math.min(e(a), c / 2, l / 2), d = Number.isFinite(o) ? o : 0, f = Number.isFinite(s) ? s : 0, p = d + c, m = f + l, h = u * n, g = (e, n) => `${t(e)} ${t(n)}`;
|
|
5
|
+
return [
|
|
6
|
+
`M ${g(d + u, f)}`,
|
|
7
|
+
`L ${g(p - u, f)}`,
|
|
8
|
+
`C ${g(p - u + h, f)} ${g(p, f + u - h)} ${g(p, f + u)}`,
|
|
9
|
+
`L ${g(p, m - u)}`,
|
|
10
|
+
`C ${g(p, m - u + h)} ${g(p - u + h, m)} ${g(p - u, m)}`,
|
|
11
|
+
`L ${g(d + u, m)}`,
|
|
12
|
+
`C ${g(d + u - h, m)} ${g(d, m - u + h)} ${g(d, m - u)}`,
|
|
13
|
+
`L ${g(d, f + u)}`,
|
|
14
|
+
`C ${g(d, f + u - h)} ${g(d + u - h, f)} ${g(d + u, f)}`,
|
|
15
|
+
"Z"
|
|
16
|
+
].join(" ");
|
|
17
|
+
}
|
|
18
|
+
//#endregion
|
|
19
|
+
export { r as createRoundedRectPath };
|
|
20
|
+
|
|
21
|
+
//# sourceMappingURL=shape.js.map
|
|
@@ -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,MAAMD,IAAQ,GAAI,IAAI,GAAI,GAElEE,IAAQ;AAOd,SAAgBC,EAAsB,GAAe,GAAgB,GAAgB,IAAI,GAAG,IAAI,GAAW;CACzG,IAAMC,IAAIL,EAAOM,CAAK,GAChBC,IAAIP,EAAOQ,CAAM,GACjBC,IAAI,KAAK,IAAIT,EAAOU,CAAM,GAAGL,IAAI,GAAGE,IAAI,CAAC,GACzCI,IAAO,OAAO,SAASC,CAAC,IAAIA,IAAI,GAChCC,IAAM,OAAO,SAASC,CAAC,IAAIA,IAAI,GAC/BC,IAAQJ,IAAON,GACfW,IAASH,IAAMN,GACfU,IAAIR,IAAIN,GACRe,KAAK,GAAY,MAAe,GAAGhB,EAAOiB,CAAE,EAAE,GAAGjB,EAAOkB,CAAE;CAChE,OAAO;EACL,KAAKF,EAAEP,IAAOF,GAAGI,CAAG;EACpB,KAAKK,EAAEH,IAAQN,GAAGI,CAAG;EACrB,KAAKK,EAAEH,IAAQN,IAAIQ,GAAGJ,CAAG,EAAE,GAAGK,EAAEH,GAAOF,IAAMJ,IAAIQ,CAAC,EAAE,GAAGC,EAAEH,GAAOF,IAAMJ,CAAC;EACvE,KAAKS,EAAEH,GAAOC,IAASP,CAAC;EACxB,KAAKS,EAAEH,GAAOC,IAASP,IAAIQ,CAAC,EAAE,GAAGC,EAAEH,IAAQN,IAAIQ,GAAGD,CAAM,EAAE,GAAGE,EAAEH,IAAQN,GAAGO,CAAM;EAChF,KAAKE,EAAEP,IAAOF,GAAGO,CAAM;EACvB,KAAKE,EAAEP,IAAOF,IAAIQ,GAAGD,CAAM,EAAE,GAAGE,EAAEP,GAAMK,IAASP,IAAIQ,CAAC,EAAE,GAAGC,EAAEP,GAAMK,IAASP,CAAC;EAC7E,KAAKS,EAAEP,GAAME,IAAMJ,CAAC;EACpB,KAAKS,EAAEP,GAAME,IAAMJ,IAAIQ,CAAC,EAAE,GAAGC,EAAEP,IAAOF,IAAIQ,GAAGJ,CAAG,EAAE,GAAGK,EAAEP,IAAOF,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 the motion system. */
|
|
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: 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: replaces the motion 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; 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 './react/bindings.js';
|
|
176
|
+
//# sourceMappingURL=react.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react.d.ts","sourceRoot":"","sources":["../src/react.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACrD,OAAO,KAAK,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACpG,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AACxF,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAClG,OAAO,KAAK,EAAE,kBAAkB,EAAE,oB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AAE,aAAa,CAAC;IAChC,kHAAkH;IAClH,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC,CAAC;CAC7D;AAED,4CAA4C;AAC5C,MAAM,MAAM,yBAAyB,GAAG,CAAC,KAAK,EAAE,qBAAqB,KAAK,YAAY,GAAG,IAAI,CAAC;AAC9F,MAAM,MAAM,WAAW,GAAG,MAAM,uBAAuB,CAAC;AACxD,MAAM,MAAM,mBAAmB,GAAG,MAAM,uBAAuB,GAAG,IAAI,CAAC;AACvE,MAAM,MAAM,gBAAgB,GAAG,CAAC,KAAK,EAAE,YAAY,KAAK,YAAY,GAAG,IAAI,CAAC;AAE5E,YAAY,EAAE,kBAAkB,EAAE,WAAW,EAAE,kBAAkB,EAAE,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,mBAAmB,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC"}
|
package/dist/react.js
ADDED
package/dist/styles.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.cloudlet-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,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudlet/toast",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Cloudlet notifications and async operations with an SSR-safe React renderer",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"homepage": "https://cloudlet.dev/toaster",
|
|
7
|
+
"repository": { "type": "git", "url": "git+https://github.com/Meerzus/cloudlet.git", "directory": "packages/toast" },
|
|
8
|
+
"bugs": "https://github.com/Meerzus/cloudlet/issues",
|
|
9
|
+
"keywords": ["react", "notifications", "toast", "snackbar", "accessibility", "async", "operations", "ssr"],
|
|
10
|
+
"publishConfig": { "access": "public", "tag": "latest" },
|
|
11
|
+
"type": "module",
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"exports": {
|
|
14
|
+
".": { "types": "./dist/index.d.ts", "import": "./dist/index.js", "default": "./dist/index.js" },
|
|
15
|
+
"./styles.css": "./dist/styles.css"
|
|
16
|
+
},
|
|
17
|
+
"files": ["dist", "src/**/*.ts", "src/**/*.tsx", "LICENSE", "THIRD_PARTY_NOTICES.md", "README.md", "CHANGELOG.md"],
|
|
18
|
+
"sideEffects": ["**/*.css"],
|
|
19
|
+
"peerDependencies": { "react": "^18.2.0 || ^19.0.0", "react-dom": "^18.2.0 || ^19.0.0" },
|
|
20
|
+
"scripts": { "build": "vite build && tsc -p tsconfig.build.json" }
|
|
21
|
+
}
|
|
@@ -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,48 @@
|
|
|
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
|
+
| 'renderer-load-error';
|
|
17
|
+
|
|
18
|
+
export interface Diagnostic {
|
|
19
|
+
readonly code: DiagnosticCode;
|
|
20
|
+
readonly source: string;
|
|
21
|
+
readonly message: string;
|
|
22
|
+
readonly handle?: NotificationHandle;
|
|
23
|
+
readonly error?: unknown;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface EventBase {
|
|
27
|
+
readonly controller: ControllerIdentity;
|
|
28
|
+
readonly sequence: number;
|
|
29
|
+
/** Monotonic milliseconds, not wall-clock time. */
|
|
30
|
+
readonly at: number;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export type SemanticEvent = EventBase & (
|
|
34
|
+
| { readonly type: 'admitted'; readonly handle: NotificationHandle }
|
|
35
|
+
| { readonly type: 'deduplicated'; readonly handle: NotificationHandle; readonly occurrences: number }
|
|
36
|
+
| { readonly type: 'updated'; readonly handle: NotificationHandle }
|
|
37
|
+
| { readonly type: 'closed'; readonly handle: NotificationHandle; readonly reason: CloseReason }
|
|
38
|
+
| { readonly type: 'presented'; readonly handle: NotificationHandle; readonly firstPresentation: boolean }
|
|
39
|
+
| { readonly type: 'operation-started'; readonly handle: NotificationHandle | null; readonly token: OperationAttemptToken; readonly attempt: number }
|
|
40
|
+
| { readonly type: 'operation-settled'; readonly handle: NotificationHandle | null; readonly token: OperationAttemptToken; readonly status: Exclude<OperationStatus, 'pending'>; readonly uiApplied: boolean }
|
|
41
|
+
| { readonly type: 'cancellation-requested'; readonly handle: NotificationHandle | null; readonly token: OperationAttemptToken }
|
|
42
|
+
| { readonly type: 'action-started'; readonly handle: NotificationHandle; readonly token: ActionAttemptToken }
|
|
43
|
+
| { readonly type: 'action-failed'; readonly handle: NotificationHandle; readonly token: ActionAttemptToken; readonly message: string }
|
|
44
|
+
| { readonly type: 'overflow'; readonly count: number }
|
|
45
|
+
| { readonly type: 'overflow-acknowledged'; readonly count: number }
|
|
46
|
+
| { readonly type: 'diagnostic'; readonly diagnostic: Diagnostic }
|
|
47
|
+
| { readonly type: 'disposed' }
|
|
48
|
+
);
|
|
@@ -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
|
+
}
|